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 cbfd273d authored by Adam Procter's avatar Adam Procter
Browse files

Merge branch 'positions' into main

parents 68ee64ae 7b175f25
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
<router-link to="/">Start</router-link> | <router-link to="/">Start</router-link> |
<router-link to="/credits">Credits</router-link> | <router-link to="/credits">Credits</router-link> |
<router-link to="/collect">Collect</router-link> | <router-link to="/collect">Collect</router-link> |
<router-link to="/cards">Cards</router-link> <router-link to="/cards">Cards</router-link> |
<router-link to="/spatial">Spatial</router-link>
</div> </div>
<router-view /> <router-view />
</template> </template>
......
...@@ -133,11 +133,15 @@ export default { ...@@ -133,11 +133,15 @@ export default {
}, },
mounted() { mounted() {
// this.$store.dispatch('getEmoji')
// this.$store.dispatch('getPositions')
setTimeout(this.loadData, 500) setTimeout(this.loadData, 500)
if (localStorage.nogg_name && localStorage.nogg_microcosm) { if (localStorage.nogg_name && localStorage.nogg_microcosm) {
var devicename = localStorage.nogg_name var devicename = localStorage.nogg_name
var microcosm = localStorage.nogg_microcosm var microcosm = localStorage.nogg_microcosm
this.$store.dispatch('setMicrocosm', { devicename, microcosm }) this.$store.dispatch('setMicrocosm', { devicename, microcosm })
// this.$store.dispatch('getEmoji')
// this.$store.dispatch('getPositions')
} else { } else {
console.log('no') console.log('no')
// go home // go home
...@@ -236,8 +240,10 @@ export default { ...@@ -236,8 +240,10 @@ export default {
var nodesFiltered = this.myNodes.myNodes.filter( var nodesFiltered = this.myNodes.myNodes.filter(
(nodes) => nodes.node_deleted == false (nodes) => nodes.node_deleted == false
) )
// this should probably be on the tool bar NOT HERE really
this.$store.dispatch('getMynodes') this.$store.dispatch('getMynodes')
this.$store.dispatch('getEmoji') this.$store.dispatch('getEmoji')
this.$store.dispatch('getPositions')
this.myArray = nodesFiltered.reverse() this.myArray = nodesFiltered.reverse()
}, },
......
...@@ -80,6 +80,7 @@ export default { ...@@ -80,6 +80,7 @@ export default {
mounted() { mounted() {
this.$store.dispatch('getOthernodes') this.$store.dispatch('getOthernodes')
this.$store.dispatch('getEmoji')
setTimeout(this.loadData, 500) setTimeout(this.loadData, 500)
// this is to get the last letter typed if no space // this is to get the last letter typed if no space
// this also loads in new Emoji // this also loads in new Emoji
...@@ -92,8 +93,6 @@ export default { ...@@ -92,8 +93,6 @@ export default {
this.nodeid = nodeid this.nodeid = nodeid
}, },
handleEmojiClick(nodeid, detail) { handleEmojiClick(nodeid, detail) {
console.log(nodeid)
var unicode = detail.emoji.unicode var unicode = detail.emoji.unicode
var annotation = detail.emoji.annotation var annotation = detail.emoji.annotation
var skinTone = detail.skinTone var skinTone = detail.skinTone
......
<template>
<div></div>
</template>
<script>
// @ is an alias to /src
import { mapState } from 'vuex'
export default {
name: 'SpaceBase',
components: {},
data() {
return {}
},
computed: {
...mapState({
otherNodes: (state) => state.otherNodes,
allEmoji: (state) => state.allEmoji,
}),
},
mounted() {
this.$store.dispatch('getPositions')
},
}
</script>
<style scoped></style>
...@@ -48,6 +48,16 @@ const routes = [ ...@@ -48,6 +48,16 @@ const routes = [
component: () => component: () =>
import(/* webpackChunkName: "cards" */ '../views/Cards.vue'), import(/* webpackChunkName: "cards" */ '../views/Cards.vue'),
}, },
{
path: '/spatial',
name: 'Spatial',
beforeEnter: guardMyroute,
// route level code-splitting
// this generates a separate chunk (credits.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () =>
import(/* webpackChunkName: "cards" */ '../views/Spatial.vue'),
},
] ]
const router = createRouter({ const router = createRouter({
......
var pouchdb var pouchdb
export const state = { export const state = {
docName: 'emojis', docEmoji: 'emojis',
allEmoji: [], allEmoji: [],
} }
export const mutations = { export const mutations = {
GET_EMOJI(state) { GET_EMOJI(state) {
pouchdb pouchdb
.get(state.docName) .get(state.docEmoji)
.then(function (doc) { .then(function (doc) {
state.allEmoji = doc.emojis state.allEmoji = doc.emojis
}) })
.catch(function (err) { .catch(function (err) {
if (err.status == 404) { if (err.status == 404) {
return pouchdb.put({ return pouchdb.put({
_id: state.docName, _id: state.docEmoji,
emojis: [], emojis: [],
}) })
} }
...@@ -25,7 +25,7 @@ export const mutations = { ...@@ -25,7 +25,7 @@ export const mutations = {
var uniqueid = var uniqueid =
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15) +
Math.random().toString(36).substring(2, 15) Math.random().toString(36).substring(2, 15)
pouchdb.get(state.docName).then(function (doc) { pouchdb.get(state.docEmoji).then(function (doc) {
doc.emojis.push({ doc.emojis.push({
emoji_id: uniqueid, emoji_id: uniqueid,
node_id: e.nodeid, node_id: e.nodeid,
...@@ -36,7 +36,7 @@ export const mutations = { ...@@ -36,7 +36,7 @@ export const mutations = {
}) })
return pouchdb return pouchdb
.put({ .put({
_id: state.docName, _id: state.docEmoji,
_rev: doc._rev, _rev: doc._rev,
emojis: doc.emojis, emojis: doc.emojis,
}) })
......
var pouchdb
export const state = {
docPositions: 'positions',
allPositions: [],
}
export const mutations = {
GET_POSITIONS(state) {
pouchdb
.get(state.docPositions)
.then(function (doc) {
state.allPositions = doc.positions
})
.catch(function (err) {
console.log(err)
if (err.status == 404) {
return pouchdb.put({
_id: state.docPositions,
positions: [],
})
}
})
},
UPDATE_POSTION(state, e) {
var i
for (i = 0; i < Object.keys(state.allPositions).length; i++) {
if (e.nodeid == state.allPositions[i].node_id) {
state.allPositions[i].node_x = e.x
state.allPositions[i].node_y = e.y
state.allPositions[i].node_width = e.width
state.allPositions[i].node_height = e.height
state.allPositions[i].node_zindex = e.zindex
}
}
pouchdb
.get(state.docPositions)
.then(function (doc) {
return pouchdb.bulkDocs([
{
_id: state.docPositions,
_rev: doc._rev,
positions: state.allPositions,
},
])
})
.then(function () {
return pouchdb.get(state.global_pos_name).then(function (doc) {
state.allPositions = doc.positions
})
})
.catch(function (err) {
if (err.status == 404) {
// pouchdb.put({ })
}
})
},
}
export const actions = {
getPositions: ({ commit }) => {
commit('GET_POSITIONS')
},
// movePos: ({ commit }, nodeid, xpos, ypos, width, height, zindex) => {
// commit('MOVE_POS', nodeid, xpos, ypos, width, height, zindex)
// },
getMicrocosm(vuexContext) {
pouchdb = vuexContext.rootState.setup.pouchdb
},
}
export const getters = {}
var pouchdb var pouchdb
var deviceName var deviceName
//var microcosmName
// var e var docPositions
export const state = { export const state = {
myNodes: [], myNodes: [],
...@@ -52,6 +52,28 @@ export const mutations = { ...@@ -52,6 +52,28 @@ export const mutations = {
console.log(err) console.log(err)
}) })
}) })
pouchdb.get(docPositions).then(function (doc) {
doc.positions.push({
node_id: uniqueid,
node_x: 0,
node_y: 0,
node_width: 200,
node_height: 370,
node_zindex: 0,
node_sort: 0,
node_radius: 0,
node_shape: 0,
})
return pouchdb
.put({
_id: docPositions,
_rev: doc._rev,
positions: doc.positions,
})
.catch(function (err) {
console.log(err)
})
})
}) })
.catch(function (err) { .catch(function (err) {
// HITS a 404 on very first node being created // HITS a 404 on very first node being created
...@@ -93,9 +115,30 @@ export const mutations = { ...@@ -93,9 +115,30 @@ export const mutations = {
.catch(function (err) { .catch(function (err) {
console.log(err) console.log(err)
}) })
pouchdb.get(docPositions).then(function (doc) {
doc.positions.push({
node_id: uniqueid,
node_x: 0,
node_y: 0,
node_width: 200,
node_height: 370,
node_zindex: 0,
node_sort: 0,
})
return pouchdb
.put({
_id: docPositions,
_rev: doc._rev,
positions: doc.positions,
})
.catch(function (err) {
console.log(err)
})
})
} }
}) })
}, },
GET_MY_NODES() { GET_MY_NODES() {
pouchdb pouchdb
.get(deviceName) .get(deviceName)
...@@ -325,18 +368,8 @@ export const actions = { ...@@ -325,18 +368,8 @@ export const actions = {
getMicrocosm(vuexContext) { getMicrocosm(vuexContext) {
deviceName = vuexContext.rootState.setup.deviceName deviceName = vuexContext.rootState.setup.deviceName
// microcosmName = vuexContext.rootState.setup.microcosmName
pouchdb = vuexContext.rootState.setup.pouchdb pouchdb = vuexContext.rootState.setup.pouchdb
docPositions = vuexContext.rootState.allPositions.docPositions
// if (deviceName == '') {
// vuexContext.dispatch('setMicrocosm', e, { root: true })
// } else {
// //
// this.microcosm = microcosmName
// this.deviceName = deviceName
// e = (this.devicename, this.microcosm)
// // this.pouchdb = pouchdb
// }
}, },
} }
......
var pouchdb var pouchdb
var deviceName var deviceName
var docName var docEmoji
var docPositions
export const state = { export const state = {
allNodes: [], allNodes: [],
...@@ -26,11 +27,13 @@ export const mutations = { ...@@ -26,11 +27,13 @@ export const mutations = {
state.otherNodes = [] state.otherNodes = []
var i var i
var j var j
// console.log(docEmoji)
// console.log(docPositions)
for (i = 0; i < Object.keys(state.allNodes).length; i++) { for (i = 0; i < Object.keys(state.allNodes).length; i++) {
if ( if (
state.allNodes[i].id != deviceName && state.allNodes[i].id != deviceName &&
state.allNodes[i].id != docName state.allNodes[i].id != docEmoji &&
state.allNodes[i].id != docPositions
) { ) {
for (j = 0; j < Object.keys(state.allNodes[i].doc.nodes).length; j++) { for (j = 0; j < Object.keys(state.allNodes[i].doc.nodes).length; j++) {
const newNode = { const newNode = {
...@@ -59,7 +62,8 @@ export const actions = { ...@@ -59,7 +62,8 @@ export const actions = {
getMicrocosm(vuexContext) { getMicrocosm(vuexContext) {
deviceName = vuexContext.rootState.setup.deviceName deviceName = vuexContext.rootState.setup.deviceName
pouchdb = vuexContext.rootState.setup.pouchdb pouchdb = vuexContext.rootState.setup.pouchdb
docName = vuexContext.rootState.allEmoji.docName docEmoji = vuexContext.rootState.allEmoji.docEmoji
docPositions = vuexContext.rootState.allPositions.docPositions
}, },
} }
......
...@@ -72,6 +72,7 @@ export const actions = { ...@@ -72,6 +72,7 @@ export const actions = {
pouchdb.replicate.from(remote).on('complete', function () { pouchdb.replicate.from(remote).on('complete', function () {
// GET_MYNODES from myNodes.js ACTION // GET_MYNODES from myNodes.js ACTION
vuexContext.dispatch('getMynodes', null, { root: true }) vuexContext.dispatch('getMynodes', null, { root: true })
// vuexContext.dispatch('getPositions', null, { root: true })
pouchdb pouchdb
.sync(state.remoteAddress, { .sync(state.remoteAddress, {
live: true, live: true,
...@@ -80,6 +81,8 @@ export const actions = { ...@@ -80,6 +81,8 @@ export const actions = {
}) })
.on('change', function () { .on('change', function () {
vuexContext.dispatch('getOthernodes', null, { root: true }) vuexContext.dispatch('getOthernodes', null, { root: true })
// vuexContext.dispatch('getEmoji', null, { root: true })
// vuexContext.dispatch('getPositions', null, { root: true })
}) })
.on('paused', function () {}) .on('paused', function () {})
.on('active', function () { .on('active', function () {
......
...@@ -4,16 +4,15 @@ import * as setup from '@/store/modules/setup.js' ...@@ -4,16 +4,15 @@ import * as setup from '@/store/modules/setup.js'
import * as myNodes from '@/store/modules/myNodes.js' import * as myNodes from '@/store/modules/myNodes.js'
import * as otherNodes from '@/store/modules/otherNodes.js' import * as otherNodes from '@/store/modules/otherNodes.js'
import * as allEmoji from '@/store/modules/allEmoji.js' import * as allEmoji from '@/store/modules/allEmoji.js'
import * as allPositions from '@/store/modules/allPositions.js'
export const store = createStore({ export const store = createStore({
//
modules: { modules: {
setup, setup,
myNodes, myNodes,
otherNodes, otherNodes,
allEmoji, allEmoji,
allPositions,
}, },
actions: {},
}) })
export default store export default store
<template>
<ToolBar @added-node="addedNode" />
<SpaceBase />
</template>
<script>
// @ is an alias to /src
import ToolBar from '@/components/ToolBar.vue'
import SpaceBase from '@/components/SpaceBase.vue'
export default {
mounted() {},
name: 'Spatial',
components: {
ToolBar,
SpaceBase,
},
data() {
return {
added: false,
}
},
}
</script>
<style scoped></style>
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