-
Notifications
You must be signed in to change notification settings - Fork 626
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
565 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* get mock data | ||
* | ||
* @param {string} path request path | ||
* @param {Object} queryParam query params | ||
* @param {Object} postParam post params | ||
* @return {Object} | ||
*/ | ||
module.exports = function (path, queryParam, postParam) { | ||
return { | ||
// moock delay | ||
_timeout: 0, | ||
// mock http status | ||
_status: 200, | ||
// mock response data | ||
_data: { | ||
status: 0, | ||
msg: 'SUCCESS', | ||
data: { | ||
"test": { | ||
"layer3/generated/animal": { | ||
"displayName": "layer3/generated/animal", | ||
"description": "" | ||
} | ||
}, | ||
"train": { | ||
"layer3/generated/animal": { | ||
"displayName": "layer3/generated/animal", | ||
"description": "" | ||
}, | ||
"layer3/generated/flower": { | ||
"displayName": "layer3/generated/flower", | ||
"description": "" | ||
}, | ||
} | ||
} | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* get mock data | ||
* | ||
* @param {string} path request path | ||
* @param {Object} queryParam query params | ||
* @param {Object} postParam post params | ||
* @return {Object} | ||
*/ | ||
module.exports = function (path, queryParam, postParam) { | ||
if (queryParam.run === 'train') { | ||
return { | ||
// moock delay | ||
_timeout: 0, | ||
// mock http status | ||
_status: 200, | ||
// mock response data | ||
_data: { | ||
status: 0, | ||
msg: 'SUCCESS', | ||
data: [[1511842145.705075, 1, "Hello 1"], [1511842145.7388, 2, "Hello 2"], [1511842145.774563, 3, "Hello 3"], [1511842145.806828, 4, "Hello 4"], [1511842145.838082, 5, "Hello 5"], [1511842145.868955, 6, "Hello 6"], [1511842145.899323, 7, "Hello 7"], [1511842145.930518, 8, "Hello 8"], [1511842145.96089, 9, "Hello 7"], [1511842146.460557, 11, "Hello 11"], [1511842146.4952, 12, "Hello 12"], [1511842146.525936, 13, "Hello 13"], [1511842146.556059, 14, "Hello 14"], [1511842146.648703, 15, "Hello 15"], [1511842146.683295, 16, "Hello 16"], [1511842146.719782, 17, "Hello 17"], [1511842146.752392, 18, "Hello 18"]] | ||
} | ||
} | ||
} | ||
else { | ||
return { | ||
// moock delay | ||
_timeout: 0, | ||
// mock http status | ||
_status: 200, | ||
// mock response data | ||
_data: { | ||
status: 0, | ||
msg: 'SUCCESS', | ||
data: [[1511842145.514333, 0, "Hello 0"], [1511842146.427384, 10, "Hello 10"], [1511842147.260405, 20, "Hello 20"], [1511842148.019018, 30, "Hello 30 "], [1511842148.793569, 40, "Hello 40 "], [1511842149.610228, 50, "Hello 50 "], [1511842150.437095, 60, "Hello 60"], [1511842151.254679, 70, "Hello 70"], [1511842152.039353, 80, "Hello 80"], [1511842152.800043, 90, "Hello 90"]] | ||
} | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
<template> | ||
<div class="visual-dl-page-container"> | ||
<div class="visual-dl-page-left"> | ||
<ui-chart-page | ||
:expand="true" | ||
:config="filteredConfig" | ||
:runsItems="runsItems" | ||
:tagList="filteredTagsList" | ||
:title="'Tags matching ' + config.groupNameReg" | ||
></ui-chart-page> | ||
<ui-chart-page | ||
v-for="item in groupedTags" | ||
:key="item.group" | ||
:config="filteredConfig" | ||
:runsItems="runsItems" | ||
:tagList="item.tags" | ||
:title="item.group" | ||
></ui-chart-page> | ||
</div> | ||
<div class="visual-dl-page-right"> | ||
<div class="visual-dl-page-config-container"> | ||
<ui-config :runsItems="runsItems" :config="config" | ||
></ui-config> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import {getPluginTextsTags, getRuns} from '../service'; | ||
import {debounce, flatten, uniq, isArray} from 'lodash'; | ||
import autoAdjustHeight from '../common/util/autoAdjustHeight'; | ||
import Config from './ui/Config' | ||
import ChartPage from './ui/ChartPage'; | ||
export default { | ||
name: 'Texts', | ||
components: { | ||
'ui-config': Config, | ||
'ui-chart-page': ChartPage | ||
}, | ||
data () { | ||
return { | ||
runsArray: [], | ||
tags: [], | ||
config: { | ||
groupNameReg: '.*', | ||
runs: [], | ||
running: true | ||
}, | ||
filteredTagsList: [] | ||
} | ||
}, | ||
computed: { | ||
runsItems() { | ||
let runsArray = this.runsArray || []; | ||
return runsArray.map(item => { | ||
return { | ||
name: item, | ||
value: item | ||
}; | ||
}); | ||
}, | ||
tagsList() { | ||
let tags = this.tags; | ||
let runs = Object.keys(tags); | ||
let tagsArray = runs.map(run => Object.keys(tags[run])); | ||
let allUniqTags = uniq(flatten(tagsArray)); | ||
// get the data for every chart | ||
return allUniqTags.map(tag => { | ||
let tagList = runs.map(run => { | ||
return { | ||
run, | ||
tag: tags[run][tag] | ||
}; | ||
}).filter(item => item.tag !== undefined); | ||
return { | ||
tagList, | ||
tag, | ||
group: tag.split('/')[0] | ||
}; | ||
}); | ||
}, | ||
groupedTags() { | ||
let tagsList = this.tagsList || []; | ||
// put data in group | ||
let groupData = {}; | ||
tagsList.forEach(item => { | ||
let group = item.group; | ||
if (groupData[group] === undefined) { | ||
groupData[group] = []; | ||
groupData[group].push(item); | ||
} | ||
else { | ||
groupData[group].push(item); | ||
} | ||
}); | ||
// to array | ||
let groups = Object.keys(groupData); | ||
return groups.map(group => { | ||
return { | ||
group, | ||
tags: groupData[group] | ||
}; | ||
}); | ||
}, | ||
filteredConfig() { | ||
let config = this.config || {}; | ||
let filteredConfig = {}; | ||
Object.keys(config).forEach(key => { | ||
let val = config[key]; | ||
filteredConfig[key] = val; | ||
}); | ||
return filteredConfig; | ||
} | ||
}, | ||
created() { | ||
getPluginTextsTags().then(({errno, data}) => { | ||
this.tags = data; | ||
// filter when inited | ||
let groupNameReg = this.config.groupNameReg; | ||
this.filterTagsList(groupNameReg); | ||
}); | ||
getRuns().then(({errno, data}) => { | ||
console.log(data); | ||
this.runsArray = data; | ||
this.config.runs = data; | ||
}); | ||
}, | ||
mounted() { | ||
autoAdjustHeight(); | ||
}, | ||
watch: { | ||
'config.groupNameReg': function(val) { | ||
this.throttledFilterTagsList() | ||
} | ||
}, | ||
methods:{ | ||
filterTagsList(groupNameReg) { | ||
if (!groupNameReg) { | ||
this.filteredTagsList = []; | ||
return; | ||
} | ||
let tagsList = this.tagsList || []; | ||
let regExp = new RegExp(groupNameReg); | ||
this.filteredTagsList = tagsList.filter(item => regExp.test(item.tag)); | ||
}, | ||
throttledFilterTagsList: _.debounce( | ||
function() { | ||
this.filterTagsList(this.config.groupNameReg) | ||
}, 300 | ||
), | ||
} | ||
}; | ||
</script> | ||
|
||
<style lang="stylus"> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import {router} from 'san-router'; | ||
|
||
import Texts from './Texts'; | ||
|
||
router.add({ | ||
target: '#content', | ||
rule: '/texts', | ||
Component: Texts | ||
}); |
Oops, something went wrong.