forked from shaba/openuds
* Fixed dropdown to include icons (for "new")
* Added Os managers (client & server)
This commit is contained in:
parent
49dc0eb0c2
commit
3c956e94df
@ -32,8 +32,10 @@
|
||||
'''
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext, ugettext_lazy as _
|
||||
from uds.models import OSManager
|
||||
|
||||
from uds.REST import NotFound, RequestError
|
||||
from uds.core.osmanagers import factory
|
||||
|
||||
from uds.REST.model import ModelHandler
|
||||
@ -46,6 +48,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class OsManagers(ModelHandler):
|
||||
model = OSManager
|
||||
save_fields = ['name', 'comments']
|
||||
|
||||
table_title = _('Current OS Managers')
|
||||
table_fields = [
|
||||
@ -62,3 +65,23 @@ class OsManagers(ModelHandler):
|
||||
'type': type_.type(),
|
||||
'comments': osm.comments,
|
||||
}
|
||||
|
||||
def checkDelete(self, item):
|
||||
if item.deployedServices.count() > 0:
|
||||
raise RequestError(ugettext('Can\'t delete an OSManager with deployed services associated'))
|
||||
|
||||
def checkSave(self, item):
|
||||
if item.deployedServices.count() > 0:
|
||||
raise RequestError(ugettext('Can\'t modify an OSManager with deployed services associated'))
|
||||
|
||||
|
||||
# Types related
|
||||
def enum_types(self):
|
||||
return factory().providers().values()
|
||||
|
||||
# Gui related
|
||||
def getGui(self, type_):
|
||||
try:
|
||||
return self.addDefaultFields(factory().lookup(type_).guiDescription(), ['name', 'comments'])
|
||||
except:
|
||||
raise NotFound('type not found')
|
||||
|
@ -34,7 +34,7 @@ from __future__ import unicode_literals
|
||||
|
||||
from django.utils.translation import ugettext, ugettext_lazy as _
|
||||
from uds.models import Provider
|
||||
from services import Services
|
||||
from services import Services as DetailServices
|
||||
from uds.core import services
|
||||
|
||||
from uds.REST import NotFound, RequestError
|
||||
@ -47,7 +47,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class Providers(ModelHandler):
|
||||
model = Provider
|
||||
detail = { 'services': Services }
|
||||
detail = { 'services': DetailServices }
|
||||
save_fields = ['name', 'comments']
|
||||
|
||||
table_title = _('Service providers')
|
||||
|
@ -369,6 +369,11 @@ class ModelHandler(BaseModelHandler):
|
||||
def checkDelete(self, item):
|
||||
pass
|
||||
|
||||
# Save related, checks if the item can be saved
|
||||
# If it can't be saved, raises an exception
|
||||
def checkSave(self, item):
|
||||
pass
|
||||
|
||||
# End overridable
|
||||
|
||||
# Helper to process detail
|
||||
@ -491,6 +496,9 @@ class ModelHandler(BaseModelHandler):
|
||||
except Exception:
|
||||
raise RequestError('incorrect invocation to PUT')
|
||||
|
||||
if not deleteOnError:
|
||||
self.checkSave(item) # Will raise an exception if item can't be saved (only for modify operations..)
|
||||
|
||||
# Store associated object if needed
|
||||
try:
|
||||
if self._params.has_key('data_type'): # Needs to store instance
|
||||
|
@ -34,6 +34,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models
|
||||
from django.db import IntegrityError
|
||||
from django.db.models import signals
|
||||
from uds.core.jobs.JobsFactory import JobsFactory
|
||||
from uds.core.Environment import Environment
|
||||
@ -364,6 +365,8 @@ class OSManager(models.Model):
|
||||
:note: If destroy raises an exception, the deletion is not taken.
|
||||
'''
|
||||
toDelete = kwargs['instance']
|
||||
if toDelete.deployedServices.count() > 0:
|
||||
raise IntegrityError('Can\'t remove os managers with assigned deployed services')
|
||||
# Only tries to get instance if data is not empty
|
||||
if toDelete.data != '':
|
||||
s = toDelete.getInstance()
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 4.3 KiB |
23
server/src/uds/static/adm/js/gui-d-osmanagers.js
Normal file
23
server/src/uds/static/adm/js/gui-d-osmanagers.js
Normal file
@ -0,0 +1,23 @@
|
||||
//------------------------
|
||||
// Os managers
|
||||
//------------------------
|
||||
gui.osmanagers = new GuiElement(api.osmanagers, 'osm');
|
||||
gui.osmanagers.link = function(event) {
|
||||
"use strict";
|
||||
// Cleans up memory used by other datatables
|
||||
$.each($.fn.dataTable.fnTables(), function(undefined, tbl){
|
||||
$(tbl).dataTable().fnDestroy();
|
||||
});
|
||||
gui.clearWorkspace();
|
||||
gui.appendToWorkspace(gui.breadcrumbs('Os Managers'));
|
||||
|
||||
gui.osmanagers.table({
|
||||
rowSelect : 'single',
|
||||
buttons : [ 'new', 'edit', 'delete', 'xls' ],
|
||||
onNew : gui.methods.typedNew(gui.osmanagers, gettext('New OSManager'), gettext('Error creating OSManager')),
|
||||
onEdit: gui.methods.typedEdit(gui.osmanagers, gettext('Edit OSManager'), gettext('Error processing OSManager')),
|
||||
onDelete: gui.methods.del(gui.osmanagers, gettext('Delete OSManager'), gettext('Error deleting OSManager')),
|
||||
});
|
||||
|
||||
return false;
|
||||
};
|
@ -26,28 +26,6 @@ gui.dashboard.link = function(event) {
|
||||
};
|
||||
|
||||
|
||||
|
||||
//------------------------
|
||||
// Os managers
|
||||
//------------------------
|
||||
gui.osmanagers = new GuiElement(api.osmanagers, 'osm');
|
||||
gui.osmanagers.link = function(event) {
|
||||
"use strict";
|
||||
// Cleans up memory used by other datatables
|
||||
$.each($.fn.dataTable.fnTables(), function(undefined, tbl){
|
||||
$(tbl).dataTable().fnDestroy();
|
||||
});
|
||||
gui.clearWorkspace();
|
||||
gui.appendToWorkspace(gui.breadcrumbs('Os Managers'));
|
||||
|
||||
gui.osmanagers.table({
|
||||
rowSelect : 'single',
|
||||
buttons : [ 'edit', 'delete', 'xls' ],
|
||||
});
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
gui.connectivity = {
|
||||
transports : new GuiElement(api.transports, 'trans'),
|
||||
networks : new GuiElement(api.networks, 'nets'),
|
||||
|
@ -101,6 +101,7 @@
|
||||
<script src="{% get_static_prefix %}adm/js/gui-definition.js"></script>
|
||||
<script src="{% get_static_prefix %}adm/js/gui-d-service-providers.js"></script>
|
||||
<script src="{% get_static_prefix %}adm/js/gui-d-authenticators.js"></script>
|
||||
<script src="{% get_static_prefix %}adm/js/gui-d-osmanagers.js"></script>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
|
@ -1,6 +0,0 @@
|
||||
{% verbatim %}
|
||||
<div class="alert alert-dismissable alert-{{ type }}">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
{{ message }}
|
||||
</div>
|
||||
{% endverbatim %}
|
@ -7,7 +7,7 @@
|
||||
</button>
|
||||
<ul class="dropdown-menu" role="menu" aria-labelledby="">
|
||||
{{# each menu }}
|
||||
<li role="presentation"><a role="menuitem" tabindex="-1" data-toggle="tooltip" title="{{ description }}" href="#" data-type="{{ type }}">{{ name }}</a></li>
|
||||
<li role="presentation"><a role="menuitem" tabindex="-1" data-toggle="tooltip" title="{{ description }}" href="#" data-type="{{ type }}"><span class="{{ css }}"></span> {{ name }}</a></li>
|
||||
{{/ each }}
|
||||
</ul>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user