@memberjunction/ng-file-storage 5.48.0 → 5.49.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.
@@ -1 +1 @@
1
- {"version":3,"file":"files-grid.d.ts","sourceRoot":"","sources":["../../../src/lib/files-grid/files-grid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnF,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EACL,MAAM,EACN,cAAc,EAMd,KAAK,KAAK,EAEX,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;;AAmD7D,qBAMa,kBAAmB,YAAW,MAAM,EAAE,SAAS;IAe9C,OAAO,CAAC,aAAa;IAd1B,KAAK,EAAE,YAAY,EAAE,CAAM;IAC3B,SAAS,EAAE,OAAO,CAAS;IAC3B,QAAQ,EAAE,YAAY,GAAG,SAAS,CAAC;IAGnC,SAAS,EAAE,KAAK,CAA6C;IAC7D,UAAU,EAAE,MAAM,EAAE,CAAM;IAC1B,aAAa,EAAE,MAAM,CAI1B;IACF,OAAO,CAAC,OAAO,CAAwB;gBAEnB,aAAa,EAAE,aAAa;IAIvC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAa;IAEpD,QAAQ,IAAI,IAAI;IAIhB,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAMlC,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAI/C;;;;;;OAMG;IACI,aAAa;IAKpB;;;;;;;OAOG;IACU,YAAY;IAmBzB;;;;;;OAMG;IACI,YAAY,GAAU,MAAM,YAAY,mBAkB7C;IAEF;;;;;OAKG;IACI,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO;IAMhD;;;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;OAMG;IACI,YAAY,GAAU,MAAM,YAAY,mBAkB7C;IAEF;;;;;OAKG;IACI,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO;IAMhD;;;;;;OAMG;IACI,UAAU,GAAU,MAAM,YAAY,mBAY3C;IAEF;;;;;OAKG;IACI,gBAAgB,CAAC,CAAC,EAAE,eAAe;IAW1C;;;OAGG;IACG,OAAO;IAiBb;;OAEG;IACH,OAAO,CAAC,eAAe;IAmCvB;;OAEG;IACH,OAAO,CAAC,kBAAkB;yCAvNf,kBAAkB;2CAAlB,kBAAkB;CAgO9B"}
@@ -1,7 +1,8 @@
1
1
  import { Component, Input } from '@angular/core';
2
2
  import { RunView } from '@memberjunction/core';
3
3
  import { GraphQLDataProvider, gql } from '@memberjunction/graphql-dataprovider';
4
- import { ModuleRegistry, AllCommunityModule, themeAlpine, colorSchemeVariable } from 'ag-grid-community';
4
+ import { MJ_AG_GRID_THEME_PARAMS } from '@memberjunction/ng-shared-generic';
5
+ import { ModuleRegistry, AllCommunityModule, themeAlpine } from 'ag-grid-community';
5
6
  import { z } from 'zod';
6
7
  import * as i0 from "@angular/core";
7
8
  import * as i1 from "@memberjunction/ng-shared";
@@ -87,7 +88,9 @@ export class FilesGridComponent {
87
88
  isLoading = false;
88
89
  editFile;
89
90
  // AG Grid configuration
90
- GridTheme = themeAlpine.withPart(colorSchemeVariable);
91
+ // Themed from the shared --mj-* token params so this grid follows light/dark and
92
+ // the org brand overlay, matching the main entity/query grids.
93
+ GridTheme = themeAlpine.withParams(MJ_AG_GRID_THEME_PARAMS);
91
94
  ColumnDefs = [];
92
95
  DefaultColDef = {
93
96
  sortable: true,
@@ -1 +1 @@
1
- {"version":3,"file":"files-grid.js","sourceRoot":"","sources":["../../../src/lib/files-grid/files-grid.ts","../../../src/lib/files-grid/files-grid.html"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAoC,MAAM,eAAe,CAAC;AAEnF,OAAO,EAAE,OAAO,EA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AG,QAAQ,CAAC;QACxB,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC5C,IAAI,CAAC,SAAS,GAAG,YAAY,SAAS,EAAE,CAAC;QACzC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACtB,OAAO,GAAG,CAAC;IACb,CAAC;4GA7NU,kBAAkB;6DAAlB,kBAAkB;YC3E/B,8BAAuB;YACrB,oFAAiB;YAKjB,0CAOoC;YAAlC,sHAAa,uBAAmB,IAAC;YACnC,iBAAkB;YAElB,+CAKC;YADC,AADA,6IAA6B,IAAI,IAAC,gHACpB,4BAAwB,IAAC;YACxC,iBAAuB;YAExB,oCAK4B;YAA1B,kGAAS,mBAAe,IAAC;YACzB,qFAAgB;YAwBd,AADF,yCAAmB,gBACsF;YAApE,+FAAS,kBAAc,IAAC;YAA4C,oBAAI;YAAA,iBAAS;YACpH,iCAAkE;YAAjD,+FAAS,mBAAe,IAAC;YAAwB,uBAAM;YAG9E,AADE,AADE,AAD0E,iBAAS,EAC/D,EACV,EACR;;YAxDJ,cAIC;YAJD,wCAIC;YAGC,cAAmB;YAInB,AADA,AADA,AADA,AADA,qCAAmB,sBACF,8BACQ,oCACM,0BACV;YAKrB,cAAyB;YACzB,AADA,2CAAyB,2BACH;YAMtB,cAAsB;YAGtB,AADA,AAFA,wCAAsB,cAET,iBACG;YAEhB,cAsBC;YAtBD,uCAsBC;YAE6D,eAA0C;YAA1C,+FAA0C;YAC3D,eAAsB;YAAtB,wCAAsB;;;iFDqB1D,kBAAkB;cAN9B,SAAS;6BACI,KAAK,YACP,eAAe;;kBAuBxB,KAAK;;kFAnBK,kBAAkB","sourcesContent":["import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core';\n\nimport { RunView } from '@memberjunction/core';\nimport { MJFileEntity } from '@memberjunction/core-entities';\nimport { GraphQLDataProvider, gql } from '@memberjunction/graphql-dataprovider';\nimport { SharedService } from '@memberjunction/ng-shared';\nimport {\n ColDef,\n GridReadyEvent,\n GridApi,\n ModuleRegistry,\n AllCommunityModule,\n themeAlpine,\n colorSchemeVariable,\n type Theme,\n ICellRendererParams\n} from 'ag-grid-community';\nimport { z } from 'zod';\nimport { FileUploadEvent } from '../file-upload/file-upload';\n\n// Register AG Grid modules\nModuleRegistry.registerModules([AllCommunityModule]);\n\n/**\n * Downloads a file from the provided URL.\n *\n * @param url - The URL of the file to be downloaded.\n * @param fileName - The name to be given to the downloaded file.\n * @param contentType - The content type of the file. Defaults to 'application/octet-stream'.\n * @returns Promise<void> - A promise that resolves when the file download is complete.\n */\nconst downloadFromUrl = async (url: string, fileName: string, contentType?: string | null) => {\n // First, fetch the data and create a blob with the correct content type\n const response = await fetch(url);\n if (!response.ok) {\n return false;\n }\n const rawBlob = await response.blob();\n const blob = new Blob([rawBlob], { type: contentType || 'application/octet-stream' });\n\n // Then add a temporary link to the document and click it\n const link = document.createElement('a');\n const blobUrl = window.URL.createObjectURL(blob);\n link.href = blobUrl;\n link.setAttribute('download', fileName);\n document.body.appendChild(link);\n link.click();\n link.parentNode?.removeChild(link);\n window.URL.revokeObjectURL(blobUrl);\n\n return true;\n};\n\nconst FileDownloadQuery = gql`\n query FileDownloadUrl($FileID: String!) {\n MJFile(ID: $FileID) {\n ContentType\n DownloadUrl\n }\n }\n`;\n\nconst FileDownloadQuerySchema = z.object({\n MJFile: z.object({\n ContentType: z.string().optional(),\n DownloadUrl: z.string(),\n }),\n});\n\n@Component({\n standalone: false,\n selector: 'mj-files-grid',\n templateUrl: './files-grid.html',\n styleUrls: ['./files-grid.css'],\n})\nexport class FilesGridComponent implements OnInit, OnChanges {\n public files: MJFileEntity[] = [];\n public isLoading: boolean = false;\n public editFile: MJFileEntity | undefined;\n\n // AG Grid configuration\n public GridTheme: Theme = themeAlpine.withPart(colorSchemeVariable);\n public ColumnDefs: ColDef[] = [];\n public DefaultColDef: ColDef = {\n sortable: true,\n resizable: true,\n filter: false,\n };\n private gridApi: GridApi | null = null;\n\n constructor(private sharedService: SharedService) {\n this.ColumnDefs = this.buildColumnDefs();\n }\n\n @Input() CategoryID: string | undefined = undefined;\n\n ngOnInit(): void {\n this.Refresh();\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n if (changes['CategoryID']) {\n this.Refresh();\n }\n }\n\n public OnGridReady(event: GridReadyEvent): void {\n this.gridApi = event.api;\n }\n\n /**\n * Resets the edited file.\n *\n * This method reverts any changes made to the edited file by calling the Revert method of the MJFileEntity class. It then sets the editFile property to undefined, indicating that there is no longer an edited file.\n *\n * @returns void\n */\n public resetEditFile() {\n this.editFile?.Revert();\n this.editFile = undefined;\n }\n\n /**\n * Saves the edited file.\n *\n * This method saves the changes made to the edited file. It first checks if there is an edited file available. If so, it sets the isLoading property to true to indicate that the save operation is in progress. Then, it calls the Save method of the edited file to save the changes. If the save operation is successful, it creates a success notification using the sharedService.CreateSimpleNotification method. The notification message includes the ID and name of the saved file. Finally, it sets the edited file to undefined and sets the isLoading property to false to indicate that the save operation is complete.\n *\n * @returns Promise<void> - A promise that resolves when the save operation is complete.\n * @throws Error - If there is an error during the save operation.\n */\n public async saveEditFile() {\n if (this.editFile) {\n this.isLoading = true;\n //\n const success = await this.editFile.Save();\n if (success) {\n this.sharedService.CreateSimpleNotification(`Successfully saved file ${this.editFile.ID} ${this.editFile.Name}`, 'success');\n this.editFile = undefined;\n // Refresh the grid to show the updated data\n if (this.gridApi) {\n this.gridApi.setGridOption('rowData', this.files);\n }\n } else {\n this.sharedService.CreateSimpleNotification(`Unable to save file ${this.editFile.ID} ${this.editFile.Name}`, 'error');\n }\n this.isLoading = false;\n }\n }\n\n /**\n * Downloads a file using the provided MJFileEntity.\n *\n * @param file - The MJFileEntity representing the file to be downloaded.\n * @returns Promise<void> - A promise that resolves when the file download is complete.\n * @throws Error - If there is an error during the file download process.\n */\n public downloadFile = async (file: MJFileEntity) => {\n this.isLoading = true;\n const result = await GraphQLDataProvider.ExecuteGQL(FileDownloadQuery, {\n FileID: file.ID,\n });\n const parsedResult = FileDownloadQuerySchema.safeParse(result);\n\n if (parsedResult.success) {\n const downloadUrl = parsedResult.data.MJFile.DownloadUrl;\n const success = downloadFromUrl(downloadUrl, file.Name, file.ContentType);\n if (!success) {\n this.sharedService.CreateSimpleNotification(`Unable to download file ${file.ID} ${file.Name}`, 'error');\n }\n } else {\n console.error(parsedResult.error);\n this.sharedService.CreateSimpleNotification(`Unable to download file ${file.ID} ${file.Name}`, 'error');\n }\n this.isLoading = false;\n };\n\n /**\n * Determines whether a file can be deleted based on its status and creation time.\n *\n * @param file - The MJFileEntity representing the file to be checked.\n * @returns boolean - True if the file can be deleted, false otherwise.\n */\n public canBeDeleted(file: MJFileEntity): boolean {\n const status = file.Status;\n const deletable = status === 'Uploaded' || Date.now() - +file.__mj_CreatedAt > 10 * 60 * 60;\n return deletable;\n }\n\n /**\n * Deletes a file using the provided MJFileEntity.\n *\n * @param file - The MJFileEntity representing the file to be deleted.\n * @returns Promise<void> - A promise that resolves when the file deletion is complete.\n * @throws Error - If there is an error during the file deletion process.\n */\n public deleteFile = async (file: MJFileEntity) => {\n this.isLoading = true;\n const ID = file.ID;\n const Name = file.Name;\n const deleteResult = await file.Delete();\n if (deleteResult) {\n this.sharedService.CreateSimpleNotification(`Successfully deleted file ${ID} ${Name}`, 'info');\n this.files = this.files.filter((f) => typeof f.ID === 'string' && f.ID !== ID);\n } else {\n this.sharedService.CreateSimpleNotification(`Unable to delete file ${ID} ${Name}`, 'error');\n }\n this.isLoading = false;\n };\n\n /**\n * Handles the file upload event, sending a notification in case of failure and otherwise adding\n * the newly uploaded files to the files currently displayed.\n *\n * @param e - The file upload event.\n */\n public handleFileUpload(e: FileUploadEvent) {\n if (!e.success) {\n this.sharedService.CreateSimpleNotification(`Unable to upload file '${e.file.name}'`, 'error');\n return;\n }\n\n this.files.push(e.file);\n this.files = [...this.files]; // trigger AG Grid row data change\n this.isLoading = false;\n }\n\n /**\n * Refreshes the data by running a view and loading the files.\n * @returns {Promise<void>} - A promise that resolves when the data is refreshed.\n */\n async Refresh() {\n this.isLoading = true;\n\n const rv = new RunView();\n const result = await rv.RunView({\n EntityName: 'MJ: Files',\n ResultType: 'entity_object',\n ...(this.CategoryID !== undefined && { ExtraFilter: `CategoryID='${this.CategoryID}'` }),\n });\n if (result.Success) {\n this.files = <MJFileEntity[]>result.Results ?? [];\n } else {\n throw new Error('Error loading files: ' + result.ErrorMessage);\n }\n this.isLoading = false;\n }\n\n /**\n * Builds AG Grid column definitions from the entity fields.\n */\n private buildColumnDefs(): ColDef[] {\n return [\n { field: 'ID', headerName: 'ID' },\n { field: 'Category', headerName: 'Category' },\n { field: 'Name', headerName: 'Name' },\n { field: 'Description', headerName: 'Description' },\n { field: 'Status', headerName: 'Status' },\n {\n headerName: 'Actions',\n sortable: false,\n resizable: false,\n filter: false,\n cellRenderer: (params: ICellRendererParams) => {\n const container = document.createElement('div');\n container.className = 'action-buttons';\n\n const downloadBtn = this.createActionButton('fa-download', params.data?.Status !== 'Uploaded');\n downloadBtn.addEventListener('click', () => this.downloadFile(params.data));\n\n const deleteBtn = this.createActionButton('fa-trash-can', !this.canBeDeleted(params.data));\n deleteBtn.addEventListener('click', () => this.deleteFile(params.data));\n\n const editBtn = this.createActionButton('fa-pen-to-square', params.data?.Status !== 'Uploaded');\n editBtn.addEventListener('click', () => { this.editFile = params.data; });\n\n container.appendChild(downloadBtn);\n container.appendChild(deleteBtn);\n container.appendChild(editBtn);\n\n return container;\n }\n }\n ];\n }\n\n /**\n * Creates a small action button element for the AG Grid cell renderer.\n */\n private createActionButton(iconClass: string, disabled: boolean): HTMLButtonElement {\n const btn = document.createElement('button');\n btn.className = 'mj-btn mj-btn-flat mj-btn-sm grid-action-btn';\n btn.disabled = disabled;\n const icon = document.createElement('span');\n icon.className = `fa-solid ${iconClass}`;\n btn.appendChild(icon);\n return btn;\n }\n}\n","<div class=\"container\">\n @if (isLoading) {\n <div class=\"grid-loading-overlay\">\n <mj-loading text=\"Loading files...\" size=\"medium\"></mj-loading>\n </div>\n }\n <ag-grid-angular\n class=\"files-grid\"\n [theme]=\"GridTheme\"\n [rowData]=\"files\"\n [columnDefs]=\"ColumnDefs\"\n [defaultColDef]=\"DefaultColDef\"\n [loading]=\"isLoading\"\n (gridReady)=\"OnGridReady($event)\">\n </ag-grid-angular>\n\n <mj-files-file-upload\n [CategoryID]=\"CategoryID\"\n [disabled]=\"isLoading\"\n (uploadStarted)=\"isLoading = true\"\n (fileUpload)=\"handleFileUpload($event)\"\n ></mj-files-file-upload>\n\n <mj-dialog\n [Visible]=\"!!editFile\"\n Title=\"Edit file\"\n [Width]=\"450\"\n [MinWidth]=\"250\"\n (Close)=\"resetEditFile()\">\n @if (editFile) {\n <div class=\"edit-form-container\">\n <form #templateForm=\"ngForm\">\n <label class=\"mj-form-field\">\n <span class=\"mj-form-label\">Name</span>\n <input\n class=\"mj-input\"\n name=\"name\"\n [(ngModel)]=\"editFile.Name\"\n required\n [disabled]=\"isLoading\" />\n </label>\n <label class=\"mj-form-field\">\n <span class=\"mj-form-label\">Description</span>\n <input\n class=\"mj-input\"\n name=\"description\"\n [(ngModel)]=\"editFile.Description\"\n [disabled]=\"isLoading\" />\n </label>\n </form>\n </div>\n }\n <mj-dialog-actions>\n <button mjButton variant=\"primary\" (click)=\"saveEditFile()\" [disabled]=\"isLoading || !editFile?.Dirty\">Save</button>\n <button mjButton (click)=\"resetEditFile()\" [disabled]=\"isLoading\">Cancel</button>\n </mj-dialog-actions>\n </mj-dialog>\n</div>\n"]}
1
+ {"version":3,"file":"files-grid.js","sourceRoot":"","sources":["../../../src/lib/files-grid/files-grid.ts","../../../src/lib/files-grid/files-grid.html"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAoC,MAAM,eAAe,CAAC;AAEnF,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAAE,mBAAmB,EAAE,GAAG,EAAE,MAAM,sCAAsC,CAAC;AAEhF,OAAO,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,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC5C,IAAI,CAAC,SAAS,GAAG,YAAY,SAAS,EAAE,CAAC;QACzC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACtB,OAAO,GAAG,CAAC;IACb,CAAC;4GA/NU,kBAAkB;6DAAlB,kBAAkB;YC3E/B,8BAAuB;YACrB,oFAAiB;YAKjB,0CAOoC;YAAlC,sHAAa,uBAAmB,IAAC;YACnC,iBAAkB;YAElB,+CAKC;YADC,AADA,6IAA6B,IAAI,IAAC,gHACpB,4BAAwB,IAAC;YACxC,iBAAuB;YAExB,oCAK4B;YAA1B,kGAAS,mBAAe,IAAC;YACzB,qFAAgB;YAwBd,AADF,yCAAmB,gBACsF;YAApE,+FAAS,kBAAc,IAAC;YAA4C,oBAAI;YAAA,iBAAS;YACpH,iCAAkE;YAAjD,+FAAS,mBAAe,IAAC;YAAwB,uBAAM;YAG9E,AADE,AADE,AAD0E,iBAAS,EAC/D,EACV,EACR;;YAxDJ,cAIC;YAJD,wCAIC;YAGC,cAAmB;YAInB,AADA,AADA,AADA,AADA,qCAAmB,sBACF,8BACQ,oCACM,0BACV;YAKrB,cAAyB;YACzB,AADA,2CAAyB,2BACH;YAMtB,cAAsB;YAGtB,AADA,AAFA,wCAAsB,cAET,iBACG;YAEhB,cAsBC;YAtBD,uCAsBC;YAE6D,eAA0C;YAA1C,+FAA0C;YAC3D,eAAsB;YAAtB,wCAAsB;;;iFDqB1D,kBAAkB;cAN9B,SAAS;6BACI,KAAK,YACP,eAAe;;kBAyBxB,KAAK;;kFArBK,kBAAkB","sourcesContent":["import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core';\n\nimport { RunView } from '@memberjunction/core';\nimport { MJFileEntity } from '@memberjunction/core-entities';\nimport { GraphQLDataProvider, gql } from '@memberjunction/graphql-dataprovider';\nimport { SharedService } from '@memberjunction/ng-shared';\nimport { MJ_AG_GRID_THEME_PARAMS } from '@memberjunction/ng-shared-generic';\nimport {\n ColDef,\n GridReadyEvent,\n GridApi,\n ModuleRegistry,\n AllCommunityModule,\n themeAlpine,\n type Theme,\n ICellRendererParams\n} from 'ag-grid-community';\nimport { z } from 'zod';\nimport { FileUploadEvent } from '../file-upload/file-upload';\n\n// Register AG Grid modules\nModuleRegistry.registerModules([AllCommunityModule]);\n\n/**\n * Downloads a file from the provided URL.\n *\n * @param url - The URL of the file to be downloaded.\n * @param fileName - The name to be given to the downloaded file.\n * @param contentType - The content type of the file. Defaults to 'application/octet-stream'.\n * @returns Promise<void> - A promise that resolves when the file download is complete.\n */\nconst downloadFromUrl = async (url: string, fileName: string, contentType?: string | null) => {\n // First, fetch the data and create a blob with the correct content type\n const response = await fetch(url);\n if (!response.ok) {\n return false;\n }\n const rawBlob = await response.blob();\n const blob = new Blob([rawBlob], { type: contentType || 'application/octet-stream' });\n\n // Then add a temporary link to the document and click it\n const link = document.createElement('a');\n const blobUrl = window.URL.createObjectURL(blob);\n link.href = blobUrl;\n link.setAttribute('download', fileName);\n document.body.appendChild(link);\n link.click();\n link.parentNode?.removeChild(link);\n window.URL.revokeObjectURL(blobUrl);\n\n return true;\n};\n\nconst FileDownloadQuery = gql`\n query FileDownloadUrl($FileID: String!) {\n MJFile(ID: $FileID) {\n ContentType\n DownloadUrl\n }\n }\n`;\n\nconst FileDownloadQuerySchema = z.object({\n MJFile: z.object({\n ContentType: z.string().optional(),\n DownloadUrl: z.string(),\n }),\n});\n\n@Component({\n standalone: false,\n selector: 'mj-files-grid',\n templateUrl: './files-grid.html',\n styleUrls: ['./files-grid.css'],\n})\nexport class FilesGridComponent implements OnInit, OnChanges {\n public files: MJFileEntity[] = [];\n public isLoading: boolean = false;\n public editFile: MJFileEntity | undefined;\n\n // AG Grid configuration\n // Themed from the shared --mj-* token params so this grid follows light/dark and\n // the org brand overlay, matching the main entity/query grids.\n public GridTheme: Theme = themeAlpine.withParams(MJ_AG_GRID_THEME_PARAMS);\n public ColumnDefs: ColDef[] = [];\n public DefaultColDef: ColDef = {\n sortable: true,\n resizable: true,\n filter: false,\n };\n private gridApi: GridApi | null = null;\n\n constructor(private sharedService: SharedService) {\n this.ColumnDefs = this.buildColumnDefs();\n }\n\n @Input() CategoryID: string | undefined = undefined;\n\n ngOnInit(): void {\n this.Refresh();\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n if (changes['CategoryID']) {\n this.Refresh();\n }\n }\n\n public OnGridReady(event: GridReadyEvent): void {\n this.gridApi = event.api;\n }\n\n /**\n * Resets the edited file.\n *\n * This method reverts any changes made to the edited file by calling the Revert method of the MJFileEntity class. It then sets the editFile property to undefined, indicating that there is no longer an edited file.\n *\n * @returns void\n */\n public resetEditFile() {\n this.editFile?.Revert();\n this.editFile = undefined;\n }\n\n /**\n * Saves the edited file.\n *\n * This method saves the changes made to the edited file. It first checks if there is an edited file available. If so, it sets the isLoading property to true to indicate that the save operation is in progress. Then, it calls the Save method of the edited file to save the changes. If the save operation is successful, it creates a success notification using the sharedService.CreateSimpleNotification method. The notification message includes the ID and name of the saved file. Finally, it sets the edited file to undefined and sets the isLoading property to false to indicate that the save operation is complete.\n *\n * @returns Promise<void> - A promise that resolves when the save operation is complete.\n * @throws Error - If there is an error during the save operation.\n */\n public async saveEditFile() {\n if (this.editFile) {\n this.isLoading = true;\n //\n const success = await this.editFile.Save();\n if (success) {\n this.sharedService.CreateSimpleNotification(`Successfully saved file ${this.editFile.ID} ${this.editFile.Name}`, 'success');\n this.editFile = undefined;\n // Refresh the grid to show the updated data\n if (this.gridApi) {\n this.gridApi.setGridOption('rowData', this.files);\n }\n } else {\n this.sharedService.CreateSimpleNotification(`Unable to save file ${this.editFile.ID} ${this.editFile.Name}`, 'error');\n }\n this.isLoading = false;\n }\n }\n\n /**\n * Downloads a file using the provided MJFileEntity.\n *\n * @param file - The MJFileEntity representing the file to be downloaded.\n * @returns Promise<void> - A promise that resolves when the file download is complete.\n * @throws Error - If there is an error during the file download process.\n */\n public downloadFile = async (file: MJFileEntity) => {\n this.isLoading = true;\n const result = await GraphQLDataProvider.ExecuteGQL(FileDownloadQuery, {\n FileID: file.ID,\n });\n const parsedResult = FileDownloadQuerySchema.safeParse(result);\n\n if (parsedResult.success) {\n const downloadUrl = parsedResult.data.MJFile.DownloadUrl;\n const success = downloadFromUrl(downloadUrl, file.Name, file.ContentType);\n if (!success) {\n this.sharedService.CreateSimpleNotification(`Unable to download file ${file.ID} ${file.Name}`, 'error');\n }\n } else {\n console.error(parsedResult.error);\n this.sharedService.CreateSimpleNotification(`Unable to download file ${file.ID} ${file.Name}`, 'error');\n }\n this.isLoading = false;\n };\n\n /**\n * Determines whether a file can be deleted based on its status and creation time.\n *\n * @param file - The MJFileEntity representing the file to be checked.\n * @returns boolean - True if the file can be deleted, false otherwise.\n */\n public canBeDeleted(file: MJFileEntity): boolean {\n const status = file.Status;\n const deletable = status === 'Uploaded' || Date.now() - +file.__mj_CreatedAt > 10 * 60 * 60;\n return deletable;\n }\n\n /**\n * Deletes a file using the provided MJFileEntity.\n *\n * @param file - The MJFileEntity representing the file to be deleted.\n * @returns Promise<void> - A promise that resolves when the file deletion is complete.\n * @throws Error - If there is an error during the file deletion process.\n */\n public deleteFile = async (file: MJFileEntity) => {\n this.isLoading = true;\n const ID = file.ID;\n const Name = file.Name;\n const deleteResult = await file.Delete();\n if (deleteResult) {\n this.sharedService.CreateSimpleNotification(`Successfully deleted file ${ID} ${Name}`, 'info');\n this.files = this.files.filter((f) => typeof f.ID === 'string' && f.ID !== ID);\n } else {\n this.sharedService.CreateSimpleNotification(`Unable to delete file ${ID} ${Name}`, 'error');\n }\n this.isLoading = false;\n };\n\n /**\n * Handles the file upload event, sending a notification in case of failure and otherwise adding\n * the newly uploaded files to the files currently displayed.\n *\n * @param e - The file upload event.\n */\n public handleFileUpload(e: FileUploadEvent) {\n if (!e.success) {\n this.sharedService.CreateSimpleNotification(`Unable to upload file '${e.file.name}'`, 'error');\n return;\n }\n\n this.files.push(e.file);\n this.files = [...this.files]; // trigger AG Grid row data change\n this.isLoading = false;\n }\n\n /**\n * Refreshes the data by running a view and loading the files.\n * @returns {Promise<void>} - A promise that resolves when the data is refreshed.\n */\n async Refresh() {\n this.isLoading = true;\n\n const rv = new RunView();\n const result = await rv.RunView({\n EntityName: 'MJ: Files',\n ResultType: 'entity_object',\n ...(this.CategoryID !== undefined && { ExtraFilter: `CategoryID='${this.CategoryID}'` }),\n });\n if (result.Success) {\n this.files = <MJFileEntity[]>result.Results ?? [];\n } else {\n throw new Error('Error loading files: ' + result.ErrorMessage);\n }\n this.isLoading = false;\n }\n\n /**\n * Builds AG Grid column definitions from the entity fields.\n */\n private buildColumnDefs(): ColDef[] {\n return [\n { field: 'ID', headerName: 'ID' },\n { field: 'Category', headerName: 'Category' },\n { field: 'Name', headerName: 'Name' },\n { field: 'Description', headerName: 'Description' },\n { field: 'Status', headerName: 'Status' },\n {\n headerName: 'Actions',\n sortable: false,\n resizable: false,\n filter: false,\n cellRenderer: (params: ICellRendererParams) => {\n const container = document.createElement('div');\n container.className = 'action-buttons';\n\n const downloadBtn = this.createActionButton('fa-download', params.data?.Status !== 'Uploaded');\n downloadBtn.addEventListener('click', () => this.downloadFile(params.data));\n\n const deleteBtn = this.createActionButton('fa-trash-can', !this.canBeDeleted(params.data));\n deleteBtn.addEventListener('click', () => this.deleteFile(params.data));\n\n const editBtn = this.createActionButton('fa-pen-to-square', params.data?.Status !== 'Uploaded');\n editBtn.addEventListener('click', () => { this.editFile = params.data; });\n\n container.appendChild(downloadBtn);\n container.appendChild(deleteBtn);\n container.appendChild(editBtn);\n\n return container;\n }\n }\n ];\n }\n\n /**\n * Creates a small action button element for the AG Grid cell renderer.\n */\n private createActionButton(iconClass: string, disabled: boolean): HTMLButtonElement {\n const btn = document.createElement('button');\n btn.className = 'mj-btn mj-btn-flat mj-btn-sm grid-action-btn';\n btn.disabled = disabled;\n const icon = document.createElement('span');\n icon.className = `fa-solid ${iconClass}`;\n btn.appendChild(icon);\n return btn;\n }\n}\n","<div class=\"container\">\n @if (isLoading) {\n <div class=\"grid-loading-overlay\">\n <mj-loading text=\"Loading files...\" size=\"medium\"></mj-loading>\n </div>\n }\n <ag-grid-angular\n class=\"files-grid\"\n [theme]=\"GridTheme\"\n [rowData]=\"files\"\n [columnDefs]=\"ColumnDefs\"\n [defaultColDef]=\"DefaultColDef\"\n [loading]=\"isLoading\"\n (gridReady)=\"OnGridReady($event)\">\n </ag-grid-angular>\n\n <mj-files-file-upload\n [CategoryID]=\"CategoryID\"\n [disabled]=\"isLoading\"\n (uploadStarted)=\"isLoading = true\"\n (fileUpload)=\"handleFileUpload($event)\"\n ></mj-files-file-upload>\n\n <mj-dialog\n [Visible]=\"!!editFile\"\n Title=\"Edit file\"\n [Width]=\"450\"\n [MinWidth]=\"250\"\n (Close)=\"resetEditFile()\">\n @if (editFile) {\n <div class=\"edit-form-container\">\n <form #templateForm=\"ngForm\">\n <label class=\"mj-form-field\">\n <span class=\"mj-form-label\">Name</span>\n <input\n class=\"mj-input\"\n name=\"name\"\n [(ngModel)]=\"editFile.Name\"\n required\n [disabled]=\"isLoading\" />\n </label>\n <label class=\"mj-form-field\">\n <span class=\"mj-form-label\">Description</span>\n <input\n class=\"mj-input\"\n name=\"description\"\n [(ngModel)]=\"editFile.Description\"\n [disabled]=\"isLoading\" />\n </label>\n </form>\n </div>\n }\n <mj-dialog-actions>\n <button mjButton variant=\"primary\" (click)=\"saveEditFile()\" [disabled]=\"isLoading || !editFile?.Dirty\">Save</button>\n <button mjButton (click)=\"resetEditFile()\" [disabled]=\"isLoading\">Cancel</button>\n </mj-dialog-actions>\n </mj-dialog>\n</div>\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/ng-file-storage",
3
- "version": "5.48.0",
3
+ "version": "5.49.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",
@@ -29,7 +29,7 @@
29
29
  "devDependencies": {
30
30
  "@angular/compiler": "21.1.3",
31
31
  "@angular/compiler-cli": "21.1.3",
32
- "@memberjunction/ng-test-utils": "5.48.0",
32
+ "@memberjunction/ng-test-utils": "5.49.0",
33
33
  "vitest": "^4.0.18"
34
34
  },
35
35
  "peerDependencies": {
@@ -39,16 +39,16 @@
39
39
  "@angular/router": "21.1.3"
40
40
  },
41
41
  "dependencies": {
42
- "@memberjunction/ng-ui-components": "5.48.0",
42
+ "@memberjunction/ng-ui-components": "5.49.0",
43
43
  "@angular/platform-browser": "21.1.3",
44
- "@memberjunction/core": "5.48.0",
45
- "@memberjunction/ng-base-types": "5.48.0",
46
- "@memberjunction/core-entities": "5.48.0",
47
- "@memberjunction/global": "5.48.0",
48
- "@memberjunction/graphql-dataprovider": "5.48.0",
49
- "@memberjunction/ng-container-directives": "5.48.0",
50
- "@memberjunction/ng-shared": "5.48.0",
51
- "@memberjunction/ng-shared-generic": "5.48.0",
44
+ "@memberjunction/core": "5.49.0",
45
+ "@memberjunction/ng-base-types": "5.49.0",
46
+ "@memberjunction/core-entities": "5.49.0",
47
+ "@memberjunction/global": "5.49.0",
48
+ "@memberjunction/graphql-dataprovider": "5.49.0",
49
+ "@memberjunction/ng-container-directives": "5.49.0",
50
+ "@memberjunction/ng-shared": "5.49.0",
51
+ "@memberjunction/ng-shared-generic": "5.49.0",
52
52
  "ag-grid-angular": "^35.0.1",
53
53
  "ag-grid-community": "^35.0.1",
54
54
  "tslib": "^2.8.1",