summaryrefslogtreecommitdiffstats
path: root/templates/instances/edit.html
blob: ef7d53ed7837dc910d069488f36c2c65955428cb (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
{% 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>
      <input type="checkbox" name="whitelist_enabled"{% if instance.whitelist_enabled %} checked{% endif %} />
      Whitelist 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>

<div class="card" style="margin-top: 1.5rem">
  <h3>Configuration Files</h3>
  <div class="meta" style="margin-bottom: 0.5rem">
    <span>Edit mod/plugin config files inside <code>config/</code></span>
  </div>
  <div class="actions">
    <a href="/instances/{{ instance.id }}/config" class="btn">Open Config Editor</a>
  </div>
</div>

<div class="card" style="margin-top: 1.5rem">
  <h3>Mods</h3>
  <div class="meta" style="margin-bottom: 0.5rem">
    <span>
      {% if instance.has_modpack %}
      <strong>{{ mod_count }}</strong> mod{% if mod_count != 1 %}s{% endif %}
      installed{% if rejected_count > 0 %} (<strong>{{ rejected_count }}</strong> rejected){% endif %}
      {% else %} No mods installed {% endif %}
    </span>
  </div>
  <div class="actions">
    <a href="/instances/{{ instance.id }}/mods" class="btn">Manage Mods</a>
  </div>
</div>
{% endblock %}