mirror of
https://gitee.com/devlive-community/datacap.git
synced 2024-12-02 20:17:45 +08:00
[Web] Fixed some issues (#380)
This commit is contained in:
commit
0e14eb1ca2
@ -482,3 +482,9 @@ values ('2', '7'),
|
||||
('1', '6'),
|
||||
('1', '11'),
|
||||
('1', '14');
|
||||
|
||||
-- --------------------------------
|
||||
-- Update to 1.12.0 --
|
||||
-- --------------------------------
|
||||
alter table `menus`
|
||||
add column `redirect` bigint default 0;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
-- --------------------------------
|
||||
-- Table for audit_plugin
|
||||
-- --------------------------------
|
||||
@ -283,7 +284,6 @@ VALUES ('datacap', '$2a$10$bZ4XBRlYUjKfkBovWT9TuuXlEF7lpRxVrXS8iqyCjCHUqy4RPTL8.
|
||||
-- --------------------------------
|
||||
alter table `audit_plugin`
|
||||
add column `count` bigint default 0;
|
||||
|
||||
INSERT INTO `template_sql` (name, content, description, plugin, configure, `system`)
|
||||
VALUES ('getAllDatabase', 'SELECT keyspace_name AS name
|
||||
FROM system_schema.keyspaces', 'Gets a list of all databases', 'Cassandra', '[]', 1);
|
||||
|
5
core/datacap-server/src/main/schema/1.12.0/update.sql
Normal file
5
core/datacap-server/src/main/schema/1.12.0/update.sql
Normal file
@ -0,0 +1,5 @@
|
||||
-- --------------------------------
|
||||
-- Update to 1.12.0 --
|
||||
-- --------------------------------
|
||||
alter table menus
|
||||
add column `redirect` long default 0;
|
@ -792,3 +792,5 @@ WHERE
|
||||
keyspace_name = ''${database:String}''
|
||||
and table_name = ''${table:String}''', 'Get the data column from the database and table', 'Cassandra',
|
||||
'[{"column":"database","type":"String","expression":"${database:String}"},{"column":"table","type":"String","expression":"${table:String}"}]', 1);
|
||||
alter table menus
|
||||
add column `redirect` long default 0;
|
||||
|
@ -73,6 +73,9 @@ public class MenuEntity
|
||||
@Column(name = "icon")
|
||||
private String icon;
|
||||
|
||||
@Column(name = "redirect")
|
||||
private long redirect;
|
||||
|
||||
@Column(name = "create_time")
|
||||
@CreatedDate
|
||||
private Timestamp createTime;
|
||||
|
@ -8,14 +8,14 @@
|
||||
<script lang="ts">
|
||||
import {defineComponent} from "vue";
|
||||
import watermark from 'watermark-dom';
|
||||
import Common from "@/common/Common";
|
||||
import {AuthResponse} from "@/model/AuthResponse";
|
||||
import {TokenCommon} from "@/common/TokenCommon";
|
||||
import router from "@/router";
|
||||
|
||||
export default defineComponent({
|
||||
mounted()
|
||||
{
|
||||
setTimeout(() => {
|
||||
const authUser = JSON.parse(localStorage.getItem(Common.token) || '{}') as AuthResponse;
|
||||
const authUser = TokenCommon.getAuthUser()
|
||||
if (authUser) {
|
||||
const applyWatermark = authUser.username ? authUser.username : 'DataCap';
|
||||
watermark['watermark'].load({
|
||||
@ -34,6 +34,9 @@ export default defineComponent({
|
||||
watermark_parent_height: 0
|
||||
});
|
||||
}
|
||||
else {
|
||||
router.push('/common/token_invalid')
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
});
|
||||
|
@ -27,41 +27,43 @@ export default defineComponent({
|
||||
handlerInitialize()
|
||||
{
|
||||
setTimeout(() => {
|
||||
const calendarContainer = document.getElementById('calendarContainer');
|
||||
const calendarChart = echarts.init(calendarContainer);
|
||||
calendarChart.setOption({
|
||||
tooltip: {
|
||||
formatter: function (params) {
|
||||
return params.data[0] + ' : ' + params.data[1];
|
||||
if (this.configure?.data) {
|
||||
const calendarContainer = document.getElementById('calendarContainer');
|
||||
const calendarChart = echarts.init(calendarContainer);
|
||||
calendarChart.setOption({
|
||||
tooltip: {
|
||||
formatter: function (params) {
|
||||
return params.data[0] + ' : ' + params.data[1];
|
||||
}
|
||||
},
|
||||
visualMap: {
|
||||
min: 0,
|
||||
max: max(this.configure.data.map(ele => ele.count)),
|
||||
type: 'piecewise',
|
||||
orient: 'horizontal',
|
||||
left: 'center',
|
||||
top: 0
|
||||
},
|
||||
calendar: {
|
||||
top: 50,
|
||||
left: 30,
|
||||
right: 10,
|
||||
cellSize: [20, 20],
|
||||
range: new Date().getFullYear(),
|
||||
itemStyle: {
|
||||
borderWidth: 0.5
|
||||
}
|
||||
},
|
||||
series: {
|
||||
type: 'heatmap',
|
||||
coordinateSystem: 'calendar',
|
||||
data: this.configure.data
|
||||
.map(ele => {
|
||||
return [ele.date, ele.count]
|
||||
})
|
||||
}
|
||||
},
|
||||
visualMap: {
|
||||
min: 0,
|
||||
max: max(this.configure.data.map(ele => ele.count)),
|
||||
type: 'piecewise',
|
||||
orient: 'horizontal',
|
||||
left: 'center',
|
||||
top: 0
|
||||
},
|
||||
calendar: {
|
||||
top: 50,
|
||||
left: 30,
|
||||
right: 10,
|
||||
cellSize: [20, 20],
|
||||
range: new Date().getFullYear(),
|
||||
itemStyle: {
|
||||
borderWidth: 0.5
|
||||
}
|
||||
},
|
||||
series: {
|
||||
type: 'heatmap',
|
||||
coordinateSystem: 'calendar',
|
||||
data: this.configure.data
|
||||
.map(ele => {
|
||||
return [ele.date, ele.count]
|
||||
})
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}, 0)
|
||||
}
|
||||
}
|
||||
|
@ -26,30 +26,32 @@ export default defineComponent({
|
||||
handlerInitialize()
|
||||
{
|
||||
setTimeout(() => {
|
||||
const indicators = Array<{ name: string, max: number }>();
|
||||
const data = [];
|
||||
this.configure.data.forEach(ele => {
|
||||
indicators.push({name: ele.label, max: 100});
|
||||
data.push(ele.percentage);
|
||||
});
|
||||
const calendarContainer = document.getElementById('radarContainer');
|
||||
const calendarChart = echarts.init(calendarContainer);
|
||||
calendarChart.setOption({
|
||||
tooltip: {},
|
||||
radar: {
|
||||
shape: 'circle',
|
||||
indicator: indicators
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: '',
|
||||
type: 'radar',
|
||||
data: [{
|
||||
value: data
|
||||
}]
|
||||
}
|
||||
]
|
||||
});
|
||||
if (this.configure?.data) {
|
||||
const indicators = Array<{ name: string, max: number }>();
|
||||
const data = [];
|
||||
this.configure.data.forEach(ele => {
|
||||
indicators.push({name: ele.label, max: 100});
|
||||
data.push(ele.percentage);
|
||||
});
|
||||
const calendarContainer = document.getElementById('radarContainer');
|
||||
const calendarChart = echarts.init(calendarContainer);
|
||||
calendarChart.setOption({
|
||||
tooltip: {},
|
||||
radar: {
|
||||
shape: 'circle',
|
||||
indicator: indicators
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: '',
|
||||
type: 'radar',
|
||||
data: [{
|
||||
value: data
|
||||
}]
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
}, 0)
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
const token = 'AuthToken';
|
||||
const menu = 'AvailableMenus';
|
||||
const token = 'DataCapAuthToken';
|
||||
const menu = 'DataCapAvailableMenus';
|
||||
const getCurrentUserId = () => {
|
||||
return JSON.parse(localStorage.getItem(token) || '{}').id;
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
import {ResponseModel} from "@/model/ResponseModel";
|
||||
import axios from 'axios';
|
||||
import Common from "@/common/Common";
|
||||
import {Message} from "view-ui-plus";
|
||||
import router from "@/router";
|
||||
import {TokenCommon} from "@/common/TokenCommon";
|
||||
|
||||
axios.defaults.headers.post['Access-Control-Allow-Origin'] = '*';
|
||||
|
||||
@ -18,8 +18,7 @@ export class HttpCommon
|
||||
else {
|
||||
axios.defaults.baseURL = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
|
||||
}
|
||||
|
||||
const auth = JSON.parse(localStorage.getItem(Common.token) || '{}');
|
||||
const auth = TokenCommon.getAuthUser();
|
||||
this.configure = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
15
core/datacap-web/src/common/TokenCommon.ts
Normal file
15
core/datacap-web/src/common/TokenCommon.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import {AuthResponse} from "@/model/AuthResponse";
|
||||
import Common from "@/common/Common";
|
||||
|
||||
export class TokenCommon
|
||||
{
|
||||
public static getAuthUser(): AuthResponse
|
||||
{
|
||||
try {
|
||||
return JSON.parse(localStorage.getItem(Common.token) || '{}') as AuthResponse;
|
||||
}
|
||||
catch (error) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
@ -118,4 +118,5 @@ export default {
|
||||
icon: 'Icon',
|
||||
user: 'User',
|
||||
count: 'count',
|
||||
redirect: 'Redirect'
|
||||
}
|
||||
|
@ -117,5 +117,6 @@ export default {
|
||||
i18nKey: 'I18n Key',
|
||||
icon: '图标',
|
||||
user: '用户',
|
||||
count: '总数'
|
||||
count: '总数',
|
||||
redirect: '重定向'
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import LayoutContainer from "@/views/layout/common/Layout.vue";
|
||||
import ProfileLayout from "@/views/layout/user-profile/ProfileLayout.vue";
|
||||
import {Router} from "vue-router";
|
||||
import {TokenCommon} from "@/common/TokenCommon";
|
||||
|
||||
interface RouterItem
|
||||
{
|
||||
@ -75,12 +76,15 @@ const createRemoteRouter = (items: RouterItem[], router: Router, parent?: any) =
|
||||
}
|
||||
|
||||
const createDefaultRouter = (router: any) => {
|
||||
const indexRouter = {
|
||||
path: '/',
|
||||
redirect: '/dashboard/index',
|
||||
component: LayoutContainer
|
||||
};
|
||||
router.addRoute(indexRouter)
|
||||
// Only when the token is valid, the redirection route will be built
|
||||
if (TokenCommon.getAuthUser() !== undefined) {
|
||||
const indexRouter = {
|
||||
path: '/',
|
||||
redirect: '/dashboard/index',
|
||||
component: LayoutContainer
|
||||
};
|
||||
router.addRoute(indexRouter)
|
||||
}
|
||||
const userRouters = {
|
||||
path: '/profile',
|
||||
redirect: '/profile/index',
|
||||
|
@ -5,6 +5,7 @@ import "nprogress/nprogress.css";
|
||||
import Common from "@/common/Common";
|
||||
import LayoutWebErrorContainer from "@/views/layout/web-error/Layout.vue";
|
||||
import {createDefaultRouter, createRemoteRouter} from "@/router/default";
|
||||
import {TokenCommon} from "@/common/TokenCommon";
|
||||
|
||||
NProgress.configure({
|
||||
easing: 'ease',
|
||||
@ -39,6 +40,11 @@ const commonRouters = [
|
||||
name: 'userNotLogin',
|
||||
path: 'not_login',
|
||||
component: () => import("../views/common/user-prepared/UserNotLogin.vue")
|
||||
},
|
||||
{
|
||||
name: 'userTokenInvalid',
|
||||
path: 'token_invalid',
|
||||
component: () => import("../views/common/user-prepared/UserTokenInvalid.vue")
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -77,7 +83,7 @@ createRemoteRouter(JSON.parse(localStorage.getItem(Common.menu)), router)
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
NProgress.start();
|
||||
const isLogin = JSON.parse(localStorage.getItem(Common.token));
|
||||
const isLogin = TokenCommon.getAuthUser();
|
||||
if (to.matched.length === 0) {
|
||||
// When the user is not logged in, echo the not logged in page
|
||||
if (isLogin) {
|
||||
|
@ -0,0 +1,25 @@
|
||||
<template>
|
||||
<div>
|
||||
<Exception type="500">
|
||||
<template #desc>
|
||||
Current token is invalid.
|
||||
</template>
|
||||
<template #actions>
|
||||
<Button type="primary" @click="handlerGoSignIn">{{ $t('common.login') }}</Button>
|
||||
</template>
|
||||
</Exception>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import router from "@/router";
|
||||
import Common from "@/common/Common";
|
||||
|
||||
export default {
|
||||
methods: {
|
||||
handlerGoSignIn() {
|
||||
localStorage.removeItem(Common.token)
|
||||
router.push('/auth/signin');
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -78,17 +78,17 @@
|
||||
<script lang="ts">
|
||||
import {defineComponent} from "vue";
|
||||
import Common from "@/common/Common";
|
||||
import {AuthResponse} from "@/model/AuthResponse";
|
||||
import router from "@/router";
|
||||
import config from '../../../../../package.json';
|
||||
import {createDefaultRouter, createRemoteRouter} from "@/router/default";
|
||||
import {TokenCommon} from "@/common/TokenCommon";
|
||||
|
||||
export default defineComponent({
|
||||
name: "LayoutHeader",
|
||||
setup()
|
||||
{
|
||||
let username;
|
||||
const authUser = JSON.parse(localStorage.getItem(Common.token) || '{}') as AuthResponse;
|
||||
const authUser = TokenCommon.getAuthUser();
|
||||
if (authUser) {
|
||||
username = authUser.username;
|
||||
}
|
||||
|
@ -42,6 +42,13 @@
|
||||
</Select>
|
||||
</FormItem>
|
||||
</Col>
|
||||
<Col span="12">
|
||||
<FormItem :label="$t('common.redirect')" :label-width="80" prop="parent">
|
||||
<Select v-model="formState['redirect']">
|
||||
<Option v-for="menu in fullMenus" :value="menu.id" :key="menu.name">{{ menu.name }}</Option>
|
||||
</Select>
|
||||
</FormItem>
|
||||
</Col>
|
||||
<Col span="12">
|
||||
<FormItem :label="$t('common.i18nKey')" :label-width="80" prop="i18nKey">
|
||||
<Input v-model="formState['i18nKey']"/>
|
||||
|
Loading…
Reference in New Issue
Block a user