diff --git a/src/app/app.component.html b/src/app/app.component.html
index 82501b4..1d2e6a9 100644
--- a/src/app/app.component.html
+++ b/src/app/app.component.html
@@ -15,7 +15,7 @@
{{'locale.' + locale + '.long' |
- i18n}}
+ i18n}} done
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index 09ca763..4adef26 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -5,7 +5,7 @@ import {I18nService} from './services/i18n.service';
import {Router} from '@angular/router';
import {DomSanitizer} from '@angular/platform-browser';
import {MatIconRegistry} from '@angular/material/icon';
-import {DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE} from '@angular/material/core';
+import {DateAdapter} from '@angular/material/core';
@Component({
selector: 'app-root',
@@ -40,6 +40,10 @@ export class AppComponent {
} else {
this.opened = true;
}
+
+ if(localStorage.getItem("bstly.darkTheme") == "true") {
+ window.document.body.classList.add("dark-theme");
+ }
}
setLocale(locale) {
diff --git a/src/app/auth/auth.guard.ts b/src/app/auth/auth.guard.ts
index 5f1e51c..15acb53 100644
--- a/src/app/auth/auth.guard.ts
+++ b/src/app/auth/auth.guard.ts
@@ -1,7 +1,10 @@
import {Injectable} from '@angular/core';
import {Router} from '@angular/router';
-import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router';
+import {CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router';
import {AuthService} from '../services/auth.service';
+import {ProfileService} from '../services/profile.service';
+import {I18nService} from '../services/i18n.service';
+
@Injectable({
providedIn: 'root'
@@ -35,7 +38,7 @@ export class AuthGuard implements CanActivate {
providedIn: 'root'
})
export class AuthenticatedGuard implements CanActivate {
- constructor(private authService: AuthService, private router: Router) {}
+ constructor(private authService: AuthService, private profileService: ProfileService, private i18nService: I18nService, private router: Router) {}
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
const that = this;
@@ -44,6 +47,27 @@ export class AuthenticatedGuard implements CanActivate {
this.router.navigateByUrl('/login');
return false;
}
+
+
+ this.profileService.getAll(["locale", "darkTheme"]).toPromise().then((profileFields: any) => {
+ let reload = false;
+ for(let profileField of profileFields) {
+ if(profileField.name == "darkTheme" && profileField.value != localStorage.getItem("bstly.darkTheme")) {
+ localStorage.setItem("bstly.darkTheme", profileField.value);
+ reload = true;
+ } else if(profileField.name == "locale" && this.i18nService.locales.indexOf(profileField.value) != -1 && localStorage.getItem("bstly.locale") != profileField.value) {
+ if(this.i18nService.locale != profileField.value) {
+ localStorage.setItem("bstly.locale", profileField.value);
+ reload = true;
+ }
+ }
+ }
+
+ if(reload) {
+ window.location.reload();
+ }
+ })
+
return true;
}).catch(function(error) {
return that.router.parseUrl('/unavailable');
diff --git a/src/app/services/i18n.service.ts b/src/app/services/i18n.service.ts
index e917908..c1cec7d 100644
--- a/src/app/services/i18n.service.ts
+++ b/src/app/services/i18n.service.ts
@@ -8,7 +8,7 @@ import {environment} from '../../environments/environment';
export class I18nService {
locale: string = "de-informal";
- locales: any = ["de-informal"];
+ locales: any[] = ["de-informal"];
i18n: any;
constructor(private http: HttpClient) {
@@ -42,7 +42,9 @@ export class I18nService {
}
try {
- this.locales = await this.http.get(environment.apiUrl + "/i18n").toPromise();
+ await this.http.get(environment.apiUrl + "/i18n").toPromise().then((response: any) => {
+ this.locales = response;
+ });
} catch(e) {
console.debug("fallback to default locales");
}
diff --git a/src/app/services/profile.service.ts b/src/app/services/profile.service.ts
index 11d263d..da30847 100644
--- a/src/app/services/profile.service.ts
+++ b/src/app/services/profile.service.ts
@@ -11,8 +11,8 @@ export class ProfileService {
constructor(private http: HttpClient) {
}
- getAll() {
- return this.http.get(environment.apiUrl + "/profiles");
+ getAll(filter?: any[]) {
+ return this.http.get(environment.apiUrl + "/profiles" + (filter ? "?filter=" + filter.join(",") : ""));
}
getAllForUser(username) {
diff --git a/src/app/ui/profilefields/profilefield.dialog.html b/src/app/ui/profilefields/profilefield.dialog.html
index 5c57ed0..4b8b389 100644
--- a/src/app/ui/profilefields/profilefield.dialog.html
+++ b/src/app/ui/profilefields/profilefield.dialog.html
@@ -34,7 +34,8 @@
-
+
{{'profileField.value' | i18n}}
diff --git a/src/app/ui/profilefields/profilefields.component.html b/src/app/ui/profilefields/profilefields.component.html
index 67d9f4b..4d5b6b2 100644
--- a/src/app/ui/profilefields/profilefields.component.html
+++ b/src/app/ui/profilefields/profilefields.component.html
@@ -17,7 +17,7 @@
{{profileField.value}}
-
+
diff --git a/src/app/ui/profilefields/profilefields.component.ts b/src/app/ui/profilefields/profilefields.component.ts
index 7df535d..804554e 100644
--- a/src/app/ui/profilefields/profilefields.component.ts
+++ b/src/app/ui/profilefields/profilefields.component.ts
@@ -148,6 +148,16 @@ export class ProfileFieldDialog {
index: ['']
});
}
+
+ booleanChange(profileField) {
+ if(profileField.value == 'false') {
+ profileField.value = 'true';
+ } else {
+ profileField.value = 'false';
+ }
+ console.log(profileField);
+ }
+
}
diff --git a/src/assets/i18n/de-informal.json b/src/assets/i18n/de-informal.json
index 4d88069..87eeb3c 100644
--- a/src/assets/i18n/de-informal.json
+++ b/src/assets/i18n/de-informal.json
@@ -93,11 +93,13 @@
"edit": "Bearbeiten",
"index": "Index",
"name": {
- ".": "Name",
- "publicKey": "Öffentlicher PGP Schlüssel",
+ ".": "Key",
+ "darkTheme" : "Dunkles Thema",
"email": "E-Mail Adresse",
+ "locale" : "Sprache",
"primaryEmail": "E-Mail Adresse primär verwenden",
- "prtyMap": "Partey Karte"
+ "prtyMap": "Partey Karte",
+ "publicKey": "Öffentlicher PGP Schlüssel"
},
"openBlob": "Anzeigen",
"type": {
@@ -177,7 +179,7 @@
},
"status": {
".": "Status",
- "change" : "Status ändern",
+ "change" : "Status aktualisieren",
"hint": "Dein User Status gibt an, wie mit deinen Account Daten umgegangen wird wenn deine Berechtigungen ausgelaufen sind.",
"NORMAL": {
".": "Normal",
diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json
index 101b073..fc836e3 100644
--- a/src/assets/i18n/en.json
+++ b/src/assets/i18n/en.json
@@ -93,11 +93,13 @@
"edit": "Edit",
"index": "Index",
"name": {
- ".": "Name",
- "publicKey": "Public PGP key",
+ ".": "Key",
+ "darkTheme" : "Dark Theme",
"email": "Email address",
+ "locale" : "Locale",
"primaryEmail": "Use email address primary",
- "prtyMap": "Partey map"
+ "prtyMap": "Partey map",
+ "publicKey": "Public PGP key"
},
"openBlob": "Display",
"type": {
diff --git a/src/styles.scss b/src/styles.scss
index 4ad2420..0012ab6 100644
--- a/src/styles.scss
+++ b/src/styles.scss
@@ -21,7 +21,7 @@ $light-theme: mat-light-theme((color: (primary: $light-primary,
// Define an alternate dark theme.
$dark-theme: mat-dark-theme((color: (primary: $dark-primary,
- accent: $dark-accent,
+ accent: $light-accent,
warn: $dark-warn,
)));