Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create text ui feature #337

Merged
merged 6 commits into from
Mar 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions frontend/mock/data/plugin/texts/tags.js
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": ""
},
}
}
}
};
};
38 changes: 38 additions & 0 deletions frontend/mock/data/plugin/texts/texts.js
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"]]
}
}
}
};
5 changes: 5 additions & 0 deletions frontend/src/common/component/AppMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ export default {
url: '/graphs',
title: 'GRAPHS',
name: 'graphs'
},
{
url: '/texts',
title: 'TEXTS',
name: 'texts'
}
]
}
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Scalars from '@/scalars/Scalars'
import Histogram from '@/histogram/Histogram'
import Images from '@/images/Images'
import Graph from '@/graph/Graph'
import Texts from '@/texts/Texts'

Vue.use(Router)

Expand All @@ -30,5 +31,10 @@ export default new Router({
name: 'Graph',
component: Graph
},
{
path: '/texts',
name: 'Texts',
component: Texts
}
]
})
4 changes: 4 additions & 0 deletions frontend/src/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ export const getPluginHistogramsTags = makeService('/data/plugin/histograms/tags
export const getPluginHistogramsHistograms = makeService('/data/plugin/histograms/histograms');

export const getPluginGraphsGraph = makeService('/data/plugin/graphs/graph');

export const getPluginTextsTags = makeService('/data/plugin/texts/tags');

export const getPluginTextsTexts = makeService('/data/plugin/texts/texts');
167 changes: 167 additions & 0 deletions frontend/src/texts/Texts.vue
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>
9 changes: 9 additions & 0 deletions frontend/src/texts/index.js
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
});
Loading