@memberjunction/ng-file-storage 2.43.0 → 2.45.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 +239 -38
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @memberjunction/ng-file-storage
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Angular components for managing file storage in MemberJunction applications. This package provides a complete file management system with categories, file upload, and grid display capabilities integrated with MemberJunction's file storage providers.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -8,10 +8,12 @@ A set of Angular components for managing file storage in MemberJunction applicat
|
|
|
8
8
|
- **File Grid**: Display files with sorting, filtering and pagination
|
|
9
9
|
- **File Upload**: Easy file uploading with progress tracking
|
|
10
10
|
- **File Operations**: Download, delete, and edit file metadata
|
|
11
|
-
- **Drag and Drop**: Move files between categories with drag and drop
|
|
11
|
+
- **Drag and Drop**: Move files between categories with drag and drop support
|
|
12
12
|
- **Integration**: Seamless integration with MemberJunction's file storage system
|
|
13
|
-
- **Provider Support**: Works with multiple file storage providers
|
|
13
|
+
- **Provider Support**: Works with multiple file storage providers (Azure Blob, AWS S3, etc.)
|
|
14
14
|
- **Overwrite Protection**: Confirmation dialog when overwriting existing files
|
|
15
|
+
- **Status Management**: Track file upload status (Pending, Uploaded, Failed)
|
|
16
|
+
- **Type Safety**: Full TypeScript support with MemberJunction entities
|
|
15
17
|
|
|
16
18
|
## Installation
|
|
17
19
|
|
|
@@ -19,6 +21,20 @@ A set of Angular components for managing file storage in MemberJunction applicat
|
|
|
19
21
|
npm install @memberjunction/ng-file-storage
|
|
20
22
|
```
|
|
21
23
|
|
|
24
|
+
**Note**: This package requires Angular 18.0.2 or later and the following MemberJunction packages:
|
|
25
|
+
- `@memberjunction/core` (^2.43.0)
|
|
26
|
+
- `@memberjunction/core-entities` (^2.43.0)
|
|
27
|
+
- `@memberjunction/global` (^2.43.0)
|
|
28
|
+
- `@memberjunction/graphql-dataprovider` (^2.43.0)
|
|
29
|
+
|
|
30
|
+
## Prerequisites
|
|
31
|
+
|
|
32
|
+
Before using this package, ensure your MemberJunction database has:
|
|
33
|
+
- File Storage Providers configured and active
|
|
34
|
+
- File Categories entity permissions for users
|
|
35
|
+
- Files entity permissions for users
|
|
36
|
+
- Proper GraphQL endpoints configured
|
|
37
|
+
|
|
22
38
|
## Usage
|
|
23
39
|
|
|
24
40
|
### Import the Module
|
|
@@ -137,58 +153,112 @@ export class DocumentManagerComponent {
|
|
|
137
153
|
}
|
|
138
154
|
```
|
|
139
155
|
|
|
140
|
-
##
|
|
156
|
+
## Component Reference
|
|
141
157
|
|
|
142
|
-
### CategoryTreeComponent
|
|
158
|
+
### CategoryTreeComponent (`mj-files-category-tree`)
|
|
143
159
|
|
|
144
160
|
A tree view component for managing file categories.
|
|
145
161
|
|
|
162
|
+
#### Selector
|
|
163
|
+
```typescript
|
|
164
|
+
selector: 'mj-files-category-tree'
|
|
165
|
+
```
|
|
166
|
+
|
|
146
167
|
#### Outputs
|
|
147
168
|
|
|
148
|
-
|
|
169
|
+
| Output | Type | Description |
|
|
170
|
+
|--------|------|-------------|
|
|
171
|
+
| `categorySelected` | `EventEmitter<string \| undefined>` | Emitted when a category is selected in the tree |
|
|
172
|
+
|
|
173
|
+
#### Public Methods
|
|
149
174
|
|
|
150
|
-
|
|
175
|
+
| Method | Description | Parameters | Returns |
|
|
176
|
+
|--------|-------------|------------|----------|
|
|
177
|
+
| `createNewCategory()` | Opens dialog to create a new category | None | `Promise<void>` |
|
|
178
|
+
| `deleteCategory(fileCategory: FileCategoryEntity)` | Deletes a category with error handling | `fileCategory: FileCategoryEntity` | `Promise<void>` |
|
|
179
|
+
| `handleDrop(e: TreeItemAddRemoveArgs)` | Handles drag and drop to move categories | `e: TreeItemAddRemoveArgs` | `Promise<void>` |
|
|
180
|
+
| `Refresh()` | Refreshes the category tree data | None | `Promise<void>` |
|
|
181
|
+
| `clearSelection()` | Clears the current selection | None | `void` |
|
|
182
|
+
| `saveNewCategory()` | Saves a new category | None | `Promise<void>` |
|
|
183
|
+
| `saveRename()` | Saves category rename | None | `Promise<void>` |
|
|
184
|
+
| `cancelRename()` | Cancels category rename | None | `void` |
|
|
151
185
|
|
|
152
|
-
|
|
153
|
-
- `deleteCategory(fileCategory: FileCategoryEntity)`: Deletes a category
|
|
154
|
-
- `handleDrop(e: TreeItemAddRemoveArgs)`: Handles drag and drop of categories
|
|
155
|
-
- `Refresh()`: Refreshes the category tree data
|
|
186
|
+
### FilesGridComponent (`mj-files-grid`)
|
|
156
187
|
|
|
157
|
-
|
|
188
|
+
A grid component for displaying and managing files with support for inline editing and file operations.
|
|
158
189
|
|
|
159
|
-
|
|
190
|
+
#### Selector
|
|
191
|
+
```typescript
|
|
192
|
+
selector: 'mj-files-grid'
|
|
193
|
+
```
|
|
160
194
|
|
|
161
195
|
#### Inputs
|
|
162
196
|
|
|
163
|
-
|
|
197
|
+
| Input | Type | Description | Default |
|
|
198
|
+
|-------|------|-------------|----------|
|
|
199
|
+
| `CategoryID` | `string \| undefined` | The ID of the category to filter files by | `undefined` |
|
|
164
200
|
|
|
165
|
-
#### Methods
|
|
201
|
+
#### Public Methods
|
|
166
202
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
203
|
+
| Method | Description | Parameters | Returns |
|
|
204
|
+
|--------|-------------|------------|----------|
|
|
205
|
+
| `downloadFile(file: FileEntity)` | Downloads file using provider's download URL | `file: FileEntity` | `Promise<void>` |
|
|
206
|
+
| `deleteFile(file: FileEntity)` | Deletes file with confirmation | `file: FileEntity` | `Promise<void>` |
|
|
207
|
+
| `saveEditFile()` | Saves changes to file metadata | None | `Promise<void>` |
|
|
208
|
+
| `resetEditFile()` | Cancels editing file metadata | None | `void` |
|
|
209
|
+
| `handleFileUpload(e: FileUploadEvent)` | Handles file upload events | `e: FileUploadEvent` | `void` |
|
|
210
|
+
| `canBeDeleted(file: FileEntity)` | Checks if file can be deleted | `file: FileEntity` | `boolean` |
|
|
211
|
+
| `Refresh()` | Refreshes the files grid data | None | `Promise<void>` |
|
|
172
212
|
|
|
173
|
-
### FileUploadComponent
|
|
213
|
+
### FileUploadComponent (`mj-files-file-upload`)
|
|
174
214
|
|
|
175
|
-
A component for uploading files.
|
|
215
|
+
A component for uploading files with provider integration and overwrite protection.
|
|
216
|
+
|
|
217
|
+
#### Selector
|
|
218
|
+
```typescript
|
|
219
|
+
selector: 'mj-files-file-upload'
|
|
220
|
+
```
|
|
176
221
|
|
|
177
222
|
#### Inputs
|
|
178
223
|
|
|
179
|
-
|
|
180
|
-
|
|
224
|
+
| Input | Type | Description | Default |
|
|
225
|
+
|-------|------|-------------|----------|
|
|
226
|
+
| `disabled` | `boolean` | Whether the upload component is disabled | `false` |
|
|
227
|
+
| `CategoryID` | `string \| undefined` | The category ID to assign to uploaded files | `undefined` |
|
|
181
228
|
|
|
182
229
|
#### Outputs
|
|
183
230
|
|
|
184
|
-
|
|
185
|
-
|
|
231
|
+
| Output | Type | Description |
|
|
232
|
+
|--------|------|-------------|
|
|
233
|
+
| `uploadStarted` | `EventEmitter<void>` | Emitted when file upload starts |
|
|
234
|
+
| `fileUpload` | `EventEmitter<FileUploadEvent>` | Emitted when a file is uploaded (success or failure) |
|
|
235
|
+
|
|
236
|
+
#### Public Methods
|
|
237
|
+
|
|
238
|
+
| Method | Description | Parameters | Returns |
|
|
239
|
+
|--------|-------------|------------|----------|
|
|
240
|
+
| `Confirm()` | Confirms file overwrite and proceeds with upload | None | `void` |
|
|
241
|
+
| `CancelConfirm()` | Cancels file overwrite and deletes pending record | None | `Promise<void>` |
|
|
242
|
+
| `Refresh()` | Loads default file storage provider | None | `Promise<void>` |
|
|
243
|
+
| `SelectEventHandler(e: SelectEvent)` | Handles file selection | `e: SelectEvent` | `Promise<void>` |
|
|
244
|
+
|
|
245
|
+
#### Properties
|
|
246
|
+
|
|
247
|
+
| Property | Type | Description |
|
|
248
|
+
|----------|------|-------------|
|
|
249
|
+
| `IsUploading` | `boolean` | Indicates if files are currently being uploaded |
|
|
250
|
+
|
|
251
|
+
## Types
|
|
186
252
|
|
|
187
|
-
|
|
253
|
+
### FileUploadEvent
|
|
188
254
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
255
|
+
```typescript
|
|
256
|
+
export type FileUploadEvent =
|
|
257
|
+
| { success: true; file: FileEntity }
|
|
258
|
+
| { success: false; file: FileInfo };
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
This type represents the result of a file upload operation, containing either a successful FileEntity or a failed FileInfo object.
|
|
192
262
|
|
|
193
263
|
## File Upload Flow
|
|
194
264
|
|
|
@@ -203,12 +273,143 @@ A component for uploading files.
|
|
|
203
273
|
|
|
204
274
|
The components use Kendo UI components for consistent styling and include basic CSS that can be overridden in your application.
|
|
205
275
|
|
|
276
|
+
## Advanced Usage
|
|
277
|
+
|
|
278
|
+
### Custom File Grid with Actions
|
|
279
|
+
|
|
280
|
+
```typescript
|
|
281
|
+
import { Component, ViewChild } from '@angular/core';
|
|
282
|
+
import { FilesGridComponent, FileUploadEvent } from '@memberjunction/ng-file-storage';
|
|
283
|
+
import { FileEntity } from '@memberjunction/core-entities';
|
|
284
|
+
|
|
285
|
+
@Component({
|
|
286
|
+
template: `
|
|
287
|
+
<div class="file-manager">
|
|
288
|
+
<div class="toolbar">
|
|
289
|
+
<button (click)="refreshFiles()">Refresh</button>
|
|
290
|
+
<mj-files-file-upload
|
|
291
|
+
[CategoryID]="categoryId"
|
|
292
|
+
(fileUpload)="onFileUploaded($event)">
|
|
293
|
+
</mj-files-file-upload>
|
|
294
|
+
</div>
|
|
295
|
+
|
|
296
|
+
<mj-files-grid #filesGrid
|
|
297
|
+
[CategoryID]="categoryId">
|
|
298
|
+
</mj-files-grid>
|
|
299
|
+
</div>
|
|
300
|
+
`
|
|
301
|
+
})
|
|
302
|
+
export class CustomFileManagerComponent {
|
|
303
|
+
@ViewChild('filesGrid') filesGrid!: FilesGridComponent;
|
|
304
|
+
categoryId = 'some-category-id';
|
|
305
|
+
|
|
306
|
+
refreshFiles() {
|
|
307
|
+
this.filesGrid.Refresh();
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
onFileUploaded(event: FileUploadEvent) {
|
|
311
|
+
if (event.success) {
|
|
312
|
+
console.log('File uploaded:', event.file.Name);
|
|
313
|
+
// The grid automatically adds the file, no refresh needed
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### Programmatic Category Management
|
|
320
|
+
|
|
321
|
+
```typescript
|
|
322
|
+
import { Component, ViewChild } from '@angular/core';
|
|
323
|
+
import { CategoryTreeComponent } from '@memberjunction/ng-file-storage';
|
|
324
|
+
import { Metadata } from '@memberjunction/core';
|
|
325
|
+
import { FileCategoryEntity } from '@memberjunction/core-entities';
|
|
326
|
+
|
|
327
|
+
@Component({
|
|
328
|
+
template: `
|
|
329
|
+
<mj-files-category-tree #categoryTree
|
|
330
|
+
(categorySelected)="onCategorySelected($event)">
|
|
331
|
+
</mj-files-category-tree>
|
|
332
|
+
`
|
|
333
|
+
})
|
|
334
|
+
export class CategoryManagerComponent {
|
|
335
|
+
@ViewChild('categoryTree') categoryTree!: CategoryTreeComponent;
|
|
336
|
+
|
|
337
|
+
async createCategoryProgrammatically(name: string, parentId?: string) {
|
|
338
|
+
const md = new Metadata();
|
|
339
|
+
const category = await md.GetEntityObject<FileCategoryEntity>('File Categories');
|
|
340
|
+
category.NewRecord();
|
|
341
|
+
category.Name = name;
|
|
342
|
+
category.ParentID = parentId;
|
|
343
|
+
|
|
344
|
+
if (await category.Save()) {
|
|
345
|
+
// Refresh the tree to show new category
|
|
346
|
+
await this.categoryTree.Refresh();
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
onCategorySelected(categoryId?: string) {
|
|
351
|
+
console.log('Selected category:', categoryId);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
## Module Exports
|
|
357
|
+
|
|
358
|
+
The `FileStorageModule` exports the following components:
|
|
359
|
+
- `CategoryTreeComponent`
|
|
360
|
+
- `FilesGridComponent`
|
|
361
|
+
- `FileUploadComponent`
|
|
362
|
+
|
|
206
363
|
## Dependencies
|
|
207
364
|
|
|
208
|
-
|
|
209
|
-
- `@memberjunction/core
|
|
210
|
-
- `@memberjunction/
|
|
211
|
-
- `@memberjunction/
|
|
212
|
-
- `@
|
|
213
|
-
- `@
|
|
214
|
-
- `@
|
|
365
|
+
### MemberJunction Dependencies
|
|
366
|
+
- `@memberjunction/core` (^2.43.0): Core metadata and entity access
|
|
367
|
+
- `@memberjunction/core-entities` (^2.43.0): File-related entity types
|
|
368
|
+
- `@memberjunction/global` (^2.43.0): Global utilities
|
|
369
|
+
- `@memberjunction/graphql-dataprovider` (^2.43.0): GraphQL data operations
|
|
370
|
+
- `@memberjunction/ng-container-directives` (^2.43.0): Container directives
|
|
371
|
+
- `@memberjunction/ng-shared` (^2.43.0): Shared Angular services
|
|
372
|
+
|
|
373
|
+
### Kendo UI Dependencies
|
|
374
|
+
- `@progress/kendo-angular-buttons` (^16.2.0)
|
|
375
|
+
- `@progress/kendo-angular-dialog` (^16.2.0)
|
|
376
|
+
- `@progress/kendo-angular-dropdowns` (^16.2.0)
|
|
377
|
+
- `@progress/kendo-angular-grid` (^16.2.0)
|
|
378
|
+
- `@progress/kendo-angular-indicators` (^16.2.0)
|
|
379
|
+
- `@progress/kendo-angular-menu` (^16.2.0)
|
|
380
|
+
- `@progress/kendo-angular-treeview` (^16.2.0)
|
|
381
|
+
- `@progress/kendo-angular-upload` (^16.2.0)
|
|
382
|
+
|
|
383
|
+
### Other Dependencies
|
|
384
|
+
- `tslib` (^2.3.0)
|
|
385
|
+
- `zod` (^3.23.4): Schema validation
|
|
386
|
+
|
|
387
|
+
## Build and Development
|
|
388
|
+
|
|
389
|
+
### Building the Package
|
|
390
|
+
```bash
|
|
391
|
+
cd packages/Angular/Generic/file-storage
|
|
392
|
+
npm run build
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### Watch Mode
|
|
396
|
+
```bash
|
|
397
|
+
npm run watch
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
### Integration with MemberJunction
|
|
401
|
+
|
|
402
|
+
This package integrates with:
|
|
403
|
+
- **File Storage Providers**: Automatically uses the highest priority active provider
|
|
404
|
+
- **GraphQL API**: Uses MemberJunction's GraphQL layer for all operations
|
|
405
|
+
- **Entity Framework**: Leverages MemberJunction's entity system for type safety
|
|
406
|
+
- **Permissions**: Respects entity-level permissions for Files and File Categories
|
|
407
|
+
|
|
408
|
+
## Notes
|
|
409
|
+
|
|
410
|
+
- File deletion is restricted based on upload status and age (10 minutes for pending files)
|
|
411
|
+
- The component automatically handles file overwrite scenarios with user confirmation
|
|
412
|
+
- All file operations are tracked with status updates (Pending → Uploaded)
|
|
413
|
+
- File download uses provider-specific signed URLs for security
|
|
414
|
+
- Category operations support drag-and-drop reorganization
|
|
415
|
+
- Components include loading states for all async operations
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ng-file-storage",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.45.0",
|
|
4
4
|
"description": "MemberJunction: Angular components for managing files, and related components.",
|
|
5
5
|
"main": "./dist/public-api.js",
|
|
6
6
|
"typings": "./dist/public-api.d.ts",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"@angular/router": "18.0.2"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@memberjunction/core": "2.
|
|
30
|
-
"@memberjunction/core-entities": "2.
|
|
31
|
-
"@memberjunction/global": "2.
|
|
32
|
-
"@memberjunction/graphql-dataprovider": "2.
|
|
33
|
-
"@memberjunction/ng-container-directives": "2.
|
|
34
|
-
"@memberjunction/ng-shared": "2.
|
|
29
|
+
"@memberjunction/core": "2.45.0",
|
|
30
|
+
"@memberjunction/core-entities": "2.45.0",
|
|
31
|
+
"@memberjunction/global": "2.45.0",
|
|
32
|
+
"@memberjunction/graphql-dataprovider": "2.45.0",
|
|
33
|
+
"@memberjunction/ng-container-directives": "2.45.0",
|
|
34
|
+
"@memberjunction/ng-shared": "2.45.0",
|
|
35
35
|
"@progress/kendo-angular-buttons": "16.2.0",
|
|
36
36
|
"@progress/kendo-angular-dialog": "16.2.0",
|
|
37
37
|
"@progress/kendo-angular-dropdowns": "16.2.0",
|