Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 56 additions & 14 deletions ui/src/views/project/AddAccountOrUserToProject.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,27 @@
<template #label>
<tooltip-label :title="$t('label.account')" :tooltip="apiParams.addAccountToProject.account.description"/>
</template>
<a-input
v-model:value="form.account"
:placeholder="apiParams.addAccountToProject.account.description"
v-focus="true" />
<a-select
show-search
v-model:value="form.account"
:placeholder="apiParams.addAccountToProject.account.description"
v-focus="true"
:filterOption="false"
@search="fetchAccounts"
>
<template v-if="load.accounts" #notFoundContent>
<a-spin size="small" />
</template>
<template v-if="!load.accounts">
<a-select-option v-for="account in accounts" :key="account.name" :value="account.name">
<span v-if="account.icon">
<resource-icon :image="account.icon.base64image" size="1x" style="margin-right: 5px"/>
</span>
<block-outlined v-else style="margin-right: 5px" />
{{ account.name }}
</a-select-option>
</template>
</a-select>
</a-form-item>
<a-form-item name="email" ref="email">
<template #label>
Expand Down Expand Up @@ -104,10 +121,27 @@
<template #label>
<tooltip-label :title="$t('label.name')" :tooltip="apiParams.addUserToProject.username.description"/>
</template>
<a-input
v-model:value="form.username"
:placeholder="apiParams.addUserToProject.username.description"
v-focus="true" />
<a-select
show-search
v-model:value="form.username"
:placeholder="apiParams.addUserToProject.username.description"
v-focus="true"
:filterOption="false"
@search="fetchUsers"
>
<template v-if="load.users" #notFoundContent>
<a-spin size="small" />
</template>
<template v-if="!load.users">
<a-select-option v-for="user in users" :key="user.username" :value="user.username">
<span v-if="user.icon">
<resource-icon :image="user.icon.base64image" size="1x" style="margin-right: 5px"/>
</span>
<block-outlined v-else style="margin-right: 5px" />
{{ user.firstname + ' ' + user.lastname + " (" + user.username + ")" }}
</a-select-option>
</template>
</a-select>
</a-form-item>
<a-form-item name="email" ref="email">
<template #label>
Expand Down Expand Up @@ -163,11 +197,13 @@
<script>
import { ref, reactive, toRaw } from 'vue'
import { api } from '@/api'
import ResourceIcon from '@/components/view/ResourceIcon'
import TooltipLabel from '@/components/widgets/TooltipLabel'

export default {
name: 'AddAccountOrUserToProject',
components: {
ResourceIcon,
TooltipLabel
},
props: {
Expand Down Expand Up @@ -218,21 +254,27 @@ export default {
this.fetchProjectRoles()
}
},
fetchUsers () {
fetchUsers (keyword) {
this.load.users = true
api('listUsers', { listall: true }).then(response => {
const params = { listall: true, showicon: true }
if (keyword) {
params.keyword = keyword
}
api('listUsers', params).then(response => {
this.users = response.listusersresponse.user ? response.listusersresponse.user : []
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.load.users = false
})
},
fetchAccounts () {
fetchAccounts (keyword) {
this.load.accounts = true
api('listAccounts', {
domainid: this.resource.domainid
}).then(response => {
const params = { domainid: this.resource.domainid, showicon: true }
if (keyword) {
params.keyword = keyword
}
api('listAccounts', params).then(response => {
this.accounts = response.listaccountsresponse.account || []
}).catch(error => {
this.$notifyError(error)
Expand Down