Revisión 212
Añadido por Manu Mora Gordillo hace más de 13 años
controlies/trunk/applications/controlies/views/thinclients/form.html | ||
---|---|---|
<script language="javascript">
|
||
|
||
$(function() {
|
||
$("#name").focus();
|
||
$("#saveButton").button({ icons: { primary: "ui-icon-disk"}});
|
||
$("#cancelButton")
|
||
.button({ icons: { primary: "ui-icon-close"}})
|
||
.click( function(){ $('#dialog-form').dialog('close'); });
|
||
});
|
||
|
||
function restartStyle(){
|
||
$("#form_data p span").css("color","black");
|
||
$('#message').html("");
|
||
}
|
||
|
||
function send(){
|
||
|
||
restartStyle();
|
||
|
||
jQuery.post('call/json/modify', jQuery("#form_data").serialize(), function(result) {
|
||
switch(result.response){
|
||
case "OK":{
|
||
jQuery('#message').html("Operación realizada correctamente").css("color","green").effect("highlight", {"color":"yellow"}, 1000);
|
||
setTimeout("$('#dialog-form').dialog('close')",1000);
|
||
jQuery("#list").trigger("reloadGrid");
|
||
break;
|
||
}
|
||
case "fail":{
|
||
jQuery('#message').html("Se produjo un error").effect("highlight", {"color":"yellow"}, 1000);
|
||
break;
|
||
}
|
||
case "hostAlreadyExists":{
|
||
jQuery('#nameTag').css("color","red");
|
||
jQuery('#name').effect("highlight", {"color":"yellow"}, 1000).focus();
|
||
jQuery('#message').html("Ya existe ese nombre").effect("slide");
|
||
break;
|
||
}
|
||
case "macAlreadyExists":{
|
||
jQuery('#macTag').css("color","red");
|
||
jQuery('#mac').effect("highlight", {"color":"yellow"}, 1000).focus();
|
||
jQuery('#message').html("Ya existe esa MAC").effect("slide");
|
||
break;
|
||
}
|
||
default:{
|
||
jQuery('#'+result.response+"Tag").css("color","red");
|
||
jQuery('#'+result.response).effect("highlight", {"color":"yellow"}, 1000).focus();
|
||
jQuery('#message').html("Hay campos vacíos o incorrectos").effect("slide");
|
||
break;
|
||
}
|
||
}
|
||
});
|
||
|
||
return false;
|
||
}
|
||
|
||
</script>
|
||
|
||
<form id="form_data" onsubmit="return send();">
|
||
<input type="hidden" id="action" name="action"/>
|
||
<div>
|
||
<div>
|
||
<p><span id="nameTag">Nombre</span><br><input type="text" id="name" name="name" maxlength="20"/></p>
|
||
<p><span id="macTag">MAC</span><br><input type="text" id="mac" name="mac" maxlength="17"/></p>
|
||
</div>
|
||
</div>
|
||
<div id="message" style="text-align:center; font-weight:bold; color:red; padding:3px; "></div>
|
||
<div style="text-align:center;"><button id="saveButton" type="submit" style="width:100px;">Guardar</button> <button type="button" id="cancelButton" style="width:100px;">Cancelar</button></div>
|
||
<p style="padding-top:10px; text-align:center; font-size:10px;" id="messageForm"></p>
|
||
</form>
|
controlies/trunk/applications/controlies/views/thinclients/index.html | ||
---|---|---|
<!-- Libreria Multiselect -->
|
||
{{response.files.append(URL('static','js/multiselect/jquery.multiselect.css'))}}
|
||
{{response.files.append(URL('static','js/multiselect/jquery.multiselect.min.js'))}}
|
||
{{response.files.append(URL('static','js/multiselect/jquery.multiselect.es.js'))}}
|
||
{{#response.files.append(URL('static','css/helper.css'))}}
|
||
{{#response.files.append(URL('static','css/dropdown.css'))}}
|
||
{{#response.files.append(URL('static','css/default.advanced.css'))}}
|
||
|
||
|
||
{{extend 'layout.html'}}
|
||
|
||
<div id="tabla_clientes" class="centerGrid">
|
||
<table width="100%" align="center">
|
||
<tr>
|
||
<td style="width:2%"></td>
|
||
<td style="text-align:center;"><table id="list" width="100%"></table></td>
|
||
<td style="width:2%"></td>
|
||
</tr>
|
||
</table>
|
||
<div id="pager" style=""></div>
|
||
<div id="filter" style="margin-left:30%;display:none">Buscar nada</div>
|
||
</div>
|
||
|
||
<div id="dialog-form"></div>
|
||
|
||
<div id="dialog-confirm" title="¿Borrar el registro seleccionado?" style="display:none;">
|
||
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>Este elemento quedará permanentemente eliminado. ¿Está seguro?</p>
|
||
</div>
|
||
|
||
<div id="dialog-alert" title="Atención" style="display:none;">
|
||
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>Para operar sobre un registro debe seleccionarlo previamente.</p>
|
||
</div>
|
||
|
||
|
||
<script type="text/javascript">
|
||
|
||
jQuery(function() {
|
||
jQuery("#dialog-confirm").dialog({ autoOpen: false });
|
||
jQuery("#dialog-alert").dialog({ autoOpen: false });
|
||
});
|
||
|
||
|
||
function print_grid(){
|
||
jQuery("#list").jqGrid({
|
||
url:"{{=URL(c='thinclients',f='call',args=['json','list'])}}",
|
||
data: "{}",
|
||
datatype: 'json',
|
||
mtype: 'GET',
|
||
contentType: "application/json; charset=utf-8",
|
||
complete: function(jsondata, stat) {
|
||
if (stat == "success") {
|
||
var thegrid = jQuery("#list")[0];
|
||
thegrid.addJSONData(JSON.parse(jsondata.responseText).d);
|
||
}
|
||
},
|
||
|
||
colNames:['Nombre','Mac'],
|
||
colModel:[
|
||
{name:'cn',index:'cn', width:450, align:"center"},
|
||
{name:'mac',index:'mac', width:450, align:"center"}
|
||
],
|
||
rowNum:25,
|
||
height:335,
|
||
width: 900,
|
||
rowList:[25,50,75],
|
||
pager: '#pager',
|
||
sortname: 'cn',
|
||
autowidth: false,
|
||
viewrecords: true,
|
||
sortorder: "desc",
|
||
caption:"Clientes ligeros"
|
||
|
||
});
|
||
jQuery("#list").jqGrid('navGrid','#pager',{add:false,edit:false,del:false,search:false,refresh:false});
|
||
|
||
jQuery("#list").jqGrid('navButtonAdd','#pager',{
|
||
caption: "Insertar",
|
||
buttonicon :'ui-icon-plus',
|
||
onClickButton : function (){
|
||
addRecord();
|
||
}
|
||
});
|
||
jQuery("#list").jqGrid('navButtonAdd','#pager',{
|
||
caption: "Modificar",
|
||
buttonicon :'ui-icon-pencil',
|
||
onClickButton : function (){
|
||
modifyRecord();
|
||
}
|
||
});
|
||
jQuery("#list").jqGrid('navButtonAdd','#pager',{
|
||
caption: "Borrar",
|
||
buttonicon :'ui-icon-trash',
|
||
onClickButton : function (){
|
||
deleteRecord();
|
||
}
|
||
});
|
||
|
||
|
||
jQuery("#list").jqGrid('filterToolbar');
|
||
|
||
}
|
||
|
||
|
||
function rowSelected(){
|
||
var uid = jQuery("#list").jqGrid('getGridParam','selrow');
|
||
|
||
if( uid == null ){
|
||
jQuery( "#dialog-alert" ).dialog({
|
||
resizable: false,
|
||
height:150,
|
||
width:290,
|
||
modal: true,
|
||
buttons: { "Aceptar": function() { $( this ).dialog( "close" ); }}
|
||
}).dialog('open');
|
||
return false;
|
||
}
|
||
return uid;
|
||
}
|
||
|
||
function addRecord(){
|
||
|
||
jQuery("#messageLoading").show();
|
||
|
||
jQuery("#dialog-form").html("").css("display","none");
|
||
jQuery("#dialog-form").load("form.html", function() {
|
||
|
||
jQuery("#form_data #action").val("add");
|
||
jQuery("#form_data #messageForm").html("Todos los campos son obligatorios");
|
||
|
||
x = (jQuery(window).width()-300)/2;
|
||
y = (jQuery(window).height()-500)/2;
|
||
|
||
jQuery("#messageLoading").hide();
|
||
|
||
jQuery("#dialog-form").dialog({
|
||
resizable: false,
|
||
position: top,
|
||
modal: true,
|
||
width: 300,
|
||
title: "Añadir Cliente Ligero"
|
||
}).dialog('option', 'position', [x, y]);
|
||
});
|
||
}
|
||
|
||
function modifyRecord(){
|
||
var uid;
|
||
|
||
jQuery("#messageLoading").show();
|
||
|
||
var uid = rowSelected();
|
||
if(uid==false)
|
||
return false;
|
||
|
||
jQuery("#dialog-form").html("").css("display","none");
|
||
jQuery("#dialog-form").load("form.html", function() {
|
||
|
||
jQuery("#form_data #action").val("modify");
|
||
jQuery("#form_data #user").attr("readonly","true");
|
||
jQuery("#form_data #user").css("background-color","#DDD");
|
||
jQuery("#form_data #messageForm").html("Todos los campos son obligatorios");
|
||
|
||
jQuery.post('call/json/getHostData',{ username: uid }, function(result) {
|
||
//var result = jQuery.parseJSON(data);
|
||
|
||
jQuery("#form_data #type").replaceWith(textType+"<input type='hidden' id='type' name='type' value='"+result.response['type']+"'/>");
|
||
jQuery("#form_data #name").val(result.response['name']);
|
||
jQuery("#form_data #nif").val(result.response['nif']);
|
||
jQuery("#form_data #user").val(result.response['user']);
|
||
jQuery("#form_data #surname").val(result.response['surname']);
|
||
if (result.response['photo']!='')
|
||
jQuery("#form_data #photo").attr("src","data:image/png;base64,"+result.response['photo']);
|
||
|
||
$.each(result.response['groups']['departments'], function(i, l){
|
||
jQuery('#form_data input:checkbox[value='+l+']').attr('checked', true);
|
||
});
|
||
|
||
$.each(result.response['groups']['classrooms'], function(i, l){
|
||
jQuery('#form_data input:checkbox[value='+l+']').attr('checked', true);
|
||
});
|
||
|
||
x = (jQuery(window).width()-300)/2;
|
||
y = (jQuery(window).height()-500)/2;
|
||
|
||
jQuery("#messageLoading").hide();
|
||
|
||
jQuery("#dialog-form").dialog({
|
||
resizable: false,
|
||
modal: true,
|
||
width: 300,
|
||
title: "Modificar Cliente Ligero"
|
||
}).dialog('option', 'position', [x, y]);
|
||
});
|
||
});
|
||
}
|
||
|
||
function deleteRecord(){
|
||
|
||
var uid = rowSelected();
|
||
if(uid==false)
|
||
return false;
|
||
|
||
jQuery( "#dialog-confirm" ).dialog({
|
||
resizable: false,
|
||
height:160,
|
||
width:350,
|
||
modal: true,
|
||
buttons: {
|
||
"Borrar": function() {
|
||
jQuery.post("call/json/delete","user="+uid, function(data){
|
||
jQuery("#dialog-confirm").dialog( "close" );
|
||
jQuery("#list").trigger("reloadGrid");
|
||
});
|
||
},
|
||
"Cancelar": function() {
|
||
$(this).dialog( "close" );
|
||
}
|
||
}
|
||
}).dialog('open');
|
||
}
|
||
|
||
</script>
|
||
|
||
|
||
<script type="text/javascript">
|
||
jQuery(document).ready(function(){ print_grid();});
|
||
</script>
|
controlies/trunk/applications/controlies/models/menu.py | ||
---|---|---|
('Grupos', False,URL( 'grupos', 'index' )),
|
||
('Servidores LTSP',False, URL( 'hosts', 'ltspservers' )),
|
||
#('Workstations', False,URL( 'hosts', 'workstations' )),
|
||
#('Clientes Ligeros', False,URL( 'hosts', 'thinclients' )),
|
||
('Clientes Ligeros', False,URL( 'thinclients', 'index' )),
|
||
#('Parámetros DHCP', False,URL( 'dhcpd', 'index' )),
|
||
|
||
]
|
Exportar a: Unified diff
Empiezo con los thinclients