Commit a89a9b81 authored by Adam Procter's avatar Adam Procter

further away

parent 983c6766
Pipeline #201 failed with stages
in 1 minute and 9 seconds
This diff is collapsed.
<template>
<section class="register">
<h1>Register</h1>
<form @submit.prevent="registeraccount()">
<form @submit="registeraccount()">
<!-- <form @submit.prevent="registeraccount()"> -->
<input type="text" name="name" v-model="name" placeholder="Name" />
<input type="text" name="email" v-model="email" placeholder="Email" />
<input type="text" name="domain" v-model="domain" placeholder="Domain" />
......@@ -34,8 +35,8 @@ export default {
},
methods: {
registeraccount() {
console.log(this.name)
this.$store.dispatch('registeraccount', this.input)
//console.log(this.name)
this.$store.dispatch('registerAccount', this.input)
}
}
// var uniqueid = Math.random().toString(36).substring(2, 15)
......
......@@ -3,7 +3,7 @@
<div id="user-interface">
<!-- the SVG.js stuff appears here -->
<styledviewer></styledviewer>
<!-- <styledviewer></styledviewer> -->
</div>
</template>
......@@ -15,13 +15,13 @@ import draggy from 'svg.draggy.js'
import connectable from 'svg.connectable.js'
import { mapGetters } from 'vuex';
import styledviewer from "@/components/styled-viewer.vue";
//import styledviewer from "@/components/styled-viewer.vue";
export default {
name: 'user-interface',
components: {
styledviewer: styledviewer
},
// components: {
// styledviewer: styledviewer
// },
// data:{
// },
methods: {
......
......@@ -4,13 +4,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');
pouchdb.sync('accounts','https://nn.adamprocter.co.uk/accounts' )
//pouchdb.sync('knowledge','https://nn.adamprocter.co.uk/knowledge' )
Vue.use(Vuex)
const LOGIN = "LOGIN";
......@@ -47,7 +45,7 @@ export default new Vuex.Store({
+ Math.random().toString(36).substring(2, 15);
//console.log(payload)
// before : is the couch name to the right is data from component
accounts_db.put
accounts_db.put
({
_id:uniqueid,
name:payload.name,
......@@ -57,16 +55,32 @@ export default new Vuex.Store({
token:payload.token,
verified:payload.verified
})
pouchdb.sync('accounts','https://nn.adamprocter.co.uk/accounts' )
},
SHOW_KNOWLEDGE_OBJECTS (state, payload) {
var ids = [];
state.allobjects.forEach(item => {ids.push(item.id)})
if (!ids.includes(payload.id)){
state.allobjects.push(payload);
}
},
ADD_KNOWLEDGE_OBJECT(data, payload){
var uniqueid = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
knowledge_db.put
({
_id:uniqueid,
type:payload.type,
author:localStorage.getItem("token"),
title:payload.title,
connections:payload.connections,
metadata:payload.metadata,
})
pouchdb.sync('knowledge','https://nn.adamprocter.co.uk/knowledge' )
}
},
actions: {
......@@ -76,23 +90,7 @@ export default new Vuex.Store({
},
// 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
//db_init(context) {
//(new pouchdb('accounts')).then(db => {
// console.log("Initiated local pouch")
// db.execSQL("CREATE TABLE IF NOT EXISTS people (id INTEGER PRIMARY KEY AUTOINCREMENT, firstname TEXT, lastname TEXT)").then(id => {
// context.commit("DB_INIT", { database: db });
// }, error => {
// console.log("CREATE TABLE ERROR", error);
// });
// }, error => {
// console.log("OPEN DB ERROR", error);
// });
// },
registeraccount({ commit }, payload) {
registerAccount({ commit }, payload) {
commit('REGISTER_ACCOUNT', payload)
},
......@@ -100,6 +98,11 @@ export default new Vuex.Store({
showKnowledgeObjects({ commit }, payload) {
commit('SHOW_KNOWLEDGE_OBJECTS', payload)
},
addKnowledgeObject({ commit }, payload) {
commit('ADD_KNOWLEDGE_OBJECT', payload)
},
login({ commit }, payload) {
commit(LOGIN, payload);
......
......@@ -21,11 +21,11 @@
</template>
<script>
import pouchdb from 'pouchdb'
//import pouchdb from 'pouchdb'
var localdb = new pouchdb('knowledge');
//var localdb = new pouchdb('knowledge');
// server admin has to create DB first and CORS allows specific domains.
var db = new pouchdb('https://nn.adamprocter.co.uk/knowledge');
//var db = new pouchdb('https://nn.adamprocter.co.uk/knowledge');
import logo from "@/components/instance-logo.vue";
......@@ -37,41 +37,46 @@ name: 'editor',
},
data() {
return {
type:'',
author:'',
title:'',
connections:[],
metadata:{},
// input :{
type:'',
author:'',
title:'',
connections:[],
metadata:{}
// }
}
},
mounted() {
this.syncData();
// this.syncData();
},
methods: {
addKnowledge() {
var uniqueid = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
localdb.put({
_id:uniqueid,
type:this.type,
author:localStorage.getItem("token"),
// need to change owner in DB
title:this.title,
connections:this.connections,
metadata:this.metadata,
this.$store.dispatch('addKnowledgeObject', this.input)
// var uniqueid = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
// localdb.put({
// _id:uniqueid,
// type:this.type,
// author:localStorage.getItem("token"),
// // need to change owner in DB
// title:this.title,
// connections:this.connections,
// metadata:this.metadata,
})
// })
this.syncData()
},
// this.syncData()
// },
syncData(){
if (db) {
localdb.sync(db)
}
// syncData(){
// if (db) {
// localdb.sync(db)
// }
//alert ("did thing")
}
......
......@@ -8,11 +8,11 @@
</template>
<script>
import pouchdb from 'pouchdb'
//import pouchdb from 'pouchdb'
var localdb = new pouchdb('knowledge');
//var localdb = new pouchdb('knowledge');
//server admin has to create DB first and CORS allows specific domains.
var db = new pouchdb('https://nn.adamprocter.co.uk/knowledge');
//var db = new pouchdb('https://nn.adamprocter.co.uk/knowledge');
// @ is an alias to /src
import instance from "@/components/current-instance.vue";
......@@ -28,19 +28,24 @@ export default {
props:{
instancename: String
},
created() {
if (db){
localdb.sync(db)
}
localdb.allDocs({
include_docs: true,
attachments: true
}).then(result => {
Array.from(result.rows.values()).forEach((element) => {
this.$store.dispatch('showKnowledgeObjects', element)
})
})
this.$store.subscribe('showKnowledgeObjects')
// if (db){
// localdb.sync(db)
// }
// localdb.allDocs({
// include_docs: true,
// attachments: true
// }).then(result => {
// Array.from(result.rows.values()).forEach((element) => {
// this.$store.dispatch('showKnowledgeObjects', element)
// })
// })
}
}
......
......@@ -6,7 +6,8 @@
<h3 class="hello">You are connected to instance : {{instancename}}</h3>
</header>
<div id="start">
<signin :instancename="instancename" :accounts="accounts"></signin>
<signin></signin>
<!-- // <signin :instancename="instancename" :accounts="accounts"></signin> -->
<register></register>
</div>
......
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