未验证 提交 202e2dfb 编写于 作者: Q Qiuxia Fan 提交者: GitHub

Bugfix: Dashboard templates (#307)

上级 dd721b15
...@@ -32,9 +32,9 @@ const m = { ...@@ -32,9 +32,9 @@ const m = {
copy: 'Copy', copy: 'Copy',
reset: 'Reset', reset: 'Reset',
apply: 'Apply', apply: 'Apply',
createGroup: 'Create Group', createTemplate: 'Create Template',
groupType: 'Group Type', templateType: 'Template Type',
groupName: 'Group Name', templateName: 'Template Name',
template: 'Template', template: 'Template',
confirm: 'Confirm', confirm: 'Confirm',
cancel: 'Cancel', cancel: 'Cancel',
...@@ -128,7 +128,7 @@ const m = { ...@@ -128,7 +128,7 @@ const m = {
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 APM', standardAPM: 'Standard',
entityType: 'Entity type', entityType: 'Entity type',
independentSelector: 'Selectors', independentSelector: 'Selectors',
unknownMetrics: 'Unknown Metrics', unknownMetrics: 'Unknown Metrics',
...@@ -142,6 +142,11 @@ const m = { ...@@ -142,6 +142,11 @@ const m = {
serviceFilter: 'Service Filter', serviceFilter: 'Service Filter',
endpointFilter: 'Endpoint Filter', endpointFilter: 'Endpoint Filter',
editConfig: 'Edit Config', editConfig: 'Edit Config',
databaseView: 'Database',
metricsView: 'NOC - Network Operation Center',
sortOrder: 'Sort Order',
descendOrder: 'Descend Order',
increaseOrder: 'Increase Order',
}; };
export default m; export default m;
...@@ -32,9 +32,9 @@ const m = { ...@@ -32,9 +32,9 @@ const m = {
copy: '拷贝', copy: '拷贝',
reset: '重制', reset: '重制',
apply: '应用', apply: '应用',
createGroup: '创建分组', createTemplate: '创建模板',
groupType: '分组类型', templateType: '模板类型',
groupName: '分组名', templateName: '模板名称',
template: '模版', template: '模版',
confirm: '确定', confirm: '确定',
cancel: '取消', cancel: '取消',
...@@ -142,6 +142,11 @@ const m = { ...@@ -142,6 +142,11 @@ const m = {
serviceFilter: '服务过滤器', serviceFilter: '服务过滤器',
endpointFilter: '端点过滤器', endpointFilter: '端点过滤器',
editConfig: '编辑', editConfig: '编辑',
databaseView: '数据库视图',
metricsView: '大屏视图',
sortOrder: '排序方式',
descendOrder: '递减顺序',
increaseOrder: '递增顺序',
}; };
export default m; export default m;
...@@ -66,7 +66,7 @@ const actions: ActionTree<State, any> = { ...@@ -66,7 +66,7 @@ const actions: ActionTree<State, any> = {
normal: true, normal: true,
scope: config.entityType, scope: config.entityType,
topN: 10, topN: 10,
order: 'DES', order: config.sortOrder || 'DES',
}, },
} }
: { : {
...@@ -90,7 +90,7 @@ const actions: ActionTree<State, any> = { ...@@ -90,7 +90,7 @@ const actions: ActionTree<State, any> = {
normal, normal,
scope: normal ? config.entityType : config.parentService ? 'Service' : config.entityType, scope: normal ? config.entityType : config.parentService ? 'Service' : config.entityType,
topN: 10, topN: 10,
order: 'DES', order: config.sortOrder || 'DES',
}, },
} }
: { : {
......
...@@ -156,7 +156,7 @@ limitations under the License. --> ...@@ -156,7 +156,7 @@ limitations under the License. -->
<option v-for="type in IndependentType" :value="type.key" :key="type.key">{{ type.label }}</option> <option v-for="type in IndependentType" :value="type.key" :key="type.key">{{ type.label }}</option>
</select> </select>
</div> </div>
<div class="flex-h mb-5" v-show="isParentService.includes(itemConfig.queryMetricType)"> <div class="flex-h mb-5" v-show="nameMetrics.includes(itemConfig.queryMetricType)">
<div class="title grey sm">{{ $t('parentService') }}:</div> <div class="title grey sm">{{ $t('parentService') }}:</div>
<select <select
class="long" class="long"
...@@ -167,6 +167,17 @@ limitations under the License. --> ...@@ -167,6 +167,17 @@ limitations under the License. -->
<option :value="false">{{ $t('noneParentService') }}</option> <option :value="false">{{ $t('noneParentService') }}</option>
</select> </select>
</div> </div>
<div class="flex-h mb-5" v-show="nameMetrics.includes(itemConfig.queryMetricType)">
<div class="title grey sm">{{ $t('sortOrder') }}:</div>
<select
class="long"
v-model="itemConfig.sortOrder"
@change="setItemConfig({ type: 'sortOrder', value: $event.target.value })"
>
<option :value="'DES'">{{ $t('descendOrder') }}</option>
<option :value="'ASC'">{{ $t('increaseOrder') }}</option>
</select>
</div>
<div class="flex-h mb-5"> <div class="flex-h mb-5">
<div class="title grey sm">{{ $t('unit') }}:</div> <div class="title grey sm">{{ $t('unit') }}:</div>
<input <input
...@@ -255,7 +266,7 @@ limitations under the License. --> ...@@ -255,7 +266,7 @@ limitations under the License. -->
private queryMetricTypesList: any = []; private queryMetricTypesList: any = [];
private isDatabase = false; private isDatabase = false;
private isLabel = false; private isLabel = false;
private isParentService = ['sortMetrics', 'readSampledRecords']; private nameMetrics = ['sortMetrics', 'readSampledRecords'];
private created() { private created() {
this.itemConfig = this.item; this.itemConfig = this.item;
......
...@@ -83,9 +83,11 @@ ...@@ -83,9 +83,11 @@
} }
} }
private exportData() { private exportData() {
const data = this.rocketComps.tree; const group = this.rocketComps.tree[this.rocketComps.group];
delete group.query;
const name = 'dashboard.json'; const name = 'dashboard.json';
saveFile(data, name);
saveFile([group], name);
} }
} }
</script> </script>
......
...@@ -37,14 +37,14 @@ limitations under the License. --> ...@@ -37,14 +37,14 @@ limitations under the License. -->
<use xlink:href="#todo-add"></use> <use xlink:href="#todo-add"></use>
</svg> </svg>
<div class="rk-dashboard-group-add-box" v-if="show"> <div class="rk-dashboard-group-add-box" v-if="show">
<div class="mb-10 vm">{{ $t('createGroup') }}</div> <div class="mb-10 vm">{{ $t('createTemplate') }}</div>
<div class="sm grey mb-5 mr-10">{{ $t('groupType') }}</div> <div class="sm grey mb-5 mr-10">{{ $t('templateType') }}</div>
<select v-model="type" class="rk-dashboard-group-sel"> <select v-model="type" class="rk-dashboard-group-sel">
<option :value="DASHBOARDTYPE.SERVICE">{{ $t('standardAPM') }}</option> <option :value="DASHBOARDTYPE.SERVICE">{{ $t('standardAPM') }}</option>
<option :value="DASHBOARDTYPE.METRIC">{{ $t('metrics') }}</option> <option :value="DASHBOARDTYPE.METRIC">{{ $t('metricsView') }}</option>
<option :value="DASHBOARDTYPE.DATABASE">{{ $t('database') }}</option> <option :value="DASHBOARDTYPE.DATABASE">{{ $t('databaseView') }}</option>
</select> </select>
<div class="sm grey mb-5 mr-10">{{ $t('groupName') }}</div> <div class="sm grey mb-5 mr-10">{{ $t('templateName') }}</div>
<input class="mb-5 rk-dashboard-group-input" type="text" v-model="name" /> <input class="mb-5 rk-dashboard-group-input" type="text" v-model="name" />
<div v-show="type === 'database'"> <div v-show="type === 'database'">
<label class="mb-10 dib"><input type="checkbox" v-model="template" />{{ $t('template') }}</label> <label class="mb-10 dib"><input type="checkbox" v-model="template" />{{ $t('template') }}</label>
......
...@@ -49,6 +49,13 @@ limitations under the License. --> ...@@ -49,6 +49,13 @@ limitations under the License. -->
import ToolNav from '@/views/components/dashboard/tool-nav.vue'; import ToolNav from '@/views/components/dashboard/tool-nav.vue';
import DashboardItem from '@/views/components/dashboard/dashboard-item.vue'; import DashboardItem from '@/views/components/dashboard/dashboard-item.vue';
interface ITemplate {
name: string;
type: string;
configuration: string;
activated: boolean;
disabled: boolean;
}
@Component({ @Component({
components: { components: {
ToolBar, ToolBar,
...@@ -100,28 +107,31 @@ limitations under the License. --> ...@@ -100,28 +107,31 @@ limitations under the License. -->
// }).then((data: any) => { // }).then((data: any) => {
// console.log(data); // console.log(data);
// }); // });
this.GET_ALL_TEMPLATES().then( this.GET_ALL_TEMPLATES().then((allTemplate: ITemplate[]) => {
( this.SET_ALL_TEMPLATES(allTemplate);
allTemplate: Array<{ if (window.localStorage.getItem('version') !== '8.0') {
name: string; window.localStorage.removeItem('dashboard');
type: string; this.setDashboardTemplates(allTemplate);
configuration: string; this.handleOption();
activated: boolean; return;
disabled: boolean; }
}>, if (window.localStorage.getItem('dashboard')) {
) => { const data: string = `${window.localStorage.getItem('dashboard')}`;
this.SET_ALL_TEMPLATES(allTemplate); this.SET_COMPS_TREE(JSON.parse(data));
if (window.localStorage.getItem('dashboard')) { } else {
const data: string = `${window.localStorage.getItem('dashboard')}`; this.setDashboardTemplates(allTemplate);
this.SET_COMPS_TREE(JSON.parse(data)); }
} else { });
const template = allTemplate.filter((item: any) => item.type === 'DASHBOARD' && item.activated)[0] || {};
this.SET_COMPS_TREE(JSON.parse(template.configuration) || []);
}
},
);
this.handleOption(); this.handleOption();
} }
private setDashboardTemplates(allTemplate: ITemplate[]) {
const template = allTemplate.filter((item: ITemplate) => item.type === 'DASHBOARD' && item.activated);
const templatesConfiguration = template.map((item: ITemplate) => JSON.parse(item.configuration)).flat(1);
this.SET_COMPS_TREE(templatesConfiguration || []);
window.localStorage.setItem('version', '8.0');
window.localStorage.setItem('dashboard', JSON.stringify(templatesConfiguration));
}
private beforeDestroy() { private beforeDestroy() {
this.SET_EDIT(false); this.SET_EDIT(false);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册