33</ div >
44
55< h3 > Select data</ h3 >
6- < form action ="%%SERVERURL%%/?task=stats " method ="post ">
7- < p >
8- Timespan:< br >
9- < select name ="time ">
10- < option value ="today " selected > Today</ option >
11- < option value ="day "> Day</ option >
12- < option value ="week "> Week</ option >
13- < option value ="month "> Month</ option >
14- < option value ="range "> Range</ option >
15- < option value ="all "> All</ option >
16- </ select >
17- < span id ="rangeblock " class ="disable ">
18- from < input type ="text " name ="range-from " id ="rf " placeholder ="2020-03-04 " pattern ="\d{4}-\d{2}-\d{2} " style ="width:100px; ">
19- to < input type ="text " name ="range-to " id ="rt " placeholder ="2020-03-04 " value ="%%TODAY%% " pattern ="\d{4}-\d{2}-\d{2} " style ="width:100px; ">
20- </ span >
21- </ p >
22- < p >
23- Filter categories:< br >
24- < input type ="text " name ="cats " placeholder ="Hobby,Home ">
25- </ p >
26- < p >
27- Filter tasks:< br >
28- < input type ="text " name ="names " placeholder ="Coding,Gaming ">
29- </ p >
30- < p >
31- Filter Devices:< br >
32- < select name ="devices[] " multiple >
33- <!--MULTIPLE-Devices-BEGIN-->
34- < option value ="%%VALUE%% " selected > %%NAME%%</ option >
35- <!--MULTIPLE-Devices-END-->
36- </ select >
37- </ p >
38- < p > < input type ="submit " value ="Show "> </ p >
39- </ form >
6+ < form action ="%%SERVERURL%%/?task=stats " method ="post ">
7+ < div class ="form-group row ">
8+ < label for ="time " class ="col-sm-2 col-form-label "> Timespan</ label >
9+ < div class ="col-sm-10 ">
10+ < select name ="time " id ="time " class ="custom-select ">
11+ < option value ="today " selected > Today</ option >
12+ < option value ="day "> Day</ option >
13+ < option value ="week "> Week</ option >
14+ < option value ="month "> Month</ option >
15+ < option value ="range "> Range</ option >
16+ < option value ="all "> All</ option >
17+ </ select >
18+ </ div >
19+ </ div >
20+ < div id ="rangeblock " class ="disable ">
21+ < div class ="form-group row ">
22+ < div class ="col-sm-2 "> </ div >
23+ < label for ="rf " class ="col-sm-2 col-form-label "> from</ label >
24+ < div class ="col-sm-6 ">
25+ < input type ="text " name ="range-from " id ="rf " placeholder ="2020-03-04 " pattern ="\d{4}-\d{2}-\d{2} " class ="form-control ">
26+ </ div >
27+ < div class ="col-sm-2 ">
28+ < button type ="button " class ="btn btn-light " id ="fromDialog "> 📅</ button >
29+ </ div >
30+ </ div >
31+ < div class ="form-group row ">
32+ < div class ="col-sm-2 "> </ div >
33+ < label for ="rf "class ="col-sm-2 col-form-label "> to</ label >
34+ < div class ="col-sm-6 ">
35+ < input type ="text " name ="range-to " id ="rt " placeholder ="2020-03-04 " value ="%%TODAY%% " pattern ="\d{4}-\d{2}-\d{2} " class ="form-control ">
36+ </ div >
37+ < div class ="col-sm-2 ">
38+ < button type ="button " class ="btn btn-light " id ="toDialog "> 📅</ button >
39+ </ div >
40+ </ div >
41+ </ div >
42+ < div class ="form-group row ">
43+ < label for ="cats " class ="col-sm-2 col-form-label "> Filter categories</ label >
44+ < div class ="col-sm-10 ">
45+ < input type ="text " placeholder ="Hobby,Home " name ="cats " id ="cats " class ="form-control ">
46+ </ div >
47+ </ div >
48+ < div class ="form-group row ">
49+ < label for ="names " class ="col-sm-2 col-form-label "> Filter tasks</ label >
50+ < div class ="col-sm-10 ">
51+ < input type ="text " placeholder ="Coding,Gaming " name ="names " id ="names " class ="form-control ">
52+ </ div >
53+ </ div >
54+ < div class ="form-group row ">
55+ < label for ="devices " class ="col-sm-2 col-form-label "> Filter Devices</ label >
56+ < div class ="col-sm-10 ">
57+ < select name ="devices[] " id ="devices " class ="custom-select " size =4 multiple >
58+ <!--MULTIPLE-Devices-BEGIN-->
59+ < option value ="%%VALUE%% " selected > %%NAME%%</ option >
60+ <!--MULTIPLE-Devices-END-->
61+ </ select >
62+ </ div >
63+ </ div >
64+ < div class ="form-group row ">
65+ < div class ="col-sm-2 "> </ div >
66+ < div class ="col-sm-10 ">
67+ < input type ="submit " value ="Show " class ="btn btn-secondary ">
68+ </ div >
69+ </ div >
70+ </ form >
71+ < input type ="hidden " id ="datepickerFrom ">
72+ < input type ="hidden " id ="datepickerTo ">
4073
4174< script >
4275$ ( "select[name=time]" ) . change ( ( ) => {
4376 if ( $ ( "select[name=time]" ) . val ( ) == "range" ) {
44- $ ( "span #rangeblock" ) . removeClass ( "disable" ) ;
77+ $ ( "div #rangeblock" ) . removeClass ( "disable" ) ;
4578 }
4679 else {
47- $ ( "span #rangeblock" ) . addClass ( "disable" ) ;
80+ $ ( "div #rangeblock" ) . addClass ( "disable" ) ;
4881 }
4982} ) ;
83+ if ( localStorage . hasOwnProperty ( 'lastServerStats' ) ) {
84+ var values = JSON . parse ( localStorage . getItem ( 'lastServerStats' ) ) ;
85+ $ . each ( values , ( k , v ) => {
86+ $ ( v . tag + '[name="' + k + '"]' ) . val ( v . value ) ;
87+ } ) ;
88+ $ ( "select[name=time]" ) . trigger ( 'change' ) ;
89+ }
90+ $ ( "form" ) . on ( "submit" , ( ) => {
91+ var values = { } ;
92+ $ ( "input, select" ) . each ( ( k , v ) => {
93+ values [ $ ( v ) . attr ( "name" ) ] = {
94+ value : $ ( v ) . val ( ) ,
95+ tag : $ ( v ) . prop ( "tagName" )
96+ } ;
97+ } ) ;
98+ localStorage . setItem ( 'lastServerStats' , JSON . stringify ( values ) ) ;
99+ } ) ;
100+ function dateDialog ( element , destination ) {
101+ var pos = $ ( destination ) . offset ( ) ;
102+ $ ( element ) . datepicker (
103+ "dialog" ,
104+ $ ( destination ) . val ( ) ,
105+ function ( v , o ) {
106+ var m = o . selectedMonth + 1 ;
107+ var d = o . selectedDay ;
108+ $ ( destination ) . val ( o . selectedYear + '-' + ( m <= 9 ? '0' : '' ) + m + '-' + ( d <= 9 ? '0' : '' ) + d ) ;
109+ } ,
110+ {
111+ dateFormat : "yy-mm-dd"
112+ } ,
113+ [ pos . left , pos . top ]
114+ ) ;
115+ }
116+ $ ( "#fromDialog" ) . click ( ( e ) => {
117+ e . preventDefault ( ) ;
118+ dateDialog ( "input#datepickerFrom" , "input[name=range-from]" ) ;
119+ } ) ;
120+ $ ( "#toDialog" ) . click ( ( e ) => {
121+ e . preventDefault ( ) ;
122+ dateDialog ( "input#datepickerTo" , "input[name=range-to]" ) ;
123+ } ) ;
50124</ script >
125+
51126< h3 > Tables</ h3 >
52- < p > < code > %%CMD%%</ code > </ p >
127+ < div class ="alert alert-info %%CMDDISABLE%% " role ="alert ">
128+ < h5 class ="alert-heading "> Client Command</ h5 >
129+ < p > < code > %%CMD%%</ code > </ p >
130+ </ div >
53131
54- < div style ="margin-bottom: 10px; ">
55- %%TABLEA%%
56- </ div >
57- < div >
58- %%TABLEB%%
59- </ div >
132+ < div style ="margin-bottom: 10px; ">
133+ %%TABLEA%%
134+ </ div >
135+ < div >
136+ %%TABLEB%%
137+ </ div >
60138
61139< h3 > Graph</ h3 >
62- < select id ="graphselect ">
63- </ select >
64- < button id ="displaygraph "> Display Graph</ button >
140+ < div class ="form-inline ">
141+ < div class ="input-group ">
142+ < select id ="graphselect " class ="custom-select " name ="graph ">
143+ </ select >
144+ </ div >
145+ < button id ="displaygraph " class ="btn btn-secondary "> Display Graph</ button >
146+ </ div >
65147
66- < div style ="width: 99%; ">
67- < canvas id ="maingraph "> </ canvas >
68- </ div >
148+
149+ < div style ="width: 99%; ">
150+ < canvas id ="maingraph "> </ canvas >
151+ </ div >
69152< script >
70153 var combiData = % % COMBIDATA % % ;
154+ var plainData = % % PLAINDATA % % ;
155+ var singleDayData = % % SINGLEDAYDATA % % ;
71156 var graphes = % % GRAPHES % % ;
72157 var loadUrl = "%%SERVERURL%%/load/graphs/" ;
73158
@@ -78,14 +163,16 @@ <h3>Graph</h3>
78163 var chart = null ;
79164
80165 $ ( "button#displaygraph" ) . click ( ( ) => {
81- var url = loadUrl + $ ( "select#graphselect" ) . val ( ) + '.js' ;
166+ var url = loadUrl + $ ( "select#graphselect" ) . val ( ) + '.js?%%VERSIONSEED%% ' ;
82167 $ . getScript ( url , ( ) => {
83- if ( typeof createGraph === "function" && combiData . length > 0 ) {
168+ if ( typeof createGraph === "function" && ( combiData . length > 0 || plainData . length > 0 || singleDayData !== false ) ) {
84169 if ( chart !== null ) {
85170 chart . destroy ( ) ;
86171 }
87172 chart = createGraph (
88173 combiData ,
174+ plainData ,
175+ singleDayData ,
89176 document . getElementById ( 'maingraph' ) . getContext ( '2d' )
90177 ) ;
91178 }
0 commit comments