mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
ACS-7407: upload as standalone
This commit is contained in:
@@ -22,7 +22,6 @@ import { CoreModule, SearchTextModule, provideTranslations } from '@alfresco/adf
|
|||||||
import { MaterialModule } from './material.module';
|
import { MaterialModule } from './material.module';
|
||||||
import { TagModule } from './tag/tag.module';
|
import { TagModule } from './tag/tag.module';
|
||||||
import { DocumentListModule } from './document-list/document-list.module';
|
import { DocumentListModule } from './document-list/document-list.module';
|
||||||
import { UploadModule } from './upload/upload.module';
|
|
||||||
import { SearchModule } from './search/search.module';
|
import { SearchModule } from './search/search.module';
|
||||||
import { BREADCRUMB_DIRECTIVES } from './breadcrumb/breadcrumb.module';
|
import { BREADCRUMB_DIRECTIVES } from './breadcrumb/breadcrumb.module';
|
||||||
import { CONTENT_VERSION_DIRECTIVES } from './version-manager/version-manager.module';
|
import { CONTENT_VERSION_DIRECTIVES } from './version-manager/version-manager.module';
|
||||||
@@ -47,6 +46,7 @@ import { CategoriesManagementComponent } from './category';
|
|||||||
import { TreeComponent } from './tree';
|
import { TreeComponent } from './tree';
|
||||||
import { NewVersionUploaderDialogComponent } from './new-version-uploader';
|
import { NewVersionUploaderDialogComponent } from './new-version-uploader';
|
||||||
import { VersionCompatibilityDirective } from './version-compatibility';
|
import { VersionCompatibilityDirective } from './version-compatibility';
|
||||||
|
import { CONTENT_UPLOAD_DIRECTIVES } from './upload';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -59,7 +59,7 @@ import { VersionCompatibilityDirective } from './version-compatibility';
|
|||||||
...CONTENT_DIALOG_DIRECTIVES,
|
...CONTENT_DIALOG_DIRECTIVES,
|
||||||
SearchModule,
|
SearchModule,
|
||||||
DocumentListModule,
|
DocumentListModule,
|
||||||
UploadModule,
|
...CONTENT_UPLOAD_DIRECTIVES,
|
||||||
MaterialModule,
|
MaterialModule,
|
||||||
DropdownSitesComponent,
|
DropdownSitesComponent,
|
||||||
...BREADCRUMB_DIRECTIVES,
|
...BREADCRUMB_DIRECTIVES,
|
||||||
@@ -85,7 +85,7 @@ import { VersionCompatibilityDirective } from './version-compatibility';
|
|||||||
...CONTENT_PIPES,
|
...CONTENT_PIPES,
|
||||||
TagModule,
|
TagModule,
|
||||||
DocumentListModule,
|
DocumentListModule,
|
||||||
UploadModule,
|
...CONTENT_UPLOAD_DIRECTIVES,
|
||||||
SearchModule,
|
SearchModule,
|
||||||
DropdownSitesComponent,
|
DropdownSitesComponent,
|
||||||
...BREADCRUMB_DIRECTIVES,
|
...BREADCRUMB_DIRECTIVES,
|
||||||
|
@@ -19,7 +19,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|||||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||||
import { mockFile, mockNode } from '../mock';
|
import { mockFile, mockNode } from '../mock';
|
||||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||||
import { UploadVersionButtonComponent } from '../upload';
|
|
||||||
import { NewVersionUploaderDataAction } from './models';
|
import { NewVersionUploaderDataAction } from './models';
|
||||||
import { NewVersionUploaderDialogComponent } from './new-version-uploader.dialog';
|
import { NewVersionUploaderDialogComponent } from './new-version-uploader.dialog';
|
||||||
|
|
||||||
@@ -44,7 +43,6 @@ describe('NewVersionUploaderDialog', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [ContentTestingModule, NewVersionUploaderDialogComponent],
|
imports: [ContentTestingModule, NewVersionUploaderDialogComponent],
|
||||||
declarations: [UploadVersionButtonComponent],
|
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: MAT_DIALOG_DATA, useValue: { node: mockNode, showVersionsOnly, file: mockFile } },
|
{ provide: MAT_DIALOG_DATA, useValue: { node: mockNode, showVersionsOnly, file: mockFile } },
|
||||||
{
|
{
|
||||||
|
@@ -16,7 +16,19 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { UserPreferencesService } from '@alfresco/adf-core';
|
import { UserPreferencesService } from '@alfresco/adf-core';
|
||||||
import { ChangeDetectorRef, Component, Input, Output, EventEmitter, OnDestroy, OnInit, ViewChild, HostBinding, ElementRef, ViewEncapsulation } from '@angular/core';
|
import {
|
||||||
|
ChangeDetectorRef,
|
||||||
|
Component,
|
||||||
|
Input,
|
||||||
|
Output,
|
||||||
|
EventEmitter,
|
||||||
|
OnDestroy,
|
||||||
|
OnInit,
|
||||||
|
ViewChild,
|
||||||
|
HostBinding,
|
||||||
|
ElementRef,
|
||||||
|
ViewEncapsulation
|
||||||
|
} from '@angular/core';
|
||||||
import { Subscription, merge, Subject } from 'rxjs';
|
import { Subscription, merge, Subject } from 'rxjs';
|
||||||
import { FileUploadingListComponent } from './file-uploading-list.component';
|
import { FileUploadingListComponent } from './file-uploading-list.component';
|
||||||
import { Direction } from '@angular/cdk/bidi';
|
import { Direction } from '@angular/cdk/bidi';
|
||||||
@@ -24,9 +36,17 @@ import { takeUntil, delay } from 'rxjs/operators';
|
|||||||
import { UploadService } from '../../common/services/upload.service';
|
import { UploadService } from '../../common/services/upload.service';
|
||||||
import { FileModel, FileUploadStatus } from '../../common/models/file.model';
|
import { FileModel, FileUploadStatus } from '../../common/models/file.model';
|
||||||
import { FileUploadDeleteEvent, FileUploadCompleteEvent } from '../../common/events/file.event';
|
import { FileUploadDeleteEvent, FileUploadCompleteEvent } from '../../common/events/file.event';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
|
import { FileUploadingListRowComponent } from './file-uploading-list-row.component';
|
||||||
|
import { A11yModule } from '@angular/cdk/a11y';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-file-uploading-dialog',
|
selector: 'adf-file-uploading-dialog',
|
||||||
|
standalone: true,
|
||||||
|
imports: [CommonModule, MatButtonModule, TranslateModule, MatIconModule, FileUploadingListComponent, FileUploadingListRowComponent, A11yModule],
|
||||||
templateUrl: './file-uploading-dialog.component.html',
|
templateUrl: './file-uploading-dialog.component.html',
|
||||||
styleUrls: ['./file-uploading-dialog.component.scss'],
|
styleUrls: ['./file-uploading-dialog.component.scss'],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
@@ -53,15 +73,11 @@ export class FileUploadingDialogComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
@HostBinding('attr.adfUploadDialogRight')
|
@HostBinding('attr.adfUploadDialogRight')
|
||||||
public get isPositionRight(): boolean {
|
public get isPositionRight(): boolean {
|
||||||
return (this.direction === 'ltr' && this.position === 'right')
|
return (this.direction === 'ltr' && this.position === 'right') || (this.direction === 'rtl' && this.position === 'left') || null;
|
||||||
|| (this.direction === 'rtl' && this.position === 'left')
|
|
||||||
|| null;
|
|
||||||
}
|
}
|
||||||
@HostBinding('attr.adfUploadDialogLeft')
|
@HostBinding('attr.adfUploadDialogLeft')
|
||||||
public get isPositionLeft(): boolean {
|
public get isPositionLeft(): boolean {
|
||||||
return (this.direction === 'ltr' && this.position === 'left')
|
return (this.direction === 'ltr' && this.position === 'left') || (this.direction === 'rtl' && this.position === 'right') || null;
|
||||||
|| (this.direction === 'rtl' && this.position === 'right')
|
|
||||||
|| null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
filesUploadingList: FileModel[] = [];
|
filesUploadingList: FileModel[] = [];
|
||||||
@@ -81,71 +97,56 @@ export class FileUploadingDialogComponent implements OnInit, OnDestroy {
|
|||||||
private uploadService: UploadService,
|
private uploadService: UploadService,
|
||||||
private changeDetector: ChangeDetectorRef,
|
private changeDetector: ChangeDetectorRef,
|
||||||
private userPreferencesService: UserPreferencesService,
|
private userPreferencesService: UserPreferencesService,
|
||||||
private elementRef: ElementRef) {
|
private elementRef: ElementRef
|
||||||
}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.dialogActive
|
this.dialogActive.pipe(delay(100), takeUntil(this.onDestroy$)).subscribe(() => {
|
||||||
.pipe(
|
const element: any = this.elementRef.nativeElement.querySelector('#upload-dialog');
|
||||||
delay(100),
|
if (element) {
|
||||||
takeUntil(this.onDestroy$)
|
element.focus();
|
||||||
)
|
}
|
||||||
.subscribe(() => {
|
});
|
||||||
const element: any = this.elementRef.nativeElement.querySelector('#upload-dialog');
|
|
||||||
if (element) {
|
|
||||||
element.focus();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this.listSubscription = this.uploadService.queueChanged
|
this.listSubscription = this.uploadService.queueChanged.pipe(takeUntil(this.onDestroy$)).subscribe((fileList) => {
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
this.filesUploadingList = fileList;
|
||||||
.subscribe(fileList => {
|
|
||||||
this.filesUploadingList = fileList;
|
|
||||||
|
|
||||||
if (this.filesUploadingList.length && !this.isDialogActive) {
|
if (this.filesUploadingList.length && !this.isDialogActive) {
|
||||||
this.isDialogActive = true;
|
this.isDialogActive = true;
|
||||||
this.dialogActive.next(undefined);
|
this.dialogActive.next(undefined);
|
||||||
} else {
|
} else {
|
||||||
this.dialogActive.next(undefined);
|
this.dialogActive.next(undefined);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.counterSubscription = merge(
|
this.counterSubscription = merge(this.uploadService.fileUploadComplete, this.uploadService.fileUploadDeleted)
|
||||||
this.uploadService.fileUploadComplete,
|
|
||||||
this.uploadService.fileUploadDeleted
|
|
||||||
)
|
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe((event: FileUploadCompleteEvent | FileUploadDeleteEvent) => {
|
.subscribe((event: FileUploadCompleteEvent | FileUploadDeleteEvent) => {
|
||||||
this.totalCompleted = event.totalComplete;
|
this.totalCompleted = event.totalComplete;
|
||||||
this.changeDetector.detectChanges();
|
this.changeDetector.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.errorSubscription = this.uploadService.fileUploadError
|
this.errorSubscription = this.uploadService.fileUploadError.pipe(takeUntil(this.onDestroy$)).subscribe((event) => {
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
this.totalErrors = event.totalError;
|
||||||
.subscribe(event => {
|
this.changeDetector.detectChanges();
|
||||||
this.totalErrors = event.totalError;
|
});
|
||||||
this.changeDetector.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
this.fileUploadSubscription = this.uploadService.fileUpload
|
this.fileUploadSubscription = this.uploadService.fileUpload.pipe(takeUntil(this.onDestroy$)).subscribe(() => {
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
this.changeDetector.detectChanges();
|
||||||
.subscribe(() => {
|
});
|
||||||
this.changeDetector.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
this.uploadService.fileDeleted
|
this.uploadService.fileDeleted.pipe(takeUntil(this.onDestroy$)).subscribe((objId) => {
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
if (this.filesUploadingList) {
|
||||||
.subscribe(objId => {
|
const uploadedFile = this.filesUploadingList.find((file) => (file.data ? file.data.entry.id === objId : false));
|
||||||
if (this.filesUploadingList) {
|
if (uploadedFile) {
|
||||||
const uploadedFile = this.filesUploadingList.find((file) => file.data ? file.data.entry.id === objId : false);
|
uploadedFile.status = FileUploadStatus.Cancelled;
|
||||||
if (uploadedFile) {
|
this.changeDetector.detectChanges();
|
||||||
uploadedFile.status = FileUploadStatus.Cancelled;
|
|
||||||
this.changeDetector.detectChanges();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this.userPreferencesService.select('textOrientation')
|
this.userPreferencesService
|
||||||
|
.select('textOrientation')
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe((textOrientation: Direction) => {
|
.subscribe((textOrientation: Direction) => {
|
||||||
this.direction = textOrientation;
|
this.direction = textOrientation;
|
||||||
@@ -221,6 +222,6 @@ export class FileUploadingDialogComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hasUploadInProgress(): boolean {
|
hasUploadInProgress(): boolean {
|
||||||
return (!this.uploadList?.isUploadCompleted() && !this.uploadList?.isUploadCancelled());
|
return !this.uploadList?.isUploadCompleted() && !this.uploadList?.isUploadCancelled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
<span *ngIf="isUploadVersion()" class="adf-file-uploading-row__version" tabindex="0" >
|
<span *ngIf="isUploadVersion()" class="adf-file-uploading-row__version" tabindex="0" >
|
||||||
<mat-chip-option color="primary"
|
<mat-chip-option color="primary"
|
||||||
[attr.aria-label]="'ADF_FILE_UPLOAD.ARIA-LABEL.VERSION' | translate: { version: versionNumber }"
|
[attr.aria-label]="'ADF_FILE_UPLOAD.ARIA-LABEL.VERSION' | translate: { version: versionNumber }"
|
||||||
[title]="'version' + versionNumber" disabled
|
[title]="'version' + versionNumber" [disabled]="true"
|
||||||
>{{ versionNumber }}</mat-chip-option>
|
>{{ versionNumber }}</mat-chip-option>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
@@ -17,9 +17,31 @@
|
|||||||
|
|
||||||
import { FileModel, FileUploadStatus } from '../../common/models/file.model';
|
import { FileModel, FileUploadStatus } from '../../common/models/file.model';
|
||||||
import { Component, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core';
|
import { Component, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
|
import { MatListModule } from '@angular/material/list';
|
||||||
|
import { FileSizePipe, IconComponent } from '@alfresco/adf-core';
|
||||||
|
import { MatChipsModule } from '@angular/material/chips';
|
||||||
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { ToggleIconDirective } from '../directives/toggle-icon.directive';
|
||||||
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
import { FileUploadErrorPipe } from '../pipes/file-upload-error.pipe';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-file-uploading-list-row',
|
selector: 'adf-file-uploading-list-row',
|
||||||
|
standalone: true,
|
||||||
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
MatIconModule,
|
||||||
|
MatListModule,
|
||||||
|
IconComponent,
|
||||||
|
MatChipsModule,
|
||||||
|
TranslateModule,
|
||||||
|
ToggleIconDirective,
|
||||||
|
FileSizePipe,
|
||||||
|
MatButtonModule,
|
||||||
|
FileUploadErrorPipe
|
||||||
|
],
|
||||||
templateUrl: './file-uploading-list-row.component.html',
|
templateUrl: './file-uploading-list-row.component.html',
|
||||||
styleUrls: ['./file-uploading-list-row.component.scss'],
|
styleUrls: ['./file-uploading-list-row.component.scss'],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
|
@@ -15,23 +15,17 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import { TranslationService } from '@alfresco/adf-core';
|
||||||
TranslationService
|
|
||||||
} from '@alfresco/adf-core';
|
|
||||||
import { UploadService } from '../../common/services/upload.service';
|
import { UploadService } from '../../common/services/upload.service';
|
||||||
import { FileModel, FileUploadStatus } from '../../common/models/file.model';
|
import { FileModel, FileUploadStatus } from '../../common/models/file.model';
|
||||||
|
|
||||||
import {
|
import { Component, ContentChild, Input, Output, TemplateRef, EventEmitter } from '@angular/core';
|
||||||
Component,
|
import { CommonModule } from '@angular/common';
|
||||||
ContentChild,
|
|
||||||
Input,
|
|
||||||
Output,
|
|
||||||
TemplateRef,
|
|
||||||
EventEmitter
|
|
||||||
} from '@angular/core';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-file-uploading-list',
|
selector: 'adf-file-uploading-list',
|
||||||
|
standalone: true,
|
||||||
|
imports: [CommonModule],
|
||||||
templateUrl: './file-uploading-list.component.html',
|
templateUrl: './file-uploading-list.component.html',
|
||||||
styleUrls: ['./file-uploading-list.component.scss']
|
styleUrls: ['./file-uploading-list.component.scss']
|
||||||
})
|
})
|
||||||
@@ -46,10 +40,7 @@ export class FileUploadingListComponent {
|
|||||||
@Output()
|
@Output()
|
||||||
error = new EventEmitter<any>();
|
error = new EventEmitter<any>();
|
||||||
|
|
||||||
constructor(
|
constructor(private uploadService: UploadService, private translateService: TranslationService) {}
|
||||||
private uploadService: UploadService,
|
|
||||||
private translateService: TranslationService) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancel file upload
|
* Cancel file upload
|
||||||
@@ -79,14 +70,14 @@ export class FileUploadingListComponent {
|
|||||||
this.uploadService.cancelUpload(file);
|
this.uploadService.cancelUpload(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.files = this.files.filter(entry => entry !== file);
|
this.files = this.files.filter((entry) => entry !== file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls the appropriate methods for each file, depending on state
|
* Calls the appropriate methods for each file, depending on state
|
||||||
*/
|
*/
|
||||||
cancelAllFiles(): void {
|
cancelAllFiles(): void {
|
||||||
const filesToCancel = this.files.filter(file => this.isUploadingFile(file));
|
const filesToCancel = this.files.filter((file) => this.isUploadingFile(file));
|
||||||
|
|
||||||
if (filesToCancel.length > 0) {
|
if (filesToCancel.length > 0) {
|
||||||
this.uploadService.cancelUpload(...filesToCancel);
|
this.uploadService.cancelUpload(...filesToCancel);
|
||||||
@@ -103,10 +94,7 @@ export class FileUploadingListComponent {
|
|||||||
!this.isUploadCancelled() &&
|
!this.isUploadCancelled() &&
|
||||||
Boolean(this.files.length) &&
|
Boolean(this.files.length) &&
|
||||||
!this.files.some(
|
!this.files.some(
|
||||||
({ status }) =>
|
({ status }) => status === FileUploadStatus.Starting || status === FileUploadStatus.Progress || status === FileUploadStatus.Pending
|
||||||
status === FileUploadStatus.Starting ||
|
|
||||||
status === FileUploadStatus.Progress ||
|
|
||||||
status === FileUploadStatus.Pending
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -120,22 +108,14 @@ export class FileUploadingListComponent {
|
|||||||
return (
|
return (
|
||||||
!!this.files.length &&
|
!!this.files.length &&
|
||||||
this.files.every(
|
this.files.every(
|
||||||
({ status }) =>
|
({ status }) => status === FileUploadStatus.Aborted || status === FileUploadStatus.Cancelled || status === FileUploadStatus.Deleted
|
||||||
status === FileUploadStatus.Aborted ||
|
|
||||||
status === FileUploadStatus.Cancelled ||
|
|
||||||
status === FileUploadStatus.Deleted
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private cancelNodeVersionInstances(file: FileModel) {
|
private cancelNodeVersionInstances(file: FileModel) {
|
||||||
this.files
|
this.files
|
||||||
.filter(
|
.filter((item) => item.options.newVersion && item.data.entry.id === file.data.entry.id)
|
||||||
(item) =>
|
|
||||||
item.options.newVersion &&
|
|
||||||
item.data.entry.id === file.data.entry.id
|
|
||||||
|
|
||||||
)
|
|
||||||
.map((item) => {
|
.map((item) => {
|
||||||
item.status = FileUploadStatus.Deleted;
|
item.status = FileUploadStatus.Deleted;
|
||||||
});
|
});
|
||||||
@@ -145,23 +125,15 @@ export class FileUploadingListComponent {
|
|||||||
let messageError: string = null;
|
let messageError: string = null;
|
||||||
|
|
||||||
if (files.length === 1) {
|
if (files.length === 1) {
|
||||||
messageError = this.translateService.instant(
|
messageError = this.translateService.instant('FILE_UPLOAD.MESSAGES.REMOVE_FILE_ERROR', { fileName: files[0].name });
|
||||||
'FILE_UPLOAD.MESSAGES.REMOVE_FILE_ERROR',
|
|
||||||
{ fileName: files[0].name }
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
messageError = this.translateService.instant(
|
messageError = this.translateService.instant('FILE_UPLOAD.MESSAGES.REMOVE_FILES_ERROR', { total: files.length });
|
||||||
'FILE_UPLOAD.MESSAGES.REMOVE_FILES_ERROR',
|
|
||||||
{ total: files.length }
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.error.emit(messageError);
|
this.error.emit(messageError);
|
||||||
}
|
}
|
||||||
|
|
||||||
private isUploadingFile(file: FileModel): boolean {
|
private isUploadingFile(file: FileModel): boolean {
|
||||||
return file.status === FileUploadStatus.Pending ||
|
return file.status === FileUploadStatus.Pending || file.status === FileUploadStatus.Starting || file.status === FileUploadStatus.Progress;
|
||||||
file.status === FileUploadStatus.Starting ||
|
|
||||||
file.status === FileUploadStatus.Progress;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,9 +25,15 @@ import { Subject } from 'rxjs';
|
|||||||
import { PermissionModel } from '../../document-list/models/permissions.model';
|
import { PermissionModel } from '../../document-list/models/permissions.model';
|
||||||
import { UploadBase } from './base-upload/upload-base';
|
import { UploadBase } from './base-upload/upload-base';
|
||||||
import { NodeAllowableOperationSubject } from '../../interfaces/node-allowable-operation-subject.interface';
|
import { NodeAllowableOperationSubject } from '../../interfaces/node-allowable-operation-subject.interface';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-upload-button',
|
selector: 'adf-upload-button',
|
||||||
|
standalone: true,
|
||||||
|
imports: [CommonModule, MatButtonModule, TranslateModule, MatIconModule],
|
||||||
templateUrl: './upload-button.component.html',
|
templateUrl: './upload-button.component.html',
|
||||||
styleUrls: ['./upload-button.component.scss'],
|
styleUrls: ['./upload-button.component.scss'],
|
||||||
viewProviders: [{ provide: EXTENDIBLE_COMPONENT, useExisting: forwardRef(() => UploadButtonComponent) }],
|
viewProviders: [{ provide: EXTENDIBLE_COMPONENT, useExisting: forwardRef(() => UploadButtonComponent) }],
|
||||||
|
@@ -23,9 +23,12 @@ import { AllowableOperationsEnum } from '../../common/models/allowable-operation
|
|||||||
import { ContentService } from '../../common/services/content.service';
|
import { ContentService } from '../../common/services/content.service';
|
||||||
import { FileModel } from '../../common/models/file.model';
|
import { FileModel } from '../../common/models/file.model';
|
||||||
import { Node } from '@alfresco/js-api';
|
import { Node } from '@alfresco/js-api';
|
||||||
|
import { FileDraggableDirective } from '../directives/file-draggable.directive';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-upload-drag-area',
|
selector: 'adf-upload-drag-area',
|
||||||
|
standalone: true,
|
||||||
|
imports: [FileDraggableDirective],
|
||||||
templateUrl: './upload-drag-area.component.html',
|
templateUrl: './upload-drag-area.component.html',
|
||||||
styleUrls: ['./upload-drag-area.component.scss'],
|
styleUrls: ['./upload-drag-area.component.scss'],
|
||||||
host: { class: 'adf-upload-drag-area' },
|
host: { class: 'adf-upload-drag-area' },
|
||||||
|
@@ -21,25 +21,33 @@ import { Node } from '@alfresco/js-api';
|
|||||||
import { UploadButtonComponent } from './upload-button.component';
|
import { UploadButtonComponent } from './upload-button.component';
|
||||||
import { AllowableOperationsEnum } from '../../common/models/allowable-operations.enum';
|
import { AllowableOperationsEnum } from '../../common/models/allowable-operations.enum';
|
||||||
import { FileModel } from '../../common/models/file.model';
|
import { FileModel } from '../../common/models/file.model';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-upload-version-button',
|
selector: 'adf-upload-version-button',
|
||||||
|
standalone: true,
|
||||||
|
imports: [CommonModule, MatButtonModule, TranslateModule, MatIconModule],
|
||||||
templateUrl: './upload-button.component.html',
|
templateUrl: './upload-button.component.html',
|
||||||
styleUrls: ['./upload-button.component.scss'],
|
styleUrls: ['./upload-button.component.scss'],
|
||||||
viewProviders: [
|
viewProviders: [{ provide: EXTENDIBLE_COMPONENT, useExisting: forwardRef(() => UploadVersionButtonComponent) }],
|
||||||
{ provide: EXTENDIBLE_COMPONENT, useExisting: forwardRef(() => UploadVersionButtonComponent) }
|
|
||||||
],
|
|
||||||
encapsulation: ViewEncapsulation.None,
|
encapsulation: ViewEncapsulation.None,
|
||||||
host: { class: 'adf-upload-version-button' }
|
host: { class: 'adf-upload-version-button' }
|
||||||
})
|
})
|
||||||
export class UploadVersionButtonComponent extends UploadButtonComponent implements OnChanges, OnInit {
|
export class UploadVersionButtonComponent extends UploadButtonComponent implements OnChanges, OnInit {
|
||||||
|
|
||||||
/** (**Required**) The node to be versioned. */
|
/** (**Required**) The node to be versioned. */
|
||||||
@Input()
|
@Input()
|
||||||
node: Node;
|
node: Node;
|
||||||
|
|
||||||
protected createFileModel(file: File): FileModel {
|
protected createFileModel(file: File): FileModel {
|
||||||
const fileModel = super.createFileModel(file, this.rootFolderId, ((file as any).webkitRelativePath || '').replace(/\/[^/]*$/, ''), this.node.id);
|
const fileModel = super.createFileModel(
|
||||||
|
file,
|
||||||
|
this.rootFolderId,
|
||||||
|
((file as any).webkitRelativePath || '').replace(/\/[^/]*$/, ''),
|
||||||
|
this.node.id
|
||||||
|
);
|
||||||
|
|
||||||
if (!this.isFileAcceptable(fileModel)) {
|
if (!this.isFileAcceptable(fileModel)) {
|
||||||
const message = this.translationService.instant('FILE_UPLOAD.VERSION.MESSAGES.INCOMPATIBLE_VERSION');
|
const message = this.translationService.instant('FILE_UPLOAD.VERSION.MESSAGES.INCOMPATIBLE_VERSION');
|
||||||
|
@@ -21,10 +21,12 @@ import { FileDraggableDirective, INPUT_FOCUS_CSS_CLASS } from '../directives/fil
|
|||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-test-component',
|
selector: 'adf-test-component',
|
||||||
|
standalone: true,
|
||||||
|
imports: [FileDraggableDirective],
|
||||||
template: `
|
template: `
|
||||||
<div id="test-container" [adf-file-draggable]="true">
|
<div id="test-container" [adf-file-draggable]="true">
|
||||||
<div id="test-content"></div>
|
<div id="test-content"></div>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
class TestComponent {
|
class TestComponent {
|
||||||
@@ -42,10 +44,7 @@ describe('FileDraggableDirective', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
declarations: [
|
imports: [TestComponent]
|
||||||
TestComponent,
|
|
||||||
FileDraggableDirective
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
|
|
||||||
fixture = TestBed.createComponent(TestComponent);
|
fixture = TestBed.createComponent(TestComponent);
|
||||||
@@ -61,11 +60,12 @@ describe('FileDraggableDirective', () => {
|
|||||||
fixture.destroy();
|
fixture.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
const createEvent = (eventName: string): DragEvent => new DragEvent(eventName, {
|
const createEvent = (eventName: string): DragEvent =>
|
||||||
bubbles: true,
|
new DragEvent(eventName, {
|
||||||
cancelable: true,
|
bubbles: true,
|
||||||
dataTransfer: new DataTransfer()
|
cancelable: true,
|
||||||
});
|
dataTransfer: new DataTransfer()
|
||||||
|
});
|
||||||
|
|
||||||
const raiseEvent = (eventName: string): DragEvent => {
|
const raiseEvent = (eventName: string): DragEvent => {
|
||||||
const event = createEvent(eventName);
|
const event = createEvent(eventName);
|
||||||
|
@@ -24,11 +24,11 @@ export const INPUT_FOCUS_CSS_CLASS = 'adf-file-draggable-input-focus';
|
|||||||
export const DROP_EFFECT = 'copy';
|
export const DROP_EFFECT = 'copy';
|
||||||
|
|
||||||
@Directive({
|
@Directive({
|
||||||
selector: '[adf-file-draggable]'
|
selector: '[adf-file-draggable]',
|
||||||
|
standalone: true
|
||||||
})
|
})
|
||||||
export class FileDraggableDirective implements OnInit, OnDestroy {
|
export class FileDraggableDirective implements OnInit, OnDestroy {
|
||||||
|
files: File[];
|
||||||
files: File [];
|
|
||||||
|
|
||||||
/** Enables/disables drag-and-drop functionality. */
|
/** Enables/disables drag-and-drop functionality. */
|
||||||
@Input('adf-file-draggable')
|
@Input('adf-file-draggable')
|
||||||
|
@@ -21,9 +21,9 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-test-component',
|
selector: 'adf-test-component',
|
||||||
template: `
|
standalone: true,
|
||||||
<button id="testButton" adf-toggle-icon>test</button>
|
imports: [ToggleIconDirective],
|
||||||
`
|
template: ` <button id="testButton" adf-toggle-icon>test</button> `
|
||||||
})
|
})
|
||||||
class TestComponent {
|
class TestComponent {
|
||||||
@ViewChild(ToggleIconDirective)
|
@ViewChild(ToggleIconDirective)
|
||||||
@@ -36,10 +36,7 @@ describe('ToggleIconDirective', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
declarations: [
|
imports: [TestComponent]
|
||||||
TestComponent,
|
|
||||||
ToggleIconDirective
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
fixture = TestBed.createComponent(TestComponent);
|
fixture = TestBed.createComponent(TestComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
@@ -19,6 +19,7 @@ import { Directive, HostListener } from '@angular/core';
|
|||||||
|
|
||||||
@Directive({
|
@Directive({
|
||||||
selector: '[adf-toggle-icon]',
|
selector: '[adf-toggle-icon]',
|
||||||
|
standalone: true,
|
||||||
exportAs: 'toggleIcon'
|
exportAs: 'toggleIcon'
|
||||||
})
|
})
|
||||||
export class ToggleIconDirective {
|
export class ToggleIconDirective {
|
||||||
|
@@ -15,9 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { CommonModule } from '@angular/common';
|
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { MaterialModule } from '../material.module';
|
|
||||||
import { FileUploadingDialogComponent } from './components/file-uploading-dialog.component';
|
import { FileUploadingDialogComponent } from './components/file-uploading-dialog.component';
|
||||||
import { FileUploadingListRowComponent } from './components/file-uploading-list-row.component';
|
import { FileUploadingListRowComponent } from './components/file-uploading-list-row.component';
|
||||||
import { FileUploadingListComponent } from './components/file-uploading-list.component';
|
import { FileUploadingListComponent } from './components/file-uploading-list.component';
|
||||||
@@ -25,33 +23,24 @@ import { UploadButtonComponent } from './components/upload-button.component';
|
|||||||
import { UploadVersionButtonComponent } from './components/upload-version-button.component';
|
import { UploadVersionButtonComponent } from './components/upload-version-button.component';
|
||||||
import { UploadDragAreaComponent } from './components/upload-drag-area.component';
|
import { UploadDragAreaComponent } from './components/upload-drag-area.component';
|
||||||
import { FileUploadErrorPipe } from './pipes/file-upload-error.pipe';
|
import { FileUploadErrorPipe } from './pipes/file-upload-error.pipe';
|
||||||
import { CoreModule, FileSizePipe } from '@alfresco/adf-core';
|
|
||||||
import { FileDraggableDirective } from './directives/file-draggable.directive';
|
import { FileDraggableDirective } from './directives/file-draggable.directive';
|
||||||
import { ToggleIconDirective } from './directives/toggle-icon.directive';
|
import { ToggleIconDirective } from './directives/toggle-icon.directive';
|
||||||
import { A11yModule } from '@angular/cdk/a11y';
|
|
||||||
|
|
||||||
|
export const CONTENT_UPLOAD_DIRECTIVES = [
|
||||||
|
FileUploadErrorPipe,
|
||||||
|
FileDraggableDirective,
|
||||||
|
ToggleIconDirective,
|
||||||
|
UploadDragAreaComponent,
|
||||||
|
UploadButtonComponent,
|
||||||
|
UploadVersionButtonComponent,
|
||||||
|
FileUploadingListRowComponent,
|
||||||
|
FileUploadingListComponent,
|
||||||
|
FileUploadingDialogComponent
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
/** @deprecated use `...CONTENT_UPLOAD_DIRECTIVES` instead or import standalone components directly */
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [CoreModule, CommonModule, MaterialModule, A11yModule, FileUploadErrorPipe, FileSizePipe],
|
imports: [...CONTENT_UPLOAD_DIRECTIVES],
|
||||||
declarations: [
|
exports: [...CONTENT_UPLOAD_DIRECTIVES]
|
||||||
FileDraggableDirective,
|
|
||||||
UploadDragAreaComponent,
|
|
||||||
UploadButtonComponent,
|
|
||||||
UploadVersionButtonComponent,
|
|
||||||
FileUploadingDialogComponent,
|
|
||||||
FileUploadingListComponent,
|
|
||||||
FileUploadingListRowComponent,
|
|
||||||
ToggleIconDirective
|
|
||||||
],
|
|
||||||
exports: [
|
|
||||||
FileDraggableDirective,
|
|
||||||
UploadDragAreaComponent,
|
|
||||||
UploadButtonComponent,
|
|
||||||
UploadVersionButtonComponent,
|
|
||||||
FileUploadingDialogComponent,
|
|
||||||
FileUploadingListComponent,
|
|
||||||
FileUploadingListRowComponent,
|
|
||||||
FileUploadErrorPipe,
|
|
||||||
ToggleIconDirective
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
export class UploadModule {}
|
export class UploadModule {}
|
||||||
|
@@ -28,13 +28,22 @@ import { FormsModule } from '@angular/forms';
|
|||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||||
import { MatInputModule } from '@angular/material/input';
|
import { MatInputModule } from '@angular/material/input';
|
||||||
import { UploadModule } from '../upload';
|
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
import { UploadVersionButtonComponent } from '../upload';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-version-upload',
|
selector: 'adf-version-upload',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, MatRadioModule, FormsModule, TranslateModule, MatFormFieldModule, MatInputModule, UploadModule, MatButtonModule],
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
MatRadioModule,
|
||||||
|
FormsModule,
|
||||||
|
TranslateModule,
|
||||||
|
MatFormFieldModule,
|
||||||
|
MatInputModule,
|
||||||
|
MatButtonModule,
|
||||||
|
UploadVersionButtonComponent
|
||||||
|
],
|
||||||
templateUrl: './version-upload.component.html',
|
templateUrl: './version-upload.component.html',
|
||||||
styleUrls: ['./version-upload.component.scss'],
|
styleUrls: ['./version-upload.component.scss'],
|
||||||
encapsulation: ViewEncapsulation.None,
|
encapsulation: ViewEncapsulation.None,
|
||||||
|
Reference in New Issue
Block a user