From c96e6ffafb62bde1e08987b1fdf3c0786487f6ec Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Tue, 24 Jan 2017 12:06:09 +0100 Subject: Initial commit --- src/scripts/controllers/simulation/taskview.ts | 64 ++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/scripts/controllers/simulation/taskview.ts (limited to 'src/scripts/controllers/simulation/taskview.ts') diff --git a/src/scripts/controllers/simulation/taskview.ts b/src/scripts/controllers/simulation/taskview.ts new file mode 100644 index 00000000..d989e103 --- /dev/null +++ b/src/scripts/controllers/simulation/taskview.ts @@ -0,0 +1,64 @@ +import * as $ from "jquery"; +import {SimulationController} from "../simulationcontroller"; +import {Util} from "../../util"; + + +export class TaskViewController { + private simulationController: SimulationController; + + + constructor(simulationController: SimulationController) { + this.simulationController = simulationController; + } + + /** + * Populates and displays the list of tasks with their current state. + */ + public update() { + const container = $(".task-list"); + container.children().remove(".task-element"); + + this.simulationController.stateCache.stateList[this.simulationController.currentTick].taskStates + .forEach((taskState: ITaskState) => { + const html = this.generateTaskElementHTML(taskState); + container.append(html); + }); + } + + private generateTaskElementHTML(taskState: ITaskState) { + let iconType, timeInfo; + + if (taskState.task.startTick > this.simulationController.currentTick) { + iconType = "glyphicon-time"; + timeInfo = "Not started yet"; + } else if (taskState.task.startTick <= this.simulationController.currentTick && taskState.flopsLeft > 0) { + iconType = "glyphicon-refresh"; + timeInfo = "Started at " + Util.convertSecondsToFormattedTime(taskState.task.startTick); + } else if (taskState.flopsLeft === 0) { + iconType = "glyphicon-ok"; + timeInfo = "Started at " + Util.convertSecondsToFormattedTime(taskState.task.startTick); + } + + // Calculate progression ratio + const progress = 1 - (taskState.flopsLeft / taskState.task.totalFlopCount); + + // Generate completion text + const flopsCompleted = taskState.task.totalFlopCount - taskState.flopsLeft; + const completionInfo = "Completed: " + flopsCompleted + " / " + taskState.task.totalFlopCount + " FLOPS"; + + return '
' + + '
' + + '
' + + '
' + timeInfo + + '
' + + '
' + + '
' + + '
' + + '
' + + '
' + completionInfo + '
' + + '
' + + '
'; + } +} -- cgit v1.2.3