mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-3499] adding new dialog for external content file (#3799)
* [ADF-3499] start creation of login dialog component with extra auth service feature * [ADF-3499] adding new dialog for external content file * [ADF-3499] fixed condition for pop up and added prefix ticket * [ADF-3499] fixed smartfolder bug for content node selector * [ADF-3499] disabling preview after uploading for external resource files * [ADF-3499] fixed unit test for document list service * [ADF-3499] added unit test to new components * [ADF-3499] added translation and some fix * [ADF-3499] fixed labels * [ADF-3499] fixed problem with node and node entry for smart folders * [ADF-3499] fixed compilation problem
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* 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 { Subject } from 'rxjs/Subject';
|
||||
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
|
||||
|
||||
export interface AttachFileWidgetDialogComponentData {
|
||||
title: string;
|
||||
actionName?: string;
|
||||
selected: Subject<MinimalNodeEntryEntity[]>;
|
||||
ecmHost: string;
|
||||
context?: string;
|
||||
isSelectionValid?: (entry: MinimalNodeEntryEntity) => boolean;
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
<header
|
||||
mat-dialog-title
|
||||
data-automation-id="content-node-selector-title">{{data?.title}}
|
||||
</header>
|
||||
|
||||
<mat-dialog-content class="adf-login-dialog-content">
|
||||
<adf-login-dialog-panel id="attach-file-login-panel" #adfLoginPanel *ngIf="!isLoggedIn()">
|
||||
</adf-login-dialog-panel>
|
||||
<adf-content-node-selector-panel *ngIf="isLoggedIn()"
|
||||
id="attach-file-content-node"
|
||||
[isSelectionValid]="data?.isSelectionValid"
|
||||
(select)="onSelect($event)">
|
||||
</adf-content-node-selector-panel>
|
||||
</mat-dialog-content>
|
||||
|
||||
<mat-dialog-actions align="end">
|
||||
<button
|
||||
mat-button
|
||||
(click)="close()"
|
||||
data-automation-id="attach-file-dialog-actions-cancel">{{ 'ATTACH-FILE.ACTIONS.CANCEL' | translate }}
|
||||
</button>
|
||||
|
||||
<button *ngIf="!isLoggedIn()"
|
||||
mat-button
|
||||
(click)="performLogin()"
|
||||
data-automation-id="attach-file-dialog-actions-login">{{ 'ATTACH-FILE.ACTIONS.LOGIN' | translate }}
|
||||
</button>
|
||||
|
||||
<button *ngIf="isLoggedIn()"
|
||||
mat-button
|
||||
[disabled]="!chosenNode"
|
||||
class="choose-action"
|
||||
(click)="onClick($event)"
|
||||
data-automation-id="attach-file-dialog-actions-choose">{{ buttonActionName | translate }}
|
||||
</button>
|
||||
|
||||
</mat-dialog-actions>
|
@@ -0,0 +1,32 @@
|
||||
@mixin adf-attach-file-widget-dialog-component-theme($theme) {
|
||||
$primary: map-get($theme, primary);
|
||||
$foreground: map-get($theme, foreground);
|
||||
$background: map-get($theme, background);
|
||||
|
||||
.adf-attach-file-widget-dialog {
|
||||
|
||||
.mat-dialog-actions {
|
||||
|
||||
background-color: mat-color($background, background);
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
color: mat-color($foreground, secondary-text);
|
||||
|
||||
button {
|
||||
text-transform: uppercase;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.choose-action {
|
||||
|
||||
&[disabled] {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
&:enabled {
|
||||
color: mat-color($primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,150 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* 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 { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { MAT_DIALOG_DATA } from '@angular/material';
|
||||
import { ContentModule, ContentNodeSelectorPanelComponent } from '@alfresco/adf-content-services';
|
||||
import { EventEmitter } from '@angular/core';
|
||||
import { ProcessTestingModule } from '../testing/process.testing.module';
|
||||
import { AttachFileWidgetDialogComponent } from './attach-file-widget-dialog.component';
|
||||
import { setupTestBed, AuthenticationService, SitesService } from '@alfresco/adf-core';
|
||||
import { AttachFileWidgetDialogComponentData } from './attach-file-widget-dialog-component.interface';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { of } from 'rxjs';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
|
||||
|
||||
describe('AttachFileWidgetDialogComponent', () => {
|
||||
|
||||
let widget: AttachFileWidgetDialogComponent;
|
||||
let fixture: ComponentFixture<AttachFileWidgetDialogComponent>;
|
||||
let data: AttachFileWidgetDialogComponentData = {
|
||||
title: 'Move along citizen...',
|
||||
actionName: 'move',
|
||||
selected: new EventEmitter<any>(),
|
||||
ecmHost: 'http://fakeUrl.com/'
|
||||
};
|
||||
let element: HTMLInputElement;
|
||||
let authService: AuthenticationService;
|
||||
let siteService: SitesService;
|
||||
|
||||
let isLogged = false;
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
ProcessTestingModule,
|
||||
ContentModule.forRoot(),
|
||||
RouterTestingModule
|
||||
],
|
||||
providers: [
|
||||
{ provide: MAT_DIALOG_DATA, useValue: data }
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture = TestBed.createComponent(AttachFileWidgetDialogComponent);
|
||||
widget = fixture.componentInstance;
|
||||
element = fixture.nativeElement;
|
||||
authService = fixture.debugElement.injector.get(AuthenticationService);
|
||||
siteService = fixture.debugElement.injector.get(SitesService);
|
||||
spyOn(siteService, 'getSites').and.returnValue(of({ list: { entries: [] } }));
|
||||
spyOn(widget, 'isLoggedIn').and.callFake(() => {
|
||||
return isLogged;
|
||||
});
|
||||
}));
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
it('should be able to create the widget', () => {
|
||||
expect(widget).not.toBeNull();
|
||||
});
|
||||
|
||||
describe('When is not logged in', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
fixture.detectChanges();
|
||||
isLogged = false;
|
||||
}));
|
||||
|
||||
it('should show the login form', () => {
|
||||
expect(element.querySelector('#attach-file-login-panel')).not.toBeNull();
|
||||
expect(element.querySelector('#username')).not.toBeNull();
|
||||
expect(element.querySelector('#password')).not.toBeNull();
|
||||
expect(element.querySelector('button[data-automation-id="attach-file-dialog-actions-login"]')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should be able to login', (done) => {
|
||||
spyOn(authService, 'login').and.returnValue(of({ type: 'type', ticket: 'ticket'}));
|
||||
isLogged = true;
|
||||
let loginButton: HTMLButtonElement = element.querySelector('button[data-automation-id="attach-file-dialog-actions-login"]');
|
||||
let usernameInput: HTMLInputElement = element.querySelector('#username');
|
||||
let passwordInput: HTMLInputElement = element.querySelector('#password');
|
||||
usernameInput.value = 'fakse-user';
|
||||
passwordInput.value = 'fakse-user';
|
||||
usernameInput.dispatchEvent(new Event('input'));
|
||||
passwordInput.dispatchEvent(new Event('input'));
|
||||
loginButton.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(element.querySelector('#attach-file-content-node')).not.toBeNull();
|
||||
loginButton = element.querySelector('button[data-automation-id="attach-file-dialog-actions-login"]');
|
||||
let chooseButton = element.querySelector('button[data-automation-id="attach-file-dialog-actions-choose"]');
|
||||
expect(loginButton).toBeNull();
|
||||
expect(chooseButton).not.toBeNull();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('When is logged in', () => {
|
||||
|
||||
let contentNodePanel;
|
||||
|
||||
beforeEach(async(() => {
|
||||
isLogged = true;
|
||||
fixture.detectChanges();
|
||||
contentNodePanel = fixture.debugElement.query(By.directive(ContentNodeSelectorPanelComponent));
|
||||
}));
|
||||
|
||||
it('should show the content node selector', () => {
|
||||
expect(element.querySelector('#attach-file-content-node')).not.toBeNull();
|
||||
expect(element.querySelector('#username')).toBeNull();
|
||||
expect(element.querySelector('#password')).toBeNull();
|
||||
expect(element.querySelector('button[data-automation-id="attach-file-dialog-actions-choose"]')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should be able to select a file', (done) => {
|
||||
data.selected.subscribe((nodeList: MinimalNodeEntryEntity[]) => {
|
||||
expect(nodeList[0].id).toBe('fake');
|
||||
expect(nodeList[0].isFile).toBeTruthy();
|
||||
done();
|
||||
});
|
||||
let fakeNode: MinimalNodeEntryEntity = { id: 'fake', isFile: true};
|
||||
contentNodePanel.componentInstance.select.emit([fakeNode]);
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
let chooseButton: HTMLButtonElement = element.querySelector('button[data-automation-id="attach-file-dialog-actions-choose"]');
|
||||
chooseButton.click();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
@@ -0,0 +1,76 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* 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 { Component, Inject, ViewEncapsulation, ViewChild } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA } from '@angular/material';
|
||||
import { ExternalAlfrescoApiService, AlfrescoApiService, AuthenticationService, LoginDialogPanelComponent, SitesService, SearchService } from '@alfresco/adf-core';
|
||||
import { DocumentListService, ContentNodeSelectorService } from '@alfresco/adf-content-services';
|
||||
import { AttachFileWidgetDialogComponentData } from './attach-file-widget-dialog-component.interface';
|
||||
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-attach-file-widget-dialog',
|
||||
templateUrl: './attach-file-widget-dialog.component.html',
|
||||
styleUrls: ['./attach-file-widget-dialog.component.scss'],
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
providers: [ AuthenticationService,
|
||||
DocumentListService,
|
||||
SitesService,
|
||||
ContentNodeSelectorService,
|
||||
SearchService,
|
||||
{ provide: AlfrescoApiService, useClass: ExternalAlfrescoApiService} ]
|
||||
})
|
||||
export class AttachFileWidgetDialogComponent {
|
||||
|
||||
@ViewChild('adfLoginPanel')
|
||||
loginPanel: LoginDialogPanelComponent;
|
||||
|
||||
chosenNode: MinimalNodeEntryEntity[];
|
||||
buttonActionName;
|
||||
|
||||
constructor(@Inject(MAT_DIALOG_DATA) public data: AttachFileWidgetDialogComponentData,
|
||||
private externalApiService: AlfrescoApiService) {
|
||||
(<any> externalApiService).init(data.ecmHost, data.context);
|
||||
this.buttonActionName = data.actionName ? `ATTACH-FILE.ACTIONS.${data.actionName.toUpperCase()}` : 'ATTACH-FILE.ACTIONS.CHOOSE';
|
||||
}
|
||||
|
||||
isLoggedIn() {
|
||||
return this.externalApiService.getInstance().isLoggedIn();
|
||||
}
|
||||
|
||||
performLogin() {
|
||||
this.loginPanel.submitForm();
|
||||
}
|
||||
|
||||
close() {
|
||||
this.data.selected.complete();
|
||||
}
|
||||
|
||||
onSelect(nodeList: MinimalNodeEntryEntity[]) {
|
||||
if (nodeList && nodeList[0].isFile) {
|
||||
this.chosenNode = nodeList;
|
||||
} else {
|
||||
this.chosenNode = null;
|
||||
}
|
||||
}
|
||||
|
||||
onClick(event: any) {
|
||||
this.data.selected.next(this.chosenNode);
|
||||
this.data.selected.complete();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* 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 { MatDialog } from '@angular/material';
|
||||
import { AttachFileWidgetDialogService } from './attach-file-widget-dialog.service';
|
||||
import { Subject, of } from 'rxjs';
|
||||
import { setupTestBed } from '@alfresco/adf-core';
|
||||
import { ProcessModule } from '../process.module';
|
||||
|
||||
describe('AttachFileWidgetDialogService', () => {
|
||||
|
||||
let service: AttachFileWidgetDialogService;
|
||||
let materialDialog: MatDialog;
|
||||
let spyOnDialogOpen: jasmine.Spy;
|
||||
let afterOpenObservable: Subject<any>;
|
||||
|
||||
setupTestBed({
|
||||
imports: [ProcessModule.forRoot()]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
service = TestBed.get(AttachFileWidgetDialogService);
|
||||
materialDialog = TestBed.get(MatDialog);
|
||||
spyOnDialogOpen = spyOn(materialDialog, 'open').and.returnValue({
|
||||
afterOpen: () => afterOpenObservable,
|
||||
afterClosed: () => of({}),
|
||||
componentInstance: {
|
||||
error: new Subject<any>()
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to create the service', () => {
|
||||
expect(service).not.toBeNull();
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
|
||||
it('should be able to open the dialog when node has permission', () => {
|
||||
service.openLogin('fake-title', 'fake-action');
|
||||
expect(spyOnDialogOpen).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should be able to close the material dialog', () => {
|
||||
spyOn(materialDialog, 'closeAll');
|
||||
service.close();
|
||||
expect(materialDialog.closeAll).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
});
|
@@ -0,0 +1,74 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* 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 { MatDialog } from '@angular/material';
|
||||
import { EventEmitter, Injectable, Output } from '@angular/core';
|
||||
import { Subject, Observable } from 'rxjs';
|
||||
import { AttachFileWidgetDialogComponentData } from './attach-file-widget-dialog-component.interface';
|
||||
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
|
||||
import { AttachFileWidgetDialogComponent } from './attach-file-widget-dialog.component';
|
||||
|
||||
@Injectable()
|
||||
export class AttachFileWidgetDialogService {
|
||||
|
||||
/** Emitted when an error occurs. */
|
||||
@Output()
|
||||
error: EventEmitter<any> = new EventEmitter<any>();
|
||||
|
||||
constructor(private dialog: MatDialog) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a dialog to choose a file to upload.
|
||||
* @param action Name of the action to show in the title
|
||||
* @param contentEntry Item to upload
|
||||
* @returns Information about the chosen file(s)
|
||||
*/
|
||||
openLogin(ecmHost: string, actionName?: string, context?: string): Observable<MinimalNodeEntryEntity[]> {
|
||||
let titleString: string = `Please log in for ${ecmHost}`;
|
||||
const selected = new Subject<MinimalNodeEntryEntity[]>();
|
||||
selected.subscribe({
|
||||
complete: this.close.bind(this)
|
||||
});
|
||||
|
||||
const data: AttachFileWidgetDialogComponentData = {
|
||||
title : titleString,
|
||||
actionName,
|
||||
selected,
|
||||
ecmHost,
|
||||
context,
|
||||
isSelectionValid: this.isNodeFile.bind(this)
|
||||
};
|
||||
|
||||
this.openLoginDialog(data, 'adf-attach-file-widget-dialog', '630px');
|
||||
return selected;
|
||||
}
|
||||
|
||||
private openLoginDialog(data: AttachFileWidgetDialogComponentData, currentPanelClass: string, chosenWidth: string) {
|
||||
this.dialog.open(AttachFileWidgetDialogComponent, { data, panelClass: currentPanelClass, width: chosenWidth });
|
||||
}
|
||||
|
||||
/** Closes the currently open dialog. */
|
||||
close() {
|
||||
this.dialog.closeAll();
|
||||
}
|
||||
|
||||
private isNodeFile(entry: MinimalNodeEntryEntity): boolean {
|
||||
return entry.isFile;
|
||||
}
|
||||
|
||||
}
|
@@ -46,7 +46,7 @@
|
||||
<div *ngIf="!isDefinedSourceFolder()">
|
||||
<button mat-menu-item *ngFor="let repo of repositoryList"
|
||||
id="attach-{{repo?.name}}"
|
||||
(click)="openSelectDialog(repo.id, repo.name)">
|
||||
(click)="openSelectDialog(repo)">
|
||||
{{repo.name}}
|
||||
<mat-icon>
|
||||
<img class="adf-attach-widget__image-logo" src="../assets/images/alfresco-flower.svg">
|
||||
@@ -76,6 +76,7 @@
|
||||
</button>
|
||||
<mat-menu #fileActionMenu="matMenu" xPosition="before">
|
||||
<button id="{{'file-'+file.id+'-show-file'}}"
|
||||
[disabled]="file.isExternal"
|
||||
mat-menu-item (click)="onAttachFileClicked(file)">
|
||||
<mat-icon>image</mat-icon>
|
||||
<span>{{ 'FORM.FIELD.SHOW_FILE' | translate }}</span>
|
||||
|
@@ -26,12 +26,15 @@ import {
|
||||
ProcessContentService,
|
||||
ActivitiContentService,
|
||||
ContentService,
|
||||
FormEvent
|
||||
FormEvent,
|
||||
AppConfigValues,
|
||||
AppConfigService
|
||||
} from '@alfresco/adf-core';
|
||||
import { ContentNodeDialogService } from '@alfresco/adf-content-services';
|
||||
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
|
||||
import { from, zip, of } from 'rxjs';
|
||||
import { mergeMap } from 'rxjs/operators';
|
||||
import { AttachFileWidgetDialogService } from './attach-file-widget-dialog.service';
|
||||
|
||||
@Component({
|
||||
selector: 'attach-widget',
|
||||
@@ -61,7 +64,9 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
|
||||
public processContentService: ProcessContentService,
|
||||
private activitiContentService: ActivitiContentService,
|
||||
private contentService: ContentService,
|
||||
private contentDialog: ContentNodeDialogService) {
|
||||
private contentDialog: ContentNodeDialogService,
|
||||
private appConfigService: AppConfigService,
|
||||
private attachDialogService: AttachFileWidgetDialogService) {
|
||||
super(formService, logger, thumbnails, processContentService);
|
||||
}
|
||||
|
||||
@@ -150,6 +155,10 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
|
||||
}
|
||||
|
||||
onAttachFileClicked(file: any) {
|
||||
if (file.isExternal) {
|
||||
this.logger.info(`The file ${file.name} comes from an external source and cannot be showed at this moment`);
|
||||
return;
|
||||
}
|
||||
if (this.isTemporaryFile(file)) {
|
||||
this.formService.formContentClicked.next(file);
|
||||
} else {
|
||||
@@ -172,27 +181,41 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
|
||||
}
|
||||
}
|
||||
|
||||
openSelectDialog(repoId: string, repoName: string) {
|
||||
const accountIdentifier = 'alfresco-' + repoId + '-' + repoName;
|
||||
this.contentDialog.openFileBrowseDialogBySite().subscribe(
|
||||
(selections: MinimalNodeEntryEntity[]) => {
|
||||
this.tempFilesList.push(...selections);
|
||||
this.uploadFileFromCS(selections, accountIdentifier);
|
||||
});
|
||||
openSelectDialog(repository) {
|
||||
const accountIdentifier = 'alfresco-' + repository.id + '-' + repository.name;
|
||||
let currentECMHost = this.getDomainHost(this.appConfigService.get(AppConfigValues.ECMHOST));
|
||||
let chosenRepositoryHost = this.getDomainHost(repository.repositoryUrl);
|
||||
if (chosenRepositoryHost !== currentECMHost) {
|
||||
let formattedReporistoryHost = repository.repositoryUrl.replace('/alfresco', '');
|
||||
this.attachDialogService.openLogin(formattedReporistoryHost).subscribe(
|
||||
(selections: any[]) => {
|
||||
selections.forEach((node) => node.isExternal = true);
|
||||
this.tempFilesList.push(...selections);
|
||||
this.uploadFileFromCS(selections, accountIdentifier);
|
||||
});
|
||||
} else {
|
||||
this.contentDialog.openFileBrowseDialogBySite().subscribe(
|
||||
(selections: MinimalNodeEntryEntity[]) => {
|
||||
this.tempFilesList.push(...selections);
|
||||
this.uploadFileFromCS(selections, accountIdentifier);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private uploadFileFromCS(fileNodeList: MinimalNodeEntryEntity[], accountId: string, siteId?: string) {
|
||||
private uploadFileFromCS(fileNodeList: any[], accountId: string, siteId?: string) {
|
||||
const filesSaved = [];
|
||||
from(fileNodeList).pipe(
|
||||
mergeMap(node =>
|
||||
zip(
|
||||
of(node.content.mimeType),
|
||||
this.activitiContentService.applyAlfrescoNode(node, siteId, accountId)
|
||||
this.activitiContentService.applyAlfrescoNode(node, siteId, accountId),
|
||||
of(node.isExternal)
|
||||
)
|
||||
)
|
||||
)
|
||||
.subscribe(([mymeType, res]) => {
|
||||
.subscribe(([mymeType, res, isExternal]) => {
|
||||
res.mimeType = mymeType;
|
||||
res.isExternal = isExternal;
|
||||
filesSaved.push(res);
|
||||
},
|
||||
(error) => {
|
||||
@@ -205,4 +228,9 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
|
||||
});
|
||||
}
|
||||
|
||||
private getDomainHost(urlToCheck) {
|
||||
let result = urlToCheck.match('^(?:https?:\/\/)?(?:[^@\/\n]+@)?(?:www\.)?([^:\/?\n]+)');
|
||||
return result[1];
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -39,13 +39,15 @@ const fakeRepositoryListAnswer = [
|
||||
'authorized': true,
|
||||
'serviceId': 'alfresco-9999-SHAREME',
|
||||
'metaDataAllowed': true,
|
||||
'name': 'SHAREME'
|
||||
'name': 'SHAREME',
|
||||
'repositoryUrl' : 'http://localhost:0000/SHAREME'
|
||||
},
|
||||
{
|
||||
'authorized': true,
|
||||
'serviceId': 'alfresco-0000-GOKUSHARE',
|
||||
'metaDataAllowed': true,
|
||||
'name': 'GOKUSHARE'
|
||||
'name': 'GOKUSHARE',
|
||||
'repositoryUrl' : 'http://localhost:0000/GOKUSHARE'
|
||||
}];
|
||||
|
||||
const onlyLocalParams = {
|
||||
|
@@ -18,26 +18,32 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { MaterialModule } from '../material.module';
|
||||
import { CoreModule } from '@alfresco/adf-core';
|
||||
import { ContentNodeSelectorModule } from '@alfresco/adf-content-services';
|
||||
|
||||
import { AttachFileWidgetComponent } from './attach-file-widget.component';
|
||||
import { AttachFolderWidgetComponent } from './attach-folder-widget.component';
|
||||
import { AttachFileWidgetDialogComponent } from './attach-file-widget-dialog.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CoreModule.forChild(),
|
||||
ContentNodeSelectorModule,
|
||||
MaterialModule
|
||||
],
|
||||
entryComponents: [
|
||||
AttachFileWidgetComponent,
|
||||
AttachFolderWidgetComponent
|
||||
AttachFolderWidgetComponent,
|
||||
AttachFileWidgetDialogComponent
|
||||
],
|
||||
declarations: [
|
||||
AttachFileWidgetComponent,
|
||||
AttachFolderWidgetComponent
|
||||
AttachFolderWidgetComponent,
|
||||
AttachFileWidgetDialogComponent
|
||||
],
|
||||
exports: [
|
||||
AttachFileWidgetComponent,
|
||||
AttachFolderWidgetComponent
|
||||
AttachFolderWidgetComponent,
|
||||
AttachFileWidgetDialogComponent
|
||||
]
|
||||
})
|
||||
export class ContentWidgetModule {}
|
||||
|
@@ -17,5 +17,8 @@
|
||||
|
||||
export * from './attach-file-widget.component';
|
||||
export * from './attach-folder-widget.component';
|
||||
export * from './attach-file-widget-dialog-component.interface';
|
||||
export * from './attach-file-widget-dialog.component';
|
||||
export * from './attach-file-widget-dialog.service';
|
||||
|
||||
export * from './content-widget.module';
|
||||
|
Reference in New Issue
Block a user