Administrator approval is now required for registering new accounts. If you are registering a new account, and are external to the University, please ask the repository owner to contact ServiceLine to request your account be approved. Repository owners must include the newly registered email address, and specific repository in the request for approval.

Commit 1226d3b2 authored by Adam Procter's avatar Adam Procter
Browse files

added other nodes live sync now working

parent fbb6a6dc
<template> <template>
<div v-for="(nodes, index) in otherArray" :key="index"> <div v-for="(nodes, index) in otherNodes.otherNodes" :key="index">
<p <p class="readmode" :id="nodes.id">
class="readmode" {{ nodes.text }}
:id="nodes.node_id" </p>
:inner-html.prop="nodes.node_text"
></p>
</div> </div>
</template> </template>
...@@ -17,45 +15,20 @@ import { mapState } from 'vuex' ...@@ -17,45 +15,20 @@ import { mapState } from 'vuex'
export default { export default {
name: 'OtherNodes', name: 'OtherNodes',
data() {
return {
otherArray: [],
}
},
computed: { computed: {
...mapState({ ...mapState({
otherNodes: (state) => state.otherNodes, otherNodes: (state) => state.otherNodes,
}), }),
}, },
// watch: {
// added: function () {
// this.loadData()
// },
// },
mounted() { mounted() {
//console.log('mounted') this.$store.dispatch('getOthernodes')
setTimeout(this.loadData, 500) setTimeout(this.loadData, 500)
// if (localStorage.nogg_microcosm) {
// // var devicename = localStorage.nogg_name
// var microcosm = localStorage.nogg_microcosm
// this.$store.dispatch('setMicrocosm', { microcosm })
// } else {
// console.log('no')
// // go home
// }
}, },
methods: { methods: {
loadData() { loadData() {
var othersFiltered = this.otherNodes.otherNodes.filter( this.$store.dispatch('setOthernodes')
(nodes) => nodes.node_deleted == false
)
this.$store.dispatch('getOthernodes')
this.otherArray = othersFiltered
}, },
}, },
} }
......
var pouchdb var pouchdb
var deviceName
// PRETTY SURE this is wrong
import * as store from '@/store/store.js'
export const state = { export const state = {
allNodes: [], allNodes: [],
...@@ -17,8 +15,7 @@ export const mutations = { ...@@ -17,8 +15,7 @@ export const mutations = {
}) })
.then(function (doc) { .then(function (doc) {
state.allNodes = doc.rows state.allNodes = doc.rows
// TODO: THIS IS NOT working console.log('get all nodes')
store.commit('SET_OTHER_NODES')
}) })
.catch(function (err) { .catch(function (err) {
console.log(err) console.log(err)
...@@ -26,19 +23,22 @@ export const mutations = { ...@@ -26,19 +23,22 @@ export const mutations = {
}, },
SET_OTHER_NODES(state) { SET_OTHER_NODES(state) {
console.log('setting')
state.otherNodes = [] state.otherNodes = []
var i var i
var j var j
for (i = 0; i < Object.keys(state.allNodes).length; i++) { for (i = 0; i < Object.keys(state.allNodes).length; i++) {
for (j = 0; j < Object.keys(state.allNodes[i].doc.nodes).length; j++) { if (state.allNodes[i].id != deviceName) {
const newNode = { for (j = 0; j < Object.keys(state.allNodes[i].doc.nodes).length; j++) {
id: state.allNodes[i].doc.nodes[j].node_id, const newNode = {
text: state.allNodes[i].doc.nodes[j].node_text, id: state.allNodes[i].doc.nodes[j].node_id,
deleted: state.allNodes[i].doc.nodes[j].node_deleted, text: state.allNodes[i].doc.nodes[j].node_text,
color: state.allNodes[i].doc.nodes[j].node_color, deleted: state.allNodes[i].doc.nodes[j].node_deleted,
color: state.allNodes[i].doc.nodes[j].node_color,
}
state.otherNodes.push(newNode)
} }
state.otherNodes.push(newNode)
} }
} }
}, },
...@@ -47,9 +47,15 @@ export const mutations = { ...@@ -47,9 +47,15 @@ export const mutations = {
export const actions = { export const actions = {
getOthernodes: ({ commit }) => { getOthernodes: ({ commit }) => {
commit('GET_ALL_NODES') commit('GET_ALL_NODES')
commit('SET_OTHER_NODES')
},
setOthernodes: ({ commit }) => {
commit('SET_OTHER_NODES')
}, },
getMicrocosm(vuexContext) { getMicrocosm(vuexContext) {
deviceName = vuexContext.rootState.setup.deviceName
pouchdb = vuexContext.rootState.setup.pouchdb pouchdb = vuexContext.rootState.setup.pouchdb
}, },
} }
......
...@@ -79,8 +79,7 @@ export const actions = { ...@@ -79,8 +79,7 @@ export const actions = {
retry: true, retry: true,
}) })
.on('change', function () { .on('change', function () {
// console.log('change happened') vuexContext.dispatch('getOthernodes', null, { root: true })
// vuexContext.dispatch('getNodes', null, { root: true })
}) })
.on('paused', function () {}) .on('paused', function () {})
.on('active', function () { .on('active', function () {
......
<template> <template>
<ToolBar @added-node="addedNode" /> <ToolBar @added-node="addedNode" />
<MyNodes :added="added" />
<OtherNodes /> <OtherNodes />
<MyNodes :added="added" />
</template> </template>
<script> <script>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment