@memberjunction/ng-file-storage 0.9.3
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/dist/lib/category-tree/category-tree.d.ts +17 -0
- package/dist/lib/category-tree/category-tree.d.ts.map +1 -0
- package/dist/lib/category-tree/category-tree.js +61 -0
- package/dist/lib/file-upload/file-upload.d.ts +28 -0
- package/dist/lib/file-upload/file-upload.d.ts.map +1 -0
- package/dist/lib/file-upload/file-upload.js +158 -0
- package/dist/lib/files-grid/files-grid.d.ts +48 -0
- package/dist/lib/files-grid/files-grid.d.ts.map +1 -0
- package/dist/lib/files-grid/files-grid.js +259 -0
- package/dist/lib/module.d.ts +26 -0
- package/dist/lib/module.d.ts.map +1 -0
- package/dist/lib/module.js +83 -0
- package/dist/public-api.d.ts +4 -0
- package/dist/public-api.d.ts.map +1 -0
- package/dist/public-api.js +6 -0
- package/package.json +44 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { OnInit } from '@angular/core';
|
|
2
|
+
import { FileCategoryEntity } from '@memberjunction/core-entities';
|
|
3
|
+
import { kendoSVGIcon } from '@memberjunction/ng-shared';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
export declare class CategoryTreeComponent implements OnInit {
|
|
6
|
+
EntityName: string;
|
|
7
|
+
BottomMargin: number;
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
kendoSVGIcon: typeof kendoSVGIcon;
|
|
10
|
+
categoriesData: FileCategoryEntity[];
|
|
11
|
+
constructor();
|
|
12
|
+
ngOnInit(): void;
|
|
13
|
+
Refresh(): Promise<void>;
|
|
14
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CategoryTreeComponent, never>;
|
|
15
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<CategoryTreeComponent, "mj-files-category-tree", never, { "EntityName": { "alias": "EntityName"; "required": false; }; "BottomMargin": { "alias": "BottomMargin"; "required": false; }; }, {}, never, never, false, never>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=category-tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"category-tree.d.ts","sourceRoot":"","sources":["../../../src/lib/category-tree/category-tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,MAAM,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;;AAGzD,qBAKa,qBAAsB,YAAW,MAAM;IACzC,UAAU,EAAG,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAK;IAE3B,SAAS,EAAE,OAAO,CAAS;IAE3B,YAAY,sBAAgB;IAE5B,cAAc,EAAE,kBAAkB,EAAE,CAAM;;IAIjD,QAAQ,IAAI,IAAI;IAIV,OAAO;yCAhBF,qBAAqB;2CAArB,qBAAqB;CAiCjC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { Component, Input } from '@angular/core';
|
|
11
|
+
import { RunView } from '@memberjunction/core';
|
|
12
|
+
import { kendoSVGIcon } from '@memberjunction/ng-shared';
|
|
13
|
+
import * as i0 from "@angular/core";
|
|
14
|
+
import * as i1 from "@progress/kendo-angular-treeview";
|
|
15
|
+
export class CategoryTreeComponent {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.BottomMargin = 0;
|
|
18
|
+
this.isLoading = false;
|
|
19
|
+
this.kendoSVGIcon = kendoSVGIcon;
|
|
20
|
+
this.categoriesData = [];
|
|
21
|
+
}
|
|
22
|
+
ngOnInit() {
|
|
23
|
+
this.Refresh();
|
|
24
|
+
}
|
|
25
|
+
Refresh() {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
this.isLoading = true;
|
|
28
|
+
const rv = new RunView();
|
|
29
|
+
const result = yield rv.RunView({
|
|
30
|
+
EntityName: 'File Categories',
|
|
31
|
+
// ExtraFilter: `LEFT(Status, 1)<>'D'`, //'CategoryID=' + e.ID,
|
|
32
|
+
ResultType: 'entity_object',
|
|
33
|
+
});
|
|
34
|
+
if (result.Success) {
|
|
35
|
+
this.categoriesData = result.Results;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
throw new Error('Error loading file categories: ' + result.ErrorMessage);
|
|
39
|
+
}
|
|
40
|
+
this.isLoading = false;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
CategoryTreeComponent.ɵfac = function CategoryTreeComponent_Factory(t) { return new (t || CategoryTreeComponent)(); };
|
|
45
|
+
CategoryTreeComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: CategoryTreeComponent, selectors: [["mj-files-category-tree"]], inputs: { EntityName: "EntityName", BottomMargin: "BottomMargin" }, decls: 2, vars: 1, consts: [[1, "container"], ["textField", "Name", "kendoTreeViewExpandable", "", "kendoTreeViewFlatDataBinding", "", "idField", "ID", "parentIdField", "ParentID", 3, "nodes"]], template: function CategoryTreeComponent_Template(rf, ctx) { if (rf & 1) {
|
|
46
|
+
i0.ɵɵelementStart(0, "div", 0);
|
|
47
|
+
i0.ɵɵelement(1, "kendo-treeview", 1);
|
|
48
|
+
i0.ɵɵelementEnd();
|
|
49
|
+
} if (rf & 2) {
|
|
50
|
+
i0.ɵɵadvance();
|
|
51
|
+
i0.ɵɵproperty("nodes", ctx.categoriesData);
|
|
52
|
+
} }, dependencies: [i1.TreeViewComponent, i1.ExpandDirective, i1.FlatDataBindingDirective], styles: ["\n\r\n\r\nkendo-treeview[_ngcontent-%COMP%] {\r\n width: 250px;\r\n}"] });
|
|
53
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CategoryTreeComponent, [{
|
|
54
|
+
type: Component,
|
|
55
|
+
args: [{ selector: 'mj-files-category-tree', template: "<div class=\"container\">\r\n <kendo-treeview \r\n [nodes]=\"categoriesData\"\r\n textField=\"Name\"\r\n kendoTreeViewExpandable\r\n kendoTreeViewFlatDataBinding\r\n idField=\"ID\"\r\n parentIdField=\"ParentID\"\r\n ></kendo-treeview>\r\n</div>\r\n", styles: ["/* Styles for category tree */\r\n\r\nkendo-treeview {\r\n width: 250px;\r\n}"] }]
|
|
56
|
+
}], () => [], { EntityName: [{
|
|
57
|
+
type: Input
|
|
58
|
+
}], BottomMargin: [{
|
|
59
|
+
type: Input
|
|
60
|
+
}] }); })();
|
|
61
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(CategoryTreeComponent, { className: "CategoryTreeComponent", filePath: "src\\lib\\category-tree\\category-tree.ts", lineNumber: 13 }); })();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { EventEmitter, OnInit } from '@angular/core';
|
|
2
|
+
import { FileEntity } from '@memberjunction/core-entities';
|
|
3
|
+
import { kendoSVGIcon } from '@memberjunction/ng-shared';
|
|
4
|
+
import { FileInfo, SelectEvent } from '@progress/kendo-angular-upload';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
export type FileUploadEvent = {
|
|
7
|
+
success: true;
|
|
8
|
+
file: FileEntity;
|
|
9
|
+
} | {
|
|
10
|
+
success: false;
|
|
11
|
+
file: FileInfo;
|
|
12
|
+
};
|
|
13
|
+
export declare class FileUploadComponent implements OnInit {
|
|
14
|
+
kendoSVGIcon: typeof kendoSVGIcon;
|
|
15
|
+
isUploading: boolean;
|
|
16
|
+
private defaultProviderID;
|
|
17
|
+
private md;
|
|
18
|
+
constructor();
|
|
19
|
+
disabled: boolean;
|
|
20
|
+
uploadStarted: EventEmitter<void>;
|
|
21
|
+
fileUpload: EventEmitter<FileUploadEvent>;
|
|
22
|
+
ngOnInit(): void;
|
|
23
|
+
Refresh(): Promise<void>;
|
|
24
|
+
selectEventHandler(e: SelectEvent): Promise<void>;
|
|
25
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FileUploadComponent, never>;
|
|
26
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<FileUploadComponent, "mj-files-file-upload", never, { "disabled": { "alias": "disabled"; "required": false; }; }, { "uploadStarted": "uploadStarted"; "fileUpload": "fileUpload"; }, never, never, false, never>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=file-upload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-upload.d.ts","sourceRoot":"","sources":["../../../src/lib/file-upload/file-upload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,YAAY,EAAS,MAAM,EAAU,MAAM,eAAe,CAAC;AAE/E,OAAO,EAAE,UAAU,EAA6B,MAAM,+BAA+B,CAAC;AAGtF,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;;AAGvE,MAAM,MAAM,eAAe,GACvB;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GACnC;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAA;AAmDtC,qBAKa,mBAAoB,YAAW,MAAM;IACzC,YAAY,sBAAgB;IAC5B,WAAW,UAAS;IAC3B,OAAO,CAAC,iBAAiB,CAAM;IAC/B,OAAO,CAAC,EAAE,CAAkB;;IAInB,QAAQ,UAAS;IAChB,aAAa,qBAA4B;IACzC,UAAU,gCAAuC;IAE3D,QAAQ,IAAI,IAAI;IAIV,OAAO;IASP,kBAAkB,CAAC,CAAC,EAAE,WAAW;yCAzB5B,mBAAmB;2CAAnB,mBAAmB;CAiF/B"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
|
11
|
+
import { Metadata, RunView } from '@memberjunction/core';
|
|
12
|
+
import { GraphQLDataProvider, gql } from '@memberjunction/graphql-dataprovider';
|
|
13
|
+
import { kendoSVGIcon } from '@memberjunction/ng-shared';
|
|
14
|
+
import { z } from 'zod';
|
|
15
|
+
import * as i0 from "@angular/core";
|
|
16
|
+
import * as i1 from "@progress/kendo-angular-upload";
|
|
17
|
+
const FileFieldsFragment = gql `
|
|
18
|
+
fragment FileFields on File_ {
|
|
19
|
+
Category
|
|
20
|
+
CategoryID
|
|
21
|
+
ContentType
|
|
22
|
+
CreatedAt
|
|
23
|
+
Description
|
|
24
|
+
ID
|
|
25
|
+
Name
|
|
26
|
+
Provider
|
|
27
|
+
ProviderID
|
|
28
|
+
ProviderKey
|
|
29
|
+
Status
|
|
30
|
+
UpdatedAt
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
const FileUploadMutation = gql `
|
|
34
|
+
${FileFieldsFragment}
|
|
35
|
+
mutation CreateFile($input: CreateFileInput!) {
|
|
36
|
+
CreateFile(input: $input) {
|
|
37
|
+
UploadUrl
|
|
38
|
+
File {
|
|
39
|
+
...FileFields
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
const FileUploadMutationSchema = z.object({
|
|
45
|
+
CreateFile: z.object({
|
|
46
|
+
UploadUrl: z.string(),
|
|
47
|
+
File: z.object({
|
|
48
|
+
Category: z.string().nullish(),
|
|
49
|
+
CategoryID: z.number().nullish(),
|
|
50
|
+
ContentType: z.string().nullish(),
|
|
51
|
+
CreatedAt: z.number(),
|
|
52
|
+
Description: z.string().nullish(),
|
|
53
|
+
ID: z.number(),
|
|
54
|
+
Name: z.string(),
|
|
55
|
+
Provider: z.string(),
|
|
56
|
+
ProviderID: z.number(),
|
|
57
|
+
ProviderKey: z.string().nullish(),
|
|
58
|
+
Status: z.string(),
|
|
59
|
+
UpdatedAt: z.number(),
|
|
60
|
+
}),
|
|
61
|
+
}),
|
|
62
|
+
});
|
|
63
|
+
export class FileUploadComponent {
|
|
64
|
+
constructor() {
|
|
65
|
+
this.kendoSVGIcon = kendoSVGIcon;
|
|
66
|
+
this.isUploading = false;
|
|
67
|
+
this.defaultProviderID = -1;
|
|
68
|
+
this.md = new Metadata();
|
|
69
|
+
this.disabled = false;
|
|
70
|
+
this.uploadStarted = new EventEmitter();
|
|
71
|
+
this.fileUpload = new EventEmitter();
|
|
72
|
+
}
|
|
73
|
+
ngOnInit() {
|
|
74
|
+
this.Refresh();
|
|
75
|
+
}
|
|
76
|
+
Refresh() {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
const rv = new RunView();
|
|
79
|
+
const viewResults = yield rv.RunView({ EntityName: 'File Storage Providers' });
|
|
80
|
+
const provider = viewResults.Results[0];
|
|
81
|
+
if (typeof (provider === null || provider === void 0 ? void 0 : provider.ID) === 'number') {
|
|
82
|
+
this.defaultProviderID = provider.ID;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
selectEventHandler(e) {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
console.log('Files were selected', e);
|
|
90
|
+
this.isUploading = true;
|
|
91
|
+
// for each selected file to upload
|
|
92
|
+
for (const file of e.files) {
|
|
93
|
+
// call the gql
|
|
94
|
+
const result = yield GraphQLDataProvider.ExecuteGQL(FileUploadMutation, {
|
|
95
|
+
input: {
|
|
96
|
+
Name: file.name,
|
|
97
|
+
ProviderID: this.defaultProviderID,
|
|
98
|
+
Status: 'Pending',
|
|
99
|
+
// TODO: Get this from outside this component
|
|
100
|
+
// CategoryID
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
// make sure the response is correct
|
|
104
|
+
const parsedResult = FileUploadMutationSchema.safeParse(result);
|
|
105
|
+
if (parsedResult.success) {
|
|
106
|
+
const { File, UploadUrl } = parsedResult.data.CreateFile;
|
|
107
|
+
try {
|
|
108
|
+
console.log('type of ', typeof file);
|
|
109
|
+
// now upload to the url
|
|
110
|
+
yield window.fetch(UploadUrl, {
|
|
111
|
+
method: 'PUT',
|
|
112
|
+
headers: { 'x-ms-blob-type': 'BlockBlob' },
|
|
113
|
+
body: file.rawFile,
|
|
114
|
+
});
|
|
115
|
+
console.log('File uploaded', file);
|
|
116
|
+
// now update that file to set status
|
|
117
|
+
const fileEntity = yield this.md.GetEntityObject('Files');
|
|
118
|
+
yield fileEntity.LoadFromData(File);
|
|
119
|
+
fileEntity.Status = 'Uploaded';
|
|
120
|
+
yield fileEntity.Save();
|
|
121
|
+
// emit an event about a new file uploaded, include the file data
|
|
122
|
+
this.fileUpload.emit({ success: true, file: fileEntity });
|
|
123
|
+
// Could also emit a progress event with each iteration
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
console.error(e);
|
|
127
|
+
// something failed when actually uploading or when updating the API, what do to about pending file?
|
|
128
|
+
this.fileUpload.emit({ success: false, file });
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
console.error('The API returned an unexpected result', parsedResult.error);
|
|
133
|
+
this.fileUpload.emit({ success: false, file });
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
this.isUploading = false;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
FileUploadComponent.ɵfac = function FileUploadComponent_Factory(t) { return new (t || FileUploadComponent)(); };
|
|
141
|
+
FileUploadComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: FileUploadComponent, selectors: [["mj-files-file-upload"]], inputs: { disabled: "disabled" }, outputs: { uploadStarted: "uploadStarted", fileUpload: "fileUpload" }, decls: 1, vars: 2, consts: [[3, "disabled", "multiple", "select"]], template: function FileUploadComponent_Template(rf, ctx) { if (rf & 1) {
|
|
142
|
+
i0.ɵɵelementStart(0, "kendo-fileselect", 0);
|
|
143
|
+
i0.ɵɵlistener("select", function FileUploadComponent_Template_kendo_fileselect_select_0_listener($event) { return ctx.selectEventHandler($event); });
|
|
144
|
+
i0.ɵɵelementEnd();
|
|
145
|
+
} if (rf & 2) {
|
|
146
|
+
i0.ɵɵproperty("disabled", ctx.isUploading || ctx.disabled)("multiple", false);
|
|
147
|
+
} }, dependencies: [i1.FileSelectComponent] });
|
|
148
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FileUploadComponent, [{
|
|
149
|
+
type: Component,
|
|
150
|
+
args: [{ selector: 'mj-files-file-upload', template: "<kendo-fileselect [disabled]=\"isUploading || disabled\" [multiple]=\"false\" (select)=\"selectEventHandler($event)\"></kendo-fileselect>\r\n" }]
|
|
151
|
+
}], () => [], { disabled: [{
|
|
152
|
+
type: Input
|
|
153
|
+
}], uploadStarted: [{
|
|
154
|
+
type: Output
|
|
155
|
+
}], fileUpload: [{
|
|
156
|
+
type: Output
|
|
157
|
+
}] }); })();
|
|
158
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(FileUploadComponent, { className: "FileUploadComponent", filePath: "src\\lib\\file-upload\\file-upload.ts", lineNumber: 68 }); })();
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { OnInit } from '@angular/core';
|
|
2
|
+
import { FileEntity } from '@memberjunction/core-entities';
|
|
3
|
+
import { SharedService, kendoSVGIcon } from '@memberjunction/ng-shared';
|
|
4
|
+
import { FileUploadEvent } from '../file-upload/file-upload';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
export declare class FilesGridComponent implements OnInit {
|
|
7
|
+
private sharedService;
|
|
8
|
+
files: FileEntity[];
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
editFile: FileEntity | undefined;
|
|
11
|
+
kendoSVGIcon: typeof kendoSVGIcon;
|
|
12
|
+
constructor(sharedService: SharedService);
|
|
13
|
+
ngOnInit(): void;
|
|
14
|
+
resetEditFile(): void;
|
|
15
|
+
saveEditFile(): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Downloads a file using the provided FileEntity.
|
|
18
|
+
*
|
|
19
|
+
* @param file - The FileEntity representing the file to be downloaded.
|
|
20
|
+
* @returns Promise<void> - A promise that resolves when the file download is complete.
|
|
21
|
+
* @throws Error - If there is an error during the file download process.
|
|
22
|
+
*/
|
|
23
|
+
downloadFile: (file: FileEntity) => Promise<void>;
|
|
24
|
+
canBeDeleted(file: FileEntity): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Deletes a file using the provided FileEntity.
|
|
27
|
+
*
|
|
28
|
+
* @param file - The FileEntity representing the file to be deleted.
|
|
29
|
+
* @returns Promise<void> - A promise that resolves when the file deletion is complete.
|
|
30
|
+
* @throws Error - If there is an error during the file deletion process.
|
|
31
|
+
*/
|
|
32
|
+
deleteFile: (file: FileEntity) => Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Handles the file upload event, sending a notification in case of failure and otherwise adding
|
|
35
|
+
* the newly uploaded files to the files currently displayed.
|
|
36
|
+
*
|
|
37
|
+
* @param e - The file upload event.
|
|
38
|
+
*/
|
|
39
|
+
handleFileUpload(e: FileUploadEvent): void;
|
|
40
|
+
/**
|
|
41
|
+
* Refreshes the data by running a view and loading the files.
|
|
42
|
+
* @returns {Promise<void>} - A promise that resolves when the data is refreshed.
|
|
43
|
+
*/
|
|
44
|
+
Refresh(): Promise<void>;
|
|
45
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FilesGridComponent, never>;
|
|
46
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<FilesGridComponent, "mj-files-grid", never, {}, {}, never, never, false, never>;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=files-grid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files-grid.d.ts","sourceRoot":"","sources":["../../../src/lib/files-grid/files-grid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,MAAM,EAAE,MAAM,eAAe,CAAC;AAGlD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAExE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;;AAiD7D,qBAKa,kBAAmB,YAAW,MAAM;IAMnC,OAAO,CAAC,aAAa;IAL1B,KAAK,EAAE,UAAU,EAAE,CAAM;IACzB,SAAS,EAAE,OAAO,CAAS;IAC3B,QAAQ,EAAE,UAAU,GAAG,SAAS,CAAC;IACjC,YAAY,sBAAgB;gBAEf,aAAa,EAAE,aAAa;IAEhD,QAAQ,IAAI,IAAI;IAIT,aAAa;IAKP,YAAY;IAezB;;;;;;OAMG;IACI,YAAY,SAAgB,UAAU,mBAkB3C;IAEK,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO;IAO9C;;;;;;OAMG;IACI,UAAU,SAAgB,UAAU,mBAUzC;IAEF;;;;;OAKG;IACI,gBAAgB,CAAC,CAAC,EAAE,eAAe;IAU1C;;;OAGG;IACG,OAAO;yCAzGF,kBAAkB;2CAAlB,kBAAkB;CA0H9B"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { Component } from '@angular/core';
|
|
11
|
+
import { RunView } from '@memberjunction/core';
|
|
12
|
+
import { GraphQLDataProvider, gql } from '@memberjunction/graphql-dataprovider';
|
|
13
|
+
import { kendoSVGIcon } from '@memberjunction/ng-shared';
|
|
14
|
+
import { z } from 'zod';
|
|
15
|
+
import * as i0 from "@angular/core";
|
|
16
|
+
import * as i1 from "@memberjunction/ng-shared";
|
|
17
|
+
import * as i2 from "@angular/common";
|
|
18
|
+
import * as i3 from "@angular/forms";
|
|
19
|
+
import * as i4 from "@progress/kendo-angular-dialog";
|
|
20
|
+
import * as i5 from "@progress/kendo-angular-buttons";
|
|
21
|
+
import * as i6 from "@progress/kendo-angular-label";
|
|
22
|
+
import * as i7 from "@progress/kendo-angular-grid";
|
|
23
|
+
import * as i8 from "@progress/kendo-angular-inputs";
|
|
24
|
+
import * as i9 from "../file-upload/file-upload";
|
|
25
|
+
function FilesGridComponent_ng_template_7_Template(rf, ctx) { if (rf & 1) {
|
|
26
|
+
const _r4 = i0.ɵɵgetCurrentView();
|
|
27
|
+
i0.ɵɵelementStart(0, "kendo-button", 10);
|
|
28
|
+
i0.ɵɵlistener("click", function FilesGridComponent_ng_template_7_Template_kendo_button_click_0_listener() { const restoredCtx = i0.ɵɵrestoreView(_r4); const dataItem_r2 = restoredCtx.$implicit; const ctx_r3 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r3.downloadFile(dataItem_r2)); });
|
|
29
|
+
i0.ɵɵelementEnd();
|
|
30
|
+
i0.ɵɵelementStart(1, "kendo-button", 10);
|
|
31
|
+
i0.ɵɵlistener("click", function FilesGridComponent_ng_template_7_Template_kendo_button_click_1_listener() { const restoredCtx = i0.ɵɵrestoreView(_r4); const dataItem_r2 = restoredCtx.$implicit; const ctx_r5 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r5.deleteFile(dataItem_r2)); });
|
|
32
|
+
i0.ɵɵelementEnd();
|
|
33
|
+
i0.ɵɵelementStart(2, "kendo-button", 10);
|
|
34
|
+
i0.ɵɵlistener("click", function FilesGridComponent_ng_template_7_Template_kendo_button_click_2_listener() { const restoredCtx = i0.ɵɵrestoreView(_r4); const dataItem_r2 = restoredCtx.$implicit; const ctx_r6 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r6.editFile = dataItem_r2); });
|
|
35
|
+
i0.ɵɵelementEnd();
|
|
36
|
+
} if (rf & 2) {
|
|
37
|
+
const dataItem_r2 = ctx.$implicit;
|
|
38
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
39
|
+
i0.ɵɵproperty("disabled", dataItem_r2.Status !== "Uploaded")("svgIcon", ctx_r0.kendoSVGIcon("download"));
|
|
40
|
+
i0.ɵɵadvance();
|
|
41
|
+
i0.ɵɵproperty("disabled", !ctx_r0.canBeDeleted(dataItem_r2))("svgIcon", ctx_r0.kendoSVGIcon("trash"));
|
|
42
|
+
i0.ɵɵadvance();
|
|
43
|
+
i0.ɵɵproperty("disabled", dataItem_r2.Status !== "Uploaded")("svgIcon", ctx_r0.kendoSVGIcon("pencil"));
|
|
44
|
+
} }
|
|
45
|
+
function FilesGridComponent_kendo_dialog_9_Template(rf, ctx) { if (rf & 1) {
|
|
46
|
+
const _r9 = i0.ɵɵgetCurrentView();
|
|
47
|
+
i0.ɵɵelementStart(0, "kendo-dialog", 11);
|
|
48
|
+
i0.ɵɵlistener("close", function FilesGridComponent_kendo_dialog_9_Template_kendo_dialog_close_0_listener() { i0.ɵɵrestoreView(_r9); const ctx_r8 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r8.resetEditFile()); });
|
|
49
|
+
i0.ɵɵelementStart(1, "div", 0)(2, "form", null, 12)(4, "kendo-label", 13)(5, "kendo-textbox", 14);
|
|
50
|
+
i0.ɵɵtwoWayListener("ngModelChange", function FilesGridComponent_kendo_dialog_9_Template_kendo_textbox_ngModelChange_5_listener($event) { i0.ɵɵrestoreView(_r9); const ctx_r10 = i0.ɵɵnextContext(); i0.ɵɵtwoWayBindingSet(ctx_r10.editFile.Name, $event) || (ctx_r10.editFile.Name = $event); return i0.ɵɵresetView($event); });
|
|
51
|
+
i0.ɵɵelementEnd()();
|
|
52
|
+
i0.ɵɵelementStart(6, "kendo-label", 15)(7, "kendo-textbox", 16);
|
|
53
|
+
i0.ɵɵtwoWayListener("ngModelChange", function FilesGridComponent_kendo_dialog_9_Template_kendo_textbox_ngModelChange_7_listener($event) { i0.ɵɵrestoreView(_r9); const ctx_r11 = i0.ɵɵnextContext(); i0.ɵɵtwoWayBindingSet(ctx_r11.editFile.Description, $event) || (ctx_r11.editFile.Description = $event); return i0.ɵɵresetView($event); });
|
|
54
|
+
i0.ɵɵelementEnd()()()();
|
|
55
|
+
i0.ɵɵelementStart(8, "kendo-dialog-actions")(9, "button", 17);
|
|
56
|
+
i0.ɵɵlistener("click", function FilesGridComponent_kendo_dialog_9_Template_button_click_9_listener() { i0.ɵɵrestoreView(_r9); const ctx_r12 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r12.resetEditFile()); });
|
|
57
|
+
i0.ɵɵtext(10, "Cancel");
|
|
58
|
+
i0.ɵɵelementEnd();
|
|
59
|
+
i0.ɵɵelementStart(11, "button", 18);
|
|
60
|
+
i0.ɵɵlistener("click", function FilesGridComponent_kendo_dialog_9_Template_button_click_11_listener() { i0.ɵɵrestoreView(_r9); const ctx_r13 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r13.saveEditFile()); });
|
|
61
|
+
i0.ɵɵtext(12, " Save ");
|
|
62
|
+
i0.ɵɵelementEnd()()();
|
|
63
|
+
} if (rf & 2) {
|
|
64
|
+
const ctx_r1 = i0.ɵɵnextContext();
|
|
65
|
+
i0.ɵɵproperty("minWidth", 250)("width", 450);
|
|
66
|
+
i0.ɵɵadvance(5);
|
|
67
|
+
i0.ɵɵtwoWayProperty("ngModel", ctx_r1.editFile.Name);
|
|
68
|
+
i0.ɵɵproperty("showSuccessIcon", ctx_r1.editFile.Name.length > 0);
|
|
69
|
+
i0.ɵɵadvance(2);
|
|
70
|
+
i0.ɵɵtwoWayProperty("ngModel", ctx_r1.editFile.Description);
|
|
71
|
+
} }
|
|
72
|
+
/**
|
|
73
|
+
* Downloads a file from the provided URL.
|
|
74
|
+
*
|
|
75
|
+
* @param url - The URL of the file to be downloaded.
|
|
76
|
+
* @param fileName - The name to be given to the downloaded file.
|
|
77
|
+
* @param contentType - The content type of the file. Defaults to 'application/octet-stream'.
|
|
78
|
+
* @returns Promise<void> - A promise that resolves when the file download is complete.
|
|
79
|
+
*/
|
|
80
|
+
const downloadFromUrl = (url, fileName, contentType) => __awaiter(void 0, void 0, void 0, function* () {
|
|
81
|
+
var _a;
|
|
82
|
+
// First, fetch the data and create a blob with the correct content type
|
|
83
|
+
const response = yield fetch(url);
|
|
84
|
+
if (!response.ok) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
const rawBlob = yield response.blob();
|
|
88
|
+
const blob = new Blob([rawBlob], { type: contentType || 'application/octet-stream' });
|
|
89
|
+
// Then add a temporary link to the document and click it
|
|
90
|
+
const link = document.createElement('a');
|
|
91
|
+
const blobUrl = window.URL.createObjectURL(blob);
|
|
92
|
+
link.href = blobUrl;
|
|
93
|
+
link.setAttribute('download', fileName);
|
|
94
|
+
document.body.appendChild(link);
|
|
95
|
+
link.click();
|
|
96
|
+
(_a = link.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(link);
|
|
97
|
+
window.URL.revokeObjectURL(blobUrl);
|
|
98
|
+
return true;
|
|
99
|
+
});
|
|
100
|
+
const FileDownloadQuery = gql `
|
|
101
|
+
query FileDownloadUrl($FileID: Int!) {
|
|
102
|
+
File(ID: $FileID) {
|
|
103
|
+
ContentType
|
|
104
|
+
DownloadUrl
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
`;
|
|
108
|
+
const FileDownloadQuerySchema = z.object({
|
|
109
|
+
File: z.object({
|
|
110
|
+
ContentType: z.string().optional(),
|
|
111
|
+
DownloadUrl: z.string(),
|
|
112
|
+
}),
|
|
113
|
+
});
|
|
114
|
+
export class FilesGridComponent {
|
|
115
|
+
constructor(sharedService) {
|
|
116
|
+
this.sharedService = sharedService;
|
|
117
|
+
this.files = [];
|
|
118
|
+
this.isLoading = false;
|
|
119
|
+
this.kendoSVGIcon = kendoSVGIcon;
|
|
120
|
+
/**
|
|
121
|
+
* Downloads a file using the provided FileEntity.
|
|
122
|
+
*
|
|
123
|
+
* @param file - The FileEntity representing the file to be downloaded.
|
|
124
|
+
* @returns Promise<void> - A promise that resolves when the file download is complete.
|
|
125
|
+
* @throws Error - If there is an error during the file download process.
|
|
126
|
+
*/
|
|
127
|
+
this.downloadFile = (file) => __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
this.isLoading = true;
|
|
129
|
+
const result = yield GraphQLDataProvider.ExecuteGQL(FileDownloadQuery, {
|
|
130
|
+
FileID: file.ID,
|
|
131
|
+
});
|
|
132
|
+
const parsedResult = FileDownloadQuerySchema.safeParse(result);
|
|
133
|
+
if (parsedResult.success) {
|
|
134
|
+
const downloadUrl = parsedResult.data.File.DownloadUrl;
|
|
135
|
+
const success = downloadFromUrl(downloadUrl, file.Name, file.ContentType);
|
|
136
|
+
if (!success) {
|
|
137
|
+
this.sharedService.CreateSimpleNotification(`Unable to download file ${file.ID} ${file.Name}`, 'error');
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
console.error(parsedResult.error);
|
|
142
|
+
this.sharedService.CreateSimpleNotification(`Unable to download file ${file.ID} ${file.Name}`, 'error');
|
|
143
|
+
}
|
|
144
|
+
this.isLoading = false;
|
|
145
|
+
});
|
|
146
|
+
/**
|
|
147
|
+
* Deletes a file using the provided FileEntity.
|
|
148
|
+
*
|
|
149
|
+
* @param file - The FileEntity representing the file to be deleted.
|
|
150
|
+
* @returns Promise<void> - A promise that resolves when the file deletion is complete.
|
|
151
|
+
* @throws Error - If there is an error during the file deletion process.
|
|
152
|
+
*/
|
|
153
|
+
this.deleteFile = (file) => __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
this.isLoading = true;
|
|
155
|
+
let deleteResult = yield file.Delete();
|
|
156
|
+
if (deleteResult) {
|
|
157
|
+
this.sharedService.CreateSimpleNotification(`Successfully deleted file ${file.ID} ${file.Name}`, 'info');
|
|
158
|
+
this.files = this.files.filter((f) => f.ID != file.ID);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
this.sharedService.CreateSimpleNotification(`Unable to delete file ${file.ID} ${file.Name}`, 'error');
|
|
162
|
+
}
|
|
163
|
+
this.isLoading = false;
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
ngOnInit() {
|
|
167
|
+
this.Refresh();
|
|
168
|
+
}
|
|
169
|
+
resetEditFile() {
|
|
170
|
+
var _a;
|
|
171
|
+
(_a = this.editFile) === null || _a === void 0 ? void 0 : _a.Revert();
|
|
172
|
+
this.editFile = undefined;
|
|
173
|
+
}
|
|
174
|
+
saveEditFile() {
|
|
175
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
176
|
+
if (this.editFile) {
|
|
177
|
+
this.isLoading = true;
|
|
178
|
+
//
|
|
179
|
+
const success = yield this.editFile.Save();
|
|
180
|
+
if (success) {
|
|
181
|
+
this.sharedService.CreateSimpleNotification(`Successfully saved file ${this.editFile.ID} ${this.editFile.Name}`, 'success');
|
|
182
|
+
this.editFile = undefined;
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
this.sharedService.CreateSimpleNotification(`Unable to save file ${this.editFile.ID} ${this.editFile.Name}`, 'error');
|
|
186
|
+
}
|
|
187
|
+
this.isLoading = false;
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
canBeDeleted(file) {
|
|
192
|
+
const status = file.Status;
|
|
193
|
+
const deletable = status === 'Uploaded' || Date.now() - +file.CreatedAt > 10 * 60 * 60;
|
|
194
|
+
console.log({ status, deletable, ID: file.ID, CreatedAt: file.CreatedAt });
|
|
195
|
+
return deletable;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Handles the file upload event, sending a notification in case of failure and otherwise adding
|
|
199
|
+
* the newly uploaded files to the files currently displayed.
|
|
200
|
+
*
|
|
201
|
+
* @param e - The file upload event.
|
|
202
|
+
*/
|
|
203
|
+
handleFileUpload(e) {
|
|
204
|
+
if (!e.success) {
|
|
205
|
+
this.sharedService.CreateSimpleNotification(`Unable to upload file '${e.file.name}'`, 'error');
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
this.files.push(e.file);
|
|
209
|
+
this.isLoading = false;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Refreshes the data by running a view and loading the files.
|
|
213
|
+
* @returns {Promise<void>} - A promise that resolves when the data is refreshed.
|
|
214
|
+
*/
|
|
215
|
+
Refresh() {
|
|
216
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
217
|
+
this.isLoading = true;
|
|
218
|
+
const rv = new RunView();
|
|
219
|
+
const result = yield rv.RunView({
|
|
220
|
+
EntityName: 'Files',
|
|
221
|
+
// TODO: Apply the category filter here
|
|
222
|
+
// ExtraFilter: `LEFT(Status, 1)<>'D'`, //'CategoryID=' + e.ID,
|
|
223
|
+
ResultType: 'entity_object',
|
|
224
|
+
});
|
|
225
|
+
if (result.Success) {
|
|
226
|
+
this.files = result.Results;
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
throw new Error('Error loading files: ' + result.ErrorMessage);
|
|
230
|
+
}
|
|
231
|
+
this.isLoading = false;
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
FilesGridComponent.ɵfac = function FilesGridComponent_Factory(t) { return new (t || FilesGridComponent)(i0.ɵɵdirectiveInject(i1.SharedService)); };
|
|
236
|
+
FilesGridComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: FilesGridComponent, selectors: [["mj-files-grid"]], decls: 10, vars: 4, consts: [[1, "container"], [3, "data", "loading"], ["field", "ID", "title", "ID"], ["field", "Name", "title", "Name"], ["field", "Description", "title", "Description"], ["field", "Status", "title", "Status"], ["field", "Actions"], ["kendoGridCellTemplate", ""], [3, "disabled", "uploadStarted", "fileUpload"], ["title", "Please confirm", 3, "minWidth", "width", "close", 4, "ngIf"], [3, "disabled", "svgIcon", "click"], ["title", "Please confirm", 3, "minWidth", "width", "close"], ["templateForm", "ngForm"], ["text", "Name", 1, "k-form"], ["name", "name", "showErrorIcon", "initial", "required", "", 3, "ngModel", "showSuccessIcon", "ngModelChange"], ["text", "Description", 1, "k-form"], ["name", "description", 3, "ngModel", "ngModelChange"], ["kendoButton", "", 3, "click"], ["kendoButton", "", "themeColor", "primary", 3, "click"]], template: function FilesGridComponent_Template(rf, ctx) { if (rf & 1) {
|
|
237
|
+
i0.ɵɵelementStart(0, "div", 0)(1, "kendo-grid", 1);
|
|
238
|
+
i0.ɵɵelement(2, "kendo-grid-column", 2)(3, "kendo-grid-column", 3)(4, "kendo-grid-column", 4)(5, "kendo-grid-column", 5);
|
|
239
|
+
i0.ɵɵelementStart(6, "kendo-grid-column", 6);
|
|
240
|
+
i0.ɵɵtemplate(7, FilesGridComponent_ng_template_7_Template, 3, 6, "ng-template", 7);
|
|
241
|
+
i0.ɵɵelementEnd()();
|
|
242
|
+
i0.ɵɵelementStart(8, "mj-files-file-upload", 8);
|
|
243
|
+
i0.ɵɵlistener("uploadStarted", function FilesGridComponent_Template_mj_files_file_upload_uploadStarted_8_listener() { return ctx.isLoading = true; })("fileUpload", function FilesGridComponent_Template_mj_files_file_upload_fileUpload_8_listener($event) { return ctx.handleFileUpload($event); });
|
|
244
|
+
i0.ɵɵelementEnd();
|
|
245
|
+
i0.ɵɵtemplate(9, FilesGridComponent_kendo_dialog_9_Template, 13, 5, "kendo-dialog", 9);
|
|
246
|
+
i0.ɵɵelementEnd();
|
|
247
|
+
} if (rf & 2) {
|
|
248
|
+
i0.ɵɵadvance();
|
|
249
|
+
i0.ɵɵproperty("data", ctx.files)("loading", ctx.isLoading);
|
|
250
|
+
i0.ɵɵadvance(7);
|
|
251
|
+
i0.ɵɵproperty("disabled", ctx.isLoading);
|
|
252
|
+
i0.ɵɵadvance();
|
|
253
|
+
i0.ɵɵproperty("ngIf", ctx.editFile);
|
|
254
|
+
} }, dependencies: [i2.NgIf, i3.ɵNgNoValidate, i3.NgControlStatus, i3.NgControlStatusGroup, i3.RequiredValidator, i3.NgModel, i3.NgForm, i4.DialogComponent, i4.DialogActionsComponent, i5.ButtonComponent, i6.LabelComponent, i7.GridComponent, i7.ColumnComponent, i7.CellTemplateDirective, i8.TextBoxComponent, i9.FileUploadComponent], styles: [".container[_ngcontent-%COMP%] {\r\n display: flex;\r\n flex-direction: column;\r\n}\r\n\r\nkendo-label[_ngcontent-%COMP%] {\r\n display: flex;\r\n flex-direction: row;\r\n align-items: center;\r\n column-gap: 12px;\r\n margin-bottom: 4px;\r\n}\r\n\r\nkendo-label[_ngcontent-%COMP%] kendo-textbox[_ngcontent-%COMP%] {\r\n width: 100%;\r\n}"] });
|
|
255
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FilesGridComponent, [{
|
|
256
|
+
type: Component,
|
|
257
|
+
args: [{ selector: 'mj-files-grid', template: "<div class=\"container\">\r\n <kendo-grid [data]=\"files\" [loading]=\"isLoading\">\r\n <kendo-grid-column field=\"ID\" title=\"ID\"> </kendo-grid-column>\r\n <kendo-grid-column field=\"Name\" title=\"Name\"> </kendo-grid-column>\r\n <kendo-grid-column field=\"Description\" title=\"Description\">\r\n </kendo-grid-column>\r\n <kendo-grid-column field=\"Status\" title=\"Status\"> </kendo-grid-column>\r\n <kendo-grid-column field=\"Actions\">\r\n <ng-template kendoGridCellTemplate let-dataItem>\r\n <kendo-button [disabled]=\"dataItem.Status!=='Uploaded'\" [svgIcon]=\"kendoSVGIcon('download')\" (click)=\"downloadFile(dataItem)\"></kendo-button>\r\n <kendo-button [disabled]=\"!canBeDeleted(dataItem)\" [svgIcon]=\"kendoSVGIcon('trash')\" (click)=\"deleteFile(dataItem)\"></kendo-button>\r\n <kendo-button [disabled]=\"dataItem.Status!=='Uploaded'\" [svgIcon]=\"kendoSVGIcon('pencil')\" (click)=\"editFile = dataItem\"></kendo-button>\r\n </ng-template>\r\n </kendo-grid-column> \r\n </kendo-grid>\r\n\r\n <mj-files-file-upload [disabled]=\"isLoading\" (uploadStarted)=\"isLoading = true\" (fileUpload)=\"handleFileUpload($event)\"></mj-files-file-upload>\r\n\r\n <kendo-dialog\r\n title=\"Please confirm\"\r\n *ngIf=\"editFile\"\r\n (close)=\"resetEditFile()\"\r\n [minWidth]=\"250\"\r\n [width]=\"450\"\r\n >\r\n <div class=\"container\">\r\n <form #templateForm=\"ngForm\">\r\n <kendo-label class=\"k-form\" text=\"Name\">\r\n <kendo-textbox\r\n name=\"name\"\r\n [(ngModel)]=\"editFile.Name\"\r\n [showSuccessIcon]=\"editFile.Name.length > 0\"\r\n showErrorIcon=\"initial\"\r\n required\r\n ></kendo-textbox>\r\n </kendo-label>\r\n <kendo-label class=\"k-form\" text=\"Description\">\r\n <kendo-textbox\r\n name=\"description\"\r\n [(ngModel)]=\"editFile.Description\"\r\n ></kendo-textbox>\r\n </kendo-label>\r\n </form>\r\n </div>\r\n <kendo-dialog-actions>\r\n <button kendoButton (click)=\"resetEditFile()\">Cancel</button>\r\n <button kendoButton (click)=\"saveEditFile()\" themeColor=\"primary\">\r\n Save\r\n </button>\r\n </kendo-dialog-actions>\r\n </kendo-dialog>\r\n</div>\r\n", styles: [".container {\r\n display: flex;\r\n flex-direction: column;\r\n}\r\n\r\nkendo-label {\r\n display: flex;\r\n flex-direction: row;\r\n align-items: center;\r\n column-gap: 12px;\r\n margin-bottom: 4px;\r\n}\r\n\r\nkendo-label kendo-textbox {\r\n width: 100%;\r\n}"] }]
|
|
258
|
+
}], () => [{ type: i1.SharedService }], null); })();
|
|
259
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(FilesGridComponent, { className: "FilesGridComponent", filePath: "src\\lib\\files-grid\\files-grid.ts", lineNumber: 62 }); })();
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import * as i1 from "./category-tree/category-tree";
|
|
3
|
+
import * as i2 from "./files-grid/files-grid";
|
|
4
|
+
import * as i3 from "./file-upload/file-upload";
|
|
5
|
+
import * as i4 from "@angular/common";
|
|
6
|
+
import * as i5 from "@progress/kendo-angular-treeview";
|
|
7
|
+
import * as i6 from "@angular/forms";
|
|
8
|
+
import * as i7 from "@progress/kendo-angular-dialog";
|
|
9
|
+
import * as i8 from "@progress/kendo-angular-excel-export";
|
|
10
|
+
import * as i9 from "@memberjunction/ng-compare-records";
|
|
11
|
+
import * as i10 from "@memberjunction/ng-container-directives";
|
|
12
|
+
import * as i11 from "@progress/kendo-angular-buttons";
|
|
13
|
+
import * as i12 from "@progress/kendo-angular-icons";
|
|
14
|
+
import * as i13 from "@progress/kendo-angular-label";
|
|
15
|
+
import * as i14 from "@progress/kendo-angular-grid";
|
|
16
|
+
import * as i15 from "@progress/kendo-angular-dropdowns";
|
|
17
|
+
import * as i16 from "@angular/platform-browser";
|
|
18
|
+
import * as i17 from "@angular/platform-browser/animations";
|
|
19
|
+
import * as i18 from "@progress/kendo-angular-inputs";
|
|
20
|
+
import * as i19 from "@progress/kendo-angular-upload";
|
|
21
|
+
export declare class FileStorageModule {
|
|
22
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FileStorageModule, never>;
|
|
23
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<FileStorageModule, [typeof i1.CategoryTreeComponent, typeof i2.FilesGridComponent, typeof i3.FileUploadComponent], [typeof i4.CommonModule, typeof i5.TreeViewModule, typeof i6.FormsModule, typeof i7.DialogsModule, typeof i8.ExcelExportModule, typeof i9.CompareRecordsModule, typeof i10.ContainerDirectivesModule, typeof i11.ButtonsModule, typeof i12.IconsModule, typeof i13.LabelModule, typeof i14.GridModule, typeof i15.DropDownsModule, typeof i16.BrowserModule, typeof i17.BrowserAnimationsModule, typeof i18.InputsModule, typeof i19.UploadsModule], [typeof i1.CategoryTreeComponent, typeof i2.FilesGridComponent]>;
|
|
24
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<FileStorageModule>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/lib/module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAyBA,qBAsBa,iBAAiB;yCAAjB,iBAAiB;0CAAjB,iBAAiB;0CAAjB,iBAAiB;CAAG"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { NgModule } from '@angular/core';
|
|
3
|
+
// Kendo UI Angular imports
|
|
4
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
5
|
+
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|
6
|
+
import { ButtonsModule } from '@progress/kendo-angular-buttons';
|
|
7
|
+
import { DialogsModule } from "@progress/kendo-angular-dialog";
|
|
8
|
+
import { ExcelExportModule } from '@progress/kendo-angular-excel-export';
|
|
9
|
+
import { GridModule } from '@progress/kendo-angular-grid';
|
|
10
|
+
import { IconsModule } from '@progress/kendo-angular-icons';
|
|
11
|
+
import { InputsModule } from '@progress/kendo-angular-inputs';
|
|
12
|
+
import { LabelModule } from '@progress/kendo-angular-label';
|
|
13
|
+
import { TreeViewModule } from '@progress/kendo-angular-treeview';
|
|
14
|
+
import { FormsModule } from '@angular/forms';
|
|
15
|
+
import { CompareRecordsModule } from '@memberjunction/ng-compare-records';
|
|
16
|
+
import { ContainerDirectivesModule } from '@memberjunction/ng-container-directives';
|
|
17
|
+
import { DropDownsModule } from '@progress/kendo-angular-dropdowns';
|
|
18
|
+
import { UploadsModule } from '@progress/kendo-angular-upload';
|
|
19
|
+
import { CategoryTreeComponent } from './category-tree/category-tree';
|
|
20
|
+
import { FileUploadComponent } from './file-upload/file-upload';
|
|
21
|
+
import { FilesGridComponent } from './files-grid/files-grid';
|
|
22
|
+
import * as i0 from "@angular/core";
|
|
23
|
+
export class FileStorageModule {
|
|
24
|
+
}
|
|
25
|
+
FileStorageModule.ɵfac = function FileStorageModule_Factory(t) { return new (t || FileStorageModule)(); };
|
|
26
|
+
FileStorageModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: FileStorageModule });
|
|
27
|
+
FileStorageModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
|
|
28
|
+
TreeViewModule,
|
|
29
|
+
FormsModule,
|
|
30
|
+
DialogsModule,
|
|
31
|
+
ExcelExportModule,
|
|
32
|
+
CompareRecordsModule,
|
|
33
|
+
ContainerDirectivesModule,
|
|
34
|
+
ButtonsModule,
|
|
35
|
+
IconsModule,
|
|
36
|
+
LabelModule,
|
|
37
|
+
GridModule,
|
|
38
|
+
DropDownsModule,
|
|
39
|
+
BrowserModule,
|
|
40
|
+
BrowserAnimationsModule,
|
|
41
|
+
InputsModule,
|
|
42
|
+
UploadsModule] });
|
|
43
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FileStorageModule, [{
|
|
44
|
+
type: NgModule,
|
|
45
|
+
args: [{
|
|
46
|
+
declarations: [CategoryTreeComponent, FilesGridComponent, FileUploadComponent],
|
|
47
|
+
imports: [
|
|
48
|
+
CommonModule,
|
|
49
|
+
TreeViewModule,
|
|
50
|
+
FormsModule,
|
|
51
|
+
DialogsModule,
|
|
52
|
+
ExcelExportModule,
|
|
53
|
+
CompareRecordsModule,
|
|
54
|
+
ContainerDirectivesModule,
|
|
55
|
+
ButtonsModule,
|
|
56
|
+
IconsModule,
|
|
57
|
+
LabelModule,
|
|
58
|
+
GridModule,
|
|
59
|
+
DropDownsModule,
|
|
60
|
+
BrowserModule,
|
|
61
|
+
BrowserAnimationsModule,
|
|
62
|
+
InputsModule,
|
|
63
|
+
UploadsModule,
|
|
64
|
+
],
|
|
65
|
+
exports: [CategoryTreeComponent, FilesGridComponent],
|
|
66
|
+
}]
|
|
67
|
+
}], null, null); })();
|
|
68
|
+
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(FileStorageModule, { declarations: [CategoryTreeComponent, FilesGridComponent, FileUploadComponent], imports: [CommonModule,
|
|
69
|
+
TreeViewModule,
|
|
70
|
+
FormsModule,
|
|
71
|
+
DialogsModule,
|
|
72
|
+
ExcelExportModule,
|
|
73
|
+
CompareRecordsModule,
|
|
74
|
+
ContainerDirectivesModule,
|
|
75
|
+
ButtonsModule,
|
|
76
|
+
IconsModule,
|
|
77
|
+
LabelModule,
|
|
78
|
+
GridModule,
|
|
79
|
+
DropDownsModule,
|
|
80
|
+
BrowserModule,
|
|
81
|
+
BrowserAnimationsModule,
|
|
82
|
+
InputsModule,
|
|
83
|
+
UploadsModule], exports: [CategoryTreeComponent, FilesGridComponent] }); })();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAIA,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,cAAc,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@memberjunction/ng-file-storage",
|
|
3
|
+
"version": "0.9.3",
|
|
4
|
+
"description": "MemberJunction: Angular components for managing files, and related components.",
|
|
5
|
+
"main": "./dist/public-api.js",
|
|
6
|
+
"typings": "./dist/public-api.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"/dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
12
|
+
"build": "ngc",
|
|
13
|
+
"watch": "ngc -w"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [],
|
|
16
|
+
"author": "",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@angular/compiler": "~17.2.2",
|
|
20
|
+
"@angular/compiler-cli": "~17.2.2"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"@angular/common": "~17.2.2",
|
|
24
|
+
"@angular/core": "~17.2.2",
|
|
25
|
+
"@angular/forms": "~17.2.2",
|
|
26
|
+
"@angular/router": "~17.2.2"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@memberjunction/core": "^0.9.174",
|
|
30
|
+
"@memberjunction/core-entities": "^0.9.159",
|
|
31
|
+
"@memberjunction/global": "^0.9.155",
|
|
32
|
+
"@memberjunction/ng-container-directives": "^0.9.138",
|
|
33
|
+
"@memberjunction/ng-shared": "^0.9.28",
|
|
34
|
+
"@progress/kendo-angular-buttons": "~15.1.0",
|
|
35
|
+
"@progress/kendo-angular-dialog": "~15.1.0",
|
|
36
|
+
"@progress/kendo-angular-dropdowns": "~15.1.0",
|
|
37
|
+
"@progress/kendo-angular-grid": "~15.1.0",
|
|
38
|
+
"@progress/kendo-angular-treeview": "~15.1.0",
|
|
39
|
+
"@progress/kendo-angular-upload": "~15.1.0",
|
|
40
|
+
"tslib": "^2.3.0",
|
|
41
|
+
"zod": "^3.22.4"
|
|
42
|
+
},
|
|
43
|
+
"sideEffects": false
|
|
44
|
+
}
|