Commit 811ebdab authored by Adam Procter's avatar Adam Procter

closer

parent 36056767
Pipeline #199 failed with stages
in 1 minute and 2 seconds
This diff is collapsed.
......@@ -25,7 +25,6 @@ export default {
email:'',
domain:'',
permissions:1,
token:'',
verified:false
}
}
......@@ -35,7 +34,8 @@ export default {
},
methods: {
registeraccount() {
this.$store.dispatch('registeraccount',this.input)
this.$store.dispatch('registeraccount', this.input)
}
}
// var uniqueid = Math.random().toString(36).substring(2, 15)
......
......@@ -27,7 +27,7 @@ new Vue({
render: h => h(App)
}).$mount('#app')
//store.dispatch("db_init");
store.dispatch("db_init")
{
require('@/assets/js/custom')
......
......@@ -5,8 +5,11 @@ import pouchdb from 'pouchdb'
const accounts_db = new pouchdb('accounts');
const knowledge_db = new pouchdb('knowledge');
// server admin has to create DB first and CORS allows specific domains.
var remote_accounts_db = new pouchdb('https://nn.adamprocter.co.uk/accounts');
var remote_knowledge_db = new pouchdb('https://nn.adamprocter.co.uk/knowledge');
//var remote_accounts_db = new pouchdb('https://nn.adamprocter.co.uk/accounts');
//var remote_knowledge_db = new pouchdb('https://nn.adamprocter.co.uk/knowledge');
pouchdb.sync('accounts','https://nn.adamprocter.co.uk/accounts' )
//pouchdb.sync('knowledge','https://nn.adamprocter.co.uk/knowledge' )
Vue.use(Vuex)
......@@ -17,6 +20,7 @@ const LOGOUT = "LOGOUT";
export default new Vuex.Store({
state: {
allobjects: [],
// registeraccount:[],
database: null,
isLoggedIn: !!localStorage.getItem("token"),
},
......@@ -37,29 +41,23 @@ export default new Vuex.Store({
state.isLoggedIn = false;
},
REGISTER_ACCOUNT(data){
REGISTER_ACCOUNT(data, payload){
var uniqueid = Math.random().toString(36).substring(2, 15)
+ Math.random().toString(36).substring(2, 15);
// state.data.push({
console.log(payload)
// before : is the couch name to the right is data from component
accounts_db.put
({
_id:uniqueid,
name:data.name,
email:data.email,
domain:data.domain,
permissions:data.permissions,
token:data.token,
verified:data.verified
name:payload.name,
email:payload.email,
domain:payload.domain,
permissions:payload.permissions,
token:payload.token,
verified:payload.verified
})
// })
// syncData()
// syncData(){
// if (remote_accounts_db) {
// accounts_db.sync(remote_accounts_db)
// }
// }
},
......@@ -73,6 +71,11 @@ export default new Vuex.Store({
},
actions: {
db_init({ commit }){
commit('DB_INIT')
},
// https://www.nativescript.org/blog/data-management-with-sqlite-and-vuex-in-a-nativescript-vue-app
// db initialisation, query, and write need to flow through vuex
// db should be stored in store
......@@ -89,9 +92,9 @@ export default new Vuex.Store({
// });
// },
registeraccount({ commit }, data) {
registeraccount({ commit }, payload) {
commit('REGISTER_ACCOUNT')
commit('REGISTER_ACCOUNT', payload)
},
showKnowledgeObjects({ commit }, payload) {
......
......@@ -28,21 +28,21 @@ name: 'app',
},
data () {
return {
instancename:'mozfest',
accounts: [
{
id:1,
human:'adam procter',
email:'adamprocter@researchnot.es',
permissions: 1
},
{
id:2,
human:'mathew parker',
email:'mathew@researchnot.es',
permissions: 1
}
]
instancename:'mozfest'//,
// accounts: [
// {
// id:1,
// human:'adam procter',
// email:'adamprocter@researchnot.es',
// permissions: 1
// },
// {
// id:2,
// human:'mathew parker',
// email:'mathew@researchnot.es',
// permissions: 1
// }
// ]
}
}
}
......
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