Migrate existing control flow directives to use new control-flow schematic
This commit is contained in:
committed by
Aditya Chandel
parent
246efdaa34
commit
0f852ef068
+105
-101
@@ -1,111 +1,115 @@
|
||||
<div
|
||||
*ngIf="(libraryState$ | async)?.libraries as libraries"
|
||||
class="flex flex-col gap-10 p-4 items-center justify-center min-w-[500px] max-w-[700px] w-full">
|
||||
|
||||
<p-select
|
||||
[options]="libraries"
|
||||
optionLabel="name"
|
||||
placeholder="Select Library"
|
||||
[(ngModel)]="selectedLibrary"
|
||||
@if ((libraryState$ | async)?.libraries; as libraries) {
|
||||
<div
|
||||
class="flex flex-col gap-10 p-4 items-center justify-center min-w-[500px] max-w-[700px] w-full">
|
||||
<p-select
|
||||
[options]="libraries"
|
||||
optionLabel="name"
|
||||
placeholder="Select Library"
|
||||
[(ngModel)]="selectedLibrary"
|
||||
class="w-full"></p-select>
|
||||
|
||||
<p-select
|
||||
[options]="selectedLibrary?.paths"
|
||||
optionLabel="path"
|
||||
placeholder="Select Upload Location"
|
||||
[(ngModel)]="selectedPath"
|
||||
[disabled]="!selectedLibrary"
|
||||
<p-select
|
||||
[options]="selectedLibrary?.paths"
|
||||
optionLabel="path"
|
||||
placeholder="Select Upload Location"
|
||||
[(ngModel)]="selectedPath"
|
||||
[disabled]="!selectedLibrary"
|
||||
class="w-full"></p-select>
|
||||
|
||||
<p-fileupload class="w-full" name="file"
|
||||
[maxFileSize]="maxFileSizeBytes"
|
||||
[customUpload]="true"
|
||||
[multiple]="true" accept=".pdf,.epub,.cbz,.cbr,.cb7"
|
||||
(onSelect)="onFilesSelect($event)"
|
||||
(uploadHandler)="uploadFiles($event)"
|
||||
[disabled]="!selectedLibrary || !selectedPath">
|
||||
<ng-template #header let-files let-chooseCallback="chooseCallback" let-clearCallback="clearCallback" let-uploadCallback="uploadCallback">
|
||||
<div class="flex flex-wrap items-center justify-center flex-1 gap-4">
|
||||
<div class="flex gap-4">
|
||||
<p-button (onClick)="choose($event, chooseCallback)"
|
||||
icon="pi pi-images"
|
||||
[rounded]="true"
|
||||
[outlined]="true"
|
||||
[disabled]="isChooseDisabled()"/>
|
||||
|
||||
<p-button (onClick)="uploadEvent(uploadCallback)"
|
||||
icon="pi pi-cloud-upload"
|
||||
[rounded]="true"
|
||||
[outlined]="true"
|
||||
severity="success"
|
||||
[disabled]="isUploadDisabled()"/>
|
||||
|
||||
<p-button (onClick)="onClear(clearCallback)"
|
||||
icon="pi pi-times"
|
||||
[rounded]="true"
|
||||
[outlined]="true"
|
||||
severity="danger"
|
||||
[disabled]="!filesPresent() || isUploading"/>
|
||||
<p-fileupload class="w-full" name="file"
|
||||
[maxFileSize]="maxFileSizeBytes"
|
||||
[customUpload]="true"
|
||||
[multiple]="true" accept=".pdf,.epub,.cbz,.cbr,.cb7"
|
||||
(onSelect)="onFilesSelect($event)"
|
||||
(uploadHandler)="uploadFiles($event)"
|
||||
[disabled]="!selectedLibrary || !selectedPath">
|
||||
<ng-template #header let-files let-chooseCallback="chooseCallback" let-clearCallback="clearCallback" let-uploadCallback="uploadCallback">
|
||||
<div class="flex flex-wrap items-center justify-center flex-1 gap-4">
|
||||
<div class="flex gap-4">
|
||||
<p-button (onClick)="choose($event, chooseCallback)"
|
||||
icon="pi pi-images"
|
||||
[rounded]="true"
|
||||
[outlined]="true"
|
||||
[disabled]="isChooseDisabled()"/>
|
||||
<p-button (onClick)="uploadEvent(uploadCallback)"
|
||||
icon="pi pi-cloud-upload"
|
||||
[rounded]="true"
|
||||
[outlined]="true"
|
||||
severity="success"
|
||||
[disabled]="isUploadDisabled()"/>
|
||||
<p-button (onClick)="onClear(clearCallback)"
|
||||
icon="pi pi-times"
|
||||
[rounded]="true"
|
||||
[outlined]="true"
|
||||
severity="danger"
|
||||
[disabled]="!filesPresent() || isUploading"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #content let-files let-removeFileCallback="removeFileCallback">
|
||||
<div class="flex flex-col gap-8 px-4">
|
||||
<div *ngIf="files?.length > 0">
|
||||
<div class="max-h-96 overflow-y-auto pr-2">
|
||||
<div class="flex flex-wrap">
|
||||
<div *ngFor="let uploadFile of this.files; let i = index" class="flex justify-between items-center w-full gap-4">
|
||||
<div class="flex items-center gap-4 overflow-hidden flex-1">
|
||||
<p-badge [value]="uploadFile.status" [severity]="getBadgeSeverity(uploadFile.status)" class="shrink-0"/>
|
||||
<span class="font-semibold text-ellipsis whitespace-nowrap overflow-hidden flex-1">
|
||||
{{ uploadFile.file.name }}
|
||||
</span>
|
||||
<div class="shrink-0">{{ formatSize(uploadFile.file.size) }}</div>
|
||||
</div>
|
||||
<ng-container [ngSwitch]="uploadFile.status">
|
||||
<p-button *ngSwitchCase="'Pending'"
|
||||
</ng-template>
|
||||
<ng-template #content let-files let-removeFileCallback="removeFileCallback">
|
||||
<div class="flex flex-col gap-8 px-4">
|
||||
@if (files?.length > 0) {
|
||||
<div>
|
||||
<div class="max-h-96 overflow-y-auto pr-2">
|
||||
<div class="flex flex-wrap">
|
||||
@for (uploadFile of this.files; track uploadFile; let i = $index) {
|
||||
<div class="flex justify-between items-center w-full gap-4">
|
||||
<div class="flex items-center gap-4 overflow-hidden flex-1">
|
||||
<p-badge [value]="uploadFile.status" [severity]="getBadgeSeverity(uploadFile.status)" class="shrink-0"/>
|
||||
<span class="font-semibold text-ellipsis whitespace-nowrap overflow-hidden flex-1">
|
||||
{{ uploadFile.file.name }}
|
||||
</span>
|
||||
<div class="shrink-0">{{ formatSize(uploadFile.file.size) }}</div>
|
||||
</div>
|
||||
@switch (uploadFile.status) {
|
||||
@case ('Pending') {
|
||||
<p-button
|
||||
icon="pi pi-times"
|
||||
(click)="onRemoveTemplatingFile($event, uploadFile.file, removeFileCallback, i)"
|
||||
severity="danger"
|
||||
[text]="true"/>
|
||||
<i *ngSwitchCase="'Uploading'"
|
||||
class="pi pi-spin pi-spinner p-3"
|
||||
style="color: slateblue"
|
||||
pTooltip="Uploading"
|
||||
tooltipPosition="top">
|
||||
</i>
|
||||
<i *ngSwitchCase="'Uploaded'"
|
||||
class="pi pi-check p-3"
|
||||
style="color: green"
|
||||
pTooltip="Uploaded"
|
||||
tooltipPosition="top">
|
||||
</i>
|
||||
<i *ngSwitchCase="'Failed'"
|
||||
class="pi pi-exclamation-triangle p-3"
|
||||
style="color: darkred"
|
||||
pTooltip="{{ uploadFile.errorMessage || 'Upload failed' }}"
|
||||
tooltipPosition="top">
|
||||
</i>
|
||||
</ng-container>
|
||||
}
|
||||
@case ('Uploading') {
|
||||
<i
|
||||
class="pi pi-spin pi-spinner p-3"
|
||||
style="color: slateblue"
|
||||
pTooltip="Uploading"
|
||||
tooltipPosition="top">
|
||||
</i>
|
||||
}
|
||||
@case ('Uploaded') {
|
||||
<i
|
||||
class="pi pi-check p-3"
|
||||
style="color: green"
|
||||
pTooltip="Uploaded"
|
||||
tooltipPosition="top">
|
||||
</i>
|
||||
}
|
||||
@case ('Failed') {
|
||||
<i
|
||||
class="pi pi-exclamation-triangle p-3"
|
||||
style="color: darkred"
|
||||
pTooltip="{{ uploadFile.errorMessage || 'Upload failed' }}"
|
||||
tooltipPosition="top">
|
||||
</i>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #file></ng-template>
|
||||
|
||||
<ng-template #empty>
|
||||
<div class="flex items-center justify-center flex-col text-center">
|
||||
<i class="pi pi-cloud-upload !border-2 !rounded-full !p-8 !text-4xl !text-muted-color"></i>
|
||||
<p class="mt-6 mb-2">Drag and drop files here to upload.</p>
|
||||
<p class="mt-2 mb-2">
|
||||
Only <strong>.pdf</strong>, <strong>.epub</strong>, <strong>.cbz</strong>, <strong>.cbr</strong>, and <strong>.cb7</strong> files are supported (max size: 100 MB per file).
|
||||
</p>
|
||||
</div>
|
||||
</ng-template>
|
||||
</p-fileupload>
|
||||
|
||||
</div>
|
||||
</ng-template>
|
||||
<ng-template #file></ng-template>
|
||||
<ng-template #empty>
|
||||
<div class="flex items-center justify-center flex-col text-center">
|
||||
<i class="pi pi-cloud-upload !border-2 !rounded-full !p-8 !text-4xl !text-muted-color"></i>
|
||||
<p class="mt-6 mb-2">Drag and drop files here to upload.</p>
|
||||
<p class="mt-2 mb-2">
|
||||
Only <strong>.pdf</strong>, <strong>.epub</strong>, <strong>.cbz</strong>, <strong>.cbr</strong>, and <strong>.cb7</strong> files are supported (max size: 100 MB per file).
|
||||
</p>
|
||||
</div>
|
||||
</ng-template>
|
||||
</p-fileupload>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {Component, inject, OnInit} from '@angular/core';
|
||||
import {FileSelectEvent, FileUpload, FileUploadHandlerEvent} from 'primeng/fileupload';
|
||||
import {Button} from 'primeng/button';
|
||||
import {AsyncPipe, NgForOf, NgIf, NgSwitch, NgSwitchCase} from '@angular/common';
|
||||
import { AsyncPipe } from '@angular/common';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {Select} from 'primeng/select';
|
||||
@@ -32,14 +32,10 @@ interface UploadingFile {
|
||||
Button,
|
||||
AsyncPipe,
|
||||
FormsModule,
|
||||
NgIf,
|
||||
Select,
|
||||
Badge,
|
||||
NgForOf,
|
||||
NgSwitchCase,
|
||||
NgSwitch,
|
||||
Tooltip
|
||||
],
|
||||
],
|
||||
templateUrl: './book-uploader.component.html',
|
||||
styleUrl: './book-uploader.component.scss'
|
||||
})
|
||||
|
||||
+7
-3
@@ -7,7 +7,7 @@
|
||||
[value]="selectedProductName"
|
||||
[disabled]="true"
|
||||
class="w-full p-2 text-base"
|
||||
/>
|
||||
/>
|
||||
<p-button label="Select" severity="success" class="w-[100px]" (click)="onSelect()"></p-button>
|
||||
</div>
|
||||
<p-table [value]="paths" [tableStyle]="{ 'min-width': '50rem' }" class="flex-grow overflow-y-auto">
|
||||
@@ -21,8 +21,12 @@
|
||||
<ng-template pTemplate="body" let-product>
|
||||
<tr class="cursor-pointer hover:bg-white/10" (click)="onRowClick(product)">
|
||||
<td>
|
||||
<i *ngIf="product === '...'" class="pi pi-arrow-up"></i>
|
||||
<i *ngIf="product !== '...'" class="pi pi-folder-open"></i>
|
||||
@if (product === '...') {
|
||||
<i class="pi pi-arrow-up"></i>
|
||||
}
|
||||
@if (product !== '...') {
|
||||
<i class="pi pi-folder-open"></i>
|
||||
}
|
||||
</td>
|
||||
<td>{{ product }}</td>
|
||||
</tr>
|
||||
|
||||
+3
-4
@@ -3,7 +3,7 @@ import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {UtilityService} from './utility.service';
|
||||
import {Button} from 'primeng/button';
|
||||
import {TableModule} from 'primeng/table';
|
||||
import {NgIf} from '@angular/common';
|
||||
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
|
||||
@Component({
|
||||
@@ -13,9 +13,8 @@ import {InputText} from 'primeng/inputtext';
|
||||
imports: [
|
||||
Button,
|
||||
TableModule,
|
||||
InputText,
|
||||
NgIf
|
||||
],
|
||||
InputText
|
||||
],
|
||||
styleUrls: ['./directory-picker.component.scss']
|
||||
})
|
||||
export class DirectoryPickerComponent implements OnInit {
|
||||
|
||||
@@ -6,12 +6,13 @@
|
||||
[style]="{ width: '500px', height: '500px' }">
|
||||
<input type="text" placeholder="Search icons..." [(ngModel)]="searchText" class="icon-search"/>
|
||||
<div class="icon-grid">
|
||||
<div
|
||||
*ngFor="let icon of filteredIcons()"
|
||||
class="icon-item"
|
||||
(click)="selectIcon(icon)"
|
||||
[class.selected]="icon === selectedIcon">
|
||||
<i [class]="icon"></i>
|
||||
</div>
|
||||
@for (icon of filteredIcons(); track icon) {
|
||||
<div
|
||||
class="icon-item"
|
||||
(click)="selectIcon(icon)"
|
||||
[class.selected]="icon === selectedIcon">
|
||||
<i [class]="icon"></i>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</p-dialog>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {Component, EventEmitter, Input, Output} from '@angular/core';
|
||||
import {DialogModule} from 'primeng/dialog';
|
||||
import {NgForOf} from '@angular/common';
|
||||
|
||||
import {FormsModule} from '@angular/forms';
|
||||
|
||||
@Component({
|
||||
@@ -9,9 +9,8 @@ import {FormsModule} from '@angular/forms';
|
||||
styleUrls: ['./icon-picker.component.scss'],
|
||||
imports: [
|
||||
DialogModule,
|
||||
NgForOf,
|
||||
FormsModule
|
||||
],
|
||||
],
|
||||
standalone: true
|
||||
})
|
||||
export class IconPickerComponent {
|
||||
|
||||
Reference in New Issue
Block a user