aboutsummaryrefslogtreecommitdiff
path: root/build/static
diff options
context:
space:
mode:
Diffstat (limited to 'build/static')
-rw-r--r--build/static/js/main.0c8ec738.chunk.js (renamed from build/static/js/main.36efdf67.chunk.js)4
-rw-r--r--build/static/js/main.0c8ec738.chunk.js.map1
-rw-r--r--build/static/js/main.36efdf67.chunk.js.map1
3 files changed, 3 insertions, 3 deletions
diff --git a/build/static/js/main.36efdf67.chunk.js b/build/static/js/main.0c8ec738.chunk.js
index 4ef4419..f55a1f0 100644
--- a/build/static/js/main.36efdf67.chunk.js
+++ b/build/static/js/main.0c8ec738.chunk.js
@@ -1,2 +1,2 @@
-(window.webpackJsonp=window.webpackJsonp||[]).push([[0],{308:function(e,t,a){e.exports=a(655)},655:function(e,t,a){"use strict";a.r(t);var n=a(1),r=a.n(n),c=a(28),o=a.n(c),i=a(137),l=a(101),s=a(39),u=a(45),h=a(78),d=a(74),m=a(79),p=(a(313),a(315),a(341),a(286)),f=a(31),v=a(99),g=a.n(v),y=a(306),E=a.n(y),w=a(305),b=a.n(w),P=a(173),x=a.n(P),k=a(81),S=a.n(k),T=a(177),C=a.n(T),D=a(93),O=a.n(D),j=a(103),R=a.n(j),N=a(40),B=a.n(N),G=a(307),I=a.n(G),W=a(174),K=a.n(W),A=function(e){return r.a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 98.905998 93.557997",version:"1.1",style:e.style},r.a.createElement("g",{id:"g13",transform:"translate(-153.533,-203.047)"},r.a.createElement("g",{id:"g29"},r.a.createElement("g",{id:"g27"},r.a.createElement("polygon",{id:"polygon7",points:"252.439,241.924 234.556,288.703 185.103,296.605 153.533,257.728 171.416,210.949 220.869,203.047 ",style:{fill:"#ff8000"}}),r.a.createElement("g",{id:"g11",transform:"translate(167.24355,224.20734)"},r.a.createElement("text",{id:"text9",style:{fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",fontStretch:"normal",fontSize:75,fontFamily:"TypoPRO Fantasque Sans Mono",fill:"#ffeade"},transform:"translate(0.586,49.072)"},"Cr"))))))},_="https://www.googleapis.com/calendar/v3",M={invalidSyncToken:1,otherError:2};function z(e){return Object.entries(e).map(function(e){var t=Object(i.a)(e,2),a=t[0],n=t[1];return"".concat(encodeURIComponent(a),"=").concat(encodeURIComponent(n))}).join("&")}function F(){return new Promise(function(e){return chrome.identity.getAuthToken({interactive:!0},function(t){return e(t)})})}function U(e){return fetch("".concat(_,"/users/me/calendarList?").concat(z({access_token:e})),{method:"GET",async:!0}).then(function(e){return e.json()}).then(function(e){return e.items})}function L(e){return fetch("".concat(_,"/colors?").concat(z({access_token:e})),{method:"GET",async:!0}).then(function(e){return e.json()})}var $=function(){function e(t,a){Object(s.a)(this,e),this.calId=t,this.name=a,this.token=F(),this.syncToken="",this.cache={}}return Object(u.a)(e,[{key:"getSlot",value:function(e){return this.cache[e]||(this.cache[e]={}),this.cache[e]}},{key:"addEvent",value:function(t){var a=e.dateToCacheKey(t.start),n=e.dateToCacheKey(new Date(t.end.getTime()-1));if(a===n)this.getSlot(a)[t.id]={start:t.start,end:t.end,id:t.id};else{this.getSlot(a)[t.id]={start:t.start,end:e.slotEndDate(a),id:t.id},this.getSlot(n)[t.id]={start:e.slotStartDate(n),end:t.end,id:t.id};for(var r=a+1;r<n;r++)this.getSlot(r)[t.id]={start:e.slotStartDate(r),end:e.slotEndDate(r),id:t.id}}}},{key:"removeEvent",value:function(t){for(var a=e.dateToCacheKey(t.start),n=e.dateToCacheKey(new Date(t.end.getTime()-1)),r=a;r<=n;r++)delete this.getSlot(r)[t.id]}},{key:"getSlotEvents",value:function(e,t,a){var n=this.getSlot(e),r=[];for(var c in n){if(!(n[c].start>=a||n[c].end<=t))(n[c].start<t?t:n[c].start)>(n[c].end>a?a:n[c].end)&&console.log(n[c],t,a),r.push({id:c,start:n[c].start<t?t:n[c].start,end:n[c].end>a?a:n[c].end})}return r}},{key:"getCachedEvents",value:function(t,a){for(var n=e.dateToCacheKey(t),r=e.dateToCacheKey(new Date(a.getTime()-1)),c=this.getSlotEvents(n,t,a),o=n+1;o<r;o++){var i=this.getSlot(o);for(var s in i)c.push(i[s])}return r>n&&c.push.apply(c,Object(l.a)(this.getSlotEvents(r,t,a))),c}},{key:"sync",value:function(){var e=this;return this.token.then(function(t){return function(e,t,a){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:100,r=[];return function a(c,o){return fetch("".concat(_,"/calendars/").concat(e,"/events?").concat(z({access_token:t,pageToken:c,syncToken:o,maxResults:n})),{method:"GET",async:!0}).then(function(e){if(200===e.status)return e.json();throw 410==e.status?M.invalidSyncToken:M.otherErrors}).then(function(e){return r.push.apply(r,Object(l.a)(e.items)),e.nextPageToken?a(e.nextPageToken,""):{nextSyncToken:e.nextSyncToken,results:r}})}("",a)}(e.calId,t,e.syncToken).then(function(a){e.syncToken=a.nextSyncToken;var n=a.results.map(function(a){return a.start?Promise.resolve(a):function(e,t,a){return fetch("".concat(_,"/calendars/").concat(e,"/events/").concat(t,"?").concat(z({access_token:a})),{method:"GET",async:!0}).then(function(e){return e.json()})}(e.calId,a.id,t)});return Promise.all(n).then(function(t){return t.forEach(function(t){t.start=new Date(t.start.dateTime),t.end=new Date(t.end.dateTime),"confirmed"===t.status?e.addEvent(t):"cancelled"===t.status&&e.removeEvent(t)})})})}).catch(function(t){if(t!=M.invalidSyncToken)throw t;e.syncToken="",e.sync()})}},{key:"getEvents",value:function(e,t){var a=this;return this.sync().then(function(){return a.getCachedEvents(e,t)})}}],[{key:"dateToCacheKey",value:function(e){return Math.floor(e/864e5)}},{key:"slotStartDate",value:function(e){return new Date(864e5*e)}},{key:"slotEndDate",value:function(e){return new Date(864e5*(e+1))}}]),e}(),H=function(){function e(t,a,n,r){Object(s.a)(this,e),this.id=t,this.isRegex=a,this.value=n,this.label=r}return Object(u.a)(e,[{key:"regex",get:function(){return new RegExp(this.isRegex?this.value:"^".concat(this.value,"$"))}},{key:"isEmpty",get:function(){return null===this.label}}]),e}();H.emptyPattern=function(){return new H(0,!0,"",null)},H.anyPattern=function(){return new H("any",!0,".*","Any")};var J=function e(t,a,n,r){Object(s.a)(this,e),this.name=t,this.idx=a,this.cal=n,this.event=r};J.defaultPatternEntry=function(e){return new J("",e,H.emptyPattern(),H.anyPattern())};var V=a(299),q=a.n(V),X=a(659),Y=a(657),Q=a(656),Z=a(554);function ee(e){var t=e.cx,a=e.cy,n=e.x,c=e.y,o=e.fill,i=e.name,l="middle",s=0,u=0;return n<t-2?(s=-5,l="end"):n>t+2&&(s=5,l="start"),c<a-2?u=-5:c>a+2&&(u=10),r.a.createElement("text",{x:n,y:c,dx:s,dy:u,fill:o,textAnchor:l},"".concat(i))}var te=Object(f.withStyles)(function(e){return{pieChart:{margin:"0 auto"}}})(function(e){return r.a.createElement(B.a,{container:!0,spacing:0},r.a.createElement(B.a,{item:!0,xs:12,lg:6},r.a.createElement("div",{className:e.classes.patternTableWrapper},r.a.createElement(X.a,{width:400,height:250,className:e.classes.pieChart},r.a.createElement(Y.a,{data:e.patternGraphData,dataKey:"value",cx:200,cy:125,outerRadius:60,fill:q.a[300],label:ee}),r.a.createElement(Q.a,{formatter:function(e){return"".concat(e.toFixed(2)," hr")}})))),r.a.createElement(B.a,{item:!0,xs:12,lg:6},r.a.createElement("div",{className:e.classes.patternTableWrapper},r.a.createElement(X.a,{width:400,height:250,className:e.classes.pieChart},r.a.createElement(Y.a,{data:e.calendarGraphData,dataKey:"value",cx:200,cy:125,innerRadius:40,outerRadius:70,fill:g.a[300],label:ee},e.calendarGraphData.map(function(e,t){return r.a.createElement(Z.a,{key:t,fill:e.color})})),r.a.createElement(Q.a,{formatter:function(e){return"".concat(e.toFixed(2)," hr")}})))))}),ae=a(136),ne=a.n(ae),re=a(301),ce=a.n(re),oe=a(303),ie=a.n(oe),le=a(140),se=a.n(le),ue=a(100),he=a.n(ue),de=a(302),me=a.n(de),pe=a(304),fe=a.n(pe),ve=a(300),ge=a.n(ve),ye=a(131),Ee=a.n(ye),we=a(172),be=a.n(we),Pe=function(e){function t(){return Object(s.a)(this,t),Object(h.a)(this,Object(d.a)(t).apply(this,arguments))}return Object(m.a)(t,e),Object(u.a)(t,[{key:"render",value:function(){var e=this,t=this.props.classes,a=[],n=this.props.options,c=new H.emptyPattern;for(var o in n[c.id]=c,n){var i=n[o].isEmpty?r.a.createElement("span",{style:{color:this.props.theme.palette.primary.dark}},"Custom"):n[o].label;a.push(r.a.createElement(be.a,{key:o,value:o},i))}var l=this.props.value.isRegex?t.fieldRegex:t.fieldNoRegex;return r.a.createElement(O.a,null,r.a.createElement("span",null,r.a.createElement(Ee.a,{value:this.props.value.id,onChange:function(t){var a;a=null==n[t.target.value].label?new H(0,!0,e.props.value.isRegex?e.props.value.value:"^".concat(e.props.value.value,"$"),null):n[t.target.value],e.props.onChange({target:{value:a}})},className:l},a),null==this.props.value.label&&r.a.createElement(ne.a,{value:this.props.value.value,onChange:function(t){return e.props.onChange({target:{value:new H(0,!0,t.target.value,null)}})}})))}}]),t}(r.a.Component),xe=Object(f.withStyles)(function(e){return{fieldNoRegex:{width:200},fieldRegex:{marginRight:"0.5em"}}})(Pe);var ke=a(139),Se=a.n(ke),Te=Object(f.createMuiTheme)({palette:{primary:{light:Se.a[300],main:Se.a[500],dark:Se.a[700],contrastText:"#fff"}},typography:{useNextVariants:!0}}),Ce=[{label:"Name",field:"name",elem:ne.a},{label:"Calendar",field:"cal",elem:Object(f.withTheme)(Te)(function(e){var t={};for(var a in e.cached.calendars)t[a]=new H(a,!1,e.cached.calendars[a].name,e.cached.calendars[a].name);return r.a.createElement(xe,{value:e.value,options:t,onChange:e.onChange,theme:e.theme})})},{label:"Event",field:"event",elem:Object(f.withTheme)(Te)(function(e){var t=H.anyPattern(),a={};return a[t.id]=t,r.a.createElement(xe,{value:e.value,options:a,onChange:e.onChange,theme:e.theme})})}],De=function(e){function t(){var e,a;Object(s.a)(this,t);for(var n=arguments.length,r=new Array(n),c=0;c<n;c++)r[c]=arguments[c];return(a=Object(h.a)(this,(e=Object(d.a)(t)).call.apply(e,[this].concat(r)))).state={page:0,rowsPerPage:5},a.handleChangePage=function(e,t){a.setState({page:t})},a.handleChangeRowsPerPage=function(e){a.setState({rowsPerPage:e.target.value})},a}return Object(m.a)(t,e),Object(u.a)(t,[{key:"render",value:function(){var e=this,t=this.props,a=t.classes,n=t.cached,c=t.patterns,o=this.state,i=o.rowsPerPage,l=o.page,s=i-Math.min(i,c.length-l*i),u=c.slice(l*i,(l+1)*i).map(function(t){return r.a.createElement(se.a,{onMouseOver:function(){return e.setState({activePattern:t.idx})},onMouseOut:function(){return e.setState({activePattern:null})}},Ce.map(function(a){var c=a.elem;return r.a.createElement(he.a,null,r.a.createElement(c,{value:t[a.field],cached:n,onChange:function(n){return e.props.onUpdatePattern(a.field,t.idx,n.target.value)}}))}),r.a.createElement("span",{className:e.state.activePattern===t.idx?a.deleteButtonShow:a.deleteButtonHide},r.a.createElement(ge.a,{className:a.deleteIcon,onClick:function(){return e.props.onRemovePattern(t.idx)}})))});return r.a.createElement("div",null,r.a.createElement("div",{className:a.patternTableWrapper},r.a.createElement(ce.a,{className:a.patternTable},r.a.createElement(me.a,null,r.a.createElement(se.a,null,Ce.map(function(e,t){return r.a.createElement(he.a,{key:t},e.label)}))),r.a.createElement(ie.a,null,u,s>0&&r.a.createElement(se.a,{style:{height:48*s}},r.a.createElement(he.a,{colSpan:Ce.length}))))),r.a.createElement(fe.a,{rowsPerPageOptions:[5,10,25],component:"div",count:c.length,rowsPerPage:i,page:l,backIconButtonProps:{"aria-label":"Previous Page"},nextIconButtonProps:{"aria-label":"Next Page"},onChangePage:this.handleChangePage,onChangeRowsPerPage:this.handleChangeRowsPerPage}))}}]),t}(r.a.Component),Oe=Object(f.withStyles)(function(e){return{deleteButtonShow:{position:"absolute",right:0,height:48},deleteButtonHide:{display:"none"},deleteIcon:{height:"100%",cursor:"pointer"},patternTableWrapper:{overflowX:"auto",overflowY:"hidden"},patternTable:{minWidth:600}}})(De),je=[{name:"Work",value:10,color:g.a[300]},{name:"Wasted",value:10,color:g.a[300]}];var Re=function(e){function t(){var e,a;Object(s.a)(this,t);for(var n=arguments.length,r=new Array(n),c=0;c<n;c++)r[c]=arguments[c];return(a=Object(h.a)(this,(e=Object(d.a)(t)).call.apply(e,[this].concat(r)))).state={patterns:[],timeRange:null,token:F(),patternGraphData:je,calendarGraphData:je,activePattern:null},a.cached={calendars:{}},a.updatePattern=function(e,t,n){var r=a.state.patterns;r[t][e]=n,a.setState({patterns:r})},a.removePattern=function(e){var t=a.state.patterns;t.splice(e,1);for(var n=0;n<t.length;n++)t[n].idx=n;a.setState({patterns:t})},a.newPattern=function(){for(var e=[J.defaultPatternEntry()].concat(Object(l.a)(a.state.patterns)),t=1;t<e.length;t++)e[t].idx=t;a.setState({patterns:e})},a.analyze=function(){if(a.state.startDate&&a.state.endDate){var e=a.state.startDate.toDate(),t=a.state.endDate.toDate();console.log(e,t);var n=[],r=function(r){n.push(a.cached.calendars[r].cal.getEvents(e,t).then(function(e){return{id:r,events:e}}).catch(function(e){return console.log("cannot load calendar ".concat(r)),{id:r,events:[]}}))};for(var c in a.cached.calendars)r(c);Promise.all(n).then(function(e){var t={},n={},r={};e.forEach(function(e){return t[e.id]=e.events});for(var c=0;c<a.state.patterns.length;c++)n[c]=0;var o=function(e){if(!t[e])return"continue";var c=function(e,t){return e.filter(function(e){return e.cal.regex.test(t)})}(a.state.patterns,a.cached.calendars[e].name);t[e].forEach(function(t){c.forEach(function(a){if(a.event.regex.test(t.summary)){r.hasOwnProperty(e)||(r[e]=0);var c=(t.end-t.start)/6e4;n[a.idx]+=c,r[e]+=c}})})};for(var i in a.cached.calendars)o(i);for(var l=[],s=[],u=0;u<a.state.patterns.length;u++)l.push({name:a.state.patterns[u].name,value:n[u]/60});for(var i in r)s.push({name:a.cached.calendars[i].name,value:r[i]/60,color:a.cached.calendars[i].color.background});a.setState({patternGraphData:l,calendarGraphData:s})})}else alert("Please choose a valid time range.")},a.loadPatterns=function(){var e=a.state.token,t=e.then(L).then(function(e){return e.calendar}),n=e.then(U);Promise.all([t,n]).then(function(e){var t=Object(i.a)(e,2),n=t[0],r=t[1];r.forEach(function(e){a.cached.calendars[e.id]={name:e.summary,color:n[e.colorId],cal:new $(e.id,e.summary)}}),a.setState({patterns:r.map(function(e,t){return new J(e.summary,t,new H(e.id,!1,e.summary,e.summary),H.anyPattern())})})})},a}return Object(m.a)(t,e),Object(u.a)(t,[{key:"render",value:function(){var e=this,t=this.props.classes;return r.a.createElement(f.MuiThemeProvider,{theme:Te},r.a.createElement("div",{className:t.root},r.a.createElement(b.a,{position:"absolute",className:t.appBar},r.a.createElement(x.a,{className:t.toolbar},r.a.createElement(S.a,{component:"h1",variant:"h6",color:"inherit",noWrap:!0,className:t.title},r.a.createElement(A,{style:{width:"2em",verticalAlign:"bottom",marginRight:"0.2em"}}),"Chromicle"))),r.a.createElement("main",{className:t.content},r.a.createElement("div",{className:t.appBarSpacer}),r.a.createElement(B.a,{container:!0,spacing:16},r.a.createElement(E.a,null),r.a.createElement(B.a,{item:!0,md:6,xs:12},r.a.createElement(O.a,{fullWidth:!0},r.a.createElement(R.a,null,r.a.createElement(S.a,{variant:"h6",component:"h1",gutterBottom:!0},"Event Patterns",r.a.createElement(K.a,{style:{marginBottom:"0.12em",marginLeft:"0.5em"},onClick:function(){return e.newPattern()}},r.a.createElement(I.a,null))),r.a.createElement(Oe,{patterns:this.state.patterns,cached:this.cached,onRemovePattern:this.removePattern,onUpdatePattern:this.updatePattern})),r.a.createElement(R.a,null,r.a.createElement(S.a,{variant:"h6",component:"h1",gutterBottom:!0},"Time Range"),r.a.createElement("div",{style:{textAlign:"center"}},r.a.createElement(p.DateRangePicker,{startDate:this.state.startDate,startDateId:"start_date_id",endDate:this.state.endDate,endDateId:"end_date_id",onDatesChange:function(t){var a=t.startDate,n=t.endDate;e.setState({startDate:a,endDate:n})},focusedInput:this.state.focusedInput,onFocusChange:function(t){return e.setState({focusedInput:t})},isOutsideRange:function(){return!1}}))),r.a.createElement("div",{className:t.buttonSpacer}),r.a.createElement(B.a,{container:!0,spacing:16},r.a.createElement(B.a,{item:!0,md:6,xs:12},r.a.createElement(R.a,null,r.a.createElement(C.a,{variant:"contained",color:"primary",onClick:this.loadPatterns},"Load"))),r.a.createElement(B.a,{item:!0,md:6,xs:12},r.a.createElement(R.a,null,r.a.createElement(C.a,{variant:"contained",color:"primary",onClick:this.analyze},"Analyze")))))),r.a.createElement(B.a,{item:!0,md:6,xs:12},r.a.createElement(S.a,{variant:"h6",component:"h1",gutterBottom:!0},"Graph"),r.a.createElement(te,{patternGraphData:this.state.patternGraphData,calendarGraphData:this.state.calendarGraphData}))))))}}]),t}(r.a.Component),Ne=Object(f.withStyles)(function(e){return{root:{display:"flex",height:"100vh"},appBar:{zIndex:e.zIndex.drawer+1,transition:e.transitions.create(["width","margin"],{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen})},title:{flexGrow:1},sectionTitle:{flex:"0 0 auto"},appBarSpacer:e.mixins.toolbar,content:{flexGrow:1,padding:3*e.spacing.unit,overflow:"auto"},buttonSpacer:{marginBottom:4*e.spacing.unit},fab:{margin:e.spacing.unit}}})(Re);Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));o.a.render(r.a.createElement(Ne,null),document.getElementById("root")),"serviceWorker"in navigator&&navigator.serviceWorker.ready.then(function(e){e.unregister()})}},[[308,2,1]]]);
-//# sourceMappingURL=main.36efdf67.chunk.js.map \ No newline at end of file
+(window.webpackJsonp=window.webpackJsonp||[]).push([[0],{308:function(e,t,a){e.exports=a(655)},655:function(e,t,a){"use strict";a.r(t);var n=a(1),r=a.n(n),c=a(28),o=a.n(c),i=a(137),l=a(101),s=a(39),u=a(45),h=a(78),d=a(74),m=a(79),p=(a(313),a(315),a(341),a(286)),f=a(31),v=a(99),g=a.n(v),y=a(306),E=a.n(y),w=a(305),b=a.n(w),P=a(173),x=a.n(P),k=a(81),S=a.n(k),T=a(177),C=a.n(T),D=a(93),O=a.n(D),j=a(103),R=a.n(j),N=a(40),B=a.n(N),G=a(307),I=a.n(G),W=a(174),K=a.n(W),A=function(e){return r.a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 98.905998 93.557997",version:"1.1",style:e.style},r.a.createElement("g",{id:"g13",transform:"translate(-153.533,-203.047)"},r.a.createElement("g",{id:"g29"},r.a.createElement("g",{id:"g27"},r.a.createElement("polygon",{id:"polygon7",points:"252.439,241.924 234.556,288.703 185.103,296.605 153.533,257.728 171.416,210.949 220.869,203.047 ",style:{fill:"#ff8000"}}),r.a.createElement("g",{id:"g11",transform:"translate(167.24355,224.20734)"},r.a.createElement("text",{id:"text9",style:{fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",fontStretch:"normal",fontSize:75,fontFamily:"TypoPRO Fantasque Sans Mono",fill:"#ffeade"},transform:"translate(0.586,49.072)"},"Cr"))))))},_="https://www.googleapis.com/calendar/v3",M={invalidSyncToken:1,otherError:2};function z(e){return Object.entries(e).map(function(e){var t=Object(i.a)(e,2),a=t[0],n=t[1];return"".concat(encodeURIComponent(a),"=").concat(encodeURIComponent(n))}).join("&")}function F(){return new Promise(function(e){return chrome.identity.getAuthToken({interactive:!0},function(t){return e(t)})})}function U(e){return fetch("".concat(_,"/users/me/calendarList?").concat(z({access_token:e})),{method:"GET",async:!0}).then(function(e){return e.json()}).then(function(e){return e.items})}function L(e){return fetch("".concat(_,"/colors?").concat(z({access_token:e})),{method:"GET",async:!0}).then(function(e){return e.json()})}var $=function(){function e(t,a){Object(s.a)(this,e),this.calId=t,this.name=a,this.token=F(),this.syncToken="",this.cache={}}return Object(u.a)(e,[{key:"getSlot",value:function(e){return this.cache[e]||(this.cache[e]={}),this.cache[e]}},{key:"addEvent",value:function(t){var a=e.dateToCacheKey(t.start),n=e.dateToCacheKey(new Date(t.end.getTime()-1));if(a===n)this.getSlot(a)[t.id]={start:t.start,end:t.end,id:t.id};else{this.getSlot(a)[t.id]={start:t.start,end:e.slotEndDate(a),id:t.id},this.getSlot(n)[t.id]={start:e.slotStartDate(n),end:t.end,id:t.id};for(var r=a+1;r<n;r++)this.getSlot(r)[t.id]={start:e.slotStartDate(r),end:e.slotEndDate(r),id:t.id}}}},{key:"removeEvent",value:function(t){for(var a=e.dateToCacheKey(t.start),n=e.dateToCacheKey(new Date(t.end.getTime()-1)),r=a;r<=n;r++)delete this.getSlot(r)[t.id]}},{key:"getSlotEvents",value:function(e,t,a){var n=this.getSlot(e),r=[];for(var c in n){if(!(n[c].start>=a||n[c].end<=t))(n[c].start<t?t:n[c].start)>(n[c].end>a?a:n[c].end)&&console.log(n[c],t,a),r.push({id:c,start:n[c].start<t?t:n[c].start,end:n[c].end>a?a:n[c].end})}return r}},{key:"getCachedEvents",value:function(t,a){for(var n=e.dateToCacheKey(t),r=e.dateToCacheKey(new Date(a.getTime()-1)),c=this.getSlotEvents(n,t,a),o=n+1;o<r;o++){var i=this.getSlot(o);for(var s in i)c.push(i[s])}return r>n&&c.push.apply(c,Object(l.a)(this.getSlotEvents(r,t,a))),c}},{key:"sync",value:function(){var e=this;return this.token.then(function(t){return function(e,t,a){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:100,r=[];return function a(c,o){return fetch("".concat(_,"/calendars/").concat(e,"/events?").concat(z({access_token:t,pageToken:c,syncToken:o,maxResults:n})),{method:"GET",async:!0}).then(function(e){if(200===e.status)return e.json();throw 410==e.status?M.invalidSyncToken:M.otherErrors}).then(function(e){return r.push.apply(r,Object(l.a)(e.items)),e.nextPageToken?a(e.nextPageToken,""):{nextSyncToken:e.nextSyncToken,results:r}})}("",a)}(e.calId,t,e.syncToken).then(function(a){e.syncToken=a.nextSyncToken;var n=a.results.map(function(a){return a.start?Promise.resolve(a):function(e,t,a){return fetch("".concat(_,"/calendars/").concat(e,"/events/").concat(t,"?").concat(z({access_token:a})),{method:"GET",async:!0}).then(function(e){return e.json()})}(e.calId,a.id,t)});return Promise.all(n).then(function(t){return t.forEach(function(t){t.start=new Date(t.start.dateTime),t.end=new Date(t.end.dateTime),"confirmed"===t.status?e.addEvent(t):"cancelled"===t.status&&e.removeEvent(t)})})})}).catch(function(t){if(t!=M.invalidSyncToken)throw t;e.syncToken="",e.sync()})}},{key:"getEvents",value:function(e,t){var a=this;return this.sync().then(function(){return a.getCachedEvents(e,t)})}}],[{key:"dateToCacheKey",value:function(e){return Math.floor(e/864e5)}},{key:"slotStartDate",value:function(e){return new Date(864e5*e)}},{key:"slotEndDate",value:function(e){return new Date(864e5*(e+1))}}]),e}(),H=function(){function e(t,a,n,r){Object(s.a)(this,e),this.id=t,this.isRegex=a,this.value=n,this.label=r}return Object(u.a)(e,[{key:"regex",get:function(){return new RegExp(this.isRegex?this.value:"^".concat(this.value,"$"))}},{key:"isEmpty",get:function(){return null===this.label}}]),e}();H.emptyPattern=function(){return new H(0,!0,"",null)},H.anyPattern=function(){return new H("any",!0,".*","Any")};var J=function e(t,a,n,r){Object(s.a)(this,e),this.name=t,this.idx=a,this.cal=n,this.event=r};J.defaultPatternEntry=function(e){return new J("",e,H.emptyPattern(),H.anyPattern())};var V=a(299),q=a.n(V),X=a(659),Y=a(657),Q=a(656),Z=a(554);function ee(e){var t=e.cx,a=e.cy,n=e.x,c=e.y,o=e.fill,i=e.name,l="middle",s=0,u=0;return n<t-2?(s=-5,l="end"):n>t+2&&(s=5,l="start"),c<a-2?u=-5:c>a+2&&(u=10),r.a.createElement("text",{x:n,y:c,dx:s,dy:u,fill:o,textAnchor:l},"".concat(i))}var te=Object(f.withStyles)(function(e){return{pieChart:{margin:"0 auto"}}})(function(e){return r.a.createElement(B.a,{container:!0,spacing:0},r.a.createElement(B.a,{item:!0,xs:12,lg:6},r.a.createElement("div",{className:e.classes.patternTableWrapper},r.a.createElement(X.a,{width:400,height:250,className:e.classes.pieChart},r.a.createElement(Y.a,{data:e.patternGraphData,dataKey:"value",cx:200,cy:125,outerRadius:60,fill:q.a[300],label:ee}),r.a.createElement(Q.a,{formatter:function(e){return"".concat(e.toFixed(2)," hr")}})))),r.a.createElement(B.a,{item:!0,xs:12,lg:6},r.a.createElement("div",{className:e.classes.patternTableWrapper},r.a.createElement(X.a,{width:400,height:250,className:e.classes.pieChart},r.a.createElement(Y.a,{data:e.calendarGraphData,dataKey:"value",cx:200,cy:125,innerRadius:40,outerRadius:70,fill:g.a[300],label:ee},e.calendarGraphData.map(function(e,t){return r.a.createElement(Z.a,{key:t,fill:e.color})})),r.a.createElement(Q.a,{formatter:function(e){return"".concat(e.toFixed(2)," hr")}})))))}),ae=a(136),ne=a.n(ae),re=a(301),ce=a.n(re),oe=a(303),ie=a.n(oe),le=a(140),se=a.n(le),ue=a(100),he=a.n(ue),de=a(302),me=a.n(de),pe=a(304),fe=a.n(pe),ve=a(300),ge=a.n(ve),ye=a(131),Ee=a.n(ye),we=a(172),be=a.n(we),Pe=function(e){function t(){return Object(s.a)(this,t),Object(h.a)(this,Object(d.a)(t).apply(this,arguments))}return Object(m.a)(t,e),Object(u.a)(t,[{key:"render",value:function(){var e=this,t=this.props.classes,a=[],n=this.props.options,c=new H.emptyPattern;for(var o in n[c.id]=c,n){var i=n[o].isEmpty?r.a.createElement("span",{style:{color:this.props.theme.palette.primary.dark}},"Custom"):n[o].label;a.push(r.a.createElement(be.a,{key:o,value:o},i))}var l=this.props.value.isRegex?t.fieldRegex:t.fieldNoRegex;return r.a.createElement(O.a,null,r.a.createElement("span",null,r.a.createElement(Ee.a,{value:this.props.value.id,onChange:function(t){var a;a=null==n[t.target.value].label?new H(0,!0,e.props.value.isRegex?e.props.value.value:"^".concat(e.props.value.value,"$"),null):n[t.target.value],e.props.onChange({target:{value:a}})},className:l},a),null==this.props.value.label&&r.a.createElement(ne.a,{value:this.props.value.value,onChange:function(t){return e.props.onChange({target:{value:new H(0,!0,t.target.value,null)}})}})))}}]),t}(r.a.Component),xe=Object(f.withStyles)(function(e){return{fieldNoRegex:{width:200},fieldRegex:{marginRight:"0.5em"}}})(Pe);var ke=a(139),Se=a.n(ke),Te=Object(f.createMuiTheme)({palette:{primary:{light:Se.a[300],main:Se.a[500],dark:Se.a[700],contrastText:"#fff"}},typography:{useNextVariants:!0}}),Ce=[{label:"Name",field:"name",elem:ne.a},{label:"Calendar",field:"cal",elem:Object(f.withTheme)(Te)(function(e){var t={};for(var a in e.cached.calendars)t[a]=new H(a,!1,e.cached.calendars[a].name,e.cached.calendars[a].name);return r.a.createElement(xe,{value:e.value,options:t,onChange:e.onChange,theme:e.theme})})},{label:"Event",field:"event",elem:Object(f.withTheme)(Te)(function(e){var t=H.anyPattern(),a={};return a[t.id]=t,r.a.createElement(xe,{value:e.value,options:a,onChange:e.onChange,theme:e.theme})})}],De=function(e){function t(){var e,a;Object(s.a)(this,t);for(var n=arguments.length,r=new Array(n),c=0;c<n;c++)r[c]=arguments[c];return(a=Object(h.a)(this,(e=Object(d.a)(t)).call.apply(e,[this].concat(r)))).state={page:0,rowsPerPage:5},a.handleChangePage=function(e,t){a.setState({page:t})},a.handleChangeRowsPerPage=function(e){a.setState({rowsPerPage:e.target.value})},a}return Object(m.a)(t,e),Object(u.a)(t,[{key:"render",value:function(){var e=this,t=this.props,a=t.classes,n=t.cached,c=t.patterns,o=this.state,i=o.rowsPerPage,l=o.page,s=i-Math.min(i,c.length-l*i),u=c.slice(l*i,(l+1)*i).map(function(t){return r.a.createElement(se.a,{onMouseOver:function(){return e.setState({activePattern:t.idx})},onMouseOut:function(){return e.setState({activePattern:null})}},Ce.map(function(a){var c=a.elem;return r.a.createElement(he.a,null,r.a.createElement(c,{value:t[a.field],cached:n,onChange:function(n){return e.props.onUpdatePattern(a.field,t.idx,n.target.value)}}))}),r.a.createElement("span",{className:e.state.activePattern===t.idx?a.deleteButtonShow:a.deleteButtonHide},r.a.createElement(ge.a,{className:a.deleteIcon,onClick:function(){return e.props.onRemovePattern(t.idx)}})))});return r.a.createElement("div",null,r.a.createElement("div",{className:a.patternTableWrapper},r.a.createElement(ce.a,{className:a.patternTable},r.a.createElement(me.a,null,r.a.createElement(se.a,null,Ce.map(function(e,t){return r.a.createElement(he.a,{key:t},e.label)}))),r.a.createElement(ie.a,null,u,s>0&&r.a.createElement(se.a,{style:{height:48*s}},r.a.createElement(he.a,{colSpan:Ce.length}))))),r.a.createElement(fe.a,{rowsPerPageOptions:[5,10,25],component:"div",count:c.length,rowsPerPage:i,page:l,backIconButtonProps:{"aria-label":"Previous Page"},nextIconButtonProps:{"aria-label":"Next Page"},onChangePage:this.handleChangePage,onChangeRowsPerPage:this.handleChangeRowsPerPage}))}}]),t}(r.a.Component),Oe=Object(f.withStyles)(function(e){return{deleteButtonShow:{position:"absolute",right:0,height:48},deleteButtonHide:{display:"none"},deleteIcon:{height:"100%",cursor:"pointer"},patternTableWrapper:{overflowX:"auto",overflowY:"hidden"},patternTable:{minWidth:600}}})(De),je=[{name:"Work",value:10,color:g.a[300]},{name:"Wasted",value:10,color:g.a[300]}];var Re=function(e){function t(){var e,a;Object(s.a)(this,t);for(var n=arguments.length,r=new Array(n),c=0;c<n;c++)r[c]=arguments[c];return(a=Object(h.a)(this,(e=Object(d.a)(t)).call.apply(e,[this].concat(r)))).state={patterns:[],timeRange:null,token:F(),patternGraphData:je,calendarGraphData:je,activePattern:null},a.cached={calendars:{}},a.updatePattern=function(e,t,n){var r=a.state.patterns;r[t][e]=n,a.setState({patterns:r})},a.removePattern=function(e){var t=a.state.patterns;t.splice(e,1);for(var n=0;n<t.length;n++)t[n].idx=n;a.setState({patterns:t})},a.newPattern=function(){for(var e=[J.defaultPatternEntry()].concat(Object(l.a)(a.state.patterns)),t=1;t<e.length;t++)e[t].idx=t;a.setState({patterns:e})},a.analyze=function(){if(a.state.startDate&&a.state.endDate){var e=a.state.startDate.startOf("day").toDate(),t=a.state.endDate.startOf("day").toDate();console.log(e,t);var n=[],r=function(r){n.push(a.cached.calendars[r].cal.getEvents(e,t).then(function(e){return{id:r,events:e}}).catch(function(e){return console.log("cannot load calendar ".concat(r)),{id:r,events:[]}}))};for(var c in a.cached.calendars)r(c);Promise.all(n).then(function(e){var t={},n={},r={};e.forEach(function(e){return t[e.id]=e.events});for(var c=0;c<a.state.patterns.length;c++)n[c]=0;var o=function(e){if(!t[e])return"continue";var c=function(e,t){return e.filter(function(e){return e.cal.regex.test(t)})}(a.state.patterns,a.cached.calendars[e].name);t[e].forEach(function(t){c.forEach(function(a){if(a.event.regex.test(t.summary)){r.hasOwnProperty(e)||(r[e]=0);var c=(t.end-t.start)/6e4;n[a.idx]+=c,r[e]+=c}})})};for(var i in a.cached.calendars)o(i);for(var l=[],s=[],u=0;u<a.state.patterns.length;u++)l.push({name:a.state.patterns[u].name,value:n[u]/60});for(var i in r)s.push({name:a.cached.calendars[i].name,value:r[i]/60,color:a.cached.calendars[i].color.background});a.setState({patternGraphData:l,calendarGraphData:s})})}else alert("Please choose a valid time range.")},a.loadPatterns=function(){var e=a.state.token,t=e.then(L).then(function(e){return e.calendar}),n=e.then(U);Promise.all([t,n]).then(function(e){var t=Object(i.a)(e,2),n=t[0],r=t[1];r.forEach(function(e){a.cached.calendars[e.id]={name:e.summary,color:n[e.colorId],cal:new $(e.id,e.summary)}}),a.setState({patterns:r.map(function(e,t){return new J(e.summary,t,new H(e.id,!1,e.summary,e.summary),H.anyPattern())})})})},a}return Object(m.a)(t,e),Object(u.a)(t,[{key:"render",value:function(){var e=this,t=this.props.classes;return r.a.createElement(f.MuiThemeProvider,{theme:Te},r.a.createElement("div",{className:t.root},r.a.createElement(b.a,{position:"absolute",className:t.appBar},r.a.createElement(x.a,{className:t.toolbar},r.a.createElement(S.a,{component:"h1",variant:"h6",color:"inherit",noWrap:!0,className:t.title},r.a.createElement(A,{style:{width:"2em",verticalAlign:"bottom",marginRight:"0.2em"}}),"Chromicle"))),r.a.createElement("main",{className:t.content},r.a.createElement("div",{className:t.appBarSpacer}),r.a.createElement(B.a,{container:!0,spacing:16},r.a.createElement(E.a,null),r.a.createElement(B.a,{item:!0,md:6,xs:12},r.a.createElement(O.a,{fullWidth:!0},r.a.createElement(R.a,null,r.a.createElement(S.a,{variant:"h6",component:"h1",gutterBottom:!0},"Event Patterns",r.a.createElement(K.a,{style:{marginBottom:"0.12em",marginLeft:"0.5em"},onClick:function(){return e.newPattern()}},r.a.createElement(I.a,null))),r.a.createElement(Oe,{patterns:this.state.patterns,cached:this.cached,onRemovePattern:this.removePattern,onUpdatePattern:this.updatePattern})),r.a.createElement(R.a,null,r.a.createElement(S.a,{variant:"h6",component:"h1",gutterBottom:!0},"Time Range"),r.a.createElement("div",{style:{textAlign:"center"}},r.a.createElement(p.DateRangePicker,{startDate:this.state.startDate,startDateId:"start_date_id",endDate:this.state.endDate,endDateId:"end_date_id",onDatesChange:function(t){var a=t.startDate,n=t.endDate;e.setState({startDate:a,endDate:n})},focusedInput:this.state.focusedInput,onFocusChange:function(t){return e.setState({focusedInput:t})},isOutsideRange:function(){return!1}}))),r.a.createElement("div",{className:t.buttonSpacer}),r.a.createElement(B.a,{container:!0,spacing:16},r.a.createElement(B.a,{item:!0,md:6,xs:12},r.a.createElement(R.a,null,r.a.createElement(C.a,{variant:"contained",color:"primary",onClick:this.loadPatterns},"Load"))),r.a.createElement(B.a,{item:!0,md:6,xs:12},r.a.createElement(R.a,null,r.a.createElement(C.a,{variant:"contained",color:"primary",onClick:this.analyze},"Analyze")))))),r.a.createElement(B.a,{item:!0,md:6,xs:12},r.a.createElement(S.a,{variant:"h6",component:"h1",gutterBottom:!0},"Graph"),r.a.createElement(te,{patternGraphData:this.state.patternGraphData,calendarGraphData:this.state.calendarGraphData}))))))}}]),t}(r.a.Component),Ne=Object(f.withStyles)(function(e){return{root:{display:"flex",height:"100vh"},appBar:{zIndex:e.zIndex.drawer+1,transition:e.transitions.create(["width","margin"],{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen})},title:{flexGrow:1},sectionTitle:{flex:"0 0 auto"},appBarSpacer:e.mixins.toolbar,content:{flexGrow:1,padding:3*e.spacing.unit,overflow:"auto"},buttonSpacer:{marginBottom:4*e.spacing.unit},fab:{margin:e.spacing.unit}}})(Re);Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));o.a.render(r.a.createElement(Ne,null),document.getElementById("root")),"serviceWorker"in navigator&&navigator.serviceWorker.ready.then(function(e){e.unregister()})}},[[308,2,1]]]);
+//# sourceMappingURL=main.0c8ec738.chunk.js.map \ No newline at end of file
diff --git a/build/static/js/main.0c8ec738.chunk.js.map b/build/static/js/main.0c8ec738.chunk.js.map
new file mode 100644
index 0000000..c60958e
--- /dev/null
+++ b/build/static/js/main.0c8ec738.chunk.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["Logo.js","gapi.js","pattern.js","Chart.js","RegexField.js","theme.js","PatternTable.js","App.js","serviceWorker.js","index.js"],"names":["Logo","props","react_default","a","createElement","xmlns","viewBox","version","style","id","transform","points","fill","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontFamily","gapi_base","GApiError","invalidSyncToken","otherError","to_params","dict","Object","entries","map","_ref","_ref2","slicedToArray","k","v","concat","encodeURIComponent","join","getAuthToken","Promise","resolver","chrome","identity","interactive","token","getCalendars","fetch","access_token","method","async","then","response","json","data","items","getColors","GCalendar","calId","name","classCallCheck","this","syncToken","cache","createClass","key","value","e","ks","dateToCacheKey","start","ke","Date","end","getTime","getSlot","slotEndDate","slotStartDate","s","results","console","log","push","getSlotEvents","apply","toConsumableArray","_this","resultsPerRequest","arguments","length","undefined","singleFetch","pageToken","maxResults","status","otherErrors","nextPageToken","nextSyncToken","getEvents","r","pm_results","resolve","eventId","getEvent","all","forEach","dateTime","addEvent","removeEvent","catch","sync","_this2","getCachedEvents","date","Math","floor","Pattern","isRegex","label","get","RegExp","emptyPattern","anyPattern","PatternEntry","idx","calPattern","eventPattern","cal","event","defaultPatternEntry","customizedLabel","cx","cy","x","y","anchor","dx","dy","textAnchor","withStyles","theme","pieChart","margin","Grid_default","container","spacing","item","xs","lg","className","classes","patternTableWrapper","PieChart","width","height","Pie","patternGraphData","dataKey","outerRadius","deepOrange","Tooltip","formatter","toFixed","calendarGraphData","innerRadius","cyan","d","i","Cell","color","RegexField","pitems","options","p0","isEmpty","palette","primary","dark","MenuItem_default","fieldRegex","fieldNoRegex","FormControl_default","Select_default","onChange","target","TextField_default","React","Component","RegexFieldWithStyles","marginRight","createMuiTheme","light","orange","main","contrastText","typography","useNextVariants","patternHead","field","elem","TextField","withTheme","cached","calendars","any","PatternTable","state","page","rowsPerPage","handleChangePage","setState","handleChangeRowsPerPage","_this$props","patterns","_this$state","nDummy","min","rows","slice","p","TableRow_default","onMouseOver","activePattern","onMouseOut","CustomText","TableCell_default","onUpdatePattern","deleteButtonShow","deleteButtonHide","DeleteOutlined_default","deleteIcon","onClick","onRemovePattern","Table_default","patternTable","TableHead_default","TableBody_default","colSpan","TablePagination_default","rowsPerPageOptions","component","count","backIconButtonProps","aria-label","nextIconButtonProps","onChangePage","onChangeRowsPerPage","position","right","display","cursor","overflowX","overflowY","minWidth","default_chart_data","Dashboard","timeRange","gapi","updatePattern","removePattern","splice","newPattern","analyze","startDate","endDate","startOf","toDate","event_pms","_loop","events","all_events","cal_results","_loop2","calName","filter","regex","test","filterPatterns","summary","hasOwnProperty","duration","background","alert","loadPatterns","colors","calendar","cals","colorId","styles","root","AppBar_default","appBar","Toolbar_default","toolbar","Typography_default","variant","noWrap","title","verticalAlign","content","appBarSpacer","CssBaseline_default","md","fullWidth","FormGroup_default","gutterBottom","IconButton_default","marginBottom","marginLeft","AddCircle_default","src_PatternTable","textAlign","react_dates","startDateId","endDateId","onDatesChange","_ref3","focusedInput","onFocusChange","isOutsideRange","buttonSpacer","Button_default","Chart","zIndex","drawer","transition","transitions","create","easing","sharp","leavingScreen","flexGrow","sectionTitle","flex","mixins","padding","unit","overflow","fab","Boolean","window","location","hostname","match","ReactDOM","render","App","document","getElementById","navigator","serviceWorker","ready","registration","unregister"],"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AAAC,GAAK,MAAK,CACrBqJ,KAAM,CACFxC,QAAS,OACT/F,OAAQ,SAEZyI,OAAQ,CACJgC,OAAQvL,EAAMuL,OAAOC,OAAS,EAC9BC,WAAYzL,EAAM0L,YAAYC,OAAO,CAAC,QAAS,UAAW,CACtDC,OAAQ5L,EAAM0L,YAAYE,OAAOC,MACjCjD,SAAU5I,EAAM0L,YAAY9C,SAASkD,iBAG7CjC,MAAO,CACHkC,SAAU,GAEdC,aAAc,CACVC,KAAM,YAEVjC,aAAchK,EAAMkM,OAAOzC,QAC3BM,QAAS,CACLgC,SAAU,EACVI,QAA8B,EAArBnM,EAAMK,QAAQ+L,KACvBC,SAAU,QAEdjB,aAAc,CACVb,aAAmC,EAArBvK,EAAMK,QAAQ+L,MAEhCE,IAAK,CACDpM,OAAQF,EAAMK,QAAQ+L,QA0MfrM,CAAmBoH,IC9PdoF,QACW,cAA7BC,OAAOC,SAASC,UAEe,UAA7BF,OAAOC,SAASC,UAEhBF,OAAOC,SAASC,SAASC,MACvB,2DCbNC,IAASC,OAAOpV,EAAAC,EAAAC,cAACmV,GAAD,MAASC,SAASC,eAAe,SD4H3C,kBAAmBC,WACrBA,UAAUC,cAAcC,MAAM5S,KAAK,SAAA6S,GACjCA,EAAaC","file":"static/js/main.0c8ec738.chunk.js","sourcesContent":["import React from 'react';\nexport default (props) =>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 98.905998 93.557997\"\n version=\"1.1\"\n style={props.style}>\n <g id=\"g13\"\n transform=\"translate(-153.533,-203.047)\">\n <g id=\"g29\">\n <g\n id=\"g27\">\n <polygon\n id=\"polygon7\"\n points=\"252.439,241.924 234.556,288.703 185.103,296.605 153.533,257.728 171.416,210.949 220.869,203.047 \"\n style={{fill: '#ff8000'}} />\n <g\n id=\"g11\"\n transform=\"translate(167.24355,224.20734)\">\n <text\n id=\"text9\"\n style={{fontStyle:'normal',\n fontVariant:'normal',\n fontWeight:'normal',\n fontStretch:'normal',\n fontSize:75,\n fontFamily:'TypoPRO Fantasque Sans Mono',\n fill:'#ffeade'}}\n transform=\"translate(0.586,49.072)\">Cr</text>\n </g>\n </g>\n </g>\n </g>\n </svg>\n","/* global chrome */\nconst gapi_base = 'https://www.googleapis.com/calendar/v3';\n\nconst GApiError = {\n invalidSyncToken: 1,\n otherError: 2,\n};\n\nfunction to_params(dict) {\n return Object.entries(dict).map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`).join('&');\n}\n\nexport function getAuthToken() {\n return new Promise(resolver =>\n chrome.identity.getAuthToken(\n {interactive: true}, token => resolver(token)));\n}\n\nexport function getCalendars(token) {\n return fetch(`${gapi_base}/users/me/calendarList?${to_params({access_token: token})}`,\n { method: 'GET', async: true })\n .then(response => response.json())\n .then(data => data.items);\n}\n\nexport function getColors(token) {\n return fetch(`${gapi_base}/colors?${to_params({access_token: token})}`,\n { method: 'GET', async: true })\n .then(response => response.json());\n}\n\nfunction getEvent(calId, eventId, token) {\n return fetch(`${gapi_base}/calendars/${calId}/events/${eventId}?${to_params({access_token: token})}`,\n { method: 'GET', async: true })\n .then(response => response.json());\n}\n\nfunction getEvents(calId, token, syncToken, resultsPerRequest=100) {\n let results = [];\n const singleFetch = (pageToken, syncToken) => fetch(`${gapi_base}/calendars/${calId}/events?${to_params({\n access_token: token,\n pageToken,\n syncToken,\n maxResults: resultsPerRequest\n })}`, { method: 'GET', async: true })\n .then(response => {\n if (response.status === 200)\n return response.json();\n else if (response.status == 410)\n throw GApiError.invalidSyncToken;\n else throw GApiError.otherErrors;\n })\n .then(data => {\n results.push(...data.items);\n if (data.nextPageToken) {\n return singleFetch(data.nextPageToken, '');\n } else {\n return ({\n nextSyncToken: data.nextSyncToken,\n results\n });\n }\n })\n\n return singleFetch('', syncToken);\n}\n\nexport class GCalendar {\n constructor(calId, name) {\n this.calId = calId;\n this.name = name;\n this.token = getAuthToken();\n this.syncToken = '';\n this.cache = {};\n }\n\n static dateToCacheKey(date) {\n return Math.floor(date / 8.64e7);\n }\n\n getSlot(k) {\n if (!this.cache[k])\n this.cache[k] = {};\n return this.cache[k];\n }\n\n static slotStartDate(k) { return new Date(k * 8.64e7); }\n static slotEndDate(k) { return new Date((k + 1) * 8.64e7); }\n\n addEvent(e) {\n let ks = GCalendar.dateToCacheKey(e.start);\n let ke = GCalendar.dateToCacheKey(new Date(e.end.getTime() - 1));\n if (ks === ke)\n this.getSlot(ks)[e.id] = {\n start: e.start,\n end: e.end,\n id: e.id };\n else\n {\n this.getSlot(ks)[e.id] = {\n start: e.start,\n end: GCalendar.slotEndDate(ks),\n id: e.id };\n this.getSlot(ke)[e.id] = {\n start: GCalendar.slotStartDate(ke),\n end: e.end,\n id: e.id };\n for (let k = ks + 1; k < ke; k++)\n this.getSlot(k)[e.id] = {\n start: GCalendar.slotStartDate(k),\n end: GCalendar.slotEndDate(k),\n id: e.id };\n }\n }\n\n removeEvent(e) {\n let ks = GCalendar.dateToCacheKey(e.start);\n let ke = GCalendar.dateToCacheKey(new Date(e.end.getTime() - 1));\n for (let k = ks; k <= ke; k++)\n delete this.getSlot(k)[e.id];\n }\n\n getSlotEvents(k, start, end) {\n let s = this.getSlot(k);\n let results = [];\n for (let id in s) {\n if (!(s[id].start >= end || s[id].end <= start))\n {\n let nstart = s[id].start < start ? start: s[id].start;\n let nend = s[id].end > end ? end: s[id].end;\n if (nstart > nend) console.log(s[id], start, end);\n results.push({\n id,\n start: s[id].start < start ? start: s[id].start,\n end: s[id].end > end ? end: s[id].end\n });\n }\n }\n return results;\n }\n\n getCachedEvents(start, end) {\n let ks = GCalendar.dateToCacheKey(start);\n let ke = GCalendar.dateToCacheKey(new Date(end.getTime() - 1));\n let results = this.getSlotEvents(ks, start, end);\n for (let k = ks + 1; k < ke; k++)\n {\n let s = this.getSlot(k);\n for (let id in s)\n results.push(s[id]);\n }\n if (ke > ks)\n results.push(...this.getSlotEvents(ke, start, end));\n return results;\n }\n\n sync() {\n return this.token.then(token => getEvents(this.calId, token, this.syncToken).then(r => {\n this.syncToken = r.nextSyncToken;\n let pm_results = r.results.map(e => e.start ? Promise.resolve(e) : getEvent(this.calId, e.id, token));\n return Promise.all(pm_results).then(results => results.forEach(e => {\n e.start = new Date(e.start.dateTime);\n e.end = new Date(e.end.dateTime);\n if (e.status === 'confirmed')\n this.addEvent(e);\n else if (e.status === 'cancelled')\n this.removeEvent(e);\n }));\n })).catch(e => {\n if (e == GApiError.invalidSyncToken) {\n this.syncToken = '';\n this.sync();\n } else throw e;\n });\n }\n\n getEvents(start, end) {\n return this.sync().then(() => this.getCachedEvents(start, end));\n }\n}\n","export class Pattern {\n constructor(id, isRegex, value, label) {\n this.id = id;\n this.isRegex = isRegex;\n this.value = value;\n this.label = label;\n }\n\n get regex() { return new RegExp(this.isRegex ? this.value : `^${this.value}$`); }\n get isEmpty() { return this.label === null; }\n static emptyPattern = () => new Pattern(0, true, '', null);\n static anyPattern = () => new Pattern('any', true, '.*', 'Any');\n}\n\nexport class PatternEntry {\n constructor(name, idx, calPattern, eventPattern) {\n this.name = name;\n this.idx = idx;\n this.cal = calPattern;\n this.event = eventPattern;\n }\n\n static defaultPatternEntry = (idx) => new PatternEntry('', idx, Pattern.emptyPattern(), Pattern.anyPattern());\n}\n","import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport Grid from '@material-ui/core/Grid';\nimport deepOrange from '@material-ui/core/colors/deepOrange';\nimport cyan from '@material-ui/core/colors/cyan';\nimport { PieChart, Pie, Cell, Tooltip } from 'recharts';\n\nconst styles = theme => ({\n pieChart: {\n margin: '0 auto',\n }\n});\n\nfunction customizedLabel(props) {\n const {cx, cy, x, y, fill, name} = props;\n let anchor = \"middle\";\n const EPS = 2;\n let dx = 0;\n let dy = 0;\n if (x < cx - EPS) {\n dx = -5;\n anchor = \"end\"\n } else if (x > cx + EPS) {\n dx = 5;\n anchor = \"start\";\n }\n\n if (y < cy - EPS) {\n dy = -5;\n } else if (y > cy + EPS) {\n dy = 10;\n }\n\n return (<text x={x} y={y} dx={dx} dy={dy} fill={fill} textAnchor={anchor}>{`${name}`}</text>);\n}\n\nfunction ChromiclePieChart(props) {\n return (\n <Grid container spacing={0}>\n <Grid item xs={12} lg={6}>\n <div className={props.classes.patternTableWrapper}>\n <PieChart width={400} height={250} className={props.classes.pieChart}>\n <Pie data={props.patternGraphData}\n dataKey='value'\n cx={200}\n cy={125}\n outerRadius={60}\n fill={deepOrange[300]}\n label={customizedLabel}/>\n <Tooltip formatter={(value) => `${value.toFixed(2)} hr`}/>\n </PieChart>\n </div>\n </Grid>\n <Grid item xs={12} lg={6}>\n <div className={props.classes.patternTableWrapper}>\n <PieChart width={400} height={250} className={props.classes.pieChart}>\n <Pie data={props.calendarGraphData}\n dataKey='value'\n cx={200}\n cy={125}\n innerRadius={40}\n outerRadius={70}\n fill={cyan[300]}\n label={customizedLabel}>\n {props.calendarGraphData.map((d, i) => <Cell key={i} fill={d.color}/>)}\n </Pie>\n <Tooltip formatter={(value) => `${value.toFixed(2)} hr`}/>\n </PieChart>\n </div>\n </Grid>\n </Grid>);\n}\n\nChromiclePieChart.propTypes = {\n patternGraphData: PropTypes.array.isRequired,\n calendarGraphData: PropTypes.array.isRequired,\n};\n\nexport default withStyles(styles)(ChromiclePieChart);\n","import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport Select from '@material-ui/core/Select';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport TextField from '@material-ui/core/TextField';\nimport FormControl from '@material-ui/core/FormControl';\nimport { Pattern } from './pattern';\n\nconst styles = theme => ({\n fieldNoRegex: {\n width: 200\n },\n fieldRegex: {\n marginRight: '0.5em'\n }\n});\n\nclass RegexField extends React.Component {\n render() {\n const { classes } = this.props;\n let items = [];\n var pitems = this.props.options;\n const p0 = new Pattern.emptyPattern();\n pitems[p0.id] = p0;\n for (let id in pitems)\n {\n const label = !pitems[id].isEmpty ? pitems[id].label :\n <span style={{color: this.props.theme.palette.primary.dark}}>Custom</span>;\n items.push(<MenuItem key={id} value={id}>{label}</MenuItem>);\n }\n const selectOnClick = event => {\n let value;\n if (pitems[event.target.value].label == null) {\n value = new Pattern(0, true,\n this.props.value.isRegex ?\n this.props.value.value :\n `^${this.props.value.value}$`, null);\n } else {\n value = pitems[event.target.value];\n }\n this.props.onChange({target: {value}});\n };\n\n const regexTextOnChange = event => this.props.onChange({\n target: { value: new Pattern(0, true, event.target.value, null)}});\n\n const className = this.props.value.isRegex ? classes.fieldRegex: classes.fieldNoRegex;\n return (\n <FormControl>\n <span>\n <Select\n value={this.props.value.id}\n onChange={selectOnClick}\n className={className}>{items}\n </Select>\n {this.props.value.label == null && (\n <TextField\n value={this.props.value.value}\n onChange={regexTextOnChange} />\n )}\n </span>\n </FormControl>);\n }\n}\n\nRegexField.propTypes = {\n classes: PropTypes.object.isRequired,\n};\n\nconst RegexFieldWithStyles = withStyles(styles)(RegexField);\n\nexport function CalendarField(props) {\n let options = {};\n for (let id in props.cached.calendars) {\n options[id] = new Pattern(id, false,\n props.cached.calendars[id].name,\n props.cached.calendars[id].name);\n }\n return (\n <RegexFieldWithStyles\n value={props.value}\n options={options}\n onChange={props.onChange}\n theme={props.theme} />);\n}\n\nexport function EventField(props) {\n let any = Pattern.anyPattern();\n let options = {};\n options[any.id] = any;\n return (\n <RegexFieldWithStyles\n value={props.value}\n options={options}\n onChange={props.onChange}\n theme={props.theme} />);\n}\n","import { createMuiTheme } from '@material-ui/core/styles';\nimport orange from '@material-ui/core/colors/orange';\n\nconst theme = createMuiTheme({\n palette: {\n primary: {\n light: orange[300],\n main: orange[500],\n dark: orange[700],\n contrastText: \"#fff\"\n }\n },\n typography: {\n useNextVariants: true,\n }\n});\n\nexport default theme;\n","import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles, withTheme } from '@material-ui/core/styles';\nimport TextField from '@material-ui/core/TextField';\nimport Table from '@material-ui/core/Table';\nimport TableBody from '@material-ui/core/TableBody';\nimport TableRow from '@material-ui/core/TableRow';\nimport TableCell from '@material-ui/core/TableCell';\nimport TableHead from '@material-ui/core/TableHead';\nimport TablePagination from '@material-ui/core/TablePagination';\nimport DeleteOutlinedIcon from '@material-ui/icons/DeleteOutlined';\nimport { CalendarField, EventField } from './RegexField';\nimport theme from './theme';\n\nconst styles = theme => ({\n deleteButtonShow: {\n position: 'absolute',\n right: 0,\n height: 48\n },\n deleteButtonHide: {\n display: 'none'\n },\n deleteIcon: {\n height: '100%',\n cursor: 'pointer'\n },\n patternTableWrapper: {\n overflowX: 'auto',\n overflowY: 'hidden'\n },\n patternTable: {\n minWidth: 600\n }\n});\n\nconst patternHead = [\n {label: \"Name\", field: \"name\", elem: TextField},\n {label: \"Calendar\", field: \"cal\", elem: withTheme(theme)(CalendarField)},\n {label: \"Event\", field: 'event', elem: withTheme(theme)(EventField)}];\n\nclass PatternTable extends React.Component {\n state = {\n page: 0,\n rowsPerPage: 5,\n };\n\n handleChangePage = (event, page) => {\n this.setState({ page });\n }\n\n handleChangeRowsPerPage = event => {\n this.setState({ rowsPerPage: event.target.value });\n }\n\n render() {\n const { classes, cached, patterns } = this.props;\n const { rowsPerPage, page } = this.state;\n const nDummy = rowsPerPage - Math.min(rowsPerPage, patterns.length - page * rowsPerPage);\n let rows = patterns.slice(page * rowsPerPage, (page + 1) * rowsPerPage).map(p => (\n <TableRow\n onMouseOver={() => this.setState({ activePattern: p.idx })}\n onMouseOut={() => this.setState({ activePattern: null })}>\n {\n patternHead.map(s => {\n const CustomText = s.elem;\n return (\n <TableCell>\n <CustomText\n value={p[s.field]}\n cached={cached}\n onChange={event => this.props.onUpdatePattern(s.field, p.idx, event.target.value)}/>\n </TableCell>)})\n }\n <span className={this.state.activePattern === p.idx ? classes.deleteButtonShow : classes.deleteButtonHide}>\n <DeleteOutlinedIcon\n className={classes.deleteIcon}\n onClick={() => this.props.onRemovePattern(p.idx)} />\n </span>\n </TableRow>));\n\n return (\n <div>\n <div className={classes.patternTableWrapper}>\n <Table className={classes.patternTable}>\n <TableHead>\n <TableRow>{patternHead.map((s, i) => (<TableCell key={i}>{s.label}</TableCell>))}</TableRow>\n </TableHead>\n <TableBody>\n {rows}\n {\n nDummy > 0 && (\n <TableRow style={{ height: 48 * nDummy }}>\n <TableCell colSpan={patternHead.length} />\n </TableRow>)\n }\n </TableBody>\n </Table>\n </div>\n <TablePagination\n rowsPerPageOptions={[5, 10, 25]}\n component=\"div\"\n count={patterns.length}\n rowsPerPage={rowsPerPage}\n page={page}\n backIconButtonProps={{'aria-label': 'Previous Page'}}\n nextIconButtonProps={{'aria-label': 'Next Page'}}\n onChangePage={this.handleChangePage}\n onChangeRowsPerPage={this.handleChangeRowsPerPage} />\n </div>);\n }\n}\n\n\nPatternTable.propTypes = {\n classes: PropTypes.object.isRequired,\n patterns: PropTypes.array.isRequired,\n cached: PropTypes.object.isRequired,\n onRemovePattern: PropTypes.func.isRequired,\n onUpdatePattern: PropTypes.func.isRequired,\n};\n\nexport default withStyles(styles)(PatternTable);\n","import React from 'react';\nimport PropTypes from 'prop-types';\nimport 'typeface-roboto';\nimport 'react-dates/initialize';\nimport 'react-dates/lib/css/_datepicker.css';\nimport { DateRangePicker } from 'react-dates';\nimport { withStyles } from '@material-ui/core/styles';\nimport { MuiThemeProvider } from '@material-ui/core/styles';\nimport cyan from '@material-ui/core/colors/cyan';\nimport CssBaseline from '@material-ui/core/CssBaseline';\nimport AppBar from '@material-ui/core/AppBar';\nimport Toolbar from '@material-ui/core/Toolbar';\nimport Typography from '@material-ui/core/Typography';\nimport Button from '@material-ui/core/Button';\nimport FormControl from '@material-ui/core/FormControl';\nimport FormGroup from '@material-ui/core/FormGroup';\nimport Grid from '@material-ui/core/Grid';\nimport AddCircleIcon from '@material-ui/icons/AddCircle';\nimport IconButton from '@material-ui/core/IconButton';\nimport Logo from './Logo';\nimport * as gapi from './gapi';\nimport { Pattern, PatternEntry } from './pattern';\nimport PieChart from './Chart';\nimport PatternTable from './PatternTable';\nimport theme from './theme';\n\nconst default_chart_data = [\n {name: 'Work', value: 10, color: cyan[300]},\n {name: 'Wasted', value: 10, color: cyan[300]}];\n\nfunction filterPatterns(patterns, calName) {\n return patterns.filter(p => {\n return p.cal.regex.test(calName);\n });\n}\n\nconst styles = theme => ({\n root: {\n display: 'flex',\n height: '100vh',\n },\n appBar: {\n zIndex: theme.zIndex.drawer + 1,\n transition: theme.transitions.create(['width', 'margin'], {\n easing: theme.transitions.easing.sharp,\n duration: theme.transitions.duration.leavingScreen,\n }),\n },\n title: {\n flexGrow: 1,\n },\n sectionTitle: {\n flex: '0 0 auto'\n },\n appBarSpacer: theme.mixins.toolbar,\n content: {\n flexGrow: 1,\n padding: theme.spacing.unit * 3,\n overflow: 'auto',\n },\n buttonSpacer: {\n marginBottom: theme.spacing.unit * 4,\n },\n fab: {\n margin: theme.spacing.unit,\n },\n});\n\nclass Dashboard extends React.Component {\n state = {\n patterns: [],\n timeRange: null,\n token: gapi.getAuthToken(),\n patternGraphData: default_chart_data,\n calendarGraphData: default_chart_data,\n activePattern: null\n };\n\n cached = {\n calendars: {}\n };\n\n updatePattern = (field, idx, value) => {\n let patterns = this.state.patterns;\n patterns[idx][field] = value;\n this.setState({ patterns });\n };\n\n removePattern = idx => {\n let patterns = this.state.patterns;\n patterns.splice(idx, 1);\n for (let i = 0; i < patterns.length; i++)\n patterns[i].idx = i;\n this.setState({ patterns });\n };\n\n newPattern = () => {\n let patterns = [PatternEntry.defaultPatternEntry(), ...this.state.patterns];\n for (let i = 1; i < patterns.length; i++)\n patterns[i].idx = i;\n this.setState({ patterns });\n };\n\n analyze = () => {\n if (!(this.state.startDate && this.state.endDate)) {\n alert(\"Please choose a valid time range.\");\n return;\n }\n let start = this.state.startDate.startOf('day').toDate();\n let end = this.state.endDate.startOf('day').toDate();\n console.log(start, end);\n let event_pms = [];\n for (let id in this.cached.calendars)\n event_pms.push(this.cached.calendars[id].cal.getEvents(start, end)\n .then(r => { return { id, events: r }; })\n .catch(e => {\n console.log(`cannot load calendar ${id}`);\n return { id, events: [] };\n }));\n\n Promise.all(event_pms).then(all_events => {\n let events = {};\n let results = {}; // pattern idx => time\n let cal_results = {}; // cal id => time\n all_events.forEach(e => events[e.id] = e.events);\n for (let i = 0; i < this.state.patterns.length; i++)\n results[i] = 0;\n for (let id in this.cached.calendars) {\n if (!events[id]) continue;\n let patterns = filterPatterns(this.state.patterns, this.cached.calendars[id].name);\n events[id].forEach(event => {\n patterns.forEach(p => {\n if (!p.event.regex.test(event.summary)) return;\n if (!cal_results.hasOwnProperty(id)) {\n cal_results[id] = 0;\n }\n let duration = (event.end - event.start) / 60000;\n results[p.idx] += duration;\n cal_results[id] += duration;\n });\n });\n }\n let patternGraphData = [];\n let calendarGraphData = [];\n for (let i = 0; i < this.state.patterns.length; i++) {\n patternGraphData.push({ name: this.state.patterns[i].name, value: results[i] / 60.0 });\n }\n for (let id in cal_results) {\n calendarGraphData.push({\n name: this.cached.calendars[id].name,\n value: (cal_results[id] / 60.0),\n color: this.cached.calendars[id].color.background});\n }\n //console.log(patternGraphData, calendarGraphData);\n this.setState({ patternGraphData, calendarGraphData });\n });\n };\n\n loadPatterns = () => {\n let token = this.state.token;\n let colors = token.then(gapi.getColors).then(color => {\n return color.calendar;\n });\n let cals = token.then(gapi.getCalendars);\n Promise.all([colors, cals]).then(([colors, items]) => {\n items.forEach(item => {\n this.cached.calendars[item.id] = {\n name: item.summary,\n color: colors[item.colorId],\n cal: new gapi.GCalendar(item.id, item.summary)\n };\n });\n this.setState({ patterns: items.map((item, idx) => {\n return new PatternEntry(item.summary, idx,\n new Pattern(item.id, false, item.summary, item.summary),\n Pattern.anyPattern());\n })});\n });\n };\n\n render() {\n const { classes } = this.props;\n\n return (\n <MuiThemeProvider theme={theme}>\n <div className={classes.root}>\n <AppBar\n position=\"absolute\"\n className={classes.appBar}>\n <Toolbar className={classes.toolbar}>\n <Typography component=\"h1\" variant=\"h6\" color=\"inherit\" noWrap className={classes.title}>\n <Logo style={{width: '2em', verticalAlign: 'bottom', marginRight: '0.2em'}}/>Chromicle\n </Typography>\n </Toolbar>\n </AppBar>\n <main className={classes.content}>\n <div className={classes.appBarSpacer} />\n <Grid container spacing={16}>\n <CssBaseline />\n <Grid item md={6} xs={12}>\n <FormControl fullWidth={true}>\n <FormGroup>\n <Typography variant=\"h6\" component=\"h1\" gutterBottom>\n Event Patterns\n <IconButton\n style={{marginBottom: '0.12em', marginLeft: '0.5em'}}\n onClick={() => this.newPattern()}><AddCircleIcon /></IconButton>\n </Typography>\n <PatternTable\n patterns={this.state.patterns}\n cached={this.cached}\n onRemovePattern={this.removePattern}\n onUpdatePattern={this.updatePattern} />\n </FormGroup>\n <FormGroup>\n <Typography variant=\"h6\" component=\"h1\" gutterBottom>\n Time Range\n </Typography>\n <div style={{textAlign: 'center'}}>\n <DateRangePicker\n startDate={this.state.startDate}\n startDateId=\"start_date_id\"\n endDate={this.state.endDate}\n endDateId=\"end_date_id\"\n onDatesChange={({ startDate, endDate }) => {\n this.setState({ startDate, endDate });\n }} \n focusedInput={this.state.focusedInput}\n onFocusChange={focusedInput => this.setState({ focusedInput })}\n isOutsideRange={() => false}/>\n </div>\n </FormGroup>\n <div className={classes.buttonSpacer} />\n <Grid container spacing={16}>\n <Grid item md={6} xs={12}>\n <FormGroup>\n <Button variant=\"contained\" color=\"primary\" onClick={this.loadPatterns}>Load</Button>\n </FormGroup>\n </Grid>\n <Grid item md={6} xs={12}>\n <FormGroup>\n <Button variant=\"contained\" color=\"primary\" onClick={this.analyze}>Analyze</Button>\n </FormGroup>\n </Grid>\n </Grid>\n </FormControl>\n </Grid>\n <Grid item md={6} xs={12}>\n <Typography variant=\"h6\" component=\"h1\" gutterBottom>\n Graph\n </Typography>\n <PieChart\n patternGraphData={this.state.patternGraphData}\n calendarGraphData={this.state.calendarGraphData}/>\n </Grid>\n </Grid>\n </main>\n </div>\n </MuiThemeProvider>);\n }\n}\n\nDashboard.propTypes = {\n classes: PropTypes.object.isRequired,\n};\n\nexport default withStyles(styles)(Dashboard);\n","// This optional code is used to register a service worker.\n// register() is not called by default.\n\n// This lets the app load faster on subsequent visits in production, and gives\n// it offline capabilities. However, it also means that developers (and users)\n// will only see deployed updates on subsequent visits to a page, after all the\n// existing tabs open on the page have been closed, since previously cached\n// resources are updated in the background.\n\n// To learn more about the benefits of this model and instructions on how to\n// opt-in, read http://bit.ly/CRA-PWA\n\nconst isLocalhost = Boolean(\n window.location.hostname === 'localhost' ||\n // [::1] is the IPv6 localhost address.\n window.location.hostname === '[::1]' ||\n // 127.0.0.1/8 is considered localhost for IPv4.\n window.location.hostname.match(\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n )\n);\n\nexport function register(config) {\n if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {\n // The URL constructor is available in all browsers that support SW.\n const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);\n if (publicUrl.origin !== window.location.origin) {\n // Our service worker won't work if PUBLIC_URL is on a different origin\n // from what our page is served on. This might happen if a CDN is used to\n // serve assets; see https://github.com/facebook/create-react-app/issues/2374\n return;\n }\n\n window.addEventListener('load', () => {\n const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;\n\n if (isLocalhost) {\n // This is running on localhost. Let's check if a service worker still exists or not.\n checkValidServiceWorker(swUrl, config);\n\n // Add some additional logging to localhost, pointing developers to the\n // service worker/PWA documentation.\n navigator.serviceWorker.ready.then(() => {\n console.log(\n 'This web app is being served cache-first by a service ' +\n 'worker. To learn more, visit http://bit.ly/CRA-PWA'\n );\n });\n } else {\n // Is not localhost. Just register service worker\n registerValidSW(swUrl, config);\n }\n });\n }\n}\n\nfunction registerValidSW(swUrl, config) {\n navigator.serviceWorker\n .register(swUrl)\n .then(registration => {\n registration.onupdatefound = () => {\n const installingWorker = registration.installing;\n if (installingWorker == null) {\n return;\n }\n installingWorker.onstatechange = () => {\n if (installingWorker.state === 'installed') {\n if (navigator.serviceWorker.controller) {\n // At this point, the updated precached content has been fetched,\n // but the previous service worker will still serve the older\n // content until all client tabs are closed.\n console.log(\n 'New content is available and will be used when all ' +\n 'tabs for this page are closed. See http://bit.ly/CRA-PWA.'\n );\n\n // Execute callback\n if (config && config.onUpdate) {\n config.onUpdate(registration);\n }\n } else {\n // At this point, everything has been precached.\n // It's the perfect time to display a\n // \"Content is cached for offline use.\" message.\n console.log('Content is cached for offline use.');\n\n // Execute callback\n if (config && config.onSuccess) {\n config.onSuccess(registration);\n }\n }\n }\n };\n };\n })\n .catch(error => {\n console.error('Error during service worker registration:', error);\n });\n}\n\nfunction checkValidServiceWorker(swUrl, config) {\n // Check if the service worker can be found. If it can't reload the page.\n fetch(swUrl)\n .then(response => {\n // Ensure service worker exists, and that we really are getting a JS file.\n const contentType = response.headers.get('content-type');\n if (\n response.status === 404 ||\n (contentType != null && contentType.indexOf('javascript') === -1)\n ) {\n // No service worker found. Probably a different app. Reload the page.\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister().then(() => {\n window.location.reload();\n });\n });\n } else {\n // Service worker found. Proceed as normal.\n registerValidSW(swUrl, config);\n }\n })\n .catch(() => {\n console.log(\n 'No internet connection found. App is running in offline mode.'\n );\n });\n}\n\nexport function unregister() {\n if ('serviceWorker' in navigator) {\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister();\n });\n }\n}\n","import React from 'react';\nimport ReactDOM from 'react-dom';\nimport App from './App';\nimport * as serviceWorker from './serviceWorker';\n\nReactDOM.render(<App />, document.getElementById('root'));\n\n// If you want your app to work offline and load faster, you can change\n// unregister() to register() below. Note this comes with some pitfalls.\n// Learn more about service workers: http://bit.ly/CRA-PWA\nserviceWorker.unregister();\n"],"sourceRoot":""} \ No newline at end of file
diff --git a/build/static/js/main.36efdf67.chunk.js.map b/build/static/js/main.36efdf67.chunk.js.map
deleted file mode 100644
index 05283ad..0000000
--- a/build/static/js/main.36efdf67.chunk.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"sources":["Logo.js","gapi.js","pattern.js","Chart.js","RegexField.js","theme.js","PatternTable.js","App.js","serviceWorker.js","index.js"],"names":["Logo","props","react_default","a","createElement","xmlns","viewBox","version","style","id","transform","points","fill","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontFamily","gapi_base","GApiError","invalidSyncToken","otherError","to_params","dict","Object","entries","map","_ref","_ref2","slicedToArray","k","v","concat","encodeURIComponent","join","getAuthToken","Promise","resolver","chrome","identity","interactive","token","getCalendars","fetch","access_token","method","async","then","response","json","data","items","getColors","GCalendar","calId","name","classCallCheck","this","syncToken","cache","createClass","key","value","e","ks","dateToCacheKey","start","ke","Date","end","getTime","getSlot","slotEndDate","slotStartDate","s","results","console","log","push","getSlotEvents","apply","toConsumableArray","_this","resultsPerRequest","arguments","length","undefined","singleFetch","pageToken","maxResults","status","otherErrors","nextPageToken","nextSyncToken","getEvents","r","pm_results","resolve","eventId","getEvent","all","forEach","dateTime","addEvent","removeEvent","catch","sync","_this2","getCachedEvents","date","Math","floor","Pattern","isRegex","label","get","RegExp","emptyPattern","anyPattern","PatternEntry","idx","calPattern","eventPattern","cal","event","defaultPatternEntry","customizedLabel","cx","cy","x","y","anchor","dx","dy","textAnchor","withStyles","theme","pieChart","margin","Grid_default","container","spacing","item","xs","lg","className","classes","patternTableWrapper","PieChart","width","height","Pie","patternGraphData","dataKey","outerRadius","deepOrange","Tooltip","formatter","toFixed","calendarGraphData","innerRadius","cyan","d","i","Cell","color","RegexField","pitems","options","p0","isEmpty","palette","primary","dark","MenuItem_default","fieldRegex","fieldNoRegex","FormControl_default","Select_default","onChange","target","TextField_default","React","Component","RegexFieldWithStyles","marginRight","createMuiTheme","light","orange","main","contrastText","typography","useNextVariants","patternHead","field","elem","TextField","withTheme","cached","calendars","any","PatternTable","state","page","rowsPerPage","handleChangePage","setState","handleChangeRowsPerPage","_this$props","patterns","_this$state","nDummy","min","rows","slice","p","TableRow_default","onMouseOver","activePattern","onMouseOut","CustomText","TableCell_default","onUpdatePattern","deleteButtonShow","deleteButtonHide","DeleteOutlined_default","deleteIcon","onClick","onRemovePattern","Table_default","patternTable","TableHead_default","TableBody_default","colSpan","TablePagination_default","rowsPerPageOptions","component","count","backIconButtonProps","aria-label","nextIconButtonProps","onChangePage","onChangeRowsPerPage","position","right","display","cursor","overflowX","overflowY","minWidth","default_chart_data","Dashboard","timeRange","gapi","updatePattern","removePattern","splice","newPattern","analyze","startDate","endDate","toDate","event_pms","_loop","events","all_events","cal_results","_loop2","calName","filter","regex","test","filterPatterns","summary","hasOwnProperty","duration","background","alert","loadPatterns","colors","calendar","cals","colorId","styles","root","AppBar_default","appBar","Toolbar_default","toolbar","Typography_default","variant","noWrap","title","verticalAlign","content","appBarSpacer","CssBaseline_default","md","fullWidth","FormGroup_default","gutterBottom","IconButton_default","marginBottom","marginLeft","AddCircle_default","src_PatternTable","textAlign","react_dates","startDateId","endDateId","onDatesChange","_ref3","focusedInput","onFocusChange","isOutsideRange","buttonSpacer","Button_default","Chart","zIndex","drawer","transition","transitions","create","easing","sharp","leavingScreen","flexGrow","sectionTitle","flex","mixins","padding","unit","overflow","fab","Boolean","window","location","hostname","match","ReactDOM","render","App","document","getElementById","navigator","serviceWorker","ready","registration","unregister"],"mappings":"gdACeA,EAAA,SAACC,GAAD,OACbC,EAAAC,EAAAC,cAAA,OACGC,MAAM,6BACNC,QAAQ,0BACRC,QAAQ,MACRC,MAAOP,EAAMO,OACdN,EAAAC,EAAAC,cAAA,KAAGK,GAAG,MACHC,UAAU,gCACXR,EAAAC,EAAAC,cAAA,KAAGK,GAAG,OACJP,EAAAC,EAAAC,cAAA,KACGK,GAAG,OACJP,EAAAC,EAAAC,cAAA,WACGK,GAAG,WACHE,OAAO,mGACPH,MAAO,CAACI,KAAM,aACjBV,EAAAC,EAAAC,cAAA,KACGK,GAAG,MACHC,UAAU,kCACXR,EAAAC,EAAAC,cAAA,QACGK,GAAG,QACFD,MAAO,CAACK,UAAU,SACdC,YAAY,SACZC,WAAW,SACXC,YAAY,SACZC,SAAS,GACTC,WAAW,8BACXN,KA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mF,QACW,cAA7BC,OAAOC,SAASC,UAEe,UAA7BF,OAAOC,SAASC,UAEhBF,OAAOC,SAASC,SAASC,MACvB,2DCbNC,IAASC,OAAOnV,EAAAC,EAAAC,cAACkV,GAAD,MAASC,SAASC,eAAe,SD4H3C,kBAAmBC,WACrBA,UAAUC,cAAcC,MAAM3S,KAAK,SAAA4S,GACjCA,EAAaC","file":"static/js/main.36efdf67.chunk.js","sourcesContent":["import React from 'react';\nexport default (props) =>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 98.905998 93.557997\"\n version=\"1.1\"\n style={props.style}>\n <g id=\"g13\"\n transform=\"translate(-153.533,-203.047)\">\n <g id=\"g29\">\n <g\n id=\"g27\">\n <polygon\n id=\"polygon7\"\n points=\"252.439,241.924 234.556,288.703 185.103,296.605 153.533,257.728 171.416,210.949 220.869,203.047 \"\n style={{fill: '#ff8000'}} />\n <g\n id=\"g11\"\n transform=\"translate(167.24355,224.20734)\">\n <text\n id=\"text9\"\n style={{fontStyle:'normal',\n fontVariant:'normal',\n fontWeight:'normal',\n fontStretch:'normal',\n fontSize:75,\n fontFamily:'TypoPRO Fantasque Sans Mono',\n fill:'#ffeade'}}\n transform=\"translate(0.586,49.072)\">Cr</text>\n </g>\n </g>\n </g>\n </g>\n </svg>\n","/* global chrome */\nconst gapi_base = 'https://www.googleapis.com/calendar/v3';\n\nconst GApiError = {\n invalidSyncToken: 1,\n otherError: 2,\n};\n\nfunction to_params(dict) {\n return Object.entries(dict).map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`).join('&');\n}\n\nexport function getAuthToken() {\n return new Promise(resolver =>\n chrome.identity.getAuthToken(\n {interactive: true}, token => resolver(token)));\n}\n\nexport function getCalendars(token) {\n return fetch(`${gapi_base}/users/me/calendarList?${to_params({access_token: token})}`,\n { method: 'GET', async: true })\n .then(response => response.json())\n .then(data => data.items);\n}\n\nexport function getColors(token) {\n return fetch(`${gapi_base}/colors?${to_params({access_token: token})}`,\n { method: 'GET', async: true })\n .then(response => response.json());\n}\n\nfunction getEvent(calId, eventId, token) {\n return fetch(`${gapi_base}/calendars/${calId}/events/${eventId}?${to_params({access_token: token})}`,\n { method: 'GET', async: true })\n .then(response => response.json());\n}\n\nfunction getEvents(calId, token, syncToken, resultsPerRequest=100) {\n let results = [];\n const singleFetch = (pageToken, syncToken) => fetch(`${gapi_base}/calendars/${calId}/events?${to_params({\n access_token: token,\n pageToken,\n syncToken,\n maxResults: resultsPerRequest\n })}`, { method: 'GET', async: true })\n .then(response => {\n if (response.status === 200)\n return response.json();\n else if (response.status == 410)\n throw GApiError.invalidSyncToken;\n else throw GApiError.otherErrors;\n })\n .then(data => {\n results.push(...data.items);\n if (data.nextPageToken) {\n return singleFetch(data.nextPageToken, '');\n } else {\n return ({\n nextSyncToken: data.nextSyncToken,\n results\n });\n }\n })\n\n return singleFetch('', syncToken);\n}\n\nexport class GCalendar {\n constructor(calId, name) {\n this.calId = calId;\n this.name = name;\n this.token = getAuthToken();\n this.syncToken = '';\n this.cache = {};\n }\n\n static dateToCacheKey(date) {\n return Math.floor(date / 8.64e7);\n }\n\n getSlot(k) {\n if (!this.cache[k])\n this.cache[k] = {};\n return this.cache[k];\n }\n\n static slotStartDate(k) { return new Date(k * 8.64e7); }\n static slotEndDate(k) { return new Date((k + 1) * 8.64e7); }\n\n addEvent(e) {\n let ks = GCalendar.dateToCacheKey(e.start);\n let ke = GCalendar.dateToCacheKey(new Date(e.end.getTime() - 1));\n if (ks === ke)\n this.getSlot(ks)[e.id] = {\n start: e.start,\n end: e.end,\n id: e.id };\n else\n {\n this.getSlot(ks)[e.id] = {\n start: e.start,\n end: GCalendar.slotEndDate(ks),\n id: e.id };\n this.getSlot(ke)[e.id] = {\n start: GCalendar.slotStartDate(ke),\n end: e.end,\n id: e.id };\n for (let k = ks + 1; k < ke; k++)\n this.getSlot(k)[e.id] = {\n start: GCalendar.slotStartDate(k),\n end: GCalendar.slotEndDate(k),\n id: e.id };\n }\n }\n\n removeEvent(e) {\n let ks = GCalendar.dateToCacheKey(e.start);\n let ke = GCalendar.dateToCacheKey(new Date(e.end.getTime() - 1));\n for (let k = ks; k <= ke; k++)\n delete this.getSlot(k)[e.id];\n }\n\n getSlotEvents(k, start, end) {\n let s = this.getSlot(k);\n let results = [];\n for (let id in s) {\n if (!(s[id].start >= end || s[id].end <= start))\n {\n let nstart = s[id].start < start ? start: s[id].start;\n let nend = s[id].end > end ? end: s[id].end;\n if (nstart > nend) console.log(s[id], start, end);\n results.push({\n id,\n start: s[id].start < start ? start: s[id].start,\n end: s[id].end > end ? end: s[id].end\n });\n }\n }\n return results;\n }\n\n getCachedEvents(start, end) {\n let ks = GCalendar.dateToCacheKey(start);\n let ke = GCalendar.dateToCacheKey(new Date(end.getTime() - 1));\n let results = this.getSlotEvents(ks, start, end);\n for (let k = ks + 1; k < ke; k++)\n {\n let s = this.getSlot(k);\n for (let id in s)\n results.push(s[id]);\n }\n if (ke > ks)\n results.push(...this.getSlotEvents(ke, start, end));\n return results;\n }\n\n sync() {\n return this.token.then(token => getEvents(this.calId, token, this.syncToken).then(r => {\n this.syncToken = r.nextSyncToken;\n let pm_results = r.results.map(e => e.start ? Promise.resolve(e) : getEvent(this.calId, e.id, token));\n return Promise.all(pm_results).then(results => results.forEach(e => {\n e.start = new Date(e.start.dateTime);\n e.end = new Date(e.end.dateTime);\n if (e.status === 'confirmed')\n this.addEvent(e);\n else if (e.status === 'cancelled')\n this.removeEvent(e);\n }));\n })).catch(e => {\n if (e == GApiError.invalidSyncToken) {\n this.syncToken = '';\n this.sync();\n } else throw e;\n });\n }\n\n getEvents(start, end) {\n return this.sync().then(() => this.getCachedEvents(start, end));\n }\n}\n","export class Pattern {\n constructor(id, isRegex, value, label) {\n this.id = id;\n this.isRegex = isRegex;\n this.value = value;\n this.label = label;\n }\n\n get regex() { return new RegExp(this.isRegex ? this.value : `^${this.value}$`); }\n get isEmpty() { return this.label === null; }\n static emptyPattern = () => new Pattern(0, true, '', null);\n static anyPattern = () => new Pattern('any', true, '.*', 'Any');\n}\n\nexport class PatternEntry {\n constructor(name, idx, calPattern, eventPattern) {\n this.name = name;\n this.idx = idx;\n this.cal = calPattern;\n this.event = eventPattern;\n }\n\n static defaultPatternEntry = (idx) => new PatternEntry('', idx, Pattern.emptyPattern(), Pattern.anyPattern());\n}\n","import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport Grid from '@material-ui/core/Grid';\nimport deepOrange from '@material-ui/core/colors/deepOrange';\nimport cyan from '@material-ui/core/colors/cyan';\nimport { PieChart, Pie, Cell, Tooltip } from 'recharts';\n\nconst styles = theme => ({\n pieChart: {\n margin: '0 auto',\n }\n});\n\nfunction customizedLabel(props) {\n const {cx, cy, x, y, fill, name} = props;\n let anchor = \"middle\";\n const EPS = 2;\n let dx = 0;\n let dy = 0;\n if (x < cx - EPS) {\n dx = -5;\n anchor = \"end\"\n } else if (x > cx + EPS) {\n dx = 5;\n anchor = \"start\";\n }\n\n if (y < cy - EPS) {\n dy = -5;\n } else if (y > cy + EPS) {\n dy = 10;\n }\n\n return (<text x={x} y={y} dx={dx} dy={dy} fill={fill} textAnchor={anchor}>{`${name}`}</text>);\n}\n\nfunction ChromiclePieChart(props) {\n return (\n <Grid container spacing={0}>\n <Grid item xs={12} lg={6}>\n <div className={props.classes.patternTableWrapper}>\n <PieChart width={400} height={250} className={props.classes.pieChart}>\n <Pie data={props.patternGraphData}\n dataKey='value'\n cx={200}\n cy={125}\n outerRadius={60}\n fill={deepOrange[300]}\n label={customizedLabel}/>\n <Tooltip formatter={(value) => `${value.toFixed(2)} hr`}/>\n </PieChart>\n </div>\n </Grid>\n <Grid item xs={12} lg={6}>\n <div className={props.classes.patternTableWrapper}>\n <PieChart width={400} height={250} className={props.classes.pieChart}>\n <Pie data={props.calendarGraphData}\n dataKey='value'\n cx={200}\n cy={125}\n innerRadius={40}\n outerRadius={70}\n fill={cyan[300]}\n label={customizedLabel}>\n {props.calendarGraphData.map((d, i) => <Cell key={i} fill={d.color}/>)}\n </Pie>\n <Tooltip formatter={(value) => `${value.toFixed(2)} hr`}/>\n </PieChart>\n </div>\n </Grid>\n </Grid>);\n}\n\nChromiclePieChart.propTypes = {\n patternGraphData: PropTypes.array.isRequired,\n calendarGraphData: PropTypes.array.isRequired,\n};\n\nexport default withStyles(styles)(ChromiclePieChart);\n","import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport Select from '@material-ui/core/Select';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport TextField from '@material-ui/core/TextField';\nimport FormControl from '@material-ui/core/FormControl';\nimport { Pattern } from './pattern';\n\nconst styles = theme => ({\n fieldNoRegex: {\n width: 200\n },\n fieldRegex: {\n marginRight: '0.5em'\n }\n});\n\nclass RegexField extends React.Component {\n render() {\n const { classes } = this.props;\n let items = [];\n var pitems = this.props.options;\n const p0 = new Pattern.emptyPattern();\n pitems[p0.id] = p0;\n for (let id in pitems)\n {\n const label = !pitems[id].isEmpty ? pitems[id].label :\n <span style={{color: this.props.theme.palette.primary.dark}}>Custom</span>;\n items.push(<MenuItem key={id} value={id}>{label}</MenuItem>);\n }\n const selectOnClick = event => {\n let value;\n if (pitems[event.target.value].label == null) {\n value = new Pattern(0, true,\n this.props.value.isRegex ?\n this.props.value.value :\n `^${this.props.value.value}$`, null);\n } else {\n value = pitems[event.target.value];\n }\n this.props.onChange({target: {value}});\n };\n\n const regexTextOnChange = event => this.props.onChange({\n target: { value: new Pattern(0, true, event.target.value, null)}});\n\n const className = this.props.value.isRegex ? classes.fieldRegex: classes.fieldNoRegex;\n return (\n <FormControl>\n <span>\n <Select\n value={this.props.value.id}\n onChange={selectOnClick}\n className={className}>{items}\n </Select>\n {this.props.value.label == null && (\n <TextField\n value={this.props.value.value}\n onChange={regexTextOnChange} />\n )}\n </span>\n </FormControl>);\n }\n}\n\nRegexField.propTypes = {\n classes: PropTypes.object.isRequired,\n};\n\nconst RegexFieldWithStyles = withStyles(styles)(RegexField);\n\nexport function CalendarField(props) {\n let options = {};\n for (let id in props.cached.calendars) {\n options[id] = new Pattern(id, false,\n props.cached.calendars[id].name,\n props.cached.calendars[id].name);\n }\n return (\n <RegexFieldWithStyles\n value={props.value}\n options={options}\n onChange={props.onChange}\n theme={props.theme} />);\n}\n\nexport function EventField(props) {\n let any = Pattern.anyPattern();\n let options = {};\n options[any.id] = any;\n return (\n <RegexFieldWithStyles\n value={props.value}\n options={options}\n onChange={props.onChange}\n theme={props.theme} />);\n}\n","import { createMuiTheme } from '@material-ui/core/styles';\nimport orange from '@material-ui/core/colors/orange';\n\nconst theme = createMuiTheme({\n palette: {\n primary: {\n light: orange[300],\n main: orange[500],\n dark: orange[700],\n contrastText: \"#fff\"\n }\n },\n typography: {\n useNextVariants: true,\n }\n});\n\nexport default theme;\n","import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles, withTheme } from '@material-ui/core/styles';\nimport TextField from '@material-ui/core/TextField';\nimport Table from '@material-ui/core/Table';\nimport TableBody from '@material-ui/core/TableBody';\nimport TableRow from '@material-ui/core/TableRow';\nimport TableCell from '@material-ui/core/TableCell';\nimport TableHead from '@material-ui/core/TableHead';\nimport TablePagination from '@material-ui/core/TablePagination';\nimport DeleteOutlinedIcon from '@material-ui/icons/DeleteOutlined';\nimport { CalendarField, EventField } from './RegexField';\nimport theme from './theme';\n\nconst styles = theme => ({\n deleteButtonShow: {\n position: 'absolute',\n right: 0,\n height: 48\n },\n deleteButtonHide: {\n display: 'none'\n },\n deleteIcon: {\n height: '100%',\n cursor: 'pointer'\n },\n patternTableWrapper: {\n overflowX: 'auto',\n overflowY: 'hidden'\n },\n patternTable: {\n minWidth: 600\n }\n});\n\nconst patternHead = [\n {label: \"Name\", field: \"name\", elem: TextField},\n {label: \"Calendar\", field: \"cal\", elem: withTheme(theme)(CalendarField)},\n {label: \"Event\", field: 'event', elem: withTheme(theme)(EventField)}];\n\nclass PatternTable extends React.Component {\n state = {\n page: 0,\n rowsPerPage: 5,\n };\n\n handleChangePage = (event, page) => {\n this.setState({ page });\n }\n\n handleChangeRowsPerPage = event => {\n this.setState({ rowsPerPage: event.target.value });\n }\n\n render() {\n const { classes, cached, patterns } = this.props;\n const { rowsPerPage, page } = this.state;\n const nDummy = rowsPerPage - Math.min(rowsPerPage, patterns.length - page * rowsPerPage);\n let rows = patterns.slice(page * rowsPerPage, (page + 1) * rowsPerPage).map(p => (\n <TableRow\n onMouseOver={() => this.setState({ activePattern: p.idx })}\n onMouseOut={() => this.setState({ activePattern: null })}>\n {\n patternHead.map(s => {\n const CustomText = s.elem;\n return (\n <TableCell>\n <CustomText\n value={p[s.field]}\n cached={cached}\n onChange={event => this.props.onUpdatePattern(s.field, p.idx, event.target.value)}/>\n </TableCell>)})\n }\n <span className={this.state.activePattern === p.idx ? classes.deleteButtonShow : classes.deleteButtonHide}>\n <DeleteOutlinedIcon\n className={classes.deleteIcon}\n onClick={() => this.props.onRemovePattern(p.idx)} />\n </span>\n </TableRow>));\n\n return (\n <div>\n <div className={classes.patternTableWrapper}>\n <Table className={classes.patternTable}>\n <TableHead>\n <TableRow>{patternHead.map((s, i) => (<TableCell key={i}>{s.label}</TableCell>))}</TableRow>\n </TableHead>\n <TableBody>\n {rows}\n {\n nDummy > 0 && (\n <TableRow style={{ height: 48 * nDummy }}>\n <TableCell colSpan={patternHead.length} />\n </TableRow>)\n }\n </TableBody>\n </Table>\n </div>\n <TablePagination\n rowsPerPageOptions={[5, 10, 25]}\n component=\"div\"\n count={patterns.length}\n rowsPerPage={rowsPerPage}\n page={page}\n backIconButtonProps={{'aria-label': 'Previous Page'}}\n nextIconButtonProps={{'aria-label': 'Next Page'}}\n onChangePage={this.handleChangePage}\n onChangeRowsPerPage={this.handleChangeRowsPerPage} />\n </div>);\n }\n}\n\n\nPatternTable.propTypes = {\n classes: PropTypes.object.isRequired,\n patterns: PropTypes.array.isRequired,\n cached: PropTypes.object.isRequired,\n onRemovePattern: PropTypes.func.isRequired,\n onUpdatePattern: PropTypes.func.isRequired,\n};\n\nexport default withStyles(styles)(PatternTable);\n","import React from 'react';\nimport PropTypes from 'prop-types';\nimport 'typeface-roboto';\nimport 'react-dates/initialize';\nimport 'react-dates/lib/css/_datepicker.css';\nimport { DateRangePicker } from 'react-dates';\nimport { withStyles } from '@material-ui/core/styles';\nimport { MuiThemeProvider } from '@material-ui/core/styles';\nimport cyan from '@material-ui/core/colors/cyan';\nimport CssBaseline from '@material-ui/core/CssBaseline';\nimport AppBar from '@material-ui/core/AppBar';\nimport Toolbar from '@material-ui/core/Toolbar';\nimport Typography from '@material-ui/core/Typography';\nimport Button from '@material-ui/core/Button';\nimport FormControl from '@material-ui/core/FormControl';\nimport FormGroup from '@material-ui/core/FormGroup';\nimport Grid from '@material-ui/core/Grid';\nimport AddCircleIcon from '@material-ui/icons/AddCircle';\nimport IconButton from '@material-ui/core/IconButton';\nimport Logo from './Logo';\nimport * as gapi from './gapi';\nimport { Pattern, PatternEntry } from './pattern';\nimport PieChart from './Chart';\nimport PatternTable from './PatternTable';\nimport theme from './theme';\n\nconst default_chart_data = [\n {name: 'Work', value: 10, color: cyan[300]},\n {name: 'Wasted', value: 10, color: cyan[300]}];\n\nfunction filterPatterns(patterns, calName) {\n return patterns.filter(p => {\n return p.cal.regex.test(calName);\n });\n}\n\nconst styles = theme => ({\n root: {\n display: 'flex',\n height: '100vh',\n },\n appBar: {\n zIndex: theme.zIndex.drawer + 1,\n transition: theme.transitions.create(['width', 'margin'], {\n easing: theme.transitions.easing.sharp,\n duration: theme.transitions.duration.leavingScreen,\n }),\n },\n title: {\n flexGrow: 1,\n },\n sectionTitle: {\n flex: '0 0 auto'\n },\n appBarSpacer: theme.mixins.toolbar,\n content: {\n flexGrow: 1,\n padding: theme.spacing.unit * 3,\n overflow: 'auto',\n },\n buttonSpacer: {\n marginBottom: theme.spacing.unit * 4,\n },\n fab: {\n margin: theme.spacing.unit,\n },\n});\n\nclass Dashboard extends React.Component {\n state = {\n patterns: [],\n timeRange: null,\n token: gapi.getAuthToken(),\n patternGraphData: default_chart_data,\n calendarGraphData: default_chart_data,\n activePattern: null\n };\n\n cached = {\n calendars: {}\n };\n\n updatePattern = (field, idx, value) => {\n let patterns = this.state.patterns;\n patterns[idx][field] = value;\n this.setState({ patterns });\n };\n\n removePattern = idx => {\n let patterns = this.state.patterns;\n patterns.splice(idx, 1);\n for (let i = 0; i < patterns.length; i++)\n patterns[i].idx = i;\n this.setState({ patterns });\n };\n\n newPattern = () => {\n let patterns = [PatternEntry.defaultPatternEntry(), ...this.state.patterns];\n for (let i = 1; i < patterns.length; i++)\n patterns[i].idx = i;\n this.setState({ patterns });\n };\n\n analyze = () => {\n if (!(this.state.startDate && this.state.endDate)) {\n alert(\"Please choose a valid time range.\");\n return;\n }\n let start = this.state.startDate.toDate();\n let end = this.state.endDate.toDate();\n console.log(start, end);\n let event_pms = [];\n for (let id in this.cached.calendars)\n event_pms.push(this.cached.calendars[id].cal.getEvents(start, end)\n .then(r => { return { id, events: r }; })\n .catch(e => {\n console.log(`cannot load calendar ${id}`);\n return { id, events: [] };\n }));\n\n Promise.all(event_pms).then(all_events => {\n let events = {};\n let results = {}; // pattern idx => time\n let cal_results = {}; // cal id => time\n all_events.forEach(e => events[e.id] = e.events);\n for (let i = 0; i < this.state.patterns.length; i++)\n results[i] = 0;\n for (let id in this.cached.calendars) {\n if (!events[id]) continue;\n let patterns = filterPatterns(this.state.patterns, this.cached.calendars[id].name);\n events[id].forEach(event => {\n patterns.forEach(p => {\n if (!p.event.regex.test(event.summary)) return;\n if (!cal_results.hasOwnProperty(id)) {\n cal_results[id] = 0;\n }\n let duration = (event.end - event.start) / 60000;\n results[p.idx] += duration;\n cal_results[id] += duration;\n });\n });\n }\n let patternGraphData = [];\n let calendarGraphData = [];\n for (let i = 0; i < this.state.patterns.length; i++) {\n patternGraphData.push({ name: this.state.patterns[i].name, value: results[i] / 60.0 });\n }\n for (let id in cal_results) {\n calendarGraphData.push({\n name: this.cached.calendars[id].name,\n value: (cal_results[id] / 60.0),\n color: this.cached.calendars[id].color.background});\n }\n //console.log(patternGraphData, calendarGraphData);\n this.setState({ patternGraphData, calendarGraphData });\n });\n };\n\n loadPatterns = () => {\n let token = this.state.token;\n let colors = token.then(gapi.getColors).then(color => {\n return color.calendar;\n });\n let cals = token.then(gapi.getCalendars);\n Promise.all([colors, cals]).then(([colors, items]) => {\n items.forEach(item => {\n this.cached.calendars[item.id] = {\n name: item.summary,\n color: colors[item.colorId],\n cal: new gapi.GCalendar(item.id, item.summary)\n };\n });\n this.setState({ patterns: items.map((item, idx) => {\n return new PatternEntry(item.summary, idx,\n new Pattern(item.id, false, item.summary, item.summary),\n Pattern.anyPattern());\n })});\n });\n };\n\n render() {\n const { classes } = this.props;\n\n return (\n <MuiThemeProvider theme={theme}>\n <div className={classes.root}>\n <AppBar\n position=\"absolute\"\n className={classes.appBar}>\n <Toolbar className={classes.toolbar}>\n <Typography component=\"h1\" variant=\"h6\" color=\"inherit\" noWrap className={classes.title}>\n <Logo style={{width: '2em', verticalAlign: 'bottom', marginRight: '0.2em'}}/>Chromicle\n </Typography>\n </Toolbar>\n </AppBar>\n <main className={classes.content}>\n <div className={classes.appBarSpacer} />\n <Grid container spacing={16}>\n <CssBaseline />\n <Grid item md={6} xs={12}>\n <FormControl fullWidth={true}>\n <FormGroup>\n <Typography variant=\"h6\" component=\"h1\" gutterBottom>\n Event Patterns\n <IconButton\n style={{marginBottom: '0.12em', marginLeft: '0.5em'}}\n onClick={() => this.newPattern()}><AddCircleIcon /></IconButton>\n </Typography>\n <PatternTable\n patterns={this.state.patterns}\n cached={this.cached}\n onRemovePattern={this.removePattern}\n onUpdatePattern={this.updatePattern} />\n </FormGroup>\n <FormGroup>\n <Typography variant=\"h6\" component=\"h1\" gutterBottom>\n Time Range\n </Typography>\n <div style={{textAlign: 'center'}}>\n <DateRangePicker\n startDate={this.state.startDate}\n startDateId=\"start_date_id\"\n endDate={this.state.endDate}\n endDateId=\"end_date_id\"\n onDatesChange={({ startDate, endDate }) => {\n this.setState({ startDate, endDate });\n }} \n focusedInput={this.state.focusedInput}\n onFocusChange={focusedInput => this.setState({ focusedInput })}\n isOutsideRange={() => false}/>\n </div>\n </FormGroup>\n <div className={classes.buttonSpacer} />\n <Grid container spacing={16}>\n <Grid item md={6} xs={12}>\n <FormGroup>\n <Button variant=\"contained\" color=\"primary\" onClick={this.loadPatterns}>Load</Button>\n </FormGroup>\n </Grid>\n <Grid item md={6} xs={12}>\n <FormGroup>\n <Button variant=\"contained\" color=\"primary\" onClick={this.analyze}>Analyze</Button>\n </FormGroup>\n </Grid>\n </Grid>\n </FormControl>\n </Grid>\n <Grid item md={6} xs={12}>\n <Typography variant=\"h6\" component=\"h1\" gutterBottom>\n Graph\n </Typography>\n <PieChart\n patternGraphData={this.state.patternGraphData}\n calendarGraphData={this.state.calendarGraphData}/>\n </Grid>\n </Grid>\n </main>\n </div>\n </MuiThemeProvider>);\n }\n}\n\nDashboard.propTypes = {\n classes: PropTypes.object.isRequired,\n};\n\nexport default withStyles(styles)(Dashboard);\n","// This optional code is used to register a service worker.\n// register() is not called by default.\n\n// This lets the app load faster on subsequent visits in production, and gives\n// it offline capabilities. However, it also means that developers (and users)\n// will only see deployed updates on subsequent visits to a page, after all the\n// existing tabs open on the page have been closed, since previously cached\n// resources are updated in the background.\n\n// To learn more about the benefits of this model and instructions on how to\n// opt-in, read http://bit.ly/CRA-PWA\n\nconst isLocalhost = Boolean(\n window.location.hostname === 'localhost' ||\n // [::1] is the IPv6 localhost address.\n window.location.hostname === '[::1]' ||\n // 127.0.0.1/8 is considered localhost for IPv4.\n window.location.hostname.match(\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n )\n);\n\nexport function register(config) {\n if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {\n // The URL constructor is available in all browsers that support SW.\n const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);\n if (publicUrl.origin !== window.location.origin) {\n // Our service worker won't work if PUBLIC_URL is on a different origin\n // from what our page is served on. This might happen if a CDN is used to\n // serve assets; see https://github.com/facebook/create-react-app/issues/2374\n return;\n }\n\n window.addEventListener('load', () => {\n const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;\n\n if (isLocalhost) {\n // This is running on localhost. Let's check if a service worker still exists or not.\n checkValidServiceWorker(swUrl, config);\n\n // Add some additional logging to localhost, pointing developers to the\n // service worker/PWA documentation.\n navigator.serviceWorker.ready.then(() => {\n console.log(\n 'This web app is being served cache-first by a service ' +\n 'worker. To learn more, visit http://bit.ly/CRA-PWA'\n );\n });\n } else {\n // Is not localhost. Just register service worker\n registerValidSW(swUrl, config);\n }\n });\n }\n}\n\nfunction registerValidSW(swUrl, config) {\n navigator.serviceWorker\n .register(swUrl)\n .then(registration => {\n registration.onupdatefound = () => {\n const installingWorker = registration.installing;\n if (installingWorker == null) {\n return;\n }\n installingWorker.onstatechange = () => {\n if (installingWorker.state === 'installed') {\n if (navigator.serviceWorker.controller) {\n // At this point, the updated precached content has been fetched,\n // but the previous service worker will still serve the older\n // content until all client tabs are closed.\n console.log(\n 'New content is available and will be used when all ' +\n 'tabs for this page are closed. See http://bit.ly/CRA-PWA.'\n );\n\n // Execute callback\n if (config && config.onUpdate) {\n config.onUpdate(registration);\n }\n } else {\n // At this point, everything has been precached.\n // It's the perfect time to display a\n // \"Content is cached for offline use.\" message.\n console.log('Content is cached for offline use.');\n\n // Execute callback\n if (config && config.onSuccess) {\n config.onSuccess(registration);\n }\n }\n }\n };\n };\n })\n .catch(error => {\n console.error('Error during service worker registration:', error);\n });\n}\n\nfunction checkValidServiceWorker(swUrl, config) {\n // Check if the service worker can be found. If it can't reload the page.\n fetch(swUrl)\n .then(response => {\n // Ensure service worker exists, and that we really are getting a JS file.\n const contentType = response.headers.get('content-type');\n if (\n response.status === 404 ||\n (contentType != null && contentType.indexOf('javascript') === -1)\n ) {\n // No service worker found. Probably a different app. Reload the page.\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister().then(() => {\n window.location.reload();\n });\n });\n } else {\n // Service worker found. Proceed as normal.\n registerValidSW(swUrl, config);\n }\n })\n .catch(() => {\n console.log(\n 'No internet connection found. App is running in offline mode.'\n );\n });\n}\n\nexport function unregister() {\n if ('serviceWorker' in navigator) {\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister();\n });\n }\n}\n","import React from 'react';\nimport ReactDOM from 'react-dom';\nimport App from './App';\nimport * as serviceWorker from './serviceWorker';\n\nReactDOM.render(<App />, document.getElementById('root'));\n\n// If you want your app to work offline and load faster, you can change\n// unregister() to register() below. Note this comes with some pitfalls.\n// Learn more about service workers: http://bit.ly/CRA-PWA\nserviceWorker.unregister();\n"],"sourceRoot":""} \ No newline at end of file