added delete post function
parent
d12c20aebe
commit
a6ade21333
@ -1,23 +0,0 @@
|
||||
<h1>Greenvironment</h1>
|
||||
<button id="tab-home" routerLink="">Home</button>
|
||||
<button id="tab-profile" routerLink={{profileUrl}} *ngIf="loggedIn">Profile</button>
|
||||
<button id="tab-about" routerLink="/about">About</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>
|
||||
<span id="symbol" (click)="showDropdown()"><i class="fa fa-caret-down" aria-hidden="true"></i></span>
|
||||
<span>{{username}}</span>
|
||||
</div>
|
||||
<div id="dropdown-content" *ngIf="dropdownShown">
|
||||
<div>
|
||||
<span>Rang:</span>
|
||||
<span>{{level}}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span>Punkte:</span>
|
||||
<span>{{points}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button id="logoutbutton" *ngIf="loggedIn" (click)="logout()"><span><i class="fa fa-sign-out-alt fa-2x" aria-hidden="true"></i></span></button>
|
@ -1,25 +0,0 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { AppScaffoldComponent } from './app-scaffold.component';
|
||||
|
||||
describe('AppScaffoldComponent', () => {
|
||||
let component: AppScaffoldComponent;
|
||||
let fixture: ComponentFixture<AppScaffoldComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ AppScaffoldComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(AppScaffoldComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
@ -1,74 +0,0 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { LoginComponent } from '../login/login.component';
|
||||
import { DatasharingService } from '../../services/datasharing.service';
|
||||
import { SelfService } from '../../services/selfservice/self.service';
|
||||
import { Levellist } from 'src/app/models/levellist';
|
||||
import { Http } from '@angular/http';
|
||||
import { Router } from '@angular/router';
|
||||
import { User } from 'src/app/models/user';
|
||||
import { environment } from 'src/environments/environment';
|
||||
|
||||
@Component({
|
||||
selector: 'app-scaffold',
|
||||
templateUrl: './app-scaffold.component.html',
|
||||
styleUrls: ['./app-scaffold.component.sass']
|
||||
})
|
||||
|
||||
export class AppScaffoldComponent implements OnInit {
|
||||
loggedIn = false;
|
||||
userId: number;
|
||||
username: string;
|
||||
user: User;
|
||||
levellist: Levellist = new Levellist();
|
||||
level: string;
|
||||
points: number;
|
||||
profileUrl: string;
|
||||
|
||||
dropdownShown = false;
|
||||
|
||||
constructor(
|
||||
private data: DatasharingService,
|
||||
private selfservice: SelfService,
|
||||
private http: Http,
|
||||
private router: Router) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.data.currentUserInfo.subscribe(user => {
|
||||
this.user = user;
|
||||
this.loggedIn = user.loggedIn;
|
||||
this.userId = user.userID;
|
||||
this.username = user.username;
|
||||
this.level = this.levellist.getLevelName(user.level);
|
||||
this.points = user.points;
|
||||
this.profileUrl = '/profile/' + this.userId;
|
||||
});
|
||||
}
|
||||
|
||||
showDropdown() {
|
||||
if (!this.dropdownShown) {
|
||||
this.dropdownShown = true;
|
||||
} else {
|
||||
this.dropdownShown = false;
|
||||
}
|
||||
}
|
||||
|
||||
logout() {
|
||||
const url = environment.graphQLUrl;
|
||||
|
||||
const headers = new Headers();
|
||||
headers.set('Content-Type', 'application/json');
|
||||
|
||||
const body = {query: `mutation {
|
||||
logout
|
||||
}`};
|
||||
|
||||
this.http.post(url, body).subscribe(response => {
|
||||
console.log(response.text()); });
|
||||
this.loggedIn = false;
|
||||
const user = new User();
|
||||
user.loggedIn = false;
|
||||
this.data.changeUserInfo(user);
|
||||
this.router.navigate(['login']);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue