[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)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return err
|
||||
// return err
|
||||
}
|
||||
fmt.Println(reflect.TypeOf(result))
|
||||
|
||||
if err := db.Get(doc, result.ID); err != nil { // get id and current revision.
|
||||
panic(err)
|
||||
return err //nie matakiego dodane pliku - cos sie nie powiodlo
|
||||
}
|
||||
// if err := db.Get(doc, result.ID); err != nil { // get id and current revision.
|
||||
// panic(err)
|
||||
// return err //nie matakiego dodane pliku - cos sie nie powiodlo
|
||||
// }
|
||||
|
||||
fmt.Printf(result.ID)
|
||||
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
|
||||
_password := checkUser.Password
|
||||
|
||||
fmt.Println("_login: ", _login)
|
||||
fmt.Println("_pasowrd: ", _password)
|
||||
|
||||
if _login == "" {
|
||||
c.JSON(http.StatusOK, "[loginUserView][Error] Nie podano loginu")
|
||||
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
|
||||
//PATRZ: documentation/couchdb/local.ini; documentation/couchdb/corsy_ustawienie.txt
|
||||
c.Header("Content-Type", "application/json")
|
||||
fmt.Println("------------------------------------------------------------------")
|
||||
fmt.Println("-------------------- ADD NEW CARD ----------------------------------------------")
|
||||
fmt.Println("------------------------------------------------------------------")
|
||||
fmt.Println("------------------------------------------------------------------")
|
||||
fmt.Println("------------------------------------------------------------------")
|
||||
@ -160,6 +163,9 @@ func addNewCardView(c *gin.Context) {
|
||||
_isQuestion := newCard.IsQuestion
|
||||
_blank := newCard.Blank
|
||||
_text := newCard.Text
|
||||
fmt.Println("_isQuestion: ", _isQuestion)
|
||||
fmt.Println("_blank: ", _blank)
|
||||
fmt.Println("_text: ", _text)
|
||||
|
||||
if _text == "" {
|
||||
c.JSON(http.StatusOK, "[updateUserPointsView][Error] Nie podano 'text'")
|
||||
@ -168,10 +174,11 @@ func addNewCardView(c *gin.Context) {
|
||||
|
||||
err := addNewCard(_isQuestion, _blank, _text)
|
||||
if err != nil {
|
||||
fmt.Println("Err: ")
|
||||
c.JSON(http.StatusOK, "[addNewCardView][Error] Nie można oddac nowej karty do [couchdb]")
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, "[addNewCardView] Dodano nową kartę")
|
||||
|
||||
}
|
||||
|
@ -48,9 +48,7 @@
|
||||
</v-menu>
|
||||
|
||||
<v-btn flat color="grey" @click="userAction">
|
||||
<span v-if="isLogged">Wyjdź
|
||||
|
||||
</span>
|
||||
<span v-if="isLogged">Wyloguj</span>
|
||||
<span v-if="!isLogged">Zaloguj</span>
|
||||
<v-icon right>exit_to_app</v-icon>
|
||||
</v-btn>
|
||||
|
@ -57,18 +57,14 @@ export default {
|
||||
"texst": "ALA MA KOTA"
|
||||
}*/
|
||||
|
||||
if (this.$refs.form.validate()){ //valinnaj JS
|
||||
// this.loading = true;
|
||||
console.log("Dodanie do bazy")
|
||||
console.log(this.cardText)
|
||||
console.log(this.cardType)
|
||||
if (this.$refs.form.validate()){ // valinnaj JS
|
||||
var blank = 0
|
||||
if (this.cardText.match(/_/g)){
|
||||
blank = this.cardText.match(/_/g).length;
|
||||
}
|
||||
if (this.cardType === "pytanie" && blank === 0){
|
||||
//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 = {}
|
||||
@ -80,16 +76,29 @@ export default {
|
||||
cardObj.blank = blank
|
||||
cardObj.text = this.cardText
|
||||
|
||||
axios.get("http://127.0.0.1:3000/api/getUsersView" , { crossdomain: true }
|
||||
).then(function(response){
|
||||
console.log(response)
|
||||
})
|
||||
.catch(function(error){
|
||||
console.log("ERROR: ", error);
|
||||
});
|
||||
axios.post("http://127.0.0.1:3000/api/addNewCardView" ,cardObj, { crossdomain: true })
|
||||
.then(response=>{
|
||||
console.log(response);
|
||||
})
|
||||
.catch(error=>{ //javascript ma swoje posrane zwrotki
|
||||
//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')
|
||||
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
|
||||
}
|
||||
});
|
||||
|
||||
this.$emit('cardAdded')
|
||||
}
|
||||
} ///dlugi if
|
||||
}
|
||||
},
|
||||
computed:{
|
||||
|
@ -16,7 +16,7 @@ export default new Router({
|
||||
base: process.env.BASE_URL,
|
||||
routes: [
|
||||
{
|
||||
path: '/',
|
||||
path: '/game',
|
||||
name: 'game',
|
||||
component: Game
|
||||
},
|
||||
@ -36,7 +36,7 @@ export default new Router({
|
||||
component: Register
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
path: '/', //doylsnie
|
||||
name: 'login',
|
||||
component: Login
|
||||
},
|
||||
|
@ -6,7 +6,7 @@ Vue.use(Vuex);
|
||||
export const store = new Vuex.Store({
|
||||
state: {
|
||||
links:[
|
||||
{ icon: 'dashboard', text: 'Gra', route: '/'},
|
||||
{ icon: 'dashboard', text: 'Gra', route: '/game'},
|
||||
{ icon: 'person', text: 'Dżentelmani', route: '/dzentelmani'},
|
||||
{ icon: "folder", text: 'Wszystkie Karty', route: '/karty'},
|
||||
// { icon: 'exit_to_app', text: 'Wyloguj', route: '/logout'},
|
||||
|
@ -1,23 +1,85 @@
|
||||
<template>
|
||||
<div id="login">
|
||||
<v-container>
|
||||
<v-layout row class="text-xs-center">
|
||||
<v-flex xs4 class="grey lighten-4">
|
||||
<v-container style="position: relative;top: 13%;" class="text-xs-center">
|
||||
<v-card flat>
|
||||
<v-card-title primary-title>
|
||||
<h4>Login</h4>
|
||||
</v-card-title>
|
||||
<v-form>
|
||||
<v-text-field prepend-icon="person" name="Username" label="Username"></v-text-field>
|
||||
<v-text-field prepend-icon="lock" name="Password" label="Password" type="password"></v-text-field>
|
||||
<v-card-actions>
|
||||
<v-btn primary large block>Login</v-btn>
|
||||
</v-card-actions>
|
||||
</v-form>
|
||||
</v-card>
|
||||
</v-container>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-container>
|
||||
</div></template>
|
||||
<v-container class="my-5">
|
||||
<v-layout column align-center>
|
||||
<v-flex id ="flex" xs12 sm6 md4 lg3 class="primary">
|
||||
<v-card flat class="text-xs-center ma-3" min-width="600px">
|
||||
<v-avatar size ="100" color="white mt-3">
|
||||
<img src="/cylinder-okragly.png">
|
||||
</v-avatar>
|
||||
<p class="primary--text mt-3 headline">Edżentelmeni</p>
|
||||
<v-card-text>
|
||||
<v-form class="px-3" ref="form">
|
||||
<v-text-field :rules="loginRules" label="login" v-model="userLogin" prepend-icon="person"></v-text-field>
|
||||
<v-text-field :rules="loginRules" label="hasło" v-model="userPassword" :type="'password'" prepend-icon="vpn_key"></v-text-field>
|
||||
</v-form>
|
||||
</v-card-text>
|
||||
<v-card-action>
|
||||
<v-btn class="primary" @click="login">
|
||||
Zaloguj
|
||||
</v-btn>
|
||||
</v-card-action>
|
||||
<v-card-text>
|
||||
<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>
|
||||
<div id="login">
|
||||
<v-container class="my-5">
|
||||
<v-layout column>
|
||||
<v-flex xs6 sm3 md2 lg1 xl1>
|
||||
|
||||
<v-card>
|
||||
<v-card-title>
|
||||
<!-- to widac w wyswietlanym oknie -->
|
||||
<h2>Nowa karta</h2>
|
||||
</v-card-title>
|
||||
<v-card-text>
|
||||
<v-form class="px-3" ref="form">
|
||||
<v-textarea label="Login" v-model="cardText" prepend-icon="edit" :rules="inputRules"></v-textarea>
|
||||
|
||||
<v-textarea label="Hasło" v-model="cardText" prepend-icon="edit" :rules="inputRules"></v-textarea>
|
||||
<v-spacer></v-spacer>
|
||||
|
||||
<v-btn class="green darken-4 white--text mt-4" @click="submit" :loading="loading" prepend-icon="edit" >
|
||||
<v-icon >done</v-icon>
|
||||
</v-btn>
|
||||
</v-form>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-flex>
|
||||
<v-layout column align-center>
|
||||
<v-flex id="flex" xs12 sm6 md4 lg3 class="primary">
|
||||
<v-card flat class="text-xs-center ma-3" min-width="600px">
|
||||
<v-avatar size ="100" color="white mt-3">
|
||||
<img src="/cylinder-okragly.png">
|
||||
</v-avatar>
|
||||
<p class="primary--text mt-3 headline">Edżentelmeni</p>
|
||||
<v-card-text>
|
||||
<v-text-field label="login" v-model="userLogin" prepend-icon="person"></v-text-field>
|
||||
<v-text-field label="hasło" v-model="userPassword" :type="'password'" prepend-icon="vpn_key"></v-text-field>
|
||||
<v-text-field label="potwierdź hasło " v-model="userPassword2" :type="'password'" prepend-icon="vpn_key"></v-text-field>
|
||||
</v-card-text>
|
||||
<v-card-action>
|
||||
<v-btn class="primary">
|
||||
Zarejestruj
|
||||
</v-btn>
|
||||
</v-card-action>
|
||||
</v-card>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</v-container>
|
||||
</div></template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
@ -42,3 +40,15 @@ export default {
|
||||
}
|
||||
}
|
||||
</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 allUsersTmp = axios.get("http://127.0.0.1:3000/api/getUsersView" ,{ crossdomain: true })
|
||||
.then(function(res){
|
||||
console.log("--------------------Users response:------------------------", res.data.allUsers)
|
||||
return res.data.allUsers //zwraca uzytkownikow
|
||||
}).then(function(res){
|
||||
objectVue.team = res
|
||||
|
Loading…
Reference in New Issue
Block a user