mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
UI: Allow accounts of the User type to add other accounts or users to projects through UI (#9927)
This commit is contained in:
parent
4189bac8e0
commit
b6937b6a51
@ -31,27 +31,23 @@
|
|||||||
<template #label>
|
<template #label>
|
||||||
<tooltip-label :title="$t('label.account')" :tooltip="apiParams.addAccountToProject.account.description"/>
|
<tooltip-label :title="$t('label.account')" :tooltip="apiParams.addAccountToProject.account.description"/>
|
||||||
</template>
|
</template>
|
||||||
<a-select
|
<a-auto-complete
|
||||||
show-search
|
|
||||||
v-model:value="form.account"
|
v-model:value="form.account"
|
||||||
:placeholder="apiParams.addAccountToProject.account.description"
|
:placeholder="apiParams.addAccountToProject.account.description"
|
||||||
v-focus="true"
|
:filterOption="filterOption"
|
||||||
:filterOption="false"
|
:options="accounts"
|
||||||
@search="fetchAccounts"
|
>
|
||||||
>
|
<template v-if="load.accounts" #notFoundContent>
|
||||||
<template v-if="load.accounts" #notFoundContent>
|
<a-spin size="small" />
|
||||||
<a-spin size="small" />
|
</template>
|
||||||
</template>
|
<template v-if="!load.accounts" #option="account">
|
||||||
<template v-if="!load.accounts">
|
<span v-if="account.icon">
|
||||||
<a-select-option v-for="account in accounts" :key="account.name" :value="account.name">
|
<resource-icon :image="account.icon.base64image" size="1x" style="margin-right: 5px"/>
|
||||||
<span v-if="account.icon">
|
</span>
|
||||||
<resource-icon :image="account.icon.base64image" size="1x" style="margin-right: 5px"/>
|
<block-outlined v-else style="margin-right: 5px" />
|
||||||
</span>
|
{{ account.name }}
|
||||||
<block-outlined v-else style="margin-right: 5px" />
|
</template>
|
||||||
{{ account.name }}
|
</a-auto-complete>
|
||||||
</a-select-option>
|
|
||||||
</template>
|
|
||||||
</a-select>
|
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item name="email" ref="email">
|
<a-form-item name="email" ref="email">
|
||||||
<template #label>
|
<template #label>
|
||||||
@ -121,27 +117,23 @@
|
|||||||
<template #label>
|
<template #label>
|
||||||
<tooltip-label :title="$t('label.name')" :tooltip="apiParams.addUserToProject.username.description"/>
|
<tooltip-label :title="$t('label.name')" :tooltip="apiParams.addUserToProject.username.description"/>
|
||||||
</template>
|
</template>
|
||||||
<a-select
|
<a-auto-complete
|
||||||
show-search
|
|
||||||
v-model:value="form.username"
|
v-model:value="form.username"
|
||||||
:placeholder="apiParams.addUserToProject.username.description"
|
:placeholder="apiParams.addUserToProject.username.description"
|
||||||
v-focus="true"
|
:filterOption="filterOption"
|
||||||
:filterOption="false"
|
:options="users"
|
||||||
@search="fetchUsers"
|
|
||||||
>
|
>
|
||||||
<template v-if="load.users" #notFoundContent>
|
<template v-if="load.users" #notFoundContent>
|
||||||
<a-spin size="small" />
|
<a-spin size="small" />
|
||||||
</template>
|
</template>
|
||||||
<template v-if="!load.users">
|
<template v-if="!load.users" #option="user">
|
||||||
<a-select-option v-for="user in users" :key="user.username" :value="user.username">
|
<span v-if="user.icon">
|
||||||
<span v-if="user.icon">
|
<resource-icon :image="user.icon.base64image" size="1x" style="margin-right: 5px"/>
|
||||||
<resource-icon :image="user.icon.base64image" size="1x" style="margin-right: 5px"/>
|
</span>
|
||||||
</span>
|
<block-outlined v-else style="margin-right: 5px" />
|
||||||
<block-outlined v-else style="margin-right: 5px" />
|
{{ user.firstName + ' ' + user.lastName + " (" + user.username + ")" }}
|
||||||
{{ user.firstname + ' ' + user.lastname + " (" + user.username + ")" }}
|
|
||||||
</a-select-option>
|
|
||||||
</template>
|
</template>
|
||||||
</a-select>
|
</a-auto-complete>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item name="email" ref="email">
|
<a-form-item name="email" ref="email">
|
||||||
<template #label>
|
<template #label>
|
||||||
@ -254,6 +246,11 @@ export default {
|
|||||||
this.fetchProjectRoles()
|
this.fetchProjectRoles()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
filterOption (input, option) {
|
||||||
|
return (
|
||||||
|
option.value.toUpperCase().indexOf(input.toUpperCase()) >= 0
|
||||||
|
)
|
||||||
|
},
|
||||||
fetchUsers (keyword) {
|
fetchUsers (keyword) {
|
||||||
this.load.users = true
|
this.load.users = true
|
||||||
const params = { listall: true, showicon: true }
|
const params = { listall: true, showicon: true }
|
||||||
@ -261,13 +258,28 @@ export default {
|
|||||||
params.keyword = keyword
|
params.keyword = keyword
|
||||||
}
|
}
|
||||||
api('listUsers', params).then(response => {
|
api('listUsers', params).then(response => {
|
||||||
this.users = response.listusersresponse.user ? response.listusersresponse.user : []
|
this.users = this.parseUsers(response?.listusersresponse?.user)
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
this.$notifyError(error)
|
this.$notifyError(error)
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.load.users = false
|
this.load.users = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
parseUsers (users) {
|
||||||
|
if (!users) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
return users.map(user => {
|
||||||
|
return {
|
||||||
|
value: user.username,
|
||||||
|
username: user.username,
|
||||||
|
firstName: user.firstname,
|
||||||
|
lastName: user.lastname,
|
||||||
|
icon: user.icon
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
fetchAccounts (keyword) {
|
fetchAccounts (keyword) {
|
||||||
this.load.accounts = true
|
this.load.accounts = true
|
||||||
const params = { domainid: this.resource.domainid, showicon: true }
|
const params = { domainid: this.resource.domainid, showicon: true }
|
||||||
@ -275,13 +287,26 @@ export default {
|
|||||||
params.keyword = keyword
|
params.keyword = keyword
|
||||||
}
|
}
|
||||||
api('listAccounts', params).then(response => {
|
api('listAccounts', params).then(response => {
|
||||||
this.accounts = response.listaccountsresponse.account || []
|
this.accounts = this.parseAccounts(response?.listaccountsresponse?.account)
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
this.$notifyError(error)
|
this.$notifyError(error)
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.load.accounts = false
|
this.load.accounts = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
parseAccounts (accounts) {
|
||||||
|
if (!accounts) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
return accounts.map(account => {
|
||||||
|
return {
|
||||||
|
value: account.name,
|
||||||
|
name: account.name,
|
||||||
|
icon: account.icon
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
fetchProjectRoles () {
|
fetchProjectRoles () {
|
||||||
this.load.projectRoles = true
|
this.load.projectRoles = true
|
||||||
api('listProjectRoles', {
|
api('listProjectRoles', {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user