feat: set root entity for dashboards and set lang (#48)

This commit is contained in:
Fine0830 2022-03-31 13:25:30 +08:00 committed by GitHub
parent ee06546c20
commit 13b508e896
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 50 additions and 148 deletions

View File

@ -49,7 +49,7 @@ interface Option {
const emit = defineEmits(["change", "query"]); const emit = defineEmits(["change", "query"]);
const props = defineProps({ const props = defineProps({
options: { options: {
type: Array as PropType<(Option & { disabled: boolean })[]>, type: Array as PropType<(Option & { disabled?: boolean })[]>,
default: () => [], default: () => [],
}, },
value: { value: {

View File

@ -19,3 +19,23 @@ export enum TimeType {
HOUR_TIME = "HOUR", HOUR_TIME = "HOUR",
DAY_TIME = "DAY", DAY_TIME = "DAY",
} }
export const Languages = [
{ label: "English", value: "en" },
{ label: "Chinese", value: "zh" },
];
export const RoutesMap: { [key: string]: string } = {
GeneralServices: "GENERAL",
Database: "VIRTUAL_DATABASE",
MeshServices: "MESH",
ControlPanel: "MESH_CP",
DataPanel: "MESH_DP",
Linux: "OS_LINUX",
SkyWalkingServer: "SO11Y_OAP",
Satellite: "SO11Y_SATELLITE",
Functions: "FAAS",
Browser: "BROWSER",
KubernetesCluster: "K8S",
KubernetesService: "K8S_SERVICE",
};

View File

@ -23,13 +23,12 @@ const messages = {
zh, zh,
}; };
const savedLanguage = window.localStorage.getItem("lang"); const savedLanguage = window.localStorage.getItem("language");
let language = navigator.language.split("-")[0]; let language = navigator.language.split("-")[0];
if (!savedLanguage) { if (!savedLanguage) {
window.localStorage.setItem("lang", language); window.localStorage.setItem("language", language);
} }
language = savedLanguage ? savedLanguage : language; language = savedLanguage ? savedLanguage : language;
const i18n = createI18n({ const i18n = createI18n({
locale: language, locale: language,
messages, messages,

View File

@ -41,12 +41,11 @@ const msg = {
dataPanel: "Data Plane", dataPanel: "Data Plane",
controlPanel: "Control Plane", controlPanel: "Control Plane",
eventList: "Event List", eventList: "Event List",
databasePanel: "Database Panel",
meshServicePanel: "Service Panel",
newDashboard: "Create a new dashboard", newDashboard: "Create a new dashboard",
dashboardEdit: "Edit the dashboard", dashboardEdit: "Edit the dashboard",
edit: "Edit", edit: "Edit",
delete: "Delete", delete: "Delete",
confirm: "Confirm",
layer: "Layer", layer: "Layer",
endpoint: "Endpoint", endpoint: "Endpoint",
instance: "Instance", instance: "Instance",
@ -145,56 +144,26 @@ const msg = {
title: "Title", title: "Title",
width: "Width", width: "Width",
height: "Height", height: "Height",
login: "Login Now",
signout: "Sign Out",
dashboard: "Dashboard", dashboard: "Dashboard",
topology: "Topology", topology: "Topology",
trace: "Trace", trace: "Trace",
alarm: "Alarms", alarm: "Alarms",
event: "Event",
auto: "Auto", auto: "Auto",
reload: "Reload", reload: "Reload",
usermode: "User Mode",
editmode: "Edit Mode",
currentVersion: "Current Version",
currentPage: "Current Page",
version: "Version", version: "Version",
page: "Page",
currentDatabase: "Current Database",
templateConfig: "Template Configuration",
copy: "Copy", copy: "Copy",
reset: "Reset", reset: "Reset",
apply: "Apply", apply: "Apply",
createTemplate: "Create Template",
templateType: "Template Type",
templateName: "Template Name",
template: "Template", template: "Template",
confirm: "Confirm",
cancel: "Cancel", cancel: "Cancel",
createTab: "Create Tab", createTab: "Create Tab",
tabName: "Tab Name", tabName: "Tab Name",
nouse: "No Use",
allServices: "All Services",
serviceDetail: "Service Detail",
detectPoint: "Detect Point", detectPoint: "Detect Point",
callType: "Call Type",
server: "Server",
client: "Client",
name: "Name", name: "Name",
types: "Types", types: "Types",
cpm: "Cpm",
sla: "SLA",
latency: "Latency",
avgResponseTime: "Avg Response Time ( ms )",
avgThroughput: "Load (CPM - calls per minute)",
avgSLA: "Successful Rate ( % )",
all: "All", all: "All",
success: "Success",
error: "Error",
endpoints: "Endpoints", endpoints: "Endpoints",
cache: "Cache", cache: "Cache",
global: "Global",
serviceendpoint: "ServiceEndpoint",
serviceinstance: "ServiceInstance", serviceinstance: "ServiceInstance",
databaseaccess: "DatabaseAccess", databaseaccess: "DatabaseAccess",
servicerelation: "ServiceRelation", servicerelation: "ServiceRelation",
@ -229,14 +198,8 @@ const msg = {
weekCutTip: "Last 1 week", weekCutTip: "Last 1 week",
monthCutTip: "Last 1 month", monthCutTip: "Last 1 month",
serverZone: "Server Zone", serverZone: "Server Zone",
percentResponse: "Response Time Percentile ( ms )",
exportImage: "Export image", exportImage: "Export image",
queryData: "Query",
previousService: "Previous Service",
nextService: "Next Service",
object: "Object", object: "Object",
ShowInstanceDependency: "Show Instance Dependency",
InstanceDependencyTitle: "Service Instance Dependency",
profile: "Profile", profile: "Profile",
newTask: "New Task", newTask: "New Task",
monitorTime: "Monitor Time", monitorTime: "Monitor Time",
@ -256,27 +219,16 @@ const msg = {
excludeChildren: "Exclude Children", excludeChildren: "Exclude Children",
view: "View", view: "View",
timeTips: "Time interval cannot exceed 60 days", timeTips: "Time interval cannot exceed 60 days",
standardAPM: "Standard",
entityType: "Entity Type", entityType: "Entity Type",
maxItemNum: "Max number of Item", maxItemNum: "Max number of Item",
independentSelector: "Selectors",
unknownMetrics: "Unknown Metrics", unknownMetrics: "Unknown Metrics",
labels: "Labels", labels: "Labels",
aggregation: "Calculation", aggregation: "Calculation",
unit: "Unit", unit: "Unit",
labelsIndex: "Label Subscript", labelsIndex: "Label Subscript",
parentService: "Parent Service",
isParentService: "Set Parent Service",
noneParentService: "No Parent Service",
group: "Service Group", group: "Service Group",
endpointFilter: "Endpoint Filter",
databaseView: "Database",
browserView: "Browser", browserView: "Browser",
metricsView: "NOC - Network Operation Center",
sortOrder: "Sort Order", sortOrder: "Sort Order",
descendOrder: "Descend Order",
increaseOrder: "Increase Order",
defaultOrder: "Default Order",
chartType: "Chart Type", chartType: "Chart Type",
currentDepth: "Current Depth", currentDepth: "Current Depth",
showDepth: "Show Depth Selector", showDepth: "Show Depth Selector",
@ -364,9 +316,6 @@ const msg = {
noticeTag: "Please press Enter after inputting a tag(key=value).", noticeTag: "Please press Enter after inputting a tag(key=value).",
conditionNotice: conditionNotice:
"Notice: Please press Enter after inputting a tag, key of content, exclude key of content(key=value).", "Notice: Please press Enter after inputting a tag, key of content, exclude key of content(key=value).",
cacheModalTitle: "Clear cache reminder",
cacheReminderContent:
"SkyWalking detected dashboard template updates, do you want to update?",
language: "Language", language: "Language",
}; };
export default msg; export default msg;

View File

@ -36,13 +36,10 @@ const msg = {
technologies: "技术", technologies: "技术",
health: "健康", health: "健康",
groupName: "群名称", groupName: "群名称",
generalServicePanel: "普通服务面板",
topologies: "拓扑图", topologies: "拓扑图",
dataPanel: "数据", dataPanel: "数据面",
controlPanel: "控制", controlPanel: "控制面",
eventList: "事件列表", eventList: "事件列表",
databasePanel: "数据库面板",
meshServicePanel: "服务面板",
newDashboard: "新增仪表盘", newDashboard: "新增仪表盘",
dashboardEdit: "编辑仪表盘", dashboardEdit: "编辑仪表盘",
edit: "编辑", edit: "编辑",
@ -112,7 +109,7 @@ const msg = {
showGroup: "显示分组", showGroup: "显示分组",
noWidget: "请添加组件", noWidget: "请添加组件",
rename: "重命名", rename: "重命名",
selfObservability: "自观测性", selfObservability: "自监控",
satellite: "Satellite", satellite: "Satellite",
skyWalkingServer: "SkyWalking服务", skyWalkingServer: "SkyWalking服务",
functions: "Functions", functions: "Functions",
@ -145,57 +142,29 @@ const msg = {
title: "标题", title: "标题",
width: "宽度", width: "宽度",
height: "高度", height: "高度",
login: "登录",
signout: "登出",
topology: "拓扑图", topology: "拓扑图",
trace: "追踪", trace: "追踪",
alarm: "告警", alarm: "告警",
event: "事件", event: "事件",
auto: "自动", auto: "自动",
reload: "刷新", reload: "刷新",
usermode: "用户模式",
editmode: "编辑模式", editmode: "编辑模式",
currentVersion: "当前版本",
currentPage: "当前页面",
version: "版本", version: "版本",
page: "页面",
currentDatabase: "当前数据库",
templateConfig: "模版配置",
copy: "拷贝", copy: "拷贝",
reset: "重制", reset: "重制",
apply: "应用", apply: "应用",
createTemplate: "创建模板",
templateType: "模板类型",
templateName: "模板名称",
template: "模版",
confirm: "确定", confirm: "确定",
cancel: "取消", cancel: "取消",
createTab: "创建分页", createTab: "创建分页",
tabName: "分页名", tabName: "分页名",
nouse: "不使用",
allServices: "所有服务",
serviceDetail: "服务详情",
detectPoint: "侦察端", detectPoint: "侦察端",
callType: "调用类型",
server: "服务端",
client: "客户端",
name: "名称", name: "名称",
types: "类型", types: "类型",
cpm: "每分钟请求量",
sla: "SLA",
latency: "延迟",
avgResponseTime: "平均响应时间",
avgThroughput: "平均吞吐量",
avgSLA: "平均SLA",
all: "全部", all: "全部",
success: "成功",
error: "失败",
service: "服务", service: "服务",
instance: "实例", instance: "实例",
endpoints: "端点", endpoints: "端点",
cache: "存储器", cache: "存储器",
global: "全局",
serviceendpoint: "服务端点",
serviceinstance: "服务实例", serviceinstance: "服务实例",
databaseaccess: "数据库存取", databaseaccess: "数据库存取",
servicerelation: "服务关系", servicerelation: "服务关系",
@ -231,14 +200,8 @@ const msg = {
weekCutTip: "最近1周", weekCutTip: "最近1周",
monthCutTip: "最近1月", monthCutTip: "最近1月",
serverZone: "服务器时区", serverZone: "服务器时区",
percentResponse: "百分比响应",
exportImage: "导出为图片", exportImage: "导出为图片",
queryData: "数据查询",
previousService: "上一个服务",
nextService: "下一个服务",
object: "粒度", object: "粒度",
ShowInstanceDependency: "展示实例依赖",
InstanceDependencyTitle: "实例依赖",
profile: "性能剖析", profile: "性能剖析",
newTask: "新建任务", newTask: "新建任务",
monitorTime: "监控时间", monitorTime: "监控时间",
@ -258,27 +221,16 @@ const msg = {
excludeChildren: "不包含子部分", excludeChildren: "不包含子部分",
view: "查看", view: "查看",
timeTips: "时间区间不能超过60天", timeTips: "时间区间不能超过60天",
standardAPM: "标准APM",
entityType: "实体类型", entityType: "实体类型",
maxItemNum: "最多条目数", maxItemNum: "最多条目数",
independentSelector: "独立选择器",
unknownMetrics: "未知指标", unknownMetrics: "未知指标",
labels: "标签", labels: "标签",
aggregation: "计算", aggregation: "计算",
unit: "单位", unit: "单位",
labelsIndex: "标签下标", labelsIndex: "标签下标",
parentService: "父级服务",
isParentService: "设置父服务",
noneParentService: "不设置父服务",
group: "服务组", group: "服务组",
endpointFilter: "端点过滤器",
databaseView: "数据库视图",
browserView: "浏览器视图", browserView: "浏览器视图",
metricsView: "大屏视图",
sortOrder: "排序方式", sortOrder: "排序方式",
descendOrder: "递减顺序",
increaseOrder: "递增顺序",
defaultOrder: "默认顺序",
chartType: "图表类型", chartType: "图表类型",
currentDepth: "当前深度", currentDepth: "当前深度",
defaultDepth: "默认深度", defaultDepth: "默认深度",
@ -365,8 +317,6 @@ const msg = {
noticeTag: "请输入一个标签(key=value)之后回车", noticeTag: "请输入一个标签(key=value)之后回车",
conditionNotice: conditionNotice:
"请输入一个标签、内容关键词或者内容不包含的关键词(key=value)之后回车", "请输入一个标签、内容关键词或者内容不包含的关键词(key=value)之后回车",
cacheModalTitle: "清除缓存提醒",
cacheReminderContent: "SkyWalking检测到仪表板模板更新是否需要更新",
language: "语言", language: "语言",
}; };
export default msg; export default msg;

View File

@ -27,47 +27,34 @@ import { useDashboardStore } from "@/store/modules/dashboard";
import Dashboard from "./dashboard/Edit.vue"; import Dashboard from "./dashboard/Edit.vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { useAppStoreWithOut } from "@/store/modules/app"; import { useAppStoreWithOut } from "@/store/modules/app";
import { RoutesMap } from "@/constants/data";
const route = useRoute(); const route = useRoute();
const { t } = useI18n(); const { t } = useI18n();
const appStore = useAppStoreWithOut(); const appStore = useAppStoreWithOut();
const dashboardStore = useDashboardStore(); const dashboardStore = useDashboardStore();
const routesMap: { [key: string]: string } = {
GeneralServices: "GENERAL",
Database: "VIRTUAL_DATABASE",
MeshServices: "MESH",
ControlPanel: "MESH_CP",
DataPanel: "MESH_DP",
Linux: "OS_LINUX",
SkyWalkingServer: "SO11Y_OAP",
Satellite: "SO11Y_SATELLITE",
Functions: "FAAS",
Browser: "BROWSER",
KubernetesCluster: "K8S",
KubernetesService: "K8S_SERVICE",
};
const layer = ref<string>("GENERAL"); const layer = ref<string>("GENERAL");
getDashboard(); getDashboard();
async function getDashboard() { async function getDashboard() {
layer.value = routesMap[String(route.name)]; layer.value = RoutesMap[String(route.name)];
dashboardStore.setLayer(layer.value); dashboardStore.setLayer(layer.value);
dashboardStore.setEntity(EntityType[1].value);
dashboardStore.setMode(false); dashboardStore.setMode(false);
await dashboardStore.setDashboards(); await dashboardStore.setDashboards();
const index = dashboardStore.dashboards.findIndex( const item = dashboardStore.dashboards.find(
(d: { name: string; isRoot: boolean; layer: string; entity: string }) => (d: { name: string; isRoot: boolean; layer: string; entity: string }) =>
d.layer === dashboardStore.layerId && d.layer === dashboardStore.layerId &&
d.entity === EntityType[1].value && [EntityType[0].value, EntityType[1].value].includes(d.entity) &&
d.isRoot d.isRoot
); );
if (index < 0) { if (!item) {
appStore.setPageTitle(dashboardStore.layer); appStore.setPageTitle(dashboardStore.layer);
dashboardStore.setCurrentDashboard(null); dashboardStore.setCurrentDashboard(null);
dashboardStore.setEntity(EntityType[1].value);
return; return;
} }
const item = dashboardStore.dashboards[index]; dashboardStore.setEntity(item.entity);
dashboardStore.setCurrentDashboard(item); dashboardStore.setCurrentDashboard(item);
} }
</script> </script>

View File

@ -14,18 +14,15 @@ See the License for the specific language governing permissions and
limitations under the License. --> limitations under the License. -->
<template> <template>
<div class="settings"> <div class="settings">
<!-- <div class="flex-h item">
<span class="label">{{ t("version") }}</span>
<span>{{ rocketbotGlobal.version }}</span>
</div> -->
<div class="flex-h item"> <div class="flex-h item">
<span class="label">{{ t("language") }}</span> <span class="label">{{ t("language") }}</span>
<el-switch <Selector
v-model="lang" v-model="lang"
:options="Languages"
placeholder="Select a language"
@change="setLang" @change="setLang"
active-text="En" size="small"
inactive-text="Zh" style="font-size: 14px"
style="height: 25px"
/> />
</div> </div>
<div class="flex-h item"> <div class="flex-h item">
@ -76,12 +73,14 @@ import { ref, reactive } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { useAppStoreWithOut } from "@/store/modules/app"; import { useAppStoreWithOut } from "@/store/modules/app";
import timeFormat from "@/utils/timeFormat"; import timeFormat from "@/utils/timeFormat";
import { Languages } from "@/constants/data";
import Selector from "@/components/Selector.vue";
const { t, locale } = useI18n(); const { t, locale } = useI18n();
const state = reactive<{ timer: ReturnType<typeof setInterval> | null }>({ const state = reactive<{ timer: ReturnType<typeof setInterval> | null }>({
timer: null, timer: null,
}); });
const lang = ref<boolean>(locale.value === "zh" ? false : true); const lang = ref<string>(locale.value || "en");
const autoTime = ref<number>(6); const autoTime = ref<number>(6);
const auto = ref<boolean>(false); const auto = ref<boolean>(false);
const appStore = useAppStoreWithOut(); const appStore = useAppStoreWithOut();
@ -123,13 +122,8 @@ const changeAutoTime = () => {
} }
}; };
const setLang = (): void => { const setLang = (): void => {
if (lang.value) { locale.value = lang.value;
locale.value = "en"; window.localStorage.setItem("language", lang.value);
window.localStorage.setItem("lang", "en");
} else {
locale.value = "zh";
window.localStorage.setItem("lang", "zh");
}
}; };
const setUTCHour = () => { const setUTCHour = () => {
if (utcHour.value < -12) { if (utcHour.value < -12) {
@ -184,7 +178,6 @@ const setUTCMin = () => {
.settings { .settings {
color: #222; color: #222;
font-family: inherit;
font-size: 14px; font-size: 14px;
padding: 20px; padding: 20px;

View File

@ -86,7 +86,11 @@ limitations under the License. -->
<el-popconfirm <el-popconfirm
title="Are you sure to set this?" title="Are you sure to set this?"
@confirm="setRoot(scope.row)" @confirm="setRoot(scope.row)"
v-if="scope.row.entity === EntityType[1].value" v-if="
[EntityType[0].value, EntityType[1].value].includes(
scope.row.entity
)
"
> >
<template #reference> <template #reference>
<el-button size="small" style="width: 120px" type="danger"> <el-button size="small" style="width: 120px" type="danger">
@ -269,7 +273,7 @@ async function setRoot(row: DashboardItem) {
} else { } else {
if ( if (
d.layer === row.layer && d.layer === row.layer &&
d.entity === row.entity && [EntityType[0].value, EntityType[1].value].includes(d.entity) &&
row.isRoot === false && row.isRoot === false &&
d.isRoot === true d.isRoot === true
) { ) {