Skip to content

Commit

Permalink
Merge pull request #177 from ActivityWatch/dev/prettier
Browse files Browse the repository at this point in the history
Ran eslint --fix on everything
  • Loading branch information
ErikBjare committed Mar 16, 2020
2 parents 553cceb + a1428a4 commit f9c0b40
Show file tree
Hide file tree
Showing 39 changed files with 882 additions and 737 deletions.
22 changes: 12 additions & 10 deletions src/App.vue
Expand Up @@ -43,33 +43,35 @@ export default {
return {
activityViews: [],
info: {},
}
};
},
mounted: async function() {
this.$aw.getInfo().then(
(info) => {
info => {
this.info = info;
},
(e) => {
console.error("Unable to connect: ", e)
e => {
console.error('Unable to connect: ', e);
this.info = {};
}
);
}
}
},
};
</script>

<style lang="scss">
$textcolor: #000;
html, body, button {
html,
body,
button {
color: $textcolor;
font-family: 'Varela Round', sans-serif !important;
}
body {
background-color: #EEE;
background-color: #eee;
}
.fa-icon {
Expand All @@ -80,8 +82,8 @@ body {
}
.aw-container {
background-color: #FFF;
border: 1px solid #CCC;
background-color: #fff;
border: 1px solid #ccc;
border-radius: 5px 5px 5px 5px;
}
</style>
39 changes: 22 additions & 17 deletions src/components/CategoryEditTree.vue
Expand Up @@ -55,13 +55,13 @@ import 'vue-awesome/icons/plus';
import 'vue-awesome/icons/edit';
export default {
name: "CategoryEditTree",
name: 'CategoryEditTree',
props: {
cls: Object,
depth: {
type: Number,
default: 0,
}
},
},
data: () => {
return {
Expand All @@ -76,21 +76,26 @@ export default {
},
computed: {
allCategories: function() {
const categories = this.$store.getters["settings/all_categories"];
const entries = categories.map(c => { return { text: c.join("->"), value: c } });
return [{ value: [], text: 'None'}].concat(entries);
const categories = this.$store.getters['settings/all_categories'];
const entries = categories.map(c => {
return { text: c.join('->'), value: c };
});
return [{ value: [], text: 'None' }].concat(entries);
},
allRuleTypes: function() {
return [
{ value: null, text: 'None' },
{ value: 'regex', text: 'Regular Expression' },
//{ value: 'glob', text: 'Glob pattern' },
]
];
},
},
methods: {
addSubclass: function(parent) {
this.$store.commit('settings/addClass', {name: parent.name.concat(["New class"]), rule: {type: "regex", regex: "FILL ME"}});
this.$store.commit('settings/addClass', {
name: parent.name.concat(['New class']),
rule: { type: 'regex', regex: 'FILL ME' },
});
},
removeClass: function(cls) {
// TODO: Show a confirmation dialog
Expand All @@ -99,22 +104,22 @@ export default {
this.$store.commit('settings/removeClass', cls);
},
showEditModal(event) {
this.$refs.edit.show()
this.$refs.edit.show();
},
checkFormValidity() {
// FIXME
return true;
},
handleOk(event) {
// Prevent modal from closing
event.preventDefault()
event.preventDefault();
// Trigger submit handler
this.handleSubmit()
this.handleSubmit();
},
handleSubmit() {
// Exit when the form isn't valid
if (!this.checkFormValidity()) {
return
return;
}
// Save the category
Expand All @@ -123,12 +128,12 @@ export default {
name: this.editing.parent.concat(this.editing.name),
rule: this.editing.rule.type !== null ? this.editing.rule : { type: null },
};
this.$store.commit("settings/updateClass", new_class);
this.$store.commit('settings/updateClass', new_class);
// Hide the modal manually
this.$nextTick(() => {
this.$refs.edit.hide()
})
this.$refs.edit.hide();
});
},
resetModal() {
this.editing = {
Expand All @@ -139,13 +144,13 @@ export default {
};
//console.log(this.editing);
},
}
}
},
};
</script>

<style scoped lang="scss">
.row.cls:hover {
background-color: #EEE;
background-color: #eee;
boder-radius: 5px;
}
</style>
6 changes: 3 additions & 3 deletions src/components/ErrorBoundary.vue
Expand Up @@ -13,15 +13,15 @@ export default {
data() {
return { errors: [] };
},
errorCaptured (err, vm, info) {
errorCaptured(err, vm, info) {
//console.error("Error captured!");
//console.error(err, vm, info);
const msg = (err.name && err.message) ? (err.name + ": " + err.message) : err;
const msg = err.name && err.message ? err.name + ': ' + err.message : err;
this.errors.push({
msg: msg,
time: new Date().toISOString(),
dismissed: false,
});
},
}
};
</script>
14 changes: 6 additions & 8 deletions src/components/EventEditor.vue
Expand Up @@ -39,23 +39,21 @@ div
| Save
</template>

<style lang="scss">
</style>
<style lang="scss"></style>

<script>
import moment from 'moment';
export default {
name: "EventEditor",
name: 'EventEditor',
props: {
event: Object,
bucket_id: String,
},
data() {
return {
editedEvent: JSON.parse(JSON.stringify(this.event)),
}
};
},
computed: {
start: {
Expand All @@ -66,7 +64,7 @@ export default {
// Duration needs to be set first since otherwise the computed for end will use the new timestamp
this.editedEvent.duration = moment(this.end).diff(dt, 'seconds');
this.editedEvent.timestamp = new Date(dt);
}
},
},
end: {
get: function() {
Expand All @@ -84,6 +82,6 @@ export default {
this.$emit('save', this.editedEvent);
await this.$aw.replaceEvent(this.bucket_id, this.editedEvent);
},
}
}
},
};
</script>
75 changes: 38 additions & 37 deletions src/components/Header.vue
Expand Up @@ -63,7 +63,6 @@ div.aw-navbar
</template>

<script>
// only import the icons you use to reduce bundle size
import 'vue-awesome/icons/calendar-day';
import 'vue-awesome/icons/calendar-week';
Expand All @@ -86,54 +85,56 @@ export default {
data() {
return {
activityViews: [],
isAndroidApp: testingAndroid || navigator.userAgent.includes("Android") && navigator.userAgent.includes("wv"), // Checks for Android and WebView
isAndroidApp:
testingAndroid ||
(navigator.userAgent.includes('Android') && navigator.userAgent.includes('wv')), // Checks for Android and WebView
};
},
mounted: async function() {
const buckets = await this.$aw.getBuckets();
const types_by_host = {};
_.each(buckets, (v) => {
types_by_host[v.hostname] = types_by_host[v.hostname] || {};
// The '&& true;' is just to typecoerce into booleans
types_by_host[v.hostname].afk |= v.type == "afkstatus";
types_by_host[v.hostname].window |= v.type == "currentwindow";
types_by_host[v.hostname].android |= v.type == "currentwindow" && this.isAndroidApp; // Use other bucket type ID in the future
})
_.each(buckets, v => {
types_by_host[v.hostname] = types_by_host[v.hostname] || {};
// The '&& true;' is just to typecoerce into booleans
types_by_host[v.hostname].afk |= v.type == 'afkstatus';
types_by_host[v.hostname].window |= v.type == 'currentwindow';
types_by_host[v.hostname].android |= v.type == 'currentwindow' && this.isAndroidApp; // Use other bucket type ID in the future
});
//console.log(types_by_host);
_.each(types_by_host, (types, hostname) => {
if(types.afk && types.window) {
this.activityViews.push({
name: hostname,
hostname: hostname,
type: "default",
pathUrl: `/activity/${hostname}`,
icon: 'desktop'
});
}
if(testingAndroid || types.android) {
this.activityViews.push({
name: `${hostname} (Android)`,
hostname: hostname,
type: "android",
pathUrl: '/activity/android',
icon: 'mobile'
});
}
})
}
}
if (types.afk && types.window) {
this.activityViews.push({
name: hostname,
hostname: hostname,
type: 'default',
pathUrl: `/activity/${hostname}`,
icon: 'desktop',
});
}
if (testingAndroid || types.android) {
this.activityViews.push({
name: `${hostname} (Android)`,
hostname: hostname,
type: 'android',
pathUrl: '/activity/android',
icon: 'mobile',
});
}
});
},
};
</script>

<style lang="scss" scoped>
.aw-navbar {
background-color: #FFF;
border: solid #CCC;
background-color: #fff;
border: solid #ccc;
border-width: 0 0 1px 0;
}
.active {
background-color: #DDD;
background-color: #ddd;
border-radius: 0.5em;
}
Expand All @@ -145,14 +146,14 @@ export default {
border-radius: 0.5em;
&:hover {
background-color: #DDD;
background-color: #ddd;
}
}
.abs-center {
position: absolute;
left: 50%;
transform: translateX(-50%);
position: absolute;
left: 50%;
transform: translateX(-50%);
}
</style>

Expand Down

0 comments on commit f9c0b40

Please sign in to comment.