Commit 2723ed1d authored by Adam Procter's avatar Adam Procter
Browse files

staying connected

ADDED
added a leave button to clear localStorage refs

FIXED:
adding nodes reloads nodes & support for dev changes means you stay connected
parent 8f0cb3a0
<template> <template>
<div v-for="(nodes, index) in myArray" v-bind:key="index"> <div v-for="(nodes, index) in myArray" :key="index">
<form class="nodes"> <form class="nodes">
<template v-if="nodes.node_readmode == false"> <template v-if="nodes.node_readmode == false">
<textarea <textarea
...@@ -55,35 +55,27 @@ export default { ...@@ -55,35 +55,27 @@ export default {
}, },
mounted() { mounted() {
//console.log('mounted')
setTimeout(this.loadData, 500) setTimeout(this.loadData, 500)
//console.log(this.microcosmName.microcosmName)
// NOT SURE THIS IS DOING ANYTHING ???
// const unwatch = this.$watch('nodesFiltered', (value) => {
// this.$options.myArray = this.nodesFiltered
// this.$forceUpdate()
// // ignore falsy values
// if (!value) return
// // stop watching when nodesFiltered[] is not empty
// if (value && value.length) unwatch()
// // process value here
// })
},
watch: { if (localStorage.nogg_name && localStorage.nogg_microcosm) {
added: { var devicename = localStorage.nogg_name
deep: true, var microcosm = localStorage.nogg_microcosm
handler() { this.$store.dispatch('setMicrocosm', { devicename, microcosm })
setTimeout(this.loadData, 500) } else {
}, console.log('no')
}, // go home
}
}, },
methods: { methods: {
loadData() { loadData() {
// console.log('loading data') // console.log('loading data')
this.myArray = this.nodesFiltered var nodesFiltered = this.myNodes.myNodes.filter(
// console.log(this.myArray) (nodes) => nodes.node_deleted == false
// this.$forceUpdate() )
this.$store.dispatch('getMynodes')
this.myArray = nodesFiltered.reverse()
}, },
editNode(e) { editNode(e) {
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<button>Select Node</button> <button>Select Node</button>
<button>Make Connections</button> <button>Make Connections</button>
<UploadMedia /> <UploadMedia />
<button @click="exitMicrocosm()">Exit</button>
</div> </div>
</template> </template>
...@@ -37,6 +38,15 @@ export default { ...@@ -37,6 +38,15 @@ export default {
this.$emit('added-node') this.$emit('added-node')
this.$store.dispatch('addNode') this.$store.dispatch('addNode')
}, },
exitMicrocosm() {
localStorage.removeItem('nogg_microcosm')
localStorage.removeItem('nogg_name')
location.assign(
process.env.VUE_APP_HTTP + '://' + process.env.VUE_APP_URL + '/'
)
},
}, },
} }
</script> </script>
......
...@@ -6,8 +6,6 @@ var deviceName ...@@ -6,8 +6,6 @@ var deviceName
export const state = { export const state = {
myNodes: [], myNodes: [],
activeNode: {}, activeNode: {},
lastMicrocosm: '',
lastdeviceName: '',
} }
export const mutations = { export const mutations = {
...@@ -81,7 +79,7 @@ export const mutations = { ...@@ -81,7 +79,7 @@ export const mutations = {
}) })
}, },
GET_MY_NODES() { GET_MY_NODES() {
// console.log('called ' + deviceName) console.log('called ' + deviceName)
pouchdb pouchdb
.get(deviceName) .get(deviceName)
.then(function (doc) { .then(function (doc) {
...@@ -108,7 +106,6 @@ export const mutations = { ...@@ -108,7 +106,6 @@ export const mutations = {
.get(deviceName) .get(deviceName)
.then(function (doc) { .then(function (doc) {
// put the store into pouchdb // put the store into pouchdb
return pouchdb.bulkDocs([ return pouchdb.bulkDocs([
{ {
_id: deviceName, _id: deviceName,
......
...@@ -14,9 +14,6 @@ export const mutations = { ...@@ -14,9 +14,6 @@ export const mutations = {
SET_MICROCOSM(state, e) { SET_MICROCOSM(state, e) {
state.deviceName = e.devicename state.deviceName = e.devicename
state.microcosmName = e.microcosm state.microcosmName = e.microcosm
// if (state.microcosmName == '') {
// console.log('empty')
// }
pouchdb = new PouchDB(state.microcosmName) pouchdb = new PouchDB(state.microcosmName)
state.pouchdb = pouchdb state.pouchdb = pouchdb
......
<template> <template>
<ToolBar @added-node="addedNode" /> <ToolBar @added-node="addedNode" />
<MyNodes :added="added" /> <MyNodes :added="added" :key="componentKey" />
</template> </template>
<script> <script>
...@@ -21,6 +21,7 @@ export default { ...@@ -21,6 +21,7 @@ export default {
data() { data() {
return { return {
componentKey: 0,
added: true, added: true,
} }
}, },
...@@ -29,6 +30,11 @@ export default { ...@@ -29,6 +30,11 @@ export default {
addedNode() { addedNode() {
//console.log('I hear you!') //console.log('I hear you!')
this.added = !this.added this.added = !this.added
this.forceRender()
},
forceRender() {
// reloads the data after adding a node
this.componentKey += 1
}, },
}, },
} }
......
Supports Markdown
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