diff --git a/ui/src/assets/icons/cloudian.svg b/ui/src/assets/icons/cloudian.svg new file mode 100644 index 00000000000..3b9e91efe84 --- /dev/null +++ b/ui/src/assets/icons/cloudian.svg @@ -0,0 +1,87 @@ + +image/svg+xml + + + + + diff --git a/ui/src/config/router.js b/ui/src/config/router.js index fb4f40a9263..8036e7adadc 100644 --- a/ui/src/config/router.js +++ b/ui/src/config/router.js @@ -29,7 +29,8 @@ import iam from '@/config/section/iam' import infra from '@/config/section/infra' import offering from '@/config/section/offering' import config from '@/config/section/config' -import plugin from '@/config/section/plugin' +import quota from '@/config/section/plugin/quota' +import cloudian from '@/config/section/plugin/cloudian' export function generateRouterMap (section) { var map = { @@ -201,7 +202,8 @@ export const asyncRouterMap = [ generateRouterMap(infra), generateRouterMap(offering), generateRouterMap(config), - generateRouterMap(plugin), + generateRouterMap(quota), + generateRouterMap(cloudian), { path: '/exception', diff --git a/ui/src/config/section/plugin.js b/ui/src/config/section/plugin/cloudian.js similarity index 68% rename from ui/src/config/section/plugin.js rename to ui/src/config/section/plugin/cloudian.js index 687cc237c4d..101c70d2c11 100644 --- a/ui/src/config/section/plugin.js +++ b/ui/src/config/section/plugin/cloudian.js @@ -15,22 +15,12 @@ // specific language governing permissions and limitations // under the License. +import cloudian from '@/assets/icons/cloudian.svg?inline' + export default { - name: 'plugin', - title: 'Plugins', - icon: 'heat-map', - children: [ - { - name: 'quota', - title: 'Quota', - icon: 'pie-chart', - permission: ['quotaSummary', 'quotaIsEnabled'] - }, - { - name: 'cloudian', - title: 'Cloudian Storage', - icon: 'cloud-download', - permission: ['cloudianSsoLogin', 'cloudianIsEnabled'] - } - ] + name: 'cloudian', + title: 'Cloudian Storage', + icon: cloudian, + permission: ['cloudianSsoLogin'], + component: () => import('@/views/plugins/CloudianPlugin.vue') } diff --git a/ui/src/config/section/plugin/quota.js b/ui/src/config/section/plugin/quota.js new file mode 100644 index 00000000000..b4fff921763 --- /dev/null +++ b/ui/src/config/section/plugin/quota.js @@ -0,0 +1,49 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +export default { + name: 'quota', + title: 'Quota', + icon: 'pie-chart', + permission: ['quotaSummary'], + children: [ + { + name: 'quotasummary', + title: 'Summary', + icon: 'bars', + permission: ['quotaSummary'], + columns: ['account', 'domain', 'state', 'currency', 'balance', 'quota'], + details: ['account', 'domain', 'state', 'currency', 'balance', 'quota', 'startdate', 'enddate'] + }, + { + name: 'quotatariff', + title: 'Tariff', + icon: 'credit-card', + permission: ['quotaTariffList'], + columns: ['usageName', 'description', 'usageUnit', 'tariffValue'], + details: ['usageName', 'description', 'usageUnit', 'tariffValue'] + }, + { + name: 'quotaemailtemplate', + title: 'Email Template', + icon: 'mail', + permission: ['quotaEmailTemplateList'], + columns: ['templatetype', 'templatesubject', 'templatebody'], + details: ['templatetype', 'templatesubject', 'templatebody'] + } + ] +} diff --git a/ui/src/store/getters.js b/ui/src/store/getters.js index 13cd2b75582..935a78f20a1 100644 --- a/ui/src/store/getters.js +++ b/ui/src/store/getters.js @@ -30,7 +30,8 @@ const getters = { addRouters: state => state.permission.addRouters, multiTab: state => state.app.multiTab, asyncJobIds: state => state.user.asyncJobIds, - isLdapEnabled: state => state.user.isLdapEnabled + isLdapEnabled: state => state.user.isLdapEnabled, + cloudian: state => state.user.cloudian } export default getters diff --git a/ui/src/store/modules/user.js b/ui/src/store/modules/user.js index 43426cc5e6c..f65215e4c36 100644 --- a/ui/src/store/modules/user.js +++ b/ui/src/store/modules/user.js @@ -32,7 +32,8 @@ const user = { features: {}, project: {}, asyncJobIds: [], - isLdapEnabled: false + isLdapEnabled: false, + cloudian: {} }, mutations: { @@ -66,6 +67,9 @@ const user = { SET_LDAP: (state, isLdapEnabled) => { state.isLdapEnabled = isLdapEnabled }, + SET_CLOUDIAN: (state, cloudian) => { + state.cloudian = cloudian + }, RESET_THEME: (state) => { Vue.ls.set(DEFAULT_THEME, 'light') } @@ -137,20 +141,37 @@ const user = { }).catch(error => { reject(error) }) + + api('cloudianIsEnabled').then(response => { + const cloudian = response.cloudianisenabledresponse.cloudianisenabled || {} + commit('SET_CLOUDIAN', cloudian) + }).catch(ignored => { + }) }) }, + Logout ({ commit, state }) { return new Promise((resolve) => { + var cloudianUrl = null + if (state.cloudian.url && state.cloudian.enabled) { + cloudianUrl = state.cloudian.url + 'logout.htm?redirect=' + encodeURIComponent(window.location.href) + } + commit('SET_TOKEN', '') commit('SET_PROJECT', {}) commit('SET_APIS', {}) + commit('SET_CLOUDIAN', {}) commit('RESET_THEME') Vue.ls.remove(CURRENT_PROJECT) Vue.ls.remove(ACCESS_TOKEN) Vue.ls.remove(ASYNC_JOB_IDS) logout(state.token).then(() => { - resolve() + if (cloudianUrl) { + window.location.href = cloudianUrl + } else { + resolve() + } }).catch(() => { resolve() }) diff --git a/ui/src/views/plugins/CloudianPlugin.vue b/ui/src/views/plugins/CloudianPlugin.vue new file mode 100644 index 00000000000..28595cc08ca --- /dev/null +++ b/ui/src/views/plugins/CloudianPlugin.vue @@ -0,0 +1,62 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + + + +