mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-11486] move NodeUdpdate in nodeapiservice (#8077)
* move NodeUdpdate in nodeapiservice * fix * build fix * Update name-column.component.ts * Update viewer.component.spec.ts
This commit is contained in:
@@ -26,9 +26,9 @@ import {
|
||||
import { DataColumn } from '../../data/data-column.model';
|
||||
import { DataRow } from '../../data/data-row.model';
|
||||
import { DataTableAdapter } from '../../data/datatable-adapter';
|
||||
import { AlfrescoApiService } from '../../../services/alfresco-api.service';
|
||||
import { BehaviorSubject, Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { NodesApiService } from '../../../services/nodes-api.service';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-datatable-cell',
|
||||
@@ -82,11 +82,11 @@ export class DataTableCellComponent implements OnInit, OnDestroy {
|
||||
|
||||
protected onDestroy$ = new Subject<boolean>();
|
||||
|
||||
constructor(protected alfrescoApiService: AlfrescoApiService) {}
|
||||
constructor(protected nodesApiService: NodesApiService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.updateValue();
|
||||
this.alfrescoApiService.nodeUpdated
|
||||
this.nodesApiService.nodeUpdated
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.subscribe(node => {
|
||||
if (this.row && node && node.id) {
|
||||
|
@@ -21,7 +21,7 @@ import {
|
||||
UserPreferencesService,
|
||||
UserPreferenceValues
|
||||
} from '../../../services/user-preferences.service';
|
||||
import { AlfrescoApiService } from '../../../services/alfresco-api.service';
|
||||
import { NodesApiService } from '../../../services/nodes-api.service';
|
||||
import { AppConfigService } from '../../../app-config/app-config.service';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
|
||||
@@ -65,10 +65,10 @@ export class DateCellComponent extends DataTableCellComponent {
|
||||
|
||||
constructor(
|
||||
userPreferenceService: UserPreferencesService,
|
||||
alfrescoApiService: AlfrescoApiService,
|
||||
nodesApiService: NodesApiService,
|
||||
appConfig: AppConfigService
|
||||
) {
|
||||
super(alfrescoApiService);
|
||||
super(nodesApiService);
|
||||
|
||||
this.dateFormat = appConfig.get('dateValues.defaultDateFormat', DateCellComponent.DATE_FORMAT);
|
||||
this.tooltipDateFormat = appConfig.get('dateValues.defaultTooltipDateFormat', DateCellComponent.DATE_FORMAT);
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
import { Component, ViewEncapsulation } from '@angular/core';
|
||||
import { DataTableCellComponent } from '../datatable-cell/datatable-cell.component';
|
||||
import { AlfrescoApiService } from '../../../services/alfresco-api.service';
|
||||
import { NodesApiService } from '../../../services/nodes-api.service';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-filesize-cell',
|
||||
@@ -33,7 +33,7 @@ import { AlfrescoApiService } from '../../../services/alfresco-api.service';
|
||||
host: { class: 'adf-filesize-cell' }
|
||||
})
|
||||
export class FileSizeCellComponent extends DataTableCellComponent {
|
||||
constructor(alfrescoApiService: AlfrescoApiService) {
|
||||
super(alfrescoApiService);
|
||||
constructor(nodesApiService: NodesApiService) {
|
||||
super(nodesApiService);
|
||||
}
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ import { ChangeDetectionStrategy, Component, OnInit, ViewEncapsulation, Input }
|
||||
import { DataTableCellComponent } from '../datatable-cell/datatable-cell.component';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { EditJsonDialogComponent, EditJsonDialogSettings } from '../../../dialogs/edit-json/edit-json.dialog';
|
||||
import { AlfrescoApiService } from '../../../services/alfresco-api.service';
|
||||
import { NodesApiService } from '../../../services/nodes-api.service';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-json-cell',
|
||||
@@ -45,9 +45,9 @@ export class JsonCellComponent extends DataTableCellComponent implements OnInit
|
||||
|
||||
constructor(
|
||||
private dialog: MatDialog,
|
||||
alfrescoApiService: AlfrescoApiService
|
||||
nodesApiService: NodesApiService
|
||||
) {
|
||||
super(alfrescoApiService);
|
||||
super(nodesApiService);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
@@ -24,7 +24,7 @@ import {
|
||||
} from '@angular/core';
|
||||
import { PathInfoEntity } from '@alfresco/js-api';
|
||||
import { DataTableCellComponent } from '../datatable-cell/datatable-cell.component';
|
||||
import { AlfrescoApiService } from '../../../services/alfresco-api.service';
|
||||
import { NodesApiService } from '../../../services/nodes-api.service';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-location-cell',
|
||||
@@ -43,8 +43,8 @@ export class LocationCellComponent extends DataTableCellComponent implements OnI
|
||||
@Input()
|
||||
link: any[];
|
||||
|
||||
constructor(alfrescoApiService: AlfrescoApiService) {
|
||||
super(alfrescoApiService);
|
||||
constructor(nodesApiService: NodesApiService) {
|
||||
super(nodesApiService);
|
||||
}
|
||||
|
||||
/** @override */
|
||||
|
@@ -16,9 +16,9 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Node, AlfrescoApi, AlfrescoApiConfig } from '@alfresco/js-api';
|
||||
import { AlfrescoApi, AlfrescoApiConfig } from '@alfresco/js-api';
|
||||
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
|
||||
import { Subject, ReplaySubject } from 'rxjs';
|
||||
import { ReplaySubject } from 'rxjs';
|
||||
import { OauthConfigModel } from '../models/oauth-config.model';
|
||||
import { StorageService } from './storage.service';
|
||||
import { OpenidConfiguration } from './openid-configuration.interface';
|
||||
@@ -27,10 +27,6 @@ import { OpenidConfiguration } from './openid-configuration.interface';
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AlfrescoApiService {
|
||||
/**
|
||||
* Publish/subscribe to events related to node updates.
|
||||
*/
|
||||
nodeUpdated = new Subject<Node>();
|
||||
|
||||
alfrescoApiInitialized: ReplaySubject<boolean> = new ReplaySubject(1);
|
||||
|
||||
|
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MinimalNode, NodeEntry, NodePaging, NodesApi, TrashcanApi } from '@alfresco/js-api';
|
||||
import { from, Observable, throwError } from 'rxjs';
|
||||
import { MinimalNode, NodeEntry, NodePaging, NodesApi, TrashcanApi, Node } from '@alfresco/js-api';
|
||||
import { Subject, from, Observable, throwError } from 'rxjs';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import { UserPreferencesService } from './user-preferences.service';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
@@ -28,6 +28,11 @@ import { NodeMetadata } from '../models/node-metadata.model';
|
||||
})
|
||||
export class NodesApiService {
|
||||
|
||||
/**
|
||||
* Publish/subscribe to events related to node updates.
|
||||
*/
|
||||
nodeUpdated = new Subject<Node>();
|
||||
|
||||
_trashcanApi: TrashcanApi;
|
||||
get trashcanApi(): TrashcanApi {
|
||||
this._trashcanApi = this._trashcanApi ?? new TrashcanApi(this.apiService.getInstance());
|
||||
|
@@ -19,7 +19,7 @@ import { Location } from '@angular/common';
|
||||
import { SpyLocation } from '@angular/common/testing';
|
||||
import { Component, ViewChild } from '@angular/core';
|
||||
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
|
||||
import { AlfrescoApiService, RenditionsService } from '../../services';
|
||||
import { NodesApiService, RenditionsService } from '../../services';
|
||||
|
||||
import { throwError } from 'rxjs';
|
||||
import { EventMock } from '../../mock/event.mock';
|
||||
@@ -153,7 +153,7 @@ describe('ViewerComponent', () => {
|
||||
|
||||
let component: ViewerComponent;
|
||||
let fixture: ComponentFixture<ViewerComponent>;
|
||||
let alfrescoApiService: AlfrescoApiService;
|
||||
let nodesApiService: NodesApiService;
|
||||
let element: HTMLElement;
|
||||
let dialog: MatDialog;
|
||||
let uploadService: UploadService;
|
||||
@@ -192,8 +192,8 @@ describe('ViewerComponent', () => {
|
||||
element = fixture.nativeElement;
|
||||
component = fixture.componentInstance;
|
||||
|
||||
nodesApiService = TestBed.inject(NodesApiService);
|
||||
uploadService = TestBed.inject(UploadService);
|
||||
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
||||
dialog = TestBed.inject(MatDialog);
|
||||
extensionService = TestBed.inject(AppExtensionService);
|
||||
});
|
||||
@@ -609,15 +609,15 @@ describe('ViewerComponent', () => {
|
||||
|
||||
expect(component.fileTitle).toBe('file1');
|
||||
|
||||
alfrescoApiService.nodeUpdated.next({ id: 'id1', name: 'file2' } as any);
|
||||
nodesApiService.nodeUpdated.next({ id: 'id1', name: 'file2' } as any);
|
||||
fixture.detectChanges();
|
||||
expect(component.fileTitle).toBe('file2');
|
||||
|
||||
alfrescoApiService.nodeUpdated.next({ id: 'id1', name: 'file3' } as any);
|
||||
nodesApiService.nodeUpdated.next({ id: 'id1', name: 'file3' } as any);
|
||||
fixture.detectChanges();
|
||||
expect(component.fileTitle).toBe('file3');
|
||||
|
||||
alfrescoApiService.nodeUpdated.next({ id: 'id2', name: 'file4' } as any);
|
||||
nodesApiService.nodeUpdated.next({ id: 'id2', name: 'file4' } as any);
|
||||
fixture.detectChanges();
|
||||
expect(component.fileTitle).toBe('file3');
|
||||
expect(component.nodeId).toBe('id1');
|
||||
|
@@ -44,6 +44,7 @@ import { MatDialog } from '@angular/material/dialog';
|
||||
import { ContentService } from '../../services/content.service';
|
||||
import { UploadService } from '../../services/upload.service';
|
||||
import { FileModel } from '../../models';
|
||||
import { NodesApiService } from '../../services/nodes-api.service';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-viewer',
|
||||
@@ -304,6 +305,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
constructor(private apiService: AlfrescoApiService,
|
||||
private nodesApiService: NodesApiService,
|
||||
private viewUtilService: ViewUtilService,
|
||||
private logService: LogService,
|
||||
private extensionService: AppExtensionService,
|
||||
@@ -320,7 +322,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.apiService.nodeUpdated.pipe(
|
||||
this.nodesApiService.nodeUpdated.pipe(
|
||||
filter((node) => node && node.id === this.nodeId &&
|
||||
(node.name !== this.fileName ||
|
||||
this.getNodeVersionProperty(this.nodeEntry.entry) !== this.getNodeVersionProperty(node))),
|
||||
|
Reference in New Issue
Block a user