diff --git a/instances/templates/instances/instance_form.html b/instances/templates/instances/instance_form.html
new file mode 100644
index 00000000..1581245b
--- /dev/null
+++ b/instances/templates/instances/instance_form.html
@@ -0,0 +1,37 @@
+
+ {% load material_form %}
+
Instance config
+
+
\ No newline at end of file
diff --git a/instances/templates/instances/instances.html b/instances/templates/instances/instances.html
index 93fc5453..734dc30d 100644
--- a/instances/templates/instances/instances.html
+++ b/instances/templates/instances/instances.html
@@ -21,44 +21,8 @@
{% endfor %}
{% endif %}
-
- {% load material_form %}
-
Instance config
-
+ {% include "instances/instance_form.html" %}
-
@@ -90,6 +54,8 @@
Server instances
+ |
+
|
{% endif %}
@@ -134,5 +100,16 @@ Server instances
$('tr#row'+el.id.replace('delete','')).remove();
});
}
+ function edit(el, name) {
+ //el.disabled = true;
+ $.post("/instances/"+name+"/edit", function(html) {
+ $('div#config_card').replaceWith(html);
+ $('button#create_instance').text('Save Changes')
+ $('.collapsible').collapsible();
+ $('form[name=instance_form]').attr('action', 'edit_instance')
+
+ })
+
+ }
{% endblock %}
diff --git a/instances/urls.py b/instances/urls.py
index c52478f5..fa2b5f93 100644
--- a/instances/urls.py
+++ b/instances/urls.py
@@ -5,10 +5,12 @@
urlpatterns = [
path('', views.index, name='instances'),
path('start', views.create, name='start'),
- path('/', views.instance, name='instance'),
+ path('edit_instance', views.edit_instance, name='edit_instance'),
+ path('/', views.instance, name='instance'),
path('/start', views.start, name='start'),
path('/stop', views.stop, name='stop'),
path('/delete', views.delete, name='delete'),
+ path('/edit', views.edit, name='edit'),
path('/stderr', views.stderr, name='stderr'),
path('/stdout', views.stdout, name='stdout'),
path('/serverlog', views.serverlog, name='serverlog'),
diff --git a/instances/views.py b/instances/views.py
index 7c051086..15c0a356 100644
--- a/instances/views.py
+++ b/instances/views.py
@@ -196,6 +196,14 @@ def render_from(request, form):
}
return HttpResponse(template.render(context, request))
+#TODO: change name to better suit this
+def render_settings(request, form):
+ template = loader.get_template('instances/instance_form.html')
+ context = {
+ 'form': form,
+ 'executors': executors
+ }
+ return HttpResponse(template.render(context, request))
def write_config(name, inst_dir, form):
### use the values of the default *.json as basis
@@ -291,7 +299,7 @@ def random_word():
return s
-def index(request):
+def index(request, name=None):
# read defaults from files
cfg = json.load(open(os.path.join(
settings.ACCSERVER, 'cfg', 'configuration.json'), 'r', encoding='utf-16'))
@@ -325,3 +333,23 @@ def index(request):
return render_from(request, InstanceForm(cfg))
+@login_required
+def edit(request, name):
+
+ cfg = json.load(open(os.path.join(
+ settings.DATA_DIR, 'instances', name, 'cfg', 'configuration.json'), 'r', encoding='utf-16'
+ ))
+ cfg.update(json.load(open(os.path.join(
+ settings.DATA_DIR, 'instances', name, 'cfg', 'settings.json'), 'r', encoding='utf-16')))
+ cfg.update(json.load(open(os.path.join(
+ settings.DATA_DIR, 'instances', name, 'cfg', 'assistRules.json'), 'r', encoding='utf-16')))
+ cfg.update(json.load(open(os.path.join(
+ settings.DATA_DIR, 'instances', name, 'cfg', 'eventRules.json'), 'r', encoding='utf-16')))
+
+ cfg['instanceName'] = name
+ return render_settings(request, InstanceForm(cfg))
+
+@login_required
+def edit_instance(request, name):
+ #TODO: basic methodology - validate config, stop running instance, unlink/delete exiting config dirs, call create method, restart server
+ pass
\ No newline at end of file