143 |
143 |
for (i=0;i<pending_actions.length;i++){ // if there is a pending action for this server execute it
|
144 |
144 |
if (pending_actions[i][1]==serverID){
|
145 |
145 |
action = pending_actions.splice(i,1)[0]; // extract action
|
146 |
|
action[0]([action[1]]); // execute action
|
|
146 |
// change the status text in cases where no api state exists
|
|
147 |
if (action[0] == start) {
|
|
148 |
$(this).parent().parent().find('.status').text('Starting');
|
|
149 |
$(this).parent().parent().find('.spinner').show();
|
|
150 |
} else if (action[0] == shutdown) {
|
|
151 |
$(this).parent().parent().find('.status').text('Shutting down');
|
|
152 |
$(this).parent().parent().find('.spinner').show();
|
|
153 |
}
|
|
154 |
action[0]([action[1]]); // execute action
|
147 |
155 |
}
|
148 |
156 |
}
|
149 |
157 |
$(this).parent().hide();
|
150 |
158 |
$(this).parent().parent().children('div.actions').children('a').removeClass('selected');
|
151 |
159 |
$(this).parent().parent().children('.state').children('.spinner').show()
|
152 |
160 |
$(this).parent().parent().children('div.actions').removeClass('display');
|
153 |
|
update_confirmations();
|
|
161 |
update_confirmations();
|
154 |
162 |
return false;
|
155 |
163 |
});
|
156 |
164 |
|
... | ... | |
203 |
211 |
console.info(existing.find("a.name span.name").text() + ' removed');
|
204 |
212 |
} catch(err) {}
|
205 |
213 |
} else if (existing.find(".status").text() != STATUS_MESSAGES[server.status]) {
|
206 |
|
|
|
214 |
|
207 |
215 |
try { // firebug console logging
|
208 |
216 |
console.info(existing.find("a.name span.name").text() + ' from '
|
209 |
217 |
+ existing.find(".status").text() + ' to ' + STATUS_MESSAGES[server.status]);
|
210 |
218 |
} catch(err) {}
|
211 |
|
|
|
219 |
|
212 |
220 |
if (['BUILD','ACTIVE','REBOOT'].indexOf(server.status) >= 0 &&
|
213 |
|
[STATUS_MESSAGES['STOPPED'], STATUS_MESSAGES['ERROR']].indexOf(existing.find(".status").text()) >= 0) {
|
|
221 |
[STATUS_MESSAGES['STOPPED'], STATUS_MESSAGES['ERROR']].indexOf(existing.find(".status").text())>=0){
|
214 |
222 |
// from stopped to running
|
215 |
223 |
moved = existing.clone().appendTo(".running");
|
216 |
224 |
moved.find("img.logo").attr("src","static/machines/"+image_tags[server.imageRef]+'.png');
|
217 |
225 |
existing.remove();
|
218 |
226 |
existing = moved;
|
|
227 |
existing.find(".status").text(STATUS_MESSAGES[server.status]);
|
219 |
228 |
} else if (['STOPPED','ERROR'].indexOf(server.status) >= 0 &&
|
220 |
229 |
[STATUS_MESSAGES['ACTIVE'], STATUS_MESSAGES['BUILD'], STATUS_MESSAGES['REBOOT']].indexOf(existing.find(".status").text()) >= 0) {
|
|
230 |
// from running to stopped
|
|
231 |
moved = existing.clone().appendTo(".terminated");
|
|
232 |
moved.find("img.logo").attr("src","static/machines/"+image_tags[server.imageRef]+'-off.png');
|
|
233 |
existing.remove();
|
|
234 |
existing = moved;
|
|
235 |
existing.find(".status").text(STATUS_MESSAGES[server.status]);
|
|
236 |
} else if (server.status == 'ACTIVE' && existing.find(".status").text() == 'Starting') {
|
|
237 |
moved = existing.clone().appendTo(".running");
|
|
238 |
moved.find("img.logo").attr("src","static/machines/"+image_tags[server.imageRef]+'.png');
|
|
239 |
existing.remove();
|
|
240 |
existing = moved;
|
|
241 |
existing.find(".status").text(STATUS_MESSAGES['ACTIVE']);
|
|
242 |
} else if (server.status == 'STOPPED' && existing.find(".status").text() == 'Shutting down') {
|
221 |
243 |
moved = existing.clone().appendTo(".terminated");
|
222 |
244 |
moved.find("img.logo").attr("src","static/machines/"+image_tags[server.imageRef]+'-off.png');
|
223 |
245 |
existing.remove();
|
224 |
246 |
existing = moved;
|
225 |
|
}
|
|
247 |
existing.find(".status").text(STATUS_MESSAGES['STOPPED']);
|
|
248 |
}
|
226 |
249 |
existing.find('.spinner').hide();
|
227 |
250 |
existing.find(' .wave').attr('src','static/wave.gif').show();
|
228 |
251 |
setTimeout("$('#" + server.id +" .wave').attr('src','').hide()", 3000);
|
229 |
|
//keep spinner while machine is rebooting
|
230 |
|
if (server.status == 'REBOOT') {
|
|
252 |
// show spinner while machine is rebooting
|
|
253 |
if (server.status == 'REBOOT' ||
|
|
254 |
['Starting', 'Shutting down'].indexOf(existing.find(".status").text()) >= 0 ) {
|
231 |
255 |
existing.find(' .wave').hide();
|
232 |
256 |
existing.find('.spinner').show();
|
233 |
|
}
|
234 |
|
existing.find(".status").text(STATUS_MESSAGES[server.status]);
|
|
257 |
}
|
235 |
258 |
}
|
236 |
259 |
existing.find("a.name span.name").text(server.name);
|
237 |
260 |
existing.find("a.ip span.public").text(String(server.addresses.values[0].values[0].addr).replace(',',' '));
|
... | ... | |
251 |
274 |
machine.appendTo(".terminated");
|
252 |
275 |
}
|
253 |
276 |
//show spinner while machine is building
|
254 |
|
if (server.status == 'BUILD') {
|
|
277 |
if (server.status == 'BUILD' ||
|
|
278 |
['Starting', 'Shutting down'].indexOf(existing.find(".status").text()) >= 0 ) {
|
255 |
279 |
machine.find('.spinner').show();
|
256 |
280 |
}
|
257 |
281 |
}
|