Pbranie danych zcouchdb
This commit is contained in:
parent
39fa0946e7
commit
4e5cb685e6
0
frontend/app/git
Normal file
0
frontend/app/git
Normal file
1359
frontend/app/package-lock.json
generated
1359
frontend/app/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -8,8 +8,16 @@
|
|||||||
"lint": "vue-cli-service lint"
|
"lint": "vue-cli-service lint"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"axios": "^0.18.0",
|
||||||
|
"body-parser": "^1.18.3",
|
||||||
|
"couch-db": "^1.1.3",
|
||||||
"date-fns": "^1.30.1",
|
"date-fns": "^1.30.1",
|
||||||
|
"ejs": "^2.6.1",
|
||||||
|
"node-couchdb": "^1.3.0",
|
||||||
|
"node-couchdb-plugin-memcached": "0.0.2",
|
||||||
|
"pouchdb": "^7.0.0",
|
||||||
"vue": "^2.5.21",
|
"vue": "^2.5.21",
|
||||||
|
"vue-resource": "^1.5.1",
|
||||||
"vue-router": "^3.0.1",
|
"vue-router": "^3.0.1",
|
||||||
"vuetify": "^1.3.0",
|
"vuetify": "^1.3.0",
|
||||||
"vuex": "^3.0.1"
|
"vuex": "^3.0.1"
|
||||||
|
33
frontend/app/src/cb.js
Normal file
33
frontend/app/src/cb.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
//connector couchdb
|
||||||
|
//Inaczej pobieranie kard, które są dostępne publicznie będzie nieodświeżało widoku wszystkich kart po dodaniu przez backend danych
|
||||||
|
// gorsze rozwiazanie to zasluchiwanie ciagle na zmiany w bazie i wtedy wykonanie w widoku pobrania jeszcze raz danych, ale komunikacja źre za dużo, więc nie
|
||||||
|
|
||||||
|
// const NodeCouchDb = require('node-couchdb');
|
||||||
|
|
||||||
|
// // node-couchdb instance with default options
|
||||||
|
// const couch = new NodeCouchDb();
|
||||||
|
|
||||||
|
// // node-couchdb instance with Memcached
|
||||||
|
// const MemcacheNode = require('node-couchdb-plugin-memcached');
|
||||||
|
// const couchWithMemcache = new NodeCouchDb({
|
||||||
|
// cache: new MemcacheNode
|
||||||
|
// });
|
||||||
|
|
||||||
|
// // node-couchdb instance talking to external service
|
||||||
|
// const couchExternal = new NodeCouchDb({
|
||||||
|
// host: 'couchdb.external.service',
|
||||||
|
// protocol: 'https',
|
||||||
|
// port: 6984
|
||||||
|
// });
|
||||||
|
|
||||||
|
// // not admin party
|
||||||
|
// const couchAuth = new NodeCouchDb({
|
||||||
|
// auth: {
|
||||||
|
// user: 'root',
|
||||||
|
// pass: 'password'
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
|
||||||
|
// export default couch;
|
||||||
|
|
@ -48,7 +48,9 @@
|
|||||||
</v-menu>
|
</v-menu>
|
||||||
|
|
||||||
<v-btn flat color="grey" @click="userAction">
|
<v-btn flat color="grey" @click="userAction">
|
||||||
<span v-if="isLogged">Wyjdź</span>
|
<span v-if="isLogged">Wyjdź
|
||||||
|
|
||||||
|
</span>
|
||||||
<span v-if="!isLogged">Zaloguj</span>
|
<span v-if="!isLogged">Zaloguj</span>
|
||||||
<v-icon right>exit_to_app</v-icon>
|
<v-icon right>exit_to_app</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
@ -95,7 +97,7 @@ export default {
|
|||||||
snackbar: false,
|
snackbar: false,
|
||||||
snackbarLogout: false,
|
snackbarLogout: false,
|
||||||
isLogged: true,
|
isLogged: true,
|
||||||
snackbarLogint: false
|
snackbarLogin: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed:{
|
computed:{
|
||||||
|
@ -2,8 +2,11 @@ import Vue from 'vue'
|
|||||||
import './plugins/vuetify'
|
import './plugins/vuetify'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import router from './router'
|
import router from './router'
|
||||||
|
import VueResource from 'vue-resource'
|
||||||
import {store} from './store/store'
|
import {store} from './store/store'
|
||||||
|
|
||||||
|
Vue.use(VueResource)
|
||||||
|
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
|
@ -53,8 +53,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<script src="http://localhost:5984/golang_cards/_all_docs?include_docs=true"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
import axios from 'axios';
|
||||||
|
import PouchDB from 'pouchdb'
|
||||||
export default {
|
export default {
|
||||||
data(){
|
data(){
|
||||||
return{
|
return{
|
||||||
@ -70,10 +74,6 @@ export default {
|
|||||||
{due: 'data jakas', text: 'jakis tekst karta pytanie9', type:'question'},
|
{due: 'data jakas', text: 'jakis tekst karta pytanie9', type:'question'},
|
||||||
{due: 'data jakas', text: 'jakis tekst karta pytanie10', type:'question'},
|
{due: 'data jakas', text: 'jakis tekst karta pytanie10', type:'question'},
|
||||||
{due: 'data jakas', text: 'jakis tekst karta pytanie0', type:'question'},
|
{due: 'data jakas', text: 'jakis tekst karta pytanie0', type:'question'},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{due: 'data jakas', text: 'karta odpowiedz jakis tekst', type:'answer'}
|
{due: 'data jakas', text: 'karta odpowiedz jakis tekst', type:'answer'}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -85,11 +85,50 @@ export default {
|
|||||||
this.cards.filter( obj => {
|
this.cards.filter( obj => {
|
||||||
return obj.type === prop
|
return obj.type === prop
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
|
daneZbazy(){
|
||||||
|
// w linii komend jako admin na Windzie w folderze app
|
||||||
|
// C:\Users\dp\Desktop\PracowaniaProgramowania\frontend\app>add-cors-to-couchdb http://127.0.0.1:5984 -u root -p password success
|
||||||
|
|
||||||
|
var db = new PouchDB('http://localhost:5984/golang_cards');
|
||||||
|
console.log("DB: ", db)
|
||||||
|
var cards = []
|
||||||
|
|
||||||
|
db.allDocs({include_docs : true}).then(function (res) {
|
||||||
|
console.log("res: ", res.rows[0].doc)
|
||||||
|
|
||||||
|
res.rows.forEach(function (entry){
|
||||||
|
var tmp = {}
|
||||||
|
tmp.due = entry.doc.Timestamp
|
||||||
|
tmp.text = entry.doc.Text
|
||||||
|
if (entry.doc.isquestion){
|
||||||
|
tmp.type = 'question'
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
tmp.type='answer'
|
||||||
|
}
|
||||||
|
|
||||||
|
cards.push(tmp)
|
||||||
|
|
||||||
|
console.log("tmp", tmp)
|
||||||
|
console.log(entry.doc.Text)
|
||||||
|
console.log(entry.doc.Timestamp)
|
||||||
|
console.log(entry.doc.blank)
|
||||||
|
console.log(entry.doc.isquestion)
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
this.cards = cards
|
||||||
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
console.log("Pobranie wszsytkich kard z bazy")
|
console.log("Pobranie wszsytkich kard z bazy")
|
||||||
|
this.daneZbazy()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user