Revision e357c9f0 ui/templates/list.html
b/ui/templates/list.html | ||
---|---|---|
188 | 188 |
} |
189 | 189 |
}); |
190 | 190 |
|
191 |
if (current != -1){ // if it's there, simply update the values |
|
192 |
var currentStatus = tableData[current][5].replace('<span class=status>', '').replace('</span>', ''); |
|
193 |
try { |
|
194 |
console.info(server.name + ' from ' + currentStatus + ' to ' + STATUS_MESSAGES[server.status]); |
|
195 |
} catch(err) {} |
|
191 |
if (current != -1) { // if it's there, update the values |
|
192 |
// get current status description, including non api states |
|
193 |
var server_row = $('#' + server.id).parent().parent(); |
|
194 |
var status_desc = server_row.find('span.status').text(); |
|
195 |
// firebug console logging |
|
196 |
try { |
|
197 |
console.info(server.name + ' from ' + status_desc + ' to ' + STATUS_MESSAGES[server.status]); |
|
198 |
} catch(err) {} |
|
199 |
// when server is in deleted status it must be removed from the list |
|
196 | 200 |
if (server.status == "DELETED") { |
197 | 201 |
vmTable.fnDeleteRow(current); |
198 |
} else { // server exists and should not be deleted |
|
199 |
// check server status to select the appropriate OS icon |
|
200 |
if (['ERROR', 'STOPPED'].indexOf(server.status) >= 0) { |
|
201 |
osIcon = osTag + "-off.png"; |
|
202 |
} |
|
203 |
// if the new state does not differ from the previous one |
|
204 |
if (currentStatus.indexOf(STATUS_MESSAGES[server.status]) > -1){ |
|
205 |
// do nothing |
|
206 |
} else { // state has changed |
|
207 |
//$('#'+server.id).parent().parent().find('.list-logo').attr('src').indexOf('wave')>-1){ |
|
208 |
imgSrc = "static/wave.gif"; |
|
202 |
} else { // when server is not be deleted, it should be updated |
|
203 |
if (['BUILD','ACTIVE','REBOOT'].indexOf(server.status) >= 0 && |
|
204 |
[STATUS_MESSAGES['STOPPED'], STATUS_MESSAGES['ERROR'], |
|
205 |
'Starting'].indexOf(server_row.find('span.status').text()) >= 0) { |
|
206 |
// from stopped, on error or starting to building, active or rebooting |
|
207 |
// starting is not an api state, it means the server is stopped or on error |
|
208 |
tableData[current][0] = "<input class="+server.status+" id="+server.id+" type=checkbox>"; |
|
209 |
imgSrc = "static/wave.gif"; |
|
210 |
imgStr = "<img class=list-logo src=" + imgSrc + " title=" + osTag + " height=16 width=16 />"; |
|
211 |
tableData[current][1] = "<span class=imagetag>" + osTag + "</span>" + imgStr; |
|
212 |
tableData[current][2] = "<a class=name><span class=name>" + server.name + "</span></a>"; |
|
213 |
//tableData[current][4] = "group"; //TODO |
|
214 |
tableData[current][5] = "<span class=status>" + STATUS_MESSAGES[server.status] + "</span>"; |
|
215 |
vmTable.fnUpdate(tableData[current],current); |
|
216 |
setTimeout("$('#"+server.id+"').parent().parent().find('.list-logo').attr('src','static/os_logos/" |
|
217 |
+ osIcon + "')", 1600); |
|
218 |
} else if (['STOPPED','ERROR'].indexOf(server.status) >= 0 && |
|
219 |
[STATUS_MESSAGES['ACTIVE'], STATUS_MESSAGES['BUILD'], STATUS_MESSAGES['REBOOT'], |
|
220 |
'Shutting down'].indexOf(server_row.find('span.status').text()) >= 0) { |
|
221 |
tableData[current][0] = "<input class="+server.status+" id="+server.id+" type=checkbox>"; |
|
222 |
imgSrc = "static/wave.gif"; |
|
223 |
imgStr = "<img class=list-logo src=" + imgSrc + " title=" + osTag + " height=16 width=16 />"; |
|
224 |
tableData[current][1] = "<span class=imagetag>" + osTag + "</span>" + imgStr; |
|
225 |
tableData[current][2] = "<a class=name><span class=name>" + server.name + "</span></a>"; |
|
226 |
//tableData[current][4] = "group"; //TODO |
|
227 |
tableData[current][5] = "<span class=status>" + STATUS_MESSAGES[server.status] + "</span>"; |
|
228 |
vmTable.fnUpdate(tableData[current],current); |
|
229 |
setTimeout("$('#"+server.id+"').parent().parent().find('.list-logo').attr('src','static/os_logos/" |
|
230 |
+ osTag + "-off.png')", 1600); |
|
231 |
} else if ( STATUS_MESSAGES[server.status] == server_row.find('span.status').text()) { |
|
232 |
|
|
233 |
} else if (server.status == 'ACTIVE' && |
|
234 |
[STATUS_MESSAGES['BUILD'], 'Rebooting'].indexOf(server_row.find('span.status').text()) >= 0) { |
|
209 | 235 |
tableData[current][0] = "<input class="+server.status+" id="+server.id+" type=checkbox>"; |
236 |
imgSrc = "static/wave.gif"; |
|
210 | 237 |
imgStr = "<img class=list-logo src=" + imgSrc + " title=" + osTag + " height=16 width=16 />"; |
211 | 238 |
tableData[current][1] = "<span class=imagetag>" + osTag + "</span>" + imgStr; |
212 | 239 |
tableData[current][2] = "<a class=name><span class=name>" + server.name + "</span></a>"; |
213 | 240 |
//tableData[current][4] = "group"; //TODO |
214 | 241 |
tableData[current][5] = "<span class=status>" + STATUS_MESSAGES[server.status] + "</span>"; |
215 |
vmTable.fnUpdate(tableData[current],current); |
|
216 |
setTimeout("$('#"+server.id+"').parent().parent().find('.list-logo').attr('src','static/os_logos/" + osIcon+"')", 2000); |
|
217 |
} |
|
242 |
vmTable.fnUpdate(tableData[current],current); |
|
243 |
setTimeout("$('#"+server.id+"').parent().parent().find('.list-logo').attr('src','static/os_logos/" |
|
244 |
+ osIcon + "')", 1600); |
|
245 |
} |
|
218 | 246 |
} |
219 | 247 |
updateActions(); |
220 | 248 |
} else if (server.status != "DELETED") { // does not exist, we should create it |
221 | 249 |
// check server status to select the appropriate OS icon |
222 | 250 |
if (['ERROR', 'STOPPED'].indexOf(server.status) >= 0) { |
223 |
osIcon = osTag + "-off.png"; |
|
251 |
osIcon = "static/os_logos/" + osTag + "-off.png"; |
|
252 |
} else if ( server.status == 'BUILD') { |
|
253 |
osIcon = "static/progress.gif"; |
|
254 |
} else { |
|
255 |
osIcon = "static/os_logos/" + osTag + ".png"; |
|
224 | 256 |
} |
225 | 257 |
// find flavor parameters |
226 | 258 |
flavorData = get_flavor(server.flavorRef); |
... | ... | |
235 | 267 |
// add new row to the table |
236 | 268 |
vmTable.fnAddData([ |
237 | 269 |
"<input class=" + server.status + " id=" + server.id + " type=checkbox>", |
238 |
"<span class=imagetag>" + osTag + "</span><img class=list-logo src=static/os_logos/" + osIcon +
|
|
270 |
"<span class=imagetag>" + osTag + "</span><img class=list-logo src=" + osIcon + |
|
239 | 271 |
" title=" + osTag + " height=16 width=16>", |
240 | 272 |
"<a class=name><span class=name>" + server.name + "</span></a>", |
241 | 273 |
"<a class=flavor><span>"+ flavorLabel + "</span></a>", |
Also available in: Unified diff