Merge branch 'max_dev'

master
Trivernis 5 years ago
commit 49b45db4da

@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { User } from './models/user'; import { User } from './models/user';
import { DatasharingService } from './services/datasharing.service'; import { DatasharingService } from './services/datasharing.service';
import { SelfService } from './services/selfservice/self.service';
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
@ -8,7 +9,7 @@ import { DatasharingService } from './services/datasharing.service';
styleUrls: ['./app.component.sass'] styleUrls: ['./app.component.sass']
}) })
export class AppComponent implements OnInit { export class AppComponent implements OnInit {
constructor(private data: DatasharingService) { } constructor(private data: DatasharingService, private selfservice: SelfService) { }
userInfo: User userInfo: User
@ -32,5 +33,8 @@ export class AppComponent implements OnInit {
console.log(this.userInfo); console.log(this.userInfo);
this.data.changeChatIDs(this.chatIDs) this.data.changeChatIDs(this.chatIDs)
}) })
if(this.loggedIn != true){
this.selfservice.checkIfLoggedIn();
}
} }
} }

@ -1,9 +1,9 @@
<h1>Greenvironment</h1> <h1>Greenvironment</h1>
<button id="tab-home" routerLink="">Home</button> <button id="tab-home" routerLink="">Home</button>
<button id="tab-profile" routerLink={{profileUrl}} *ngIf="loggedIn">Profile</button> <button id="tab-profile" routerLink={{profileUrl}} *ngIf="loggedIn">Profile</button>
<button id="tab-rank" *ngIf="loggedIn">Rank</button>
<button id="tab-about" routerLink="/about">About</button> <button id="tab-about" routerLink="/about">About</button>
<button id="tab-imprint" routerLink="/imprint">Imprint</button> <button id="tab-imprint" routerLink="/imprint">Imprint</button>
<button id="tab-login" routerLink="/login" *ngIf="loggedIn != true">Login</button>
<div id="dropdown" *ngIf="loggedIn"> <div id="dropdown" *ngIf="loggedIn">
<div> <div>
<span><i class="fa fa-caret-down" aria-hidden="true"></i></span> <span><i class="fa fa-caret-down" aria-hidden="true"></i></span>

@ -30,13 +30,13 @@ h1
#tab-profile #tab-profile
@include gridPosition(1, 2, 3, 4) @include gridPosition(1, 2, 3, 4)
#tab-rank #tab-about
@include gridPosition(1, 2, 4, 5) @include gridPosition(1, 2, 4, 5)
#tab-about #tab-imprint
@include gridPosition(1, 2, 5, 6) @include gridPosition(1, 2, 5, 6)
#tab-about #tab-login
@include gridPosition(1, 2, 6, 7) @include gridPosition(1, 2, 6, 7)
#dropdown #dropdown

@ -14,20 +14,14 @@ export class AppScaffoldComponent implements OnInit {
userId: number; userId: number;
profileUrl: string; profileUrl: string;
constructor(private data: DatasharingService,private selfservice: SelfService) { } constructor(private data: DatasharingService) { }
ngOnInit() { ngOnInit() {
this.data.currentUserInfo.subscribe(user => { this.data.currentUserInfo.subscribe(user => {
this.loggedIn = user.loggedIn; this.loggedIn = user.loggedIn;
this.userId = user.userID; this.userId = user.userID;
this.profileUrl = '/profile/' + this.userId; this.profileUrl = '/profile/' + this.userId;
console.log(user.loggedIn); })
})
if(this.loggedIn != true){
console.log('user is not logged in');
this.selfservice.checkIfLoggedIn;
};
console.log('loggedIn is ' + this.loggedIn)
} }
} }

@ -1,7 +1,7 @@
<div id="login"> <div id="login">
<div id="logincontainer"> <div id="logincontainer">
<table style="width:100%"> <table style="width:100%" (keyup.enter)="onClickSubmit(email.value,password.value)">
<tr> <tr>
<td>email: </td> <td>email: </td>
<td><input #email type="text" name="email"><br></td> <td><input #email type="text" name="email"><br></td>
@ -11,9 +11,10 @@
<td> <input #password type="password" name="password"><br></td> <td> <input #password type="password" name="password"><br></td>
</tr> </tr>
</table> </table>
<button type="loginbutton" (click)="onClickSubmit(email.value,password.value)">Login</button> <button type="loginbutton" (onClick)="onClickSubmit(email.value,password.value)">Login</button>
<p *ngIf="errorOccurred">{{errorMessage}}</p> <p *ngIf="errorOccurred">{{errorMessage}}</p>
<br> <br>
<br>
<a href="/register">You aren´t part of greenvironment yet? - join us here</a> <a href="/register">You aren´t part of greenvironment yet? - join us here</a>
</div> </div>
</div> </div>

@ -9,9 +9,14 @@
max-height: 100vh max-height: 100vh
#logincontainer #logincontainer
@include gridPosition(2, 2,2,2) @include gridPosition(2, 2,2,2)
grid-template: 15% 15% 15% 15% 15% 15% / 100% background-color: $cPrimaryBackground
background-color: $cPrimaryBackground padding: 1em
padding: 1em
input input
margin: 0.25em margin: 0.25em
a
color: $cHeadPrimaryBackground

@ -1,6 +1,6 @@
<div id="register"> <div id="register">
<div id="registercontainer"> <div id="registercontainer">
<table style="width:100%"> <table style="width:100%" (keyup.enter)="onClickSubmit(username.value,email.value,password.value, repeatpassword.value)">
<tr> <tr>
<td>username: </td> <td>username: </td>
<td><input #username type="text" name="username" username.value=''><br></td> <td><input #username type="text" name="username" username.value=''><br></td>
@ -21,6 +21,7 @@
<button type="registerbutton" (click)="onClickSubmit(username.value,email.value,password.value, repeatpassword.value)">Register</button> <button type="registerbutton" (click)="onClickSubmit(username.value,email.value,password.value, repeatpassword.value)">Register</button>
<p *ngIf="errorOccurred">{{errorMessage}}</p> <p *ngIf="errorOccurred">{{errorMessage}}</p>
<br> <br>
<br>
<a href="/login">You are already part of greenvironment? - login</a> <a href="/login">You are already part of greenvironment? - login</a>
</div> </div>
</div> </div>

@ -16,3 +16,5 @@
input input
margin: 0.25em margin: 0.25em
a
color: $cHeadPrimaryBackground

@ -55,7 +55,7 @@ export class LoginService {
public buildJson(login: Login): any { public buildJson(login: Login): any {
const body = {query: `mutation($email: String, $pwHash: String) { const body = {query: `mutation($email: String, $pwHash: String) {
login(email: $email, passwordHash: $pwHash) {id, name, handle, points, level, friends{id}, groups{id},chats{id}} login(email: $email, passwordHash: $pwHash) {id, name,email, handle, points, level, friends{id}, groups{id},chats{id}}
}`, variables: { }`, variables: {
email: login.email, email: login.email,
pwHash: login.passwordHash, pwHash: login.passwordHash,

@ -39,7 +39,7 @@ export class SelfService {
public notLoggedIn(){ public notLoggedIn(){
console.log('user was not logged in'); console.log('user was not logged in');
//do routing //do routing
this.router.navigateByUrl('/login'); //this.router.navigateByUrl('/login');
} }
public updateUserInfo(response : any){ public updateUserInfo(response : any){
@ -60,8 +60,8 @@ export class SelfService {
} }
public buildJson(): any { public buildJson(): any {
const body = {query: `query() { const body = {query: `{
getSelf(){id, name, handle, points, level, friends{id}, groups{id},chats{id}} getSelf{id, name,email, handle, points, level, friends{id}, groups{id},chats{id}}
}`, variables: { }`, variables: {
}}; }};
return body; return body;

Loading…
Cancel
Save