Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WINDUP-1560 Print a warning on the web console for large analysis #487

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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[] = [];
Expand All @@ -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((<RegisteredApplication>r.currentValue).fileSize);
if (analysisExpectedDuration) {
this._notificationService.warning("Large application uploaded '" + (<RegisteredApplication>r.currentValue).inputFilename + "': analysis may take about " + analysisExpectedDuration);
}
});
}
}

ngAfterViewInit(): any {
Expand Down Expand Up @@ -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;
}
}