Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AMORO-2359] Support log out of the ams dashboard #2360

Merged
merged 3 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
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
50 changes: 47 additions & 3 deletions ams/dashboard/src/components/Topbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,24 @@
<template #title>{{$t('userGuide')}}</template>
<question-circle-outlined class="question-icon" @click="goDocs" />
</a-tooltip>
<a-tooltip>
<template #title>{{$t('logout')}}</template>
<a-button class='logout-button' @click="handleLogout">
<LogoutOutlined style="font-size: 1.2em"></LogoutOutlined>
</a-button>
</a-tooltip>
</div>
</template>

<script lang="ts">

import { defineComponent, onMounted, reactive } from 'vue'
import { QuestionCircleOutlined } from '@ant-design/icons-vue'
import { QuestionCircleOutlined, LogoutOutlined } from '@ant-design/icons-vue'
import { Modal } from 'ant-design-vue'
import { useI18n } from 'vue-i18n'
import useStore from '@/store'
import { getVersionInfo } from '@/services/global.service'
import loginService from '@/services/login.service'

interface IVersion {
version: string
Expand All @@ -25,13 +35,17 @@ interface IVersion {
export default defineComponent ({
name: 'Topbar',
components: {
QuestionCircleOutlined
QuestionCircleOutlined,
LogoutOutlined
},
setup() {
const verInfo = reactive<IVersion>({
version: '',
commitTime: ''
})

const { t } = useI18n()

const getVersion = async() => {
const res = await getVersionInfo()
if (res) {
Expand All @@ -40,16 +54,40 @@ export default defineComponent ({
}
}

const handleLogout = async () => {
Modal.confirm({
title: t('logoutModalTitle'),
content: '',
okText: '',
cancelText: '',
onOk: async () => {
try {
const res = await loginService.logout()
console.log(res.code)
} catch (error) {
} finally {
const store = useStore()
store.updateUserInfo({
userName: ''
})
window.location.href = '/login'
}
}
})
}

const goDocs = () => {
window.open('https://amoro.netease.com/docs/latest/')
}

onMounted(() => {
getVersion()
})

return {
verInfo,
goDocs
goDocs,
handleLogout
}
}
})
Expand All @@ -75,4 +113,10 @@ export default defineComponent ({
.topbar-tooltip .ant-tooltip-inner {
font-size: 12px;
}
.logout-button {
border-color: transparent;
}
.logout-button:hover {
border-color: unset;
}
</style>
2 changes: 2 additions & 0 deletions ams/dashboard/src/language/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export default {
backHome: 'Back to Home',
version: 'Version',
userGuide: 'User Guide',
logout: 'Logout',
logoutModalTitle: 'Log out of the ams?',
order: 'Order',
cluster: 'Cluster',
database: 'Database | Databases',
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading