diff --git a/src/app/mock-api/apps/file-manager/api.ts b/src/app/mock-api/apps/file-manager/api.ts index 95c56045..ff4f7e7a 100644 --- a/src/app/mock-api/apps/file-manager/api.ts +++ b/src/app/mock-api/apps/file-manager/api.ts @@ -33,10 +33,18 @@ export class FileManagerMockApi // ----------------------------------------------------------------------------------------------------- this._fuseMockApiService .onGet('api/apps/file-manager') - .reply(() => { + .reply(({request}) => { // Clone the items - const items = cloneDeep(this._items); + let items = cloneDeep(this._items); + + // See if a folder id exist + const folderId = request.params.get('folderId') ?? null; + + // Filter the items by folder id. If folder id is null, + // that means we want to root items which have folder id + // of null + items = items.filter(item => item.folderId === folderId); // Separate the items by folders and files const folders = items.filter(item => item.type === 'folder'); @@ -46,11 +54,38 @@ export class FileManagerMockApi folders.sort((a, b) => a.name.localeCompare(b.name)); files.sort((a, b) => a.name.localeCompare(b.name)); + // Figure out the path and attach it to the response + // Prepare the empty paths array + const pathItems = cloneDeep(this._items); + const path = []; + + // Prepare the current folder + let currentFolder = null; + + // Get the current folder and add it as the first entry + if ( folderId ) + { + currentFolder = pathItems.find(item => item.id === folderId); + path.push(currentFolder); + } + + // Start traversing and storing the folders as a path array + // until we hit null on the folder id + while ( currentFolder?.folderId ) + { + currentFolder = pathItems.find(item => item.id === currentFolder.folderId); + if ( currentFolder ) + { + path.unshift(currentFolder); + } + } + return [ 200, { folders, - files + files, + path } ]; }); diff --git a/src/app/mock-api/apps/file-manager/data.ts b/src/app/mock-api/apps/file-manager/data.ts index bf4b7ff0..fa6184f6 100644 --- a/src/app/mock-api/apps/file-manager/data.ts +++ b/src/app/mock-api/apps/file-manager/data.ts @@ -2,6 +2,7 @@ export const items = [ { id : 'cd6897cb-acfd-4016-8b53-3f66a5b5fc68', + folderId : null, name : 'Personal', createdBy : 'Brian Hughes', createdAt : 'April 24, 2018', @@ -13,6 +14,7 @@ export const items = [ }, { id : '6da8747f-b474-4c9a-9eba-5ef212285500', + folderId : null, name : 'Photos', createdBy : 'Brian Hughes', createdAt : 'November 01, 2021', @@ -24,6 +26,7 @@ export const items = [ }, { id : 'ed58add1-45a7-41db-887d-3ca7ee7f2719', + folderId : null, name : 'Work', createdBy : 'Brian Hughes', createdAt : 'May 8, 2020', @@ -35,6 +38,7 @@ export const items = [ }, { id : '5cb66e32-d1ac-4b9a-8c34-5991ce25add2', + folderId : null, name : 'Contract #123', createdBy : 'Brian Hughes', createdAt : 'January 14, 2021', @@ -46,6 +50,7 @@ export const items = [ }, { id : '3ffc3d84-8f2d-4929-903a-ef6fc21657a7', + folderId : null, name : 'Estimated budget', createdBy : 'Brian Hughes', createdAt : 'December 14, 2020', @@ -57,6 +62,7 @@ export const items = [ }, { id : '157adb9a-14f8-4559-ac93-8be893c9f80a', + folderId : null, name : 'DMCA notice #42', createdBy : 'Brian Hughes', createdAt : 'May 8, 2021', @@ -68,6 +74,7 @@ export const items = [ }, { id : '4f64597a-df7e-461c-ad60-f33e5f7e0747', + folderId : null, name : 'Invoices', createdBy : 'Brian Hughes', createdAt : 'January 12, 2020', @@ -79,6 +86,7 @@ export const items = [ }, { id : 'e445c445-57b2-4476-8c62-b068e3774b8e', + folderId : null, name : 'Crash logs', createdBy : 'Brian Hughes', createdAt : 'June 8, 2020', @@ -90,6 +98,7 @@ export const items = [ }, { id : 'b482f93e-7847-4614-ad48-b78b78309f81', + folderId : null, name : 'System logs', createdBy : 'Brian Hughes', createdAt : 'June 8, 2020', @@ -101,6 +110,7 @@ export const items = [ }, { id : 'ec07a98d-2e5b-422c-a9b2-b5d1c0e263f5', + folderId : null, name : 'Personal projects', createdBy : 'Brian Hughes', createdAt : 'March 18, 2020', @@ -112,6 +122,7 @@ export const items = [ }, { id : 'ae908d59-07da-4dd8-aba0-124e50289295', + folderId : null, name : 'Biometric portrait', createdBy : 'Brian Hughes', createdAt : 'August 29, 2020', @@ -123,6 +134,7 @@ export const items = [ }, { id : '4038a5b6-5b1a-432d-907c-e037aeb817a8', + folderId : null, name : 'Scanned image 20201012-1', createdBy : 'Brian Hughes', createdAt : 'September 13, 2020', @@ -134,6 +146,7 @@ export const items = [ }, { id : '630d2e9a-d110-47a0-ac03-256073a0f56d', + folderId : null, name : 'Scanned image 20201012-2', createdBy : 'Brian Hughes', createdAt : 'September 14, 2020', @@ -145,6 +158,7 @@ export const items = [ }, { id : '1417d5ed-b616-4cff-bfab-286677b69d79', + folderId : null, name : 'Prices', createdBy : 'Brian Hughes', createdAt : 'April 07, 2020', @@ -156,6 +170,7 @@ export const items = [ }, { id : 'bd2817c7-6751-40dc-b252-b6b5634c0689', + folderId : null, name : 'Shopping list', createdBy : 'Brian Hughes', createdAt : 'March 26, 2021', @@ -167,6 +182,7 @@ export const items = [ }, { id : '14fb47c9-6eeb-4070-919c-07c8133285d1', + folderId : null, name : 'Summer budget', createdBy : 'Brian Hughes', createdAt : 'June 02, 2020', @@ -175,5 +191,67 @@ export const items = [ type : 'XLS', contents : null, description: null + }, + + { + id : '894e8514-03d3-4f5e-bb28-f6c092501fae', + folderId : 'cd6897cb-acfd-4016-8b53-3f66a5b5fc68', + name : 'A personal file', + createdBy : 'Brian Hughes', + createdAt : 'June 02, 2020', + modifiedAt : 'June 02, 2020', + size : '943 KB', + type : 'XLS', + contents : null, + description: null + }, + { + id : '74010810-16cf-441d-a1aa-c9fb620fceea', + folderId : 'cd6897cb-acfd-4016-8b53-3f66a5b5fc68', + name : 'A personal folder', + createdBy : 'Brian Hughes', + createdAt : 'November 01, 2021', + modifiedAt : 'November 01, 2021', + size : '3015 MB', + type : 'folder', + contents : '907 files', + description: 'Personal photos; selfies, family, vacation and etc.' + }, + { + id : 'a8c73e5a-8114-436d-ab54-d900b50b3762', + folderId : '74010810-16cf-441d-a1aa-c9fb620fceea', + name : 'A personal file within the personal folder', + createdBy : 'Brian Hughes', + createdAt : 'June 02, 2020', + modifiedAt : 'June 02, 2020', + size : '943 KB', + type : 'XLS', + contents : null, + description: null + }, + + { + id : '12d851a8-4f60-473e-8a59-abe4b422ea99', + folderId : '6da8747f-b474-4c9a-9eba-5ef212285500', + name : 'Photos file', + createdBy : 'Brian Hughes', + createdAt : 'June 02, 2020', + modifiedAt : 'June 02, 2020', + size : '943 KB', + type : 'XLS', + contents : null, + description: null + }, + { + id : '2836766d-27e1-4f40-a31a-5a8419105e7e', + folderId : 'ed58add1-45a7-41db-887d-3ca7ee7f2719', + name : 'Work file', + createdBy : 'Brian Hughes', + createdAt : 'June 02, 2020', + modifiedAt : 'June 02, 2020', + size : '943 KB', + type : 'XLS', + contents : null, + description: null } ]; diff --git a/src/app/modules/admin/apps/file-manager/details/details.component.html b/src/app/modules/admin/apps/file-manager/details/details.component.html index 55599ee8..b258d689 100644 --- a/src/app/modules/admin/apps/file-manager/details/details.component.html +++ b/src/app/modules/admin/apps/file-manager/details/details.component.html @@ -4,7 +4,7 @@