SLA and Service Directory code added
[unfold.git] / sla / static / js / sla.js
1 /**
2  * MyPlugin:    demonstration plugin
3  * Version:     0.1
4  * Description: Template for writing new plugins and illustrating the different
5  *              possibilities of the plugin API.
6  *              This file is part of the Manifold project 
7  * Requires:    js/plugin.js
8  * URL:         http://www.myslice.info
9  * Author:      Jordan AugĂ© <jordan.auge@lip6.fr>
10  * Copyright:   Copyright 2012-2013 UPMC Sorbonne UniversitĂ©s
11  * License:     GPLv3
12  */
13
14 (function($){
15
16     var MyPlugin = Plugin.extend({
17
18         /** XXX to check
19          * @brief Plugin constructor
20          * @param options : an associative array of setting values
21          * @param element : 
22          * @return : a jQuery collection of objects on which the plugin is
23          *     applied, which allows to maintain chainability of calls
24          */
25         init: function(options, element) {
26             // for debugging tools
27             this.classname="myplugin";
28             // Call the parent constructor, see FAQ when forgotten
29             this._super(options, element);
30
31             /* Member variables */
32
33             /* Plugin events */
34
35             /* Setup query and record handlers */
36
37             // Explain this will allow query events to be handled
38             // What happens when we don't define some events ?
39             // Some can be less efficient
40             this.listen_query(options.query_uuid);
41             this.listen_query(options.query_uuid, 'all');
42
43             /* GUI setup and event binding */
44             // call function
45
46         },
47
48         /* PLUGIN EVENTS */
49         // on_show like in querytable
50
51
52         /* GUI EVENTS */
53
54         // a function to bind events here: click change
55         // how to raise manifold events
56
57
58         /* GUI MANIPULATION */
59
60         // We advise you to write function to change behaviour of the GUI
61         // Will use naming helpers to access content _inside_ the plugin
62         // always refer to these functions in the remaining of the code
63
64
65
66          this.id('showEvaluations').click(function() {
67          alert("WARNING! The experiments are still running.
68              These SLA evaluations could be different at the end of the experiments."  );
69             $(".status").css("display","");
70          });
71          });
72
73         show_hide_button: function() 
74         {
75             // this.id, this.el, this.cl, this.elts
76             // same output as a jquery selector with some guarantees
77         },
78
79         /* TEMPLATES */
80
81         // see in the html template
82         // How to load a template, use of mustache
83
84         /* QUERY HANDLERS */
85
86         // How to make sure the plugin is not desynchronized
87         // He should manifest its interest in filters, fields or records
88         // functions triggered only if the proper listen is done
89
90         // no prefix
91
92         on_filter_added: function(filter)
93         {
94
95         },
96
97         // ... be sure to list all events here
98
99         /* RECORD HANDLERS */
100         on_all_new_record: function(record)
101         {
102             //
103         },
104
105         /* INTERNAL FUNCTIONS */
106         _dummy: function() {
107             // only convention, not strictly enforced at the moment
108         },
109
110     });
111
112     /* Plugin registration */
113     $.plugin('MyPlugin', MyPlugin);
114
115     // TODO Here use cases for instanciating plugins in different ways like in the pastie.
116
117 })(jQuery);
118
119
120 $(document).ready(function() {
121     $(".status-success").addClass("icon-ok-sign").attr("title", "Fulfilled")
122     $(".status-error").addClass("icon-remove-sign").attr("title", "Violated")
123     $(".status-non-determined").addClass("icon-exclamation-sign").attr("title", "Non determined")
124
125     $(".icon-plus, .icon-minus").click(function(){ $(this).toggleClass("icon-plus icon-minus")});
126     console.log("ready")
127 });
128
129 $(".agreement_detail").click(function (ev) { // for each edit contact url
130     ev.preventDefault(); // prevent navigation
131     var url = $(this).data("form"); // get the contact form url
132     $("#sla-modal-agreements-{{ a.agreement_id }}").load(url, function () { // load the url into the modal
133         $(this).modal('show'); // display the modal on url load
134     });
135     return false; // prevent the click propagation
136 });
137
138 $('.agreement-detail').live('submit', function () {
139     $.ajax({
140         type: $(this).attr('method'),
141         url: this.action,
142         data: $(this).serialize(),
143         context: this,
144         success: function (data, status) {
145             $('#sla-modal-agreements-{{ a.agreement_id }}').html(data);
146         }
147     });
148     return false;
149 });
150
151 $(document).ready(function() {
152     console.log("consumer_agreements ready");
153 });
154
155 $(".violation-detail").click(function(ev) { // for each edit contact url
156     ev.preventDefault(); // prevent navigation
157     var url = $(this).data("href");
158     $("#violation-modal").load(url, function() { // load the url into the modal
159         $(this).modal('show'); // display the modal on url load
160     });
161     return false; // prevent the click propagation
162 });
163
164
165  this.elts('showEvaluations').click(function(){displayDate()};
166
167