Merge branch 'max_dev' of Software_Engineering_I/greenvironment-frontend into master

master
Trivernis 5 years ago committed by Gitea
commit 10c71cbc16

@ -3,7 +3,6 @@ import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
import { Observable } from 'rxjs';
import { map, shareReplay } from 'rxjs/operators';
import { DatasharingService } from '../../services/datasharing.service';
import { SelfService } from '../../services/selfservice/self.service';
import { RequestService } from '../../services/request/request.service';
import { SettingsService } from '../../services/settings/settings.service';
import { environment } from 'src/environments/environment';
@ -23,7 +22,6 @@ export class MainNavigationComponent implements OnInit {
constructor(
public overlayContainer: OverlayContainer,
private data: DatasharingService,
private selfservice: SelfService,
private settingsService: SettingsService,
private requestservice: RequestService,
private breakpointObserver: BreakpointObserver,
@ -75,6 +73,8 @@ export class MainNavigationComponent implements OnInit {
if (this.user.darkmode === true && this.lighttheme) {
this.toggleTheme();
this.darkModeButtonChecked = true;
} else if (!this.user.darkmode && !this.lighttheme) {
this.settingsService.setDarkModeActive(true);
}
this.updateLinks();
});
@ -86,30 +86,21 @@ export class MainNavigationComponent implements OnInit {
this.overlay.classList.add('light-theme');
this.onSetTheme('light-theme');
this.lighttheme = true;
this.setDarkModeActive(false);
this.settingsService.setDarkModeActive(false);
} else if (this.overlay.classList.contains('light-theme')) {
this.overlay.classList.remove('light-theme');
this.overlay.classList.add('dark-theme');
this.onSetTheme('dark-theme');
this.lighttheme = false;
this.setDarkModeActive(true);
this.settingsService.setDarkModeActive(true);
} else {
this.overlay.classList.add('dark-theme');
this.onSetTheme('dark-theme');
this.lighttheme = false;
this.setDarkModeActive(true);
this.settingsService.setDarkModeActive(true);
}
}
setDarkModeActive(active: boolean) {
const url = environment.graphQLUrl;
const headers = new Headers();
headers.set('Content-Type', 'application/json');
const body = this.settingsService.buildJsonDarkMode('darkmode: ' + '\'' + active + '\'');
this.http.post(url, body).subscribe(response => {
console.log(response.text()); });
}
updateLinks() {
this.navLinksLoggedIn = [
{ path: '', label: 'Home' },

@ -1,6 +1,7 @@
import {Injectable} from '@angular/core';
import {Http} from '@angular/http';
import { User } from 'src/app/models/user';
import { environment } from 'src/environments/environment';
@Injectable({
providedIn: 'root'
@ -11,6 +12,15 @@ export class SettingsService {
constructor(private http: Http) {
}
setDarkModeActive(active: boolean) {
const url = environment.graphQLUrl;
const headers = new Headers();
headers.set('Content-Type', 'application/json');
const body = this.buildJsonDarkMode('darkmode: ' + '\'' + active + '\'');
this.http.post(url, body).subscribe(response => {
console.log(response.text()); });
}
public buildJsonDarkMode(setting_: string): any {
const body = {
query: `mutation($setting: String!) {

Loading…
Cancel
Save