Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Benutzerdaten ändern (inkl. Profilbild) #19

Merged
merged 38 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c63cba0
initial user creation
Feb 23, 2024
636d35d
linter stuff
Feb 23, 2024
c36a3ae
Added placeholder image to component and loading card data
np-complete-graph Feb 23, 2024
367df92
Fixed lint issues
np-complete-graph Feb 23, 2024
4222e0d
Adapted placeholders and renamed form variable
np-complete-graph Feb 23, 2024
dc6bcd1
Integrated upload img endpoint
np-complete-graph Feb 23, 2024
1d11986
Integrating current user card id
np-complete-graph Feb 23, 2024
55dd61e
Styled save button
np-complete-graph Feb 23, 2024
ee762cf
service aazopft,
Feb 23, 2024
9ff7069
Merge branch 'feature/initial_card' of https://github.com/iptch/g-col…
Feb 23, 2024
ce01ab9
cleanup
Feb 23, 2024
9556d96
loopedyloop
Feb 23, 2024
07a23dd
fucking linter
Feb 23, 2024
99c4d4e
Added wrapper dialog to make content scrollable
np-complete-graph Feb 23, 2024
68b7d53
Fixed lint issues
np-complete-graph Feb 23, 2024
cc07f06
Take over existing card values
np-complete-graph Feb 23, 2024
07fc00b
Merge remote-tracking branch 'origin/main' into feature/initial_card
np-complete-graph Feb 23, 2024
28ef6b7
Fixed lint issues
np-complete-graph Feb 23, 2024
cb9eefe
Implemented dialog close after successful save
np-complete-graph Feb 23, 2024
9b20bdb
Fixed lint issues
np-complete-graph Feb 23, 2024
317bc3b
Refactorings
np-complete-graph Feb 23, 2024
c27d1c5
Renamed component
np-complete-graph Feb 23, 2024
e0da2bb
Added labels to form
np-complete-graph Feb 23, 2024
83d7ab1
Added label and validation for acronym
np-complete-graph Feb 23, 2024
52bc653
save button in the middle
np-complete-graph Feb 23, 2024
7cba3c4
create separate menu item for user card
ihaveamicroservice Feb 24, 2024
59b2e9a
adjust dialog spacing
ihaveamicroservice Feb 25, 2024
5dd1582
don't submit the whole form when uploading an image because it leads …
ihaveamicroservice Feb 25, 2024
8a81491
show uploaded image after successful upload
ihaveamicroservice Feb 25, 2024
1042db6
add state and display loader/error for picture upload
ihaveamicroservice Feb 25, 2024
5401822
use picture endpoint to fetch picture when modifying card
ihaveamicroservice Feb 25, 2024
a29507b
write card id into state
ihaveamicroservice Mar 1, 2024
74d6595
use correct actions
ihaveamicroservice Mar 1, 2024
b0e2f03
show loader and error messages, write updated card into state
ihaveamicroservice Mar 2, 2024
cee6a3e
make acronym input uppercase
ihaveamicroservice Mar 2, 2024
3cd1fc0
validate user input when creating or modifying card
ihaveamicroservice Mar 3, 2024
fe36ac6
refactor image validation
ihaveamicroservice Mar 3, 2024
6f1f544
refactor image validation even more
ihaveamicroservice Mar 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"singleQuote": true,
"printWidth": 80,
"tabWidth": 2,
"endOfLine": "auto",
"overrides": [
{ "files": "*.html", "options": { "parser": "html" } },
{ "files": "*.component.html", "options": { "parser": "angular" } }
Expand Down
5 changes: 5 additions & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { DashboardComponent } from './components/dashboard/dashboard.component';
import { QrScannerComponent } from './components/qr-scanner/qr-scanner.component';
import { QuizComponent } from './components/quiz/quiz.component';
import { UserComponent } from './components/user/user.component';
import { UserCardComponent } from './components/user-card/user-card.component';

const routes: Routes = [
{
Expand All @@ -25,6 +26,10 @@ const routes: Routes = [
path: 'admin',
component: AdminComponent,
},
{
path: 'card',
component: UserCardComponent,
},
{
path: 'cards',
component: CardsComponent,
Expand Down
5 changes: 4 additions & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<div *ngIf="loading$ | async" class="flex h-screen justify-center items-center">
<app-loader></app-loader>
</div>
<div *ngIf="error$ | async" class="flex h-screen items-center p-2">
<div
*ngIf="error$ | async"
class="flex h-screen items-center justify-center p-2"
>
<app-alert [message]="(error$ | async)!"></app-alert>
</div>
<ng-container *ngIf="!((loading$ | async) || (error$ | async))">
Expand Down
18 changes: 15 additions & 3 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { NgOptimizedImage, registerLocaleData } from '@angular/common';
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
import localeDeCh from '@angular/common/locales/de-CH';
import { LOCALE_ID, NgModule, isDevMode } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
import { MatDialogModule } from '@angular/material/dialog';
import { NgOptimizedImage, registerLocaleData } from '@angular/common';
import { MatInputModule } from '@angular/material/input';
import { MatMenuModule } from '@angular/material/menu';
import { MatPaginatorModule } from '@angular/material/paginator';
Expand Down Expand Up @@ -54,6 +55,8 @@ import { CardsComponent } from './components/cards/cards.component';
import { DashboardComponent } from './components/dashboard/dashboard.component';
import { FieldComponent } from './components/field/field.component';
import { HeaderComponent } from './components/header/header.component';
import { EditUserCardComponent } from './components/edit-user-card/edit-user-card.component';
import { UserCardComponent } from './components/user-card/user-card.component';
import { LoaderComponent } from './components/loader/loader.component';
import { NavigationComponent } from './components/navigation/navigation.component';
import { PanelComponent } from './components/panel/panel.component';
Expand All @@ -66,10 +69,12 @@ import { UserComponent } from './components/user/user.component';
import { CardEffects } from './state/card/card.effects';
import { DashboardEffects } from './state/dashboard/dashboard.effects';
import { DistributionEffects } from './state/distribution/distribution.effects';
import { QuizEffects } from './state/quiz/quiz.effects';
import { reducers } from './state/reducers';
import { TransferEffects } from './state/transfer/transfer.effects';
import { UserEffects } from './state/user/user.effects';
import { InitialCardCreationDialogComponent } from './components/initial-card-creation-dialog/initial-card-creation.dialog';
import { QuizEffects } from './state/quiz/quiz.effects';
import { PictureEffects } from './state/picture/picture.effects';

registerLocaleData(localeDeCh);

Expand Down Expand Up @@ -143,6 +148,9 @@ export function MSALGuardConfigFactory(): MsalGuardConfiguration {
FieldComponent,
AlertComponent,
AdminComponent,
EditUserCardComponent,
UserCardComponent,
InitialCardCreationDialogComponent,
QuizComponent,
QuizQuestionComponent,
],
Expand All @@ -157,6 +165,9 @@ export function MSALGuardConfigFactory(): MsalGuardConfiguration {
MatSlideToggleModule,
MatSelectModule,
MatPaginatorModule,
MatDialogModule,
ReactiveFormsModule,
FormsModule,
ServiceWorkerModule.register('ngsw-worker.js', {
enabled: !isDevMode(),
// Register the ServiceWorker as soon as the application is stable
Expand All @@ -180,6 +191,7 @@ export function MSALGuardConfigFactory(): MsalGuardConfiguration {
UserEffects,
TransferEffects,
QuizEffects,
PictureEffects,
]),
MatSliderModule,
MatSnackBarModule,
Expand Down
18 changes: 8 additions & 10 deletions src/app/components/button/button.component.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
<button
class="flex items-center px-2 py-1 space-x-2 border-2 no-tap-highlight"
class="flex items-center px-2 py-1 space-x-2 border-2 no-tap-highlight active:brightness-125"
[disabled]="disabled"
[ngClass]="{
'border-light-blue text-light-blue': outlined && color === 'blue',
'border-dark-blue bg-dark-blue active:bg-light-blue':
!outlined && color === 'blue',
'border-dark-blue bg-dark-blue': !outlined && color === 'blue',
'border-light-green text-light-green': outlined && color === 'green',
'border-dark-green bg-dark-green active:bg-light-green':
!outlined && color === 'green',
'border-dark-green bg-dark-green': !outlined && color === 'green',
'border-light-pink text-light-pink': outlined && color === 'pink',
'border-dark-pink bg-dark-pink active:bg-light-pink':
!outlined && color === 'pink',
'border-dark-pink bg-dark-pink': !outlined && color === 'pink',
'border-light-red text-light-red': outlined && color === 'red',
'border-dark-red bg-dark-red active:bg-light-red':
!outlined && color === 'red',
'w-full': fullWidth
'border-dark-red bg-dark-red': !outlined && color === 'red',
'w-full': fullWidth,
'active:brightness-100': disabled,
'opacity-60': transparent
}"
>
<span *ngIf="symbol" class="material-symbols-outlined">{{ symbol }}</span>
Expand Down
1 change: 1 addition & 0 deletions src/app/components/button/button.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export class ButtonComponent {
@Input() outlined = false;
@Input() fullWidth = false;
@Input() centerText = false;
@Input() transparent = false;
}
3 changes: 3 additions & 0 deletions src/app/components/card-detail/card-detail.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
Component,
ElementRef,
Input,
OnDestroy,
OnInit,
ViewChild,
Expand All @@ -22,6 +23,8 @@ import {
templateUrl: './card-detail.component.html',
})
export class CardDetailComponent implements OnInit, OnDestroy {
@Input() isInitialUserCreation = false;

@ViewChild('image') image!: ElementRef;

loading$?: Observable<boolean>;
Expand Down
117 changes: 117 additions & 0 deletions src/app/components/edit-user-card/edit-user-card.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<input
style="display: none"
type="file"
id="chooseImage"
accept="image"
capture
height="100%"
#chooseImage
(change)="uploadPicture($event.target)"
/>

<div class="w-full aspect-square flex items-center justify-center relative">
<img
#image
[hidden]="pictureLoading$ | async"
[src]="picture$ | async"
(error)="onImageMissing(image)"
class="w-full h-full object-cover absolute"
alt="Card image"
/>

<button
class="absolute right-0 bottom-0 m-4 w-14 h-14 bg-dark-pink rounded-full no-tap-highlight active:bg-light-pink shadow z-20"
(click)="chooseImage.click()"
>
<span class="material-symbols-outlined align-middle text-white">edit</span>
</button>

<div
*ngIf="pictureLoading$ | async"
class="flex w-full h-full items-center justify-center bg-black bg-opacity-70 z-30"
>
<app-loader></app-loader>
</div>

<div
*ngIf="pictureError$ | async"
class="flex w-full h-full items-center justify-center bg-black bg-opacity-70 z-10"
>
<app-alert [message]="(pictureError$ | async)!"></app-alert>
</div>
</div>
<p class="text-xs text-light-gray opacity-60 p-2">
Es kann ein paar Minütchen dauern bis das Bild auf dem Chärtli erscheint.
Eventual consistency!
</p>

<div *ngIf="cardLoading$ | async" class="flex justify-center">
<app-loader></app-loader>
</div>

<app-alert
*ngIf="cardError$ | async"
[message]="'Infos konnten nicht geladen werden.'"
></app-alert>

<form
*ngIf="!((cardLoading$ | async) || (cardError$ | async))"
class="flex flex-col"
[formGroup]="userForm"
(ngSubmit)="updateUser()"
>
<mat-form-field>
<mat-label>Mein Kürzel</mat-label>
<input
matInput
formControlName="acronymInput"
oninput="this.value = this.value.toUpperCase()"
/>
</mat-form-field>

<mat-form-field>
<mat-label>Ich bin bei der ipt seit</mat-label>
<input matInput type="date" formControlName="startDateInput" />
</mat-form-field>

<mat-form-field>
<mat-label>Meine Rolle</mat-label>
<mat-select formControlName="jobInput">
<mat-option></mat-option>
@for (job of jobs; track job) {
<mat-option [value]="job">{{ job }}</mat-option>
}
</mat-select>
</mat-form-field>

<mat-form-field>
<mat-label>Da würde ich am liebsten mal hinreisen</mat-label>
<input matInput formControlName="wishDestinationInput" />
</mat-form-field>

<mat-form-field>
<mat-label>Für einen Tag tauschen würde ich mit</mat-label>
<input matInput formControlName="wishPersonInput" />
</mat-form-field>

<mat-form-field>
<mat-label>Das wollte ich schon immer mal erlernen</mat-label>
<input matInput formControlName="wishSkillInput" />
</mat-form-field>

<mat-form-field>
<mat-label>Der beste Ratschlag</mat-label>
<input matInput formControlName="bestAdviceInput" />
</mat-form-field>

<div class="flex justify-center">
<app-button
[disabled]="isCardInvalid()"
[transparent]="isCardInvalid()"
text="Update"
symbol="save"
color="pink"
class="text-white"
></app-button>
</div>
</form>
Loading
Loading