diff --git a/public/config.json b/public/config.json
index f4fda4114..ee03c80a0 100644
--- a/public/config.json
+++ b/public/config.json
@@ -1,5 +1,11 @@
{
- "apiBase": "/client/api",
+ "servers": [
+ {
+ "name": "Local-Server",
+ "apiHost": "",
+ "apiBase": "/client/api"
+ }
+ ],
"docBase": "http://docs.cloudstack.apache.org/en/latest",
"appTitle": "CloudStack",
"footer": "Licensed under the Apache License, Version 2.0.",
diff --git a/src/components/widgets/Console.vue b/src/components/widgets/Console.vue
index 3064d8f0d..b9a5b0553 100644
--- a/src/components/widgets/Console.vue
+++ b/src/components/widgets/Console.vue
@@ -18,7 +18,7 @@
@@ -27,6 +27,9 @@
diff --git a/src/main.js b/src/main.js
index acc41d2de..bffed7604 100644
--- a/src/main.js
+++ b/src/main.js
@@ -37,7 +37,7 @@ Vue.use(toLocaleDatePlugin)
fetch('config.json').then(response => response.json()).then(config => {
Vue.prototype.$config = config
- Vue.axios.defaults.baseURL = config.apiBase
+ Vue.axios.defaults.baseURL = (config.servers[0].apiHost || '') + config.servers[0].apiBase
loadLanguageAsync().then(() => {
new Vue({
diff --git a/src/permission.js b/src/permission.js
index 8e9751186..d931f5f5a 100644
--- a/src/permission.js
+++ b/src/permission.js
@@ -26,7 +26,7 @@ import 'nprogress/nprogress.css' // progress bar style
import message from 'ant-design-vue/es/message'
import notification from 'ant-design-vue/es/notification'
import { setDocumentTitle } from '@/utils/domUtil'
-import { ACCESS_TOKEN, APIS } from '@/store/mutation-types'
+import { ACCESS_TOKEN, APIS, SERVER_MANAGER } from '@/store/mutation-types'
NProgress.configure({ showSpinner: false }) // NProgress Configuration
@@ -39,6 +39,19 @@ router.beforeEach((to, from, next) => {
const title = i18n.t(to.meta.title) + ' - ' + Vue.prototype.$config.appTitle
setDocumentTitle(title)
}
+
+ const servers = Vue.prototype.$config.servers
+ const serverStorage = Vue.ls.get(SERVER_MANAGER)
+ let apiFullPath = ''
+ if (serverStorage) {
+ apiFullPath = (serverStorage.apiHost || '') + serverStorage.apiBase
+ }
+ const serverFilter = servers.filter(ser => (ser.apiHost || '') + ser.apiBase === apiFullPath)
+ const server = serverFilter[0] || servers[0]
+
+ Vue.axios.defaults.baseURL = (server.apiHost || '') + server.apiBase
+ store.dispatch('SetServer', server)
+
const validLogin = Vue.ls.get(ACCESS_TOKEN) || Cookies.get('userid') || Cookies.get('userid', { path: '/client' })
if (validLogin) {
if (to.path === '/user/login') {
diff --git a/src/store/getters.js b/src/store/getters.js
index 4e2d5eb21..30321f521 100644
--- a/src/store/getters.js
+++ b/src/store/getters.js
@@ -35,6 +35,7 @@ const getters = {
cloudian: state => state.user.cloudian,
zones: state => state.user.zones,
timezoneoffset: state => state.user.timezoneoffset,
+ server: state => state.app.server,
usebrowsertimezone: state => state.user.usebrowsertimezone
}
diff --git a/src/store/modules/app.js b/src/store/modules/app.js
index a03fc63b2..afd552093 100644
--- a/src/store/modules/app.js
+++ b/src/store/modules/app.js
@@ -27,6 +27,7 @@ import {
DEFAULT_FIXED_HEADER_HIDDEN,
DEFAULT_CONTENT_WIDTH_TYPE,
DEFAULT_MULTI_TAB,
+ SERVER_MANAGER,
USE_BROWSER_TIMEZONE
} from '@/store/mutation-types'
@@ -44,7 +45,8 @@ const app = {
color: null,
inverted: true,
multiTab: true,
- metrics: false
+ metrics: false,
+ server: ''
},
mutations: {
SET_SIDEBAR_TYPE: (state, type) => {
@@ -97,6 +99,10 @@ const app = {
SET_METRICS: (state, bool) => {
state.metrics = bool
},
+ SET_SERVER: (state, server) => {
+ Vue.ls.set(SERVER_MANAGER, server)
+ state.server = server
+ },
SET_USE_BROWSER_TIMEZONE: (state, bool) => {
Vue.ls.set(USE_BROWSER_TIMEZONE, bool)
state.usebrowsertimezone = bool
@@ -145,6 +151,9 @@ const app = {
SetMetrics ({ commit }, bool) {
commit('SET_METRICS', bool)
},
+ SetServer ({ commit }, server) {
+ commit('SET_SERVER', server)
+ },
SetUseBrowserTimezone ({ commit }, bool) {
commit('SET_USE_BROWSER_TIMEZONE', bool)
}
diff --git a/src/store/mutation-types.js b/src/store/mutation-types.js
index 9d735610e..1e5b58cd8 100644
--- a/src/store/mutation-types.js
+++ b/src/store/mutation-types.js
@@ -31,6 +31,7 @@ export const APIS = 'APIS'
export const ZONES = 'ZONES'
export const ASYNC_JOB_IDS = 'ASYNC_JOB_IDS'
export const TIMEZONE_OFFSET = 'TIMEZONE_OFFSET'
+export const SERVER_MANAGER = 'SERVER_MANAGER'
export const USE_BROWSER_TIMEZONE = 'USE_BROWSER_TIMEZONE'
export const CONTENT_WIDTH_TYPE = {
diff --git a/src/views/auth/Login.vue b/src/views/auth/Login.vue
index a43b61191..a1e038799 100644
--- a/src/views/auth/Login.vue
+++ b/src/views/auth/Login.vue
@@ -35,6 +35,23 @@
{{ $t('label.login.portal') }}
+
+
+
+
+ {{ item.name }}
+
+
+
{{ $t('label.login.single.signon') }}
+
+
+
+
+ {{ item.name }}
+
+
+
@@ -110,8 +144,11 @@