This repository has been archived by the owner on Oct 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from SE-TINF22B2/johanna
FE-#103: Benutzereinstellungen im Frontend
- Loading branch information
Showing
16 changed files
with
352 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,9 @@ | |
public enum ColorMode { | ||
LIGHT, | ||
DARK, | ||
MODERN | ||
|
||
|
||
WATER, | ||
GRASSLAND, | ||
SUNSET, | ||
DEVELOPER, | ||
AUTUMN | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...tend/src/app/dashboard/user-settings/user-settings-item/user-settings-item.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<div class="wrapper" #wrapper> | ||
<mat-card | ||
appearance="outlined" | ||
(click)="onSelect.emit()" | ||
(keyup.enter)="onSelect.emit()" | ||
[class.selected]="isSelected" | ||
tabindex="0" | ||
class="settings-card" | ||
> | ||
<div class="ripple-container" mat-ripple [matRippleTrigger]="wrapper"></div> | ||
|
||
<mat-card-content> | ||
<div class="cardcontent-container"> | ||
<div class="colorcard" [style.background-color]="'var(--' + colorMode.toLowerCase() + '-primary-preview)'"></div> | ||
{{ colorMode | titlecase }} | ||
</div> | ||
</mat-card-content> | ||
</mat-card> | ||
</div> |
45 changes: 45 additions & 0 deletions
45
...tend/src/app/dashboard/user-settings/user-settings-item/user-settings-item.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
.settings-card { | ||
cursor: pointer; | ||
overflow: hidden; | ||
--mdc-outlined-card-outline-color: transparent; | ||
|
||
&.selected { | ||
--mdc-outlined-card-outline-color: var(--primary-color); | ||
} | ||
|
||
& > * { | ||
z-index: 1; | ||
} | ||
} | ||
|
||
.ripple-container { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
z-index: 0; | ||
} | ||
|
||
mat-card-content { | ||
padding: 8px !important; | ||
} | ||
|
||
.cardcontent-container { | ||
display: flex; | ||
flex-direction: row; | ||
flex-wrap: nowrap; | ||
gap: var(--size-12); | ||
align-items: center; | ||
font-weight: var(--font-weight-subtitle); | ||
|
||
.colorcard { | ||
position: relative; | ||
aspect-ratio: 1 / 1; | ||
height: 50px; | ||
padding: 0; | ||
margin: 0; | ||
border-radius: 12px; | ||
} | ||
} | ||
|
23 changes: 23 additions & 0 deletions
23
...d/src/app/dashboard/user-settings/user-settings-item/user-settings-item.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { UserSettingsItemComponent } from './user-settings-item.component'; | ||
|
||
describe('UserSettingsItemComponent', () => { | ||
let component: UserSettingsItemComponent; | ||
let fixture: ComponentFixture<UserSettingsItemComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [UserSettingsItemComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(UserSettingsItemComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
frontend/src/app/dashboard/user-settings/user-settings-item/user-settings-item.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {Component, EventEmitter, Input, Output} from '@angular/core'; | ||
import {ColorMode} from "../../../../model/user"; | ||
|
||
@Component({ | ||
selector: 'app-user-settings-item', | ||
templateUrl: './user-settings-item.component.html', | ||
styleUrl: './user-settings-item.component.scss' | ||
}) | ||
export class UserSettingsItemComponent { | ||
|
||
@Input() | ||
colorMode!: ColorMode; | ||
|
||
@Input() | ||
isSelected = false; | ||
|
||
@Output() | ||
onSelect = new EventEmitter(); | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
frontend/src/app/dashboard/user-settings/user-settings.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<h2 mat-dialog-title class="prim-color"> | ||
Einstellungen | ||
<button mat-icon-button class="close-button" matDialogClose tabindex="-1"> | ||
<mat-icon>close</mat-icon> | ||
</button> | ||
</h2> | ||
<mat-dialog-content> | ||
<p>Wähle ein Farbschema aus</p> | ||
|
||
@if (userService.user | async; as user) { | ||
<h4 class="section-title">Day Theme</h4> | ||
<ul class="color-list"> | ||
@for (color of lightColors; track color) { | ||
<li> | ||
<app-user-settings-item | ||
[colorMode]="color" | ||
[isSelected]="user.settings.colorMode === color" | ||
(onSelect)="selectColorMode(color)" | ||
></app-user-settings-item> | ||
</li> | ||
} | ||
</ul> | ||
|
||
<h4 class="section-title">Night Theme</h4> | ||
<ul class="color-list"> | ||
@for (color of darkColors; track color) { | ||
<li> | ||
<app-user-settings-item | ||
[colorMode]="color" | ||
[isSelected]="user.settings.colorMode === color" | ||
(onSelect)="selectColorMode(color)" | ||
></app-user-settings-item> | ||
</li> | ||
} | ||
</ul> | ||
} @else { | ||
<div class="loading-container"> | ||
<mat-spinner></mat-spinner> | ||
<p>Profil wird geladen...</p> | ||
</div> | ||
} | ||
</mat-dialog-content> |
38 changes: 38 additions & 0 deletions
38
frontend/src/app/dashboard/user-settings/user-settings.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
.close-button { | ||
float: right; | ||
margin-top: 8px; | ||
} | ||
|
||
.container { | ||
overflow-y: auto; | ||
height: 100%; | ||
} | ||
.color-list { | ||
list-style: none; | ||
padding: 0; | ||
margin: 0; | ||
|
||
|
||
li:not(:last-child) { | ||
margin-bottom: 2px; | ||
} | ||
} | ||
|
||
.prim-color { | ||
color: var(--primary-color); | ||
} | ||
|
||
.section-title { | ||
color: var(--secondary-color); | ||
margin-top: var(--size-24); | ||
} | ||
|
||
.loading-container { | ||
text-align: center; | ||
padding: var(--size-12); | ||
|
||
mat-spinner { | ||
margin-left: auto; | ||
margin-right: auto; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
frontend/src/app/dashboard/user-settings/user-settings.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { UserSettingsComponent } from './user-settings.component'; | ||
|
||
describe('UserSettingsComponent', () => { | ||
let component: UserSettingsComponent; | ||
let fixture: ComponentFixture<UserSettingsComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [UserSettingsComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(UserSettingsComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
26 changes: 26 additions & 0 deletions
26
frontend/src/app/dashboard/user-settings/user-settings.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import {Component} from '@angular/core'; | ||
import {UserService} from "../../../services/user.service"; | ||
import {ColorMode} from "../../../model/user"; | ||
|
||
@Component({ | ||
selector: 'app-user-settings', | ||
templateUrl: './user-settings.component.html', | ||
styleUrl: './user-settings.component.scss' | ||
}) | ||
export class UserSettingsComponent { | ||
lightColors = [ColorMode.LIGHT, ColorMode.WATER, ColorMode.SUNSET, ColorMode.GRASSLAND]; | ||
darkColors = [ColorMode.DARK, ColorMode.DEVELOPER, ColorMode.AUTUMN]; | ||
|
||
isLoading = false; | ||
|
||
constructor(public userService: UserService) { | ||
} | ||
|
||
selectColorMode(colorMode: ColorMode) { | ||
this.isLoading = true; | ||
this.userService.applyThemeAttribute(colorMode); | ||
this.userService.updateTheme(colorMode).subscribe(() => { | ||
this.isLoading = false; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.