1
1
<template lang="pug">
2
2
div
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
+
4
11
div( v-if ="type == 'top_apps'" )
5
- aw-summary( :fields ="top_apps" ,
12
+ aw-summary( :fields ="$store.state.activity.window. top_apps" ,
6
13
:namefunc ="e => e.data.app" ,
7
14
:colorfunc ="e => e.data.app" ,
8
15
with_limit )
9
16
div( v-if ="type == 'top_titles'" )
10
- aw-summary( :fields ="top_titles" ,
17
+ aw-summary( :fields ="$store.state.activity.window. top_titles" ,
11
18
:namefunc ="e => e.data.title" ,
12
19
:colorfunc ="e => e.data.app" ,
13
20
with_limit )
14
21
div( v-if ="type == 'top_domains'" )
15
- aw-summary( :fields ="top_domains" ,
22
+ aw-summary( :fields ="$store.state.activity.browser. top_domains" ,
16
23
:namefunc ="e => e.data.$domain" ,
17
24
:colorfunc ="e => e.data.$domain" ,
18
25
with_limit )
19
26
div( v-if ="type == 'top_urls'" )
20
- aw-summary( :fields ="top_urls" ,
27
+ aw-summary( :fields ="$store.state.activity.browser. top_urls" ,
21
28
:namefunc ="e => e.data.url" ,
22
29
:colorfunc ="e => e.data.$domain" ,
23
30
with_limit )
37
44
:colorfunc ="e => e.data.language" ,
38
45
with_limit )
39
46
div( v-if ="type == 'top_categories'" )
40
- aw-summary( :fields ="top_categories " ,
47
+ aw-summary( :fields ="$store.state.activity.category.top " ,
41
48
:namefunc ="e => e.data['$category'].join(' > ')" ,
42
49
:colorfunc ="e => e.data['$category'].join(' > ')" ,
43
50
with_limit )
44
51
div( v-if ="type == 'category_tree'" )
45
- aw-categorytree( :events ="top_categories " )
52
+ aw-categorytree( :events ="$store.state.activity.category.top " )
46
53
div( v-if ="type == 'category_sunburst'" )
47
54
aw-sunburst-categories( :data ="top_categories_hierarchy" , style ="height: 20em" )
48
55
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) }}
54
56
</template >
55
57
56
- <style scoped lang="scss">
58
+ <style lang="scss">
57
59
.vis-style-dropdown-btn {
58
60
position : absolute ;
59
- bottom : 0 ;
60
- right : 0.5 em ;
61
+ top : 0.8 em ;
62
+ right : 1 em ;
61
63
62
- background-color : #fff ;
64
+ > .btn {
65
+ border : 0px ;
66
+ }
63
67
}
64
68
</style >
65
69
@@ -109,24 +113,56 @@ export default {
109
113
};
110
114
},
111
115
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
+ };
126
161
},
127
162
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 => {
130
166
return { name: c .data .$category , size: c .duration };
131
167
});
132
168
@@ -138,59 +174,6 @@ export default {
138
174
return null ;
139
175
}
140
176
},
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
- },
194
177
},
195
178
};
196
179
</script >
0 commit comments