Commit 47940145 authored by Christodoulos Psaltis's avatar Christodoulos Psaltis
Browse files

Get metadata and show the in dialog, Refs #375

parent d8d456de
......@@ -677,6 +677,28 @@ function start(serverIDs){
return false;
}
// get server metadata
function get_metadata(serverID) {
$.ajax({
url: API_URL + '/servers/' + serverID + '/meta',
type: "GET",
//async: false,
dataType: "json",
timeout: TIMEOUT,
error: function(jqXHR, textStatus, errorThrown) {
try {
ajax_error(jqXHR.status, undefined, 'Get metadata', jqXHR.responseText);
} catch (err) {
ajax_error(err);
}
},
success: function(data, textStatus, jqXHR) {
update_metadata(data);
}
});
return false;
}
// show the welcome screen
function showWelcome() {
$("#view-select").fadeOut("fast");
......
......@@ -185,8 +185,8 @@
<hr class="topruler" />
<hr class="fatruler" />
<div class="content">
<ul>
<li class="meta-template">
<ul class="meta-template" style="display:none">
<li>
<label>{% trans "Metadata key" %}</label>
<button type="button" class="remove">{% trans "remove x" %}</button>
<hr class="meta-separator">
......@@ -194,6 +194,8 @@
<button type="button" class="edit">{% trans "edit" %}</button>
</li>
</ul>
<ul class="meta-list">
</ul>
</div>
<button type="button" class="create">{% trans "Create New+" %}</button>
<div class="bottomruler" />
......@@ -593,8 +595,9 @@ function editMetadata() {
oneInstance: false,
load: false
});
// get metadata for current server
//get_metadata(serverID);
// get metadata for current server and fill the dialog
serverID = $("#editor-1 h3").attr('id');
get_metadata(serverID);
$("a#meta-editor-1").data('overlay').load();
return false;
}
......@@ -652,6 +655,21 @@ $('#editor-2.meta-modal button.save').click( function(){
editMetadata();
});
// update metadata in edit dialog
function update_metadata(data) {
meta = data.metadata.values;
for (key in meta) {
alert(key);
alert(meta[key]);
pair = $("ul.meta-template li").clone();
pair.find("label").text(key);
pair.find("p").text(meta[key]);
pair.appendTo("#editor-1 div.content ul.meta-list");
}
}
// basic functions executed on page load
if (images.length > 0) {
// populate image list
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment