mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-22 13:34:04 +03:00
Adding "new group" functional form
This commit is contained in:
parent
b0756d8e3e
commit
83b8c474bd
@ -1,3 +1,3 @@
|
||||
eclipse.preferences.version=1
|
||||
excluded=//*.min.js\://PluginDetect_Java.js
|
||||
excluded=//*.min.js\://PluginDetect_Java.js\://handlebars*.js
|
||||
included=//*.js
|
||||
|
@ -29,7 +29,7 @@ function minify_admin() {
|
||||
'FileSaver',
|
||||
'ZeroClipboard',
|
||||
'dataTables.bootstrap',
|
||||
'handlebars-v1.1.2',
|
||||
'handlebars-v1.3.0',
|
||||
// Api
|
||||
'api',
|
||||
'api-tools',
|
||||
|
@ -37,6 +37,6 @@ from uds import REST
|
||||
|
||||
urlpatterns = patterns('uds.admin.views',
|
||||
(r'^$', 'index'),
|
||||
(r'^tmpl/(?P<template>[a-zA-Z0-9]*)$', 'tmpl'),
|
||||
(r'^tmpl/(?P<template>[a-zA-Z0-9_-]*)$', 'tmpl'),
|
||||
(r'^sample$', 'sample'),
|
||||
)
|
||||
|
@ -30,18 +30,14 @@
|
||||
'''
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden
|
||||
from django.http import HttpResponse, HttpResponseForbidden
|
||||
from django.template import RequestContext, loader
|
||||
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.shortcuts import render
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
from uds.core.auths.auth import webLoginRequired
|
||||
from uds.core.util import log
|
||||
from uds.core.util.Decorators import denyBrowsers
|
||||
from uds.web import errors
|
||||
|
||||
import logging
|
||||
|
||||
|
@ -33,6 +33,5 @@ gui.dashboard.link = function(event) {
|
||||
|
||||
});
|
||||
|
||||
gui.tools.fix3dButtons('#test');
|
||||
});
|
||||
};
|
||||
|
@ -114,7 +114,7 @@ gui.servicesPools.link = function(event) {
|
||||
/*
|
||||
* Services pools part
|
||||
*/
|
||||
var tableId = gui.servicesPools.table({
|
||||
var servicesPoolsTable = gui.servicesPools.table({
|
||||
container : 'deployed-services-placeholder',
|
||||
rowSelect : 'single',
|
||||
buttons : [ 'new', 'edit', 'delete', { text: gettext('Test'), css: 'disabled', click: testClick, select: testSelect }, 'xls' ],
|
||||
@ -184,6 +184,39 @@ gui.servicesPools.link = function(event) {
|
||||
container : 'groups-placeholder',
|
||||
rowSelect : 'single',
|
||||
buttons : [ 'new', 'delete', 'xls' ],
|
||||
onNew: function(value, event, table, refreshFnc) {
|
||||
|
||||
api.templates.get('pool_add_group', function(tmpl){
|
||||
api.authenticators.overview(function(data){
|
||||
var modalId = gui.launchModal(gettext('Add group'),api.templates.evaluate(tmpl, {
|
||||
auths: data,
|
||||
}));
|
||||
|
||||
$(modalId + ' #id_auth_select').on('change', function(event){
|
||||
var auth = $(modalId + ' #id_auth_select').val();
|
||||
|
||||
api.authenticators.detail(auth, 'groups').overview(function(data){
|
||||
var $select = $(modalId + ' #id_group_select');
|
||||
$select.empty();
|
||||
|
||||
$.each(data, function(undefined, value){
|
||||
$select.append('<option value="' + value.id + '">' + value.name + '</option>');
|
||||
});
|
||||
// Refresh selectpicker if item is such
|
||||
if($select.hasClass('selectpicker'))
|
||||
$select.selectpicker('refresh');
|
||||
});
|
||||
});
|
||||
|
||||
$(modalId + ' .button-accept').on('click', function(event) {
|
||||
alert(event);
|
||||
});
|
||||
// Makes form "beautyfull" :-)
|
||||
gui.forms.beautify(modalId);
|
||||
});
|
||||
});
|
||||
|
||||
},
|
||||
onData : function(data) {
|
||||
$.each(data, function(undefined, value){
|
||||
value.group_name = '<b>' + value.auth_name + '</b>\\' + value.name;
|
||||
|
@ -168,6 +168,20 @@
|
||||
gui.doLog(res);
|
||||
return res;
|
||||
};
|
||||
|
||||
// Beautifies a form
|
||||
gui.forms.beautify = function(formSelector) {
|
||||
// For "beauty" switches, initialize them now
|
||||
$(formSelector + ' [type="checkbox"]').bootstrapSwitch();
|
||||
// Activate "cool" selects
|
||||
$(formSelector + ' .selectpicker').selectpicker();
|
||||
// TEST: cooller on mobile devices
|
||||
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
|
||||
$(formSelector + ' .selectpicker').selectpicker('mobile');
|
||||
}
|
||||
// Activate tooltips
|
||||
$(formSelector + ' [data-toggle="tooltip"]').tooltip({delay: {show: 1000, hide: 100}, placement: 'auto right'});
|
||||
};
|
||||
|
||||
// Options has this keys:
|
||||
// title
|
||||
@ -217,16 +231,7 @@
|
||||
// Get form
|
||||
var $form = $(id + ' form');
|
||||
|
||||
// For "beauty" switches, initialize them now
|
||||
$(id + ' [type="checkbox"]').bootstrapSwitch();
|
||||
// Activate "cool" selects
|
||||
$(id + ' .selectpicker').selectpicker();
|
||||
// TEST: cooller on mobile devices
|
||||
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
|
||||
$(id + ' .selectpicker').selectpicker('mobile');
|
||||
}
|
||||
// Activate tooltips
|
||||
$(id + ' [data-toggle="tooltip"]').tooltip({delay: {show: 1000, hide: 100}, placement: 'auto right'});
|
||||
gui.forms.beautify(id);
|
||||
|
||||
// Validation
|
||||
$form.validate({
|
||||
|
@ -89,6 +89,9 @@
|
||||
return '<div class="row"><div class="col-lg-12"><ol class="breadcrumb">' + list + "</ol></div></div>";
|
||||
};
|
||||
|
||||
// By default, actionButton has class "button-accept", so you can use returned id + this class to select it
|
||||
// and do whatever is needed (for example, insert an "on click" event (this method returns id without '#'
|
||||
// Example: $('#' + id + ' .button-accept').on('click', ...
|
||||
gui.modal = function(id, title, content, options) {
|
||||
options = options || {};
|
||||
return api.templates.evaluate('tmpl_comp_modal', {
|
||||
@ -102,6 +105,7 @@
|
||||
});
|
||||
};
|
||||
|
||||
// As previous, this creates the modal and shows it. in this case, the id of the modal returned already has '#'
|
||||
gui.launchModal = function(title, content, options) {
|
||||
options = options || {};
|
||||
var id = gui.genRamdonId('modal-'); // Get a random ID for this modal
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -88,7 +88,7 @@
|
||||
<script src="{% get_static_prefix %}adm/js/dataTables.bootstrap.js"></script>
|
||||
|
||||
<!-- template engine -->
|
||||
<script src="{% get_static_prefix %}adm/js/handlebars-v1.1.2.js"></script>
|
||||
<script src="{% get_static_prefix %}adm/js/handlebars-v1.3.0.js"></script>
|
||||
|
||||
<!-- First all api related stuff -->
|
||||
<script src="{% get_static_prefix %}adm/js/api.js"></script>
|
||||
|
@ -25,8 +25,6 @@
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="lnk-configuration" href="#">{% trans 'Configuration' %}</a></li>
|
||||
<li><a class="lnk-clear_cache" href="#">{% trans 'Flush cache' %}</a></li>
|
||||
<li><a href="#">Third Item</a></li>
|
||||
<li><a href="#">Last Item</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
25
server/src/uds/templates/uds/admin/tmpl/pool_add_group.html
Normal file
25
server/src/uds/templates/uds/admin/tmpl/pool_add_group.html
Normal file
@ -0,0 +1,25 @@
|
||||
{% load i18n %}
|
||||
{% verbatim %}
|
||||
<form class="form-horizontal" role="form">
|
||||
<div class="form-group">
|
||||
<label for="id_auth_select" class="col-sm-2 control-label">{% endverbatim %}{% trans 'Authenticator' %}{% verbatim %}</label>
|
||||
<div class="col-sm-10">
|
||||
<select id="id_auth_select" name="auth" class="selectpicker show-menu-arrow show-tick modal_field_data" data-style="btn-default" data-width="100%">
|
||||
<option value="-1"></option>
|
||||
{{# each auths }}
|
||||
<option value="{{ id }}">{{ name }}</option>
|
||||
{{/ each }}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="id_group_select" class="col-sm-2 control-label">{% endverbatim %}{% trans 'Group' %}{% verbatim %}</label>
|
||||
<div class="col-sm-10">
|
||||
<select id="id_group_select" name="group" class="selectpicker show-menu-arrow show-tick modal_field_data" data-style="btn-default" data-width="100%">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
{% endverbatim %}
|
Loading…
Reference in New Issue
Block a user