Revision 5186eb04

b/ui/static/synnefo.js
677 677
    return false;
678 678
}
679 679

  
680
// get server metadata
681
function get_metadata(serverID) { 
682
    $.ajax({
683
        url: API_URL + '/servers/' + serverID + '/meta',
684
        type: "GET",
685
        //async: false,
686
        dataType: "json",
687
        timeout: TIMEOUT,
688
        error: function(jqXHR, textStatus, errorThrown) { 
689
            try {
690
				ajax_error(jqXHR.status, undefined, 'Get metadata', jqXHR.responseText);
691
			} catch (err) {
692
				ajax_error(err);
693
			}
694
        },
695
        success: function(data, textStatus, jqXHR) {
696
            update_metadata(data);
697
        }
698
    });
699
    return false;
700
}
701

  
680 702
// show the welcome screen
681 703
function showWelcome() {
682 704
    $("#view-select").fadeOut("fast");
b/ui/templates/machines.html
185 185
    <hr class="topruler" />
186 186
    <hr class="fatruler" />
187 187
    <div class="content">
188
        <ul>
189
            <li class="meta-template">
188
        <ul class="meta-template" style="display:none">
189
            <li>
190 190
                <label>{% trans "Metadata key" %}</label>
191 191
                <button type="button" class="remove">{% trans "remove x" %}</button>
192 192
                <hr class="meta-separator">
......
194 194
                <button type="button" class="edit">{% trans "edit" %}</button>
195 195
            </li>
196 196
        </ul>
197
        <ul class="meta-list">
198
        </ul>
197 199
    </div>
198 200
    <button type="button" class="create">{% trans "Create New+" %}</button>
199 201
    <div class="bottomruler" /> 
......
593 595
        oneInstance: false,
594 596
        load: false
595 597
    });
596
    // get metadata for current server
597
    //get_metadata(serverID);
598
    // get metadata for current server and fill the dialog
599
    serverID = $("#editor-1 h3").attr('id');
600
    get_metadata(serverID);
598 601
    $("a#meta-editor-1").data('overlay').load();
599 602
    return false; 
600 603
}
......
652 655
    editMetadata();
653 656
});
654 657

  
658
// update metadata in edit dialog
659
function update_metadata(data) {
660

  
661
    meta = data.metadata.values;
662

  
663
    for (key in meta) {
664
        alert(key);
665
        alert(meta[key]);
666
        pair = $("ul.meta-template li").clone();
667
        pair.find("label").text(key);
668
        pair.find("p").text(meta[key]);
669
        pair.appendTo("#editor-1 div.content ul.meta-list");
670
    }
671
}
672

  
655 673
// basic functions executed on page load
656 674
if (images.length > 0) {
657 675
    // populate image list

Also available in: Unified diff