From 6ddd5829af1c1b99e1f4aca48262d3e849cb30be Mon Sep 17 00:00:00 2001 From: Julian Matschinske <ge93nar@mytum.de> Date: Fri, 10 Apr 2020 12:17:13 +0200 Subject: [PATCH] Intuitive queue position --- src/app/analysis.service.ts | 8 +++++--- .../launch-analysis/launch-analysis.component.html | 2 +- .../launch-analysis/launch-analysis.component.ts | 4 +++- src/app/components/task-list/task-list.component.html | 11 +++++++++-- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/app/analysis.service.ts b/src/app/analysis.service.ts index 55306456..ff11a2bd 100644 --- a/src/app/analysis.service.ts +++ b/src/app/analysis.service.ts @@ -28,6 +28,8 @@ export const DEGREE_CENTRALITY: Algorithm = {slug: 'degree', name: algorithmName export const KEYPATHWAYMINER: Algorithm = {slug: 'keypathwayminer', name: algorithmNames.keypathwayminer}; export const MULTISTEINER: Algorithm = {slug: 'multisteiner', name: algorithmNames.multisteiner}; +export const MAX_TASKS = 3; + @Injectable({ providedIn: 'root' }) @@ -140,7 +142,7 @@ export class AnalysisService { async startQuickAnalysis() { if (!this.canLaunchTask()) { toast({ - message: 'You can only run 3 tasks at once. Please wait for one of them to finish or delete it from the task list.', + message: `You can only run ${MAX_TASKS} tasks at once. Please wait for one of them to finish or delete it from the task list.`, duration: 5000, dismissible: true, pauseOnHover: true, @@ -177,7 +179,7 @@ export class AnalysisService { async startAnalysis(algorithm, target: 'drug' | 'drug-target', parameters) { if (!this.canLaunchTask()) { toast({ - message: 'You can only run 3 tasks at once. Please wait for one of them to finish or delete it from the task list.', + message: `You can only run ${MAX_TASKS} tasks at once. Please wait for one of them to finish or delete it from the task list.`, duration: 5000, dismissible: true, pauseOnHover: true, @@ -246,7 +248,7 @@ export class AnalysisService { } } }); - this.canLaunchNewTask = queuedOrRunningTasks < 3; + this.canLaunchNewTask = queuedOrRunningTasks < MAX_TASKS; } else { this.canLaunchNewTask = true; } diff --git a/src/app/components/launch-analysis/launch-analysis.component.html b/src/app/components/launch-analysis/launch-analysis.component.html index fa30c15b..a9be25dc 100644 --- a/src/app/components/launch-analysis/launch-analysis.component.html +++ b/src/app/components/launch-analysis/launch-analysis.component.html @@ -30,7 +30,7 @@ <div *ngIf="!analysis.canLaunchTask()"> <div class="notification is-warning warning"> - You can only run 3 tasks at once. Please wait for one of them to finish or delete it from the task list. + You can only run {{maxTasks}} tasks at once. Please wait for one of them to finish or delete it from the task list. </div> </div> diff --git a/src/app/components/launch-analysis/launch-analysis.component.ts b/src/app/components/launch-analysis/launch-analysis.component.ts index 7afca91c..8939eaa3 100644 --- a/src/app/components/launch-analysis/launch-analysis.component.ts +++ b/src/app/components/launch-analysis/launch-analysis.component.ts @@ -4,7 +4,7 @@ import { AlgorithmType, AnalysisService, CLOSENESS_CENTRALITY, DEGREE_CENTRALITY, - KEYPATHWAYMINER, + KEYPATHWAYMINER, MAX_TASKS, MULTISTEINER, QuickAlgorithmType, TRUSTRANK @@ -55,6 +55,8 @@ export class LaunchAnalysisComponent implements OnInit, OnChanges { public hasBaits; + public maxTasks = MAX_TASKS; + constructor(public analysis: AnalysisService) { this.hasBaits = !!analysis.getSelection().find((i) => i.type === 'virus'); analysis.subscribe(() => { diff --git a/src/app/components/task-list/task-list.component.html b/src/app/components/task-list/task-list.component.html index 1ee860b2..2b659a54 100644 --- a/src/app/components/task-list/task-list.component.html +++ b/src/app/components/task-list/task-list.component.html @@ -8,8 +8,15 @@ <span class="icon is-pulled-right"><i class="fas fa-pause" aria-hidden="true"></i></span> </p> <p> - <small *ngIf="task.stats.queueLength > 0">Queue position: {{task.stats.queuePosition}}/{{task.stats.queueLength}}</small> - <small *ngIf="task.stats.queueLength === 0">Execution imminent...</small> + <small *ngIf="task.stats.queuePosition === 1"> + Queued: 1 other task to finish + </small> + <small *ngIf="task.stats.queuePosition > 1"> + Queued: {{task.stats.queuePosition}} other tasks to finish + </small> + <small *ngIf="task.stats.queuePosition === 0"> + Execution imminent... + </small> <a (click)="analysis.removeTask(task.token)" class="has-text-danger"> <span class="icon is-pulled-right"> <i class="fa fa-trash"></i> -- GitLab