Migrate existing control flow directives to use new control-flow schematic
This commit is contained in:
committed by
Aditya Chandel
parent
246efdaa34
commit
0f852ef068
@@ -17,13 +17,19 @@
|
||||
<div class="p-field">
|
||||
<label for="confirmNewPassword">Confirm New Password</label>
|
||||
<p-password id="confirmNewPassword" [(ngModel)]="confirmNewPassword" name="confirmNewPassword" [feedback]="false" required fluid></p-password>
|
||||
<p-message *ngIf="!passwordsMatch && confirmNewPassword" severity="error" text="New passwords do not match."></p-message>
|
||||
@if (!passwordsMatch && confirmNewPassword) {
|
||||
<p-message severity="error" text="New passwords do not match."></p-message>
|
||||
}
|
||||
</div>
|
||||
|
||||
<p-button type="submit" label="Change Password" icon="pi pi-key" class="p-fluid"></p-button>
|
||||
|
||||
<p-message *ngIf="errorMessage" severity="error" text="{{ errorMessage }}"></p-message>
|
||||
<p-message *ngIf="successMessage" severity="success" text="{{ successMessage }}"></p-message>
|
||||
@if (errorMessage) {
|
||||
<p-message severity="error" text="{{ errorMessage }}"></p-message>
|
||||
}
|
||||
@if (successMessage) {
|
||||
<p-message severity="success" text="{{ successMessage }}"></p-message>
|
||||
}
|
||||
</form>
|
||||
</ng-template>
|
||||
</p-card>
|
||||
|
||||
@@ -3,7 +3,7 @@ import {Button} from 'primeng/button';
|
||||
import {Card} from 'primeng/card';
|
||||
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||
import {Message} from 'primeng/message';
|
||||
import {NgIf} from '@angular/common';
|
||||
|
||||
import {Password} from 'primeng/password';
|
||||
import {MessageService, PrimeTemplate} from 'primeng/api';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
@@ -17,11 +17,10 @@ import {AuthService} from '../../service/auth.service';
|
||||
Card,
|
||||
FormsModule,
|
||||
Message,
|
||||
NgIf,
|
||||
Password,
|
||||
PrimeTemplate,
|
||||
ReactiveFormsModule
|
||||
],
|
||||
],
|
||||
templateUrl: './change-password.component.html',
|
||||
styleUrl: './change-password.component.scss'
|
||||
})
|
||||
|
||||
@@ -24,11 +24,15 @@
|
||||
icon="pi pi-sign-in"
|
||||
[disabled]="!loginForm.valid || !username || !password">
|
||||
</p-button>
|
||||
<p-message *ngIf="errorMessage" severity="error" text="{{ errorMessage }}"></p-message>
|
||||
<div *ngIf="oidcEnabled">
|
||||
<p-divider></p-divider>
|
||||
<p-button fluid severity="info" type="button" label="Login with OIDC" icon="pi pi-id-card" (click)="loginWithOidc()"></p-button>
|
||||
</div>
|
||||
@if (errorMessage) {
|
||||
<p-message severity="error" text="{{ errorMessage }}"></p-message>
|
||||
}
|
||||
@if (oidcEnabled) {
|
||||
<div>
|
||||
<p-divider></p-divider>
|
||||
<p-button fluid severity="info" type="button" label="Login with OIDC" icon="pi pi-id-card" (click)="loginWithOidc()"></p-button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</form>
|
||||
</ng-template>
|
||||
|
||||
@@ -2,7 +2,7 @@ import {Component, inject, OnInit} from '@angular/core';
|
||||
import {AuthService} from '../../service/auth.service';
|
||||
import {Router} from '@angular/router';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {NgIf} from '@angular/common';
|
||||
|
||||
import {Card} from 'primeng/card';
|
||||
import {Password} from 'primeng/password';
|
||||
import {Button} from 'primeng/button';
|
||||
@@ -20,7 +20,6 @@ import {filter, take} from 'rxjs/operators';
|
||||
selector: 'app-login',
|
||||
imports: [
|
||||
FormsModule,
|
||||
NgIf,
|
||||
Card,
|
||||
Password,
|
||||
Button,
|
||||
@@ -28,7 +27,7 @@ import {filter, take} from 'rxjs/operators';
|
||||
PrimeTemplate,
|
||||
InputText,
|
||||
Divider
|
||||
],
|
||||
],
|
||||
templateUrl: './login.component.html',
|
||||
styleUrls: ['./login.component.scss']
|
||||
})
|
||||
|
||||
+63
-58
@@ -29,9 +29,11 @@
|
||||
[disabled]="!isOidcFormComplete()"
|
||||
(onChange)="toggleOidcEnabled()">
|
||||
</p-toggleswitch>
|
||||
<div *ngIf="!isOidcFormComplete()" class="text-sm text-gray-400">
|
||||
(Fill all required fields to enable)
|
||||
</div>
|
||||
@if (!isOidcFormComplete()) {
|
||||
<div class="text-sm text-gray-400">
|
||||
(Fill all required fields to enable)
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<p class=" pt-8">OIDC Provider Settings:</p>
|
||||
@@ -137,64 +139,67 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="oidcEnabled">
|
||||
<p class=" pt-6">OIDC User Provisioning:</p>
|
||||
<div class="pl-6 space-y-6 p-4 m-4 custom-border">
|
||||
<div>
|
||||
<p class="text-lg pb-3">Automatic user provisioning:</p>
|
||||
<div class="flex items-center gap-4 pl-6">
|
||||
<label class="">Enabled</label>
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="autoUserProvisioningEnabled"
|
||||
inputId="autoProvision"
|
||||
(onChange)="saveAutoProvision()">
|
||||
</p-toggleswitch>
|
||||
<div class="flex items-center gap-2 text-sm text-gray-400">
|
||||
<i class="pi pi-info-circle text-blue-500"></i>
|
||||
<span>
|
||||
Enabling auto-provisioning ensures that new users are automatically created with the selected default permissions. If turned off, users must be manually created in Booklore before they can log in.
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="autoUserProvisioningEnabled">
|
||||
<p class=" pt-8">Default permissions for auto-provisioned users:</p>
|
||||
<div class="flex items-center gap-2 pl-6 pt-2">
|
||||
<p-checkbox
|
||||
[binary]="true"
|
||||
[disabled]="true"
|
||||
[ngModel]="true"
|
||||
inputId="permissionRead">
|
||||
</p-checkbox>
|
||||
<label class="text-sm">Read Books</label>
|
||||
</div>
|
||||
|
||||
<div *ngFor="let perm of availablePermissions" class="flex items-center gap-2 pl-6">
|
||||
<p-checkbox
|
||||
[(ngModel)]="perm.selected"
|
||||
[binary]="true"
|
||||
[inputId]="perm.value">
|
||||
</p-checkbox>
|
||||
<label [for]="perm.value" class="text-sm">{{ perm.label }}</label>
|
||||
</div>
|
||||
|
||||
<p class=" pb-3 pt-6">Default libraries for auto-provisioned users:</p>
|
||||
<div class="pl-6">
|
||||
<p-multiSelect
|
||||
[options]="allLibraries"
|
||||
optionLabel="name"
|
||||
optionValue="id"
|
||||
[(ngModel)]="editingLibraryIds"
|
||||
placeholder="Select Libraries"
|
||||
appendTo="body">
|
||||
</p-multiSelect>
|
||||
</div>
|
||||
<div class="mt-8">
|
||||
<p-button label="Save Settings" [outlined]="true" (click)="saveAutoProvisioningSettings()"></p-button>
|
||||
@if (oidcEnabled) {
|
||||
<div>
|
||||
<p class=" pt-6">OIDC User Provisioning:</p>
|
||||
<div class="pl-6 space-y-6 p-4 m-4 custom-border">
|
||||
<div>
|
||||
<p class="text-lg pb-3">Automatic user provisioning:</p>
|
||||
<div class="flex items-center gap-4 pl-6">
|
||||
<label class="">Enabled</label>
|
||||
<p-toggleswitch
|
||||
[(ngModel)]="autoUserProvisioningEnabled"
|
||||
inputId="autoProvision"
|
||||
(onChange)="saveAutoProvision()">
|
||||
</p-toggleswitch>
|
||||
<div class="flex items-center gap-2 text-sm text-gray-400">
|
||||
<i class="pi pi-info-circle text-blue-500"></i>
|
||||
<span>
|
||||
Enabling auto-provisioning ensures that new users are automatically created with the selected default permissions. If turned off, users must be manually created in Booklore before they can log in.
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@if (autoUserProvisioningEnabled) {
|
||||
<div>
|
||||
<p class=" pt-8">Default permissions for auto-provisioned users:</p>
|
||||
<div class="flex items-center gap-2 pl-6 pt-2">
|
||||
<p-checkbox
|
||||
[binary]="true"
|
||||
[disabled]="true"
|
||||
[ngModel]="true"
|
||||
inputId="permissionRead">
|
||||
</p-checkbox>
|
||||
<label class="text-sm">Read Books</label>
|
||||
</div>
|
||||
@for (perm of availablePermissions; track perm) {
|
||||
<div class="flex items-center gap-2 pl-6">
|
||||
<p-checkbox
|
||||
[(ngModel)]="perm.selected"
|
||||
[binary]="true"
|
||||
[inputId]="perm.value">
|
||||
</p-checkbox>
|
||||
<label [for]="perm.value" class="text-sm">{{ perm.label }}</label>
|
||||
</div>
|
||||
}
|
||||
<p class=" pb-3 pt-6">Default libraries for auto-provisioned users:</p>
|
||||
<div class="pl-6">
|
||||
<p-multiSelect
|
||||
[options]="allLibraries"
|
||||
optionLabel="name"
|
||||
optionValue="id"
|
||||
[(ngModel)]="editingLibraryIds"
|
||||
placeholder="Select Libraries"
|
||||
appendTo="body">
|
||||
</p-multiSelect>
|
||||
</div>
|
||||
<div class="mt-8">
|
||||
<p-button label="Save Settings" [outlined]="true" (click)="saveAutoProvisioningSettings()"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+2
-4
@@ -3,7 +3,7 @@ import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {Button} from 'primeng/button';
|
||||
import {DropdownModule} from 'primeng/dropdown';
|
||||
import {NgForOf, NgIf} from '@angular/common';
|
||||
|
||||
import {Checkbox} from 'primeng/checkbox';
|
||||
import {ToggleSwitch} from 'primeng/toggleswitch';
|
||||
import {MessageService} from 'primeng/api';
|
||||
@@ -24,15 +24,13 @@ import {LibraryService} from '../../../book/service/library.service';
|
||||
FormsModule,
|
||||
InputText,
|
||||
DropdownModule,
|
||||
NgIf,
|
||||
NgForOf,
|
||||
Checkbox,
|
||||
ToggleSwitch,
|
||||
Divider,
|
||||
Button,
|
||||
MultiSelect,
|
||||
ReactiveFormsModule
|
||||
],
|
||||
],
|
||||
styleUrls: ['./authentication-settings.component.scss']
|
||||
})
|
||||
export class AuthenticationSettingsComponent implements OnInit {
|
||||
|
||||
@@ -11,43 +11,55 @@
|
||||
<div class="flex flex-col gap-2">
|
||||
<label for="name">Username</label>
|
||||
<input pInputText id="name" type="text" formControlName="username" required />
|
||||
<small class="text-red-500" *ngIf="setupForm.get('username')?.invalid && setupForm.get('username')?.touched">
|
||||
Username is required.
|
||||
</small>
|
||||
@if (setupForm.get('username')?.invalid && setupForm.get('username')?.touched) {
|
||||
<small class="text-red-500">
|
||||
Username is required.
|
||||
</small>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<label for="name">Name</label>
|
||||
<input pInputText id="name" type="text" formControlName="name" required />
|
||||
<small class="text-red-500" *ngIf="setupForm.get('name')?.invalid && setupForm.get('name')?.touched">
|
||||
Name is required.
|
||||
</small>
|
||||
@if (setupForm.get('name')?.invalid && setupForm.get('name')?.touched) {
|
||||
<small class="text-red-500">
|
||||
Name is required.
|
||||
</small>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<label for="email">Email</label>
|
||||
<input pInputText id="email" type="email" formControlName="email" required />
|
||||
<small class="text-red-500" *ngIf="setupForm.get('email')?.invalid && setupForm.get('email')?.touched">
|
||||
Valid email is required.
|
||||
</small>
|
||||
@if (setupForm.get('email')?.invalid && setupForm.get('email')?.touched) {
|
||||
<small class="text-red-500">
|
||||
Valid email is required.
|
||||
</small>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<label for="password">Password</label>
|
||||
<p-password fluid id="password" formControlName="password" [feedback]="false" required></p-password>
|
||||
<small class="text-red-500" *ngIf="setupForm.get('password')?.invalid && setupForm.get('password')?.touched">
|
||||
Minimum 6 characters required.
|
||||
</small>
|
||||
@if (setupForm.get('password')?.invalid && setupForm.get('password')?.touched) {
|
||||
<small class="text-red-500">
|
||||
Minimum 6 characters required.
|
||||
</small>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-3 mt-4">
|
||||
<p-button fluid severity="success" type="submit"
|
||||
[label]="loading ? 'Creating…' : 'Create Admin Account'"
|
||||
[disabled]="loading || setupForm.invalid"
|
||||
icon="pi pi-user-plus">
|
||||
[label]="loading ? 'Creating…' : 'Create Admin Account'"
|
||||
[disabled]="loading || setupForm.invalid"
|
||||
icon="pi pi-user-plus">
|
||||
</p-button>
|
||||
<p-message *ngIf="error" severity="error" text="{{ error }}"></p-message>
|
||||
<p-message *ngIf="success" severity="success" text="Admin account created! Redirecting…"></p-message>
|
||||
@if (error) {
|
||||
<p-message severity="error" text="{{ error }}"></p-message>
|
||||
}
|
||||
@if (success) {
|
||||
<p-message severity="success" text="Admin account created! Redirecting…"></p-message>
|
||||
}
|
||||
</div>
|
||||
</form>
|
||||
</ng-template>
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Component } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { Router } from '@angular/router';
|
||||
import { SetupService } from './setup.service';
|
||||
import { NgIf } from '@angular/common';
|
||||
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { Card } from 'primeng/card';
|
||||
import { PrimeTemplate } from 'primeng/api';
|
||||
@@ -18,14 +18,13 @@ import { Message } from 'primeng/message';
|
||||
standalone: true,
|
||||
imports: [
|
||||
ReactiveFormsModule,
|
||||
NgIf,
|
||||
Card,
|
||||
PrimeTemplate,
|
||||
InputText,
|
||||
Password,
|
||||
Button,
|
||||
Message
|
||||
]
|
||||
]
|
||||
})
|
||||
export class SetupComponent {
|
||||
setupForm: FormGroup;
|
||||
|
||||
Reference in New Issue
Block a user