aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2019-02-11 01:09:51 -0500
committerDeterminant <[email protected]>2019-02-11 01:09:51 -0500
commitf28b818cc62c7fff67517a4147e64f08ebd73027 (patch)
tree49ed08257897088acaede1ef7dcf00eb6ed75e2a /src
parent7ec26813a0cae0996f2d5873b9bdd1aeede68d41 (diff)
fix regression bugs
Diffstat (limited to 'src')
-rw-r--r--src/Analyze.js22
-rw-r--r--src/PatternTable.js8
-rw-r--r--src/RegexField.js10
-rw-r--r--src/Settings.js1
-rw-r--r--src/background.js34
-rw-r--r--src/gapi.js2
6 files changed, 42 insertions, 35 deletions
diff --git a/src/Analyze.js b/src/Analyze.js
index 0985b2d..98e3ce2 100644
--- a/src/Analyze.js
+++ b/src/Analyze.js
@@ -134,15 +134,25 @@ class Analyze extends React.Component {
});
}
+ loadDefaultPatterns() {
+ let patterns = [];
+ let idx = 0;
+ for (let id in this.state.calendars) {
+ let cal = this.state.calendars[id];
+ if (!cal.enabled) continue;
+ patterns.push(new PatternEntry(cal.name, idx++,
+ new Pattern(id, false, cal.name, cal.name),
+ Pattern.anyPattern(),
+ cal.color));
+ }
+ console.log(patterns);
+ this.loadPatterns(patterns);
+ }
+
default = () => {
this.handleDialogOpen("Load Default", "Load the calendars as patterns?").then(ans => {
if (!ans) return;
- this.loadPatterns(Object.keys(this.state.calendars).map((id, idx) => {
- let item = this.state.calendars[id];
- return new PatternEntry(item.name, idx,
- new Pattern(id, false, item.name, item.name),
- Pattern.anyPattern());
- }));
+ this.loadDefaultPatterns();
});
}
diff --git a/src/PatternTable.js b/src/PatternTable.js
index 49fec21..93be293 100644
--- a/src/PatternTable.js
+++ b/src/PatternTable.js
@@ -51,17 +51,17 @@ let nameFieldstyles = {
};
function NameField(props) {
- let color = props.value.color.background;
+ let color = props.value.color;
return (
<span>
<div
className={props.classes.colorSample}
- style={{backgroundColor: color ? color : defaultChartColor}}
+ style={{backgroundColor: color ? color.background : defaultChartColor}}
onClick={props.colorOnClick}>
</div>
<TextField
value={props.value.name}
- onChange={props.onChange} />
+ onChange={event => props.onChange('name', event.target.value)} />
</span>);
}
@@ -123,7 +123,7 @@ class PatternTable extends React.Component {
<CustomText
value={p}
calendars={calendars}
- onChange={event => this.props.onUpdatePattern(s.field, p.idx, event.target.value)}
+ onChange={(field, value) => this.props.onUpdatePattern(field, p.idx, value)}
colorOnClick={event => {
this.activeColorPattern = p.idx;
this.setState({
diff --git a/src/RegexField.js b/src/RegexField.js
index f1bc2e8..e3fa9f4 100644
--- a/src/RegexField.js
+++ b/src/RegexField.js
@@ -39,11 +39,11 @@ class RegexField extends React.Component {
} else {
value = pitems[event.target.value];
}
- this.props.onChange({target: {value}});
+ this.props.onChange(value);
};
- const regexTextOnChange = event => this.props.onChange({
- target: { value: new Pattern(0, true, event.target.value, null)}});
+ const regexTextOnChange = event => this.props.onChange(
+ new Pattern(0, true, event.target.value, null));
const className = this.props.value.isRegex ? classes.fieldRegex: classes.fieldNoRegex;
return (
@@ -81,7 +81,7 @@ export function CalendarField(props) {
<RegexFieldWithStyles
value={props.value.cal}
options={options}
- onChange={props.onChange}
+ onChange={value => props.onChange('cal', value)}
theme={props.theme} />);
}
@@ -93,6 +93,6 @@ export function EventField(props) {
<RegexFieldWithStyles
value={props.value.event}
options={options}
- onChange={props.onChange}
+ onChange={value => props.onChange('event', value)}
theme={props.theme} />);
}
diff --git a/src/Settings.js b/src/Settings.js
index 40f4839..2835483 100644
--- a/src/Settings.js
+++ b/src/Settings.js
@@ -255,7 +255,6 @@ class Settings extends React.Component {
updatePattern = (field, idx, value) => {
let patterns = this.state.patterns;
patterns[idx][field] = value;
- console.log(patterns[idx]);
this.loadPatterns(patterns);
};
diff --git a/src/background.js b/src/background.js
index 1907a30..f22970e 100644
--- a/src/background.js
+++ b/src/background.js
@@ -16,7 +16,7 @@ let config = {
{name: 'This Week', start: Duration.weeks(1), end: Duration.weeks(0)},
{name: 'This Month', start: Duration.months(1), end: Duration.months(0)}]
};
-let mainGraphData = [{}, {}, {}, {}];
+let mainGraphData = [];
let dirtyMetadata = false;
function loadMetadata() {
@@ -24,26 +24,23 @@ function loadMetadata() {
'calendars', 'config', 'mainPatterns', 'analyzePatterns',
], function(items) {
if (chrome.runtime.lastError)
- {
console.error("error while loading saved metadata");
- return;
- }
- if (!items.hasOwnProperty('config'))
- {
+ else if (!items.hasOwnProperty('config'))
console.log("no saved metadata");
- return;
+ else
+ {
+ console.log('metadata loaded');
+ config = {
+ trackedPeriods: items.config.trackedPeriods.map(p => ({
+ name: p.name,
+ start: Duration.inflate(p.start),
+ end: Duration.inflate(p.end),
+ }))
+ };
+ calendars = items.calendars;
+ mainPatterns = items.mainPatterns.map(p => PatternEntry.inflate(p));
+ analyzePatterns = items.analyzePatterns.map(p => PatternEntry.inflate(p));
}
- console.log('metadata loaded');
- config = {
- trackedPeriods: items.config.trackedPeriods.map(p => ({
- name: p.name,
- start: Duration.inflate(p.start),
- end: Duration.inflate(p.end),
- }))
- };
- calendars = items.calendars;
- mainPatterns = items.mainPatterns.map(p => PatternEntry.inflate(p));
- analyzePatterns = items.analyzePatterns.map(p => PatternEntry.inflate(p));
resolver();
}));
}
@@ -119,6 +116,7 @@ function updateMainGraphData() {
}
async function pollSync() {
+ console.log('poll');
await updateMainGraphData();
if (dirtyMetadata)
await saveMetadata().then(() => dirtyMetadata = false);
diff --git a/src/gapi.js b/src/gapi.js
index c2c5dd6..3938864 100644
--- a/src/gapi.js
+++ b/src/gapi.js
@@ -282,7 +282,7 @@ export class GCalendar {
query.start = k;
query.end = k;
}
- console.log(`start: ${start} end: ${end}`);
+ //console.log(`start: ${start} end: ${end}`);
if (query.hasOwnProperty('start'))
{
console.assert(query.start <= query.end);