X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plugins%2Fqueryupdater%2Fstatic%2Fjs%2Fqueryupdater.js;h=3057cf5bb787fede4c1d55a0a06966eb762dbb1c;hb=3018b838efd77bc3b7b9ee1df727e328c8464db1;hp=ac7fc0aeccf3e70f473371fa4db69c8037c6553d;hpb=c99f1bd98ff355bd3f63b4929739ea5bd92cd6a3;p=unfold.git diff --git a/plugins/queryupdater/static/js/queryupdater.js b/plugins/queryupdater/static/js/queryupdater.js index ac7fc0ae..3057cf5b 100644 --- a/plugins/queryupdater/static/js/queryupdater.js +++ b/plugins/queryupdater/static/js/queryupdater.js @@ -29,10 +29,14 @@ var QueryUpdater = Plugin.extend({ init: function(options, element) { - this.classname="queryupdater"; + this.classname="queryupdater"; this._super(options, element); var self = this; + + this.initial = Array(); + this.selected_resources = Array(); + this.table = this.elmt('table').dataTable({ // the original querytable layout was // sDom: "<'row'<'col-xs-5'l><'col-xs-1'r><'col-xs-6'f>>t<'row'<'col-xs-5'i><'col-xs-7'p>>", @@ -40,7 +44,7 @@ sDom: "<'row'<'col-xs-5'l><'col-xs-1'r><'col-xs-6'f>>t>", // so this does not matter anymore now that the pagination area is turned off // sPaginationType: 'bootstrap', - bAutoWidth: true, + bAutoWidth: true, // bJQueryUI : true, // bRetrieve : true, // sScrollX : '100%', // Horizontal scrolling @@ -56,7 +60,7 @@ }); // XXX This should not be done at init... - this.elmt('update').click(this, this.do_update); + this.elmt('update').click(this, this.do_checksla); this.elmt('refresh').click(this, this.do_refresh); this.elmt('reset').click(this, this.do_reset); this.elmt('clear_annotations').click(this, this.do_clear_annotations); @@ -68,53 +72,249 @@ /***************************** GUI EVENTS *****************************/ - do_update: function(e) { - var self = e.data; + do_checksla: function(e) { var username = e.data.options.username; var urn = data.value; + var arrayselectedresources = data.selected_resources; + + var accepted_sla = Array(); + var count = 0; + var self = e.data; // XXX check that the query is not disabled console.log("DATA VALUE: " + data.value); + + //
SLA description
+ //Testbed guarantees 0.99 Uptime rate for 0.99 rate of the VirtualWall resources during the sliver lifetime
+ //SLA description
+ //Testbed guarantees 0.99 Uptime rate for 0.99 rate of the WiLab2 resources during the sliver lifetime
+ var promt = $('#modal-body'); + + // id="myModalLabel" + var flagVW = false; + var flagWi = false; + + promt.append('SLA description
'); + + var wilabForm = ""; + wilabForm += "SLA description
Testbed guarantees 0.99 Uptime rate for 0.99 rate of the VirtualWall resources during the sliver lifetime
'; + + var wallForm = ""; + wallForm += "Testbed guarantees 0.99 Uptime rate for 0.99 rate of the WiLab2 resources during the sliver lifetime
'); + promt.append(wilabForm); + promt.append('Testbed guarantees 0.99 Uptime rate for 0.99 rate of the VirtualWall resources during the sliver lifetime
'); + promt.append(wallForm); + promt.append('SLA description
Testbed guarantees 0.99 Uptime rate for 0.99 rate of the VirtualWall resources during the sliver lifetime
' + if(flagWi || flagVW){ $('#sla_dialog').show(); - $('#slamodal').modal('show'); + + $('#slamodal-wilab2').modal('show'); + } + else + { - $(document).ready(function() { - $("#accept_sla").click(function(){ - console.log("SLA ACCEPTED"); - console.log("With username: " + username); - if(urn.toLowerCase().indexOf("wall2") >= 0){ - $.post("/sla/agreements/simplecreate", - { "template_id": "iMindsServiceVirtualwall", - "user": username, - "expiration_time": new Date() // jgarcia: FIXME - }); - } else if(urn.toLowerCase().indexOf("wilab2") >= 0){ - $.post("/sla/agreements/simplecreate", - { "template_id":"iMindsServiceWiLab2", - "user":username, - "expiration_time": new Date() // jgarcia: FIXME - }); - } - $('#slamodal').modal('hide'); - console.log("Executing raise_event after sending SLA"); - // manifold.raise_event(self.options.query_uuid, RUN_UPDATE); - }); - }); - - $(document).ready(function() { - $("#dismiss_sla").click(function(){ - console.log("SLA NOT ACCEPTED"); - $('#slamodal').modal('hide'); - }); - }); - } else { - console.log("Executing raise_event"); + var username = e.data.options.username; + var urn = data.value; + // XXX check that the query is not disabled + + self.spin(); + console.log("do_update"); + // XXX check that the query is not disabled manifold.raise_event(self.options.query_uuid, RUN_UPDATE); + return; } + + $("#accept_sla_wilab2").click(function(){ + console.log("SLA ACCEPTED"); + console.log("With username: " + username); + + // var promt = $('#modal-body'); + // var notchecked = true; + // for (var i=0;i<50;i++) + // { + // var wielement = $('#wi'+i); + // var wallElement = $('#wall'+i); + // if(wielement != null && !wielement.checked) + // { + // notchecked = false; + // } + // if(wallElement!= null && !wallElement.checked) + // { + // notchecked = false; + // } + // } + + + if(flagDouble) + { + $.post("/sla/agreements/simplecreate", + { "template_id": "iMindsServiceWiLab2", + "user": username, + "expiration_time": new Date().toISOString() + }); + $.post("/sla/agreements/simplecreate", + { "template_id": "iMindsServiceVirtualwall", + "user": username, + "expiration_time": new Date().toISOString() + }); + + $('#slamodal-wilab2').modal('hide'); + accepted_sla["wilab2"] = true; + + manifold.raise_event(self.options.query_uuid, RUN_UPDATE); + } + $('#modal-body').empty(); + }); + + $("#dismiss_sla_wilab2").click(function(){ + console.log("SLA NOT ACCEPTED"); + $('#slamodal-wilab2').modal('hide'); + $('#modal-body').empty(); + }); + + // } else { + // this.do_update(e); + // } + + // for(var iter = 0; iter < arrayselectedresources.length; iter++){ + // var list = ''+arrayselectedresources[iter].toLowerCase()+'