Skip to content
This repository was archived by the owner on Jun 1, 2022. It is now read-only.

Commit 9927681

Browse files
authored
fix: avoid some abnormal settings (#561)
1 parent 7c82b29 commit 9927681

File tree

4 files changed

+40
-21
lines changed

4 files changed

+40
-21
lines changed

src/graph/fragments/dashboard.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,6 @@ export const getAllTemplates = {
3232
`,
3333
};
3434

35-
export const addTemplate = {
36-
variable: '$setting: DashboardSetting!',
37-
query: `
38-
addTemplate(setting: $setting) {
39-
status
40-
message
41-
}
42-
`,
43-
};
44-
4535
export const fetchEvents = {
4636
variable: ['$condition: EventQueryCondition'],
4737
query: `

src/graph/query/dashboard.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import {
1919
TypeOfMetrics,
2020
getAllTemplates,
21-
addTemplate,
2221
changeTemplate,
2322
disableTemplate,
2423
querySampledRecords,
@@ -32,8 +31,6 @@ import {
3231

3332
export const queryTypeOfMetrics = `query queryTypeOfMetrics(${TypeOfMetrics.variable}) {${TypeOfMetrics.query}}`;
3433

35-
export const mutationAddTemplate = `mutation mutationAddTemplate(${addTemplate.variable}) {${addTemplate.query}}`;
36-
3734
export const mutationChangeTemplate = `mutation mutationChangeTemplate(${changeTemplate.variable}) {
3835
${changeTemplate.query}}`;
3936

src/views/components/dashboard/charts/chart-edit.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ limitations under the License. -->
285285
<input
286286
type="text"
287287
class="rk-chart-edit-input long"
288-
:value="itemConfig.tips"
289-
@change="setItemConfig({ type: 'tips', value: $event.target.value })"
288+
:value="decodeURIComponent(itemConfig.tipsContent)"
289+
@change="setItemConfig({ type: 'tipsContent', value: encodeURIComponent($event.target.value) })"
290290
/>
291291
</div>
292292
</div>
@@ -381,6 +381,10 @@ limitations under the License. -->
381381
if (this.isChartSlow && !this.itemConfig.maxItemNum) {
382382
this.itemConfig.maxItemNum = MaxItemNum;
383383
}
384+
if (!this.itemConfig.tipsContent && this.itemConfig.tips) {
385+
this.itemConfig.tipsContent = encodeURIComponent(this.itemConfig.tips);
386+
this.setItemConfig({ type: 'tipsContent', value: this.itemConfig.tipsContent });
387+
}
384388
this.hasChartType();
385389
}
386390
@@ -409,14 +413,17 @@ limitations under the License. -->
409413
private setItemConfig(params: { type: string; value: string }) {
410414
this.itemConfig[params.type] = params.value;
411415
const types = ['endpointsKey', 'instancesKey', 'currentService'];
412-
const typesUpdate = ['title', 'width', 'height', 'unit', 'tips'];
416+
const typesUpdate = ['title', 'width', 'height', 'unit', 'tipsContent'];
413417
if (params.type === 'servicesKey') {
414418
this.setItemServices(true);
415419
}
416420
if (types.includes(params.type)) {
417421
this.getServiceObject(true);
418422
}
419423
if (typesUpdate.includes(params.type)) {
424+
if (params.type === 'tipsContent') {
425+
this.EDIT_COMP_CONFIG({ index: this.index, values: { tips: decodeURIComponent(params.value) } });
426+
}
420427
this.$emit('updateStatus', params.type, params.value);
421428
}
422429
if (params.type === 'entityType') {

src/views/components/dashboard/dashboard-item.vue

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License. -->
1515
<template>
1616
<div class="rk-dashboard-item" :class="`g-sm-${width}`" :style="`height:${height}px;`" v-if="itemConfig.entityType">
17-
<div class="rk-dashboard-item-title ell">
17+
<div class="rk-dashboard-item-title">
1818
<span v-show="rocketGlobal.edit || stateTopo.editDependencyMetrics" @click="deleteItem(index, itemConfig.uuid)">
1919
<rk-icon class="r edit red" icon="file-deletion" />
2020
</span>
@@ -33,7 +33,10 @@ limitations under the License. -->
3333
>
3434
<rk-icon class="r cp" icon="review-list" />
3535
</span>
36-
<rk-icon v-if="tips" class="r edit" icon="info_outline" v-tooltip:bottom="{ content: tips }" />
36+
<span v-if="tips" class="r edit tipsContent" @mouseenter="showTips = true" @mouseleave="showTips = false">
37+
<rk-icon icon="info_outline" />
38+
<div v-show="showTips">{{ decodeURIComponent(tips) }}</div>
39+
</span>
3740
</div>
3841
<div class="rk-dashboard-item-body" ref="chartBody">
3942
<div style="height:100%;width:100%">
@@ -133,11 +136,12 @@ limitations under the License. -->
133136
TopologyType.TOPOLOGY_SERVICE_INSTANCE_DEPENDENCY,
134137
TopologyType.TOPOLOGY_ENDPOINT_DEPENDENCY,
135138
] as string[];
139+
private showTips: boolean = false;
136140
137141
private created() {
138142
this.status = this.item.metricType;
139143
this.title = this.item.title;
140-
this.tips = this.item.tips;
144+
this.tips = this.item.tips ? encodeURIComponent(this.item.tips) : '';
141145
this.width = this.item.width;
142146
this.height = this.item.height;
143147
this.unit = this.item.unit;
@@ -342,7 +346,7 @@ limitations under the License. -->
342346
if (type === 'unit') {
343347
this.unit = value;
344348
}
345-
if (type === 'tips') {
349+
if (type === 'tipsContent') {
346350
this.tips = value;
347351
}
348352
}
@@ -474,7 +478,7 @@ limitations under the License. -->
474478
}
475479
}
476480
</script>
477-
<style lang="scss">
481+
<style lang="scss" scope>
478482
.rk-dashboard-item {
479483
display: flex;
480484
height: 100%;
@@ -502,6 +506,8 @@ limitations under the License. -->
502506
background-color: rgba(196, 200, 225, 0.2);
503507
color: #9da5b2;
504508
padding: 6px 10px;
509+
text-overflow: ellipsis;
510+
white-space: nowrap;
505511
}
506512
.rk-dashboard-item-title .hint {
507513
color: #fbb03b;
@@ -541,4 +547,23 @@ limitations under the License. -->
541547
.config-box {
542548
padding: 40px 30px;
543549
}
550+
.tipsContent {
551+
position: relative;
552+
> div {
553+
display: inline-block;
554+
position: absolute;
555+
top: 16px;
556+
left: 10px;
557+
background: #252a2f;
558+
box-shadow: 1px 5px 1px #333;
559+
color: #efefef;
560+
border-radius: 3px;
561+
z-index: 9999;
562+
padding: 10px;
563+
word-wrap: break-word;
564+
word-break: break-all;
565+
height: auto;
566+
max-width: 300px;
567+
}
568+
}
544569
</style>

0 commit comments

Comments
 (0)