mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
UI will now use the config param "allow.public.user.templates". If this is false, only admins will be able to set the "public" status of a template.
This commit is contained in:
parent
37598f182c
commit
5c5563dfdd
@ -38,10 +38,11 @@ public class ListCapabilitiesCmd extends BaseCmd {
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
Map<String, String> capabilities = _mgr.listCapabilities(this);
|
||||
Map<String, Object> capabilities = _mgr.listCapabilities(this);
|
||||
CapabilitiesResponse response = new CapabilitiesResponse();
|
||||
response.setSecurityGroupsEnabled(capabilities.get("securityGroupsEnabled"));
|
||||
response.setCloudStackVersion(capabilities.get("cloudStackVersion"));
|
||||
response.setSecurityGroupsEnabled((Boolean)capabilities.get("securityGroupsEnabled"));
|
||||
response.setCloudStackVersion((String)capabilities.get("cloudStackVersion"));
|
||||
response.setUserPublicTemplateEnabled((Boolean)capabilities.get("userPublicTemplateEnabled"));
|
||||
response.setObjectName("capability");
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
|
||||
@ -5,16 +5,19 @@ import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class CapabilitiesResponse extends BaseResponse {
|
||||
@SerializedName("securitygroupsenabled") @Param(description="true if security groups support is enabled, false otherwise")
|
||||
private String securityGroupsEnabled;
|
||||
private boolean securityGroupsEnabled;
|
||||
|
||||
@SerializedName("cloudstackversion") @Param(description="version of the cloud stack")
|
||||
private String cloudStackVersion;
|
||||
|
||||
@SerializedName("userpublictemplateenabled") @Param(description="true if user and domain admins can set templates to be shared, false otherwise")
|
||||
private boolean userPublicTemplateEnabled;
|
||||
|
||||
public String getSecurityGroupsEnabled() {
|
||||
public boolean getSecurityGroupsEnabled() {
|
||||
return securityGroupsEnabled;
|
||||
}
|
||||
|
||||
public void setSecurityGroupsEnabled(String securityGroupsEnabled) {
|
||||
public void setSecurityGroupsEnabled(boolean securityGroupsEnabled) {
|
||||
this.securityGroupsEnabled = securityGroupsEnabled;
|
||||
}
|
||||
|
||||
@ -25,4 +28,12 @@ public class CapabilitiesResponse extends BaseResponse {
|
||||
public void setCloudStackVersion(String cloudStackVersion) {
|
||||
this.cloudStackVersion = cloudStackVersion;
|
||||
}
|
||||
|
||||
public boolean getUserPublicTemplateEnabled() {
|
||||
return securityGroupsEnabled;
|
||||
}
|
||||
|
||||
public void setUserPublicTemplateEnabled(boolean userPublicTemplateEnabled) {
|
||||
this.userPublicTemplateEnabled = userPublicTemplateEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
@ -352,7 +352,7 @@ public interface ManagementService {
|
||||
|
||||
List<? extends InstanceGroup> searchForVmGroups(ListVMGroupsCmd cmd);
|
||||
|
||||
Map<String, String> listCapabilities(ListCapabilitiesCmd cmd);
|
||||
Map<String, Object> listCapabilities(ListCapabilitiesCmd cmd);
|
||||
|
||||
/**
|
||||
* Extracts the volume to a particular location.
|
||||
|
||||
@ -4148,15 +4148,14 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> listCapabilities(ListCapabilitiesCmd cmd) {
|
||||
Map<String, String> capabilities = new HashMap<String, String>();
|
||||
public Map<String, Object> listCapabilities(ListCapabilitiesCmd cmd) {
|
||||
Map<String, Object> capabilities = new HashMap<String, Object>();
|
||||
|
||||
String securityGroupsEnabled = _configs.get("direct.attach.security.groups.enabled");
|
||||
if(securityGroupsEnabled == null) {
|
||||
securityGroupsEnabled = "false";
|
||||
}
|
||||
String securityGroupsEnabled = _configs.get(Config.DirectAttachSecurityGroupsEnabled.key());
|
||||
String userPublicTemplateEnabled = _configs.get(Config.AllowPublicUserTemplates.key());
|
||||
|
||||
capabilities.put("securityGroupsEnabled", securityGroupsEnabled);
|
||||
capabilities.put("securityGroupsEnabled", (securityGroupsEnabled == null || securityGroupsEnabled.equals("false") ? false : true));
|
||||
capabilities.put("userPublicTemplateEnabled", (userPublicTemplateEnabled == null || userPublicTemplateEnabled.equals("false") ? false : true));
|
||||
capabilities.put("cloudStackVersion", getVersion());
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
@ -158,7 +158,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid_rows odd">
|
||||
<div class="grid_rows even">
|
||||
<div class="grid_row_cell" style="width: 20%;">
|
||||
<div class="row_celltitles">
|
||||
<%=t.t("crossZones")%>:</div>
|
||||
@ -168,7 +168,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_rows even">
|
||||
<div class="grid_rows odd">
|
||||
<div class="grid_row_cell" style="width: 20%;">
|
||||
<div class="row_celltitles">
|
||||
<%=t.t("OS.Type")%>:</div>
|
||||
@ -180,7 +180,7 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_rows odd">
|
||||
<div class="grid_rows even">
|
||||
<div class="grid_row_cell" style="width: 20%;">
|
||||
<div class="row_celltitles">
|
||||
<%=t.t("Account")%>:</div>
|
||||
@ -190,7 +190,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_rows even">
|
||||
<div class="grid_rows odd">
|
||||
<div class="grid_row_cell" style="width: 20%;">
|
||||
<div class="row_celltitles">
|
||||
<%=t.t("Domain")%>:</div>
|
||||
@ -200,7 +200,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_rows odd">
|
||||
<div class="grid_rows even">
|
||||
<div class="grid_row_cell" style="width: 20%;">
|
||||
<div class="row_celltitles">
|
||||
<%=t.t("Created")%>:</div>
|
||||
@ -271,7 +271,7 @@
|
||||
<option value="false">No</option>
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
<li id="add_iso_public_container" style="display:none">
|
||||
<label>Public?:</label>
|
||||
<select class="select" id="add_iso_public">
|
||||
<option value="false">No</option>
|
||||
|
||||
@ -170,7 +170,7 @@
|
||||
<select class="select" id="os_type">
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
<li id="create_template_public_container" style="display:none">
|
||||
<label for="create_template_public">
|
||||
Public:</label>
|
||||
<select class="select" id="ispublic">
|
||||
|
||||
@ -368,7 +368,7 @@
|
||||
<option value="true">Yes</option>
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
<li id="add_template_public_container" style="display:none">
|
||||
<label>Public?:</label>
|
||||
<select class="select" id="add_template_public">
|
||||
<option value="false">No</option>
|
||||
|
||||
@ -239,7 +239,7 @@
|
||||
<select class="select" name="create_template_os_type" id="create_template_os_type">
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
<li id="create_template_public_container" style="display:none">
|
||||
<label for="create_template_public">
|
||||
Public:</label>
|
||||
<select class="select" name="create_template_public" id="create_template_public">
|
||||
@ -739,7 +739,7 @@
|
||||
<select class="select" id="os_type">
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
<li id="create_template_public_container" style="display:none">
|
||||
<label for="ispublic">
|
||||
Public:</label>
|
||||
<select class="select" name="ispublic" id="ispublic">
|
||||
|
||||
@ -705,13 +705,31 @@ $(document).ready(function() {
|
||||
$.cookie('directattacheduntaggedenabled', g_directAttachedUntaggedEnabled, { expires: 1});
|
||||
$.cookie('systemvmuselocalstorage', g_systemVmUseLocalStorage, { expires: 1});
|
||||
|
||||
buildSecondLevelNavigation();
|
||||
|
||||
$("#main_username").text(g_username);
|
||||
$("#login_wrapper").hide();
|
||||
showLeftNavigationBasedOnRole();
|
||||
initUI();
|
||||
$("#main").show();
|
||||
$.ajax({
|
||||
data: createURL("command=listCapabilities"),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
if (json.listcapabilitiesresponse.capability.userpublictemplateenabled != null) {
|
||||
g_userPublicTemplateEnabled = ""+json.listcapabilitiesresponse.capability.userpublictemplateenabled;
|
||||
$.cookie('userpublictemplateenabled', g_userPublicTemplateEnabled, { expires: 1});
|
||||
}
|
||||
|
||||
buildSecondLevelNavigation();
|
||||
$("#main_username").text(g_username);
|
||||
$("#login_wrapper").hide();
|
||||
showLeftNavigationBasedOnRole();
|
||||
initUI();
|
||||
$("#main").show();
|
||||
},
|
||||
error: function(xmlHTTP) {
|
||||
logout(false);
|
||||
},
|
||||
beforeSend: function(xmlHTTP) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function() {
|
||||
$("#account_password").val("");
|
||||
@ -759,6 +777,7 @@ $(document).ready(function() {
|
||||
g_directAttachSecurityGroupsEnabled = $.cookie("directattachsecuritygroupsenabled");
|
||||
g_directAttachedUntaggedEnabled = $.cookie("directattacheduntaggedenabled");
|
||||
g_systemVmUseLocalStorage = $.cookie("systemvmuselocalstorage");
|
||||
g_userPublicTemplateEnabled = $.cookie("userpublictemplateenabled");
|
||||
|
||||
if($.cookie("timezoneoffset") != null)
|
||||
g_timezoneoffset = isNaN($.cookie("timezoneoffset"))?null: parseFloat($.cookie("timezoneoffset"));
|
||||
@ -777,8 +796,11 @@ $(document).ready(function() {
|
||||
if (!g_systemVmUseLocalStorage || g_systemVmUseLocalStorage.length == 0)
|
||||
g_systemVmUseLocalStorage = "false";
|
||||
|
||||
if (!g_userPublicTemplateEnabled || g_userPublicTemplateEnabled.length == 0)
|
||||
g_userPublicTemplateEnabled = "true";
|
||||
|
||||
$.ajax({
|
||||
data: createURL("command=listZones&available=true&response=json"),
|
||||
data: createURL("command=listCapabilities"),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
|
||||
@ -110,7 +110,11 @@ function initAddIsoDialog() {
|
||||
});
|
||||
|
||||
//add button ***
|
||||
$("#add_iso_button").unbind("click").bind("click", function(event) {
|
||||
$("#add_iso_button").unbind("click").bind("click", function(event) {
|
||||
if (g_userPublicTemplateEnabled == "true" || isAdmin()) {
|
||||
$("#dialog_add_iso #add_iso_public_container").show();
|
||||
}
|
||||
|
||||
$dialogAddIso
|
||||
.dialog('option', 'buttons', {
|
||||
"Create": function() {
|
||||
@ -444,12 +448,17 @@ function doEditISO($actionLink, $detailsTab, $midmenuItem1) {
|
||||
var $readonlyFields, $editFields;
|
||||
|
||||
if(isAdmin()) {
|
||||
$readonlyFields = $detailsTab.find("#name, #displaytext, #ispublic, #ostypename, #isfeatured");
|
||||
$editFields = $detailsTab.find("#name_edit, #displaytext_edit, #ispublic_edit, #ostypename_edit, #isfeatured_edit");
|
||||
$readonlyFields = $detailsTab.find("#name, #displaytext, #ispublic, #ostypename, #isfeatured");
|
||||
$editFields = $detailsTab.find("#name_edit, #displaytext_edit, #ispublic_edit, #ostypename_edit, #isfeatured_edit");
|
||||
}
|
||||
else {
|
||||
$readonlyFields = $detailsTab.find("#name, #displaytext, #ispublic, #ostypename");
|
||||
$editFields = $detailsTab.find("#name_edit, #displaytext_edit, #ispublic_edit, #ostypename_edit");
|
||||
if (g_userPublicTemplateEnabled == "true") {
|
||||
$readonlyFields = $detailsTab.find("#name, #displaytext, #ispublic, #ostypename");
|
||||
$editFields = $detailsTab.find("#name_edit, #displaytext_edit, #ispublic_edit, #ostypename_edit");
|
||||
} else {
|
||||
$readonlyFields = $detailsTab.find("#name, #displaytext, #ostypename");
|
||||
$editFields = $detailsTab.find("#name_edit, #displaytext_edit, #ostypename_edit");
|
||||
}
|
||||
}
|
||||
|
||||
$readonlyFields.hide();
|
||||
|
||||
@ -50,6 +50,10 @@ function afterLoadSnapshotJSP() {
|
||||
}
|
||||
|
||||
function initCreateTemplateFromSnapshotDialog() {
|
||||
if (g_userPublicTemplateEnabled == "true" || isAdmin()) {
|
||||
$("#dialog_create_template_from_snapshot #create_template_public_container").show();
|
||||
}
|
||||
|
||||
initDialog("dialog_create_template_from_snapshot", 450);
|
||||
|
||||
var $dialogCreateTemplateFromSnapshot = $("#dialog_create_template_from_snapshot");
|
||||
|
||||
@ -90,7 +90,11 @@ function afterLoadTemplateJSP() {
|
||||
|
||||
//add button ***
|
||||
$("#add_template_button").unbind("click").bind("click", function(event) {
|
||||
$("#dialog_add_template #add_template_hypervisor").change();
|
||||
$("#dialog_add_template #add_template_hypervisor").change();
|
||||
|
||||
if (g_userPublicTemplateEnabled == "true" || isAdmin()) {
|
||||
$("#dialog_add_template #add_template_public_container").show();
|
||||
}
|
||||
|
||||
$("#dialog_add_template")
|
||||
.dialog('option', 'buttons', {
|
||||
@ -467,9 +471,21 @@ var templateActionMap = {
|
||||
}
|
||||
|
||||
function doEditTemplate($actionLink, $detailsTab, $midmenuItem1) {
|
||||
//var $detailsTab = $("#right_panel_content #tab_content_details");
|
||||
var $readonlyFields = $detailsTab.find("#name, #displaytext, #passwordenabled, #ispublic, #isfeatured, #ostypename");
|
||||
var $editFields = $detailsTab.find("#name_edit, #displaytext_edit, #passwordenabled_edit, #ispublic_edit, #isfeatured_edit, #ostypename_edit");
|
||||
var $readonlyFields, $editFields;
|
||||
|
||||
if(isAdmin()) {
|
||||
$readonlyFields = $detailsTab.find("#name, #displaytext, #passwordenabled, #ispublic, #isfeatured, #ostypename");
|
||||
$editFields = $detailsTab.find("#name_edit, #displaytext_edit, #passwordenabled_edit, #ispublic_edit, #isfeatured_edit, #ostypename_edit");
|
||||
}
|
||||
else {
|
||||
if (g_userPublicTemplateEnabled == "true") {
|
||||
$readonlyFields = $detailsTab.find("#name, #displaytext, #passwordenabled, #ispublic, #ostypename");
|
||||
$editFields = $detailsTab.find("#name_edit, #displaytext_edit, #passwordenabled_edit, #ispublic_edit, #ostypename_edit");
|
||||
} else {
|
||||
$readonlyFields = $detailsTab.find("#name, #displaytext, #passwordenabled, #ostypename");
|
||||
$editFields = $detailsTab.find("#name_edit, #displaytext_edit, #passwordenabled_edit, #ostypename_edit");
|
||||
}
|
||||
}
|
||||
|
||||
$readonlyFields.hide();
|
||||
$editFields.show();
|
||||
|
||||
@ -629,7 +629,11 @@ function doDownloadVolume($actionLink, $detailsTab, $midmenuItem1) {
|
||||
});
|
||||
}
|
||||
|
||||
function doCreateTemplateFromVolume($actionLink, $detailsTab, $midmenuItem1) {
|
||||
function doCreateTemplateFromVolume($actionLink, $detailsTab, $midmenuItem1) {
|
||||
if (g_userPublicTemplateEnabled == "true" || isAdmin()) {
|
||||
$("#dialog_create_template #create_template_public_container").show();
|
||||
}
|
||||
|
||||
var jsonObj = $midmenuItem1.data("jsonObj");
|
||||
$("#dialog_create_template").find("#volume_name").text(jsonObj.name);
|
||||
|
||||
@ -1022,7 +1026,11 @@ function doCreateVolumeFromSnapshotInVolumePage($actionLink, $subgridItem) {
|
||||
}).dialog("open");
|
||||
}
|
||||
|
||||
function doCreateTemplateFromSnapshotInVolumePage($actionLink, $subgridItem) {
|
||||
function doCreateTemplateFromSnapshotInVolumePage($actionLink, $subgridItem) {
|
||||
if (g_userPublicTemplateEnabled == "true" || isAdmin()) {
|
||||
$("#dialog_create_template_from_snapshot #create_template_public_container").show();
|
||||
}
|
||||
|
||||
var jsonObj = $subgridItem.data("jsonObj");
|
||||
|
||||
$("#dialog_create_template_from_snapshot")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user