提交 88fa954f 编写于 作者: X xiayifan

scalar threshold feature v2

上级 4975cb72
...@@ -313,10 +313,19 @@ export default { ...@@ -313,10 +313,19 @@ export default {
destroyed() { destroyed() {
// Remove the listener of window size change // Remove the listener of window size change
window.removeEventListener('resize', this.resizeCallback); window.removeEventListener('resize', this.resizeCallback);
this.$bus.$off('resize');
}, },
methods: { methods: {
init() { init() {
this.getCoreTypeList(); this.getCoreTypeList();
this.$bus.$on('resize', this.resizeEchart);
},
resizeEchart() {
if (this.coreCharts.chartDom) {
setTimeout(() => {
this.coreCharts.chartDom.resize();
}, 200);
}
}, },
/** /**
* Current device change * Current device change
......
...@@ -91,7 +91,7 @@ limitations under the License. ...@@ -91,7 +91,7 @@ limitations under the License.
</div> </div>
<div class="chartThreshold"> <div class="chartThreshold">
<div class="chartThresholdLeft">{{$t("scalar.currentThreshold")}}:{{sampleItem.pieceStr}}</div> <div class="chartThresholdLeft">{{$t("scalar.currentThreshold")}}{{sampleItem.pieceStr || "-"}}</div>
<div class="chartThresholdRight"> <div class="chartThresholdRight">
<span @click="setThreshold(sampleItem)" <span @click="setThreshold(sampleItem)"
v-if="!thresholdLocal v-if="!thresholdLocal
...@@ -388,25 +388,60 @@ export default { ...@@ -388,25 +388,60 @@ export default {
this.decodeTrainingJobId = decodeURIComponent(this.trainingJobId); this.decodeTrainingJobId = decodeURIComponent(this.trainingJobId);
this.getCache();
// auto refresh
if (this.isTimeReload) {
this.autoUpdateSamples();
}
},
methods: {
/**
* get localStorge
*/
getCache() {
if (localStorage.getItem('thresholdCache')) { if (localStorage.getItem('thresholdCache')) {
try { try {
this.thresholdLocal = JSON.parse( this.thresholdLocal = JSON.parse(
localStorage.getItem('thresholdCache'), localStorage.getItem('thresholdCache'),
); );
this.clearCache();
} catch (e) { } catch (e) {
localStorage.removeItem('thresholdCache'); localStorage.removeItem('thresholdCache');
this.thresholdLocal = {};
} }
} else {
this.thresholdLocal = {};
} }
},
// auto refresh /**
if (this.isTimeReload) { * clear localStorge
this.autoUpdateSamples(); */
clearCache() {
if (
this.thresholdLocal &&
this.thresholdLocal[this.decodeTrainingJobId]
) {
if (
Object.keys(this.thresholdLocal[this.decodeTrainingJobId]).length ===
0
) {
delete this.thresholdLocal[this.decodeTrainingJobId];
localStorage.setItem(
'thresholdCache',
JSON.stringify(this.thresholdLocal),
);
}
} }
}, },
methods: {
/** /**
* Obtain the tag and run list. * Obtain the tag and run list.
*/ */
getScalarsList() { getScalarsList() {
const params = { const params = {
plugin_name: 'scalar', plugin_name: 'scalar',
...@@ -679,7 +714,7 @@ export default { ...@@ -679,7 +714,7 @@ export default {
} else { } else {
returnFlag = true; returnFlag = true;
} }
this.getCache();
if ( if (
this.thresholdLocal && this.thresholdLocal &&
this.thresholdLocal[this.decodeTrainingJobId] && this.thresholdLocal[this.decodeTrainingJobId] &&
...@@ -692,7 +727,6 @@ export default { ...@@ -692,7 +727,6 @@ export default {
); );
let pieceStr = ''; let pieceStr = '';
if (tempStorgeArr.length === 1) { if (tempStorgeArr.length === 1) {
if (tempStorgeArr[0].gt && tempStorgeArr[0].lt) { if (tempStorgeArr[0].gt && tempStorgeArr[0].lt) {
pieceStr = `(${tempStorgeArr[0].gt},${tempStorgeArr[0].lt})`; pieceStr = `(${tempStorgeArr[0].gt},${tempStorgeArr[0].lt})`;
...@@ -745,6 +779,9 @@ export default { ...@@ -745,6 +779,9 @@ export default {
silent: true, silent: true,
data: markLineData, data: markLineData,
}; };
} else {
sampleObject.pieceStr = '';
dataObj.markLine = null;
} }
seriesData.push(dataObj, dataObjBackend); seriesData.push(dataObj, dataObjBackend);
...@@ -1152,6 +1189,9 @@ export default { ...@@ -1152,6 +1189,9 @@ export default {
*/ */
timeTypeChange(val) { timeTypeChange(val) {
if (this.isTimeReload) {
this.autoUpdateSamples();
}
if (this.axisBenchChangeTimer) { if (this.axisBenchChangeTimer) {
clearTimeout(this.axisBenchChangeTimer); clearTimeout(this.axisBenchChangeTimer);
this.axisBenchChangeTimer = null; this.axisBenchChangeTimer = null;
...@@ -1235,6 +1275,9 @@ export default { ...@@ -1235,6 +1275,9 @@ export default {
if (!selectedItemDict) { if (!selectedItemDict) {
return; return;
} }
if (this.isTimeReload) {
this.autoUpdateSamples();
}
this.multiSelectedTagNames = selectedItemDict; this.multiSelectedTagNames = selectedItemDict;
// Reset to the first page // Reset to the first page
this.pageIndex = 0; this.pageIndex = 0;
...@@ -1247,6 +1290,9 @@ export default { ...@@ -1247,6 +1290,9 @@ export default {
resizeCallback() { resizeCallback() {
if (!this.compare) { if (!this.compare) {
if (this.isTimeReload) {
this.autoUpdateSamples();
}
if (this.charResizeTimer) { if (this.charResizeTimer) {
clearTimeout(this.charResizeTimer); clearTimeout(this.charResizeTimer);
this.charResizeTimer = null; this.charResizeTimer = null;
...@@ -1539,6 +1585,10 @@ export default { ...@@ -1539,6 +1585,10 @@ export default {
return; return;
} }
if (this.isTimeReload) {
this.autoUpdateSamples();
}
// Update the smoothness of initialized data // Update the smoothness of initialized data
this.curPageArr.forEach((sampleObject) => { this.curPageArr.forEach((sampleObject) => {
if (sampleObject.charObj) { if (sampleObject.charObj) {
...@@ -1717,11 +1767,26 @@ export default { ...@@ -1717,11 +1767,26 @@ export default {
*/ */
setThreshold(sampleItem) { setThreshold(sampleItem) {
this.getCache();
if (
this.thresholdLocal &&
this.thresholdLocal[this.decodeTrainingJobId] &&
this.thresholdLocal[this.decodeTrainingJobId][sampleItem.tagName]
) {
delete this.thresholdLocal[this.decodeTrainingJobId][
sampleItem.tagName
];
}
this.currentTagName = sampleItem.tagName; this.currentTagName = sampleItem.tagName;
this.currentSample = sampleItem; this.currentSample = sampleItem;
this.thresholdDialogVisible = true; this.thresholdDialogVisible = true;
}, },
/**
* delete threshold
* @param {Object} sampleItem sampleItem
*/
delThreshold(sampleItem) { delThreshold(sampleItem) {
this.$confirm(this.$t('scalar.isDelete'), this.$t('scalar.info'), { this.$confirm(this.$t('scalar.isDelete'), this.$t('scalar.info'), {
confirmButtonText: this.$t('public.sure'), confirmButtonText: this.$t('public.sure'),
...@@ -1729,10 +1794,21 @@ export default { ...@@ -1729,10 +1794,21 @@ export default {
type: 'warning', type: 'warning',
}) })
.then(() => { .then(() => {
this.getCache();
if (
this.thresholdLocal &&
this.thresholdLocal[this.decodeTrainingJobId] &&
this.thresholdLocal[this.decodeTrainingJobId][sampleItem.tagName]
) {
delete this.thresholdLocal[this.decodeTrainingJobId][ delete this.thresholdLocal[this.decodeTrainingJobId][
sampleItem.tagName sampleItem.tagName
]; ];
this.clearCache();
localStorage.setItem(
'thresholdCache',
JSON.stringify(this.thresholdLocal),
);
}
sampleItem.pieceStr = ''; sampleItem.pieceStr = '';
const tempCharOption = sampleItem.charData.charOption; const tempCharOption = sampleItem.charData.charOption;
tempCharOption.visualMap.pieces = []; tempCharOption.visualMap.pieces = [];
...@@ -1742,17 +1818,17 @@ export default { ...@@ -1742,17 +1818,17 @@ export default {
this.autoUpdateSamples(); this.autoUpdateSamples();
} }
sampleItem.charObj.setOption(tempCharOption, true); sampleItem.charObj.setOption(tempCharOption, true);
localStorage.setItem(
'thresholdCache',
JSON.stringify(this.thresholdLocal),
);
this.$forceUpdate(); this.$forceUpdate();
}) })
.catch(() => {}); .catch(() => {});
}, },
/**
* threshold validate
*/
thresholdValidate() { thresholdValidate() {
const isValidate = true; let isValidate = true;
const valueFirst = this.thresholdValue[0].value; const valueFirst = this.thresholdValue[0].value;
const valueSec = this.thresholdValue[1].value; const valueSec = this.thresholdValue[1].value;
...@@ -1762,73 +1838,54 @@ export default { ...@@ -1762,73 +1838,54 @@ export default {
if (!this.thresholdRelational) { if (!this.thresholdRelational) {
if (!valueFirst) { if (!valueFirst) {
this.thresholdErrorMsg = this.$t('scalar.placeHolderThreshold'); this.thresholdErrorMsg = this.$t('scalar.placeHolderThreshold');
this.isValidate = false; isValidate = false;
return; } else if (isNaN(valueFirst)) {
}
if (isNaN(valueFirst)) {
this.thresholdErrorMsg = this.$t('scalar.placeHolderNumber'); this.thresholdErrorMsg = this.$t('scalar.placeHolderNumber');
this.isValidate = false; isValidate = false;
return;
} }
} else { } else {
if (filterConditionFirst === filterConditionSec) { if (filterConditionFirst === filterConditionSec) {
this.thresholdErrorMsg = this.$t('scalar.sameCompare'); this.thresholdErrorMsg = this.$t('scalar.sameCompare');
this.isValidate = false; isValidate = false;
return; } else if (!valueFirst || !valueSec) {
}
if (!valueFirst || !valueSec) {
this.thresholdErrorMsg = this.$t('scalar.placeHolderThreshold'); this.thresholdErrorMsg = this.$t('scalar.placeHolderThreshold');
this.isValidate = false; isValidate = false;
return; } else if (valueFirst === valueSec) {
}
if (valueFirst === valueSec) {
this.thresholdErrorMsg = this.$t('scalar.unreasonable'); this.thresholdErrorMsg = this.$t('scalar.unreasonable');
this.isValidate = false; isValidate = false;
return; } else if (isNaN(valueFirst) || isNaN(valueSec)) {
}
if (isNaN(valueFirst) || isNaN(valueSec)) {
this.thresholdErrorMsg = this.$t('scalar.placeHolderNumber'); this.thresholdErrorMsg = this.$t('scalar.placeHolderNumber');
this.isValidate = false; isValidate = false;
return; } else {
}
if (this.thresholdRelational === this.$t('scalar.or')) { if (this.thresholdRelational === this.$t('scalar.or')) {
if ( if (
filterConditionFirst === this.$t('scalar.greaterThan') && filterConditionFirst === this.$t('scalar.greaterThan') &&
Number(valueFirst) < Number(valueSec) Number(valueFirst) < Number(valueSec)
) { ) {
this.thresholdErrorMsg = this.$t('scalar.unreasonable'); this.thresholdErrorMsg = this.$t('scalar.unreasonable');
this.isValidate = false; isValidate = false;
return; } else if (
}
if (
filterConditionFirst === this.$t('scalar.lessThan') && filterConditionFirst === this.$t('scalar.lessThan') &&
Number(valueFirst) > Number(valueSec) Number(valueFirst) > Number(valueSec)
) { ) {
this.thresholdErrorMsg = this.$t('scalar.unreasonable'); this.thresholdErrorMsg = this.$t('scalar.unreasonable');
this.isValidate = false; isValidate = false;
return;
} }
} }
if (this.thresholdRelational === this.$t('scalar.and')) { if (this.thresholdRelational === this.$t('scalar.and')) {
if ( if (
filterConditionFirst === this.$t('scalar.greaterThan') && filterConditionFirst === this.$t('scalar.greaterThan') &&
Number(valueFirst) > Number(valueSec) Number(valueFirst) > Number(valueSec)
) { ) {
this.thresholdErrorMsg = this.$t('scalar.unreasonable'); this.thresholdErrorMsg = this.$t('scalar.unreasonable');
this.isValidate = false; isValidate = false;
return; } else if (
}
if (
filterConditionFirst === this.$t('scalar.lessThan') && filterConditionFirst === this.$t('scalar.lessThan') &&
Number(valueFirst) < Number(valueSec) Number(valueFirst) < Number(valueSec)
) { ) {
this.thresholdErrorMsg = this.$t('scalar.unreasonable'); this.thresholdErrorMsg = this.$t('scalar.unreasonable');
this.isValidate = false; isValidate = false;
return; }
} }
} }
} }
...@@ -1862,7 +1919,7 @@ export default { ...@@ -1862,7 +1919,7 @@ export default {
tempArr.push(item.value); tempArr.push(item.value);
}); });
if (tempArr[0] > tempArr[1]) { if (Number(tempArr[0]) > Number(tempArr[1])) {
chartPiecesData.gt = Number(tempArr[1]); chartPiecesData.gt = Number(tempArr[1]);
chartPiecesData.lt = Number(tempArr[0]); chartPiecesData.lt = Number(tempArr[0]);
chartPieces.push(chartPiecesData); chartPieces.push(chartPiecesData);
...@@ -1877,12 +1934,10 @@ export default { ...@@ -1877,12 +1934,10 @@ export default {
const chartPiecesData = {}; const chartPiecesData = {};
if (!item.value) { if (!item.value) {
return; return;
} } else if (item.filterCondition === this.$t('scalar.greaterThan')) {
if (item.filterCondition === this.$t('scalar.greaterThan')) {
chartPiecesData.gt = Number(item.value); chartPiecesData.gt = Number(item.value);
chartPieces.push(chartPiecesData); chartPieces.push(chartPiecesData);
} } else if (item.filterCondition === this.$t('scalar.lessThan')) {
if (item.filterCondition === this.$t('scalar.lessThan')) {
chartPiecesData.lt = Number(item.value); chartPiecesData.lt = Number(item.value);
chartPieces.push(chartPiecesData); chartPieces.push(chartPiecesData);
} }
...@@ -1919,20 +1974,16 @@ export default { ...@@ -1919,20 +1974,16 @@ export default {
if (chartPieces.length === 1) { if (chartPieces.length === 1) {
if (chartPieces[0].gt && chartPieces[0].lt) { if (chartPieces[0].gt && chartPieces[0].lt) {
pieceStr = `(${chartPieces[0].gt},${chartPieces[0].lt})`; pieceStr = `(${chartPieces[0].gt},${chartPieces[0].lt})`;
} } else if (chartPieces[0].gt && !chartPieces[0].lt) {
if (chartPieces[0].gt && !chartPieces[0].lt) {
pieceStr = `(${chartPieces[0].gt},Infinity)`; pieceStr = `(${chartPieces[0].gt},Infinity)`;
} } else if (chartPieces[0].lt && !chartPieces[0].gt) {
if (chartPieces[0].lt && !chartPieces[0].gt) {
pieceStr = `(-Infinity,${chartPieces[0].lt})`; pieceStr = `(-Infinity,${chartPieces[0].lt})`;
} }
} }
if (chartPieces.length === 2) { if (chartPieces.length === 2) {
if (chartPieces[0].lt && chartPieces[1].gt) { if (chartPieces[0].lt && chartPieces[1].gt) {
pieceStr = `(-Infinity,${chartPieces[0].lt}),(${chartPieces[1].gt},Infinity)`; pieceStr = `(-Infinity,${chartPieces[0].lt}),(${chartPieces[1].gt},Infinity)`;
} } else if (chartPieces[0].gt && chartPieces[1].lt) {
if (chartPieces[0].gt && chartPieces[1].lt) {
pieceStr = `(-Infinity,${chartPieces[1].lt}),(${chartPieces[0].gt},Infinity)`; pieceStr = `(-Infinity,${chartPieces[1].lt}),(${chartPieces[0].gt},Infinity)`;
} }
} }
...@@ -2012,20 +2063,16 @@ export default { ...@@ -2012,20 +2063,16 @@ export default {
if (chartPieces.length === 1) { if (chartPieces.length === 1) {
if (chartPieces[0].gt && chartPieces[0].lt) { if (chartPieces[0].gt && chartPieces[0].lt) {
pieceStr = `(${chartPieces[0].gt},${chartPieces[0].lt})`; pieceStr = `(${chartPieces[0].gt},${chartPieces[0].lt})`;
} } else if (chartPieces[0].gt && !chartPieces[0].lt) {
if (chartPieces[0].gt && !chartPieces[0].lt) {
pieceStr = `(${chartPieces[0].gt},Infinity)`; pieceStr = `(${chartPieces[0].gt},Infinity)`;
} } else if (chartPieces[0].lt && !chartPieces[0].gt) {
if (chartPieces[0].lt && !chartPieces[0].gt) {
pieceStr = `(-Infinity,${chartPieces[0].lt})`; pieceStr = `(-Infinity,${chartPieces[0].lt})`;
} }
} }
if (chartPieces.length === 2) { if (chartPieces.length === 2) {
if (chartPieces[0].lt && chartPieces[1].gt) { if (chartPieces[0].lt && chartPieces[1].gt) {
pieceStr = `(-Infinity,${chartPieces[0].lt}),(${chartPieces[1].gt},Infinity)`; pieceStr = `(-Infinity,${chartPieces[0].lt}),(${chartPieces[1].gt},Infinity)`;
} } else if (chartPieces[0].gt && chartPieces[1].lt) {
if (chartPieces[0].gt && chartPieces[1].lt) {
pieceStr = `(-Infinity,${chartPieces[1].lt}),(${chartPieces[0].gt},Infinity)`; pieceStr = `(-Infinity,${chartPieces[1].lt}),(${chartPieces[0].gt},Infinity)`;
} }
} }
...@@ -2081,6 +2128,7 @@ export default { ...@@ -2081,6 +2128,7 @@ export default {
relationalChange(val) { relationalChange(val) {
if (!val) { if (!val) {
this.thresholdValue[1].value = ''; this.thresholdValue[1].value = '';
this.thresholdErrorMsg = '';
} }
}, },
...@@ -2353,7 +2401,7 @@ export default { ...@@ -2353,7 +2401,7 @@ export default {
flex: 1; flex: 1;
text-align: left; text-align: left;
padding-left: 5px; padding-left: 5px;
font-size: 12px; font-size: 14px;
color: #6c7280; color: #6c7280;
} }
...@@ -2362,8 +2410,14 @@ export default { ...@@ -2362,8 +2410,14 @@ export default {
text-align: right; text-align: right;
padding-right: 10px; padding-right: 10px;
font-size: 12px; font-size: 12px;
cursor: pointer;
color: #00a5a7; color: #00a5a7;
span {
width: 80px;
height: 39px;
display: inline-block;
cursor: pointer;
}
} }
} }
.tag-name { .tag-name {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册