mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-19 17:14:45 +00:00
ACS-8404: Update application settings service (#3988)
This commit is contained in:
parent
360970da85
commit
11f51af54c
app/src
karma.conf.jsprojects
aca-content
src/lib
components/info-drawer/versions-tab
services
store/effects
viewer/src/lib/components/viewer
aca-shared/src/lib/services
@ -38,7 +38,6 @@
|
||||
"logo": "assets/images/app-logo.svg",
|
||||
"copyright": "APP.COPYRIGHT"
|
||||
},
|
||||
"viewer.maxRetries": 1,
|
||||
"pagination": {
|
||||
"size": 25,
|
||||
"supportedPageSizes": [25, 50, 100]
|
||||
@ -54,10 +53,6 @@
|
||||
"defaultDateTimeFormat": "MMM d, y, h:mm",
|
||||
"defaultLocale": "en"
|
||||
},
|
||||
"adf-version-manager": {
|
||||
"allowComments": true,
|
||||
"allowDownload": true
|
||||
},
|
||||
"sideNav": {
|
||||
"preserveState": true,
|
||||
"expandedSidenav": true
|
||||
@ -330,7 +325,6 @@
|
||||
"downloadPromptDelay": 50,
|
||||
"downloadPromptReminderDelay": 30,
|
||||
"enableFileAutoDownload": true,
|
||||
"fileAutoDownloadSizeThresholdInMB": 15,
|
||||
"closeButtonPosition": "right"
|
||||
"fileAutoDownloadSizeThresholdInMB": 15
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<adf-login
|
||||
[copyrightText]="'application.copyright' | adfAppConfig | translate"
|
||||
[copyrightText]="settings.appCopyright | translate"
|
||||
successRoute="/personal-files"
|
||||
logoImageUrl="./assets/images/alfresco-logo.svg"
|
||||
backgroundImageUrl="./assets/images/Wallpaper-BG-generic.svg"
|
||||
|
@ -22,14 +22,17 @@
|
||||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { AppConfigPipe, LoginComponent } from '@alfresco/adf-core';
|
||||
import { Component, ViewEncapsulation } from '@angular/core';
|
||||
import { LoginComponent } from '@alfresco/adf-core';
|
||||
import { Component, inject, ViewEncapsulation } from '@angular/core';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { AppSettingsService } from '@alfresco/aca-shared';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
imports: [LoginComponent, TranslateModule, AppConfigPipe],
|
||||
imports: [LoginComponent, TranslateModule],
|
||||
templateUrl: './app-login.component.html',
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class AppLoginComponent {}
|
||||
export class AppLoginComponent {
|
||||
settings = inject(AppSettingsService);
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ module.exports = () => {
|
||||
global: {
|
||||
statements: 75,
|
||||
branches: 65,
|
||||
functions: 70,
|
||||
functions: 69,
|
||||
lines: 74
|
||||
}
|
||||
}
|
||||
|
@ -22,25 +22,21 @@
|
||||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Component, Input, OnChanges, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, inject, Input, OnChanges, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Node } from '@alfresco/js-api';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { VersionManagerModule } from '@alfresco/adf-content-services';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { AppConfigPipe } from '@alfresco/adf-core';
|
||||
import { AppSettingsService } from '@alfresco/aca-shared';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
imports: [CommonModule, VersionManagerModule, MatIconModule, TranslateModule, AppConfigPipe],
|
||||
imports: [CommonModule, VersionManagerModule, MatIconModule, TranslateModule],
|
||||
selector: 'app-versions-tab',
|
||||
template: `
|
||||
<ng-container *ngIf="isFileSelected; else empty">
|
||||
<adf-version-manager
|
||||
[showComments]="'adf-version-manager.allowComments' | adfAppConfig : true"
|
||||
[allowDownload]="'adf-version-manager.allowDownload' | adfAppConfig : true"
|
||||
[node]="node"
|
||||
>
|
||||
<adf-version-manager [showComments]="settings.uploadAllowComments" [allowDownload]="settings.uploadAllowDownload" [node]="node">
|
||||
</adf-version-manager>
|
||||
</ng-container>
|
||||
|
||||
@ -54,6 +50,8 @@ import { AppConfigPipe } from '@alfresco/adf-core';
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class VersionsTabComponent implements OnInit, OnChanges {
|
||||
settings = inject(AppSettingsService);
|
||||
|
||||
@Input()
|
||||
node: Node;
|
||||
|
||||
|
@ -1505,7 +1505,10 @@ describe('ContentManagementService', () => {
|
||||
|
||||
it('should open dialog with NewVersionUploaderService', () => {
|
||||
contentManagementService.versionUpdateDialog(fakeNode, fakeFile);
|
||||
const expectedParams = [{ node: fakeNode, file: fakeFile, currentVersion: { id: '1.0' }, title: 'VERSION.DIALOG.TITLE' }, { width: '600px' }];
|
||||
const expectedParams = [
|
||||
{ node: fakeNode, file: fakeFile, currentVersion: { id: '1.0' }, title: 'VERSION.DIALOG.TITLE', showComments: true, allowDownload: true },
|
||||
{ width: '600px' }
|
||||
];
|
||||
expect(spyOnOpenUploadNewVersionDialog).toHaveBeenCalledOnceWith(...expectedParams);
|
||||
});
|
||||
|
||||
|
@ -47,7 +47,6 @@ import {
|
||||
DocumentListService,
|
||||
FolderDialogComponent,
|
||||
LibraryDialogComponent,
|
||||
NewVersionUploaderData,
|
||||
NewVersionUploaderDataAction,
|
||||
NewVersionUploaderDialogData,
|
||||
NewVersionUploaderService,
|
||||
@ -152,17 +151,20 @@ export class ContentManagementService {
|
||||
}
|
||||
}
|
||||
|
||||
versionUpdateDialog(node, file) {
|
||||
versionUpdateDialog(node: Node, file: File) {
|
||||
this.contentApi.getNodeVersions(node.id).subscribe(({ list }) => {
|
||||
const newVersionUploaderDialogData: NewVersionUploaderDialogData = {
|
||||
const newVersionUploaderDialogData = {
|
||||
node,
|
||||
file,
|
||||
currentVersion: list.entries[0].entry,
|
||||
title: 'VERSION.DIALOG.TITLE'
|
||||
};
|
||||
title: 'VERSION.DIALOG.TITLE',
|
||||
showComments: this.appSettingsService.uploadAllowComments,
|
||||
allowDownload: this.appSettingsService.uploadAllowDownload
|
||||
} as NewVersionUploaderDialogData;
|
||||
const dialogConfig: MatDialogConfig = { width: '600px' };
|
||||
|
||||
this.newVersionUploaderService.openUploadNewVersionDialog(newVersionUploaderDialogData, dialogConfig).subscribe(
|
||||
(data: NewVersionUploaderData) => {
|
||||
(data) => {
|
||||
if (data.action === NewVersionUploaderDataAction.upload) {
|
||||
if (data.newVersion.value.entry.properties['cm:lockType'] === 'WRITE_LOCK') {
|
||||
this.store.dispatch(new UnlockWriteAction(data.newVersion.value));
|
||||
@ -573,7 +575,7 @@ export class ContentManagementService {
|
||||
this.newVersionUploaderService
|
||||
.openUploadNewVersionDialog(newVersionUploaderDialogData, { width: '630px', role: 'dialog' }, focusedElementOnCloseSelector)
|
||||
.subscribe({
|
||||
next: (newVersionUploaderData: NewVersionUploaderData) => {
|
||||
next: (newVersionUploaderData) => {
|
||||
switch (newVersionUploaderData.action) {
|
||||
case NewVersionUploaderDataAction.refresh:
|
||||
this.store.dispatch(new RefreshPreviewAction(newVersionUploaderData.node));
|
||||
|
@ -235,13 +235,13 @@ describe('UploadEffects', () => {
|
||||
detail: {
|
||||
files: [
|
||||
{
|
||||
file: new FileModel({
|
||||
file: {
|
||||
name: 'Fake New file',
|
||||
type: 'image/png',
|
||||
lastModified: 1589273450599,
|
||||
size: 1351,
|
||||
slice: null
|
||||
} as File),
|
||||
} as File,
|
||||
entry: new FileModel({
|
||||
name: 'Fake New file',
|
||||
type: 'image/png',
|
||||
@ -274,7 +274,7 @@ describe('UploadEffects', () => {
|
||||
id: '1bf8a8f7-18ac-4eef-919d-61d952eaa179',
|
||||
allowableOperations: ['delete', 'update', 'updatePermissions'],
|
||||
isFavorite: false
|
||||
}
|
||||
} as any
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
[ngClass]="{
|
||||
'aca-right_side--hide': !showRightSide
|
||||
}"
|
||||
[maxRetries]="'viewer.maxRetries' | adfAppConfig"
|
||||
[maxRetries]="settings.viewerMaxRetries"
|
||||
[nodeId]="nodeId"
|
||||
[versionId]="versionId"
|
||||
[allowNavigate]="navigateMultiple"
|
||||
@ -14,7 +14,7 @@
|
||||
[allowFullScreen]="false"
|
||||
[overlayMode]="true"
|
||||
[hideInfoButton]="true"
|
||||
[closeButtonPosition]="'viewer.closeButtonPosition' | adfAppConfig: 'right'"
|
||||
[closeButtonPosition]="settings.viewerCloseButtonPosition"
|
||||
(showViewerChange)="onViewerVisibilityChanged()"
|
||||
[canNavigateBefore]="!!previousNodeId"
|
||||
[canNavigateNext]="!!nextNodeId"
|
||||
|
@ -39,7 +39,6 @@ import {
|
||||
} from '@alfresco/aca-shared';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { Node } from '@alfresco/js-api';
|
||||
import { AcaViewerModule } from '../../viewer.module';
|
||||
|
||||
const apiError = `{
|
||||
"error": {
|
||||
@ -68,7 +67,7 @@ describe('AcaViewerComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [LibTestingModule, AcaViewerModule],
|
||||
imports: [LibTestingModule, AcaViewerComponent],
|
||||
providers: [
|
||||
{ provide: DocumentBasePageService, useValue: DocumentBasePageServiceMock },
|
||||
{ provide: DiscoveryApiService, useValue: discoveryApiServiceMockValue },
|
||||
|
@ -25,6 +25,7 @@
|
||||
import {
|
||||
AppExtensionService,
|
||||
AppHookService,
|
||||
AppSettingsService,
|
||||
ContentApiService,
|
||||
InfoDrawerComponent,
|
||||
ToolbarComponent,
|
||||
@ -45,18 +46,27 @@ import { ContentActionRef, SelectionState } from '@alfresco/adf-extensions';
|
||||
import { Node, VersionEntry, VersionsApi } from '@alfresco/js-api';
|
||||
import { Component, HostListener, inject, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { ActivatedRoute, PRIMARY_OUTLET, Router } from '@angular/router';
|
||||
import { AlfrescoApiService, AppConfigPipe, ViewerModule } from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService, ViewerOpenWithComponent, ViewerSidebarComponent, ViewerToolbarActionsComponent } from '@alfresco/adf-core';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { from, Observable, Subject } from 'rxjs';
|
||||
import { debounceTime, takeUntil } from 'rxjs/operators';
|
||||
import { Actions, ofType } from '@ngrx/effects';
|
||||
import { AlfrescoViewerModule, DocumentListService, NodesApiService, UploadService } from '@alfresco/adf-content-services';
|
||||
import { AlfrescoViewerComponent, DocumentListService, NodesApiService, UploadService } from '@alfresco/adf-content-services';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ViewerService } from '../../services/viewer.service';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
imports: [CommonModule, ViewerModule, AlfrescoViewerModule, InfoDrawerComponent, ToolbarMenuItemComponent, ToolbarComponent, AppConfigPipe],
|
||||
imports: [
|
||||
CommonModule,
|
||||
InfoDrawerComponent,
|
||||
ToolbarMenuItemComponent,
|
||||
ToolbarComponent,
|
||||
AlfrescoViewerComponent,
|
||||
ViewerToolbarActionsComponent,
|
||||
ViewerOpenWithComponent,
|
||||
ViewerSidebarComponent
|
||||
],
|
||||
selector: 'aca-viewer',
|
||||
templateUrl: './viewer.component.html',
|
||||
styleUrls: ['./viewer.component.scss'],
|
||||
@ -64,6 +74,8 @@ import { ViewerService } from '../../services/viewer.service';
|
||||
host: { class: 'app-viewer' }
|
||||
})
|
||||
export class AcaViewerComponent implements OnInit, OnDestroy {
|
||||
settings = inject(AppSettingsService);
|
||||
|
||||
private documentListService = inject(DocumentListService);
|
||||
|
||||
private _versionsApi: VersionsApi;
|
||||
|
@ -23,13 +23,20 @@
|
||||
*/
|
||||
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { AppConfigService } from '@alfresco/adf-core';
|
||||
import { AppConfigService, CloseButtonPosition } from '@alfresco/adf-core';
|
||||
import { AlfrescoMimeType, DefaultMimeTypes } from '../constants/mime-types';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class AppSettingsService {
|
||||
private appConfig = inject(AppConfigService);
|
||||
|
||||
/**
|
||||
* Get the application copyright text from the app settings.
|
||||
*/
|
||||
get appCopyright(): string {
|
||||
return this.appConfig.get<string>('application.copyright', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the AOS (Alfresco Office Services) host URL from the app settings.
|
||||
*/
|
||||
@ -98,6 +105,34 @@ export class AppSettingsService {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the viewer close button position from the app settings.
|
||||
*/
|
||||
get viewerCloseButtonPosition(): CloseButtonPosition {
|
||||
return this.appConfig.get('viewer.closeButtonPosition', CloseButtonPosition.Right);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the viewer max retries from the app settings.
|
||||
*/
|
||||
get viewerMaxRetries(): number {
|
||||
return this.appConfig.get<number>('viewer.maxRetries', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enabled state of the comment feature for upload dialog
|
||||
*/
|
||||
get uploadAllowComments(): boolean {
|
||||
return this.appConfig.get<boolean>('adf-version-manager.allowComments', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enabled state of the download feature for upload dialog
|
||||
*/
|
||||
get uploadAllowDownload(): boolean {
|
||||
return this.appConfig.get<boolean>('adf-version-manager.allowDownload', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the enablement of the file auto tryDownload feature from the app settings.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user