mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +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:
parent
b0561a2453
commit
ae126475f7
@ -26,7 +26,7 @@ import {
|
|||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { NodeEntry, Node } from '@alfresco/js-api';
|
import { NodeEntry, Node } from '@alfresco/js-api';
|
||||||
import { BehaviorSubject, Subject } from 'rxjs';
|
import { BehaviorSubject, Subject } from 'rxjs';
|
||||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
import { NodesApiService } from '@alfresco/adf-core';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -52,12 +52,12 @@ export class NameColumnComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
private onDestroy$ = new Subject<boolean>();
|
private onDestroy$ = new Subject<boolean>();
|
||||||
|
|
||||||
constructor(private element: ElementRef, private alfrescoApiService: AlfrescoApiService) {}
|
constructor(private element: ElementRef, private nodesApiService: NodesApiService) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.updateValue();
|
this.updateValue();
|
||||||
|
|
||||||
this.alfrescoApiService.nodeUpdated
|
this.nodesApiService.nodeUpdated
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe((node: Node) => {
|
.subscribe((node: Node) => {
|
||||||
const row = this.context.row;
|
const row = this.context.row;
|
||||||
|
@ -124,6 +124,19 @@ v6.0.0 and after:
|
|||||||
````
|
````
|
||||||
]})
|
]})
|
||||||
```
|
```
|
||||||
|
### nodeUpdated Subject
|
||||||
|
The nodeUpdated Subject has been moved from AlfrescoApiService to NodesApiService
|
||||||
|
|
||||||
|
v6.0.0 and before:
|
||||||
|
```
|
||||||
|
this.alfrescoApiService.nodeUpdated.pipe .....
|
||||||
|
```
|
||||||
|
|
||||||
|
v6.0.0 and after:
|
||||||
|
|
||||||
|
```
|
||||||
|
this.nodesApiService.nodeUpdated.pipe .....
|
||||||
|
```
|
||||||
|
|
||||||
## Renamed items
|
## Renamed items
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
import { MinimalNode } from '@alfresco/js-api';
|
import { MinimalNode } from '@alfresco/js-api';
|
||||||
import { TestBed } from '@angular/core/testing';
|
import { TestBed } from '@angular/core/testing';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { AlfrescoApiService, NodesApiService, setupTestBed } from '@alfresco/adf-core';
|
import { NodesApiService, setupTestBed } from '@alfresco/adf-core';
|
||||||
import { EMPTY, of } from 'rxjs';
|
import { EMPTY, of } from 'rxjs';
|
||||||
import { ContentTestingModule } from '../../testing/content.testing.module';
|
import { ContentTestingModule } from '../../testing/content.testing.module';
|
||||||
import { NodeAspectService } from './node-aspect.service';
|
import { NodeAspectService } from './node-aspect.service';
|
||||||
@ -30,7 +30,6 @@ describe('NodeAspectService', () => {
|
|||||||
let dialogAspectListService: DialogAspectListService;
|
let dialogAspectListService: DialogAspectListService;
|
||||||
let nodeAspectService: NodeAspectService;
|
let nodeAspectService: NodeAspectService;
|
||||||
let nodeApiService: NodesApiService;
|
let nodeApiService: NodesApiService;
|
||||||
let alfrescoApiService: AlfrescoApiService;
|
|
||||||
let cardViewContentUpdateService: CardViewContentUpdateService;
|
let cardViewContentUpdateService: CardViewContentUpdateService;
|
||||||
|
|
||||||
setupTestBed({
|
setupTestBed({
|
||||||
@ -44,7 +43,6 @@ describe('NodeAspectService', () => {
|
|||||||
dialogAspectListService = TestBed.inject(DialogAspectListService);
|
dialogAspectListService = TestBed.inject(DialogAspectListService);
|
||||||
nodeAspectService = TestBed.inject(NodeAspectService);
|
nodeAspectService = TestBed.inject(NodeAspectService);
|
||||||
nodeApiService = TestBed.inject(NodesApiService);
|
nodeApiService = TestBed.inject(NodesApiService);
|
||||||
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
|
||||||
cardViewContentUpdateService = TestBed.inject(CardViewContentUpdateService);
|
cardViewContentUpdateService = TestBed.inject(CardViewContentUpdateService);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -79,7 +77,7 @@ describe('NodeAspectService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should send and update node event once the node has been updated', async () => {
|
it('should send and update node event once the node has been updated', async () => {
|
||||||
await alfrescoApiService.nodeUpdated.subscribe((nodeUpdated) => {
|
await nodeApiService.nodeUpdated.subscribe((nodeUpdated) => {
|
||||||
expect(nodeUpdated.id).toBe('fake-node-id');
|
expect(nodeUpdated.id).toBe('fake-node-id');
|
||||||
expect(nodeUpdated.aspectNames).toEqual(['a', 'b', 'c']);
|
expect(nodeUpdated.aspectNames).toEqual(['a', 'b', 'c']);
|
||||||
});
|
});
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { AlfrescoApiService, NodesApiService } from '@alfresco/adf-core';
|
import { NodesApiService } from '@alfresco/adf-core';
|
||||||
import { DialogAspectListService } from './dialog-aspect-list.service';
|
import { DialogAspectListService } from './dialog-aspect-list.service';
|
||||||
import { CardViewContentUpdateService } from '../../services/card-view-content-update.service';
|
import { CardViewContentUpdateService } from '../../services/card-view-content-update.service';
|
||||||
|
|
||||||
@ -25,8 +25,7 @@ import { CardViewContentUpdateService } from '../../services/card-view-content-u
|
|||||||
})
|
})
|
||||||
export class NodeAspectService {
|
export class NodeAspectService {
|
||||||
|
|
||||||
constructor(private alfrescoApiService: AlfrescoApiService,
|
constructor(private nodesApiService: NodesApiService,
|
||||||
private nodesApiService: NodesApiService,
|
|
||||||
private dialogAspectListService: DialogAspectListService,
|
private dialogAspectListService: DialogAspectListService,
|
||||||
private cardViewContentUpdateService: CardViewContentUpdateService) {
|
private cardViewContentUpdateService: CardViewContentUpdateService) {
|
||||||
}
|
}
|
||||||
@ -34,7 +33,7 @@ export class NodeAspectService {
|
|||||||
updateNodeAspects(nodeId: string, selectorAutoFocusedOnClose?: string) {
|
updateNodeAspects(nodeId: string, selectorAutoFocusedOnClose?: string) {
|
||||||
this.dialogAspectListService.openAspectListDialog(nodeId, selectorAutoFocusedOnClose).subscribe((aspectList) => {
|
this.dialogAspectListService.openAspectListDialog(nodeId, selectorAutoFocusedOnClose).subscribe((aspectList) => {
|
||||||
this.nodesApiService.updateNode(nodeId, { aspectNames: [...aspectList] }).subscribe((updatedNode) => {
|
this.nodesApiService.updateNode(nodeId, { aspectNames: [...aspectList] }).subscribe((updatedNode) => {
|
||||||
this.alfrescoApiService.nodeUpdated.next(updatedNode);
|
this.nodesApiService.nodeUpdated.next(updatedNode);
|
||||||
this.cardViewContentUpdateService.updateNodeAspect(updatedNode);
|
this.cardViewContentUpdateService.updateNodeAspect(updatedNode);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -22,7 +22,6 @@ import {
|
|||||||
CardViewItem,
|
CardViewItem,
|
||||||
NodesApiService,
|
NodesApiService,
|
||||||
LogService,
|
LogService,
|
||||||
AlfrescoApiService,
|
|
||||||
TranslationService,
|
TranslationService,
|
||||||
AppConfigService,
|
AppConfigService,
|
||||||
CardViewBaseItemModel,
|
CardViewBaseItemModel,
|
||||||
@ -100,7 +99,6 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
private cardViewContentUpdateService: CardViewContentUpdateService,
|
private cardViewContentUpdateService: CardViewContentUpdateService,
|
||||||
private nodesApiService: NodesApiService,
|
private nodesApiService: NodesApiService,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
private alfrescoApiService: AlfrescoApiService,
|
|
||||||
private translationService: TranslationService,
|
private translationService: TranslationService,
|
||||||
private appConfig: AppConfigService
|
private appConfig: AppConfigService
|
||||||
) {
|
) {
|
||||||
@ -212,7 +210,7 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
this.revertChanges();
|
this.revertChanges();
|
||||||
Object.assign(this.node, updatedNode);
|
Object.assign(this.node, updatedNode);
|
||||||
this.alfrescoApiService.nodeUpdated.next(this.node);
|
this.nodesApiService.nodeUpdated.next(this.node);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ import {
|
|||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { NodeEntry, Site } from '@alfresco/js-api';
|
import { NodeEntry, Site } from '@alfresco/js-api';
|
||||||
import { ShareDataRow } from '../../data/share-data-row.model';
|
import { ShareDataRow } from '../../data/share-data-row.model';
|
||||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
import { NodesApiService } from '@alfresco/adf-core';
|
||||||
import { BehaviorSubject, Subject } from 'rxjs';
|
import { BehaviorSubject, Subject } from 'rxjs';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
|
||||||
@ -63,13 +63,13 @@ export class LibraryNameColumnComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private element: ElementRef,
|
private element: ElementRef,
|
||||||
private alfrescoApiService: AlfrescoApiService
|
private nodesApiService: NodesApiService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.updateValue();
|
this.updateValue();
|
||||||
|
|
||||||
this.alfrescoApiService.nodeUpdated
|
this.nodesApiService.nodeUpdated
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe(node => {
|
.subscribe(node => {
|
||||||
const row: ShareDataRow = this.context.row;
|
const row: ShareDataRow = this.context.row;
|
||||||
|
@ -24,7 +24,7 @@ import {
|
|||||||
OnDestroy
|
OnDestroy
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { BehaviorSubject, Subject } from 'rxjs';
|
import { BehaviorSubject, Subject } from 'rxjs';
|
||||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
import { NodesApiService } from '@alfresco/adf-core';
|
||||||
import { SiteEntry, Site } from '@alfresco/js-api';
|
import { SiteEntry, Site } from '@alfresco/js-api';
|
||||||
import { ShareDataRow } from '../../data/share-data-row.model';
|
import { ShareDataRow } from '../../data/share-data-row.model';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
@ -48,12 +48,12 @@ export class LibraryRoleColumnComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
private onDestroy$ = new Subject<boolean>();
|
private onDestroy$ = new Subject<boolean>();
|
||||||
|
|
||||||
constructor(private api: AlfrescoApiService) {}
|
constructor(private nodesApiService: NodesApiService) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.updateValue();
|
this.updateValue();
|
||||||
|
|
||||||
this.api.nodeUpdated
|
this.nodesApiService.nodeUpdated
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe(node => {
|
.subscribe(node => {
|
||||||
const row: ShareDataRow = this.context.row;
|
const row: ShareDataRow = this.context.row;
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, Input, OnInit, OnDestroy } from '@angular/core';
|
import { Component, Input, OnInit, OnDestroy } from '@angular/core';
|
||||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
import { NodesApiService } from '@alfresco/adf-core';
|
||||||
import { BehaviorSubject, Subject } from 'rxjs';
|
import { BehaviorSubject, Subject } from 'rxjs';
|
||||||
import { Site, SiteEntry } from '@alfresco/js-api';
|
import { Site, SiteEntry } from '@alfresco/js-api';
|
||||||
import { ShareDataRow } from '../../data/share-data-row.model';
|
import { ShareDataRow } from '../../data/share-data-row.model';
|
||||||
@ -39,12 +39,12 @@ export class LibraryStatusColumnComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
private onDestroy$ = new Subject<boolean>();
|
private onDestroy$ = new Subject<boolean>();
|
||||||
|
|
||||||
constructor(private api: AlfrescoApiService) {}
|
constructor(private nodesApiService: NodesApiService) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.updateValue();
|
this.updateValue();
|
||||||
|
|
||||||
this.api.nodeUpdated
|
this.nodesApiService.nodeUpdated
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe(node => {
|
.subscribe(node => {
|
||||||
const row: ShareDataRow = this.context.row;
|
const row: ShareDataRow = this.context.row;
|
||||||
|
@ -26,7 +26,7 @@ import {
|
|||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { NodeEntry } from '@alfresco/js-api';
|
import { NodeEntry } from '@alfresco/js-api';
|
||||||
import { BehaviorSubject, Subject } from 'rxjs';
|
import { BehaviorSubject, Subject } from 'rxjs';
|
||||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
import { NodesApiService } from '@alfresco/adf-core';
|
||||||
import { ShareDataRow } from '../../data/share-data-row.model';
|
import { ShareDataRow } from '../../data/share-data-row.model';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
|
||||||
@ -61,12 +61,12 @@ export class NameColumnComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
private onDestroy$ = new Subject<boolean>();
|
private onDestroy$ = new Subject<boolean>();
|
||||||
|
|
||||||
constructor(private element: ElementRef, private alfrescoApiService: AlfrescoApiService) {}
|
constructor(private element: ElementRef, private nodesApiService: NodesApiService) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.updateValue();
|
this.updateValue();
|
||||||
|
|
||||||
this.alfrescoApiService.nodeUpdated
|
this.nodesApiService.nodeUpdated
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe(node => {
|
.subscribe(node => {
|
||||||
const row: ShareDataRow = this.context.row;
|
const row: ShareDataRow = this.context.row;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { AlfrescoApiService, setupTestBed } from '@alfresco/adf-core';
|
import { NodesApiService, setupTestBed } from '@alfresco/adf-core';
|
||||||
import { Node, VersionPaging } from '@alfresco/js-api';
|
import { Node, VersionPaging } from '@alfresco/js-api';
|
||||||
import { VersionManagerComponent } from './version-manager.component';
|
import { VersionManagerComponent } from './version-manager.component';
|
||||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||||
@ -28,7 +28,7 @@ describe('VersionManagerComponent', () => {
|
|||||||
let component: VersionManagerComponent;
|
let component: VersionManagerComponent;
|
||||||
let fixture: ComponentFixture<VersionManagerComponent>;
|
let fixture: ComponentFixture<VersionManagerComponent>;
|
||||||
let spyOnListVersionHistory: jasmine.Spy;
|
let spyOnListVersionHistory: jasmine.Spy;
|
||||||
let alfrescoApiService: AlfrescoApiService;
|
let nodesApiService: NodesApiService;
|
||||||
|
|
||||||
const expectedComment = 'test-version-comment';
|
const expectedComment = 'test-version-comment';
|
||||||
const node: Node = new Node({
|
const node: Node = new Node({
|
||||||
@ -57,7 +57,7 @@ describe('VersionManagerComponent', () => {
|
|||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
component.node = node;
|
component.node = node;
|
||||||
|
|
||||||
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
nodesApiService = TestBed.inject(NodesApiService);
|
||||||
spyOnListVersionHistory = spyOn(component.versionListComponent['versionsApi'], 'listVersionHistory').and
|
spyOnListVersionHistory = spyOn(component.versionListComponent['versionsApi'], 'listVersionHistory').and
|
||||||
.callFake(() => Promise.resolve(new VersionPaging({ list: { entries: [ versionEntry ] }})));
|
.callFake(() => Promise.resolve(new VersionPaging({ list: { entries: [ versionEntry ] }})));
|
||||||
});
|
});
|
||||||
@ -102,7 +102,7 @@ describe('VersionManagerComponent', () => {
|
|||||||
|
|
||||||
it('should emit nodeUpdated event upon successful upload of a new version', () => {
|
it('should emit nodeUpdated event upon successful upload of a new version', () => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
alfrescoApiService.nodeUpdated.subscribe((res) => {
|
nodesApiService.nodeUpdated.subscribe((res) => {
|
||||||
expect(res).toEqual(node);
|
expect(res).toEqual(node);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
import { Component, Input, ViewEncapsulation, ViewChild, Output, EventEmitter, OnInit } from '@angular/core';
|
import { Component, Input, ViewEncapsulation, ViewChild, Output, EventEmitter, OnInit } from '@angular/core';
|
||||||
import { Node } from '@alfresco/js-api';
|
import { Node } from '@alfresco/js-api';
|
||||||
import { VersionListComponent } from './version-list.component';
|
import { VersionListComponent } from './version-list.component';
|
||||||
import { ContentService, AlfrescoApiService, FileUploadErrorEvent } from '@alfresco/adf-core';
|
import { ContentService, FileUploadErrorEvent, NodesApiService } from '@alfresco/adf-core';
|
||||||
import { trigger, state, style, animate, transition } from '@angular/animations';
|
import { trigger, state, style, animate, transition } from '@angular/animations';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -85,7 +85,7 @@ export class VersionManagerComponent implements OnInit {
|
|||||||
uploadState: string = 'close';
|
uploadState: string = 'close';
|
||||||
|
|
||||||
constructor(private contentService: ContentService,
|
constructor(private contentService: ContentService,
|
||||||
private alfrescoApiService: AlfrescoApiService) {
|
private nodesApiService: NodesApiService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@ -95,7 +95,7 @@ export class VersionManagerComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
refresh(node: Node) {
|
refresh(node: Node) {
|
||||||
this.alfrescoApiService.nodeUpdated.next(node);
|
this.nodesApiService.nodeUpdated.next(node);
|
||||||
this.versionListComponent.loadVersionHistory();
|
this.versionListComponent.loadVersionHistory();
|
||||||
this.uploadSuccess.emit(node);
|
this.uploadSuccess.emit(node);
|
||||||
this.uploadState = 'close';
|
this.uploadState = 'close';
|
||||||
@ -104,7 +104,7 @@ export class VersionManagerComponent implements OnInit {
|
|||||||
onUploadSuccess(event: any) {
|
onUploadSuccess(event: any) {
|
||||||
this.showVersionComparison = false;
|
this.showVersionComparison = false;
|
||||||
this.newFileVersion = null;
|
this.newFileVersion = null;
|
||||||
this.alfrescoApiService.nodeUpdated.next(event.value.entry);
|
this.nodesApiService.nodeUpdated.next(event.value.entry);
|
||||||
this.versionListComponent.loadVersionHistory();
|
this.versionListComponent.loadVersionHistory();
|
||||||
this.uploadSuccess.emit(event.value.entry);
|
this.uploadSuccess.emit(event.value.entry);
|
||||||
this.uploadState = 'close';
|
this.uploadState = 'close';
|
||||||
|
@ -26,9 +26,9 @@ import {
|
|||||||
import { DataColumn } from '../../data/data-column.model';
|
import { DataColumn } from '../../data/data-column.model';
|
||||||
import { DataRow } from '../../data/data-row.model';
|
import { DataRow } from '../../data/data-row.model';
|
||||||
import { DataTableAdapter } from '../../data/datatable-adapter';
|
import { DataTableAdapter } from '../../data/datatable-adapter';
|
||||||
import { AlfrescoApiService } from '../../../services/alfresco-api.service';
|
|
||||||
import { BehaviorSubject, Subject } from 'rxjs';
|
import { BehaviorSubject, Subject } from 'rxjs';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
import { NodesApiService } from '../../../services/nodes-api.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-datatable-cell',
|
selector: 'adf-datatable-cell',
|
||||||
@ -82,11 +82,11 @@ export class DataTableCellComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
protected onDestroy$ = new Subject<boolean>();
|
protected onDestroy$ = new Subject<boolean>();
|
||||||
|
|
||||||
constructor(protected alfrescoApiService: AlfrescoApiService) {}
|
constructor(protected nodesApiService: NodesApiService) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.updateValue();
|
this.updateValue();
|
||||||
this.alfrescoApiService.nodeUpdated
|
this.nodesApiService.nodeUpdated
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe(node => {
|
.subscribe(node => {
|
||||||
if (this.row && node && node.id) {
|
if (this.row && node && node.id) {
|
||||||
|
@ -21,7 +21,7 @@ import {
|
|||||||
UserPreferencesService,
|
UserPreferencesService,
|
||||||
UserPreferenceValues
|
UserPreferenceValues
|
||||||
} from '../../../services/user-preferences.service';
|
} 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 { AppConfigService } from '../../../app-config/app-config.service';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
|
||||||
@ -65,10 +65,10 @@ export class DateCellComponent extends DataTableCellComponent {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
userPreferenceService: UserPreferencesService,
|
userPreferenceService: UserPreferencesService,
|
||||||
alfrescoApiService: AlfrescoApiService,
|
nodesApiService: NodesApiService,
|
||||||
appConfig: AppConfigService
|
appConfig: AppConfigService
|
||||||
) {
|
) {
|
||||||
super(alfrescoApiService);
|
super(nodesApiService);
|
||||||
|
|
||||||
this.dateFormat = appConfig.get('dateValues.defaultDateFormat', DateCellComponent.DATE_FORMAT);
|
this.dateFormat = appConfig.get('dateValues.defaultDateFormat', DateCellComponent.DATE_FORMAT);
|
||||||
this.tooltipDateFormat = appConfig.get('dateValues.defaultTooltipDateFormat', DateCellComponent.DATE_FORMAT);
|
this.tooltipDateFormat = appConfig.get('dateValues.defaultTooltipDateFormat', DateCellComponent.DATE_FORMAT);
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import { Component, ViewEncapsulation } from '@angular/core';
|
import { Component, ViewEncapsulation } from '@angular/core';
|
||||||
import { DataTableCellComponent } from '../datatable-cell/datatable-cell.component';
|
import { DataTableCellComponent } from '../datatable-cell/datatable-cell.component';
|
||||||
import { AlfrescoApiService } from '../../../services/alfresco-api.service';
|
import { NodesApiService } from '../../../services/nodes-api.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-filesize-cell',
|
selector: 'adf-filesize-cell',
|
||||||
@ -33,7 +33,7 @@ import { AlfrescoApiService } from '../../../services/alfresco-api.service';
|
|||||||
host: { class: 'adf-filesize-cell' }
|
host: { class: 'adf-filesize-cell' }
|
||||||
})
|
})
|
||||||
export class FileSizeCellComponent extends DataTableCellComponent {
|
export class FileSizeCellComponent extends DataTableCellComponent {
|
||||||
constructor(alfrescoApiService: AlfrescoApiService) {
|
constructor(nodesApiService: NodesApiService) {
|
||||||
super(alfrescoApiService);
|
super(nodesApiService);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ import { ChangeDetectionStrategy, Component, OnInit, ViewEncapsulation, Input }
|
|||||||
import { DataTableCellComponent } from '../datatable-cell/datatable-cell.component';
|
import { DataTableCellComponent } from '../datatable-cell/datatable-cell.component';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { EditJsonDialogComponent, EditJsonDialogSettings } from '../../../dialogs/edit-json/edit-json.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({
|
@Component({
|
||||||
selector: 'adf-json-cell',
|
selector: 'adf-json-cell',
|
||||||
@ -45,9 +45,9 @@ export class JsonCellComponent extends DataTableCellComponent implements OnInit
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private dialog: MatDialog,
|
private dialog: MatDialog,
|
||||||
alfrescoApiService: AlfrescoApiService
|
nodesApiService: NodesApiService
|
||||||
) {
|
) {
|
||||||
super(alfrescoApiService);
|
super(nodesApiService);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
@ -24,7 +24,7 @@ import {
|
|||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { PathInfoEntity } from '@alfresco/js-api';
|
import { PathInfoEntity } from '@alfresco/js-api';
|
||||||
import { DataTableCellComponent } from '../datatable-cell/datatable-cell.component';
|
import { DataTableCellComponent } from '../datatable-cell/datatable-cell.component';
|
||||||
import { AlfrescoApiService } from '../../../services/alfresco-api.service';
|
import { NodesApiService } from '../../../services/nodes-api.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-location-cell',
|
selector: 'adf-location-cell',
|
||||||
@ -43,8 +43,8 @@ export class LocationCellComponent extends DataTableCellComponent implements OnI
|
|||||||
@Input()
|
@Input()
|
||||||
link: any[];
|
link: any[];
|
||||||
|
|
||||||
constructor(alfrescoApiService: AlfrescoApiService) {
|
constructor(nodesApiService: NodesApiService) {
|
||||||
super(alfrescoApiService);
|
super(nodesApiService);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
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 { 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 { OauthConfigModel } from '../models/oauth-config.model';
|
||||||
import { StorageService } from './storage.service';
|
import { StorageService } from './storage.service';
|
||||||
import { OpenidConfiguration } from './openid-configuration.interface';
|
import { OpenidConfiguration } from './openid-configuration.interface';
|
||||||
@ -27,10 +27,6 @@ import { OpenidConfiguration } from './openid-configuration.interface';
|
|||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class AlfrescoApiService {
|
export class AlfrescoApiService {
|
||||||
/**
|
|
||||||
* Publish/subscribe to events related to node updates.
|
|
||||||
*/
|
|
||||||
nodeUpdated = new Subject<Node>();
|
|
||||||
|
|
||||||
alfrescoApiInitialized: ReplaySubject<boolean> = new ReplaySubject(1);
|
alfrescoApiInitialized: ReplaySubject<boolean> = new ReplaySubject(1);
|
||||||
|
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { MinimalNode, NodeEntry, NodePaging, NodesApi, TrashcanApi } from '@alfresco/js-api';
|
import { MinimalNode, NodeEntry, NodePaging, NodesApi, TrashcanApi, Node } from '@alfresco/js-api';
|
||||||
import { from, Observable, throwError } from 'rxjs';
|
import { Subject, from, Observable, throwError } from 'rxjs';
|
||||||
import { AlfrescoApiService } from './alfresco-api.service';
|
import { AlfrescoApiService } from './alfresco-api.service';
|
||||||
import { UserPreferencesService } from './user-preferences.service';
|
import { UserPreferencesService } from './user-preferences.service';
|
||||||
import { catchError, map } from 'rxjs/operators';
|
import { catchError, map } from 'rxjs/operators';
|
||||||
@ -28,6 +28,11 @@ import { NodeMetadata } from '../models/node-metadata.model';
|
|||||||
})
|
})
|
||||||
export class NodesApiService {
|
export class NodesApiService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Publish/subscribe to events related to node updates.
|
||||||
|
*/
|
||||||
|
nodeUpdated = new Subject<Node>();
|
||||||
|
|
||||||
_trashcanApi: TrashcanApi;
|
_trashcanApi: TrashcanApi;
|
||||||
get trashcanApi(): TrashcanApi {
|
get trashcanApi(): TrashcanApi {
|
||||||
this._trashcanApi = this._trashcanApi ?? new TrashcanApi(this.apiService.getInstance());
|
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 { SpyLocation } from '@angular/common/testing';
|
||||||
import { Component, ViewChild } from '@angular/core';
|
import { Component, ViewChild } from '@angular/core';
|
||||||
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
|
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
|
||||||
import { AlfrescoApiService, RenditionsService } from '../../services';
|
import { NodesApiService, RenditionsService } from '../../services';
|
||||||
|
|
||||||
import { throwError } from 'rxjs';
|
import { throwError } from 'rxjs';
|
||||||
import { EventMock } from '../../mock/event.mock';
|
import { EventMock } from '../../mock/event.mock';
|
||||||
@ -153,7 +153,7 @@ describe('ViewerComponent', () => {
|
|||||||
|
|
||||||
let component: ViewerComponent;
|
let component: ViewerComponent;
|
||||||
let fixture: ComponentFixture<ViewerComponent>;
|
let fixture: ComponentFixture<ViewerComponent>;
|
||||||
let alfrescoApiService: AlfrescoApiService;
|
let nodesApiService: NodesApiService;
|
||||||
let element: HTMLElement;
|
let element: HTMLElement;
|
||||||
let dialog: MatDialog;
|
let dialog: MatDialog;
|
||||||
let uploadService: UploadService;
|
let uploadService: UploadService;
|
||||||
@ -192,8 +192,8 @@ describe('ViewerComponent', () => {
|
|||||||
element = fixture.nativeElement;
|
element = fixture.nativeElement;
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
|
||||||
|
nodesApiService = TestBed.inject(NodesApiService);
|
||||||
uploadService = TestBed.inject(UploadService);
|
uploadService = TestBed.inject(UploadService);
|
||||||
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
|
||||||
dialog = TestBed.inject(MatDialog);
|
dialog = TestBed.inject(MatDialog);
|
||||||
extensionService = TestBed.inject(AppExtensionService);
|
extensionService = TestBed.inject(AppExtensionService);
|
||||||
});
|
});
|
||||||
@ -609,15 +609,15 @@ describe('ViewerComponent', () => {
|
|||||||
|
|
||||||
expect(component.fileTitle).toBe('file1');
|
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();
|
fixture.detectChanges();
|
||||||
expect(component.fileTitle).toBe('file2');
|
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();
|
fixture.detectChanges();
|
||||||
expect(component.fileTitle).toBe('file3');
|
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();
|
fixture.detectChanges();
|
||||||
expect(component.fileTitle).toBe('file3');
|
expect(component.fileTitle).toBe('file3');
|
||||||
expect(component.nodeId).toBe('id1');
|
expect(component.nodeId).toBe('id1');
|
||||||
|
@ -44,6 +44,7 @@ import { MatDialog } from '@angular/material/dialog';
|
|||||||
import { ContentService } from '../../services/content.service';
|
import { ContentService } from '../../services/content.service';
|
||||||
import { UploadService } from '../../services/upload.service';
|
import { UploadService } from '../../services/upload.service';
|
||||||
import { FileModel } from '../../models';
|
import { FileModel } from '../../models';
|
||||||
|
import { NodesApiService } from '../../services/nodes-api.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-viewer',
|
selector: 'adf-viewer',
|
||||||
@ -304,6 +305,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
constructor(private apiService: AlfrescoApiService,
|
constructor(private apiService: AlfrescoApiService,
|
||||||
|
private nodesApiService: NodesApiService,
|
||||||
private viewUtilService: ViewUtilService,
|
private viewUtilService: ViewUtilService,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
private extensionService: AppExtensionService,
|
private extensionService: AppExtensionService,
|
||||||
@ -320,7 +322,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.apiService.nodeUpdated.pipe(
|
this.nodesApiService.nodeUpdated.pipe(
|
||||||
filter((node) => node && node.id === this.nodeId &&
|
filter((node) => node && node.id === this.nodeId &&
|
||||||
(node.name !== this.fileName ||
|
(node.name !== this.fileName ||
|
||||||
this.getNodeVersionProperty(this.nodeEntry.entry) !== this.getNodeVersionProperty(node))),
|
this.getNodeVersionProperty(this.nodeEntry.entry) !== this.getNodeVersionProperty(node))),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user