@flusys/ng-storage 1.1.0-beta → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +144 -5
- package/fesm2022/{flusys-ng-storage-file-manager-form.component-CxAYC6nj.mjs → flusys-ng-storage-file-manager-form.component-CXVB9G-f.mjs} +120 -351
- package/fesm2022/flusys-ng-storage-file-manager-form.component-CXVB9G-f.mjs.map +1 -0
- package/fesm2022/flusys-ng-storage-file-manager-list.component-0O_b4EjN.mjs +304 -0
- package/fesm2022/flusys-ng-storage-file-manager-list.component-0O_b4EjN.mjs.map +1 -0
- package/fesm2022/flusys-ng-storage-folder-form.component-BTQGEqNu.mjs +155 -0
- package/fesm2022/flusys-ng-storage-folder-form.component-BTQGEqNu.mjs.map +1 -0
- package/fesm2022/flusys-ng-storage-folder-list.component-B8GoIh6Z.mjs +194 -0
- package/fesm2022/flusys-ng-storage-folder-list.component-B8GoIh6Z.mjs.map +1 -0
- package/fesm2022/{flusys-ng-storage-storage-config-form.component-SEYIBife.mjs → flusys-ng-storage-storage-config-form.component-CorNWrmF.mjs} +219 -302
- package/fesm2022/flusys-ng-storage-storage-config-form.component-CorNWrmF.mjs.map +1 -0
- package/fesm2022/flusys-ng-storage-storage-config-list.component-YXzz3Tvo.mjs +187 -0
- package/fesm2022/flusys-ng-storage-storage-config-list.component-YXzz3Tvo.mjs.map +1 -0
- package/fesm2022/flusys-ng-storage.mjs +267 -226
- package/fesm2022/flusys-ng-storage.mjs.map +1 -1
- package/package.json +9 -9
- package/types/flusys-ng-storage.d.ts +101 -151
- package/fesm2022/flusys-ng-storage-file-manager-form.component-CxAYC6nj.mjs.map +0 -1
- package/fesm2022/flusys-ng-storage-file-manager-list.component-BevfDZO0.mjs +0 -475
- package/fesm2022/flusys-ng-storage-file-manager-list.component-BevfDZO0.mjs.map +0 -1
- package/fesm2022/flusys-ng-storage-folder-form.component-BhurG3dl.mjs +0 -253
- package/fesm2022/flusys-ng-storage-folder-form.component-BhurG3dl.mjs.map +0 -1
- package/fesm2022/flusys-ng-storage-folder-list.component-Clrjcw0B.mjs +0 -267
- package/fesm2022/flusys-ng-storage-folder-list.component-Clrjcw0B.mjs.map +0 -1
- package/fesm2022/flusys-ng-storage-storage-config-form.component-SEYIBife.mjs.map +0 -1
- package/fesm2022/flusys-ng-storage-storage-config-list.component-CofVBysj.mjs +0 -328
- package/fesm2022/flusys-ng-storage-storage-config-list.component-CofVBysj.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Storage Package Guide
|
|
2
2
|
|
|
3
3
|
> **Package:** `@flusys/ng-storage`
|
|
4
|
+
> **Version:** 1.1.0
|
|
4
5
|
> **Type:** File storage management with upload, folder organization, and multi-provider support
|
|
5
6
|
|
|
6
7
|
---
|
|
@@ -48,6 +49,8 @@ readonly currentCompanyName = computed(
|
|
|
48
49
|
|
|
49
50
|
```
|
|
50
51
|
ng-storage/
|
|
52
|
+
├── adapters/
|
|
53
|
+
│ └── profile-upload-provider.adapter.ts # Profile upload adapter for ng-auth
|
|
51
54
|
├── enums/
|
|
52
55
|
│ ├── file-location.enum.ts # FileLocationEnum, ImageFormat
|
|
53
56
|
│ └── public-api.ts
|
|
@@ -57,11 +60,17 @@ ng-storage/
|
|
|
57
60
|
│ ├── storage-config.interface.ts # IStorageConfig, provider-specific configs
|
|
58
61
|
│ ├── upload.interface.ts # IUploadOptionsDto, IUploadedFileInfo
|
|
59
62
|
│ └── public-api.ts
|
|
63
|
+
├── providers/
|
|
64
|
+
│ └── storage-providers.ts # provideStorageProviders()
|
|
60
65
|
├── services/
|
|
61
66
|
│ ├── file-manager-api.service.ts # File metadata CRUD + presigned URLs
|
|
62
67
|
│ ├── folder-api.service.ts # Folder CRUD
|
|
63
68
|
│ ├── storage-config-api.service.ts # Storage config CRUD
|
|
64
69
|
│ └── upload.service.ts # File upload/delete operations
|
|
70
|
+
├── utils/
|
|
71
|
+
│ ├── base-storage-page.ts # BaseStoragePage, BaseStorageListPage base classes
|
|
72
|
+
│ ├── storage-utils.ts # Utility functions (icons, labels, formatters)
|
|
73
|
+
│ └── public-api.ts
|
|
65
74
|
├── pages/
|
|
66
75
|
│ ├── storage-container/
|
|
67
76
|
│ │ └── storage-container.component.ts # Tab container (Files, Folders, Configs)
|
|
@@ -184,6 +193,7 @@ interface IFileManager {
|
|
|
184
193
|
url: string | null; // Presigned URL (regenerated by backend)
|
|
185
194
|
location: FileLocationEnum;
|
|
186
195
|
storageConfigId: string | null;
|
|
196
|
+
providerName?: string; // Storage config name (enriched from storage_config table)
|
|
187
197
|
expiresAt: Date | null; // URL expiration time
|
|
188
198
|
isPrivate: boolean;
|
|
189
199
|
companyId?: string; // Only in company mode
|
|
@@ -303,9 +313,11 @@ Handles file upload and deletion. Extends `BaseApiService` (from ng-core).
|
|
|
303
313
|
|--------|----------|-------------|
|
|
304
314
|
| `uploadSingleFile(file, options?)` | `POST /storage/upload/single-file` | Upload single file |
|
|
305
315
|
| `uploadMultipleFiles(files, options?)` | `POST /storage/upload/multiple-file` | Upload multiple files (max 50) |
|
|
316
|
+
| `uploadAndRegister(file, options?)` | Combined | Upload file and create file manager record |
|
|
306
317
|
| `deleteSingleFile(key, storageConfigId?)` | `POST /storage/upload/delete-single-file` | Delete single file from storage |
|
|
307
318
|
| `deleteMultipleFiles(keys, storageConfigId?)` | `POST /storage/upload/delete-multiple-file` | Delete multiple files |
|
|
308
319
|
| `getFileUrl(key)` | `GET /storage/upload/file/:key` | Get direct file download URL |
|
|
320
|
+
| `getDefaultConfigId()` | - | Get default storage config ID from APP_CONFIG |
|
|
309
321
|
|
|
310
322
|
Upload options are sent as **query parameters**, not form data:
|
|
311
323
|
|
|
@@ -357,19 +369,58 @@ Storage provider configuration CRUD. Extends `ApiResourceService<IUpdateStorageC
|
|
|
357
369
|
|
|
358
370
|
All components are standalone, use Angular 21 signal forms, and lazy-load via routes.
|
|
359
371
|
|
|
372
|
+
### Base Classes
|
|
373
|
+
|
|
374
|
+
Components extend shared base classes from `utils/base-storage-page.ts`:
|
|
375
|
+
|
|
376
|
+
```typescript
|
|
377
|
+
// BaseStoragePage - Common functionality for all storage pages
|
|
378
|
+
abstract class BaseStoragePage {
|
|
379
|
+
readonly isLoading = signal(false);
|
|
380
|
+
readonly showCompanyInfo = computed(() => this.appConfig.enableCompanyFeature);
|
|
381
|
+
readonly currentCompanyName = computed(() =>
|
|
382
|
+
this.companyContext.currentCompanyInfo()?.name ?? DEFAULT_APP_NAME
|
|
383
|
+
);
|
|
384
|
+
|
|
385
|
+
protected showSuccess(detail: string): void;
|
|
386
|
+
protected showError(detail: string): void;
|
|
387
|
+
protected navigateTo(path: string[]): void;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// BaseStorageListPage - Adds pagination support
|
|
391
|
+
abstract class BaseStorageListPage extends BaseStoragePage {
|
|
392
|
+
readonly totalRecords = signal(0);
|
|
393
|
+
readonly pageSize = signal(50);
|
|
394
|
+
readonly currentPage = signal(1);
|
|
395
|
+
|
|
396
|
+
onPageChange(event: { first?: number; rows?: number }): void;
|
|
397
|
+
protected getPaginationParams(): { currentPage: number; pageSize: number };
|
|
398
|
+
abstract loadData(): Promise<void>;
|
|
399
|
+
}
|
|
400
|
+
```
|
|
401
|
+
|
|
360
402
|
### StorageContainerComponent
|
|
361
403
|
|
|
362
|
-
Main container with tab navigation between Files, Folders, and Configs sections.
|
|
404
|
+
Main container with tab navigation between Files, Folders, and Configs sections.
|
|
363
405
|
|
|
364
406
|
**Selector:** `lib-storage-container`
|
|
365
407
|
|
|
408
|
+
**Features:**
|
|
409
|
+
- Tab navigation with `scrollbar-hide` CSS (horizontal scroll without visible scrollbar on mobile)
|
|
410
|
+
- Responsive padding: `p-2 sm:p-4`
|
|
411
|
+
- Dark mode compatible using Tailwind theme classes
|
|
412
|
+
|
|
366
413
|
### List Components
|
|
367
414
|
|
|
368
415
|
All list components share:
|
|
369
|
-
- **
|
|
370
|
-
- **
|
|
416
|
+
- **Extends `BaseStorageListPage`** for common functionality
|
|
417
|
+
- **Lazy pagination** via `p-table` with `[paginator]="totalRecords() > 0"` (hidden when no data)
|
|
418
|
+
- **Responsive columns** with `hidden sm:table-cell`, `hidden md:table-cell`, etc.
|
|
419
|
+
- **Company info display** when company feature enabled
|
|
371
420
|
- **Delete confirmation** via `ConfirmationService`
|
|
372
|
-
- **Signal-based state:** `isLoading`,
|
|
421
|
+
- **Signal-based state:** `isLoading`, data signal, `totalRecords`, `pageSize`, `currentPage`
|
|
422
|
+
- **Responsive title:** `text-lg sm:text-xl`
|
|
423
|
+
- **Responsive buttons:** `w-full sm:w-auto`
|
|
373
424
|
|
|
374
425
|
**FileManagerListComponent** additionally supports:
|
|
375
426
|
- File content type icons (image, video, audio, PDF, Word, Excel, generic)
|
|
@@ -383,6 +434,11 @@ All form components share:
|
|
|
383
434
|
- **Signal Forms** using Angular 21 `form()` helper with `required()` validators
|
|
384
435
|
- **Create/Edit mode** auto-detection based on route param (`:id`)
|
|
385
436
|
- **Navigation** back to list on save/cancel
|
|
437
|
+
- **Button styling pattern:**
|
|
438
|
+
- Cancel: `severity="secondary" [outlined]="true"`
|
|
439
|
+
- Submit: Primary style (no severity attribute)
|
|
440
|
+
- Order: Cancel first, then Submit (right-aligned)
|
|
441
|
+
- Responsive: `flex justify-end gap-4 pt-4`
|
|
386
442
|
|
|
387
443
|
**FileManagerFormComponent** additionally supports:
|
|
388
444
|
- PrimeNG file upload with drag-drop
|
|
@@ -403,6 +459,41 @@ When `isDefault: true`, this configuration will be used automatically when no `s
|
|
|
403
459
|
|
|
404
460
|
---
|
|
405
461
|
|
|
462
|
+
## Utility Functions
|
|
463
|
+
|
|
464
|
+
The `utils/storage-utils.ts` file provides helper functions used across components:
|
|
465
|
+
|
|
466
|
+
```typescript
|
|
467
|
+
// Get display label for storage provider
|
|
468
|
+
getProviderLabel(storage: FileLocationEnum): string;
|
|
469
|
+
// Returns: 'AWS S3', 'Azure Blob', 'SFTP', 'Local'
|
|
470
|
+
|
|
471
|
+
// Get icon class for storage provider
|
|
472
|
+
getProviderIcon(storage: FileLocationEnum): string;
|
|
473
|
+
// Returns: 'pi pi-cloud', 'pi pi-server', 'pi pi-folder'
|
|
474
|
+
|
|
475
|
+
// Get severity for p-tag based on provider
|
|
476
|
+
getProviderSeverity(storage: FileLocationEnum): 'success' | 'info' | 'warn' | 'danger' | 'secondary' | 'contrast';
|
|
477
|
+
|
|
478
|
+
// Get file icon based on content type
|
|
479
|
+
getFileIcon(contentType: string): string;
|
|
480
|
+
// Returns: 'pi pi-image', 'pi pi-video', 'pi pi-file-pdf', etc.
|
|
481
|
+
|
|
482
|
+
// Format file size to human readable
|
|
483
|
+
formatFileSize(bytes: number): string;
|
|
484
|
+
// Returns: '1.5 MB', '256 KB', etc.
|
|
485
|
+
|
|
486
|
+
// Storage provider options for dropdowns
|
|
487
|
+
const STORAGE_PROVIDERS = [
|
|
488
|
+
{ label: 'AWS S3', value: FileLocationEnum.AWS },
|
|
489
|
+
{ label: 'Azure Blob Storage', value: FileLocationEnum.AZURE },
|
|
490
|
+
{ label: 'SFTP', value: FileLocationEnum.SFTP },
|
|
491
|
+
{ label: 'Local Storage', value: FileLocationEnum.LOCAL },
|
|
492
|
+
];
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
---
|
|
496
|
+
|
|
406
497
|
## Usage Examples
|
|
407
498
|
|
|
408
499
|
### Upload a File
|
|
@@ -428,6 +519,28 @@ async uploadImage(file: File): Promise<IUploadedFileInfo | null> {
|
|
|
428
519
|
}
|
|
429
520
|
```
|
|
430
521
|
|
|
522
|
+
### Upload and Register (Combined)
|
|
523
|
+
|
|
524
|
+
Use `uploadAndRegister` for a single call that uploads and creates the file manager record:
|
|
525
|
+
|
|
526
|
+
```typescript
|
|
527
|
+
import { UploadService, IFileManager } from '@flusys/ng-storage';
|
|
528
|
+
|
|
529
|
+
private readonly uploadService = inject(UploadService);
|
|
530
|
+
|
|
531
|
+
async uploadProfilePicture(file: File): Promise<IFileManager | null> {
|
|
532
|
+
const response = await firstValueFrom(
|
|
533
|
+
this.uploadService.uploadAndRegister(file, {
|
|
534
|
+
compress: true,
|
|
535
|
+
quality: 85,
|
|
536
|
+
isPrivate: false,
|
|
537
|
+
folderId: 'avatars-folder-id',
|
|
538
|
+
})
|
|
539
|
+
);
|
|
540
|
+
return response.success ? response.data : null;
|
|
541
|
+
}
|
|
542
|
+
```
|
|
543
|
+
|
|
431
544
|
### Get Files with Presigned URLs
|
|
432
545
|
|
|
433
546
|
```typescript
|
|
@@ -566,6 +679,31 @@ services: {
|
|
|
566
679
|
}
|
|
567
680
|
```
|
|
568
681
|
|
|
682
|
+
### 6. Responsive Design Patterns
|
|
683
|
+
|
|
684
|
+
All components follow these responsive patterns:
|
|
685
|
+
|
|
686
|
+
```html
|
|
687
|
+
<!-- Titles: smaller on mobile -->
|
|
688
|
+
<h3 class="text-lg sm:text-xl font-semibold">Title</h3>
|
|
689
|
+
|
|
690
|
+
<!-- Buttons: full width on mobile, auto on larger -->
|
|
691
|
+
<p-button label="New" styleClass="w-full sm:w-auto" />
|
|
692
|
+
|
|
693
|
+
<!-- Form grids: stack on mobile, 2 columns on md+ -->
|
|
694
|
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
695
|
+
|
|
696
|
+
<!-- Labels: smaller text on mobile -->
|
|
697
|
+
<label class="text-sm sm:text-base">Label</label>
|
|
698
|
+
|
|
699
|
+
<!-- Table columns: hide on smaller screens -->
|
|
700
|
+
<th class="hidden sm:table-cell">Column</th>
|
|
701
|
+
<th class="hidden md:table-cell">Column</th>
|
|
702
|
+
|
|
703
|
+
<!-- Tab navigation: horizontal scroll without visible scrollbar -->
|
|
704
|
+
<div class="scrollbar-hide flex overflow-x-auto">
|
|
705
|
+
```
|
|
706
|
+
|
|
569
707
|
---
|
|
570
708
|
|
|
571
709
|
## Provider Functions
|
|
@@ -653,5 +791,6 @@ export { provideStorageProviders } from '@flusys/ng-storage';
|
|
|
653
791
|
|
|
654
792
|
---
|
|
655
793
|
|
|
656
|
-
**Last Updated:** 2026-02-
|
|
794
|
+
**Last Updated:** 2026-02-23
|
|
795
|
+
**Version:** 1.1.0
|
|
657
796
|
**Angular Version:** 21
|