Commit e8ebc7f1 authored by Adam Procter's avatar Adam Procter

trying to move register account to store

this will prove the concept as well for the main knowledge obbjects
parent 65b13777
Pipeline #196 failed with stages
in 1 minute and 14 seconds
This diff is collapsed.
......@@ -11,12 +11,10 @@
</template>
<script>
import pouchdb from 'pouchdb'
var localdb = new pouchdb('accounts');
//import pouchdb from 'pouchdb'
//var localdb = new pouchdb('accounts');
// server admin has to create DB first and CORS allows specific domains.
var db = new pouchdb('https://nn.adamprocter.co.uk/accounts');
//var db = new pouchdb('https://nn.adamprocter.co.uk/accounts');
export default {
name: 'register-account',
......@@ -31,47 +29,50 @@ export default {
}
},
mounted() {
this.syncData();
// this.syncData();
},
methods: {
methods: {
register() {
var uniqueid = Math.random().toString(36).substring(2, 15)
+ Math.random().toString(36).substring(2, 15);
this.$store.dispatch('register')
}
}
// var uniqueid = Math.random().toString(36).substring(2, 15)
// + Math.random().toString(36).substring(2, 15);
localdb.put({
_id:uniqueid,
name:this.name,
email:this.email,
domain:this.domain,
permissions:this.permissions,
token:this.token,
verified:this.verified
})
this.syncData()
},
syncData(){
if (db) {
localdb.sync(db)
}
},
checkData(){
//db.info().then(function (info) {
// // console.log(info);
//})
// db.get('one').then(function (doc) {
// console.log(doc);
// });
// localdb.put({
// _id:uniqueid,
// name:this.name,
// email:this.email,
// domain:this.domain,
// permissions:this.permissions,
// token:this.token,
// verified:this.verified
// })
// this.syncData()
// },
// syncData(){
// if (db) {
// localdb.sync(db)
// }
// },
// checkData(){
// //db.info().then(function (info) {
// // // console.log(info);
// //})
// // db.get('one').then(function (doc) {
// // console.log(doc);
// // });
//db.allDocs({
// include_docs: true,
// attachments: true
//}).then(function (result) {
// // handle result
// // console.log(result)
//})
}
// //db.allDocs({
// // include_docs: true,
// // attachments: true
// //}).then(function (result) {
// // // handle result
// // // console.log(result)
// //})
// }
// }
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
......
......@@ -44,6 +44,32 @@ export default new Vuex.Store({
}
},
actions: {
register() {
var uniqueid = Math.random().toString(36).substring(2, 15)
+ Math.random().toString(36).substring(2, 15);
accounts_db.put({
_id:uniqueid,
name:this.name,
email:this.email,
domain:this.domain,
permissions:this.permissions,
token:this.token,
verified:this.verified
})
//checkData()
// syncData()
},
syncData(){
if (remote_accounts_db) {
accounts_db.sync(remote_accounts_db)
}
},
checkData(){
// ???
},
// 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
......
......@@ -17,7 +17,6 @@ var db = new pouchdb('https://nn.adamprocter.co.uk/knowledge');
// @ is an alias to /src
import instance from "@/components/current-instance.vue";
import logo from "@/components/instance-logo.vue";
import { mapActions } from 'vuex';
export default {
name: 'home',
......@@ -25,11 +24,7 @@ export default {
instance: instance,
logo: logo,
},
methods: {
...mapActions([
'addKnowledgeObject'
]),
},
props:{
instancename: String
},
......
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