diff options
Diffstat (limited to 'build/static/js/main.51a6471b.chunk.js')
-rw-r--r-- | build/static/js/main.51a6471b.chunk.js | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/build/static/js/main.51a6471b.chunk.js b/build/static/js/main.51a6471b.chunk.js new file mode 100644 index 0000000..ce0008c --- /dev/null +++ b/build/static/js/main.51a6471b.chunk.js @@ -0,0 +1,2 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[0],{307:function(e,t,a){e.exports=a(660)},660: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(280),l=a(281),s=a(305),u=a(282),m=a(306),d=a(170),h=(a(312),a(314),a(340),a(283)),p=(a(5),a(57)),f=a(130),g=a.n(f),v=a(129),E=a.n(v),x=a(296),P=a.n(x),w=a(298),y=a.n(w),b=a(297),D=a.n(b),k=a(165),S=a.n(k),C=a(302),G=a.n(C),O=a(77),I=a.n(O),j=a(299),R=a.n(j),B=a(301),N=a.n(B),T=a(132),_=a.n(T),M=a(94),W=a.n(M),z=a(300),A=a.n(z),H=a(304),F=a.n(H),q=a(169),J=a.n(q),L=a(166),U=a.n(L),X=a(96),$=a.n(X),K=a(44),Q=a.n(K),V=a(303),Y=a.n(V),Z=a(665),ee=a(661),te=a(662),ae=a(560),ne=[{name:"Work",value:10,color:E.a[300]},{name:"Wasted",value:10,color:E.a[300]}],re="https://www.googleapis.com/calendar/v3",ce=Object(p.createMuiTheme)({palette:{primary:{light:g.a[300],main:g.a[500],dark:g.a[700],contrastText:"#fff"}}});function oe(e){return Object.entries(e).map(function(e){var t=Object(d.a)(e,2),a=t[0],n=t[1];return"".concat(encodeURIComponent(a),"=").concat(encodeURIComponent(n))}).join("&")}function ie(e){return fetch(re+"/users/me/calendarList?"+oe({access_token:e}),{method:"GET",async:!0}).then(function(e){return e.json()}).then(function(e){return e.items})}function le(e){return fetch(re+"/colors?"+oe({access_token:e}),{method:"GET",async:!0}).then(function(e){return e.json()})}function se(e){var t=e.cx,a=e.cy,n=e.x,c=e.y,o=(e.stroke,e.fill),i=e.name,l=(e.value,"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))}function ue(e){return r.a.createElement(Q.a,{container:!0,spacing:0},r.a.createElement(Q.a,{item:!0,xs:12,lg:6},r.a.createElement(Z.a,{width:400,height:300,className:e.classes.pieChart},r.a.createElement(ee.a,{data:e.patternGraphData,cx:200,cy:150,outerRadius:60,fill:P.a[300],label:se}),r.a.createElement(te.a,{formatter:function(e){return"".concat(e.toFixed(2)," hr")}}))),r.a.createElement(Q.a,{item:!0,xs:12,lg:6},r.a.createElement(Z.a,{width:400,height:300,className:e.classes.pieChart},r.a.createElement(ee.a,{data:e.calendarGraphData,cx:200,cy:150,innerRadius:40,outerRadius:70,fill:E.a[300],label:se},e.calendarGraphData.map(function(e){return r.a.createElement(ae.a,{fill:e.color})})),r.a.createElement(te.a,{formatter:function(e){return"".concat(e.toFixed(2)," hr")}}))))}var me=function(e){function t(){var e,a;Object(i.a)(this,t);for(var n=arguments.length,r=new Array(n),c=0;c<n;c++)r[c]=arguments[c];return(a=Object(s.a)(this,(e=Object(u.a)(t)).call.apply(e,[this].concat(r)))).state={open:!0,patterns:[],page:0,rowsPerPage:5,timeRange:null,token:new Promise(function(e){return chrome.identity.getAuthToken({interactive:!0},function(t){return e(t)})}),patternGraphData:ne,calendarGraphData:ne,activePattern:null},a.cached={calendars:{}},a.handleChangePage=function(e,t){a.setState({page:t})},a.handleChangeRowsPerPage=function(e){a.setState({rowsPerPage:e.target.value})},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.analyze=function(){if(a.state.startDate&&a.state.endDate){var e=a.state.startDate.toISOString(),t=a.state.endDate.toISOString(),n=[],r=function(r){var c,o,i;n.push(a.state.token.then((c=r,o=e,i=t,function(e){return fetch(re+"/calendars/"+c+"/events?"+oe({access_token:e,timeMin:o,timeMax:i}),{method:"GET",async:!0}).then(function(e){return e.json()}).then(function(e){return e.items})})).then(function(e){return a.cached.calendars[r].events=e}))};for(var c in a.cached.calendars)r(c);Promise.all(n).then(function(){for(var e={},t={},n=0;n<a.state.patterns.length;n++)e[n]=0;var r=function(n){var r=function(e,t){return e.filter(function(e){return new RegExp(e.cal).test(t)})}(a.state.patterns,a.cached.calendars[n].name).map(function(e){return{regex:new RegExp(e.event),idx:e.idx}});if(!a.cached.calendars[n].events)return"continue";a.cached.calendars[n].events.forEach(function(a){"confirmed"==a.status&&r.forEach(function(r){if(r.regex.test(a.summary)){void 0===t[n]&&(t[n]=0);var c=(new Date(a.end.dateTime)-new Date(a.start.dateTime))/6e4;e[r.idx]+=c,t[n]+=c}})})};for(var c in a.cached.calendars)r(c);for(var o=[],i=[],l=0;l<a.state.patterns.length;l++)o.push({name:a.state.patterns[l].name,value:e[l]/60});for(var c in t)i.push({name:a.cached.calendars[c].name,value:t[c]/60,color:a.cached.calendars[c].color.background});a.setState({patternGraphData:o,calendarGraphData:i})})}else alert("Please choose a valid time range.")},a.loadPatterns=function(){var e=a.state.token,t=e.then(le).then(function(e){return e.calendar}),n=e.then(ie);Promise.all([t,n]).then(function(e){var t=Object(d.a)(e,2),n=t[0],r=t[1];r.forEach(function(e){a.cached.calendars[e.id]={name:e.summary,events:{},color:n[e.colorId]}}),a.setState({patterns:r.map(function(e,t){return{name:e.summary,cal:e.summary,event:".*",idx:t}})})})},a}return Object(m.a)(t,e),Object(l.a)(t,[{key:"render",value:function(){var e=this,a=this.props.classes,n=this.state,c=n.patterns,o=(n.rows,n.rowsPerPage),i=n.page,l=o-Math.min(o,c.length-i*o);return r.a.createElement(p.MuiThemeProvider,{theme:ce},r.a.createElement("div",{className:a.root},r.a.createElement(D.a,{position:"absolute",className:a.appBar},r.a.createElement(S.a,{disableGutters:!this.state.open,className:a.toolbar},r.a.createElement(I.a,{component:"h1",variant:"h6",color:"inherit",noWrap:!0,className:a.title},"Chromicle"))),r.a.createElement("main",{className:a.content},r.a.createElement("div",{className:a.appBarSpacer}),r.a.createElement(Q.a,{container:!0,spacing:16},r.a.createElement(y.a,null),r.a.createElement(Q.a,{item:!0,md:6,xs:12},r.a.createElement(U.a,{fullWidth:!0},r.a.createElement($.a,null,r.a.createElement(I.a,{variant:"h6",component:"h1",gutterBottom:!0},"Event Patterns"),r.a.createElement(R.a,null,r.a.createElement(A.a,null,r.a.createElement(_.a,null,t.patternHead.map(function(e){return r.a.createElement(W.a,null,e.label)}))),r.a.createElement(N.a,null,c.slice(i*o,(i+1)*o).map(function(n){return r.a.createElement(_.a,{onMouseOver:function(){return e.setState({activePattern:n.idx})},onMouseOut:function(){return e.setState({activePattern:null})}},t.patternHead.map(function(t){return r.a.createElement(W.a,null,r.a.createElement(G.a,{value:n[t.field],onChange:function(a){return e.updatePattern(t.field,n.idx,a.target.value)}}))}),r.a.createElement("span",{style:e.state.activePattern==n.idx&&{position:"absolute",right:0,height:48}||{display:"none"}},r.a.createElement(Y.a,{className:a.icon,style:{height:"100%",cursor:"pointer"},onClick:function(){return e.removePattern(n.idx)}})))}),l>0&&r.a.createElement(_.a,{style:{height:48*l}},r.a.createElement(W.a,{colSpan:t.patternHead.length})))),r.a.createElement(F.a,{rowsPerPageOptions:[5,10,25],component:"div",count:c.length,rowsPerPage:o,page:i,backIconButtonProps:{"aria-label":"Previous Page"},nextIconButtonProps:{"aria-label":"Next Page"},onChangePage:this.handleChangePage,onChangeRowsPerPage:this.handleChangeRowsPerPage})),r.a.createElement($.a,null,r.a.createElement(I.a,{variant:"h6",component:"h1",gutterBottom:!0},"Time Range"),r.a.createElement("div",{style:{textAlign:"center"}},r.a.createElement(h.DateRangePicker,{startDate:this.state.startDate,startDateId:"your_unique_start_date_id",endDate:this.state.endDate,endDateId:"your_unique_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:a.buttonSpacer}),r.a.createElement(Q.a,{container:!0,spacing:16},r.a.createElement(Q.a,{item:!0,md:6,xs:12},r.a.createElement($.a,null,r.a.createElement(J.a,{variant:"contained",color:"primary",onClick:this.loadPatterns},"Load"))),r.a.createElement(Q.a,{item:!0,md:6,xs:12},r.a.createElement($.a,null,r.a.createElement(J.a,{variant:"contained",color:"primary",onClick:this.analyze},"Analyze")))))),r.a.createElement(Q.a,{item:!0,md:6,xs:12},r.a.createElement(I.a,{variant:"h6",component:"h1",gutterBottom:!0},"Graph"),r.a.createElement(ue,{patternGraphData:this.state.patternGraphData,calendarGraphData:this.state.calendarGraphData,classes:a}))))))}}]),t}(r.a.Component);me.patternHead=[{label:"Name",field:"name"},{label:"Calendar",field:"cal"},{label:"Event",field:"event"}];var de=Object(p.withStyles)(function(e){return{root:{display:"flex",height:"100vh"},icon:{margin:2*e.spacing.unit},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},patternTable:{overflowX:"auto"},pieChart:{margin:"0 auto"},fab:{margin:e.spacing.unit}}})(me);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(de,null),document.getElementById("root")),"serviceWorker"in navigator&&navigator.serviceWorker.ready.then(function(e){e.unregister()})}},[[307,2,1]]]); +//# sourceMappingURL=main.51a6471b.chunk.js.map
\ No newline at end of file |