[logowanie] [rejestracja] front
This commit is contained in:
parent
9ab5e231da
commit
b1ef71f2d9
@ -58,14 +58,14 @@ func addNewCard(_isQuestion bool, _blank int, _text string) error {
|
|||||||
result, err := db.Post(doc)
|
result, err := db.Post(doc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
return err
|
// return err
|
||||||
}
|
}
|
||||||
fmt.Println(reflect.TypeOf(result))
|
fmt.Println(reflect.TypeOf(result))
|
||||||
|
|
||||||
if err := db.Get(doc, result.ID); err != nil { // get id and current revision.
|
// if err := db.Get(doc, result.ID); err != nil { // get id and current revision.
|
||||||
panic(err)
|
// panic(err)
|
||||||
return err //nie matakiego dodane pliku - cos sie nie powiodlo
|
// return err //nie matakiego dodane pliku - cos sie nie powiodlo
|
||||||
}
|
// }
|
||||||
|
|
||||||
fmt.Printf(result.ID)
|
fmt.Printf(result.ID)
|
||||||
return nil
|
return nil
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
//Dane do testow hardkodowane
|
|
||||||
|
|
||||||
//Lista użytkownikow na sztywno
|
|
||||||
var hardcodedUsers = []User{}
|
|
||||||
|
|
||||||
// Lista kart na sztywno
|
|
||||||
var hardcodedCards = []Card{
|
|
||||||
Card{0, 0, 0, "Adoptowanie dziecka tylko po, by porzucić je w galerii handlowej."},
|
|
||||||
Card{1, 0, 0, "Sieroty, które wybuchają gdy ktoś je tylko pokocha."},
|
|
||||||
Card{2, 0, 0, "Niekończąca się aktualizacja Windowsa"},
|
|
||||||
Card{3, 0, 0, "Bug."},
|
|
||||||
Card{4, 0, 0, "Wadliwe testy jednostkowe."},
|
|
||||||
Card{5, 0, 0, "Użyszkodnik."},
|
|
||||||
Card{6, 0, 0, "Aplikacja kalkulatora zajmująca 5GB."},
|
|
||||||
Card{7, 1, 1, "Nie programuję w święta, bo _ się rodzi."},
|
|
||||||
Card{8, 1, 1, "3 rzeczy lepsze od seksu. _ _ _"},
|
|
||||||
Card{9, 0, 0, "Audyt bezpiezeństwa teleinformatycznego."},
|
|
||||||
Card{10, 0, 0, "Testy na produkcji."},
|
|
||||||
Card{11, 0, 0, "Pasywno-agresywna notatka o bałaganie w mieszkaniu."},
|
|
||||||
Card{12, 0, 0, "Spanko."},
|
|
||||||
Card{13, 0, 0, "Granko."},
|
|
||||||
Card{14, 0, 0, "Niech żyje zbrodniczy reżim."},
|
|
||||||
Card{15, 0, 0, "Kuce z Orła."},
|
|
||||||
Card{16, 0, 0, "Wałówka od mamy."},
|
|
||||||
Card{17, 0, 0, "10 dni do wypłaty."},
|
|
||||||
Card{18, 0, 0, "Bo to zła kobieta była."},
|
|
||||||
Card{19, 1, 2, "Rude to _ i _."},
|
|
||||||
Card{20, 0, 0, "Tłusty drewnojad."},
|
|
||||||
Card{21, 0, 0, "Zupa z paczki o smaku opakowania."},
|
|
||||||
Card{22, 0, 0, "Przez twe oczy zielone, zielone _."},
|
|
||||||
Card{23, 0, 0, "Naleśnikowa środa."},
|
|
||||||
Card{24, 0, 0, "Kończenie dokumentacji o 5 nad ranem."},
|
|
||||||
Card{25, 0, 0, "Powtarzanie roku."},
|
|
||||||
Card{26, 0, 0, "Warunek."},
|
|
||||||
Card{27, 0, 0, "Pralka."},
|
|
||||||
Card{28, 0, 0, "Chodzenie po starym rynku w szpilkach."},
|
|
||||||
Card{29, 0, 0, "Nieudana migracja bez logów."},
|
|
||||||
Card{30, 0, 0, "Nocny dyżur."},
|
|
||||||
Card{31, 1, 1, "Kac morderca jest wtedy gdy _."},
|
|
||||||
Card{32, 0, 0, "Buka."},
|
|
||||||
Card{33, 0, 0, "Nie mogę wyjść, mam _."},
|
|
||||||
Card{34, 0, 0, "Cukier."},
|
|
||||||
Card{35, 0, 0, "Co?"},
|
|
||||||
Card{36, 0, 0, "Chodź, debata jest."},
|
|
||||||
Card{37, 0, 0, "Ranga w pubg."},
|
|
||||||
Card{38, 0, 0, "Dla Ciebie Pani Sarna."},
|
|
||||||
Card{39, 1, 1, "Palenie papierosów powoduje _."},
|
|
||||||
Card{40, 0, 0, "Syndrom Sztokholmski."},
|
|
||||||
Card{41, 0, 0, "Domyśl się."},
|
|
||||||
}
|
|
@ -90,6 +90,9 @@ func loginUserView(c *gin.Context) {
|
|||||||
_login := checkUser.Login
|
_login := checkUser.Login
|
||||||
_password := checkUser.Password
|
_password := checkUser.Password
|
||||||
|
|
||||||
|
fmt.Println("_login: ", _login)
|
||||||
|
fmt.Println("_pasowrd: ", _password)
|
||||||
|
|
||||||
if _login == "" {
|
if _login == "" {
|
||||||
c.JSON(http.StatusOK, "[loginUserView][Error] Nie podano loginu")
|
c.JSON(http.StatusOK, "[loginUserView][Error] Nie podano loginu")
|
||||||
return
|
return
|
||||||
@ -147,7 +150,7 @@ func addNewCardView(c *gin.Context) {
|
|||||||
//ale dodawanei tutaj bo i tak mozna to zrobic w tej samem domenie co couchdb
|
//ale dodawanei tutaj bo i tak mozna to zrobic w tej samem domenie co couchdb
|
||||||
//PATRZ: documentation/couchdb/local.ini; documentation/couchdb/corsy_ustawienie.txt
|
//PATRZ: documentation/couchdb/local.ini; documentation/couchdb/corsy_ustawienie.txt
|
||||||
c.Header("Content-Type", "application/json")
|
c.Header("Content-Type", "application/json")
|
||||||
fmt.Println("------------------------------------------------------------------")
|
fmt.Println("-------------------- ADD NEW CARD ----------------------------------------------")
|
||||||
fmt.Println("------------------------------------------------------------------")
|
fmt.Println("------------------------------------------------------------------")
|
||||||
fmt.Println("------------------------------------------------------------------")
|
fmt.Println("------------------------------------------------------------------")
|
||||||
fmt.Println("------------------------------------------------------------------")
|
fmt.Println("------------------------------------------------------------------")
|
||||||
@ -160,6 +163,9 @@ func addNewCardView(c *gin.Context) {
|
|||||||
_isQuestion := newCard.IsQuestion
|
_isQuestion := newCard.IsQuestion
|
||||||
_blank := newCard.Blank
|
_blank := newCard.Blank
|
||||||
_text := newCard.Text
|
_text := newCard.Text
|
||||||
|
fmt.Println("_isQuestion: ", _isQuestion)
|
||||||
|
fmt.Println("_blank: ", _blank)
|
||||||
|
fmt.Println("_text: ", _text)
|
||||||
|
|
||||||
if _text == "" {
|
if _text == "" {
|
||||||
c.JSON(http.StatusOK, "[updateUserPointsView][Error] Nie podano 'text'")
|
c.JSON(http.StatusOK, "[updateUserPointsView][Error] Nie podano 'text'")
|
||||||
@ -168,10 +174,11 @@ func addNewCardView(c *gin.Context) {
|
|||||||
|
|
||||||
err := addNewCard(_isQuestion, _blank, _text)
|
err := addNewCard(_isQuestion, _blank, _text)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("Err: ")
|
||||||
c.JSON(http.StatusOK, "[addNewCardView][Error] Nie można oddac nowej karty do [couchdb]")
|
c.JSON(http.StatusOK, "[addNewCardView][Error] Nie można oddac nowej karty do [couchdb]")
|
||||||
return
|
return
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSON(http.StatusOK, "[addNewCardView] Dodano nową kartę")
|
c.JSON(http.StatusOK, "[addNewCardView] Dodano nową kartę")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -48,9 +48,7 @@
|
|||||||
</v-menu>
|
</v-menu>
|
||||||
|
|
||||||
<v-btn flat color="grey" @click="userAction">
|
<v-btn flat color="grey" @click="userAction">
|
||||||
<span v-if="isLogged">Wyjdź
|
<span v-if="isLogged">Wyloguj</span>
|
||||||
|
|
||||||
</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>
|
||||||
|
@ -57,18 +57,14 @@ export default {
|
|||||||
"texst": "ALA MA KOTA"
|
"texst": "ALA MA KOTA"
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
if (this.$refs.form.validate()){ //valinnaj JS
|
if (this.$refs.form.validate()){ // valinnaj JS
|
||||||
// this.loading = true;
|
|
||||||
console.log("Dodanie do bazy")
|
|
||||||
console.log(this.cardText)
|
|
||||||
console.log(this.cardType)
|
|
||||||
var blank = 0
|
var blank = 0
|
||||||
if (this.cardText.match(/_/g)){
|
if (this.cardText.match(/_/g)){
|
||||||
blank = this.cardText.match(/_/g).length;
|
blank = this.cardText.match(/_/g).length;
|
||||||
}
|
}
|
||||||
if (this.cardType === "pytanie" && blank === 0){
|
if (this.cardType === "pytanie" && blank === 0){
|
||||||
//walidacja - karta pytanie musi miec min 1 pole puste
|
//walidacja - karta pytanie musi miec min 1 pole puste
|
||||||
this.inputRules = [false || 'Karta pytanie musi miec min jedno pole na odpwiedz ( znak podłogi _)'] //info zwrotne w dialogu dla uzytkownika
|
this.inputRules = [false || 'Karta pytanie musi miec min jedno pole na odpwiedz (znak podłogi _)'] //info zwrotne w dialogu dla uzytkownika
|
||||||
}
|
}
|
||||||
|
|
||||||
var cardObj = {}
|
var cardObj = {}
|
||||||
@ -80,16 +76,29 @@ export default {
|
|||||||
cardObj.blank = blank
|
cardObj.blank = blank
|
||||||
cardObj.text = this.cardText
|
cardObj.text = this.cardText
|
||||||
|
|
||||||
axios.get("http://127.0.0.1:3000/api/getUsersView" , { crossdomain: true }
|
axios.post("http://127.0.0.1:3000/api/addNewCardView" ,cardObj, { crossdomain: true })
|
||||||
).then(function(response){
|
.then(response=>{
|
||||||
console.log(response)
|
console.log(response);
|
||||||
})
|
})
|
||||||
.catch(function(error){
|
.catch(error=>{ //javascript ma swoje posrane zwrotki
|
||||||
console.log("ERROR: ", error);
|
//400 bad request wychodzi z asynchronicznosci tutaj, i wszyscy tak to obsluguja
|
||||||
});
|
//Sprawdzanie czy to na pewno blad czy po prostu javascript sie fąfla -,-
|
||||||
|
if ( error.response.data == "[addNewCardView] Dodano nową kartę"){
|
||||||
this.$emit('cardAdded')
|
this.$emit('cardAdded')
|
||||||
}
|
return
|
||||||
|
}
|
||||||
|
if(error.response.data == "[updateUserPointsView][Error] Nie podano 'text'"){
|
||||||
|
// To sie nie zadzieje, bo js ma walidacje
|
||||||
|
console.log("Nie podano tekstu karty")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
else{//tu jest blad
|
||||||
|
console.log("ERROR: ", error.response.data)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} ///dlugi if
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed:{
|
computed:{
|
||||||
|
@ -16,7 +16,7 @@ export default new Router({
|
|||||||
base: process.env.BASE_URL,
|
base: process.env.BASE_URL,
|
||||||
routes: [
|
routes: [
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/game',
|
||||||
name: 'game',
|
name: 'game',
|
||||||
component: Game
|
component: Game
|
||||||
},
|
},
|
||||||
@ -36,7 +36,7 @@ export default new Router({
|
|||||||
component: Register
|
component: Register
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/login',
|
path: '/', //doylsnie
|
||||||
name: 'login',
|
name: 'login',
|
||||||
component: Login
|
component: Login
|
||||||
},
|
},
|
||||||
|
@ -6,7 +6,7 @@ Vue.use(Vuex);
|
|||||||
export const store = new Vuex.Store({
|
export const store = new Vuex.Store({
|
||||||
state: {
|
state: {
|
||||||
links:[
|
links:[
|
||||||
{ icon: 'dashboard', text: 'Gra', route: '/'},
|
{ icon: 'dashboard', text: 'Gra', route: '/game'},
|
||||||
{ icon: 'person', text: 'Dżentelmani', route: '/dzentelmani'},
|
{ icon: 'person', text: 'Dżentelmani', route: '/dzentelmani'},
|
||||||
{ icon: "folder", text: 'Wszystkie Karty', route: '/karty'},
|
{ icon: "folder", text: 'Wszystkie Karty', route: '/karty'},
|
||||||
// { icon: 'exit_to_app', text: 'Wyloguj', route: '/logout'},
|
// { icon: 'exit_to_app', text: 'Wyloguj', route: '/logout'},
|
||||||
|
@ -1,23 +1,85 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="login">
|
<div id="login">
|
||||||
<v-container>
|
<v-container class="my-5">
|
||||||
<v-layout row class="text-xs-center">
|
<v-layout column align-center>
|
||||||
<v-flex xs4 class="grey lighten-4">
|
<v-flex id ="flex" xs12 sm6 md4 lg3 class="primary">
|
||||||
<v-container style="position: relative;top: 13%;" class="text-xs-center">
|
<v-card flat class="text-xs-center ma-3" min-width="600px">
|
||||||
<v-card flat>
|
<v-avatar size ="100" color="white mt-3">
|
||||||
<v-card-title primary-title>
|
<img src="/cylinder-okragly.png">
|
||||||
<h4>Login</h4>
|
</v-avatar>
|
||||||
</v-card-title>
|
<p class="primary--text mt-3 headline">Edżentelmeni</p>
|
||||||
<v-form>
|
<v-card-text>
|
||||||
<v-text-field prepend-icon="person" name="Username" label="Username"></v-text-field>
|
<v-form class="px-3" ref="form">
|
||||||
<v-text-field prepend-icon="lock" name="Password" label="Password" type="password"></v-text-field>
|
<v-text-field :rules="loginRules" label="login" v-model="userLogin" prepend-icon="person"></v-text-field>
|
||||||
<v-card-actions>
|
<v-text-field :rules="loginRules" label="hasło" v-model="userPassword" :type="'password'" prepend-icon="vpn_key"></v-text-field>
|
||||||
<v-btn primary large block>Login</v-btn>
|
</v-form>
|
||||||
</v-card-actions>
|
</v-card-text>
|
||||||
</v-form>
|
<v-card-action>
|
||||||
</v-card>
|
<v-btn class="primary" @click="login">
|
||||||
</v-container>
|
Zaloguj
|
||||||
</v-flex>
|
</v-btn>
|
||||||
</v-layout>
|
</v-card-action>
|
||||||
</v-container>
|
<v-card-text>
|
||||||
</div></template>
|
<v-list-tile router :to="'/register'">
|
||||||
|
<v-list-tile-title class="mt-3 subheading" >Nie masz konta? Zarejestruj się! </v-list-tile-title>
|
||||||
|
</v-list-tile>
|
||||||
|
</v-card-text>
|
||||||
|
</v-card>
|
||||||
|
</v-flex>
|
||||||
|
</v-layout>
|
||||||
|
</v-container>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import axios from 'axios'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data(){
|
||||||
|
return{
|
||||||
|
userLogin : '',
|
||||||
|
userPassword: '',
|
||||||
|
loginRules: [
|
||||||
|
v => v.length >= 0 || 'Pole nie może być puste'
|
||||||
|
] //nie sprawdzam hasla, bo to przy rejestracji
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods:{
|
||||||
|
login(){
|
||||||
|
axios.post("http://127.0.0.1:3000/api/loginUserView" ,
|
||||||
|
{"login": this.userLogin, "password": this.userPassword},
|
||||||
|
{ crossdomain: true })
|
||||||
|
.then(response=>{
|
||||||
|
console.log(response.data);
|
||||||
|
if (response.data == true){
|
||||||
|
window.location.replace("http://localhost:8080/game");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//Zły login albo hasło
|
||||||
|
this.loginRules= [false || 'Nieprawidłowe dane']
|
||||||
|
|
||||||
|
}
|
||||||
|
this.userLogin = ""
|
||||||
|
this.userPassword = ""
|
||||||
|
})
|
||||||
|
|
||||||
|
.catch(error=>{
|
||||||
|
console.log("ERROR: ", error.response.data)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
goRegister(){
|
||||||
|
console.log("Log register")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.v-card{
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#flex{
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@ -1,31 +1,29 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="login">
|
<div id="login">
|
||||||
<v-container class="my-5">
|
<v-container class="my-5">
|
||||||
<v-layout column>
|
<v-layout column align-center>
|
||||||
<v-flex xs6 sm3 md2 lg1 xl1>
|
<v-flex id="flex" xs12 sm6 md4 lg3 class="primary">
|
||||||
|
<v-card flat class="text-xs-center ma-3" min-width="600px">
|
||||||
<v-card>
|
<v-avatar size ="100" color="white mt-3">
|
||||||
<v-card-title>
|
<img src="/cylinder-okragly.png">
|
||||||
<!-- to widac w wyswietlanym oknie -->
|
</v-avatar>
|
||||||
<h2>Nowa karta</h2>
|
<p class="primary--text mt-3 headline">Edżentelmeni</p>
|
||||||
</v-card-title>
|
<v-card-text>
|
||||||
<v-card-text>
|
<v-text-field label="login" v-model="userLogin" prepend-icon="person"></v-text-field>
|
||||||
<v-form class="px-3" ref="form">
|
<v-text-field label="hasło" v-model="userPassword" :type="'password'" prepend-icon="vpn_key"></v-text-field>
|
||||||
<v-textarea label="Login" v-model="cardText" prepend-icon="edit" :rules="inputRules"></v-textarea>
|
<v-text-field label="potwierdź hasło " v-model="userPassword2" :type="'password'" prepend-icon="vpn_key"></v-text-field>
|
||||||
|
</v-card-text>
|
||||||
<v-textarea label="Hasło" v-model="cardText" prepend-icon="edit" :rules="inputRules"></v-textarea>
|
<v-card-action>
|
||||||
<v-spacer></v-spacer>
|
<v-btn class="primary">
|
||||||
|
Zarejestruj
|
||||||
<v-btn class="green darken-4 white--text mt-4" @click="submit" :loading="loading" prepend-icon="edit" >
|
</v-btn>
|
||||||
<v-icon >done</v-icon>
|
</v-card-action>
|
||||||
</v-btn>
|
</v-card>
|
||||||
</v-form>
|
</v-flex>
|
||||||
</v-card-text>
|
|
||||||
</v-card>
|
|
||||||
</v-flex>
|
|
||||||
</v-layout>
|
</v-layout>
|
||||||
</v-container>
|
</v-container>
|
||||||
</div></template>
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
@ -42,3 +40,15 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.v-card{
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#flex{
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ export default {
|
|||||||
var promiseUsers = new Promise(function(resolve, reject) {
|
var promiseUsers = new Promise(function(resolve, reject) {
|
||||||
var allUsersTmp = axios.get("http://127.0.0.1:3000/api/getUsersView" ,{ crossdomain: true })
|
var allUsersTmp = axios.get("http://127.0.0.1:3000/api/getUsersView" ,{ crossdomain: true })
|
||||||
.then(function(res){
|
.then(function(res){
|
||||||
|
console.log("--------------------Users response:------------------------", res.data.allUsers)
|
||||||
return res.data.allUsers //zwraca uzytkownikow
|
return res.data.allUsers //zwraca uzytkownikow
|
||||||
}).then(function(res){
|
}).then(function(res){
|
||||||
objectVue.team = res
|
objectVue.team = res
|
||||||
|
Loading…
Reference in New Issue
Block a user