Merge pull request !263 from WeiFeng-mindinsight/myMastertags/v0.5.0-beta
| @@ -65,7 +65,9 @@ | |||||
| </div> | </div> | ||||
| <el-table v-show="!statisticType && opTypeCol && opTypeCol.length" | <el-table v-show="!statisticType && opTypeCol && opTypeCol.length" | ||||
| :data="opTypeList" | :data="opTypeList" | ||||
| ref="expandTable" | |||||
| @expand-change="expandTypeItem" | @expand-change="expandTypeItem" | ||||
| @sort-change="opTypeSortChange" | |||||
| stripe | stripe | ||||
| height="calc(100% - 75px)" | height="calc(100% - 75px)" | ||||
| width="100%"> | width="100%"> | ||||
| @@ -74,6 +76,7 @@ | |||||
| <div class="expand-table"> | <div class="expand-table"> | ||||
| <el-table :data="props.row.opDetailList" | <el-table :data="props.row.opDetailList" | ||||
| stripe | stripe | ||||
| ref="expandChild" | |||||
| width="100%" | width="100%" | ||||
| tooltip-effect="light" | tooltip-effect="light" | ||||
| @cell-click="showInfoDetail" | @cell-click="showInfoDetail" | ||||
| @@ -294,6 +297,11 @@ export default { | |||||
| }, // operator type filter | }, // operator type filter | ||||
| initOver: false, | initOver: false, | ||||
| objectType: 'object', | objectType: 'object', | ||||
| curActiveRow: { | |||||
| rowItem: null, | |||||
| childProp: null, | |||||
| childOrder: null, | |||||
| }, | |||||
| }; | }; | ||||
| }, | }, | ||||
| watch: { | watch: { | ||||
| @@ -313,12 +321,11 @@ 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'); | |||||
| this.$bus.$off('collapse'); | |||||
| }, | }, | ||||
| methods: { | methods: { | ||||
| init() { | init() { | ||||
| this.getCoreTypeList(); | this.getCoreTypeList(); | ||||
| this.$bus.$on('resize', this.resizeEchart); | |||||
| }, | }, | ||||
| resizeEchart() { | resizeEchart() { | ||||
| if (this.coreCharts.chartDom) { | if (this.coreCharts.chartDom) { | ||||
| @@ -340,6 +347,14 @@ export default { | |||||
| this.getCpuList(true); | this.getCpuList(true); | ||||
| } | } | ||||
| }, | }, | ||||
| opTypeSortChange() { | |||||
| this.$nextTick(() => { | |||||
| const item = this.$refs['expandChild']; | |||||
| if (item && this.curActiveRow.rowItem) { | |||||
| item.sort(this.curActiveRow.childProp, this.curActiveRow.childOrder); | |||||
| } | |||||
| }); | |||||
| }, | |||||
| /** | /** | ||||
| * clear cpu data | * clear cpu data | ||||
| */ | */ | ||||
| @@ -426,6 +441,15 @@ export default { | |||||
| }); | }); | ||||
| this.opTypeList.push(object); | this.opTypeList.push(object); | ||||
| }); | }); | ||||
| this.$nextTick(() => { | |||||
| const elementItem = this.$refs['expandTable']; | |||||
| if (elementItem) { | |||||
| elementItem.sort( | |||||
| this.op_sort_condition.name, | |||||
| this.op_sort_condition.type, | |||||
| ); | |||||
| } | |||||
| }); | |||||
| if ( | if ( | ||||
| !this.coreCharts.device_id || | !this.coreCharts.device_id || | ||||
| this.coreCharts.device_id !== this.currentCard | this.coreCharts.device_id !== this.currentCard | ||||
| @@ -486,6 +510,20 @@ export default { | |||||
| .then((res) => { | .then((res) => { | ||||
| if (res && res.data) { | if (res && res.data) { | ||||
| this.formatterDetailData(row, res.data); | this.formatterDetailData(row, res.data); | ||||
| this.$nextTick(() => { | |||||
| const item = this.$refs['expandChild']; | |||||
| if (item) { | |||||
| this.curActiveRow = { | |||||
| rowItem: row, | |||||
| childProp: row.op_sort_condition.name, | |||||
| childOrder: row.op_sort_condition.type, | |||||
| }; | |||||
| item.sort( | |||||
| row.op_sort_condition.name, | |||||
| row.op_sort_condition.type, | |||||
| ); | |||||
| } | |||||
| }); | |||||
| } | } | ||||
| }) | }) | ||||
| .catch(() => {}); | .catch(() => {}); | ||||
| @@ -580,6 +618,13 @@ export default { | |||||
| } else { | } else { | ||||
| this.op_filter_condition = {}; | this.op_filter_condition = {}; | ||||
| } | } | ||||
| if (this.curActiveRow.rowItem) { | |||||
| this.curActiveRow = { | |||||
| rowItem: null, | |||||
| childProp: null, | |||||
| childOrder: null, | |||||
| }; | |||||
| } | |||||
| this.getCoreTypeList(); | this.getCoreTypeList(); | ||||
| } | } | ||||
| }, | }, | ||||
| @@ -653,12 +698,30 @@ export default { | |||||
| expandTypeItem(row) { | expandTypeItem(row) { | ||||
| row.isExpanded = !row.isExpanded; | row.isExpanded = !row.isExpanded; | ||||
| if (row.isExpanded) { | if (row.isExpanded) { | ||||
| if (this.curActiveRow.rowItem) { | |||||
| this.curActiveRow.rowItem.isExpanded = false; | |||||
| const item = this.$refs['expandTable']; | |||||
| if (item) { | |||||
| item.toggleRowExpansion(this.curActiveRow.rowItem, false); | |||||
| } | |||||
| } | |||||
| this.curActiveRow = { | |||||
| rowItem: row, | |||||
| childProp: null, | |||||
| childOrder: null, | |||||
| }; | |||||
| row.opDetailList = []; | row.opDetailList = []; | ||||
| row.opDetailCol = []; | row.opDetailCol = []; | ||||
| row.opDetailPage.offset = 0; | row.opDetailPage.offset = 0; | ||||
| row.pageTotal = 0; | row.pageTotal = 0; | ||||
| row.op_sort_condition = {name: 'execution_time', type: 'descending'}; | row.op_sort_condition = {name: 'execution_time', type: 'descending'}; | ||||
| this.getCoreDetailList(row); | this.getCoreDetailList(row); | ||||
| } else { | |||||
| this.curActiveRow = { | |||||
| rowItem: null, | |||||
| childProp: null, | |||||
| childOrder: null, | |||||
| }; | |||||
| } | } | ||||
| }, | }, | ||||
| /** | /** | ||||
| @@ -949,11 +1012,16 @@ export default { | |||||
| }, | }, | ||||
| mounted() { | mounted() { | ||||
| if (this.train_id) { | if (this.train_id) { | ||||
| document.title = `${decodeURIComponent(this.train_id)}-${this.$t('profiling.operatorDetail')}-MindInsight`; | |||||
| document.title = `${decodeURIComponent(this.train_id)}-${this.$t( | |||||
| 'profiling.operatorDetail', | |||||
| )}-MindInsight`; | |||||
| } else { | } else { | ||||
| document.title = `${this.$t('profiling.operatorDetail')}-MindInsight`; | document.title = `${this.$t('profiling.operatorDetail')}-MindInsight`; | ||||
| } | } | ||||
| window.addEventListener('resize', this.resizeCallback, false); | window.addEventListener('resize', this.resizeCallback, false); | ||||
| setTimeout(() => { | |||||
| this.$bus.$on('collapse', this.resizeEchart); | |||||
| }, 500); | |||||
| }, | }, | ||||
| }; | }; | ||||
| </script> | </script> | ||||
| @@ -195,10 +195,18 @@ export default { | |||||
| }, | }, | ||||
| }; | }; | ||||
| }, | }, | ||||
| mounted() {}, | |||||
| mounted() { | |||||
| setTimeout(() => { | |||||
| this.$bus.$on('collapse', this.resizeTrace); | |||||
| }, 500); | |||||
| }, | |||||
| watch: { | watch: { | ||||
| '$parent.curDashboardInfo': { | '$parent.curDashboardInfo': { | ||||
| handler(newValue, oldValue) { | handler(newValue, oldValue) { | ||||
| if (newValue.curCardNum === '') { | |||||
| this.pieChart.noData = true; | |||||
| this.svg.noData = true; | |||||
| } | |||||
| if (newValue.query.dir && newValue.query.id && newValue.query.path) { | if (newValue.query.dir && newValue.query.id && newValue.query.path) { | ||||
| this.summaryPath = newValue.query.dir; | this.summaryPath = newValue.query.dir; | ||||
| this.trainingJobId = newValue.query.id; | this.trainingJobId = newValue.query.id; | ||||
| @@ -226,7 +234,6 @@ export default { | |||||
| this.queryTrainingTrace(); | this.queryTrainingTrace(); | ||||
| this.initPieChart(); | this.initPieChart(); | ||||
| window.addEventListener('resize', this.resizeTrace, false); | window.addEventListener('resize', this.resizeTrace, false); | ||||
| this.$bus.$on('resize', this.resizeTrace); | |||||
| }, | }, | ||||
| viewDetail(path) { | viewDetail(path) { | ||||
| this.$router.push({ | this.$router.push({ | ||||
| @@ -393,10 +400,13 @@ export default { | |||||
| svg.insertBefore(dashedLine, svg.querySelector('g')); | svg.insertBefore(dashedLine, svg.querySelector('g')); | ||||
| row.forEach((i) => { | row.forEach((i) => { | ||||
| if (i.duration) { | if (i.duration) { | ||||
| const tempDom = i.name | |||||
| ? this.createRect(i, index) | |||||
| : this.createArrow(i, index); | |||||
| svg.insertBefore(tempDom, svg.querySelector('g')); | |||||
| if (i.name) { | |||||
| const tempDom = this.createRect(i, index); | |||||
| svg.insertBefore(tempDom, svg.querySelector('g')); | |||||
| } else { | |||||
| const tempDom = this.createArrow(i, index); | |||||
| svg.appendChild(tempDom); | |||||
| } | |||||
| } | } | ||||
| }); | }); | ||||
| } | } | ||||
| @@ -488,7 +498,13 @@ export default { | |||||
| const text = document.createElementNS(this.svg.namespaceURI, 'text'); | const text = document.createElementNS(this.svg.namespaceURI, 'text'); | ||||
| text.textContent = `${data.duration.toFixed(4)}ms`; | text.textContent = `${data.duration.toFixed(4)}ms`; | ||||
| const textWidth = this.getTextWidth(text.textContent); | const textWidth = this.getTextWidth(text.textContent); | ||||
| text.setAttribute('x', Math.max(0, (x2 - x1) / 2 + x1 - textWidth / 2)); | |||||
| text.setAttribute( | |||||
| 'x', | |||||
| Math.min( | |||||
| this.svg.svgPadding * 2 + this.svg.totalWidth - textWidth, | |||||
| Math.max(0, (x2 - x1) / 2 + x1 - textWidth / 2), | |||||
| ), | |||||
| ); | |||||
| text.setAttribute('y', y - 6); | text.setAttribute('y', y - 6); | ||||
| text.setAttribute('font-size', 12); | text.setAttribute('font-size', 12); | ||||
| text.setAttribute('fill', '#6c7280'); | text.setAttribute('fill', '#6c7280'); | ||||
| @@ -555,7 +571,7 @@ export default { | |||||
| }, | }, | ||||
| destroyed() { | destroyed() { | ||||
| window.removeEventListener('resize', this.resizeTrace, false); | window.removeEventListener('resize', this.resizeTrace, false); | ||||
| this.$bus.$off('resize'); | |||||
| this.$bus.$off('collapse'); | |||||
| }, | }, | ||||
| }; | }; | ||||
| </script> | </script> | ||||
| @@ -36,7 +36,8 @@ limitations under the License. | |||||
| {{$t("profiling.smartHelper")}} | {{$t("profiling.smartHelper")}} | ||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| <div class="collapse-btn" :class="{collapse:collapse}" | |||||
| <div class="collapse-btn" | |||||
| :class="{collapse:collapse}" | |||||
| @click="collapseLeft()"> | @click="collapseLeft()"> | ||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| @@ -121,9 +122,12 @@ export default { | |||||
| }, | }, | ||||
| collapseLeft() { | collapseLeft() { | ||||
| this.collapse = !this.collapse; | this.collapse = !this.collapse; | ||||
| this.$bus.$emit('resize'); | |||||
| this.$bus.$emit('collapse'); | |||||
| }, | }, | ||||
| }, | }, | ||||
| destroyed() { | |||||
| this.$bus.$off('collapse'); | |||||
| }, | |||||
| }; | }; | ||||
| </script> | </script> | ||||
| <style lang="scss"> | <style lang="scss"> | ||||
| @@ -84,8 +84,9 @@ limitations under the License. | |||||
| class="chart-wrap"> | class="chart-wrap"> | ||||
| <div class="title">{{ item.name }}</div> | <div class="title">{{ item.name }}</div> | ||||
| <div class="rate-wrap"> | <div class="rate-wrap"> | ||||
| <div v-if="item.timeSummary.total_time !== undefined"> | |||||
| <span>{{item.timeLabel}}:</span>{{item.timeSummary.total_time}}ms</div> | |||||
| <div v-if="item.timeSummary.total_time !== undefined && item.timeSummary[item.rate] !== undefined"> | |||||
| <span>{{item.timeLabel}}:</span> | |||||
| {{(item.timeSummary.total_time*parseFloat(item.timeSummary[item.rate])/100).toFixed(4)}}ms</div> | |||||
| <div v-if="item.timeSummary[item.rate] !== undefined"> | <div v-if="item.timeSummary[item.rate] !== undefined"> | ||||
| <span>{{item.rateLabel}}:</span>{{item.timeSummary[item.rate]}}</div> | <span>{{item.rateLabel}}:</span>{{item.timeSummary[item.rate]}}</div> | ||||
| <div v-if="item.timeSummary.total_steps !== undefined"> | <div v-if="item.timeSummary.total_steps !== undefined"> | ||||
| @@ -205,13 +206,18 @@ export default { | |||||
| }, | }, | ||||
| }, | }, | ||||
| computed: {}, | computed: {}, | ||||
| mounted() {}, | |||||
| mounted() { | |||||
| setTimeout(() => { | |||||
| this.$bus.$on('collapse', () => { | |||||
| this.resizeTrace(); | |||||
| this.resizeEchart(); | |||||
| }); | |||||
| }, 500); | |||||
| }, | |||||
| methods: { | methods: { | ||||
| init() { | init() { | ||||
| window.addEventListener('resize', this.resizeTrace, false); | window.addEventListener('resize', this.resizeTrace, false); | ||||
| this.$bus.$on('resize', this.resizeTrace); | |||||
| window.addEventListener('resize', this.resizeEchart, false); | window.addEventListener('resize', this.resizeEchart, false); | ||||
| this.$bus.$on('resize', this.resizeEchart); | |||||
| if (this.charts.length) { | if (this.charts.length) { | ||||
| this.charts.forEach((val) => { | this.charts.forEach((val) => { | ||||
| val.clear(); | val.clear(); | ||||
| @@ -395,10 +401,13 @@ export default { | |||||
| svg.insertBefore(dashedLine, svg.querySelector('g')); | svg.insertBefore(dashedLine, svg.querySelector('g')); | ||||
| row.forEach((i) => { | row.forEach((i) => { | ||||
| if (i.duration) { | if (i.duration) { | ||||
| const tempDom = i.name | |||||
| ? this.createRect(i, index) | |||||
| : this.createArrow(i, index); | |||||
| svg.insertBefore(tempDom, svg.querySelector('g')); | |||||
| if (i.name) { | |||||
| const tempDom = this.createRect(i, index); | |||||
| svg.insertBefore(tempDom, svg.querySelector('g')); | |||||
| } else { | |||||
| const tempDom = this.createArrow(i, index); | |||||
| svg.appendChild(tempDom); | |||||
| } | |||||
| } | } | ||||
| }); | }); | ||||
| } | } | ||||
| @@ -489,7 +498,13 @@ export default { | |||||
| const text = document.createElementNS(this.svg.namespaceURI, 'text'); | const text = document.createElementNS(this.svg.namespaceURI, 'text'); | ||||
| text.textContent = `${data.duration.toFixed(4)}ms`; | text.textContent = `${data.duration.toFixed(4)}ms`; | ||||
| const textWidth = this.getTextWidth(text.textContent); | const textWidth = this.getTextWidth(text.textContent); | ||||
| text.setAttribute('x', Math.max(0, (x2 - x1) / 2 + x1 - textWidth / 2)); | |||||
| text.setAttribute( | |||||
| 'x', | |||||
| Math.min( | |||||
| this.svg.svgPadding * 2 + this.svg.totalWidth - textWidth, | |||||
| Math.max(0, (x2 - x1) / 2 + x1 - textWidth / 2), | |||||
| ), | |||||
| ); | |||||
| text.setAttribute('y', y - 6); | text.setAttribute('y', y - 6); | ||||
| text.setAttribute('font-size', 12); | text.setAttribute('font-size', 12); | ||||
| text.setAttribute('fill', '#6c7280'); | text.setAttribute('fill', '#6c7280'); | ||||
| @@ -559,7 +574,7 @@ export default { | |||||
| destroyed() { | destroyed() { | ||||
| window.removeEventListener('resize', this.resizeTrace, false); | window.removeEventListener('resize', this.resizeTrace, false); | ||||
| window.removeEventListener('resize', this.resizeEchart, false); | window.removeEventListener('resize', this.resizeEchart, false); | ||||
| this.$bus.$off('resize'); | |||||
| this.$bus.$off('collapse'); | |||||
| }, | }, | ||||
| }; | }; | ||||
| </script> | </script> | ||||