root / ui / templates / standard.html @ d1bcc1e7
History | View | Annotate | Download (17.3 kB)
1 | 42f67a2a | Dimitris Moraitis | {% load i18n %} |
---|---|---|---|
2 | 42f67a2a | Dimitris Moraitis | |
3 | 42f67a2a | Dimitris Moraitis | <!-- the standard view -->
|
4 | 42f67a2a | Dimitris Moraitis | <div id="machinesview" class="standard"> |
5 | 42f67a2a | Dimitris Moraitis | <div id="spinner"></div> |
6 | 42f67a2a | Dimitris Moraitis | <div class="machine" id="machine-template" style="display:none"> |
7 | 6d0a36e5 | Dimitris Moraitis | <div class="actions"> |
8 | 6d0a36e5 | Dimitris Moraitis | <a href="#" class="action-start">{% trans "Start" %}</a> |
9 | 6d0a36e5 | Dimitris Moraitis | <a href="#" class="action-reboot">{% trans "Reboot" %}</a> |
10 | 6d0a36e5 | Dimitris Moraitis | <a href="#" class="action-shutdown">{% trans "Shutdown" %}</a> |
11 | f3632e8d | Christodoulos Psaltis | <a href="#" class="action-destroy">{% trans "Destroy" %}</a> |
12 | 6d0a36e5 | Dimitris Moraitis | </div>
|
13 | 42f67a2a | Dimitris Moraitis | <div class="state"> |
14 | 42f67a2a | Dimitris Moraitis | <div class="status">{% trans "Running" %}</div> |
15 | 42f67a2a | Dimitris Moraitis | <div class="indicator"></div> |
16 | 42f67a2a | Dimitris Moraitis | <div class="indicator"></div> |
17 | 42f67a2a | Dimitris Moraitis | <div class="indicator"></div> |
18 | 42f67a2a | Dimitris Moraitis | <div class="indicator"></div> |
19 | 1d72dcdc | Markos Gogoulos | <img class="spinner" style="display:none" src="/static/progress.gif" /> |
20 | 1d72dcdc | Markos Gogoulos | <img class="wave" style="display:none" src="/static/wave.gif" /> |
21 | 42f67a2a | Dimitris Moraitis | </div>
|
22 | 42f67a2a | Dimitris Moraitis | <img class="logo" src="" /> |
23 | 42f67a2a | Dimitris Moraitis | <a href="#" class="name"> |
24 | 528a931a | Christodoulos Psaltis | <h5>{% trans "Name: " %}<span class="name">node.name</span><span class="rename"></span></h5> |
25 | 42f67a2a | Dimitris Moraitis | </a>
|
26 | 42f67a2a | Dimitris Moraitis | <a href="#" class="ip"> |
27 | 528a931a | Christodoulos Psaltis | <h5>{% trans "IP: " %}<span class="public">node.public_ip</span></h5> |
28 | 42f67a2a | Dimitris Moraitis | </a>
|
29 | 42f67a2a | Dimitris Moraitis | <h5 class="settings"> |
30 | 339712cb | Christodoulos Psaltis | {% trans "Show:" %} |
31 | 67679131 | Christodoulos Psaltis | <a class="show-disks"href="#">{% trans "disks" %}</a> | |
32 | 67679131 | Christodoulos Psaltis | <a class="show-networks"href="#">{% trans "networks" %}</a> | |
33 | 67679131 | Christodoulos Psaltis | <a class="show-group"href="#">{% trans "group" %}</a> | |
34 | 339712cb | Christodoulos Psaltis | <a class="show-metadata" href="#">{% trans "metadata" %}</a> |
35 | 42f67a2a | Dimitris Moraitis | </h5>
|
36 | 267403ca | Dimitris Moraitis | <div class="confirm_single"> |
37 | c2464ef2 | Christodoulos Psaltis | <button class="yes">{% trans "Confirm" %}</button> |
38 | c2464ef2 | Christodoulos Psaltis | <button class="no">{% trans "Cancel" %}</button> |
39 | 31343277 | Christodoulos Psaltis | </div>
|
40 | 695e1b21 | Dimitris Moraitis | <div class="action_error" align="center"> |
41 | 528a931a | Christodoulos Psaltis | {% trans "<span class='orange'>Error</span> on" %} <span class="action">{% trans "error action" %}</span> |
42 | 038383b1 | Dimitris Moraitis | <span class="code"></span> |
43 | 695e1b21 | Dimitris Moraitis | <span class="message"></span> |
44 | 528a931a | Christodoulos Psaltis | <button class="details">{% trans "Details" %}</button> |
45 | 879748ec | Markos Gogoulos | </div>
|
46 | c2464ef2 | Christodoulos Psaltis | <div class="separator"></div> |
47 | 42f67a2a | Dimitris Moraitis | </div>
|
48 | 42f67a2a | Dimitris Moraitis | <div class="running"></div> |
49 | e5b0ba20 | Vangelis Koukis | <div id="mini" class="separator"></div> |
50 | 42f67a2a | Dimitris Moraitis | <div class="terminated"></div> |
51 | 42f67a2a | Dimitris Moraitis | </div>
|
52 | 42f67a2a | Dimitris Moraitis | |
53 | 42f67a2a | Dimitris Moraitis | <script>
|
54 | 339712cb | Christodoulos Psaltis | |
55 | c902e956 | Christodoulos Psaltis | // intercept edit metadata click
|
56 | 339712cb | Christodoulos Psaltis | $("a.show-metadata").live('click', function() {
|
57 | 339712cb | Christodoulos Psaltis | // get server name and server ID
|
58 | 339712cb | Christodoulos Psaltis | var serverID = $(this).parent().parent().attr("id");
|
59 | 339712cb | Christodoulos Psaltis | var serverName = $(this).parent().prevAll("a.name").find("span.name").text();
|
60 | 4629cc1f | Christodoulos Psaltis | // set server name to all related metadata dialogs
|
61 | 4629cc1f | Christodoulos Psaltis | $("#editor-1 h3 span").text(serverName);
|
62 | 4629cc1f | Christodoulos Psaltis | $("#editor-2 h3 span").text(serverName);
|
63 | 4629cc1f | Christodoulos Psaltis | // set server id to all related metadata dialogs
|
64 | 4629cc1f | Christodoulos Psaltis | $("#editor-1 h3").attr('id', serverID);
|
65 | 4629cc1f | Christodoulos Psaltis | $("#editor-2 h3").attr('id', serverID);
|
66 | 4629cc1f | Christodoulos Psaltis | editMetadata();
|
67 | 339712cb | Christodoulos Psaltis | });
|
68 | 339712cb | Christodoulos Psaltis | |
69 | 42f67a2a | Dimitris Moraitis | // intercept reboot click
|
70 | 42f67a2a | Dimitris Moraitis | $("div.actions a.action-reboot").live('click', function(){
|
71 | 42f67a2a | Dimitris Moraitis | var serverID = $(this).parent().parent().attr("id");
|
72 | 42f67a2a | Dimitris Moraitis | var serverName = $(this).parent().prevAll("a.name").find("span.name").text();
|
73 | 267403ca | Dimitris Moraitis | var found = false;
|
74 | 695e1b21 | Dimitris Moraitis |
|
75 | aa0534a7 | Dimitris Moraitis | $(this).parent().children('a').removeClass('selected');
|
76 | aa0534a7 | Dimitris Moraitis | $(this).addClass('selected');
|
77 | 695e1b21 | Dimitris Moraitis | $(this).parent().addClass('display');
|
78 | 695e1b21 | Dimitris Moraitis | $(this).parent().parent().find('.action_error').hide();
|
79 | 267403ca | Dimitris Moraitis | for (i=0;i<pending_actions.length;i++){ // if there is already a pending action for this server replace it
|
80 | 267403ca | Dimitris Moraitis | if (pending_actions[i][1]==serverID){
|
81 | 267403ca | Dimitris Moraitis | pending_actions[i][0] = reboot;
|
82 | 267403ca | Dimitris Moraitis | found = true
|
83 | 267403ca | Dimitris Moraitis | }
|
84 | 267403ca | Dimitris Moraitis | }
|
85 | 267403ca | Dimitris Moraitis | if (!found) // no pending action for this server was found, so let's just add it to the list
|
86 | 267403ca | Dimitris Moraitis | pending_actions.push([reboot, serverID, serverName])
|
87 | 267403ca | Dimitris Moraitis | update_confirmations();
|
88 | 42f67a2a | Dimitris Moraitis | return false;
|
89 | 42f67a2a | Dimitris Moraitis | });
|
90 | 42f67a2a | Dimitris Moraitis | |
91 | 42f67a2a | Dimitris Moraitis | // intercept shutdown click
|
92 | 42f67a2a | Dimitris Moraitis | $("div.actions a.action-shutdown").live('click', function(){
|
93 | 42f67a2a | Dimitris Moraitis | var serverID = $(this).parent().parent().attr("id");
|
94 | 42f67a2a | Dimitris Moraitis | var serverName = $(this).parent().prevAll("a.name").find("span.name").text();
|
95 | 267403ca | Dimitris Moraitis | var found = false;
|
96 | aa0534a7 | Dimitris Moraitis | $(this).parent().children('a').removeClass('selected');
|
97 | aa0534a7 | Dimitris Moraitis | $(this).addClass('selected');
|
98 | aa0534a7 | Dimitris Moraitis | $(this).parent().addClass('display')
|
99 | 695e1b21 | Dimitris Moraitis | $(this).parent().parent().find('.action_error').hide();
|
100 | aa0534a7 | Dimitris Moraitis | |
101 | 267403ca | Dimitris Moraitis | for (i=0;i<pending_actions.length;i++){ // if there is already a pending action for this server replace it
|
102 | 267403ca | Dimitris Moraitis | if (pending_actions[i][1]==serverID){
|
103 | 267403ca | Dimitris Moraitis | pending_actions[i][0] = shutdown;
|
104 | 267403ca | Dimitris Moraitis | found = true
|
105 | 267403ca | Dimitris Moraitis | }
|
106 | 267403ca | Dimitris Moraitis | }
|
107 | 267403ca | Dimitris Moraitis | if (!found) // no pending action for this server was found, so let's just add it to the list
|
108 | 267403ca | Dimitris Moraitis | pending_actions.push([shutdown, serverID, serverName])
|
109 | 267403ca | Dimitris Moraitis | update_confirmations();
|
110 | 42f67a2a | Dimitris Moraitis | return false;
|
111 | 42f67a2a | Dimitris Moraitis | });
|
112 | eae0a59a | Dimitris Moraitis | |
113 | 42f67a2a | Dimitris Moraitis | // intercept start click
|
114 | 42f67a2a | Dimitris Moraitis | $("div.actions a.action-start").live('click', function(){
|
115 | 42f67a2a | Dimitris Moraitis | var serverID = $(this).parent().parent().attr("id");
|
116 | 42f67a2a | Dimitris Moraitis | var serverName = $(this).parent().prevAll("a.name").find("span.name").text();
|
117 | 267403ca | Dimitris Moraitis | var found = false;
|
118 | aa0534a7 | Dimitris Moraitis | $(this).parent().children('a').removeClass('selected');
|
119 | aa0534a7 | Dimitris Moraitis | $(this).addClass('selected');
|
120 | aa0534a7 | Dimitris Moraitis | $(this).parent().addClass('display')
|
121 | 695e1b21 | Dimitris Moraitis | $(this).parent().parent().find('.action_error').hide();
|
122 | 695e1b21 | Dimitris Moraitis | |
123 | 267403ca | Dimitris Moraitis | for (i=0;i<pending_actions.length;i++){ // if there is already a pending action for this server replace it
|
124 | 267403ca | Dimitris Moraitis | if (pending_actions[i][1]==serverID){
|
125 | 267403ca | Dimitris Moraitis | pending_actions[i][0] = start;
|
126 | 267403ca | Dimitris Moraitis | found = true
|
127 | 267403ca | Dimitris Moraitis | }
|
128 | 267403ca | Dimitris Moraitis | }
|
129 | 267403ca | Dimitris Moraitis | if (!found) // no pending action for this server was found, so let's just add it to the list
|
130 | 267403ca | Dimitris Moraitis | pending_actions.push([start, serverID, serverName])
|
131 | 267403ca | Dimitris Moraitis | update_confirmations();
|
132 | 267403ca | Dimitris Moraitis | return false;
|
133 | 267403ca | Dimitris Moraitis | });
|
134 | 267403ca | Dimitris Moraitis | |
135 | f3632e8d | Christodoulos Psaltis | // intercept destroy click
|
136 | f3632e8d | Christodoulos Psaltis | $("div.actions a.action-destroy").live('click', function(){
|
137 | f3632e8d | Christodoulos Psaltis | var serverID = $(this).parent().parent().attr("id");
|
138 | f3632e8d | Christodoulos Psaltis | var serverName = $(this).parent().prevAll("a.name").find("span.name").text();
|
139 | f3632e8d | Christodoulos Psaltis | var found = false;
|
140 | f3632e8d | Christodoulos Psaltis | $(this).parent().children('a').removeClass('selected');
|
141 | f3632e8d | Christodoulos Psaltis | $(this).addClass('selected');
|
142 | f3632e8d | Christodoulos Psaltis | $(this).parent().addClass('display')
|
143 | f3632e8d | Christodoulos Psaltis | $(this).parent().parent().find('.action_error').hide();
|
144 | f3632e8d | Christodoulos Psaltis | |
145 | f3632e8d | Christodoulos Psaltis | for (i=0;i<pending_actions.length;i++){ // if there is already a pending action for this server replace it
|
146 | f3632e8d | Christodoulos Psaltis | if (pending_actions[i][1]==serverID){
|
147 | c5ffb0de | Christodoulos Psaltis | pending_actions[i][0] = destroy;
|
148 | f3632e8d | Christodoulos Psaltis | found = true
|
149 | f3632e8d | Christodoulos Psaltis | }
|
150 | f3632e8d | Christodoulos Psaltis | }
|
151 | f3632e8d | Christodoulos Psaltis | if (!found) // no pending action for this server was found, so let's just add it to the list
|
152 | f3632e8d | Christodoulos Psaltis | pending_actions.push([destroy, serverID, serverName])
|
153 | f3632e8d | Christodoulos Psaltis | update_confirmations();
|
154 | f3632e8d | Christodoulos Psaltis | return false;
|
155 | f3632e8d | Christodoulos Psaltis | });
|
156 | f3632e8d | Christodoulos Psaltis | |
157 | 267403ca | Dimitris Moraitis | $("div.confirm_single .yes").live('click', function(){
|
158 | 267403ca | Dimitris Moraitis | var serverID = $(this).parent().parent().attr("id");
|
159 | 267403ca | Dimitris Moraitis | for (i=0;i<pending_actions.length;i++){ // if there is a pending action for this server execute it
|
160 | 267403ca | Dimitris Moraitis | if (pending_actions[i][1]==serverID){
|
161 | a1a31201 | Dimitris Moraitis | action = pending_actions.splice(i,1)[0]; // extract action
|
162 | 198e13aa | Christodoulos Psaltis | // change the status text in cases where no api state exists
|
163 | 198e13aa | Christodoulos Psaltis | if (action[0] == start) {
|
164 | 198e13aa | Christodoulos Psaltis | $(this).parent().parent().find('.status').text('Starting');
|
165 | 198e13aa | Christodoulos Psaltis | $(this).parent().parent().find('.spinner').show();
|
166 | 198e13aa | Christodoulos Psaltis | } else if (action[0] == shutdown) {
|
167 | 198e13aa | Christodoulos Psaltis | $(this).parent().parent().find('.status').text('Shutting down');
|
168 | 198e13aa | Christodoulos Psaltis | $(this).parent().parent().find('.spinner').show();
|
169 | 66edd851 | Christodoulos Psaltis | } else if (action[0] == reboot) {
|
170 | 66edd851 | Christodoulos Psaltis | $(this).parent().parent().find('.status').text('Rebooting');
|
171 | 66edd851 | Christodoulos Psaltis | $(this).parent().parent().find('.spinner').show();
|
172 | 66edd851 | Christodoulos Psaltis | } else if (action[0] == destroy) {
|
173 | 66edd851 | Christodoulos Psaltis | $(this).parent().parent().find('.status').text('Destroying');
|
174 | 66edd851 | Christodoulos Psaltis | $(this).parent().parent().find('.spinner').show();
|
175 | 66edd851 | Christodoulos Psaltis | }
|
176 | 198e13aa | Christodoulos Psaltis | action[0]([action[1]]); // execute action
|
177 | 267403ca | Dimitris Moraitis | }
|
178 | 267403ca | Dimitris Moraitis | }
|
179 | 267403ca | Dimitris Moraitis | $(this).parent().hide();
|
180 | aa0534a7 | Dimitris Moraitis | $(this).parent().parent().children('div.actions').children('a').removeClass('selected');
|
181 | aa0534a7 | Dimitris Moraitis | $(this).parent().parent().children('.state').children('.spinner').show()
|
182 | aa0534a7 | Dimitris Moraitis | $(this).parent().parent().children('div.actions').removeClass('display');
|
183 | 198e13aa | Christodoulos Psaltis | update_confirmations();
|
184 | 42f67a2a | Dimitris Moraitis | return false;
|
185 | 42f67a2a | Dimitris Moraitis | });
|
186 | 42f67a2a | Dimitris Moraitis | |
187 | 267403ca | Dimitris Moraitis | $("div.confirm_single .no").live('click', function(){
|
188 | 267403ca | Dimitris Moraitis | // remove the action from the pending list
|
189 | 267403ca | Dimitris Moraitis | var serverID = $(this).parent().parent().attr("id");
|
190 | aa0534a7 | Dimitris Moraitis |
|
191 | aa0534a7 | Dimitris Moraitis | $(this).parent().parent().children('div.actions').children('a').removeClass('selected');
|
192 | aa0534a7 | Dimitris Moraitis | $(this).parent().parent().children('div.actions').removeClass('display');
|
193 | 267403ca | Dimitris Moraitis | for (i=0;i<pending_actions.length;i++){ // if there is a pending action for this server remove it
|
194 | 267403ca | Dimitris Moraitis | if (pending_actions[i][1]==serverID){
|
195 | 267403ca | Dimitris Moraitis | pending_actions.splice(i,1);
|
196 | 267403ca | Dimitris Moraitis | }
|
197 | 267403ca | Dimitris Moraitis | }
|
198 | 267403ca | Dimitris Moraitis | $(this).parent().hide();
|
199 | 3d286f84 | Dimitris Moraitis | update_confirmations();
|
200 | 267403ca | Dimitris Moraitis | return false;
|
201 | 267403ca | Dimitris Moraitis | });
|
202 | 267403ca | Dimitris Moraitis | |
203 | 695e1b21 | Dimitris Moraitis | $("div.action_error .details").live('click', function(){
|
204 | 695e1b21 | Dimitris Moraitis | // remove the action from the pending list
|
205 | 038383b1 | Dimitris Moraitis | ajax_error($(this).parent().children('.code').text(), undefined, $(this).parent().children('.action').text(), $(this).parent().children('.message').text());
|
206 | 695e1b21 | Dimitris Moraitis | $(this).parent().hide();
|
207 | 695e1b21 | Dimitris Moraitis | });
|
208 | 695e1b21 | Dimitris Moraitis | |
209 | 695e1b21 | Dimitris Moraitis | |
210 | eae0a59a | Dimitris Moraitis | // update the servers list
|
211 | eae0a59a | Dimitris Moraitis | function update_machines_view(data){
|
212 | eae0a59a | Dimitris Moraitis | /*
|
213 | 1a49199e | Dimitris Moraitis | Go through the servers in the input data. Update existing entries, add
|
214 | eae0a59a | Dimitris Moraitis | new ones to the list
|
215 | ce4f9227 | Mike Muzurakis | */
|
216 | 0fb26db0 | Mike Muzurakis | |
217 | 0fb26db0 | Mike Muzurakis | // show message in case user has no servers!
|
218 | 0fb26db0 | Mike Muzurakis | if (data.servers.values.length == 0) {
|
219 | 0fb26db0 | Mike Muzurakis | showWelcome()
|
220 | 0fb26db0 | Mike Muzurakis | } else {
|
221 | 0fb26db0 | Mike Muzurakis | hideWelcome()
|
222 | 0fb26db0 | Mike Muzurakis | }
|
223 | ce4f9227 | Mike Muzurakis |
|
224 | 7e45ddef | Dimitris Moraitis | $.each(data.servers.values, function(i,server){
|
225 | 150eb972 | Christodoulos Psaltis | existing = $('#' + server.id);
|
226 | eae0a59a | Dimitris Moraitis |
|
227 | 87feccc4 | Dimitris Moraitis | // if multiple machines exist in the DOM, delete all but one
|
228 | 87feccc4 | Dimitris Moraitis | // defensive coding - that shouldn't happen normally
|
229 | 87feccc4 | Dimitris Moraitis | while (existing.length > 1){
|
230 | eae0a59a | Dimitris Moraitis | existing.remove();
|
231 | eae0a59a | Dimitris Moraitis | }
|
232 | a64e74f0 | Markos Gogoulos | |
233 | a64e74f0 | Markos Gogoulos | var server_image = os_icon(server.metadata);
|
234 | a64e74f0 | Markos Gogoulos | |
235 | a64e74f0 | Markos Gogoulos | |
236 | 87feccc4 | Dimitris Moraitis | // server already exists in DOM
|
237 | 1a49199e | Dimitris Moraitis | if (existing.length){
|
238 | ab5282e4 | Dimitris Moraitis | $("div.machine:last-child").find("div.separator").show();
|
239 | ab5282e4 | Dimitris Moraitis | |
240 | 87feccc4 | Dimitris Moraitis | // if the status is deleted, delete it from the DOM
|
241 | 87feccc4 | Dimitris Moraitis | if (server.status == 'DELETED') {
|
242 | d1aa78ff | Mike Muzurakis | existing.remove();
|
243 | d1aa78ff | Mike Muzurakis | // Reload the page to check if server list is empty
|
244 | f5ebca32 | Mike Muzurakis | standard_view()
|
245 | 81d48bff | Christodoulos Psaltis | try {
|
246 | 1a49199e | Dimitris Moraitis | console.info(existing.find("a.name span.name").text() + ' removed');
|
247 | 1a49199e | Dimitris Moraitis | } catch(err) {}
|
248 | 1a49199e | Dimitris Moraitis | } else if (existing.find(".status").text() != STATUS_MESSAGES[server.status]) {
|
249 | 198e13aa | Christodoulos Psaltis | |
250 | 1a49199e | Dimitris Moraitis | try { // firebug console logging
|
251 | 150eb972 | Christodoulos Psaltis | console.info(existing.find("a.name span.name").text() + ' from '
|
252 | 150eb972 | Christodoulos Psaltis | + existing.find(".status").text() + ' to ' + STATUS_MESSAGES[server.status]);
|
253 | 81d48bff | Christodoulos Psaltis | } catch(err) {}
|
254 | 33282d93 | Markos Gogoulos | //show reboot and shutdown actions
|
255 | 33282d93 | Markos Gogoulos | if (server.status == 'ACTIVE' || server.status == 'REBOOT') {
|
256 | e4f426f1 | Dimitris Moraitis | $('div.#' + server.id + ' a.action-reboot').attr('style','');
|
257 | e4f426f1 | Dimitris Moraitis | $('div.#' + server.id + ' a.action-shutdown').attr('style','');
|
258 | 33282d93 | Markos Gogoulos | $('div.#' + server.id + ' a.action-destroy').removeClass('destroy-padding');
|
259 | 33282d93 | Markos Gogoulos | }
|
260 | 1a49199e | Dimitris Moraitis | if (['BUILD','ACTIVE','REBOOT'].indexOf(server.status) >= 0 &&
|
261 | 513bc21d | Christodoulos Psaltis | [STATUS_MESSAGES['STOPPED'], STATUS_MESSAGES['ERROR'],
|
262 | 513bc21d | Christodoulos Psaltis | 'Starting'].indexOf(existing.find(".status").text()) >= 0) {
|
263 | 513bc21d | Christodoulos Psaltis | // from stopped, on error or starting to building, active or rebooting
|
264 | 513bc21d | Christodoulos Psaltis | // starting is not an api state, it means the vm is stopped or on error
|
265 | 1a49199e | Dimitris Moraitis | moved = existing.clone().appendTo(".running");
|
266 | 333d00ff | Markos Gogoulos | moved.find("img.logo").attr("src","static/machines/" + server_image + '-on.png');
|
267 | 1a49199e | Dimitris Moraitis | existing.remove();
|
268 | 1a49199e | Dimitris Moraitis | existing = moved;
|
269 | 513bc21d | Christodoulos Psaltis | existing.find(".status").text(STATUS_MESSAGES[server.status]);
|
270 | 1a49199e | Dimitris Moraitis | } else if (['STOPPED','ERROR'].indexOf(server.status) >= 0 &&
|
271 | 513bc21d | Christodoulos Psaltis | [STATUS_MESSAGES['ACTIVE'], STATUS_MESSAGES['BUILD'], STATUS_MESSAGES['REBOOT'],
|
272 | 513bc21d | Christodoulos Psaltis | 'Shutting down'].indexOf(existing.find(".status").text()) >= 0) {
|
273 | 513bc21d | Christodoulos Psaltis | // from active, building, rebooting, or shutting down to stopped or on error
|
274 | e357c9f0 | Christodoulos Psaltis | // shutting down is not an api state, it means the server is active
|
275 | 198e13aa | Christodoulos Psaltis | moved = existing.clone().appendTo(".terminated");
|
276 | 513bc21d | Christodoulos Psaltis | moved.find("img.logo").attr("src","static/machines/" + server_image + '-off.png');
|
277 | 198e13aa | Christodoulos Psaltis | existing.remove();
|
278 | 198e13aa | Christodoulos Psaltis | existing = moved;
|
279 | 513bc21d | Christodoulos Psaltis | existing.find(".status").text(STATUS_MESSAGES[server.status]);
|
280 | 513bc21d | Christodoulos Psaltis | } else if (['BUILD','ACTIVE','REBOOT'].indexOf(server.status) >= 0 &&
|
281 | 513bc21d | Christodoulos Psaltis | [STATUS_MESSAGES['ACTIVE'], STATUS_MESSAGES['BUILD'],
|
282 | 513bc21d | Christodoulos Psaltis | STATUS_MESSAGES['REBOOT']].indexOf(existing.find(".status").text()) >= 0) {
|
283 | e357c9f0 | Christodoulos Psaltis | // the server changes status, but remains in running list
|
284 | 513bc21d | Christodoulos Psaltis | existing.find(".status").text(STATUS_MESSAGES[server.status]);
|
285 | 513bc21d | Christodoulos Psaltis | } else if (['STOPPED','ERROR'].indexOf(server.status) >= 0 &&
|
286 | 513bc21d | Christodoulos Psaltis | [STATUS_MESSAGES['STOPPED'],
|
287 | 513bc21d | Christodoulos Psaltis | STATUS_MESSAGES['ERROR']].indexOf(existing.find(".status").text()) >= 0) {
|
288 | e357c9f0 | Christodoulos Psaltis | // the server changes status, but remains in terminated list
|
289 | 513bc21d | Christodoulos Psaltis | existing.find(".status").text(STATUS_MESSAGES[server.status]);
|
290 | 513bc21d | Christodoulos Psaltis | }
|
291 | 309d7ed2 | Dimitris Moraitis | existing.find('.spinner').hide();
|
292 | 309d7ed2 | Dimitris Moraitis | existing.find(' .wave').attr('src','static/wave.gif').show();
|
293 | 97a4b51d | Christodoulos Psaltis | setTimeout("$('#" + server.id +" .wave').attr('src','').hide()", 3000);
|
294 | e357c9f0 | Christodoulos Psaltis | // show spinner while the server is rebooting, starting or shutting down
|
295 | 513bc21d | Christodoulos Psaltis | if ([STATUS_MESSAGES['REBOOT'],
|
296 | 513bc21d | Christodoulos Psaltis | 'Starting', 'Shutting down'].indexOf(existing.find(".status").text()) >= 0 ) {
|
297 | 97a4b51d | Christodoulos Psaltis | existing.find(' .wave').hide();
|
298 | 97a4b51d | Christodoulos Psaltis | existing.find('.spinner').show();
|
299 | 198e13aa | Christodoulos Psaltis | }
|
300 | eae0a59a | Dimitris Moraitis | }
|
301 | eae0a59a | Dimitris Moraitis | existing.find("a.name span.name").text(server.name);
|
302 | 7e45ddef | Dimitris Moraitis | existing.find("a.ip span.public").text(String(server.addresses.values[0].values[0].addr).replace(',',' '));
|
303 | 87feccc4 | Dimitris Moraitis | } else if (server.status != 'DELETED') {
|
304 | 1a49199e | Dimitris Moraitis | // If it does not exist and it's not deleted, we should create it
|
305 | eae0a59a | Dimitris Moraitis | var machine = $("#machine-template").clone().attr("id", server.id).fadeIn("slow");
|
306 | eae0a59a | Dimitris Moraitis | machine.find("a.name span.name").text(server.name);
|
307 | 333d00ff | Markos Gogoulos | machine.find("img.logo").attr("src","static/machines/"+server_image+'-on.png');
|
308 | a64e74f0 | Markos Gogoulos | machine.find("span.imagetag").text(server_image);
|
309 | 7e45ddef | Dimitris Moraitis | machine.find("a.ip span.public").text(String(server.addresses.values[0].values[0].addr).replace(',',' '));
|
310 | eae0a59a | Dimitris Moraitis | machine.find(".status").text(STATUS_MESSAGES[server.status]);
|
311 | eae0a59a | Dimitris Moraitis | if (['BUILD', 'ACTIVE', 'REBOOT'].indexOf(server.status) >= 0){
|
312 | eae0a59a | Dimitris Moraitis | machine.appendTo(".running");
|
313 | eae0a59a | Dimitris Moraitis | } else {
|
314 | a64e74f0 | Markos Gogoulos | machine.find("img.logo").attr("src","static/machines/"+server_image+'-off.png');
|
315 | eae0a59a | Dimitris Moraitis | machine.appendTo(".terminated");
|
316 | eae0a59a | Dimitris Moraitis | }
|
317 | 63119250 | Christodoulos Psaltis | //show spinner while machine is building
|
318 | 198e13aa | Christodoulos Psaltis | if (server.status == 'BUILD' ||
|
319 | 198e13aa | Christodoulos Psaltis | ['Starting', 'Shutting down'].indexOf(existing.find(".status").text()) >= 0 ) {
|
320 | 97a4b51d | Christodoulos Psaltis | machine.find('.spinner').show();
|
321 | 97a4b51d | Christodoulos Psaltis | }
|
322 | e64bfe94 | Markos Gogoulos | //allow destroy action only while machine is building
|
323 | e64bfe94 | Markos Gogoulos | if (server.status == 'BUILD') {
|
324 | e64bfe94 | Markos Gogoulos | $('div.#' + server.id + ' a.action-reboot').hide();
|
325 | e64bfe94 | Markos Gogoulos | $('div.#' + server.id + ' a.action-shutdown').hide();
|
326 | 33282d93 | Markos Gogoulos | $('div.#' + server.id + ' a.action-destroy').addClass('destroy-padding');
|
327 | e64bfe94 | Markos Gogoulos | }
|
328 | eae0a59a | Dimitris Moraitis | }
|
329 | eae0a59a | Dimitris Moraitis | });
|
330 | eae0a59a | Dimitris Moraitis | |
331 | eae0a59a | Dimitris Moraitis | $("#spinner").hide();
|
332 | ed81826a | Christodoulos Psaltis | // show all separators
|
333 | ed81826a | Christodoulos Psaltis | $("div.machine div.separator").show();
|
334 | ed81826a | Christodoulos Psaltis | // hide the last one
|
335 | e5b0ba20 | Vangelis Koukis | $("div.machine:last-child").find("div.separator").hide();
|
336 | e5b0ba20 | Vangelis Koukis | // the separator shows only when running and terminated machines are available
|
337 | c58db69b | Christodoulos Psaltis | if ($(".terminated a.name").length > 0 && $(".running a.name").length > 0) {
|
338 | e5b0ba20 | Vangelis Koukis | $("#mini.separator").fadeIn("slow");
|
339 | e5b0ba20 | Vangelis Koukis | } else {
|
340 | e5b0ba20 | Vangelis Koukis | $("#mini.separator").fadeOut("slow");
|
341 | ce4f9227 | Mike Muzurakis | }
|
342 | 309d7ed2 | Dimitris Moraitis |
|
343 | 309d7ed2 | Dimitris Moraitis | // set confirm box position
|
344 | 82bf6df0 | Dimitris Moraitis | if (window.innerHeight - 220 < $('#machinesview').height())
|
345 | 309d7ed2 | Dimitris Moraitis | $('.confirm_multiple').addClass('fixed');
|
346 | 309d7ed2 | Dimitris Moraitis | else
|
347 | 309d7ed2 | Dimitris Moraitis | $('.confirm_multiple').removeClass('fixed');
|
348 | eae0a59a | Dimitris Moraitis | }
|
349 | eae0a59a | Dimitris Moraitis | |
350 | a1a31201 | Dimitris Moraitis | // indicate that the requested action was succesfully completed
|
351 | a1a31201 | Dimitris Moraitis | function display_success(serverID) {
|
352 | 6d0a36e5 | Dimitris Moraitis | |
353 | a1a31201 | Dimitris Moraitis | }
|
354 | a1a31201 | Dimitris Moraitis | |
355 | 879748ec | Markos Gogoulos | // indicate that the requested action was not completed
|
356 | 038383b1 | Dimitris Moraitis | function display_failure(status, serverID, action, responseText) {
|
357 | 879748ec | Markos Gogoulos | $('#'+serverID+ ' .spinner').hide();
|
358 | 879748ec | Markos Gogoulos | $('#'+serverID+ ' .action_error .action').text(action);
|
359 | 038383b1 | Dimitris Moraitis | $('#'+serverID+ ' .action_error .code').text(status);
|
360 | 038383b1 | Dimitris Moraitis | $('#'+serverID+ ' .action_error .message').text(responseText);
|
361 | 339712cb | Christodoulos Psaltis | $('#'+serverID+ ' .action_error').show();
|
362 | 879748ec | Markos Gogoulos | }
|
363 | 879748ec | Markos Gogoulos | |
364 | 339712cb | Christodoulos Psaltis | // basic functions executed on page load
|
365 | 146b6003 | Dimitris Moraitis | if (images.length == 0) {
|
366 | 146b6003 | Dimitris Moraitis | // populate image list
|
367 | 146b6003 | Dimitris Moraitis | update_images();
|
368 | 146b6003 | Dimitris Moraitis | }
|
369 | 146b6003 | Dimitris Moraitis | if (flavors.length == 0) {
|
370 | 146b6003 | Dimitris Moraitis | // configure flavors
|
371 | 146b6003 | Dimitris Moraitis | update_flavors();
|
372 | 146b6003 | Dimitris Moraitis | }
|
373 | c53d09e2 | Christodoulos Psaltis | // set the label of the multiple buttons
|
374 | c53d09e2 | Christodoulos Psaltis | $('div.confirm_multiple button.yes').text('Confirm All');
|
375 | c53d09e2 | Christodoulos Psaltis | $('div.confirm_multiple button.no').text('Cancel All');
|
376 | 82bf6df0 | Dimitris Moraitis | // reposition multiple confirmation box on window resize
|
377 | 82bf6df0 | Dimitris Moraitis | $(window).resize(function(){
|
378 | 82bf6df0 | Dimitris Moraitis | if (this.innerHeight - 220 < $('#machinesview').height())
|
379 | 82bf6df0 | Dimitris Moraitis | $('.confirm_multiple').addClass('fixed');
|
380 | 82bf6df0 | Dimitris Moraitis | else
|
381 | 82bf6df0 | Dimitris Moraitis | $('.confirm_multiple').removeClass('fixed');
|
382 | 82bf6df0 | Dimitris Moraitis | });
|
383 | c53d09e2 | Christodoulos Psaltis | // start updating vm list
|
384 | 146b6003 | Dimitris Moraitis | update_vms(UPDATE_INTERVAL);
|
385 | 2ed4ced5 | Markos Gogoulos | </script> |