Skip to content

Commit

Permalink
style: fixed lints, applied prettier v2 style, removed old Log view
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Jul 16, 2020
1 parent 5b35c95 commit 91878ee
Show file tree
Hide file tree
Showing 39 changed files with 162 additions and 268 deletions.
4 changes: 2 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ import 'vue-awesome/icons/brands/twitter';
import 'vue-awesome/icons/brands/github';
export default {
data: function() {
data: function () {
return {
activityViews: [],
info: {},
};
},
mounted: async function() {
mounted: async function () {
this.$aw.getInfo().then(
info => {
this.info = info;
Expand Down
10 changes: 6 additions & 4 deletions src/components/CategoryEditTree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ import 'vue-awesome/icons/trash';
import 'vue-awesome/icons/plus';
import 'vue-awesome/icons/edit';
import _ from 'lodash';
export default {
name: 'CategoryEditTree',
props: {
Expand All @@ -75,14 +77,14 @@ export default {
};
},
computed: {
allCategories: function() {
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);
},
allRuleTypes: function() {
allRuleTypes: function () {
return [
{ value: null, text: 'None' },
{ value: 'regex', text: 'Regular Expression' },
Expand All @@ -91,13 +93,13 @@ export default {
},
},
methods: {
addSubclass: function(parent) {
addSubclass: function (parent) {
this.$store.commit('settings/addClass', {
name: parent.name.concat(['New class']),
rule: { type: 'regex', regex: 'FILL ME' },
});
},
removeClass: function(_class) {
removeClass: function (_class) {
// TODO: Show a confirmation dialog
// TODO: Remove children as well?
// TODO: Move button to edit modal?
Expand Down
8 changes: 4 additions & 4 deletions src/components/EventEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,21 @@ export default {
},
computed: {
start: {
get: function() {
get: function () {
return moment(this.editedEvent.timestamp).format();
},
set: function(dt) {
set: function (dt) {
// 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() {
get: function () {
const end = moment(this.editedEvent.timestamp).add(this.editedEvent.duration, 'seconds');
return end.format();
},
set: function(dt) {
set: function (dt) {
this.editedEvent.duration = moment(dt).diff(this.editedEvent.timestamp, 'seconds');
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default {
activityViews: [],
};
},
mounted: async function() {
mounted: async function () {
const buckets = await this.$aw.getBuckets();
const types_by_host = {};
Expand Down
6 changes: 3 additions & 3 deletions src/components/SelectableVisualization.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default {
id: Number,
type: String,
},
data: function() {
data: function () {
return {
types: [
'top_apps',
Expand Down Expand Up @@ -119,7 +119,7 @@ export default {
};
},
computed: {
visualizations: function() {
visualizations: function () {
return {
top_apps: {
title: 'Top Applications',
Expand Down Expand Up @@ -165,7 +165,7 @@ export default {
},
};
},
top_categories_hierarchy: function() {
top_categories_hierarchy: function () {
const top_categories = this.$store.state.activity.category.top;
if (top_categories) {
const categories = top_categories.map(c => {
Expand Down
6 changes: 3 additions & 3 deletions src/components/StopwatchEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ export default {
},
},
methods: {
stop: async function() {
stop: async function () {
let new_event = JSON.parse(JSON.stringify(this.event));
new_event.data.running = false;
new_event.duration = (moment() - moment(new_event.timestamp)) / 1000;
new_event = await this.$aw.replaceEvent(this.bucket_id, new_event);
this.$emit('update', new_event);
},
save: async function(new_event) {
save: async function (new_event) {
this.$emit('update', new_event);
},
delete_: async function(new_event) {
delete_: async function (new_event) {
this.$emit('delete', new_event);
},
},
Expand Down
6 changes: 3 additions & 3 deletions src/mixins/asyncErrorCaptured.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ function handleError(error, vm, info) {
}

export default {
beforeCreate: function() {
beforeCreate: function () {
const that = this;
const methods = this.$options.methods || {};
for (const key in methods) {
const original = methods[key];
methods[key] = function(...args) {
methods[key] = function (...args) {
try {
const result = original.apply(this, args);
// let's analyse what is returned from the method
if (result && typeof result.then === 'function' && typeof result.catch === 'function') {
// this looks like a Promise. let's handle it's errors:
return result.catch(function(err) {
return result.catch(function (err) {
handleError(err, that, key);
});
} else return result;
Expand Down
2 changes: 0 additions & 2 deletions src/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const Buckets = () => import('./views/Buckets.vue');
const Bucket = () => import('./views/Bucket.vue');
const QueryExplorer = () => import('./views/QueryExplorer.vue');
const Timeline = () => import('./views/Timeline.vue');
const Log = () => import('./views/Log.vue');
const Settings = () => import('./views/settings/Settings.vue');
const Stopwatch = () => import('./views/Stopwatch.vue');
const Dev = () => import('./views/Dev.vue');
Expand Down Expand Up @@ -67,7 +66,6 @@ const router = new VueRouter({
{ path: '/buckets/:id', component: Bucket, props: true },
{ path: '/timeline', component: Timeline },
{ path: '/query', component: QueryExplorer },
{ path: '/log', component: Log },
{ path: '/settings', component: Settings },
{ path: '/stopwatch', component: Stopwatch },
{ path: '/dev', component: Dev },
Expand Down
10 changes: 5 additions & 5 deletions src/util/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ import { seconds_to_duration, friendlydate } from './time.js';

import moment from 'moment';

Vue.filter('shortdate', function(timestamp) {
Vue.filter('shortdate', function (timestamp) {
return moment(timestamp).format('YYYY-MM-DD');
});

Vue.filter('shorttime', function(timestamp) {
Vue.filter('shorttime', function (timestamp) {
return moment(timestamp).format('HH:mm');
});

Vue.filter('friendlytime', function(timestamp) {
Vue.filter('friendlytime', function (timestamp) {
return friendlydate(timestamp);
});

Vue.filter('iso8601', function(timestamp) {
Vue.filter('iso8601', function (timestamp) {
return moment.parseZone(timestamp).format();
});

Vue.filter('friendlyduration', function(seconds) {
Vue.filter('friendlyduration', function (seconds) {
return seconds_to_duration(seconds);
});

Expand Down
14 changes: 3 additions & 11 deletions src/util/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,11 @@ export function get_day_start_with_offset(dateParam) {
const start_of_day = localStorage.startOfDay;
const start_of_day_hours = parseInt(start_of_day.split(':')[0]);
const start_of_day_minutes = parseInt(start_of_day.split(':')[1]);
return dateMoment
.hour(start_of_day_hours)
.minute(start_of_day_minutes)
.format();
return dateMoment.hour(start_of_day_hours).minute(start_of_day_minutes).format();
}

export function get_day_end_with_offset(date) {
return moment(get_day_start_with_offset(date))
.add(1, 'days')
.format();
return moment(get_day_start_with_offset(date)).add(1, 'days').format();
}

export function get_day_period(date) {
Expand All @@ -61,8 +56,5 @@ export function get_offset() {

export function get_today() {
// Gets "today" in an offset-aware way
return moment()
.subtract(get_offset())
.startOf('day')
.format('YYYY-MM-DD');
return moment().subtract(get_offset()).startOf('day').format('YYYY-MM-DD');
}
10 changes: 5 additions & 5 deletions src/views/Bucket.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,28 @@ export default {
},
},
watch: {
daterange: async function() {
daterange: async function () {
await this.getEvents(this.id);
},
},
mounted: async function() {
mounted: async function () {
await this.$store.dispatch('buckets/ensureBuckets');
await this.getEvents(this.id);
await this.getEventCount(this.id);
},
methods: {
getEvents: async function(bucket_id) {
getEvents: async function (bucket_id) {
this.bucket_with_events = await this.$store.dispatch('buckets/getBucketWithEvents', {
id: bucket_id,
start: this.daterange[0].format(),
end: this.daterange[1].format(),
});
this.events = this.bucket_with_events.events;
},
getEventCount: async function(bucket_id) {
getEventCount: async function (bucket_id) {
this.eventcount = (await this.$aw.countEvents(bucket_id)).data;
},
updateEvent: function(event) {
updateEvent: function (event) {
const i = this.events.findIndex(e => e.id == event.id);
if (i != -1) {
// This is needed instead of this.events[i] because insides of arrays
Expand Down
12 changes: 6 additions & 6 deletions src/views/Buckets.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ export default {
};
},
computed: {
buckets: function() {
buckets: function () {
return _.orderBy(this.$store.state.buckets.buckets, [b => b.id], ['asc']);
},
},
watch: {
import_file: async function(_new_value, _old_value) {
import_file: async function (_new_value, _old_value) {
if (this.import_file != null) {
console.log('Importing file');
try {
Expand All @@ -145,19 +145,19 @@ export default {
}
},
},
mounted: async function() {
mounted: async function () {
await this.$store.dispatch('buckets/ensureBuckets');
},
methods: {
openDeleteBucketModal: function(bucketId) {
openDeleteBucketModal: function (bucketId) {
this.delete_bucket_selected = bucketId;
this.$root.$emit('bv::show::modal', 'delete-modal');
},
deleteBucket: async function(bucketId) {
deleteBucket: async function (bucketId) {
await this.$store.dispatch('buckets/deleteBucket', { bucketId });
this.$root.$emit('bv::hide::modal', 'delete-modal');
},
importBuckets: async function(importFile) {
importBuckets: async function (importFile) {
const formData = new FormData();
formData.append('buckets.json', importFile);
const headers = { 'Content-Type': 'multipart/form-data' };
Expand Down
6 changes: 3 additions & 3 deletions src/views/Dev.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ console.log(moment);
export default {
name: 'aw-dev',
data: function() {
data: function () {
return {
queryOptions: {
aw_client: this.$aw,
Expand All @@ -31,10 +31,10 @@ export default {
console.log(this.$store);
},
methods: {
query_window_timing: async function() {
query_window_timing: async function () {
await this.$store.dispatch('activity/query_window', this.queryOptions);
},
query_browser_timing: async function() {
query_browser_timing: async function () {
await this.$store.dispatch('activity/query_browser', this.queryOptions);
},
},
Expand Down
61 changes: 0 additions & 61 deletions src/views/Log.vue

This file was deleted.

Loading

0 comments on commit 91878ee

Please sign in to comment.