Skip to content

Commit

Permalink
Merge pull request #176 from ActivityWatch/dev/demomode
Browse files Browse the repository at this point in the history
Started working on demo mode
  • Loading branch information
ErikBjare committed Mar 16, 2020
2 parents 0a60cf7 + 5a47ebe commit 553cceb
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"plugin:@typescript-eslint/eslint-recommended"
],
"rules": {
"prettier/prettier": "off",
"prettier/prettier": "warn",
"vue/require-default-prop": "off",
"vue/prop-name-casing": "off",
"vue/name-property-casing": "off",
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ clean:
rm -rf node_modules dist

lint:
npx eslint --ext=js,vue src/
npx eslint --ext=js,ts,vue src/

lint-fix:
npx eslint --ext=js,ts,vue --fix src/

aw-client-js:
make --directory=aw-client-js build
34 changes: 31 additions & 3 deletions src/store/modules/activity_daily.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,34 @@ const actions = {
commit('browser_buckets', browser_buckets);
commit('editor_buckets', editor_buckets);
},

async load_demo({ commit }) {
// A function to load some demo data (for screenshots and stuff)
commit('start_loading', {});

commit('query_window_completed', {
duration: 30,
app_events: [{ duration: 10, data: { app: 'test' } }],
title_events: [{ duration: 10, data: { title: 'test' }}],
cat_events: [{ duration: 10, data: { $category: ['test', 'subtest'] }}],
active_events: [{ timestamp: new Date().toISOString(), duration: 1.5*60*60, data: { afk: 'not-afk' }}],
});

commit('browser_buckets', ['aw-watcher-firefox']);
commit('query_browser_completed', {
duration: 20,
domains: [{ duration: 10, data: { $domain: "github.com" } }],
urls: [{ duration: 10, data: { url: "https://github.com/ActivityWatch/activitywatch" } }],
});

commit('editor_buckets', ['aw-watcher-vim']);
commit('query_editor_completed', {
duration: 30,
files: [{ duration: 10, data: { file: "test.py" }}],
languages: [{ duration: 10, data: { language: "python" }}],
projects: [{ duration: 10, data: { project: "aw-core" }}],
});
},
};

// mutations
Expand All @@ -205,9 +233,9 @@ const mutations = {
state.top_urls = null;

state.editor_duration = 0;
state.top_editor_files = null,
state.top_editor_languages = null,
state.top_editor_projects = null,
state.top_editor_files = null;
state.top_editor_languages = null;
state.top_editor_projects = null;

state.top_categories = null;
state.active_duration = null;
Expand Down
8 changes: 8 additions & 0 deletions src/views/activity/daily/ActivityDaily.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ div
div.col-md-6
b-form-group(label="Show category" label-cols="5" label-cols-lg="4")
b-form-select(v-model="filterCategory", :options="categories")

aw-devonly
b-btn(@click="load_demo")
| Load demo data
</template>

<style lang="scss" scoped>
Expand Down Expand Up @@ -188,6 +192,10 @@ export default {
refresh: async function(force) {
await this.$store.dispatch("activity_daily/ensure_loaded", { timeperiod: this.timeperiod, host: this.host, force: force, filterAFK: true, filterCategories: this.filterCategories });
},
load_demo: async function() {
await this.$store.dispatch('activity_daily/load_demo');
},
},
}
</script>

0 comments on commit 553cceb

Please sign in to comment.