Merge remote-tracking branch 'apache/4.16'

This commit is contained in:
Wei Zhou 2021-12-10 17:50:25 +01:00
commit 51d4e5475f
17 changed files with 95 additions and 63 deletions

View File

@ -31,6 +31,7 @@ import java.util.UUID;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import com.cloud.hypervisor.vmware.mo.DatastoreFile;
import com.vmware.vim25.FileInfo; import com.vmware.vim25.FileInfo;
import com.vmware.vim25.FileQueryFlags; import com.vmware.vim25.FileQueryFlags;
import com.vmware.vim25.HostDatastoreBrowserSearchResults; import com.vmware.vim25.HostDatastoreBrowserSearchResults;
@ -1140,12 +1141,12 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
return "snapshots/" + accountId + "/" + volumeId; return "snapshots/" + accountId + "/" + volumeId;
} }
private long getVMSnapshotChainSize(VmwareContext context, VmwareHypervisorHost hyperHost, String fileName, ManagedObjectReference morDs, String exceptFileName) private long getVMSnapshotChainSize(VmwareContext context, VmwareHypervisorHost hyperHost, String fileName, ManagedObjectReference morDs,
throws Exception { String exceptFileName, String vmName) throws Exception {
long size = 0; long size = 0;
DatastoreMO dsMo = new DatastoreMO(context, morDs); DatastoreMO dsMo = new DatastoreMO(context, morDs);
HostDatastoreBrowserMO browserMo = dsMo.getHostDatastoreBrowserMO(); HostDatastoreBrowserMO browserMo = dsMo.getHostDatastoreBrowserMO();
String datastorePath = "[" + dsMo.getName() + "]"; String datastorePath = (new DatastoreFile(dsMo.getName(), vmName)).getPath();
HostDatastoreBrowserSearchSpec searchSpec = new HostDatastoreBrowserSearchSpec(); HostDatastoreBrowserSearchSpec searchSpec = new HostDatastoreBrowserSearchSpec();
FileQueryFlags fqf = new FileQueryFlags(); FileQueryFlags fqf = new FileQueryFlags();
fqf.setFileSize(true); fqf.setFileSize(true);
@ -1306,11 +1307,11 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
// get volume's chain size for this VM snapshot; exclude current volume vdisk // get volume's chain size for this VM snapshot; exclude current volume vdisk
DataStoreTO store = volumeTO.getDataStore(); DataStoreTO store = volumeTO.getDataStore();
ManagedObjectReference morDs = getDatastoreAsManagedObjectReference(baseName, hyperHost, store); ManagedObjectReference morDs = getDatastoreAsManagedObjectReference(baseName, hyperHost, store);
long size = getVMSnapshotChainSize(context, hyperHost, baseName + "-*.vmdk", morDs, newPath); long size = getVMSnapshotChainSize(context, hyperHost, baseName + "-*.vmdk", morDs, newPath, vmName);
if (volumeTO.getVolumeType() == Volume.Type.ROOT) { if (volumeTO.getVolumeType() == Volume.Type.ROOT) {
// add memory snapshot size // add memory snapshot size
size += getVMSnapshotChainSize(context, hyperHost, vmName + "-*.vmsn", morDs, null); size += getVMSnapshotChainSize(context, hyperHost, vmName + "-*.vmsn", morDs, null, vmName);
} }
volumeTO.setSize(size); volumeTO.setSize(size);

View File

@ -48,8 +48,6 @@ import java.util.stream.Collectors;
import javax.naming.ConfigurationException; import javax.naming.ConfigurationException;
import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.datatype.XMLGregorianCalendar;
import com.cloud.utils.script.Script;
import com.cloud.hypervisor.vmware.mo.NetworkMO;
import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.storage.command.CopyCommand; import org.apache.cloudstack.storage.command.CopyCommand;
import org.apache.cloudstack.storage.command.StorageSubSystemCommand; import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
@ -234,6 +232,7 @@ import com.cloud.hypervisor.vmware.mo.HostMO;
import com.cloud.hypervisor.vmware.mo.HostStorageSystemMO; import com.cloud.hypervisor.vmware.mo.HostStorageSystemMO;
import com.cloud.hypervisor.vmware.mo.HypervisorHostHelper; import com.cloud.hypervisor.vmware.mo.HypervisorHostHelper;
import com.cloud.hypervisor.vmware.mo.NetworkDetails; import com.cloud.hypervisor.vmware.mo.NetworkDetails;
import com.cloud.hypervisor.vmware.mo.NetworkMO;
import com.cloud.hypervisor.vmware.mo.PbmProfileManagerMO; import com.cloud.hypervisor.vmware.mo.PbmProfileManagerMO;
import com.cloud.hypervisor.vmware.mo.StoragepodMO; import com.cloud.hypervisor.vmware.mo.StoragepodMO;
import com.cloud.hypervisor.vmware.mo.TaskMO; import com.cloud.hypervisor.vmware.mo.TaskMO;
@ -276,6 +275,7 @@ import com.cloud.utils.mgmt.JmxUtil;
import com.cloud.utils.mgmt.PropertyMapDynamicBean; import com.cloud.utils.mgmt.PropertyMapDynamicBean;
import com.cloud.utils.net.NetUtils; import com.cloud.utils.net.NetUtils;
import com.cloud.utils.nicira.nvp.plugin.NiciraNvpApiVersion; import com.cloud.utils.nicira.nvp.plugin.NiciraNvpApiVersion;
import com.cloud.utils.script.Script;
import com.cloud.utils.ssh.SshHelper; import com.cloud.utils.ssh.SshHelper;
import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachine.PowerState; import com.cloud.vm.VirtualMachine.PowerState;
@ -1764,7 +1764,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
// Check if license supports the feature // Check if license supports the feature
VmwareHelper.isFeatureLicensed(hyperHost, FeatureKeyConstants.HOTPLUG); VmwareHelper.isFeatureLicensed(hyperHost, FeatureKeyConstants.HOTPLUG);
VmwareHelper.setVmScaleUpConfig(vmConfigSpec, vmSpec.getCpus(), vmSpec.getMaxSpeed(), vmSpec.getMinSpeed(), (int) requestedMaxMemoryInMb, ramMb, VmwareHelper.setVmScaleUpConfig(vmConfigSpec, vmSpec.getCpus(), vmSpec.getMaxSpeed(), getReservedCpuMHZ(vmSpec), (int) requestedMaxMemoryInMb, ramMb,
vmSpec.getLimitCpuUse()); vmSpec.getLimitCpuUse());
if (!vmMo.configureVm(vmConfigSpec)) { if (!vmMo.configureVm(vmConfigSpec)) {

View File

@ -3947,7 +3947,7 @@ public class ApiResponseHelper implements ResponseGenerator {
final StringBuilder builder = new StringBuilder(); final StringBuilder builder = new StringBuilder();
builder.append("VMSnapshot usage"); builder.append("VMSnapshot usage");
if (vmSnapshotVO != null) { if (vmSnapshotVO != null) {
builder.append(" Id: ").append(vmSnapshotVO.getId()).append(" (").append(vmSnapshotVO.getUuid()).append(") "); builder.append(" Id: ").append(vmSnapshotVO.getUuid());
} }
if (vmInstance != null) { if (vmInstance != null) {
builder.append(" for VM ").append(vmInstance.getHostName()).append(" (").append(vmInstance.getUuid()).append(")"); builder.append(" for VM ").append(vmInstance.getHostName()).append(" (").append(vmInstance.getUuid()).append(")");
@ -3990,7 +3990,7 @@ public class ApiResponseHelper implements ResponseGenerator {
final StringBuilder builder = new StringBuilder(); final StringBuilder builder = new StringBuilder();
builder.append("VMSnapshot on primary storage usage"); builder.append("VMSnapshot on primary storage usage");
if (vmSnapshotVO != null) { if (vmSnapshotVO != null) {
builder.append(" Id: ").append(vmSnapshotVO.getId()).append(" (").append(vmSnapshotVO.getUuid()).append(") "); builder.append(" Id: ").append(vmSnapshotVO.getUuid());
} }
if (vmInstance != null) { if (vmInstance != null) {
builder.append(" for VM ").append(vmInstance.getHostName()).append(" (").append(vmInstance.getUuid()).append(") ") builder.append(" for VM ").append(vmInstance.getHostName()).append(" (").append(vmInstance.getUuid()).append(") ")

View File

@ -16,6 +16,7 @@
// under the License. // under the License.
import store from '@/store' import store from '@/store'
import { isAdmin } from '@/role'
export default { export default {
name: 'network', name: 'network',
@ -29,8 +30,20 @@ export default {
icon: 'apartment', icon: 'apartment',
permission: ['listNetworks'], permission: ['listNetworks'],
resourceType: 'Network', resourceType: 'Network',
columns: ['name', 'state', 'type', 'vpcname', 'cidr', 'ip6cidr', 'broadcasturi', 'domain', 'account', 'zonename'], columns: () => {
details: ['name', 'id', 'description', 'type', 'traffictype', 'vpcid', 'vlan', 'broadcasturi', 'cidr', 'ip6cidr', 'netmask', 'gateway', 'aclname', 'ispersistent', 'restartrequired', 'reservediprange', 'redundantrouter', 'networkdomain', 'zonename', 'account', 'domain'], var fields = ['name', 'state', 'type', 'vpcname', 'cidr', 'ip6cidr', 'broadcasturi', 'domain', 'account', 'zonename']
if (!isAdmin()) {
fields = fields.filter(function (e) { return e !== 'broadcasturi' })
}
return fields
},
details: () => {
var fields = ['name', 'id', 'description', 'type', 'traffictype', 'vpcid', 'vlan', 'broadcasturi', 'cidr', 'ip6cidr', 'netmask', 'gateway', 'aclname', 'ispersistent', 'restartrequired', 'reservediprange', 'redundantrouter', 'networkdomain', 'zonename', 'account', 'domain']
if (!isAdmin()) {
fields = fields.filter(function (e) { return e !== 'broadcasturi' })
}
return fields
},
filters: ['all', 'isolated', 'shared', 'l2'], filters: ['all', 'isolated', 'shared', 'l2'],
searchFilters: ['keyword', 'zoneid', 'domainid', 'account', 'tags'], searchFilters: ['keyword', 'zoneid', 'domainid', 'account', 'tags'],
related: [{ related: [{

26
ui/src/role/index.js Normal file
View File

@ -0,0 +1,26 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with 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.
import store from '@/store'
export function isAdmin () {
return ['Admin'].includes(store.getters.userInfo.roletype)
}
export function isAdminOrDomainAdmin () {
return ['Admin', 'DomainAdmin'].includes(this.$store.getters.userInfo.roletype)
}

View File

@ -150,6 +150,7 @@
<script> <script>
import { api } from '@/api' import { api } from '@/api'
import { isAdmin } from '@/role'
import { mixinDevice } from '@/utils/mixin.js' import { mixinDevice } from '@/utils/mixin.js'
import DetailsTab from '@/components/view/DetailsTab' import DetailsTab from '@/components/view/DetailsTab'
import FirewallRules from '@/views/network/FirewallRules' import FirewallRules from '@/views/network/FirewallRules'
@ -230,7 +231,7 @@ export default {
dataIndex: 'zonename' dataIndex: 'zonename'
} }
] ]
if (!this.isAdmin()) { if (!isAdmin()) {
this.vmColumns = this.vmColumns.filter(x => x.dataIndex !== 'instancename') this.vmColumns = this.vmColumns.filter(x => x.dataIndex !== 'instancename')
} }
this.handleFetchData() this.handleFetchData()
@ -279,12 +280,6 @@ export default {
}).join('&') }).join('&')
) )
}, },
isAdmin () {
return ['Admin'].includes(this.$store.getters.userInfo.roletype)
},
isAdminOrDomainAdmin () {
return ['Admin', 'DomainAdmin'].includes(this.$store.getters.userInfo.roletype)
},
isValidValueForKey (obj, key) { isValidValueForKey (obj, key) {
return key in obj && obj[key] != null return key in obj && obj[key] != null
}, },

View File

@ -141,7 +141,7 @@
:closable="true" :closable="true"
:footer="null" :footer="null"
@cancel="() => { showError = false }" @cancel="() => { showError = false }"
v-ctrl-enter="showError = false" v-ctrl-enter="() => { showError = false }"
centered centered
> >
<span>{{ $t('message.required.traffic.type') }}</span> <span>{{ $t('message.required.traffic.type') }}</span>

View File

@ -68,7 +68,7 @@
</a-select-option> </a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
<a-form-item v-if="this.isAdminOrDomainAdmin()"> <a-form-item v-if="isAdminOrDomainAdmin()">
<tooltip-label slot="label" :title="$t('label.domainid')" :tooltip="apiParams.domainid.description"/> <tooltip-label slot="label" :title="$t('label.domainid')" :tooltip="apiParams.domainid.description"/>
<a-select <a-select
v-decorator="['domainid', {}]" v-decorator="['domainid', {}]"
@ -193,6 +193,7 @@
<script> <script>
import { api } from '@/api' import { api } from '@/api'
import { isAdmin, isAdminOrDomainAdmin } from '@/role'
import ResourceIcon from '@/components/view/ResourceIcon' import ResourceIcon from '@/components/view/ResourceIcon'
import TooltipLabel from '@/components/widgets/TooltipLabel' import TooltipLabel from '@/components/widgets/TooltipLabel'
@ -231,7 +232,7 @@ export default {
vpcs: [], vpcs: [],
vpcLoading: false, vpcLoading: false,
selectedVpc: {}, selectedVpc: {},
accountVisible: this.isAdminOrDomainAdmin() accountVisible: isAdminOrDomainAdmin()
} }
}, },
watch: { watch: {
@ -257,11 +258,8 @@ export default {
this.fetchDomainData() this.fetchDomainData()
this.fetchZoneData() this.fetchZoneData()
}, },
isAdmin () {
return ['Admin'].includes(this.$store.getters.userInfo.roletype)
},
isAdminOrDomainAdmin () { isAdminOrDomainAdmin () {
return ['Admin', 'DomainAdmin'].includes(this.$store.getters.userInfo.roletype) return isAdminOrDomainAdmin()
}, },
isObjectEmpty (obj) { isObjectEmpty (obj) {
return !(obj !== null && obj !== undefined && Object.keys(obj).length > 0 && obj.constructor === Object) return !(obj !== null && obj !== undefined && Object.keys(obj).length > 0 && obj.constructor === Object)
@ -320,7 +318,7 @@ export default {
handleDomainChange (domain) { handleDomainChange (domain) {
this.selectedDomain = domain this.selectedDomain = domain
this.accountVisible = domain.id !== '-1' this.accountVisible = domain.id !== '-1'
if (this.isAdminOrDomainAdmin()) { if (isAdminOrDomainAdmin()) {
this.updateVPCCheckAndFetchNetworkOfferingData() this.updateVPCCheckAndFetchNetworkOfferingData()
} }
}, },
@ -349,10 +347,10 @@ export default {
supportedServices: 'SourceNat', supportedServices: 'SourceNat',
state: 'Enabled' state: 'Enabled'
} }
if (this.isAdminOrDomainAdmin() && this.selectedDomain.id !== '-1') { // domain is visible only for admins if (isAdminOrDomainAdmin() && this.selectedDomain.id !== '-1') { // domain is visible only for admins
params.domainid = this.selectedDomain.id params.domainid = this.selectedDomain.id
} }
if (!this.isAdmin()) { // normal user is not aware of the VLANs in the system, so normal user is not allowed to create network with network offerings whose specifyvlan = true if (!isAdmin()) { // normal user is not aware of the VLANs in the system, so normal user is not allowed to create network with network offerings whose specifyvlan = true
params.specifyvlan = false params.specifyvlan = false
} }
if (forVpc !== null) { if (forVpc !== null) {

View File

@ -68,7 +68,7 @@
</a-select-option> </a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
<a-form-item v-if="this.isAdminOrDomainAdmin()"> <a-form-item v-if="isAdminOrDomainAdmin()">
<tooltip-label slot="label" :title="$t('label.domainid')" :tooltip="apiParams.domainid.description"/> <tooltip-label slot="label" :title="$t('label.domainid')" :tooltip="apiParams.domainid.description"/>
<a-select <a-select
v-decorator="['domainid', {}]" v-decorator="['domainid', {}]"
@ -180,6 +180,7 @@
<script> <script>
import { api } from '@/api' import { api } from '@/api'
import { isAdmin, isAdminOrDomainAdmin } from '@/role'
import ResourceIcon from '@/components/view/ResourceIcon' import ResourceIcon from '@/components/view/ResourceIcon'
import TooltipLabel from '@/components/widgets/TooltipLabel' import TooltipLabel from '@/components/widgets/TooltipLabel'
@ -215,7 +216,7 @@ export default {
networkOfferings: [], networkOfferings: [],
networkOfferingLoading: false, networkOfferingLoading: false,
selectedNetworkOffering: {}, selectedNetworkOffering: {},
accountVisible: this.isAdminOrDomainAdmin(), accountVisible: isAdminOrDomainAdmin(),
isolatePvlanType: 'none' isolatePvlanType: 'none'
} }
}, },
@ -242,11 +243,8 @@ export default {
this.fetchDomainData() this.fetchDomainData()
this.fetchZoneData() this.fetchZoneData()
}, },
isAdmin () {
return ['Admin'].includes(this.$store.getters.userInfo.roletype)
},
isAdminOrDomainAdmin () { isAdminOrDomainAdmin () {
return ['Admin', 'DomainAdmin'].includes(this.$store.getters.userInfo.roletype) return isAdminOrDomainAdmin()
}, },
isObjectEmpty (obj) { isObjectEmpty (obj) {
return !(obj !== null && obj !== undefined && Object.keys(obj).length > 0 && obj.constructor === Object) return !(obj !== null && obj !== undefined && Object.keys(obj).length > 0 && obj.constructor === Object)
@ -309,7 +307,7 @@ export default {
handleDomainChange (domain) { handleDomainChange (domain) {
this.selectedDomain = domain this.selectedDomain = domain
this.accountVisible = domain.id !== '-1' this.accountVisible = domain.id !== '-1'
if (this.isAdminOrDomainAdmin()) { if (isAdminOrDomainAdmin()) {
this.updateVPCCheckAndFetchNetworkOfferingData() this.updateVPCCheckAndFetchNetworkOfferingData()
} }
}, },
@ -337,10 +335,10 @@ export default {
guestiptype: 'L2', guestiptype: 'L2',
state: 'Enabled' state: 'Enabled'
} }
if (this.isAdminOrDomainAdmin() && this.selectedDomain.id !== '-1') { // domain is visible only for admins if (isAdminOrDomainAdmin() && this.selectedDomain.id !== '-1') { // domain is visible only for admins
params.domainid = this.selectedDomain.id params.domainid = this.selectedDomain.id
} }
if (!this.isAdmin()) { // normal user is not aware of the VLANs in the system, so normal user is not allowed to create network with network offerings whose specifyvlan = true if (!isAdmin()) { // normal user is not aware of the VLANs in the system, so normal user is not allowed to create network with network offerings whose specifyvlan = true
params.specifyvlan = false params.specifyvlan = false
} }
if (forVpc !== null) { if (forVpc !== null) {

View File

@ -34,7 +34,7 @@
@refresh-data="refreshParent" @refresh-data="refreshParent"
@refresh="handleRefresh"/> @refresh="handleRefresh"/>
</a-tab-pane> </a-tab-pane>
<a-tab-pane :tab="$t('label.shared')" key="3" v-if="this.isAdmin()"> <a-tab-pane :tab="$t('label.shared')" key="3" v-if="isAdmin()">
<CreateSharedNetworkForm <CreateSharedNetworkForm
:loading="loading" :loading="loading"
:resource="resource" :resource="resource"
@ -48,6 +48,7 @@
<script> <script>
import { api } from '@/api' import { api } from '@/api'
import { isAdmin } from '@/role'
import CreateIsolatedNetworkForm from '@/views/network/CreateIsolatedNetworkForm' import CreateIsolatedNetworkForm from '@/views/network/CreateIsolatedNetworkForm'
import CreateL2NetworkForm from '@/views/network/CreateL2NetworkForm' import CreateL2NetworkForm from '@/views/network/CreateL2NetworkForm'
import CreateSharedNetworkForm from '@/views/network/CreateSharedNetworkForm' import CreateSharedNetworkForm from '@/views/network/CreateSharedNetworkForm'
@ -89,9 +90,6 @@ export default {
}) })
}, },
methods: { methods: {
isAdmin () {
return ['Admin'].includes(this.$store.getters.userInfo.roletype)
},
fetchActionZoneData () { fetchActionZoneData () {
this.loading = true this.loading = true
const params = {} const params = {}
@ -107,6 +105,9 @@ export default {
this.loading = false this.loading = false
}) })
}, },
isAdmin () {
return isAdmin()
},
handleRefresh () { handleRefresh () {
}, },
refreshParent () { refreshParent () {

View File

@ -423,12 +423,6 @@ export default {
this.fetchNetworkOfferingData() this.fetchNetworkOfferingData()
} }
}, },
isAdmin () {
return ['Admin'].includes(this.$store.getters.userInfo.roletype)
},
isAdminOrDomainAdmin () {
return ['Admin', 'DomainAdmin'].includes(this.$store.getters.userInfo.roletype)
},
isObjectEmpty (obj) { isObjectEmpty (obj) {
return !(obj !== null && obj !== undefined && Object.keys(obj).length > 0 && obj.constructor === Object) return !(obj !== null && obj !== undefined && Object.keys(obj).length > 0 && obj.constructor === Object)
}, },

View File

@ -106,6 +106,7 @@
<script> <script>
import { api } from '@/api' import { api } from '@/api'
import { isAdmin } from '@/role'
import TooltipLabel from '@/components/widgets/TooltipLabel' import TooltipLabel from '@/components/widgets/TooltipLabel'
export default { export default {
@ -156,12 +157,12 @@ export default {
} }
}, },
methods: { methods: {
isAdmin () {
return ['Admin'].includes(this.$store.getters.userInfo.roletype)
},
fetchData () { fetchData () {
this.fetchNetworkOfferingData() this.fetchNetworkOfferingData()
}, },
isAdmin () {
return isAdmin()
},
arrayHasItems (array) { arrayHasItems (array) {
return array !== null && array !== undefined && Array.isArray(array) && array.length > 0 return array !== null && array !== undefined && Array.isArray(array) && array.length > 0
}, },

View File

@ -516,6 +516,7 @@
<script> <script>
import { api } from '@/api' import { api } from '@/api'
import { isAdmin } from '@/role'
import ResourceIcon from '@/components/view/ResourceIcon' import ResourceIcon from '@/components/view/ResourceIcon'
import TooltipLabel from '@/components/widgets/TooltipLabel' import TooltipLabel from '@/components/widgets/TooltipLabel'
@ -609,19 +610,19 @@ export default {
this.isSystem = true this.isSystem = true
} }
this.fetchData() this.fetchData()
this.isPublic = this.isAdmin() this.isPublic = isAdmin()
}, },
methods: { methods: {
fetchData () { fetchData () {
this.fetchDomainData() this.fetchDomainData()
this.fetchZoneData() this.fetchZoneData()
if (this.isAdmin()) { if (isAdmin()) {
this.fetchStorageTagData() this.fetchStorageTagData()
this.fetchDeploymentPlannerData() this.fetchDeploymentPlannerData()
} }
}, },
isAdmin () { isAdmin () {
return ['Admin'].includes(this.$store.getters.userInfo.roletype) return isAdmin()
}, },
arrayHasItems (array) { arrayHasItems (array) {
return array !== null && array !== undefined && Array.isArray(array) && array.length > 0 return array !== null && array !== undefined && Array.isArray(array) && array.length > 0
@ -713,7 +714,7 @@ export default {
this.selectedDeployementPlanner = planner this.selectedDeployementPlanner = planner
this.plannerModeVisible = false this.plannerModeVisible = false
if (this.selectedDeployementPlanner === 'ImplicitDedicationPlanner') { if (this.selectedDeployementPlanner === 'ImplicitDedicationPlanner') {
this.plannerModeVisible = this.isAdmin() this.plannerModeVisible = isAdmin()
} }
}, },
handlePlannerModeChange (val) { handlePlannerModeChange (val) {

View File

@ -351,6 +351,7 @@
<script> <script>
import { api } from '@/api' import { api } from '@/api'
import { isAdmin } from '@/role'
import ResourceIcon from '@/components/view/ResourceIcon' import ResourceIcon from '@/components/view/ResourceIcon'
import TooltipLabel from '@/components/widgets/TooltipLabel' import TooltipLabel from '@/components/widgets/TooltipLabel'
@ -397,18 +398,18 @@ export default {
} }
] ]
this.fetchData() this.fetchData()
this.isPublic = this.isAdmin() this.isPublic = isAdmin()
}, },
methods: { methods: {
fetchData () { fetchData () {
this.fetchDomainData() this.fetchDomainData()
this.fetchZoneData() this.fetchZoneData()
if (this.isAdmin()) { if (isAdmin()) {
this.fetchStorageTagData() this.fetchStorageTagData()
} }
}, },
isAdmin () { isAdmin () {
return ['Admin'].includes(this.$store.getters.userInfo.roletype) return isAdmin()
}, },
arrayHasItems (array) { arrayHasItems (array) {
return array !== null && array !== undefined && Array.isArray(array) && array.length > 0 return array !== null && array !== undefined && Array.isArray(array) && array.length > 0

View File

@ -433,6 +433,7 @@
<script> <script>
import { api } from '@/api' import { api } from '@/api'
import { isAdmin } from '@/role'
import CheckBoxSelectPair from '@/components/CheckBoxSelectPair' import CheckBoxSelectPair from '@/components/CheckBoxSelectPair'
import ResourceIcon from '@/components/view/ResourceIcon' import ResourceIcon from '@/components/view/ResourceIcon'
import TooltipLabel from '@/components/widgets/TooltipLabel' import TooltipLabel from '@/components/widgets/TooltipLabel'
@ -498,7 +499,7 @@ export default {
this.fetchServiceOfferingData() this.fetchServiceOfferingData()
}, },
isAdmin () { isAdmin () {
return ['Admin'].includes(this.$store.getters.userInfo.roletype) return isAdmin()
}, },
isSupportedServiceObject (obj) { isSupportedServiceObject (obj) {
return (obj !== null && obj !== undefined && Object.keys(obj).length > 0 && obj.constructor === Object && 'provider' in obj) return (obj !== null && obj !== undefined && Object.keys(obj).length > 0 && obj.constructor === Object && 'provider' in obj)

View File

@ -142,6 +142,7 @@
<script> <script>
import { api } from '@/api' import { api } from '@/api'
import { isAdmin } from '@/role'
import CheckBoxSelectPair from '@/components/CheckBoxSelectPair' import CheckBoxSelectPair from '@/components/CheckBoxSelectPair'
import ResourceIcon from '@/components/view/ResourceIcon' import ResourceIcon from '@/components/view/ResourceIcon'
import TooltipLabel from '@/components/widgets/TooltipLabel' import TooltipLabel from '@/components/widgets/TooltipLabel'
@ -190,7 +191,7 @@ export default {
this.fetchSupportedServiceData() this.fetchSupportedServiceData()
}, },
isAdmin () { isAdmin () {
return ['Admin'].includes(this.$store.getters.userInfo.roletype) return isAdmin()
}, },
isSupportedServiceObject (obj) { isSupportedServiceObject (obj) {
return (obj !== null && obj !== undefined && Object.keys(obj).length > 0 && obj.constructor === Object && 'provider' in obj) return (obj !== null && obj !== undefined && Object.keys(obj).length > 0 && obj.constructor === Object && 'provider' in obj)

View File

@ -23,7 +23,7 @@
@submit="handleSubmit" @submit="handleSubmit"
layout="vertical"> layout="vertical">
<a-form-item :label="$t('label.ispublic')" v-show="this.isAdmin()"> <a-form-item :label="$t('label.ispublic')" v-show="isAdmin()">
<a-switch v-decorator="['ispublic', { initialValue: this.offeringIsPublic }]" :checked="this.offeringIsPublic" @change="val => { this.offeringIsPublic = val }" /> <a-switch v-decorator="['ispublic', { initialValue: this.offeringIsPublic }]" :checked="this.offeringIsPublic" @change="val => { this.offeringIsPublic = val }" />
</a-form-item> </a-form-item>
@ -103,6 +103,7 @@
<script> <script>
import { api } from '@/api' import { api } from '@/api'
import { isAdmin } from '@/role'
import ResourceIcon from '@/components/view/ResourceIcon' import ResourceIcon from '@/components/view/ResourceIcon'
export default { export default {
@ -169,7 +170,7 @@ export default {
this.fetchZoneData() this.fetchZoneData()
}, },
isAdmin () { isAdmin () {
return ['Admin'].includes(this.$store.getters.userInfo.roletype) return isAdmin()
}, },
fetchOfferingData () { fetchOfferingData () {
this.loading = true this.loading = true
@ -228,7 +229,7 @@ export default {
} }
} }
} else { } else {
if (this.isAdmin()) { if (isAdmin()) {
this.offeringIsPublic = true this.offeringIsPublic = true
} }
} }