Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
chore: user menu list
Browse files Browse the repository at this point in the history
  • Loading branch information
hibig committed Aug 9, 2023
1 parent 97ff3b6 commit 811e6a3
Show file tree
Hide file tree
Showing 31 changed files with 300 additions and 203 deletions.
2 changes: 1 addition & 1 deletion config/vite.config.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default mergeConfig(
},
https: true,
port: 4000,
proxy: createProxyTable('https://192.168.50.29')
proxy: createProxyTable()
},
plugins: [
basicSsl(),
Expand Down
2 changes: 1 addition & 1 deletion src/assets/style/global.less
Original file line number Diff line number Diff line change
Expand Up @@ -368,4 +368,4 @@ body {
@import url('./arco-descriptions.less');
@import url('./flex.less');
@import url('./margin.less');
@import url('//at.alicdn.com/t/c/font_3892962_46d5t377xga.css');
@import url('//at.alicdn.com/t/c/font_3892962_leqtve70tse.css');
2 changes: 1 addition & 1 deletion src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import Breadcrumb from './breadcrumb/index.vue';
import GroupTitle from './group-title/index.vue';

const IconFont = Icon.addFromIconFontCn({
src: '//at.alicdn.com/t/c/font_3892962_46d5t377xga.js'
src: '//at.alicdn.com/t/c/font_3892962_leqtve70tse.js'
});
// Manually introduce ECharts modules to reduce packing size

Expand Down
1 change: 0 additions & 1 deletion src/components/menu/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
});
const appRoute = computed(() => {
return router.getRoutes().find((el) => {
// return el.name === currentRoute.value;
return el.name === 'root';
}) as RouteRecordNormalized;
});
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/permissions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function usePermission(to?) {
},

getFirstRouteName(appRoutes: routeRaw[]) {
const firstChildren = get(appRoutes, '0.children');
const firstChildren = get(appRoutes, '0.children') || [];
const firstName = get(appRoutes, '0.name');
// all routes permission denied
if ((!firstChildren || !firstChildren.length) && !firstName)
Expand Down
3 changes: 2 additions & 1 deletion src/locale/en-US/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,6 @@ export default {
'common.tips.change': 'there are unsaved changes!',
'common.copy.notSupport': 'Your browser does not support Clipboard API',
'common.title.basicInfo': 'Basic Information',
'common.help.need': 'Need help?'
'common.help.need': 'Need help?',
'common.help.eg': 'e.g.:'
};
3 changes: 2 additions & 1 deletion src/locale/zh-CN/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,6 @@ export default {
'common.tips.change': '有未保存的更改!',
'common.copy.notSupport': '您的浏览器不支持剪贴板 API',
'common.title.basicInfo': '基本信息',
'common.help.need': '需要帮助?'
'common.help.need': '需要帮助?',
'common.help.eg': '例:'
};
1 change: 1 addition & 0 deletions src/router/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ export { default as DASHBOARD } from './dashboard';
export { default as OPERATIONHUB } from './operation-hub';
export { default as PROFILE } from './profile';
export { default as SYSTEMSETTINGS } from './system-settings';
export { default as USERS } from './users';

export default {};
6 changes: 6 additions & 0 deletions src/router/config/users.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const Users = {
Index: 'Users',
List: 'UsersList'
};

export default Users;
2 changes: 1 addition & 1 deletion src/router/guard/permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function setupPermissionGuard(router: Router) {
name: 'forbidden'
};
next({
name: destination
name: destination as string
});
return;
}
Expand Down
9 changes: 7 additions & 2 deletions src/router/routes/modules/cost.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Resources } from '@/permissions/config';
import analyseRoutes from '@/views/cost-management/analyse/routes';
import COST from '../../config/cost-management';

Expand All @@ -7,11 +8,15 @@ export default {
component: () => import('@/views/cost-management/index.vue'),
meta: {
locale: 'navbar.costmanagement',
requiresAuth: false,
requiresAuth: true,
isRouteView: true,
order: 2,
icon: 'icon-bar-chart',
onlyRenderChildren: true
onlyRenderChildren: true,
permission: {
resource: Resources.Costs,
actions: ['POST']
}
},
children: [...analyseRoutes]
};
19 changes: 17 additions & 2 deletions src/router/routes/modules/operation.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Resources } from '@/permissions/config';
import connectorRoutes from '@/views/operation-hub/connectors/routes';
import templateRoutes from '@/views/operation-hub/templates/routes';
import secretRoutes from '@/views/operation-hub/variables/routes';
Expand All @@ -10,11 +11,25 @@ export default {
component: () => import('@/views/operation-hub/index.vue'),
meta: {
locale: 'navbar.operatorhub',
requiresAuth: false,
requiresAuth: true,
isRouteView: true,
order: 3,
icon: 'i class="icon-a-relation10-line iconfont size-18"',
onlyRenderChildren: true
onlyRenderChildren: true,
permission: [
{
resource: Resources.Templates,
actions: ['GET']
},
{
resource: Resources.Connectors,
actions: ['GET']
},
{
resource: Resources.Secrets,
actions: ['GET']
}
]
},
children: [
...operationRoutes,
Expand Down
14 changes: 8 additions & 6 deletions src/router/routes/modules/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@ export default {
ignoreCache: true,
locale: 'menu.system.setting',
icon: 'icon-settings',
requiresAuth: false,
requiresAuth: true,
isRouteView: true,
order: 6,
onlyRenderChildren: true
onlyRenderChildren: true,
permission: [
{
resource: Resources.Settings,
actions: ['GET']
}
]
},
children: [
{
Expand All @@ -30,10 +36,6 @@ export default {
{
resource: Resources.Settings,
actions: ['GET']
},
{
resource: Resources.Subjects,
actions: ['GET']
}
],
roles: ['*']
Expand Down
46 changes: 46 additions & 0 deletions src/router/routes/modules/users.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Resources } from '@/permissions/config';
import USERS from '../../config/users';

export default {
path: 'system',
name: USERS.Index,
component: () => import('@/views/system/index.vue'),
meta: {
hideInMenu: false,
ignoreCache: true,
locale: 'menu.systemsettings.user',
icon: 'i class="icon-users-o iconfont size-18"',
iconfont: true,
requiresAuth: true,
isRouteView: true,
order: 6,
onlyRenderChildren: true,
permission: [
{
resource: Resources.Subjects,
actions: ['GET']
}
]
},
children: [
{
path: 'settings',
name: USERS.List,
component: () => import('@/views/users/pages/list.vue'),
meta: {
hideInMenu: false,
ignoreCache: true,
clearMenuStatus: false,
locale: 'menu.systemsettings.user',
requiresAuth: true,
permission: [
{
resource: Resources.Subjects,
actions: ['GET']
}
],
roles: ['*']
}
}
]
};
118 changes: 3 additions & 115 deletions src/views/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,12 @@
import dayjs from 'dayjs';
import _, { reduce, each, get, sortBy, keys, uniq, map, uniqBy } from 'lodash';
import _, { each, get, sortBy, uniq } from 'lodash';

export const dateFormatMap = {
day: 'YYYY.MM.DD',
week: 'YYYY.MM.DD',
month: 'YYYY.MM',
year: 'YYYY'
};
export const getStackLineDataList = (
source: any[],
obj: { fields: string[]; xAxis: string }
) => {
type ItemType = { name: string; value: number[] };
source = sortBy(source, (item) => item[obj.xAxis]);
const dataList: ItemType[] = [];
const xAxis: string[] = [];
each(obj.fields, (key) => {
const itemData: ItemType = {
name: key,
value: []
};
each(source, (item) => {
itemData.value.push(item[key] || 0);
xAxis.push(dayjs(get(item, obj.xAxis)).format('YYYY-MM-DD'));
});
dataList.push(itemData);
});
return { data: dataList, xAxis: uniq(xAxis) };
};

export const setEndTimeAddDay = (time, mode) => {
if (mode === 'utc') {
Expand All @@ -36,89 +15,6 @@ export const setEndTimeAddDay = (time, mode) => {
return dayjs(time).hour(0).minute(0).second(0).add(1, 'day').format();
};

/**
*
* @date 2023-03-22
* @param {any} {list: source list
* @param {any} key: data key
* @param {any} xAxis}:
*/
export const getStackLineData = ({
list,
key = 'totalCost',
fieldName = 'itemName',
xAxis = 'startTime',
step = 'day'
}: {
list: object[];
key?: string;
fieldName?: string;
xAxis?: string;
step?: string;
}) => {
const result = {
bar: [],
line: [] as any[],
xAxis: [] as string[],
dataConfig: [] as any[]
};
list = map(list || [], (s) => {
s[key] = s[key] || 0;
return s;
});
list = sortBy(list, (s) => s[xAxis]);
const diffFieldName = uniqBy(list, (s) => s[fieldName]);
// {[key]: {name: key, value: []}}
const dataObj = reduce(
diffFieldName,
(obj, item) => {
obj[get(item, fieldName)] = {
name: get(item, fieldName),
value: []
};
result.dataConfig.push({
name: get(item, fieldName),
label: get(item, fieldName)
});
return obj;
},
{}
);
// {'2023-03-22': {fieldName: ''}}
const fielNameValueInxAixs = reduce(
list,
(obj, item) => {
const xAxisVal = dayjs(item[xAxis]).format(get(dateFormatMap, step));
result.xAxis.push(xAxisVal);
const fieldNameVal = item[fieldName];
if (obj[xAxisVal]) {
if (!get(obj, `${xAxisVal}.${fieldNameVal}`)) {
obj[xAxisVal][fieldNameVal] = item[key];
}
} else {
obj[xAxisVal] = {};
obj[xAxisVal][fieldNameVal] = item[key];
}
return obj;
},
{}
);
// ['2023-1','2023-1',...]
const xAxisList = keys(fielNameValueInxAixs);
each(diffFieldName, (p) => {
const k = get(p, fieldName);
each(xAxisList, (x) => {
dataObj[k].value.push(get(fielNameValueInxAixs[x], `${k}`) || 0);
});
});

each(diffFieldName, (sItem) => {
result.line.push(get(dataObj, sItem[fieldName]));
});
result.xAxis = uniq(result.xAxis);
return result;
};

export const websocketEventType = {
CREATE: 1,
UPDATE: 2,
Expand Down Expand Up @@ -189,16 +85,8 @@ export const QAlinkMap = {
],
Cost: 'https://seal-io.github.io/docs/category/%E6%88%90%E6%9C%AC%E4%B8%AD%E5%BF%83',
Template: 'https://seal-io.github.io/docs/operation/template',
Settings: [
{
label: 'menu.systemsettings.user',
url: 'https://seal-io.github.io/docs/setting/user'
},
{
label: 'menu.systemsettings.config',
url: 'https://seal-io.github.io/docs/setting/configuration'
}
]
Settings: 'https://seal-io.github.io/docs/setting/configuration',
Users: 'https://seal-io.github.io/docs/setting/user'
};
export const USER_DEFAULT_PROJECT = 'USER_DEFAULT_PROJECT';

Expand Down
Loading

0 comments on commit 811e6a3

Please sign in to comment.