提交 d7734be6 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!230 code optimization and code formatting ,add querysummaryList method add request header variable

Merge pull request !230 from 王卫宁/master
...@@ -42,13 +42,15 @@ export default { ...@@ -42,13 +42,15 @@ export default {
}); });
}, },
// query summary list // query summary list
querySummaryList(params) { querySummaryList(params, isIgnoreError) {
return axios({ return axios({
method: 'get', method: 'get',
url: '/v1/mindinsight/datavisual/train-jobs', url: '/v1/mindinsight/datavisual/train-jobs',
params: params, params: params,
headers: {
ignoreError: isIgnoreError,
},
}); });
}, },
...@@ -103,18 +105,6 @@ export default { ...@@ -103,18 +105,6 @@ export default {
}); });
}, },
// query trainJob data
getTrainJobs(params, isIgnoreError) {
return axios({
method: 'get',
params: params,
url: 'v1/mindinsight/datavisual/train-jobs',
headers: {
ignoreError: isIgnoreError,
},
});
},
// set caches // set caches
trainJobsCaches(params) { trainJobsCaches(params) {
return axios({ return axios({
......
...@@ -27,23 +27,21 @@ limitations under the License. ...@@ -27,23 +27,21 @@ limitations under the License.
<!--summary select--> <!--summary select-->
<div class="cl-eval-operate-component"> <div class="cl-eval-operate-component">
<multiSelectGroupComponents ref="summaryGroup" <multiSelectGroupComponents ref="summaryGroup"
:checkListArr="summaryOperateList" :checkListArr="summaryOperateList"
:isLimit="true" :isLimit="true"
:limitNum="5" :limitNum="5"
@selectedChange="summarySelectedChanged" @selectedChange="summarySelectedChanged"
:componentsLabel="componentsLabel.summary" :componentsLabel="componentsLabel.summary"></multiSelectGroupComponents>
></multiSelectGroupComponents>
</div> </div>
<!--tag select--> <!--tag select-->
<div class="cl-eval-operate-component"> <div class="cl-eval-operate-component">
<multiSelectGroupComponents ref="tagsGroup" <multiSelectGroupComponents ref="tagsGroup"
:checkListArr="tagOperateList" :checkListArr="tagOperateList"
@selectedChange="tagSelectedChanged" @selectedChange="tagSelectedChanged"
:componentsLabel="componentsLabel.tag" :componentsLabel="componentsLabel.tag"></multiSelectGroupComponents>
></multiSelectGroupComponents> </div>
</div>
</div> </div>
<!-- Slider --> <!-- Slider -->
...@@ -62,13 +60,12 @@ limitations under the License. ...@@ -62,13 +60,12 @@ limitations under the License.
<el-slider v-model="smoothValue" <el-slider v-model="smoothValue"
:step="0.01" :step="0.01"
:max="0.99" :max="0.99"
@input="updataInputValue" @input="updataInputValue"></el-slider>
></el-slider>
<el-input v-model="smoothValueNumber" <el-input v-model="smoothValueNumber"
class="w60" class="w60"
@input="smoothValueChange" @input="smoothValueChange"
@blur="smoothValueBlur"></el-input> @blur="smoothValueBlur"></el-input>
</div> </div>
<!-- Content display --> <!-- Content display -->
<div class="cl-eval-show-data-content" <div class="cl-eval-show-data-content"
...@@ -284,11 +281,11 @@ export default { ...@@ -284,11 +281,11 @@ export default {
* Obtain the tag and summary list. * Obtain the tag and summary list.
*/ */
getScalarsList() { getScalarsList() {
const params={}; const params = {};
params.offset = 0; params.offset = 0;
params.limit = 999; params.limit = 999;
RequestService.getTrainJobs(params) RequestService.querySummaryList(params)
.then((res) => { .then((res) => {
// error; // error;
if ( if (
...@@ -318,10 +315,10 @@ export default { ...@@ -318,10 +315,10 @@ export default {
colorIndex: colorIndex, colorIndex: colorIndex,
}); });
if (summaryObj.cache_status===this.cacheStatus) { if (summaryObj.cache_status === this.cacheStatus) {
tempSummaryList.forEach((item)=>{ tempSummaryList.forEach((item) => {
if (item.label=== summaryObj.train_id) { if (item.label === summaryObj.train_id) {
item.loading=true; item.loading = true;
} }
}); });
} }
...@@ -339,7 +336,7 @@ export default { ...@@ -339,7 +336,7 @@ export default {
if (!this.oriDataDictionaries[tagObj]) { if (!this.oriDataDictionaries[tagObj]) {
// Add the tag list // Add the tag list
this.oriDataDictionaries[tagObj]=true; this.oriDataDictionaries[tagObj] = true;
tempTagList.push({ tempTagList.push({
label: tagObj, label: tagObj,
checked: true, checked: true,
...@@ -386,11 +383,13 @@ export default { ...@@ -386,11 +383,13 @@ export default {
this.initOver = true; this.initOver = true;
this.$nextTick(() => { this.$nextTick(() => {
this.multiSelectedTagNames=this.$refs.tagsGroup.updateSelectedDic(); this.multiSelectedTagNames = this.$refs.tagsGroup.updateSelectedDic();
this.multiSelectedSummaryNames=this.$refs.summaryGroup.updateSelectedDic(); this.multiSelectedSummaryNames = this.$refs.summaryGroup.updateSelectedDic();
this.updateTagInPage(); this.updateTagInPage();
this.resizeCallback(); this.resizeCallback();
this.trainJobsCaches(); if (Object.keys(this.multiSelectedSummaryNames).length > 0) {
this.trainJobsCaches();
}
}); });
}, this.requestErrorCallback) }, this.requestErrorCallback)
.catch((e) => { .catch((e) => {
...@@ -399,8 +398,8 @@ export default { ...@@ -399,8 +398,8 @@ export default {
}, },
trainJobsCaches() { trainJobsCaches() {
const params={}; const params = {};
params.train_ids=Object.keys(this.multiSelectedSummaryNames); params.train_ids = Object.keys(this.multiSelectedSummaryNames);
RequestService.trainJobsCaches(params); RequestService.trainJobsCaches(params);
}, },
...@@ -437,12 +436,12 @@ export default { ...@@ -437,12 +436,12 @@ export default {
*/ */
updateCurPageSamples() { updateCurPageSamples() {
this.curPageArr.forEach((sampleObject)=>{ this.curPageArr.forEach((sampleObject) => {
if (!sampleObject) { if (!sampleObject) {
return; return;
} }
sampleObject.updateFlag = true; sampleObject.updateFlag = true;
const sampleIndex=sampleObject.sampleIndex; const sampleIndex = sampleObject.sampleIndex;
const summaryCount = sampleObject.summaryNames.length; const summaryCount = sampleObject.summaryNames.length;
if (summaryCount === 0) { if (summaryCount === 0) {
return; return;
...@@ -453,15 +452,14 @@ export default { ...@@ -453,15 +452,14 @@ export default {
tag: sampleObject.tagName, tag: sampleObject.tagName,
}; };
for (let i=0; i<summaryCount; i++) { for (let i = 0; i < summaryCount; i++) {
if (i===summaryCount-1) { if (i === summaryCount - 1) {
params.train_id += sampleObject.summaryNames[i]; params.train_id += sampleObject.summaryNames[i];
} else { } else {
params.train_id += sampleObject.summaryNames[i]+'&'; params.train_id += sampleObject.summaryNames[i] + '&';
} }
} }
RequestService.getSummarySample(params) RequestService.getSummarySample(params)
.then((res) => { .then((res) => {
if (sampleObject.charObj) { if (sampleObject.charObj) {
...@@ -537,12 +535,10 @@ export default { ...@@ -537,12 +535,10 @@ export default {
this.updateOrCreateChar(sampleIndex); this.updateOrCreateChar(sampleIndex);
}); });
}) })
.catch((error) => { .catch((error) => {});
});
}); });
}, },
/** /**
* Formatting Chart Data * Formatting Chart Data
* @param {Number} sampleIndex Chart subscript * @param {Number} sampleIndex Chart subscript
...@@ -717,7 +713,7 @@ export default { ...@@ -717,7 +713,7 @@ export default {
}, },
grid: { grid: {
left: 80, left: 80,
right: sampleObject.fullScreen ? 80:10, right: sampleObject.fullScreen ? 80 : 10,
}, },
animation: true, animation: true,
dataZoom: [ dataZoom: [
...@@ -962,11 +958,11 @@ export default { ...@@ -962,11 +958,11 @@ export default {
if (sampleObject.fullScreen) { if (sampleObject.fullScreen) {
sampleObject.charData.charOption.toolbox.feature.myToolFullScreen.iconStyle.borderColor = sampleObject.charData.charOption.toolbox.feature.myToolFullScreen.iconStyle.borderColor =
'#3E98C5'; '#3E98C5';
sampleObject.charData.charOption.grid.right=80; sampleObject.charData.charOption.grid.right = 80;
} else { } else {
sampleObject.charData.charOption.toolbox.feature.myToolFullScreen.iconStyle.borderColor = sampleObject.charData.charOption.toolbox.feature.myToolFullScreen.iconStyle.borderColor =
'#6D7278'; '#6D7278';
sampleObject.charData.charOption.grid.right=10; sampleObject.charData.charOption.grid.right = 10;
} }
sampleObject.updateFlag = true; sampleObject.updateFlag = true;
...@@ -985,13 +981,13 @@ export default { ...@@ -985,13 +981,13 @@ export default {
*/ */
updateTagInPage(noPageDataNumChange) { updateTagInPage(noPageDataNumChange) {
const curFilterSamples=[]; const curFilterSamples = [];
this.originDataArr.forEach((sampleItem)=>{ this.originDataArr.forEach((sampleItem) => {
if (this.multiSelectedTagNames[sampleItem.tagName]) { if (this.multiSelectedTagNames[sampleItem.tagName]) {
curFilterSamples.push(sampleItem); curFilterSamples.push(sampleItem);
} }
}); });
this.curFilterSamples=curFilterSamples; this.curFilterSamples = curFilterSamples;
this.getCurPageDataArr(noPageDataNumChange); this.getCurPageDataArr(noPageDataNumChange);
}, },
...@@ -1086,9 +1082,9 @@ export default { ...@@ -1086,9 +1082,9 @@ export default {
if (!selectedItemDict) { if (!selectedItemDict) {
return; return;
} }
this.multiSelectedTagNames=selectedItemDict; this.multiSelectedTagNames = selectedItemDict;
// reset to the first page // reset to the first page
this.pageIndex=0; this.pageIndex = 0;
this.updateTagInPage(); this.updateTagInPage();
}, },
...@@ -1101,11 +1097,13 @@ export default { ...@@ -1101,11 +1097,13 @@ export default {
if (!selectedItemDict) { if (!selectedItemDict) {
return; return;
} }
this.multiSelectedSummaryNames=selectedItemDict; this.multiSelectedSummaryNames = selectedItemDict;
if (this.isTimeReload) { if (this.isTimeReload) {
this.autoUpdateSamples(); this.autoUpdateSamples();
} }
this.trainJobsCaches(); if (Object.keys(this.multiSelectedSummaryNames).length > 0) {
this.trainJobsCaches();
}
this.updateSummary(); this.updateSummary();
}, },
...@@ -1114,33 +1112,30 @@ export default { ...@@ -1114,33 +1112,30 @@ export default {
*/ */
updateSummary() { updateSummary() {
// update the data display area // update the data display area
this.originDataArr.forEach((sampleObject)=>{ this.originDataArr.forEach((sampleObject) => {
if (sampleObject.charObj) { if (sampleObject.charObj) {
sampleObject.updateFlag=true; sampleObject.updateFlag = true;
sampleObject.summaryNames.forEach((summaryName)=>{ sampleObject.summaryNames.forEach((summaryName) => {
const sampleSelect =
sampleObject.charData.charOption.legend.selected;
if (!sampleSelect) {
return;
}
if (this.multiSelectedSummaryNames[summaryName]) { if (this.multiSelectedSummaryNames[summaryName]) {
sampleObject.charData.charOption.legend.selected[ sampleSelect[summaryName] = true;
summaryName sampleSelect[summaryName + this.backendString] = true;
]=true;
sampleObject.charData.charOption.legend.selected[
summaryName+this.backendString
]=true;
} else { } else {
sampleObject.charData.charOption.legend.selected[ sampleSelect[summaryName] = false;
summaryName sampleSelect[summaryName + this.backendString] = false;
]=false;
sampleObject.charData.charOption.legend.selected[
summaryName+this.backendString
]=false;
} }
}); });
} }
}); });
setTimeout(()=>{ setTimeout(() => {
// Refresh the current page chart // Refresh the current page chart
this.curPageArr.forEach((sampleObject)=>{ this.curPageArr.forEach((sampleObject) => {
sampleObject.charData.charOption.animation=false; sampleObject.charData.charOption.animation = false;
this.updateOrCreateChar(sampleObject.sampleIndex, true); this.updateOrCreateChar(sampleObject.sampleIndex, true);
}); });
}, 0); }, 0);
...@@ -1151,6 +1146,9 @@ export default { ...@@ -1151,6 +1146,9 @@ export default {
*/ */
resizeCallback() { resizeCallback() {
if (this.isTimeReload) {
this.autoUpdateSamples();
}
if (this.charResizeTimer) { if (this.charResizeTimer) {
clearTimeout(this.charResizeTimer); clearTimeout(this.charResizeTimer);
this.charResizeTimer = null; this.charResizeTimer = null;
...@@ -1165,7 +1163,6 @@ export default { ...@@ -1165,7 +1163,6 @@ export default {
}, 500); }, 500);
}, },
/** /**
* Initialize the color array * Initialize the color array
*/ */
...@@ -1192,7 +1189,7 @@ export default { ...@@ -1192,7 +1189,7 @@ export default {
this.tagOperateList = []; this.tagOperateList = [];
this.pageIndex = 0; this.pageIndex = 0;
this.originDataArr = []; this.originDataArr = [];
this.oriDataDictionaries={}; this.oriDataDictionaries = {};
this.curPageArr = []; this.curPageArr = [];
}, },
...@@ -1214,7 +1211,6 @@ export default { ...@@ -1214,7 +1211,6 @@ export default {
} }
}, },
/** /**
* Delete the data that does not exist * Delete the data that does not exist
* @param {Object} oriData Original summary and tag data * @param {Object} oriData Original summary and tag data
...@@ -1334,16 +1330,16 @@ export default { ...@@ -1334,16 +1330,16 @@ export default {
summaryColor = this.summaryOperateList[sameSummaryIndex].color; summaryColor = this.summaryOperateList[sameSummaryIndex].color;
} }
if (summaryObj.cache_status===this.cacheStatus) { if (summaryObj.cache_status === this.cacheStatus) {
this.summaryOperateList.forEach((item)=>{ this.summaryOperateList.forEach((item) => {
if (item.label=== summaryObj.train_id) { if (item.label === summaryObj.train_id) {
item.loading=true; item.loading = true;
} }
}); });
} else { } else {
this.summaryOperateList.forEach((item)=>{ this.summaryOperateList.forEach((item) => {
if (item.label=== summaryObj.train_id) { if (item.label === summaryObj.train_id) {
item.loading=false; item.loading = false;
} }
}); });
} }
...@@ -1399,17 +1395,16 @@ export default { ...@@ -1399,17 +1395,16 @@ export default {
return dataAddFlag; return dataAddFlag;
}, },
/** /**
* Updating all data * Updating all data
* @param {Boolean} ignoreError whether ignore error tip * @param {Boolean} ignoreError whether ignore error tip
*/ */
updateAllData(ignoreError) { updateAllData(ignoreError) {
const params={}; const params = {};
params.offset = 0; params.offset = 0;
params.limit = 999; params.limit = 999;
RequestService.getTrainJobs(params, ignoreError) RequestService.querySummaryList(params, ignoreError)
.then((res) => { .then((res) => {
if (this.isReloading) { if (this.isReloading) {
this.$store.commit('setIsReload', false); this.$store.commit('setIsReload', false);
...@@ -1417,10 +1412,12 @@ export default { ...@@ -1417,10 +1412,12 @@ export default {
} }
// Fault tolerance processing // Fault tolerance processing
if (!res || if (
!res ||
!res.data || !res.data ||
!res.data.train_jobs || !res.data.train_jobs ||
!res.data.train_jobs.length) { !res.data.train_jobs.length
) {
this.clearAllData(); this.clearAllData();
return; return;
} }
...@@ -1440,7 +1437,9 @@ export default { ...@@ -1440,7 +1437,9 @@ export default {
this.updateTagInPage(!tagRemoveFlag && !tagAddFlag); this.updateTagInPage(!tagRemoveFlag && !tagAddFlag);
this.resizeCallback(); this.resizeCallback();
this.trainJobsCaches(); if (Object.keys(this.multiSelectedSummaryNames).length > 0) {
this.trainJobsCaches();
}
}); });
}, this.requestErrorCallback) }, this.requestErrorCallback)
.catch((e) => { .catch((e) => {
...@@ -1483,7 +1482,7 @@ export default { ...@@ -1483,7 +1482,7 @@ export default {
if (this.firstNum === 0) { if (this.firstNum === 0) {
return; return;
} }
this.smoothValueNumber=Number(val); this.smoothValueNumber = Number(val);
if (this.smoothSliderValueTimer) { if (this.smoothSliderValueTimer) {
clearTimeout(this.smoothSliderValueTimer); clearTimeout(this.smoothSliderValueTimer);
this.smoothSliderValueTimer = null; this.smoothSliderValueTimer = null;
...@@ -1496,26 +1495,26 @@ export default { ...@@ -1496,26 +1495,26 @@ export default {
smoothValueChange(val) { smoothValueChange(val) {
if (!isNaN(val)) { if (!isNaN(val)) {
if (Number(val)===0) { if (Number(val) === 0) {
this.smoothValue=0; this.smoothValue = 0;
} }
if (Number(val)<0) { if (Number(val) < 0) {
this.smoothValue=0; this.smoothValue = 0;
this.smoothValueNumber=0; this.smoothValueNumber = 0;
} }
if (Number(val)>0) { if (Number(val) > 0) {
if (Number(val)>0.99) { if (Number(val) > 0.99) {
this.smoothValue=0.99; this.smoothValue = 0.99;
this.smoothValueNumber=0.99; this.smoothValueNumber = 0.99;
} else { } else {
this.smoothValue=Number(val); this.smoothValue = Number(val);
} }
} }
} }
}, },
smoothValueBlur() { smoothValueBlur() {
this.smoothValueNumber=this.smoothValue; this.smoothValueNumber = this.smoothValue;
}, },
/** /**
...@@ -1715,7 +1714,7 @@ export default { ...@@ -1715,7 +1714,7 @@ export default {
background: #ffffff; background: #ffffff;
.cl-eval-operate-component { .cl-eval-operate-component {
margin-top:8px; margin-top: 8px;
} }
} }
.cl-eval-slider-operate-content { .cl-eval-slider-operate-content {
......
...@@ -127,7 +127,7 @@ export default { ...@@ -127,7 +127,7 @@ export default {
* @param {Object} params page info param * @param {Object} params page info param
*/ */
querySummaryList(params) { querySummaryList(params) {
RequestService.querySummaryList(params) RequestService.querySummaryList(params, false)
.then( .then(
(res) => { (res) => {
if (res && res.data && res.data.train_jobs) { if (res && res.data && res.data.train_jobs) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册