11<template lang="pug">
22div
33 h5 {{ visualizations[type].title }}
4- div
5- b-dropdown.vis-style-dropdown-btn ( size ="sm" variant ="outline-secondary" )
4+ div( v-if = "editable" ) .vis-style-dropdown-btn
5+ b-dropdown.mr-1 ( size ="sm" variant ="outline-secondary" )
66 template( v-slot:button-content )
77 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 }}
8+ b-dropdown-item( v-for ="t in types" : key= "t" variant ="outline-secondary" @click ="$emit('onTypeChange', id, t)" )
9+ | {{ visualizations[t].title }} #[ span.small ( v-if ="!visualizations[t].available" style ="color: #A50" ) (no data)]
10+ b-button.p-0 ( size ="sm" , variant ="outline-danger" @click ="$emit('onRemove', id)" )
11+ icon( name ="times" )
12+
13+ // Check data prerequisites
14+ div( v-if ="!has_prerequisites" )
15+ b-alert.small.px-2.py-1 ( show variant ="warning" )
16+ | This feature is missing data from a required watcher.
17+ | You can find a list of all watchers in #[ a( href ="https://activitywatch.readthedocs.io/en/latest/watchers.html" ) the documentation] .
1018
1119 div( v-if ="type == 'top_apps'" )
1220 aw-summary( :fields ="$store.state.activity.window.top_apps" ,
5462 aw-categorytree( :events ="$store.state.activity.category.top" )
5563 div( v-if ="type == 'category_sunburst'" )
5664 aw-sunburst-categories( :data ="top_categories_hierarchy" , style ="height: 20em" )
57-
65+ div( v-if ="type == 'timeline_barchart'" )
66+ aw-timeline-barchart( :datasets ="datasets" , style ="height: 100" )
67+ // TODO: Broke when we switched to customizable views (since it doesn't use vuex to request data)
68+ //div(v-if="type == 'sunburst_clock'")
69+ aw-sunburst-clock(:date="date", :afkBucketId="bucket_id_afk", :windowBucketId="bucket_id_window")
5870 </template >
5971
6072<style lang="scss">
6375 top : 0.8em ;
6476 right : 0.8em ;
6577
66- > .btn {
78+ .btn {
6779 border : 0px ;
6880 }
6981}
7082 </style >
7183
7284<script >
85+ import ' vue-awesome/icons/cog' ;
86+ import ' vue-awesome/icons/times' ;
87+
88+ import { split_by_hour_into_data } from ' ~/util/transforms' ;
89+
7390// TODO: Move this somewhere else
7491import { build_category_hierarchy } from ' ~/util/classes' ;
92+
7593function pick_subname_as_name (c ) {
7694 c .name = c .subname ;
7795 c .children = c .children .map (pick_subname_as_name);
@@ -83,6 +101,7 @@ export default {
83101 props: {
84102 id: Number ,
85103 type: String ,
104+ editable: { type: Boolean , default: true },
86105 },
87106 data : function () {
88107 return {
@@ -97,6 +116,7 @@ export default {
97116 ' top_editor_files' ,
98117 ' top_editor_languages' ,
99118 ' top_editor_projects' ,
119+ ' timeline_barchart' ,
100120 ],
101121 // TODO: Move this function somewhere else
102122 top_editor_files_namefunc : e => {
@@ -163,8 +183,23 @@ export default {
163183 title: ' Category Sunburst' ,
164184 available: this .$store .state .activity .category .available ,
165185 },
186+ timeline_barchart: {
187+ title: ' Timeline (barchart)' ,
188+ // TODO
189+ available: true ,
190+ },
191+ /*
192+ sunburst_clock: {
193+ title: 'Sunburst clock',
194+ // TODO
195+ available: true,
196+ },
197+ */
166198 };
167199 },
200+ has_prerequisites () {
201+ return this .visualizations [this .type ].available ;
202+ },
168203 top_categories_hierarchy : function () {
169204 const top_categories = this .$store .state .activity .category .top ;
170205 if (top_categories) {
@@ -180,6 +215,17 @@ export default {
180215 return null ;
181216 }
182217 },
218+ datasets : function () {
219+ // TODO: Move elsewhere
220+ const data = split_by_hour_into_data (this .$store .state .activity .active .events );
221+ return [
222+ {
223+ label: ' Total time' ,
224+ backgroundColor: ' #6699ff' ,
225+ data,
226+ },
227+ ];
228+ },
183229 },
184230};
185231 </script >
0 commit comments