diff --git a/server/src/uds/REST/methods/transports.py b/server/src/uds/REST/methods/transports.py index b1394e230..74653c315 100644 --- a/server/src/uds/REST/methods/transports.py +++ b/server/src/uds/REST/methods/transports.py @@ -56,11 +56,11 @@ class Transports(ModelHandlerMixin, Handler): 'comments': item.comments, 'priority': item.priority, 'nets_positive': item.nets_positive, + 'networks': [ {'id': k.id} for k in item.networks.all() ], 'deployed_count': item.deployedServices.count(), 'type': type_.type(), } - class Types(ModelTypeHandlerMixin, Handler): path = 'transports' @@ -78,7 +78,7 @@ class Types(ModelTypeHandlerMixin, Handler): 'label': ugettext('Priority'), 'tooltip': ugettext('Priority of this transport'), 'type': 'numeric', - 'order': 100, # At end + 'order': -50, # At end }) except: raise NotFound('type not found') diff --git a/server/src/uds/REST/mixins.py b/server/src/uds/REST/mixins.py index a97335831..e9faf6fc6 100644 --- a/server/src/uds/REST/mixins.py +++ b/server/src/uds/REST/mixins.py @@ -226,7 +226,7 @@ class ModelTypeHandlerMixin(object): 'required': True, 'label': _('Name'), 'tooltip': _('Name of this element'), - 'order': -2, + 'order': -100, }) # And maybe comments (only if model has this field) if 'comments' in flds: @@ -235,7 +235,7 @@ class ModelTypeHandlerMixin(object): 'label': _('Comments'), 'tooltip': _('Comments for this element'), 'length': 256, - 'order': -1, + 'order': -99, }) return gui diff --git a/server/src/uds/REST/processors.py b/server/src/uds/REST/processors.py index 65bd40694..563a4b2ad 100644 --- a/server/src/uds/REST/processors.py +++ b/server/src/uds/REST/processors.py @@ -32,7 +32,7 @@ ''' from __future__ import unicode_literals -#from django.utils import simplejson +#from django.utils import simplejson as json import ujson as json from django import http diff --git a/server/src/uds/core/util/middleware/__init__.py b/server/src/uds/core/util/middleware/__init__.py index 0e73d0f6c..1c691af32 100644 --- a/server/src/uds/core/util/middleware/__init__.py +++ b/server/src/uds/core/util/middleware/__init__.py @@ -13,4 +13,4 @@ class XUACompatibleMiddleware(object): def process_response(self, request, response): if response.get('content-type', '').startswith('text/html'): response['X-UA-Compatible'] = 'IE=edge' - return response \ No newline at end of file + return response diff --git a/server/src/uds/static/adm/js/gui-definition.js b/server/src/uds/static/adm/js/gui-definition.js index 5e7cfe263..56276846a 100644 --- a/server/src/uds/static/adm/js/gui-definition.js +++ b/server/src/uds/static/adm/js/gui-definition.js @@ -145,24 +145,48 @@ gui.connectivity.link = function(event) { onEdit: function(value, event, table, refreshFnc) { gui.connectivity.transports.rest.gui(value.type, function(itemGui){ gui.connectivity.transports.rest.item(value.id, function(item) { - var form = gui.form.fromFields(itemGui, item); - gui.launchModalForm(gettext('Edit transport')+' '+value.name,form, function(form_selector, closeFnc) { - var fields = gui.form.read(form_selector); - fields.data_type = value.type; - fields.nets_positive = false; - gui.connectivity.transports.rest.save(fields, function(data) { // Success on put - closeFnc(); - refreshFnc(); - }, gui.failRequestModalFnc(gettext('Error creating transport')) // Fail on put, show modal message - ); - return false; - }); + var tabs = { + tabs: [ + { + title: 'General', + fields: itemGui, + }, + { + title: 'Networks', + fields: [], + }, + ] + }; + var form = gui.form.fromFields(tabs, item); + gui.launchModalForm(gettext('Edit transport')+' '+value.name,form, function(form_selector, closeFnc) { + var fields = gui.form.read(form_selector); + fields.data_type = value.type; + fields.nets_positive = false; + gui.connectivity.transports.rest.save(fields, function(data) { // Success on put + closeFnc(); + refreshFnc(); + }, gui.failRequestModalFnc(gettext('Error creating transport')) // Fail on put, show modal message + ); + return false; }); + }); }); }, onNew: function(type, table, refreshFnc) { gui.connectivity.transports.rest.gui(type, function(itemGui) { - var form = gui.form.fromFields(itemGui); + var tabs = { + tabs: [ + { + title: 'General', + fields: itemGui, + }, + { + title: 'Networks', + fields: [], + }, + ] + }; + var form = gui.form.fromFields(tabs); gui.launchModalForm(gettext('New transport'), form, function(form_selector, closeFnc) { var fields = gui.form.read(form_selector); // Append "own" fields, in this case data_type diff --git a/server/src/uds/static/adm/js/gui-form.js b/server/src/uds/static/adm/js/gui-form.js index ccdf04367..d1d84c118 100644 --- a/server/src/uds/static/adm/js/gui-form.js +++ b/server/src/uds/static/adm/js/gui-form.js @@ -38,7 +38,16 @@ var form = '
' + ''; if( fields.tabs ) { - + var id = 'tab-' + Math.random().toString().split('.')[1]; // Get a random base ID for tab entries + var tabs = []; + var tabsContent = []; + var active = ' active in' ; + $.each(fields.tabs, function(index, tab){ + tabsContent.push('
' + gui.fieldsToHtml(tab.fields, item) + '
' ); + tabs.push('
  • ' + tab.title + '
  • ' ); + active = ''; + }); + form += '
    ' + tabsContent.join('\n') + '
    '; } else { form += gui.fieldsToHtml(fields, item, editing); } diff --git a/server/src/uds/static/adm/js/gui.js b/server/src/uds/static/adm/js/gui.js index 0486416dc..fd313ab42 100644 --- a/server/src/uds/static/adm/js/gui.js +++ b/server/src/uds/static/adm/js/gui.js @@ -119,7 +119,7 @@ }; gui.launchModalForm = function(title, form, onSuccess) { - var id = Math.random().toString().split('.')[1]; // Get a random ID for this modal + var id = 'modal-' + Math.random().toString().split('.')[1]; // Get a random ID for this modal gui.appendToWorkspace(gui.modal(id, title, form)); id = '#' + id; // for jQuery