@memberjunction/ng-file-storage 2.32.2 → 2.34.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 +214 -0
- package/package.json +7 -7
package/README.md
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# File Storage Components
|
|
2
|
+
|
|
3
|
+
A set of Angular components for managing file storage in MemberJunction applications. This package provides a complete file management system with categories, file upload, and grid display.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Category Management**: Create, rename, and organize file categories in a tree structure
|
|
8
|
+
- **File Grid**: Display files with sorting, filtering and pagination
|
|
9
|
+
- **File Upload**: Easy file uploading with progress tracking
|
|
10
|
+
- **File Operations**: Download, delete, and edit file metadata
|
|
11
|
+
- **Drag and Drop**: Move files between categories with drag and drop
|
|
12
|
+
- **Integration**: Seamless integration with MemberJunction's file storage system
|
|
13
|
+
- **Provider Support**: Works with multiple file storage providers
|
|
14
|
+
- **Overwrite Protection**: Confirmation dialog when overwriting existing files
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @memberjunction/ng-file-storage
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
### Import the Module
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { FileStorageModule } from '@memberjunction/ng-file-storage';
|
|
28
|
+
|
|
29
|
+
@NgModule({
|
|
30
|
+
imports: [
|
|
31
|
+
FileStorageModule,
|
|
32
|
+
// other imports
|
|
33
|
+
],
|
|
34
|
+
// ...
|
|
35
|
+
})
|
|
36
|
+
export class YourModule { }
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Basic Component Usage
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<!-- File management interface with category tree and file grid -->
|
|
43
|
+
<div class="file-manager-container">
|
|
44
|
+
<div class="category-panel">
|
|
45
|
+
<mj-files-category-tree
|
|
46
|
+
(categorySelected)="selectedCategoryId = $event">
|
|
47
|
+
</mj-files-category-tree>
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
<div class="files-panel">
|
|
51
|
+
<mj-files-grid
|
|
52
|
+
[CategoryID]="selectedCategoryId">
|
|
53
|
+
</mj-files-grid>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### File Upload Component
|
|
59
|
+
|
|
60
|
+
```html
|
|
61
|
+
<!-- Standalone file upload component -->
|
|
62
|
+
<mj-files-file-upload
|
|
63
|
+
[CategoryID]="selectedCategoryId"
|
|
64
|
+
(uploadStarted)="handleUploadStarted()"
|
|
65
|
+
(fileUpload)="handleFileUploaded($event)">
|
|
66
|
+
</mj-files-file-upload>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### TypeScript Component Example
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { Component } from '@angular/core';
|
|
73
|
+
import { FileUploadEvent } from '@memberjunction/ng-file-storage';
|
|
74
|
+
import { SharedService } from '@memberjunction/ng-shared';
|
|
75
|
+
|
|
76
|
+
@Component({
|
|
77
|
+
selector: 'app-document-manager',
|
|
78
|
+
template: `
|
|
79
|
+
<h2>Document Manager</h2>
|
|
80
|
+
|
|
81
|
+
<div class="file-manager">
|
|
82
|
+
<div class="categories">
|
|
83
|
+
<h3>Categories</h3>
|
|
84
|
+
<mj-files-category-tree
|
|
85
|
+
(categorySelected)="onCategorySelected($event)">
|
|
86
|
+
</mj-files-category-tree>
|
|
87
|
+
</div>
|
|
88
|
+
|
|
89
|
+
<div class="files">
|
|
90
|
+
<h3>Files in {{ currentCategoryName || 'All Categories' }}</h3>
|
|
91
|
+
<mj-files-grid
|
|
92
|
+
[CategoryID]="selectedCategoryId">
|
|
93
|
+
</mj-files-grid>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
`,
|
|
97
|
+
styles: [`
|
|
98
|
+
.file-manager {
|
|
99
|
+
display: flex;
|
|
100
|
+
height: 600px;
|
|
101
|
+
}
|
|
102
|
+
.categories {
|
|
103
|
+
width: 300px;
|
|
104
|
+
border-right: 1px solid #ccc;
|
|
105
|
+
padding-right: 20px;
|
|
106
|
+
}
|
|
107
|
+
.files {
|
|
108
|
+
flex: 1;
|
|
109
|
+
padding-left: 20px;
|
|
110
|
+
}
|
|
111
|
+
`]
|
|
112
|
+
})
|
|
113
|
+
export class DocumentManagerComponent {
|
|
114
|
+
selectedCategoryId?: string;
|
|
115
|
+
currentCategoryName?: string;
|
|
116
|
+
|
|
117
|
+
constructor(private sharedService: SharedService) {}
|
|
118
|
+
|
|
119
|
+
onCategorySelected(categoryId?: string) {
|
|
120
|
+
this.selectedCategoryId = categoryId;
|
|
121
|
+
// You could load the category name here if needed
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
handleFileUploaded(event: FileUploadEvent) {
|
|
125
|
+
if (event.success) {
|
|
126
|
+
this.sharedService.CreateSimpleNotification(
|
|
127
|
+
`File "${event.file.Name}" uploaded successfully`,
|
|
128
|
+
'success'
|
|
129
|
+
);
|
|
130
|
+
} else {
|
|
131
|
+
this.sharedService.CreateSimpleNotification(
|
|
132
|
+
`Failed to upload file "${event.file.name}"`,
|
|
133
|
+
'error'
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## API Reference
|
|
141
|
+
|
|
142
|
+
### CategoryTreeComponent
|
|
143
|
+
|
|
144
|
+
A tree view component for managing file categories.
|
|
145
|
+
|
|
146
|
+
#### Outputs
|
|
147
|
+
|
|
148
|
+
- `categorySelected`: EventEmitter<string | undefined> - Emitted when a category is selected in the tree
|
|
149
|
+
|
|
150
|
+
#### Methods
|
|
151
|
+
|
|
152
|
+
- `createNewCategory()`: Opens dialog to create a new category
|
|
153
|
+
- `deleteCategory(fileCategory: FileCategoryEntity)`: Deletes a category
|
|
154
|
+
- `handleDrop(e: TreeItemAddRemoveArgs)`: Handles drag and drop of categories
|
|
155
|
+
- `Refresh()`: Refreshes the category tree data
|
|
156
|
+
|
|
157
|
+
### FilesGridComponent
|
|
158
|
+
|
|
159
|
+
A grid component for displaying and managing files.
|
|
160
|
+
|
|
161
|
+
#### Inputs
|
|
162
|
+
|
|
163
|
+
- `CategoryID`: string | undefined - The ID of the category to filter files by
|
|
164
|
+
|
|
165
|
+
#### Methods
|
|
166
|
+
|
|
167
|
+
- `downloadFile(file: FileEntity)`: Downloads the specified file
|
|
168
|
+
- `deleteFile(file: FileEntity)`: Deletes the specified file
|
|
169
|
+
- `saveEditFile()`: Saves changes to a file's metadata
|
|
170
|
+
- `resetEditFile()`: Cancels editing a file's metadata
|
|
171
|
+
- `Refresh()`: Refreshes the files grid data
|
|
172
|
+
|
|
173
|
+
### FileUploadComponent
|
|
174
|
+
|
|
175
|
+
A component for uploading files.
|
|
176
|
+
|
|
177
|
+
#### Inputs
|
|
178
|
+
|
|
179
|
+
- `disabled`: boolean - Whether the upload component is disabled
|
|
180
|
+
- `CategoryID`: string | undefined - The category ID to assign to uploaded files
|
|
181
|
+
|
|
182
|
+
#### Outputs
|
|
183
|
+
|
|
184
|
+
- `uploadStarted`: EventEmitter<void> - Emitted when file upload starts
|
|
185
|
+
- `fileUpload`: EventEmitter<FileUploadEvent> - Emitted when a file is uploaded (success or failure)
|
|
186
|
+
|
|
187
|
+
#### Methods
|
|
188
|
+
|
|
189
|
+
- `Confirm()`: Confirms file overwrite
|
|
190
|
+
- `CancelConfirm()`: Cancels file overwrite
|
|
191
|
+
- `Refresh()`: Refreshes the file upload component state
|
|
192
|
+
|
|
193
|
+
## File Upload Flow
|
|
194
|
+
|
|
195
|
+
1. User selects a file using the file upload component
|
|
196
|
+
2. Component creates a preliminary file record in the MemberJunction system
|
|
197
|
+
3. If a file with the same name exists, a confirmation dialog is shown
|
|
198
|
+
4. On confirmation, the file is uploaded to the storage provider
|
|
199
|
+
5. After successful upload, the file record status is updated to "Uploaded"
|
|
200
|
+
6. The component emits a fileUpload event with success status and file details
|
|
201
|
+
|
|
202
|
+
## Styling
|
|
203
|
+
|
|
204
|
+
The components use Kendo UI components for consistent styling and include basic CSS that can be overridden in your application.
|
|
205
|
+
|
|
206
|
+
## Dependencies
|
|
207
|
+
|
|
208
|
+
- `@memberjunction/core`: For metadata and entity access
|
|
209
|
+
- `@memberjunction/core-entities`: For file-related entity types
|
|
210
|
+
- `@memberjunction/global`: For global utilities
|
|
211
|
+
- `@memberjunction/graphql-dataprovider`: For GraphQL data operations
|
|
212
|
+
- `@progress/kendo-angular-upload`: For file upload UI
|
|
213
|
+
- `@progress/kendo-angular-grid`: For file grid display
|
|
214
|
+
- `@progress/kendo-angular-treeview`: For category tree view
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ng-file-storage",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.34.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.34.0",
|
|
30
|
+
"@memberjunction/core-entities": "2.34.0",
|
|
31
|
+
"@memberjunction/global": "2.34.0",
|
|
32
|
+
"@memberjunction/graphql-dataprovider": "2.34.0",
|
|
33
|
+
"@memberjunction/ng-container-directives": "2.34.0",
|
|
34
|
+
"@memberjunction/ng-shared": "2.34.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",
|