From 24ff5c361e28f3b7f19cd3cf4b0f518b30c3d86a Mon Sep 17 00:00:00 2001 From: mrizzi Date: Tue, 25 Jul 2017 11:02:39 +0200 Subject: [PATCH] JIRA_WINDUP-1560 Print a warning on the web console for large analysis --- .../application-queue-list.component.ts | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/ui/src/main/webapp/src/app/registered-application/application-queue-list.component.ts b/ui/src/main/webapp/src/app/registered-application/application-queue-list.component.ts index 91a883e94..4c2d9efef 100644 --- a/ui/src/main/webapp/src/app/registered-application/application-queue-list.component.ts +++ b/ui/src/main/webapp/src/app/registered-application/application-queue-list.component.ts @@ -1,10 +1,13 @@ -import {AfterViewInit, ChangeDetectionStrategy, Component, Input, OnInit, ViewChild} from "@angular/core"; +import { + AfterViewInit, ChangeDetectionStrategy, Component, Input, OnInit, ViewChild, DoCheck, KeyValueDiffers +} from "@angular/core"; import {MigrationProject, RegisteredApplication} from "../generated/windup-services"; import {ConfirmationModalComponent} from "../shared/dialog/confirmation-modal.component"; import {FileItem} from "ng2-file-upload"; import {RegisteredApplicationService} from "./registered-application.service"; import {NotificationService} from "../core/notification/notification.service"; import {utils} from "../shared/utils"; +import {DurationPipe} from "../shared/duration.pipe"; /** * This component is quite hacky way how to show the same visuals as in alternative-upload-queue. @@ -33,7 +36,7 @@ import {utils} from "../shared/utils"; ], changeDetection: ChangeDetectionStrategy.OnPush }) -export class ApplicationQueueListComponent implements AfterViewInit +export class ApplicationQueueListComponent implements AfterViewInit, DoCheck { @Input() public registeredApplications: RegisteredApplication[] = []; @@ -44,10 +47,27 @@ export class ApplicationQueueListComponent implements AfterViewInit @ViewChild('deleteAppDialog') readonly deleteAppDialog: ConfirmationModalComponent; + differ: any; + constructor( protected _registeredApplicationsService: RegisteredApplicationService, - protected _notificationService: NotificationService + protected _notificationService: NotificationService, + private differs: KeyValueDiffers ) { + this.differ = differs.find({}).create(null); + } + + ngDoCheck() { + var changes = this.differ.diff(this.registeredApplications); + + if(changes) { + changes.forEachAddedItem(r => { + let analysisExpectedDuration = this.getAnalysisExpectedDuration((r.currentValue).fileSize); + if (analysisExpectedDuration) { + this._notificationService.warning("Large application uploaded '" + (r.currentValue).inputFilename + "': analysis may take about " + analysisExpectedDuration); + } + }); + } } ngAfterViewInit(): any { @@ -77,4 +97,15 @@ export class ApplicationQueueListComponent implements AfterViewInit this.deleteAppDialog.show(); } + + private getAnalysisExpectedDuration(fileSize: number): String { + let message: String; + if (fileSize > 104857600) { + // using a baseline of 1 hr per 200 MB + // => 3600000 msec per 209715200 bytes + // => 0.017 msec per 1 byte + message = new DurationPipe().transform(fileSize * 0.017); + } + return message; + } }