11<template lang="pug">
22div
3- h5 {{ type_title }}
3+ h5 {{ visualizations[type].title }}
4+ div
5+ b-dropdown.vis-style-dropdown-btn ( size ="sm" variant ="outline-secondary" )
6+ template( v-slot:button-content )
7+ icon( name ="cog" )
8+ b-dropdown-item( v-for ="t in types" : key= "t" variant ="outline-secondary" @click ="$emit('onTypeChange', id, t)" v-bind:disabled ="!visualizations[t].available" )
9+ | {{ visualizations[t].title }}
10+
411 div( v-if ="type == 'top_apps'" )
5- aw-summary( :fields ="top_apps" ,
12+ aw-summary( :fields ="$store.state.activity.window. top_apps" ,
613 :namefunc ="e => e.data.app" ,
714 :colorfunc ="e => e.data.app" ,
815 with_limit )
916 div( v-if ="type == 'top_titles'" )
10- aw-summary( :fields ="top_titles" ,
17+ aw-summary( :fields ="$store.state.activity.window. top_titles" ,
1118 :namefunc ="e => e.data.title" ,
1219 :colorfunc ="e => e.data.app" ,
1320 with_limit )
1421 div( v-if ="type == 'top_domains'" )
15- aw-summary( :fields ="top_domains" ,
22+ aw-summary( :fields ="$store.state.activity.browser. top_domains" ,
1623 :namefunc ="e => e.data.$domain" ,
1724 :colorfunc ="e => e.data.$domain" ,
1825 with_limit )
1926 div( v-if ="type == 'top_urls'" )
20- aw-summary( :fields ="top_urls" ,
27+ aw-summary( :fields ="$store.state.activity.browser. top_urls" ,
2128 :namefunc ="e => e.data.url" ,
2229 :colorfunc ="e => e.data.$domain" ,
2330 with_limit )
3744 :colorfunc ="e => e.data.language" ,
3845 with_limit )
3946 div( v-if ="type == 'top_categories'" )
40- aw-summary( :fields ="top_categories " ,
47+ aw-summary( :fields ="$store.state.activity.category.top " ,
4148 :namefunc ="e => e.data['$category'].join(' > ')" ,
4249 :colorfunc ="e => e.data['$category'].join(' > ')" ,
4350 with_limit )
4451 div( v-if ="type == 'category_tree'" )
45- aw-categorytree( :events ="top_categories " )
52+ aw-categorytree( :events ="$store.state.activity.category.top " )
4653 div( v-if ="type == 'category_sunburst'" )
4754 aw-sunburst-categories( :data ="top_categories_hierarchy" , style ="height: 20em" )
4855
49- b-dropdown.vis-style-dropdown-btn ( size ="sm" variant ="outline-secondary" )
50- template( v-slot:button-content )
51- icon( name ="cog" )
52- b-dropdown-item( v-for ="t in types" : key= "t" variant ="outline-secondary" @click ="$emit('onTypeChange', id, t)" v-bind:disabled ="!get_type_available(t)" )
53- | {{ get_type_title(t) }}
5456</template >
5557
56- <style scoped lang="scss">
58+ <style lang="scss">
5759.vis-style-dropdown-btn {
5860 position : absolute ;
59- bottom : 0 ;
60- right : 0.5 em ;
61+ top : 0.8 em ;
62+ right : 1 em ;
6163
62- background-color : #fff ;
64+ > .btn {
65+ border : 0px ;
66+ }
6367}
6468 </style >
6569
@@ -109,24 +113,56 @@ export default {
109113 };
110114 },
111115 computed: {
112- top_apps : function () {
113- return this .$store .state .activity .window .top_apps ;
114- },
115- top_titles : function () {
116- return this .$store .state .activity .window .top_titles ;
117- },
118- top_domains : function () {
119- return this .$store .state .activity .browser .top_domains ;
120- },
121- top_urls : function () {
122- return this .$store .state .activity .browser .top_urls ;
123- },
124- top_categories : function () {
125- return this .$store .state .activity .category .top ;
116+ visualizations : function () {
117+ return {
118+ top_apps: {
119+ title: ' Top Applications' ,
120+ available:
121+ this .$store .state .activity .window .available ||
122+ this .$store .state .activity .android .available ,
123+ },
124+ top_titles: {
125+ title: ' Top Window Titles' ,
126+ available: this .$store .state .activity .window .available ,
127+ },
128+ top_domains: {
129+ title: ' Top Browser Domains' ,
130+ available: this .$store .state .activity .browser .available ,
131+ },
132+ top_urls: {
133+ title: ' Top Browser URLs' ,
134+ available: this .$store .state .activity .browser .available ,
135+ },
136+ top_editor_files: {
137+ title: ' Top Editor Files' ,
138+ available: this .$store .state .activity .editor .available ,
139+ },
140+ top_editor_languages: {
141+ title: ' Top Editor Languages' ,
142+ available: this .$store .state .activity .editor .available ,
143+ },
144+ top_editor_projects: {
145+ title: ' Top Editor Projects' ,
146+ available: this .$store .state .activity .editor .available ,
147+ },
148+ top_categories: {
149+ title: ' Top Categories' ,
150+ available: this .$store .state .activity .category .available ,
151+ },
152+ category_tree: {
153+ title: ' Category Tree' ,
154+ available: this .$store .state .activity .category .available ,
155+ },
156+ category_sunburst: {
157+ title: ' Category Sunburst' ,
158+ available: this .$store .state .activity .category .available ,
159+ },
160+ };
126161 },
127162 top_categories_hierarchy : function () {
128- if (this .top_categories ) {
129- const categories = this .top_categories .map (c => {
163+ const top_categories = this .$store .state .activity .category .top ;
164+ if (top_categories) {
165+ const categories = top_categories .map (c => {
130166 return { name: c .data .$category , size: c .duration };
131167 });
132168
@@ -138,59 +174,6 @@ export default {
138174 return null ;
139175 }
140176 },
141- type_title : function () {
142- return this .get_type_title (this .type );
143- },
144- },
145- methods: {
146- get_type_available : function (type ) {
147- if (type === ' top_apps' || type === ' top_titles' ) {
148- return this .$store .state .activity .window .available ;
149- } else if (type === ' top_domains' || type === ' top_urls' ) {
150- return this .$store .state .activity .browser .available ;
151- } else if (
152- type === ' top_editor_files' ||
153- type === ' top_editor_languages' ||
154- type === ' top_editor_projects'
155- ) {
156- return this .$store .state .activity .editor .available ;
157- } else if (
158- type === ' top_categories' ||
159- type === ' category_tree' ||
160- type === ' category_sunburst'
161- ) {
162- return this .$store .state .activity .category .available ;
163- } else {
164- console .error (' Unknown type available: ' , type);
165- return false ;
166- }
167- },
168- get_type_title : function (type ) {
169- if (type === ' top_apps' ) {
170- return ' Top Applications' ;
171- } else if (type === ' top_titles' ) {
172- return ' Top Window Titles' ;
173- } else if (type === ' top_domains' ) {
174- return ' Top Browser Domains' ;
175- } else if (type === ' top_urls' ) {
176- return ' Top Browser URLs' ;
177- } else if (type === ' top_editor_files' ) {
178- return ' Top Editor Files' ;
179- } else if (type === ' top_editor_languages' ) {
180- return ' Top Editor Languages' ;
181- } else if (type === ' top_editor_projects' ) {
182- return ' Top Editor Projects' ;
183- } else if (type === ' top_categories' ) {
184- return ' Top Categories' ;
185- } else if (type === ' category_tree' ) {
186- return ' Category Tree' ;
187- } else if (type === ' category_sunburst' ) {
188- return ' Category Sunburst' ;
189- } else {
190- console .error (' Unknown type: ' , type);
191- return ' Unknown' ;
192- }
193- },
194177 },
195178};
196179 </script >
0 commit comments