This is an automated email from the ASF dual-hosted git repository. nvazquez pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/main by this push: new 11455f6d49c UI: Add option to Login to a specific Project view via setting on config.json (#10935) 11455f6d49c is described below commit 11455f6d49c051f56f7c3a2c7d3003bb9e6e74ef Author: Nicolas Vazquez <nicovazque...@gmail.com> AuthorDate: Thu Jul 24 11:42:25 2025 -0300 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 <pearl1...@gmail.com> --- ui/public/config.json | 1 + ui/src/views/auth/Login.vue | 44 +++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/ui/public/config.json b/ui/public/config.json index bea9599fa3a..a1069218136 100644 --- a/ui/public/config.json +++ b/ui/public/config.json @@ -98,6 +98,7 @@ "basicZoneEnabled": true, "multipleServer": false, "allowSettingTheme": true, + "displayProjectFieldOnLogin": false, "imageSelectionInterface": "modern", "showUserCategoryForModernImageSelection": true, "showAllCategoryForModernImageSelection": false, diff --git a/ui/src/views/auth/Login.vue b/ui/src/views/auth/Login.vue index a3a20428f0b..531250a4ffc 100644 --- a/ui/src/views/auth/Login.vue +++ b/ui/src/views/auth/Login.vue @@ -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