mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[MNT-24575] Added APIS and models folder information dialog (#10460)
* [MNT-24575] Added APIs folder information * [MNT-24575] Added models * [MNT-24575] Added constructors to model * [MNT-24575] Added documentation * [MNT-24575] Added documentation * [MNT-24575] Addressed Code review comments * [MNT-24575] Added unit tests. Fixed typo * [MNT-24575] Fixed accesibility issue in DialogComponent. Fixed typo in enum * [MNT-24575] Fixed typo, incorrect ACS version, and incorrect imports * [MNT-24575] Added unit tests to js-api * Empty commit to trigger GHA * [ci:force] Empty force commit to trigger GHA * [MNT-24575] Fixed linting issue * [MNT-24575] Removed redundant * * [ci:force] Empty force commit to trigger GHA
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
import { CoreTestingModule, RedirectAuthService } from '@alfresco/adf-core';
|
||||
import { EMPTY, firstValueFrom, of } from 'rxjs';
|
||||
import { JobIdBodyEntry, SizeDetails, SizeDetailsEntry } from '@alfresco/js-api';
|
||||
import { NodesApiService } from './nodes-api.service';
|
||||
import { AlfrescoApiService } from '../../services/alfresco-api.service';
|
||||
import { AlfrescoApiServiceMock } from '../../mock/alfresco-api.service.mock';
|
||||
|
||||
const fakeInitiateFolderSizeResponse: JobIdBodyEntry = {
|
||||
entry: {
|
||||
jobId: 'fake-job-id'
|
||||
}
|
||||
};
|
||||
|
||||
const fakeFolderSizeResponse: SizeDetailsEntry = {
|
||||
entry: {
|
||||
jobId: 'fake-job-id',
|
||||
calculatedAt: new Date().toString(),
|
||||
sizeInBytes: '1234',
|
||||
numberOfFiles: 1,
|
||||
status: SizeDetails.StatusEnum.COMPLETE,
|
||||
id: 'fake-id'
|
||||
}
|
||||
};
|
||||
|
||||
describe('NodesApiService', () => {
|
||||
let nodesApiService: NodesApiService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [HttpClientTestingModule, CoreTestingModule],
|
||||
providers: [
|
||||
NodesApiService,
|
||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
||||
{ provide: RedirectAuthService, useValue: { onLogin: EMPTY, onTokenReceived: of(), init: () => {} } }
|
||||
]
|
||||
});
|
||||
|
||||
nodesApiService = TestBed.inject(NodesApiService);
|
||||
});
|
||||
|
||||
it('should call initiateFolderSizeCalculation api with nodeId parameter', async () => {
|
||||
spyOn(nodesApiService.nodesApi, 'initiateFolderSizeCalculation').and.returnValue(Promise.resolve(fakeInitiateFolderSizeResponse));
|
||||
await firstValueFrom(nodesApiService.initiateFolderSizeCalculation('fake-node-id'));
|
||||
|
||||
expect(nodesApiService.nodesApi.initiateFolderSizeCalculation).toHaveBeenCalledWith('fake-node-id');
|
||||
});
|
||||
|
||||
it('should call getFolderSizeInfo api with nodeId and jobId parameter', async () => {
|
||||
spyOn(nodesApiService.nodesApi, 'getFolderSizeInfo').and.returnValue(Promise.resolve(fakeFolderSizeResponse));
|
||||
await firstValueFrom(nodesApiService.getFolderSizeInfo('fake-node-id', 'fake-job-id'));
|
||||
|
||||
expect(nodesApiService.nodesApi.getFolderSizeInfo).toHaveBeenCalledWith('fake-node-id', 'fake-job-id');
|
||||
});
|
||||
});
|
@@ -16,7 +16,18 @@
|
||||
*/
|
||||
|
||||
import { UserPreferencesService } from '@alfresco/adf-core';
|
||||
import { ContentPagingQuery, Node, NodeAssignedHold, NodeEntry, NodePaging, NodesApi, NodesIncludeQuery, TrashcanApi } from '@alfresco/js-api';
|
||||
import {
|
||||
ContentPagingQuery,
|
||||
Node,
|
||||
NodeAssignedHold,
|
||||
NodeEntry,
|
||||
NodePaging,
|
||||
NodesApi,
|
||||
NodesIncludeQuery,
|
||||
TrashcanApi,
|
||||
SizeDetailsEntry,
|
||||
JobIdBodyEntry
|
||||
} from '@alfresco/js-api';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { from, Observable, Subject, throwError } from 'rxjs';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
@@ -246,6 +257,27 @@ export class NodesApiService {
|
||||
return this.createNodeInsideRoot(name || this.randomNodeName(), nodeType, properties, path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiate a new request to calculate folder size.
|
||||
*
|
||||
* @param nodeId Node Id
|
||||
* @returns The job id which can be used to track request status
|
||||
*/
|
||||
initiateFolderSizeCalculation(nodeId: string): Observable<JobIdBodyEntry> {
|
||||
return from(this.nodesApi.initiateFolderSizeCalculation(nodeId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the size of a folder.
|
||||
*
|
||||
* @param nodeId Node Id
|
||||
* @param jobId Job Id
|
||||
* @returns Folder details
|
||||
*/
|
||||
getFolderSizeInfo(nodeId: string, jobId: string): Observable<SizeDetailsEntry> {
|
||||
return from(this.nodesApi.getFolderSizeInfo(nodeId, jobId));
|
||||
}
|
||||
|
||||
private randomNodeName(): string {
|
||||
return `node_${Date.now()}`;
|
||||
}
|
||||
|
Reference in New Issue
Block a user