summaryrefslogtreecommitdiffstats
path: root/templates/instances/edit.html
blob: fdfc0e1beee7f6cc08b167b7aa51b6044a772ab2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
{% extends "base.html" %}
{% block content %}
<h1>Edit: {{ instance.name }}</h1>

<div class="card card-muted">
    <div class="meta">
        <span><strong>Version:</strong> {{ instance.version }}</span>
        <span><strong>Type:</strong> {{ instance.server_type }}</span>
        <span><strong>World:</strong> {{ instance.world_source }}</span>
        {% if let Some(seed) = current_seed %}
        <span><strong>Seed:</strong> {{ seed }}</span>
        {% endif %}
        {% if instance.has_modpack %}
        <span><strong>Modpack:</strong> Installed</span>
        {% endif %}
    </div>
</div>

<form action="/instances/{{ instance.id }}/edit" method="post" class="form-col">
    <fieldset>
        <legend>Server Properties</legend>
        <label>
            Memory (MB)
            <input type="number" name="memory_mb" value="{{ instance.memory_mb }}" min="512" max="{{ max_memory_mb }}" required>
        </label>
        <label>
            Difficulty
            <select name="difficulty">
                <option value="0" {% if instance.difficulty == 0 %}selected{% endif %}>Peaceful</option>
                <option value="1" {% if instance.difficulty == 1 %}selected{% endif %}>Easy</option>
                <option value="2" {% if instance.difficulty == 2 %}selected{% endif %}>Normal</option>
                <option value="3" {% if instance.difficulty == 3 %}selected{% endif %}>Hard</option>
            </select>
        </label>
        <label>
            Gamemode
            <select name="gamemode">
                <option value="0" {% if instance.gamemode == 0 %}selected{% endif %}>Survival</option>
                <option value="1" {% if instance.gamemode == 1 %}selected{% endif %}>Creative</option>
                <option value="2" {% if instance.gamemode == 2 %}selected{% endif %}>Adventure</option>
                <option value="3" {% if instance.gamemode == 3 %}selected{% endif %}>Spectator</option>
            </select>
        </label>
        <label>
            Max Players
            <input type="number" name="max_players" value="{{ instance.max_players }}" min="1" max="100">
        </label>
        <label>
            <input type="checkbox" name="pvp" {% if instance.pvp %}checked{% endif %}> PvP enabled
        </label>
        <label>
            MOTD
            <input type="text" name="motd" value="{{ instance.motd }}" maxlength="59">
        </label>
    </fieldset>

    <div class="actions">
        <button type="submit" class="btn-ok">Save Changes</button>
        <a href="/instances" class="btn">Cancel</a>
    </div>
</form>

<div class="card{% if instance.is_active %} card-muted{% endif %}" style="margin-top:1.5rem">
    <h3>World Management</h3>

    {% if instance.is_active %}
    <div class="flash flash-warn">Stop the server before managing the world.</div>
    {% endif %}

    <div class="meta" style="margin-bottom:1rem">
        <span><strong>Current seed:</strong>
            {% if let Some(seed) = current_seed %}
                {{ seed }}
            {% else %}
                <em>not yet generated</em>
            {% endif %}
        </span>
    </div>

    <div class="actions" style="flex-wrap:wrap; gap:1rem; {% if instance.is_active %}pointer-events:none; opacity:0.5{% endif %}">
        <a href="/instances/{{ instance.id }}/world/export" class="btn" hx-boost="false"{% if instance.is_active %} tabindex="-1"{% endif %}>Export World</a>

        <form action="/instances/{{ instance.id }}/world/import" method="post" enctype="multipart/form-data" style="display:flex;align-items:center;gap:0.5rem" hx-boost="false">
            <input type="file" name="world_zip" accept=".zip" required style="font-size:0.85rem"{% if instance.is_active %} disabled{% endif %}>
            <button type="submit" class="btn" onclick="return confirm('This will replace the current world. Continue?')"{% if instance.is_active %} disabled{% endif %}>Import</button>
        </form>

        <form action="/instances/{{ instance.id }}/world/regenerate" method="post" class="form-row" onsubmit="return confirm('This will DELETE the current world and generate a new one. Continue?')">
            <input type="text" name="seed" placeholder="Seed (empty = random)" style="width:180px"{% if instance.is_active %} disabled{% endif %}>
            <button type="submit" class="btn-danger"{% if instance.is_active %} disabled{% endif %}>Regenerate</button>
        </form>
    </div>
</div>
{% endblock %}