X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plugins%2Fsladialog%2Fstatic%2Fjs%2Fsladialog.js;h=8ea38dc525dae53d7c2be5409eabe35875f5db94;hb=26b2d32f6132a3e619f47411adeccfa693b71162;hp=89d1ab0da12e8bb2ad0add77130c631cf6fb1863;hpb=ba476841726dc818c0efd3ed25e42955a39fc504;p=myslice.git diff --git a/plugins/sladialog/static/js/sladialog.js b/plugins/sladialog/static/js/sladialog.js index 89d1ab0d..8ea38dc5 100644 --- a/plugins/sladialog/static/js/sladialog.js +++ b/plugins/sladialog/static/js/sladialog.js @@ -1,13 +1,10 @@ /** - * MyPlugin: demonstration plugin - * Version: 0.1 - * Description: Template for writing new plugins and illustrating the different - * possibilities of the plugin API. - * This file is part of the Manifold project + * SlaDialog + * Description: Plugin to allow SLA acceptance and creation to MySlice portal + * in Fed4FIRE * Requires: js/plugin.js - * URL: http://www.myslice.info - * Author: Jordan Augé - * Copyright: Copyright 2012-2013 UPMC Sorbonne Universités + * Author: Javier García Lloreda + * Copyright: Copyright Atos Spain S.A. * License: GPLv3 */ @@ -15,17 +12,11 @@ var SlaDialog = Plugin.extend({ - /** XXX to check - * @brief Plugin constructor - * @param options : an associative array of setting values - * @param element : - * @return : a jQuery collection of objects on which the plugin is - * applied, which allows to maintain chainability of calls - */ + accepted_slas: {}, + queries: [], + init: function(options, element) { - // for debugging tools - this.classname="SlaDialog"; - // Call the parent constructor, see FAQ when forgotten + this.classname = "SlaDialog"; this._super(options, element); /* Member variables */ @@ -33,154 +24,216 @@ /* Plugin events */ /* Setup query and record handlers */ - - // Explain this will allow query events to be handled - // What happens when we don't define some events ? - // Some can be less efficient this.listen_query(options.query_uuid); /* GUI setup and event binding */ + // call function + this.button_binding(); + // Get testbeds with sla and store them in localStorage + this.get_testbeds_with_sla(); }, - find_row: function(key) - { - // key in third position, column id = 2 - var KEY_POS = 2; + get_testbeds_with_sla: function () { + var self = this; + return $.get('/sla/testbeds/', function(data) { + if (typeof(Storage) !== "undefined") { + if (!localStorage.getItem("sla_testbeds")) { + var testbeds = data; + localStorage.setItem("sla_testbeds", testbeds); + } + } + }).done(function(data) { + self.get_sla_templates(data); + alert("sla templates recovered: " + data); + }); + }, - var cols = $.grep(this.table.fnSettings().aoData, function(col) { - return (col._aData[KEY_POS] == key); - } ); + get_sla_templates: function (testbeds) { + + testbeds.forEach(function(testbed, index, array) { + + if(testbed!="omf:netmode") { return } // TODO: remove + + $.get('/sla/agreements/templates/' + testbed, function(slo) { + + $(".modal-body #sla_template").append(slo); + + var content = + "