mirror of https://github.com/apache/cloudstack.git
139 lines
5.8 KiB
JavaScript
139 lines
5.8 KiB
JavaScript
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
|
// Apache License, Version 2.0 (the "License"); you may not use this
|
|
// file except in compliance with the License. Citrix Systems, Inc.
|
|
// reserves all rights not expressly granted by the License.
|
|
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
//
|
|
// Automatically generated by addcopyright.py at 04/03/2012
|
|
function afterLoadGlobalSettingJSP() {
|
|
var $actionLink = $("#right_panel_content #tab_content_details #action_link");
|
|
bindActionLink($actionLink);
|
|
/*
|
|
$actionLink.bind("mouseover", function(event) {
|
|
$(this).find("#action_menu").show();
|
|
return false;
|
|
});
|
|
$actionLink.bind("mouseout", function(event) {
|
|
$(this).find("#action_menu").hide();
|
|
return false;
|
|
});
|
|
*/
|
|
|
|
populateGlobalSettingGrid();
|
|
|
|
//actions
|
|
var $actionList = $("#right_panel_content #tab_content_details #action_link #action_menu").find("#action_list").empty();
|
|
var $listItem = $("#action_list_item").clone();
|
|
$listItem.find("#link").text(dictionary["label.action.edit.global.setting"]);
|
|
$listItem.bind("click", function(event) {
|
|
doEditGlobalSetting();
|
|
return false;
|
|
});
|
|
$actionList.append($listItem.show());
|
|
|
|
//dialogs
|
|
initDialogWithOK("dialog_alert_restart_management_server");
|
|
}
|
|
|
|
function populateGlobalSettingGrid() {
|
|
var $thisTab = $("#right_panel_content #tab_content_details");
|
|
$thisTab.find("#tab_container").hide();
|
|
$thisTab.find("#tab_spinning_wheel").show();
|
|
|
|
$.ajax({
|
|
data: createURL("command=listConfigurations"),
|
|
dataType: "json",
|
|
success: function(json) {
|
|
var items = json.listconfigurationsresponse.configuration;
|
|
$container = $("#tab_content_details").find("#grid_content").empty();
|
|
$templateText = $("#globalsetting_template_text");
|
|
$templatePassword = $("#globalsetting_template_password");
|
|
if(items != null && items.length > 0) {
|
|
for(var i=0; i<items.length; i++) {
|
|
var $newTemplate;
|
|
if(items[i].name.toLowerCase().indexOf("password") == -1)
|
|
$newTemplate = $templateText.clone();
|
|
else
|
|
$newTemplate = $templatePassword.clone();
|
|
globalsettingJSONToTemplate(items[i], $newTemplate);
|
|
$container.append($newTemplate.show());
|
|
}
|
|
}
|
|
$thisTab.find("#tab_spinning_wheel").hide();
|
|
$thisTab.find("#tab_container").show();
|
|
}
|
|
});
|
|
}
|
|
|
|
var globalsettingGridIndex = 0;
|
|
function globalsettingJSONToTemplate(jsonObj, template) {
|
|
(globalsettingGridIndex++ % 2 == 0)? template.addClass("even"): template.addClass("odd");
|
|
template.find("#name").text(fromdb(jsonObj.name));
|
|
template.find("#value").text(fromdb(jsonObj.value));
|
|
template.find("#value_edit").val(fromdb(jsonObj.value));
|
|
template.find("#description").text(fromdb(jsonObj.description));
|
|
}
|
|
|
|
function doEditGlobalSetting() {
|
|
var $detailsTab = $("#right_panel_content #tab_content_details");
|
|
var $readonlyFields = $detailsTab.find("#globalsetting_template_text #value, #globalsetting_template_password #password_mask");
|
|
var $editFields = $detailsTab.find("#value_edit");
|
|
|
|
$readonlyFields.hide();
|
|
$editFields.show();
|
|
$detailsTab.find("#cancel_button, #save_button").show();
|
|
|
|
$detailsTab.find("#cancel_button").unbind("click").bind("click", function(event){
|
|
$editFields.hide();
|
|
$readonlyFields.show();
|
|
$("#save_button, #cancel_button").hide();
|
|
return false;
|
|
});
|
|
$detailsTab.find("#save_button").unbind("click").bind("click", function(event){
|
|
doEditGlobalSetting2($readonlyFields, $editFields);
|
|
return false;
|
|
});
|
|
}
|
|
|
|
function doEditGlobalSetting2($readonlyFields, $editFields) {
|
|
var isChanged = false;
|
|
|
|
$("#right_panel_content #tab_content_details").find("#globalsetting_template_text,#globalsetting_template_password").each(function(index) {
|
|
var $thisRow =$(this);
|
|
|
|
if($thisRow.find("#value_edit").val() != $thisRow.find("#value").text()) {
|
|
// validate values
|
|
var isValid = true;
|
|
isValid &= validateString("Value", $thisRow.find("#value_edit"), $thisRow.find("#value_edit_errormsg"), true);
|
|
if (!isValid)
|
|
return;
|
|
|
|
var name = $thisRow.find("#name").text();
|
|
var value = $thisRow.find("#value_edit").val();
|
|
|
|
$.ajax({
|
|
data: createURL("command=updateConfiguration&name="+todb(name)+"&value="+todb(value)),
|
|
dataType: "json",
|
|
async: false,
|
|
success: function(json) {
|
|
var jsonObj = json.updateconfigurationresponse.configuration;
|
|
globalsettingJSONToTemplate(jsonObj, $thisRow);
|
|
isChanged = true;
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
$editFields.hide();
|
|
$readonlyFields.show();
|
|
$("#save_button, #cancel_button").hide();
|
|
|
|
if(isChanged == true)
|
|
$("#dialog_alert_restart_management_server").dialog("open");
|
|
}
|