summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2018-10-10 09:46:26 +0200
committerJulius Härtl <jus@bitgrid.net>2018-10-23 22:12:11 +0200
commitd5643d82ab8c8160e205970ca346bfba8a7ad947 (patch)
tree4e12655c10b24d00b6ed85d015a0a3f5f5d479e0
parent72655b073486856467f0e57ea31fdbe52d493b6f (diff)
Add vuex structure
Signed-off-by: Julius Härtl <jus@bitgrid.net>
-rw-r--r--src/App.vue33
-rw-r--r--src/main.js6
-rw-r--r--src/store/index.js43
-rw-r--r--src/store/timeline.js40
4 files changed, 106 insertions, 16 deletions
diff --git a/src/App.vue b/src/App.vue
index d97b47a3..984a0d0f 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -97,26 +97,29 @@
};
},
+ beforeMount: function() {
+ let example = {
+ message: 'Want to #DropDropbox? #DeleteGoogle? #decentralize? We got you covered, easy as a piece of 🥞\n' +
+ '\n' +
+ 'Get started right now: https://nextcloud.com/signup',
+ author: 'Nextcloud 📱☁️💻',
+ authorId: '@nextcloud@mastodon.xyz',
+ authorAvatar: OC.linkTo('social', 'img/nextcloud.png'),
+ timestamp: '1 day ago'
+ };
+ let data = [];
+ for (let i=0; i<20; i++) {
+ example.id = Math.floor((Math.random() * 100));
+ data.push(example);
+ }
+ this.$store.commit('addToTimeline', data);
+ },
computed: {
socialId: function() {
return '@' + OC.getCurrentUser().uid + '@' + OC.getHost();
},
timeline: function() {
- let example = {
- message: 'Want to #DropDropbox? #DeleteGoogle? #decentralize? We got you covered, easy as a piece of 🥞\n' +
- '\n' +
- 'Get started right now: https://nextcloud.com/signup',
- author: 'Nextcloud 📱☁️💻',
- authorId: '@nextcloud@mastodon.xyz',
- authorAvatar: OC.linkTo('social', 'img/nextcloud.png'),
- timestamp: '1 day ago'
- };
- let data = [];
- for (let i=0; i<20; i++) {
- example.id = Math.floor((Math.random() * 100));
- data.push(example);
- }
- return data;
+ return this.$store.getters.getTimeline;
},
menu: function () {
let defaultCategories = [
diff --git a/src/main.js b/src/main.js
index bf06512c..892e527b 100644
--- a/src/main.js
+++ b/src/main.js
@@ -23,6 +23,9 @@
import Vue from 'vue'
import App from './App'
+import store from './store';
+
+
Vue.prototype.t = t
Vue.prototype.n = n
Vue.prototype.OC = OC
@@ -30,5 +33,6 @@ Vue.prototype.OCA = OCA
/* eslint-disable-next-line no-new */
new Vue({
- render: h => h(App)
+ render: h => h(App),
+ store: store
}).$mount('#content')
diff --git a/src/store/index.js b/src/store/index.js
new file mode 100644
index 00000000..061ad400
--- /dev/null
+++ b/src/store/index.js
@@ -0,0 +1,43 @@
+/*
+ * @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com>
+ *
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
+ * @author Julius Härtl <jus@bitgrid.net>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+import Vue from 'vue';
+import Vuex from 'vuex';
+import timeline from './timeline';
+
+Vue.use(Vuex)
+
+const debug = process.env.NODE_ENV !== 'production';
+
+const mutations = {
+
+};
+
+export default new Vuex.Store({
+ modules: {
+ timeline
+ },
+ strict: debug,
+
+ mutations
+});
diff --git a/src/store/timeline.js b/src/store/timeline.js
new file mode 100644
index 00000000..00028d3b
--- /dev/null
+++ b/src/store/timeline.js
@@ -0,0 +1,40 @@
+/*
+ * @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
+ *
+ * @author Julius Härtl <jus@bitgrid.net>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+const state = {
+ timeline: []
+};
+const mutations = {
+ addToTimeline(state, data) {
+ for (let item in data) {
+ state.timeline.push(data[item]);
+ }
+ }
+};
+const getters = {
+ getTimeline(state) {
+ return state.timeline;
+ }
+};
+const actions = {};
+
+export default {state, mutations, getters, actions};