-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
75172fe
commit 035b70f
Showing
22 changed files
with
281 additions
and
33 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
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
8 changes: 8 additions & 0 deletions
8
libs/mix-share/src/modules/account/components/role-active/role-active.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,8 @@ | ||
<div class="p-3 border-b w-full border-slate-200 flex gap-3 items-center"> | ||
<div> | ||
<mix-toggle [formControl]="activeForm"></mix-toggle> | ||
</div> | ||
<div> | ||
{{ role.name }} | ||
</div> | ||
</div> |
File renamed without changes.
41 changes: 41 additions & 0 deletions
41
libs/mix-share/src/modules/account/components/role-active/role-active.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,41 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
EventEmitter, | ||
Input, | ||
Output, | ||
} from '@angular/core'; | ||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; | ||
import { FormControl, ReactiveFormsModule } from '@angular/forms'; | ||
import { MixRole } from '@mixcore/lib/model'; | ||
import { MixToggleComponent } from '@mixcore/ui/toggle'; | ||
|
||
@Component({ | ||
selector: 'role-active', | ||
standalone: true, | ||
imports: [CommonModule, MixToggleComponent, ReactiveFormsModule], | ||
templateUrl: './role-active.component.html', | ||
styleUrl: './role-active.component.scss', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class RoleActiveComponent { | ||
@Output() public activeChange = new EventEmitter<boolean>(); | ||
@Input() public role!: MixRole; | ||
@Input() public set active(value: boolean) { | ||
this._active = value; | ||
this.activeForm.patchValue(value, { emitEvent: false }); | ||
} | ||
public get active() { | ||
return this._active; | ||
} | ||
private _active: boolean = false; | ||
|
||
public activeForm = new FormControl(this.active); | ||
|
||
constructor() { | ||
this.activeForm.valueChanges.pipe(takeUntilDestroyed()).subscribe((v) => { | ||
this.activeChange.emit(Boolean(v)); | ||
}); | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
...share/src/modules/account/components/update-user-dialog/update-user-dialog.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,83 @@ | ||
<div class="mix-dialog --default-padding h-full flex flex-col"> | ||
<div class="mix-dialog__header">Update user info</div> | ||
<div class="mix-dialog__content grow grid grid-cols-4 divide-x"> | ||
<div class="col-span-1"> | ||
<div class="flex flex-col items-center text-center p-3 py-5"> | ||
<img class="rounded-circle" | ||
src="https://st3.depositphotos.com/15648834/17930/v/600/depositphotos_179308454-stock-illustration-unknown-person-silhouette-glasses-profile.jpg" | ||
width="150px" | ||
height="150px"> | ||
<span class="font-weight-bold text-l"> | ||
<mix-inline-input placeHolder="Type the name"></mix-inline-input> | ||
</span> | ||
</div> | ||
|
||
<div class="mt-3 pr-4"> | ||
<mix-text-area placeHolder="Note something..."></mix-text-area> | ||
</div> | ||
|
||
</div> | ||
|
||
<div class="col-span-2 px-4" | ||
[formGroup]="userForm"> | ||
<div class="text-xl font-medium"> Information </div> | ||
|
||
<label class="content-label mt-4">Email</label> | ||
<mix-input [mixAutoFocus]="true" | ||
formControlName="email" | ||
placeHolder="Type email"></mix-input> | ||
<mix-form-error formControlName="email"></mix-form-error> | ||
|
||
<label class="content-label mt-2">Username - Login ID</label> | ||
<mix-input formControlName="username" | ||
placeHolder="Type username for login"></mix-input> | ||
<mix-form-error formControlName="username"></mix-form-error> | ||
|
||
<label class="content-label mt-2">First name</label> | ||
<mix-input formControlName="firstName" | ||
placeHolder="Type first name"></mix-input> | ||
<mix-form-error formControlName="firstName"></mix-form-error> | ||
|
||
<label class="content-label mt-2">Last name</label> | ||
<mix-input formControlName="lastName" | ||
placeHolder="Type last name"></mix-input> | ||
<mix-form-error formControlName="lastName"></mix-form-error> | ||
|
||
<div class="w-full bg-slate-100 p-4 rounded-md mt-4"> | ||
<label class="content-label">New Password:</label> | ||
<mix-input type="password" | ||
formControlName="password" | ||
placeHolder="Type password"></mix-input> | ||
<mix-form-error formControlName="password"></mix-form-error> | ||
|
||
<label class="content-label mt-2">Confirm Password:</label> | ||
<mix-input type="password" | ||
formControlName="confirmPassword" | ||
placeHolder="Confirm password"></mix-input> | ||
<mix-form-error formControlName="confirmPassword"></mix-form-error> | ||
</div> | ||
|
||
</div> | ||
|
||
<div *ngIf="roleStore.vm$ | async as vm" | ||
class="col-span-1 px-4"> | ||
<div class="text-xl font-medium mb-4"> Roles </div> | ||
|
||
@for (role of vm.data; track role.id) { | ||
<role-active [active]="roleDict[role.id] === true" | ||
[role]="role" | ||
(activeChange)="userRoleChange(role , $event)"></role-active> | ||
} | ||
|
||
</div> | ||
</div> | ||
|
||
<div class="mix-dialog__footer mt-auto"> | ||
<mix-button class="mr-auto" | ||
type="outline" | ||
[loading]="loadingState() === 'Loading'" | ||
(click)="dialogRef.close()">Cancel</mix-button> | ||
<mix-button [loading]="loadingState() === 'Loading'" | ||
(click)="dialogRef.close()">Update</mix-button> | ||
</div> | ||
</div> |
4 changes: 4 additions & 0 deletions
4
...share/src/modules/account/components/update-user-dialog/update-user-dialog.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,4 @@ | ||
:host { | ||
height: 100%; | ||
display: block; | ||
} |
98 changes: 98 additions & 0 deletions
98
...x-share/src/modules/account/components/update-user-dialog/update-user-dialog.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,98 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { ChangeDetectionStrategy, Component, inject } from '@angular/core'; | ||
import { | ||
FormControl, | ||
FormGroup, | ||
ReactiveFormsModule, | ||
Validators, | ||
} from '@angular/forms'; | ||
import { MixRole, UserListVm } from '@mixcore/lib/model'; | ||
import { MixApiFacadeService } from '@mixcore/share/api'; | ||
import { AuthService } from '@mixcore/share/auth'; | ||
import { BaseComponent } from '@mixcore/share/base'; | ||
import { MixAutoFocus } from '@mixcore/share/directives'; | ||
import { MixFormErrorComponent } from '@mixcore/share/form'; | ||
import { toastObserverProcessing } from '@mixcore/share/helper'; | ||
import { UserInfoStore } from '@mixcore/share/stores'; | ||
import { MixButtonComponent } from '@mixcore/ui/button'; | ||
import { MixInlineInputComponent } from '@mixcore/ui/inline-input'; | ||
import { MixInputComponent } from '@mixcore/ui/input'; | ||
import { MixTextAreaComponent } from '@mixcore/ui/textarea'; | ||
import { DialogRef, DialogService } from '@ngneat/dialog'; | ||
import { HotToastService } from '@ngneat/hot-toast'; | ||
import { RolesStore } from '../../stores/roles.store'; | ||
import { UserStore } from '../../stores/user.store'; | ||
import { RoleActiveComponent } from '../role-active/role-active.component'; | ||
|
||
@Component({ | ||
selector: 'update-user-dialog', | ||
standalone: true, | ||
imports: [ | ||
CommonModule, | ||
MixButtonComponent, | ||
MixInputComponent, | ||
MixInlineInputComponent, | ||
MixFormErrorComponent, | ||
MixTextAreaComponent, | ||
MixAutoFocus, | ||
ReactiveFormsModule, | ||
RoleActiveComponent, | ||
], | ||
templateUrl: './update-user-dialog.component.html', | ||
styleUrl: './update-user-dialog.component.scss', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class UpdateUserDialogComponent extends BaseComponent { | ||
public store = inject(UserStore); | ||
public infoStore = inject(UserInfoStore); | ||
public roleStore = inject(RolesStore); | ||
|
||
public mixApi = inject(MixApiFacadeService); | ||
public dialog = inject(DialogService); | ||
public toast = inject(HotToastService); | ||
public dialogRef = inject(DialogRef); | ||
public authService = inject(AuthService); | ||
|
||
public roleDict: Record<string, boolean> = {}; | ||
public userData!: UserListVm; | ||
public userForm = new FormGroup({ | ||
avatar: new FormControl('', { validators: [], nonNullable: true }), | ||
username: new FormControl('', { | ||
validators: [Validators.required], | ||
nonNullable: true, | ||
}), | ||
password: new FormControl('', { | ||
validators: [Validators.required], | ||
nonNullable: true, | ||
}), | ||
confirmPassword: new FormControl('', { | ||
validators: [Validators.required], | ||
nonNullable: true, | ||
}), | ||
firstName: new FormControl('', { validators: [], nonNullable: true }), | ||
lastName: new FormControl('', { validators: [], nonNullable: true }), | ||
email: new FormControl('', { | ||
validators: [Validators.email], | ||
nonNullable: true, | ||
}), | ||
}); | ||
|
||
ngOnInit() { | ||
this.userData = this.dialogRef.data; | ||
this.userForm.patchValue(this.userData); | ||
(this.userData.roles || []).forEach((role) => { | ||
this.roleDict[role.roleId!] = true; | ||
}); | ||
} | ||
|
||
public userRoleChange(role: MixRole, active: boolean) { | ||
this.authService | ||
.toggleUserInRoles(active, role.id, role.name, this.userData.id) | ||
.pipe(toastObserverProcessing(this.toast)) | ||
.subscribe({ | ||
next: () => { | ||
this.roleDict[role.id] = active; | ||
}, | ||
}); | ||
} | ||
} |
1 change: 0 additions & 1 deletion
1
...share/src/modules/account/components/user-detail-dialog/user-detail-dialog.component.html
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
...x-share/src/modules/account/components/user-detail-dialog/user-detail-dialog.component.ts
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.
035b70f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
mix-portal-angular – ./
p4ps-portal.vercel.app
mix-portal-angular-phongcaos-projects.vercel.app
mix-portal-angular-git-master-phongcaos-projects.vercel.app