ajout d'une interface pour la gestion des machines
darcs-hash:20061110134614-f46e9-a636e37c33caab306cfd87e565f2fad28c78596f.gz
This commit is contained in:
parent
f4d5e3c798
commit
4e7c67e33b
14 changed files with 1124 additions and 406 deletions
|
@ -1,193 +1,81 @@
|
|||
function askForName(oldName) {
|
||||
var c = '';
|
||||
while ( c == '')
|
||||
c = prompt("Votre nom :",oldName);
|
||||
if (c == null)
|
||||
return false;
|
||||
else
|
||||
window.location.href= 'changeNomAdherent?nouveauNom=' + c;
|
||||
/* ************************************************************
|
||||
* Crans
|
||||
************************************************************
|
||||
* Crans.messages : afficher des messages sur les pages
|
||||
* Crans.loading : afficher l'indicateur de chargement
|
||||
*/
|
||||
Crans = {};
|
||||
|
||||
/*****************************
|
||||
Crans.Messages
|
||||
*****************************/
|
||||
Crans.messages = {}
|
||||
Crans.messages.initialized = false;
|
||||
|
||||
Crans.messages.init = function()
|
||||
{
|
||||
if (!Crans.messages.initialized)
|
||||
{
|
||||
updateNodeAttributes(document.body, {'onclick':'Crans.messages.setMessage();'});
|
||||
appendChildNodes(document.body, DIV({'id':'_crans_main_message_place_holder'}));
|
||||
Crans.messages.initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function askForSurname(oldSurname) {
|
||||
var c = '';
|
||||
while ( c == '')
|
||||
c = prompt("Votre prénom :",oldSurname);
|
||||
if (c == null)
|
||||
return false;
|
||||
else
|
||||
window.location.href= 'changePrenomAdherent?nouveauPrenom=' + c;
|
||||
Crans.messages.setMessage = function(m, messageClass)
|
||||
{
|
||||
if (!Crans.messages.initialized)
|
||||
Crans.messages.init();
|
||||
if (m == null) {
|
||||
var messageBox = '';
|
||||
} else {
|
||||
if (messageClass==null)
|
||||
messageClass='message';
|
||||
var textHolder = SPAN({'class':'messageText'},m);
|
||||
var messageBox = DIV({'class':messageClass},textHolder);
|
||||
var messagePlace = document.getElementById("_crans_main_message_place_holder");
|
||||
}
|
||||
try
|
||||
{
|
||||
var messagePlace = document.getElementById("_crans_main_message_place_holder");
|
||||
replaceChildNodes(messagePlace,messageBox);
|
||||
try {roundElement(messageBox);} catch (error) {}
|
||||
}
|
||||
catch (error)
|
||||
{
|
||||
logError("élement _crans_main_message_place_holder introuvable")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
function askForTel(oldTel) {
|
||||
var c = '';
|
||||
while ( c == '')
|
||||
c = prompt("Votre numéro de téléphone :",oldTel);
|
||||
if (c == null)
|
||||
return false;
|
||||
else
|
||||
window.location.href= 'changeTelAdherent?nouveauTel=' + c;
|
||||
/*****************************
|
||||
Crans.loading
|
||||
*****************************/
|
||||
Crans.loading = {}
|
||||
Crans.loading.initialized = false;
|
||||
|
||||
Crans.loading.init = function(){
|
||||
try {
|
||||
if (!Crans.loading.initialized) {
|
||||
appendChildNodes(document.body, DIV({'id':'_crans_main_message_chargement'}, "Chargement..."));
|
||||
Crans.loading.initialized = true;
|
||||
}
|
||||
} catch (error) {
|
||||
logError(error.description);
|
||||
}
|
||||
}
|
||||
|
||||
function askForMachineMac(oldMac, mid) {
|
||||
var c = '';
|
||||
while ( c == '')
|
||||
c = prompt("Adresse MAC de la machine :",oldMac);
|
||||
if (c == null)
|
||||
return false;
|
||||
var e = loadJSONDoc('changeMACMachine?nouvelleMAC=' + c + '&mid=' + mid);
|
||||
e.addCallback(machineModifHandler);
|
||||
e.addErrback(ajaxErrorHandler);
|
||||
loading(true);
|
||||
return false;
|
||||
}
|
||||
function askForMachineName(oldName, mid) {
|
||||
var c = '';
|
||||
while ( c == '')
|
||||
c = prompt("Nom de la machine :",oldName);
|
||||
if (c == null)
|
||||
return false;
|
||||
var e = loadJSONDoc("changeNomMachine?nouveauNom=" + c + "&mid=" + mid);
|
||||
e.addCallback(machineModifHandler);
|
||||
e.addErrback(ajaxErrorHandler);
|
||||
loading(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
function askForDeleteMachine(mid, nom) {
|
||||
if (confirm("Supprimer la machine ?")) {
|
||||
var e = loadJSONDoc('supprimeMachine?mid=' + mid);
|
||||
e.addCallback(machineModifHandler);
|
||||
e.addErrback(ajaxErrorHandler);
|
||||
loading(true);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function newAlias() {
|
||||
var c = '';
|
||||
while ( c == '')
|
||||
c = prompt("Nouvel alias :");
|
||||
if (c == null)
|
||||
return false;
|
||||
else
|
||||
window.location.href= 'newAlias?alias=' + c + "#mailTab";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function newMachineNode(name, shortName, mac, ip, mid, type, ipsec) {
|
||||
machineName = H3({},shortName);
|
||||
|
||||
var propertiesList = createDOM("DL",{'class':'machineInfos'});
|
||||
valuesList = [
|
||||
{'label':'Type : ', 'value':type},
|
||||
{'label':'Mac : ', 'value':mac},
|
||||
{'label':'IP : ', 'value':ip},
|
||||
{'label':'ipsec : ', 'value':ipsec},
|
||||
] ;
|
||||
for (var i=0; i<valuesList.length; i++) {
|
||||
var item = valuesList[i];
|
||||
if (item.value) {
|
||||
propertiesList.appendChild(createDOM("DT",item.label));
|
||||
propertiesList.appendChild(createDOM("DD",item.value));
|
||||
}
|
||||
}
|
||||
var actions = SPAN({'class':'actions'},[
|
||||
A({'href':'#','onclick':"return askForMachineName('"+shortName+"','"+mid+"');"},'Renommer'),
|
||||
A({'href':'#','onclick':"return askForMachineMac('"+mac+"','"+mid+"');"},'Changer de MAC'),
|
||||
A({'href':'#','onclick':"return askForDeleteMachine('"+mid+"');"},'Supprimer'),
|
||||
]);
|
||||
return LI({},[
|
||||
machineName,
|
||||
propertiesList,
|
||||
DIV({'class':'clear'},''),
|
||||
actions,
|
||||
DIV({'class':'clear'},''),
|
||||
]);
|
||||
}
|
||||
|
||||
function newMachineLiNodeFromDict(adict) {
|
||||
return LI({},newMachineNode(adict.nom, adict.nomCourt, adict.mac, adict.ip, adict.mid, adict.type, adict.ipsec));
|
||||
}
|
||||
|
||||
function renderMachineList(result) {
|
||||
replaceChildNodes('machineList',map(newMachineLiNodeFromDict,result.machines));
|
||||
}
|
||||
function loadMachineList() {
|
||||
var e = loadJSONDoc('listeMachines');
|
||||
e.addCallback(renderMachineList);
|
||||
e.addErrback(ajaxErrorHandler);
|
||||
}
|
||||
|
||||
function ajaxErrorHandler(d) {
|
||||
loading(false);
|
||||
alert(d)
|
||||
logError("AJAX Error");
|
||||
logerror(d);
|
||||
window.location.href= "";
|
||||
}
|
||||
|
||||
|
||||
function machineModifHandler(result) {
|
||||
loading(false);
|
||||
if (result.message){
|
||||
setMessage(result.message);
|
||||
addMachineForm.clear();
|
||||
logDebug("AJAX Succed");
|
||||
}
|
||||
if (result.error){
|
||||
alert(result.error);
|
||||
logError("AJAX error");
|
||||
}
|
||||
loadMachineList();
|
||||
}
|
||||
|
||||
addMachineForm = {}
|
||||
|
||||
addMachineForm.setFieldValue = function(fieldName, newValue) {
|
||||
document.addMachineForm[fieldName] = newValue;
|
||||
}
|
||||
|
||||
addMachineForm.clear = function() {
|
||||
document.addMachineForm.reset();
|
||||
logDebug("addMachineForm cleared");
|
||||
}
|
||||
|
||||
function creerMachine(nom, mac, estMachineWifi) {
|
||||
var e = loadJSONDoc("creerMachine?nomNouvelleMachine=" + nom + "&MACNouvelleMachine=" + mac + "&estMachineWifi="+estMachineWifi);
|
||||
e.addCallback(machineModifHandler);
|
||||
e.addErrback(ajaxErrorHandler);
|
||||
loading(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function setMessage(m, messageClass) {
|
||||
if (m == null) {
|
||||
var messagePlace = document.getElementById("messagePlaceHolder");
|
||||
replaceChildNodes(messagePlace,'');
|
||||
return
|
||||
}
|
||||
if (messageClass==null)
|
||||
messageClass='message'
|
||||
var textHolder = SPAN({'class':'messageText'},m);
|
||||
var messageBox = DIV({'class':messageClass},textHolder);
|
||||
var messagePlace = document.getElementById("messagePlaceHolder");
|
||||
replaceChildNodes(messagePlace,messageBox);
|
||||
roundElement(messageBox);
|
||||
}
|
||||
|
||||
function loading(bool) {
|
||||
var loadingEl = document.getElementById("loadings");
|
||||
if (loadingEl) {
|
||||
if (bool) {
|
||||
loadingEl.style.display='block';
|
||||
} else {
|
||||
loadingEl.style.display='none';
|
||||
}
|
||||
}
|
||||
return false;
|
||||
Crans.loading.display = function(bool) {
|
||||
if (!Crans.loading.initialized)
|
||||
Crans.loading.init();
|
||||
var loadingEl = document.getElementById("_crans_main_message_chargement");
|
||||
if (loadingEl) {
|
||||
if (bool) {
|
||||
appear(loadingEl);
|
||||
} else {
|
||||
fade(loadingEl);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/* ************************************************************
|
||||
* Digicode
|
||||
************************************************************
|
||||
* Digicode.init : initialisation de la page
|
||||
* Digicode.makeCode : creation de codes
|
||||
* Digicode.codelist : liste des codes
|
||||
* Digicode.AJAX : ajax
|
||||
*/
|
||||
* Digicode
|
||||
************************************************************
|
||||
* Digicode.init : initialisation de la page
|
||||
* Digicode.makeCode : creation de codes
|
||||
* Digicode.codelist : liste des codes
|
||||
* Digicode.AJAX : ajax
|
||||
*/
|
||||
Digicode = {};
|
||||
|
||||
/*****************************
|
||||
|
@ -13,13 +13,13 @@ Digicode = {};
|
|||
*****************************/
|
||||
Digicode.init = function()
|
||||
{
|
||||
// afficher le tableau codelist
|
||||
appendChildNodes("globalDiv", Digicode.codelist.create())
|
||||
// recuperer la liste des codes
|
||||
this.codelist.load();
|
||||
// afficher le formulaire de creation de code
|
||||
appendChildNodes("globalDiv", DIV({"id":"addCodeBox"}));
|
||||
Digicode.makeCode.displayForm();
|
||||
// afficher le tableau codelist
|
||||
appendChildNodes("globalDiv", Digicode.codelist.create());
|
||||
// recuperer la liste des codes
|
||||
this.codelist.load();
|
||||
// afficher le formulaire de creation de code
|
||||
appendChildNodes("globalDiv", DIV({"id":"addCodeBox"}));
|
||||
Digicode.makeCode.displayForm();
|
||||
}
|
||||
|
||||
/*****************************
|
||||
|
@ -29,74 +29,76 @@ Digicode.makeCode = {}
|
|||
|
||||
Digicode.makeCode.displayForm = function()
|
||||
{
|
||||
|
||||
var myForm = FORM({'id':'createCodeForm', 'name':'createCodeForm','onsubmit':"Digicode.makeCode.createCode(document.createCodeForm.newCode.value); return false;", 'style':'display: none;'},
|
||||
BUTTON({"type":"button","onclick":"Digicode.makeCode.createCode(document.createCodeForm.newCode.value)", "style":"float:right;"},"Créer code"),
|
||||
INPUT({"name":"newCode", "size":"6", "maxlength":"6", "style":"float:right;"}),
|
||||
BUTTON({"type":"button","onclick":"Digicode.makeCode.createCode()", "style":"float:right;clear:both;"},"Code aléatoire")
|
||||
);
|
||||
replaceChildNodes("addCodeBox", H1({},"Nouveau code"), myForm );
|
||||
appear(myForm);
|
||||
|
||||
var myForm = FORM({'id':'createCodeForm', 'name':'createCodeForm','onsubmit':"Digicode.makeCode.createCode(document.createCodeForm.newCode.value); return false;", 'style':'display: none;'},
|
||||
LABEL({'for':'newCodeLogin', "style":"clear:left;"}, "Login adhérent :"),
|
||||
INPUT({"name":"newCodeLogin", "size":"10", "maxlength":"20", "style":"float:rightk;clear:both;"}),
|
||||
LABEL({'for':'newCode', "style":"clear:left;"}, "Code :"),
|
||||
INPUT({"name":"newCode", "size":"6", "maxlength":"6", "style":"float:rightk;clear:both;"}),
|
||||
BUTTON({"type":"button","onclick":"Digicode.makeCode.createCode(document.createCodeForm.newCodeLogin.value, document.createCodeForm.newCode.value)", "style":"float:right;"},"Créer code"),
|
||||
BUTTON({"type":"button","onclick":"Digicode.makeCode.createCode(document.createCodeForm.newCodeLogin.value)", "style":"float:right;"},"Code aléatoire")
|
||||
);
|
||||
replaceChildNodes("addCodeBox", H1({},"Nouveau code"), myForm );
|
||||
appear(myForm);
|
||||
|
||||
}
|
||||
|
||||
Digicode.makeCode.restoreForm = function()
|
||||
{
|
||||
try
|
||||
{
|
||||
removeElement("newCodeDisplay");
|
||||
removeElement("loading");
|
||||
} catch (error){}
|
||||
appear("createCodeForm");
|
||||
|
||||
try
|
||||
{
|
||||
removeElement("newCodeDisplay");
|
||||
removeElement("loading");
|
||||
} catch (error){}
|
||||
appear("createCodeForm");
|
||||
|
||||
}
|
||||
|
||||
Digicode.makeCode.createCode = function(code)
|
||||
Digicode.makeCode.createCode = function(login, code)
|
||||
{
|
||||
var image = createDOM("IMG",{'style':'margin-right:2px;float:right;','src':'/static/images/indicator.gif'});
|
||||
appendChildNodes("addCodeBox", DIV({'id':"loading",'style':'display:none;max-height:1em;float:left;'},image,"Loading"))
|
||||
removeElement("createCodeForm");
|
||||
appear("loading");
|
||||
if (code)
|
||||
Digicode.AJAX.call("createCode?code="+code, this.handleNewCode);
|
||||
else
|
||||
Digicode.AJAX.call("createCode", this.handleNewCode);
|
||||
|
||||
var image = createDOM("IMG",{'style':'margin-right:2px;float:right;','src':'/static/images/indicator.gif'});
|
||||
appendChildNodes("addCodeBox", DIV({'id':"loading",'style':'display:none;max-height:1em;float:left;'},image,"Loading"));
|
||||
removeElement("createCodeForm");
|
||||
appear("loading");
|
||||
if (code)
|
||||
Digicode.AJAX.call("createCode?code="+code + "&adherent=" + login, this.handleNewCode);
|
||||
else
|
||||
Digicode.AJAX.call("createCode?adherent=" + login, this.handleNewCode);
|
||||
|
||||
}
|
||||
Digicode.makeCode.handleNewCode = function(res)
|
||||
{
|
||||
if (res.code)
|
||||
{
|
||||
appendChildNodes("addCodeBox",
|
||||
DIV({'id':"newCodeDisplay",
|
||||
'style':'display:none;font-size:2em;maring:1em;font-weight:bold;text-align:center;',
|
||||
'onclick':"Digicode.makeCode.displayForm();"},res.code));
|
||||
appear("newCodeDisplay");
|
||||
removeElement("loading")
|
||||
Digicode.codelist.addCode(res);
|
||||
} else if (res.erreur) {
|
||||
logError("Erreur distante : " + res.erreur);
|
||||
alert("Erreur sur le serveur, le code est peut-être déjà pris.")
|
||||
Digicode.makeCode.displayForm();
|
||||
} else if (res.formatErreur) {
|
||||
alert("Ceci n'est pas un code valide");
|
||||
Digicode.makeCode.displayForm();
|
||||
}
|
||||
|
||||
if (res.code)
|
||||
{
|
||||
appendChildNodes("addCodeBox",
|
||||
DIV({'id':"newCodeDisplay",
|
||||
'style':'display:none;font-size:2em;maring:1em;font-weight:bold;text-align:center;',
|
||||
'onclick':"Digicode.makeCode.displayForm();"},res.code));
|
||||
appear("newCodeDisplay");
|
||||
removeElement("loading")
|
||||
Digicode.codelist.addCode(res);
|
||||
} else if (res.erreur) {
|
||||
logError("Erreur distante : " + res.erreur);
|
||||
alert("Erreur sur le serveur, le code est peut-être déjà pris.")
|
||||
Digicode.makeCode.displayForm();
|
||||
} else if (res.formatErreur) {
|
||||
alert("Ceci n'est pas un code valide");
|
||||
Digicode.makeCode.displayForm();
|
||||
}
|
||||
|
||||
}
|
||||
/*****************************
|
||||
Digicode.codelist
|
||||
Digicode.codelist
|
||||
*****************************/
|
||||
Digicode.codelist = {};
|
||||
|
||||
Digicode.codelist.create = function ()
|
||||
{
|
||||
var thead = createDOM("thead", {},
|
||||
createDOM("th", {'class':'code'}, "Code" ),
|
||||
createDOM("th", {'class':'age'}, "Age")
|
||||
);
|
||||
var tbody = createDOM("tbody", {"id":"codeList"});
|
||||
return TABLE({"id":"codesTable", "cellspacing":"0"}, thead, tbody)
|
||||
var thead = createDOM("thead", {},
|
||||
createDOM("th", {'class':'code'}, "Code" ),
|
||||
createDOM("th", {'class':'age'}, "Age")
|
||||
);
|
||||
var tbody = createDOM("tbody", {"id":"codeList"});
|
||||
return TABLE({"id":"codesTable", "cellspacing":"0"}, thead, tbody)
|
||||
}
|
||||
|
||||
|
||||
|
@ -108,28 +110,28 @@ Digicode.codelist.load = function()
|
|||
|
||||
Digicode.codelist.displayCodes = function(result)
|
||||
{
|
||||
if (result.codes)
|
||||
replaceChildNodes('codeList',map(Digicode.codelist.newCodeTrNodeFromDict,result.codes));
|
||||
else if (result.erreur)
|
||||
logError("Erreur distante : " + result.erreur);
|
||||
if (result.codes)
|
||||
replaceChildNodes('codeList',map(Digicode.codelist.newCodeTrNodeFromDict,result.codes));
|
||||
else if (result.erreur)
|
||||
logError("Erreur distante : " + result.erreur);
|
||||
}
|
||||
|
||||
Digicode.codelist.newCodeTrNodeFromDict = function (aDict, style)
|
||||
{
|
||||
if (style) {
|
||||
var aRow = createDOM("TR", {'id':'code'+aDict.code,"style":style});
|
||||
} else
|
||||
var aRow = createDOM("TR", {'id':'code'+aDict.code});
|
||||
appendChildNodes(aRow, createDOM("TD", {'class':'code'}, aDict.code, SPAN({'style':'color:gray;margin-left:2em;'}, aDict.desc ) ) );
|
||||
appendChildNodes(aRow, createDOM("TD", {'class':'age'}, aDict.age) );
|
||||
return aRow;
|
||||
if (style) {
|
||||
var aRow = createDOM("TR", {'id':'code'+aDict.code,"style":style});
|
||||
} else
|
||||
var aRow = createDOM("TR", {'id':'code'+aDict.code});
|
||||
appendChildNodes(aRow, createDOM("TD", {'class':'code'}, aDict.code, SPAN({'style':'color:gray;margin-left:2em;'}, aDict.desc ) ) );
|
||||
appendChildNodes(aRow, createDOM("TD", {'class':'age'}, aDict.age) );
|
||||
return aRow;
|
||||
}
|
||||
|
||||
Digicode.codelist.addCode = function (aDict)
|
||||
{
|
||||
var newLine = this.newCodeTrNodeFromDict(aDict)
|
||||
appendChildNodes("codeList", newLine);
|
||||
pulsate(newLine);
|
||||
var newLine = this.newCodeTrNodeFromDict(aDict);
|
||||
appendChildNodes("codeList", newLine);
|
||||
pulsate(newLine);
|
||||
}
|
||||
|
||||
|
||||
|
@ -139,7 +141,7 @@ Digicode.codelist.addCode = function (aDict)
|
|||
Digicode.AJAX = {}
|
||||
|
||||
Digicode.AJAX.call = function(page, callBack) {
|
||||
logDebug("calling AJAX : " + page)
|
||||
logDebug("calling AJAX : " + page);
|
||||
var e = loadJSONDoc(page);
|
||||
e.addCallback(callBack);
|
||||
e.addErrback(this.errorHandler);
|
||||
|
@ -150,12 +152,4 @@ Digicode.AJAX.errorHandler = function(d) {
|
|||
logError("AJAX Error: " + d);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
setInterval(Digicode.codelist.load, 30000);
|
||||
|
|
348
intranet/static/scripts/machines.js
Normal file
348
intranet/static/scripts/machines.js
Normal file
|
@ -0,0 +1,348 @@
|
|||
/* ************************************************************
|
||||
* Machines
|
||||
************************************************************
|
||||
* Machines.init : initialisation de la page
|
||||
* Machines.listeMachines : liste des machines
|
||||
* Machines.infoPane : information sur une machine
|
||||
* Machines.actions : modifications, ajout...
|
||||
* Machines.AJAX : ajax
|
||||
*/
|
||||
Machines = {};
|
||||
|
||||
/*****************************
|
||||
Machines.init
|
||||
*****************************/
|
||||
Machines.init = function()
|
||||
{
|
||||
// afficher le tableau codelist
|
||||
appendChildNodes("globalDiv", Machines.createFrames());
|
||||
appendChildNodes("globalDiv", Machines.actions.makeMenu());
|
||||
// recuperer la liste des codes
|
||||
this.listeMachines.load();
|
||||
}
|
||||
|
||||
Machines.createFrames = function()
|
||||
{
|
||||
var main = DIV({"id":"gestion_machines_main_frame"});
|
||||
var inside = DIV({"id":"__insideDivId", "style":"background:white;margin:5px;padding:5px;"},main);
|
||||
var outside = DIV({"id":"__outsideDivId","style":"background:#000080;z-index:500;padding:0;"}, inside );
|
||||
roundElement(outside);
|
||||
roundElement(inside);
|
||||
log("Creation du cadre");
|
||||
return outside
|
||||
}
|
||||
|
||||
/*****************************
|
||||
Machines.listeMachines
|
||||
*****************************/
|
||||
Machines.listeMachines = {};
|
||||
|
||||
|
||||
Machines.listeMachines.load = function()
|
||||
{
|
||||
Machines.AJAX.call("AJAXListeMachines", Machines.listeMachines.display);
|
||||
log("Chargement liste...");
|
||||
Machines.currentMachine = '';
|
||||
}
|
||||
|
||||
Machines.listeMachines.display = function(result)
|
||||
{
|
||||
Crans.loading.display(false);
|
||||
log("display liste");
|
||||
|
||||
replaceChildNodes( "gestion_machines_main_frame",
|
||||
H2({}, "Mes machines"),
|
||||
UL({"id":"listeMachines"}),
|
||||
DIV( {"style":"clear:both;"} )
|
||||
);
|
||||
if (result.machines) {
|
||||
replaceChildNodes('listeMachines',map(Machines.listeMachines.newMachineNodeFromDict ,result.machines));
|
||||
Machines.actions.updateMenu(Machines.actions.actionForMachineList);
|
||||
aMachines.currentMid = '';
|
||||
}
|
||||
else if (result.erreur)
|
||||
logError("Erreur distante : " + result.erreur);
|
||||
else
|
||||
logError("Probleme bizarre...");
|
||||
}
|
||||
|
||||
Machines.listeMachines.newMachineNodeFromDict = function (aDict, style)
|
||||
{
|
||||
var nom = aDict.nomCourt;
|
||||
var mid = aDict.mid;
|
||||
var image = "machines_icon_" + aDict.type + ".png";
|
||||
//log("create an item : " + nom);
|
||||
if (style) {
|
||||
var anIcon = LI({'id':'machine_' + mid,"style":style});
|
||||
} else
|
||||
var anIcon = LI( {'id':'machine_' + mid} );
|
||||
appendChildNodes(anIcon, A({"href":"#", "onclick":"Machines.infoPane.loadInfo('"+mid+"');return false;"}, IMG({"src":"/static/images/" + image}), SPAN({},nom) ) );
|
||||
return anIcon;
|
||||
}
|
||||
|
||||
/*****************************
|
||||
Machines.infoPane
|
||||
*****************************/
|
||||
Machines.infoPane = {};
|
||||
|
||||
Machines.infoPane.loadInfo = function(mid)
|
||||
{
|
||||
if (!mid)
|
||||
if (!Machines.currentMachine) {
|
||||
logError("Machines.infoPane.loadInfo : pas de mid, pas de machine courrante...");
|
||||
return
|
||||
} else
|
||||
mid = Machines.currentMachine.mid;
|
||||
|
||||
log("load info : " + mid);
|
||||
Machines.AJAX.call("AJAXMachineInfo?mid=" + mid, Machines.infoPane.display);
|
||||
try {
|
||||
pulsate('machine_' + mid);
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
Machines.infoPane.display = function(result)
|
||||
{
|
||||
Crans.loading.display(false);
|
||||
if (result.nom) {
|
||||
log("displaying info : " + result.mid);
|
||||
// building pane
|
||||
var machinePane = DIV({"id":"machine_pane"});
|
||||
|
||||
// lien pour retourner a la liste des machines
|
||||
var back_link = A({"href":"#", "onclick":"Machines.listeMachines.load(); return false;"},"Retour");
|
||||
appendChildNodes( machinePane, back_link );
|
||||
|
||||
// titre (nom de machine + alias)
|
||||
var title = H2({}, IMG({"src":"/static/images/machines_icon_" + result.type + ".png"}), " ", result.nom);
|
||||
var alias = DIV({"class":"alias"},
|
||||
map(function(a_name) { return SPAN({}, a_name + " ")}, result.alias));
|
||||
appendChildNodes( title, alias );
|
||||
appendChildNodes( machinePane, title );
|
||||
|
||||
// infos de base (type, mac, ip, ipsec...)
|
||||
var basicInfos = createDOM("DL", {"class":"basicInfos"});
|
||||
appendChildNodes(basicInfos, createDOM("DT", "type:" ), createDOM("DD",{},"Machine " + result.type ) );
|
||||
appendChildNodes(basicInfos, createDOM("DT", "mac: " ), createDOM("DD",{},result.mac ) );
|
||||
appendChildNodes(basicInfos, createDOM("DT", "ip: " ), createDOM("DD",{},result.ip ) );
|
||||
if (result.ipsec)
|
||||
appendChildNodes(basicInfos, createDOM("DT", "Clef ipSec:" ), createDOM("DD",{},result.ipsec ) );
|
||||
appendChildNodes( machinePane, basicInfos );
|
||||
appendChildNodes( machinePane, DIV( {"style":"clear:both;"} ) );
|
||||
|
||||
|
||||
// blacklist
|
||||
if (result.blacklist)
|
||||
if (result.blacklist.length) {
|
||||
var subtitle = H3({}, "Blacklist");
|
||||
appendChildNodes( machinePane, subtitle );
|
||||
var blacklist_table = TABLE({"class":"blacklist_table", "cellspacing":"0"},
|
||||
THEAD({},
|
||||
TH({}, "Cause"),
|
||||
TH({}, "Debut"),
|
||||
TH({}, "Fin")
|
||||
)
|
||||
);
|
||||
map(function(a_blacklist_dict) {
|
||||
var style = "inactif";
|
||||
if (a_blacklist_dict.actif)
|
||||
style = "actif";
|
||||
var line = TR({"class":style},
|
||||
TD({}, a_blacklist_dict.type),
|
||||
TD({}, a_blacklist_dict.begin),
|
||||
TD({}, a_blacklist_dict.end)
|
||||
);
|
||||
appendChildNodes(blacklist_table, line);
|
||||
}, result.blacklist );
|
||||
appendChildNodes( machinePane, blacklist_table );
|
||||
}
|
||||
// liste des ports ouverts
|
||||
if (result.ports)
|
||||
if (result.ports.length) {
|
||||
var subtitle = H3({}, "Ports ouverts");
|
||||
appendChildNodes( machinePane, subtitle );
|
||||
var port_table = TABLE({"class":"ports_table", "cellspacing":"0"});
|
||||
map(function(a_port_dict) {
|
||||
var line = TR({},
|
||||
TH({}, a_port_dict.titre),
|
||||
map(function(a_port) {return TD({}, a_port);}, a_port_dict.ports)
|
||||
);
|
||||
appendChildNodes(port_table, line);
|
||||
}, result.ports );
|
||||
appendChildNodes( machinePane, port_table );
|
||||
}
|
||||
|
||||
// attaching pane to document
|
||||
replaceChildNodes( "gestion_machines_main_frame", machinePane);
|
||||
// updationg actions
|
||||
Machines.currentMachine = result;
|
||||
Machines.actions.updateMenu(Machines.actions.actionsForInfoPane);
|
||||
} else if (result.erreur) {
|
||||
logError("Erreur distante : " + result.erreur);
|
||||
} else
|
||||
logError("Probleme bizarr...");
|
||||
|
||||
}
|
||||
|
||||
/*****************************
|
||||
Machines.actions
|
||||
*****************************/
|
||||
Machines.actions = {}
|
||||
|
||||
Machines.actions.disponibles =
|
||||
{
|
||||
'Ajouter machine fixe':'Machines.actions.formulaire.nouvelleMachine(\'fixe\');',
|
||||
'Ajouter machine wifi':'Machines.actions.formulaire.nouvelleMachine(\'wifi\');',
|
||||
'Modifier Mac':'Machines.actions.formulaire.modifierMac(Machines.currentMid);',
|
||||
'Renommer':'Machines.actions.formulaire.renommer(Machines.currentMid);',
|
||||
'Supprimer':'Machines.actions.formulaire.supprimer(Machines.currentMid);',
|
||||
'Demander l\'ouverture d\'un port':'Machines.actions.formulaire.ouverturePort(Machines.currentMid);'
|
||||
}
|
||||
Machines.actions.actionForMachineList = ['Ajouter machine fixe', 'Ajouter machine wifi'];
|
||||
Machines.actions.actionsForInfoPane = ['Modifier Mac', 'Renommer', 'Supprimer', 'Demander l\'ouverture d\'un port'];
|
||||
|
||||
Machines.actions.makeMenu = function(actionListe)
|
||||
{
|
||||
log("building action menu");
|
||||
var liste = UL({"id":"liste_actions"});
|
||||
//this.updateMenu(actionListe, liste)
|
||||
return DIV( {"id":"menu_actions"},
|
||||
H1( {}, "ACTIONS"),
|
||||
liste
|
||||
);
|
||||
}
|
||||
|
||||
Machines.actions.updateMenu = function(actionListe, liste_actionsNode)
|
||||
{
|
||||
if (!liste_actionsNode)
|
||||
liste_actionsNode = "liste_actions";
|
||||
replaceChildNodes(liste_actionsNode);
|
||||
map(
|
||||
function(actionName) {
|
||||
appendChildNodes(liste_actionsNode, LI({}, Machines.actions.makeActionLink(actionName)));
|
||||
}
|
||||
, actionListe);
|
||||
}
|
||||
|
||||
Machines.actions.makeActionLink = function(actionName)
|
||||
{
|
||||
if (this.disponibles[actionName])
|
||||
{
|
||||
return A({"href":"#", "onclick":this.disponibles[actionName] + "return false;"}, actionName);
|
||||
} else
|
||||
logError("action inconnue " + actionName);
|
||||
return A({}, "???");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Machines.actions.callback = function(result) {
|
||||
Crans.loading.display(false);
|
||||
if (result.message){
|
||||
log(result.message);
|
||||
Crans.messages.setMessage(result.message);
|
||||
if (result.mid)
|
||||
Machines.infoPane.loadInfo(result.mid);
|
||||
else
|
||||
Machines.listeMachines.load();
|
||||
}
|
||||
if (result.error){
|
||||
alert(result.error);
|
||||
logError("AJAX error");
|
||||
}
|
||||
}
|
||||
|
||||
// actions : affichage des formulaires
|
||||
Machines.actions.formulaire = {}
|
||||
Machines.actions.formulaire.modifierMac = function()
|
||||
{
|
||||
if (!Machines.currentMachine)
|
||||
logError("pas de machine courrante");
|
||||
else {
|
||||
var c = '';
|
||||
while ( c == '')
|
||||
c = prompt("Adresse MAC de la machine :",Machines.currentMachine.mac);
|
||||
if (c == null)
|
||||
return false;
|
||||
// AJAX stuff
|
||||
Machines.AJAX.call('AJAXchangerMAC?nouvelleMAC=' + c + '&mid=' + Machines.currentMachine.mid,
|
||||
Machines.actions.callback);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Machines.actions.formulaire.renommer = function() {
|
||||
if (!Machines.currentMachine)
|
||||
logError("pas de machine courrante");
|
||||
else {
|
||||
var c = '';
|
||||
while ( c == '')
|
||||
c = prompt("Nom de la machine :",Machines.currentMachine.nomCourt);
|
||||
if (c == null)
|
||||
return false;
|
||||
// AJAX stuff
|
||||
Machines.AJAX.call('AJAXChangerNom?nouveauNom=' + c + '&mid=' + Machines.currentMachine.mid,
|
||||
Machines.actions.callback);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Machines.actions.formulaire.supprimer = function() {
|
||||
if (!Machines.currentMachine)
|
||||
logError("pas de machine courrante");
|
||||
else {
|
||||
if (confirm("Supprimer la machine " + Machines.currentMachine.nomCourt +" ?")) {
|
||||
// AJAX stuff
|
||||
Machines.AJAX.call('AJAXSupprimerMachine?mid=' + Machines.currentMachine.mid,
|
||||
Machines.actions.callback);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Machines.actions.formulaire.nouvelleMachine = function(type) {
|
||||
replaceChildNodes( "gestion_machines_main_frame",
|
||||
A({"href":"#", "onclick":"Machines.listeMachines.load(); return false;"},"Retour"),
|
||||
H2({}, "Nouvelle machine"),
|
||||
FORM({"style":"clear:both;", 'onsubmit':'Machines.actions.creerMachine(this.typeField.value, this.nom.value, this.mac.value);return false;'},
|
||||
createDOM('label', {'for':'add_machine_nom'}, "Nom de la machine : "),
|
||||
INPUT({"name":"nom"}),
|
||||
BR(),
|
||||
createDOM('label', {'for':'add_machine_mac'}, "Adresse MAC : "),
|
||||
INPUT({"name":"mac"}),
|
||||
BR(),
|
||||
createDOM('label', {'for':'add_machine_type'}, "Type de machine : "),
|
||||
SPAN({'id':'add_machine_type'}, type),
|
||||
INPUT({"name":"typeField", 'type':'hidden', 'value':type}),
|
||||
BR(),
|
||||
BUTTON({"class":"liens", 'type':'submit'}, 'Ajouter')
|
||||
)
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
Machines.actions.creerMachine = function(type, nom, mac) {
|
||||
Machines.AJAX.call('AJAXCreerMachine?nomNouvelleMachine=' + nom
|
||||
+ '&MACNouvelleMachine=' + mac
|
||||
+ '&typeNouvelleMachine=' + type,
|
||||
Machines.actions.callback);
|
||||
}
|
||||
|
||||
/*****************************
|
||||
Machines.AJAX
|
||||
*****************************/
|
||||
Machines.AJAX = {}
|
||||
|
||||
Machines.AJAX.call = function(page, callBack) {
|
||||
logDebug("calling AJAX : " + page);
|
||||
var e = loadJSONDoc(page);
|
||||
e.addCallback(callBack);
|
||||
e.addErrback(this.errorHandler);
|
||||
Crans.loading.display(true);
|
||||
|
||||
}
|
||||
|
||||
Machines.AJAX.errorHandler = function(d) {
|
||||
//Machines.AJAX..modifPrix("Erreur", false);
|
||||
logError("AJAX Error: " + d);
|
||||
Crans.loading.display(false);
|
||||
}
|
||||
|
41
intranet/static/scripts/moncompte.js
Normal file
41
intranet/static/scripts/moncompte.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
function askForName(oldName) {
|
||||
var c = '';
|
||||
while ( c == '')
|
||||
c = prompt("Votre nom :",oldName);
|
||||
if (c == null)
|
||||
return false;
|
||||
else
|
||||
window.location.href= 'changeNomAdherent?nouveauNom=' + c;
|
||||
}
|
||||
|
||||
|
||||
function askForSurname(oldSurname) {
|
||||
var c = '';
|
||||
while ( c == '')
|
||||
c = prompt("Votre prénom :",oldSurname);
|
||||
if (c == null)
|
||||
return false;
|
||||
else
|
||||
window.location.href= 'changePrenomAdherent?nouveauPrenom=' + c;
|
||||
}
|
||||
|
||||
function askForTel(oldTel) {
|
||||
var c = '';
|
||||
while ( c == '')
|
||||
c = prompt("Votre numéro de téléphone :",oldTel);
|
||||
if (c == null)
|
||||
return false;
|
||||
else
|
||||
window.location.href= 'changeTelAdherent?nouveauTel=' + c;
|
||||
}
|
||||
|
||||
|
||||
function newAlias() {
|
||||
var c = '';
|
||||
while ( c == '')
|
||||
c = prompt("Nouvel alias :");
|
||||
if (c == null)
|
||||
return false;
|
||||
else
|
||||
window.location.href= 'newAlias?alias=' + c + "#mailTab";
|
||||
}
|
|
@ -2,33 +2,34 @@ Popup = {};
|
|||
Popup.popupNode = null;
|
||||
Popup.visible = false;
|
||||
|
||||
Popup.display = function() {
|
||||
if (this.popupNode == null) {
|
||||
logError("Popup not created, cannot be displayed");
|
||||
return false;
|
||||
}
|
||||
appendChildNodes("pageContent", this.popupNode);
|
||||
this.visible = true;
|
||||
// logDebug("popup visible");
|
||||
Popup.display = function()
|
||||
{
|
||||
if (this.popupNode == null) {
|
||||
logError("Popup not created, cannot be displayed");
|
||||
return false;
|
||||
}
|
||||
appendChildNodes("pageContent", this.popupNode);
|
||||
this.visible = true;
|
||||
// logDebug("popup visible");
|
||||
}
|
||||
|
||||
Popup.create = function(options, title_popup, content) {
|
||||
var inPopup = DIV({"id":"__popupInDivId", "style":"background:white;margin:2px 5px;"}, content);
|
||||
var outPopup = DIV({"id":"__popupOutDivId","style":"background:#AE0F3E;z-index:500;float:left;padding:0;min-width:300px;position:fixed;top:30%;left:30%;right:30%;"}, H1({"style":"font-size:1em;margin:0;text-align:center;color:white;"}, IMG({"src":"/static/images/WindowTitleLogo.png","alt":"icon", "style":"margin:0 5px;"}), title_popup), inPopup );
|
||||
roundElement(outPopup);
|
||||
logDebug("Popup \""+ title_popup +"\" created");
|
||||
this.popupNode = outPopup;
|
||||
var inPopup = DIV({"id":"__popupInDivId", "style":"background:white;margin:2px 5px;"}, content);
|
||||
var outPopup = DIV({"id":"__popupOutDivId","style":"background:#AE0F3E;z-index:500;float:left;padding:0;min-width:300px;position:fixed;top:30%;left:30%;right:30%;"}, H1({"style":"font-size:1em;margin:0;text-align:center;color:white;"}, IMG({"src":"/static/images/WindowTitleLogo.png","alt":"icon", "style":"margin:0 5px;"}), title_popup), inPopup );
|
||||
roundElement(outPopup);
|
||||
logDebug("Popup \""+ title_popup +"\" created");
|
||||
this.popupNode = outPopup;
|
||||
}
|
||||
|
||||
Popup.hide = function() {
|
||||
if (this.visible) {
|
||||
removeElement(this.popupNode);
|
||||
this.visible = false;
|
||||
}
|
||||
// logDebug("popup not visible");
|
||||
if (this.visible) {
|
||||
removeElement(this.popupNode);
|
||||
this.visible = false;
|
||||
}
|
||||
// logDebug("popup not visible");
|
||||
}
|
||||
Popup.closeLink = function(options, text_link) {
|
||||
options["href"] = "#";
|
||||
options["onclick"] = "Popup.hide()";
|
||||
return A(options, text_link);
|
||||
}
|
||||
options["href"] = "#";
|
||||
options["onclick"] = "Popup.hide()";
|
||||
return A(options, text_link);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue