mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
UI: Add option to Login to a specific Project view via setting on config.json (#10935)
* UI: Login to a specific Project view * Fix project icon * Add the option to display project on login on the config.json file --------- Co-authored-by: Pearl Dsilva <pearl1594@gmail.com>
This commit is contained in:
parent
22b753e930
commit
11455f6d49
1
ui/public/config.json
vendored
1
ui/public/config.json
vendored
@ -98,6 +98,7 @@
|
||||
"basicZoneEnabled": true,
|
||||
"multipleServer": false,
|
||||
"allowSettingTheme": true,
|
||||
"displayProjectFieldOnLogin": false,
|
||||
"imageSelectionInterface": "modern",
|
||||
"showUserCategoryForModernImageSelection": true,
|
||||
"showAllCategoryForModernImageSelection": false,
|
||||
|
||||
@ -91,6 +91,18 @@
|
||||
type="text"
|
||||
:placeholder="$t('label.domain')"
|
||||
v-model:value="form.domain"
|
||||
>
|
||||
<template #prefix>
|
||||
<project-outlined />
|
||||
</template>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
<a-form-item ref="project" name="project" v-if="$config.displayProjectFieldOnLogin">
|
||||
<a-input
|
||||
size="large"
|
||||
type="text"
|
||||
:placeholder="$t('label.project')"
|
||||
v-model:value="form.project"
|
||||
>
|
||||
<template #prefix>
|
||||
<block-outlined />
|
||||
@ -230,7 +242,8 @@ export default {
|
||||
loginType: 0
|
||||
},
|
||||
server: '',
|
||||
forgotPasswordEnabled: false
|
||||
forgotPasswordEnabled: false,
|
||||
project: null
|
||||
}
|
||||
},
|
||||
created () {
|
||||
@ -255,7 +268,8 @@ export default {
|
||||
this.form = reactive({
|
||||
server: (this.server.apiHost || '') + this.server.apiBase,
|
||||
username: this.$route.query?.username || '',
|
||||
domain: this.$route.query?.domain || ''
|
||||
domain: this.$route.query?.domain || '',
|
||||
project: null
|
||||
})
|
||||
this.rules = reactive({})
|
||||
this.setRules()
|
||||
@ -447,7 +461,7 @@ export default {
|
||||
})
|
||||
})
|
||||
},
|
||||
loginSuccess (res) {
|
||||
async loginSuccess (res) {
|
||||
this.$notification.destroy()
|
||||
this.$store.commit('SET_COUNT_NOTIFY', 0)
|
||||
if (store.getters.twoFaEnabled === true && store.getters.twoFaProvider !== '' && store.getters.twoFaProvider !== undefined) {
|
||||
@ -456,9 +470,33 @@ export default {
|
||||
this.$router.push({ path: '/setup2FA' }).catch(() => {})
|
||||
} else {
|
||||
this.$store.commit('SET_LOGIN_FLAG', true)
|
||||
const values = toRaw(this.form)
|
||||
if (values.project) {
|
||||
await this.getProject(values.project)
|
||||
this.$store.dispatch('ProjectView', this.project.id)
|
||||
this.$store.dispatch('SetProject', this.project)
|
||||
this.$store.dispatch('ToggleTheme', this.project.id === undefined ? 'light' : 'dark')
|
||||
}
|
||||
this.$router.push({ path: '/dashboard' }).catch(() => {})
|
||||
}
|
||||
},
|
||||
getProject (projectName) {
|
||||
return new Promise((resolve, reject) => {
|
||||
api('listProjects', {
|
||||
response: 'json',
|
||||
domainId: this.selectedDomain,
|
||||
details: 'min'
|
||||
}).then((response) => {
|
||||
const projects = response.listprojectsresponse.project
|
||||
this.project = projects.filter(project => project.name === projectName)?.[0] || null
|
||||
resolve(this.project)
|
||||
}).catch((error) => {
|
||||
this.$notifyError(error)
|
||||
}).finally(() => {
|
||||
this.loading = false
|
||||
})
|
||||
})
|
||||
},
|
||||
requestFailed (err) {
|
||||
if (err && err.response && err.response.data && err.response.data.loginresponse) {
|
||||
const error = err.response.data.loginresponse.errorcode + ': ' + err.response.data.loginresponse.errortext
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user