Revision 4b2ed497

b/ui/static/synnefo.js
355 355
                try {
356 356
                    //servers = data.servers.values;
357 357
                    update_servers_data(data.servers.values, data);
358
                    jQuery.parseJSON(data);
359 358
                    update_machines_view(data);
360 359
                } catch(err) { ajax_error('400', undefined, 'Update VMs', jqXHR.responseText);}
361 360
            } else if (jqXHR.status != 304){
......
404 403
            $.each(el, function(key,v) {
405 404
                // new attribute added
406 405
                var previous_value = initial[key];
407

  
406
                var v = v;
408 407
                if (initial[key] == undefined) {
409 408
                    $(window).trigger("vm:attr:add", initial, key, v);
410 409
                } else {
411 410
                    // value changed
412 411
                    if (initial[key] != v) {
413 412
                        if (key == "status") {
413
                            // dont change if in destroy state
414
                            if (initial.status == "DESTROY") {
415
                                v = "DESTROY";
416
                            }
414 417
                            status_changed = {'old': previous_value, 'new': v}; 
415 418
                        }
416 419
                        $(window).trigger("vm:attr:change", {'initial': initial, 'attr': key, 'newvalue': v});
......
1019 1022
                        try {
1020 1023
                            console.info('destroyed ' + serverID);
1021 1024
                        } catch (err) {}
1025

  
1026
                        // update status on local storage object
1027
                        vm = get_machine(serverID);
1028
                        vm.status = "DESTROY";
1029

  
1022 1030
                        // indicate that the action succeeded
1023 1031
                        display_success(serverID);
1024 1032
                        // continue with the rest of the servers
b/ui/templates/machines_icon.html
533 533
    new ones to the list
534 534
    */
535 535
    $.each(data.servers.values, function(i,server) {
536

  
536 537
        // get DOM element, if it exists
537 538
        existing = $('#machinesview-icon.standard #' + server.id);
538 539
        // get server OS, if it exists
......
687 688
        if (!(server.metadata == undefined)) {
688 689
                list_metadata_keys(server.id, server.metadata.values);
689 690
        }
691

  
692
        // if machine in destroy state keep it that way
693
        var server = get_machine(server.id);
694
        if (server.status == "DESTROY") {
695
            existing = $('#machinesview-icon.standard #' + server.id);
696
            if (existing.length) {
697
                $(existing).find('.status').text(TRANSITIONS['Destroying']);
698
                $(existing).find('.state').removeClass().addClass('state destroying-state');
699
                $(existing).find('.spinner').show();
700
            }
701
        }
702

  
703

  
690 704
    });
691 705
    /*
692 706
    Do some standard stuff, repeated each time
b/ui/templates/machines_list.html
266 266
    tableData = vmTable.fnGetData();
267 267

  
268 268
    $.each(data.servers.values, function(i,server){
269
        var server = get_machine(server.id);
270

  
269 271
        current = -1;
270 272
        // check server status to select the appropriate OS icon, defaults to on state
271 273
        osTag = os_icon(server.metadata);
......
336 338
            // check server status to select the appropriate OS icon
337 339
            if (['ERROR', 'STOPPED', 'UNKNOWN'].indexOf(server.status) >= 0) {
338 340
                osIcon = "static/icons/machines/small/" + osTag + "-off.png";
339
            } else if ( server.status == 'BUILD') {
341
            } else if ( server.status == 'BUILD' || server.status == "DESTROY" ) {
340 342
                osIcon = "static/icons/indicators/small/progress.gif";
341 343
            } else {
342 344
                osIcon = "static/icons/machines/small/" + osTag + "-on.png";
......
361 363
                flavorLabel = 'No flavor data';
362 364
            }
363 365

  
366
            var status_string = STATUSES[server.status];
367

  
368
            // if destroy is requested don't change the state
369
            var server = get_machine(server.id);
370
            if (server.status == "DESTROY") {
371
                status_string = TRANSITIONS['Destroying'];
372
            }
373

  
364 374
            // add new row to the table
365 375
            vmTable.fnAddData([
366 376
                "<input class=" + server.status + " id=" + server.id + " type=checkbox>",
......
369 379
                "<a class=name><span class=name>" + server.name.substring(0,60) + "</span></a>",
370 380
                "<a class=flavor><span>"+ flavorLabel + "</span></a>",
371 381
                //"group",
372
                "<span class=status>" + STATUSES[server.status] + "</span>"
382
                "<span class=status>" + status_string + "</span>"
373 383
            ]);
374 384
        }
375 385
    });
b/ui/templates/machines_single.html
625 625
        if (server.id == current_serverId()) {
626 626
            get_server_stats(server.id);
627 627
        }
628

  
629
        // if machine in destroy state keep it that way
630
        var server = get_machine(server.id);
631
        if (server.status == "DESTROY") {
632
            existing = $('#machinesview-single.single #' + server.id);
633
            if (existing.length) {
634
                existing.find(".column1 .state-label").text(TRANSITIONS['Destroying']);
635
                existing.find(".column1 .state").removeClass().addClass('state destroying-state');
636
                existing.find(".column1 .state .spinner").show();
637
            }
638
        }
628 639
    });
629 640

  
630 641
    // hide pane spinner

Also available in: Unified diff