summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/scripts/controllers/connection/cache.ts2
-rw-r--r--src/scripts/controllers/connection/socket.ts6
-rw-r--r--src/scripts/controllers/mapcontroller.ts42
-rw-r--r--src/scripts/controllers/modes/building.ts9
-rw-r--r--src/scripts/controllers/modes/node.ts42
-rw-r--r--src/scripts/controllers/modes/object.ts29
-rw-r--r--src/scripts/controllers/modes/room.ts42
-rw-r--r--src/scripts/controllers/scaleindicator.ts2
-rw-r--r--src/scripts/controllers/simulation/chart.ts12
-rw-r--r--src/scripts/controllers/simulation/statecache.ts8
-rw-r--r--src/scripts/controllers/simulation/timeline.ts8
-rw-r--r--src/scripts/controllers/simulationcontroller.ts16
12 files changed, 108 insertions, 110 deletions
diff --git a/src/scripts/controllers/connection/cache.ts b/src/scripts/controllers/connection/cache.ts
index 15517519..c1c47c2d 100644
--- a/src/scripts/controllers/connection/cache.ts
+++ b/src/scripts/controllers/connection/cache.ts
@@ -62,7 +62,7 @@ export class CacheController {
}
public onFetch(request: IRequest, response: IResponse): any {
- let pathWithoutVersion = request.path.replace(/\/v\d+/, "");
+ const pathWithoutVersion = request.path.replace(/\/v\d+/, "");
this.routeCaches[pathWithoutVersion][request.parameters.path["id"]].status = CacheStatus.HIT;
this.routeCaches[pathWithoutVersion][request.parameters.path["id"]].object = response.content;
diff --git a/src/scripts/controllers/connection/socket.ts b/src/scripts/controllers/connection/socket.ts
index b38c303f..c23495f1 100644
--- a/src/scripts/controllers/connection/socket.ts
+++ b/src/scripts/controllers/connection/socket.ts
@@ -19,7 +19,7 @@ export class SocketController {
this._socket.on('connect', onConnect);
this._socket.on('response', (jsonResponse: string) => {
- let response: IResponse = JSON.parse(jsonResponse);
+ const response: IResponse = JSON.parse(jsonResponse);
console.log("Response, ID:", response.id, response);
this.callbacks[response.id](response);
delete this.callbacks[response.id];
@@ -34,7 +34,7 @@ export class SocketController {
*/
public sendRequest(request: IRequest, callback: (response: IResponse) => any): void {
// Check local cache, in case request is for cachable GET route
- let cacheStatus = this._cacheController.checkCache(request);
+ const cacheStatus = this._cacheController.checkCache(request);
if (cacheStatus === CacheStatus.HIT) {
callback({
@@ -73,4 +73,4 @@ export class SocketController {
SocketController.id++;
}
}
-} \ No newline at end of file
+}
diff --git a/src/scripts/controllers/mapcontroller.ts b/src/scripts/controllers/mapcontroller.ts
index ca55683b..4ad1b20b 100644
--- a/src/scripts/controllers/mapcontroller.ts
+++ b/src/scripts/controllers/mapcontroller.ts
@@ -178,7 +178,7 @@ export class MapController {
* Does not change the x and y coordinates, only returns.
*/
public checkCanvasMovement(x: number, y: number, scale: number): IGridPosition {
- let result: IGridPosition = {x: x, y: y};
+ const result: IGridPosition = {x: x, y: y};
if (x + this.mapView.gridLayer.gridPixelSize * scale < this.mapView.canvasWidth) {
result.x = this.mapView.canvasWidth - this.mapView.gridLayer.gridPixelSize *
this.mapView.mapContainer.scaleX;
@@ -211,10 +211,10 @@ export class MapController {
}
public static showConfirmDeleteDialog(itemType: string, onConfirm: () => void): void {
- let modalDialog = <any>$("#confirm-delete");
+ const modalDialog = <any>$("#confirm-delete");
modalDialog.find(".modal-body").text("Are you sure you want to delete this " + itemType + "?");
- let callback = () => {
+ const callback = () => {
onConfirm();
modalDialog.modal("hide");
modalDialog.find("button.confirm").first().off("click");
@@ -241,16 +241,16 @@ export class MapController {
* @param type The severity of the message; Currently supported: "info" and "warning"
*/
public showInfoBalloon(message: string, type: string): void {
- let balloon = $(".info-balloon");
+ const balloon = $(".info-balloon");
balloon.html('<span></span>' + message);
- let callback = () => {
+ const callback = () => {
balloon.fadeOut(300);
this.infoTimeOut = undefined;
};
const DISPLAY_TIME = 3000;
- let balloonIcon = balloon.find("span").first();
+ const balloonIcon = balloon.find("span").first();
balloonIcon.removeClass();
balloon.css("background", Colors.INFO_BALLOON_MAP[type]);
@@ -278,9 +278,9 @@ export class MapController {
this.currentStageMouseX = event.stageX;
this.currentStageMouseY = event.stageY;
- let gridPos = this.convertScreenCoordsToGridCoords([event.stageX, event.stageY]);
- let tileX = gridPos.x;
- let tileY = gridPos.y;
+ const gridPos = this.convertScreenCoordsToGridCoords([event.stageX, event.stageY]);
+ const tileX = gridPos.x;
+ const tileY = gridPos.y;
// Check whether the coordinates of the hover location have changed since the last draw
if (this.mapView.hoverLayer.hoverTilePosition.x !== tileX) {
@@ -339,7 +339,7 @@ export class MapController {
// Relay scroll events to the MapView zoom handler
$("#main-canvas").on("mousewheel", (event: JQueryEventObject) => {
- let originalEvent = (<any>event.originalEvent);
+ const originalEvent = (<any>event.originalEvent);
this.mapView.zoom([this.currentStageMouseX, this.currentStageMouseY], -0.7 * originalEvent.deltaY);
this.scaleIndicatorController.update();
});
@@ -369,7 +369,7 @@ export class MapController {
// Menu panels
$(".menu-header-bar .menu-collapse").on("click", (event: JQueryEventObject) => {
- let container = $(event.target).closest(".menu-container");
+ const container = $(event.target).closest(".menu-container");
if (this.appMode === AppMode.CONSTRUCTION) {
container.children(".menu-body.construction").first().slideToggle(300);
} else if (this.appMode === AppMode.SIMULATION) {
@@ -380,7 +380,7 @@ export class MapController {
// Menu close button
$(".menu-header-bar .menu-exit").on("click", (event: JQueryEventObject) => {
- let nearestMenuContainer = $(event.target).closest(".menu-container");
+ const nearestMenuContainer = $(event.target).closest(".menu-container");
if (nearestMenuContainer.is("#node-menu")) {
this.interactionLevel = InteractionLevel.OBJECT;
$(".node-element-overlay").addClass("hidden");
@@ -400,10 +400,10 @@ export class MapController {
// Handler for the version-save button
$("#save-version-btn").on("click", (event: JQueryEventObject) => {
- let target = $(event.target);
+ const target = $(event.target);
target.attr("data-saved", "false");
- let lastPath = this.mapView.simulation.paths[this.mapView.simulation.paths.length - 1];
+ const lastPath = this.mapView.simulation.paths[this.mapView.simulation.paths.length - 1];
this.api.branchFromPath(
this.mapView.simulation.id, lastPath.id, lastPath.sections[lastPath.sections.length - 1].startTick + 1
).then((data: IPath) => {
@@ -437,11 +437,11 @@ export class MapController {
* @param stageY The y coordinate of the location in pixels on the stage
*/
private handleCanvasMouseClick(stageX: number, stageY: number): void {
- let gridPos = this.convertScreenCoordsToGridCoords([stageX, stageY]);
+ const gridPos = this.convertScreenCoordsToGridCoords([stageX, stageY]);
if (this.interactionLevel === InteractionLevel.BUILDING) {
if (this.interactionMode === InteractionMode.DEFAULT) {
- let roomIndex = Util.roomCollisionIndexOf(this.mapView.currentDatacenter.rooms, gridPos);
+ const roomIndex = Util.roomCollisionIndexOf(this.mapView.currentDatacenter.rooms, gridPos);
if (roomIndex !== -1) {
this.interactionLevel = InteractionLevel.ROOM;
@@ -474,7 +474,7 @@ export class MapController {
* @returns {Array} The corresponding grid cell coordinates
*/
private convertScreenCoordsToGridCoords(stagePosition: number[]): IGridPosition {
- let result = {x: 0, y: 0};
+ const result = {x: 0, y: 0};
result.x = Math.floor((stagePosition[0] - this.mapView.mapContainer.x) /
(this.mapView.mapContainer.scaleX * CELL_SIZE));
result.y = Math.floor((stagePosition[1] - this.mapView.mapContainer.y) /
@@ -486,7 +486,7 @@ export class MapController {
* Adjusts the canvas size to fit the window perfectly.
*/
private onWindowResize() {
- let parent = this.canvas.parent(".app-content");
+ const parent = this.canvas.parent(".app-content");
parent.height($(window).height() - 50);
this.canvas.attr("width", parent.width());
this.canvas.attr("height", parent.height());
@@ -505,15 +505,15 @@ export class MapController {
}
private matchUserAuthLevel() {
- let authLevel = localStorage.getItem("simulationAuthLevel");
+ const authLevel = localStorage.getItem("simulationAuthLevel");
if (authLevel === "VIEW") {
$(".side-menu-container.right-middle-side, .side-menu-container.right-side").hide();
}
}
private exportCanvasToImage() {
- let canvasData = (<HTMLCanvasElement>this.canvas.get(0)).toDataURL("image/png");
- let newWindow = window.open('about:blank', 'OpenDC Canvas Export');
+ const canvasData = (<HTMLCanvasElement>this.canvas.get(0)).toDataURL("image/png");
+ const newWindow = window.open('about:blank', 'OpenDC Canvas Export');
newWindow.document.write("<img src='" + canvasData + "' alt='Canvas Image Export'/>");
newWindow.document.title = "OpenDC Canvas Export";
}
diff --git a/src/scripts/controllers/modes/building.ts b/src/scripts/controllers/modes/building.ts
index 4d82f090..217f5935 100644
--- a/src/scripts/controllers/modes/building.ts
+++ b/src/scripts/controllers/modes/building.ts
@@ -22,7 +22,7 @@ export class BuildingModeController {
* Connects all DOM event listeners to their respective element targets.
*/
public setupEventListeners() {
- let resetConstructionButtons = () => {
+ const resetConstructionButtons = () => {
this.mapController.interactionMode = InteractionMode.DEFAULT;
this.mapView.hoverLayer.setHoverTileVisibility(false);
$("#room-construction").text("Construct new room");
@@ -79,7 +79,7 @@ export class BuildingModeController {
* @param position The new tile position to be added
*/
public addSelectedTile(position: IGridPosition): void {
- let tile = {
+ const tile = {
id: -1,
roomId: this.newRoomId,
position: {x: position.x, y: position.y}
@@ -96,11 +96,10 @@ export class BuildingModeController {
* @param position The position of the tile to be removed
*/
public removeSelectedTile(position: IGridPosition): void {
- let tile;
let objectIndex = -1;
for (let i = 0; i < this.mapView.roomLayer.selectedTileObjects.length; i++) {
- tile = this.mapView.roomLayer.selectedTileObjects[i];
+ const tile = this.mapView.roomLayer.selectedTileObjects[i];
if (tile.position.x === position.x && tile.position.y === position.y) {
objectIndex = i;
}
@@ -111,4 +110,4 @@ export class BuildingModeController {
this.mapView.roomLayer.removeSelectedTile(position, objectIndex);
});
}
-} \ No newline at end of file
+}
diff --git a/src/scripts/controllers/modes/node.ts b/src/scripts/controllers/modes/node.ts
index 3b3f8a32..cef61bba 100644
--- a/src/scripts/controllers/modes/node.ts
+++ b/src/scripts/controllers/modes/node.ts
@@ -53,17 +53,17 @@ export class NodeModeController {
* Connects all DOM event listeners to their respective element targets.
*/
public setupEventListeners(): void {
- let nodeMenu = $("#node-menu");
+ const nodeMenu = $("#node-menu");
nodeMenu.find(".panel-group").on("click", ".remove-unit", (event: JQueryEventObject) => {
MapController.showConfirmDeleteDialog("unit", () => {
- let index = $(event.target).closest(".panel").index();
+ const index = $(event.target).closest(".panel").index();
if (index === -1) {
return;
}
- let closestTabPane = $(event.target).closest(".panel-group");
+ const closestTabPane = $(event.target).closest(".panel-group");
let objectList, idList;
if (closestTabPane.is("#cpu-accordion")) {
@@ -94,9 +94,9 @@ export class NodeModeController {
});
nodeMenu.find(".add-unit").on("click", (event: JQueryEventObject) => {
- let dropdown = $(event.target).closest(".input-group-btn").siblings("select").first();
+ const dropdown = $(event.target).closest(".input-group-btn").siblings("select").first();
- let closestTabPane = $(event.target).closest(".input-group").siblings(".panel-group").first();
+ const closestTabPane = $(event.target).closest(".input-group").siblings(".panel-group").first();
let objectList, idList, typePlural;
if (closestTabPane.is("#cpu-accordion")) {
objectList = this.currentMachine.cpus;
@@ -121,7 +121,7 @@ export class NodeModeController {
return;
}
- let id = parseInt(dropdown.val(), 10);
+ const id = parseInt(dropdown.val());
idList.push(id);
this.mapController.api.getSpecificationOfType(typePlural, id).then((spec: INodeUnit) => {
objectList.push(spec);
@@ -141,10 +141,10 @@ export class NodeModeController {
* Populates the "add" dropdowns with all available unit options.
*/
private loadAddDropdowns(): void {
- let unitTypes = [
+ const unitTypes = [
"cpus", "gpus", "memories", "storages"
];
- let dropdowns = [
+ const dropdowns = [
$("#add-cpu-form").find("select"),
$("#add-gpu-form").find("select"),
$("#add-memory-form").find("select"),
@@ -166,7 +166,7 @@ export class NodeModeController {
*/
private populateUnitLists(): void {
// Contains the skeleton of a unit element and inserts the given data into it
- let generatePanel = (type: string, index: number, list: any, specSection: string): string => {
+ const generatePanel = (type: string, index: number, list: any, specSection: string): string => {
return '<div class="panel panel-default">' +
' <div class="panel-heading">' +
' <h4 class="panel-title">' +
@@ -188,7 +188,7 @@ export class NodeModeController {
};
// Generates the structure of the specification list of a processing unit
- let generateProcessingUnitHtml = (element: IProcessingUnit) => {
+ const generateProcessingUnitHtml = (element: IProcessingUnit) => {
return ' <tr>' +
' <td class="glyphicon glyphicon-tasks"></td>' +
' <td>Number of Cores</td>' +
@@ -212,7 +212,7 @@ export class NodeModeController {
};
// Generates the structure of the spec list of a storage unit
- let generateStorageUnitHtml = (element: IStorageUnit) => {
+ const generateStorageUnitHtml = (element: IStorageUnit) => {
return ' <tr>' +
' <td class="glyphicon glyphicon-floppy-disk"></td>' +
' <td>Size (Mb)</td>' +
@@ -236,7 +236,7 @@ export class NodeModeController {
};
// Inserts a "No units" message into the container of the given unit type
- let addNoUnitsMessage = (type: string) => {
+ const addNoUnitsMessage = (type: string) => {
$("#" + type + "-accordion").append("<p>There are currently no units present here. " +
"<em>Add some with the dropdown below!</em></p>");
};
@@ -249,8 +249,8 @@ export class NodeModeController {
addNoUnitsMessage("cpu");
} else {
this.currentMachine.cpus.forEach((element: ICPU, i: number) => {
- let specSection = generateProcessingUnitHtml(element);
- let content = generatePanel("cpu", i, this.currentMachine.cpus, specSection);
+ const specSection = generateProcessingUnitHtml(element);
+ const content = generatePanel("cpu", i, this.currentMachine.cpus, specSection);
container.append(content);
});
}
@@ -262,8 +262,8 @@ export class NodeModeController {
addNoUnitsMessage("gpu");
} else {
this.currentMachine.gpus.forEach((element: IGPU, i: number) => {
- let specSection = generateProcessingUnitHtml(element);
- let content = generatePanel("gpu", i, this.currentMachine.gpus, specSection);
+ const specSection = generateProcessingUnitHtml(element);
+ const content = generatePanel("gpu", i, this.currentMachine.gpus, specSection);
container.append(content);
});
}
@@ -275,8 +275,8 @@ export class NodeModeController {
addNoUnitsMessage("memory");
} else {
this.currentMachine.memories.forEach((element: IMemory, i: number) => {
- let specSection = generateStorageUnitHtml(element);
- let content = generatePanel("memory", i, this.currentMachine.memories, specSection);
+ const specSection = generateStorageUnitHtml(element);
+ const content = generatePanel("memory", i, this.currentMachine.memories, specSection);
container.append(content);
});
}
@@ -288,10 +288,10 @@ export class NodeModeController {
addNoUnitsMessage("storage");
} else {
this.currentMachine.storages.forEach((element: IMemory, i: number) => {
- let specSection = generateStorageUnitHtml(element);
- let content = generatePanel("storage", i, this.currentMachine.storages, specSection);
+ const specSection = generateStorageUnitHtml(element);
+ const content = generatePanel("storage", i, this.currentMachine.storages, specSection);
container.append(content);
});
}
}
-} \ No newline at end of file
+}
diff --git a/src/scripts/controllers/modes/object.ts b/src/scripts/controllers/modes/object.ts
index e922433e..d974df7a 100644
--- a/src/scripts/controllers/modes/object.ts
+++ b/src/scripts/controllers/modes/object.ts
@@ -97,12 +97,12 @@ export class ObjectModeController {
});
});
- let nodeListContainer = $(".node-list-container");
+ const nodeListContainer = $(".node-list-container");
// Handler for the 'add' button of each machine slot of the rack
nodeListContainer.on("click", ".add-node", (event: JQueryEventObject) => {
// Convert the DOM element index to a JS array index
- let index = this.currentRack.machines.length - $(event.target).closest(".node-element").index() - 1;
+ const index = this.currentRack.machines.length - $(event.target).closest(".node-element").index() - 1;
// Insert an empty machine at the selected position
this.mapController.api.addMachineToRack(this.mapView.simulation.id,
@@ -127,10 +127,10 @@ export class ObjectModeController {
// Handler for the 'remove' button of each machine slot of the rack
nodeListContainer.on("click", ".remove-node", (event: JQueryEventObject) => {
- let target = $(event.target);
+ const target = $(event.target);
MapController.showConfirmDeleteDialog("machine", () => {
// Convert the DOM element index to a JS array index
- let index = this.currentRack.machines.length - target.closest(".node-element").index() - 1;
+ const index = this.currentRack.machines.length - target.closest(".node-element").index() - 1;
this.mapController.api.deleteMachine(this.mapView.simulation.id,
this.mapView.currentDatacenter.id, this.mapController.roomModeController.currentRoom.id,
@@ -146,9 +146,9 @@ export class ObjectModeController {
// Handler for every node element, triggering node mode
nodeListContainer.on("click", ".node-element", (event: JQueryEventObject) => {
- let domIndex = $(event.target).closest(".node-element").index();
- let index = this.currentRack.machines.length - domIndex - 1;
- let machine = this.currentRack.machines[index];
+ const domIndex = $(event.target).closest(".node-element").index();
+ const index = this.currentRack.machines.length - domIndex - 1;
+ const machine = this.currentRack.machines[index];
if (machine != null) {
this.mapController.interactionLevel = InteractionLevel.NODE;
@@ -222,8 +222,8 @@ export class ObjectModeController {
continue;
}
- let container = this.mapController.appMode === AppMode.CONSTRUCTION ? ".construction" : ".simulation";
- let element = $(container + " .node-element").eq(this.currentRack.machines.length - i - 1);
+ const container = this.mapController.appMode === AppMode.CONSTRUCTION ? ".construction" : ".simulation";
+ const element = $(container + " .node-element").eq(this.currentRack.machines.length - i - 1);
if (this.currentRack.machines[i].cpus.length !== 0) {
element.find(".overlay-cpu").addClass("hidden");
} else {
@@ -251,8 +251,7 @@ export class ObjectModeController {
* Dynamically generates and inserts HTML code for every node in the current rack.
*/
private populateNodeList(): void {
- let type, content;
- let container = $(".node-list-container");
+ const container = $(".node-list-container");
// Remove any previously present node elements
container.children().remove(".node-element");
@@ -260,8 +259,8 @@ export class ObjectModeController {
for (let i = 0; i < this.currentRack.machines.length; i++) {
// Depending on whether the current machine slot is filled, allow removing or adding a new machine by adding
// the appropriate button next to the machine slot
- type = (this.currentRack.machines[i] == null ? "glyphicon-plus add-node" : "glyphicon-remove remove-node");
- content =
+ const type = (this.currentRack.machines[i] == null ? "glyphicon-plus add-node" : "glyphicon-remove remove-node");
+ let content =
'<div class="node-element" data-id="' + (this.currentRack.machines[i] === null ?
"" : this.currentRack.machines[i].id) + '">' +
' <div class="node-element-overlay hidden"></div>' +
@@ -291,7 +290,7 @@ export class ObjectModeController {
}
private scrollToBottom(): void {
- let scrollContainer = $('.node-list-container');
+ const scrollContainer = $('.node-list-container');
scrollContainer.scrollTop(scrollContainer[0].scrollHeight);
}
-} \ No newline at end of file
+}
diff --git a/src/scripts/controllers/modes/room.ts b/src/scripts/controllers/modes/room.ts
index a858af5a..8a982ef1 100644
--- a/src/scripts/controllers/modes/room.ts
+++ b/src/scripts/controllers/modes/room.ts
@@ -63,9 +63,9 @@ export class RoomModeController {
MapController.hideAndShowMenus("#room-menu");
// Pre-select the type of the current room in the dropdown
- let roomTypeDropdown = $("#roomtype-select");
+ const roomTypeDropdown = $("#roomtype-select");
roomTypeDropdown.find('option').prop("selected", "false");
- let roomTypeIndex = this.roomTypes.indexOf(this.currentRoom.roomType);
+ const roomTypeIndex = this.roomTypes.indexOf(this.currentRoom.roomType);
if (roomTypeIndex !== -1) {
roomTypeDropdown.find('option[value="' + roomTypeIndex + '"]').prop("selected", "true");
} else {
@@ -106,11 +106,11 @@ export class RoomModeController {
public setupEventListeners(): void {
// Component buttons
- let addRackBtn = $("#add-rack-btn");
- let addPSUBtn = $("#add-psu-btn");
- let addCoolingItemBtn = $("#add-cooling-item-btn");
+ const addRackBtn = $("#add-rack-btn");
+ const addPSUBtn = $("#add-psu-btn");
+ const addCoolingItemBtn = $("#add-cooling-item-btn");
- let roomTypeDropdown = $("#roomtype-select");
+ const roomTypeDropdown = $("#roomtype-select");
addRackBtn.on("click", () => {
this.handleItemClick("RACK");
@@ -137,7 +137,7 @@ export class RoomModeController {
MapController.showConfirmDeleteDialog("room", () => {
this.mapController.api.deleteRoom(this.mapView.simulation.id,
this.mapView.currentDatacenter.id, this.currentRoom.id).then(() => {
- let roomIndex = this.mapView.currentDatacenter.rooms.indexOf(this.currentRoom);
+ const roomIndex = this.mapView.currentDatacenter.rooms.indexOf(this.currentRoom);
this.mapView.currentDatacenter.rooms.splice(roomIndex, 1);
this.mapView.redrawMap();
@@ -148,7 +148,7 @@ export class RoomModeController {
// Handler for the room type dropdown component
roomTypeDropdown.on("change", () => {
- let newRoomType = this.roomTypes[roomTypeDropdown.val()];
+ const newRoomType = this.roomTypes[roomTypeDropdown.val()];
if (!this.checkRoomTypeLegality(newRoomType)) {
roomTypeDropdown.val(this.roomTypes.indexOf(this.currentRoom.roomType));
this.mapController.showInfoBalloon("Room type couldn't be changed, illegal objects", "warning");
@@ -167,10 +167,10 @@ export class RoomModeController {
public handleCanvasMouseClick(gridPos: IGridPosition): void {
if (this.roomInteractionMode === RoomInteractionMode.DEFAULT) {
- let tileIndex = Util.tileListPositionIndexOf(this.currentRoom.tiles, gridPos);
+ const tileIndex = Util.tileListPositionIndexOf(this.currentRoom.tiles, gridPos);
if (tileIndex !== -1) {
- let tile = this.currentRoom.tiles[tileIndex];
+ const tile = this.currentRoom.tiles[tileIndex];
if (tile.object !== undefined) {
this.mapController.interactionLevel = InteractionLevel.OBJECT;
@@ -192,11 +192,11 @@ export class RoomModeController {
}
private handleItemClick(type: string): void {
- let addRackBtn = $("#add-rack-btn");
- let addPSUBtn = $("#add-psu-btn");
- let addCoolingItemBtn = $("#add-cooling-item-btn");
- let allObjectContainers = $(".dc-component-container");
- let objectTypes = [
+ const addRackBtn = $("#add-rack-btn");
+ const addPSUBtn = $("#add-psu-btn");
+ const addCoolingItemBtn = $("#add-cooling-item-btn");
+ const allObjectContainers = $(".dc-component-container");
+ const objectTypes = [
{
type: "RACK",
mode: RoomInteractionMode.ADD_RACK,
@@ -264,7 +264,7 @@ export class RoomModeController {
return;
}
- let tileList = this.mapView.mapController.roomModeController.currentRoom.tiles;
+ const tileList = this.mapView.mapController.roomModeController.currentRoom.tiles;
for (let i = 0; i < tileList.length; i++) {
if (tileList[i].position.x === position.x && tileList[i].position.y === position.y) {
@@ -320,7 +320,7 @@ export class RoomModeController {
* Populates the room-type dropdown element with all available room types
*/
private populateRoomTypeDropdown(): void {
- let dropdown = $("#roomtype-select");
+ const dropdown = $("#roomtype-select");
this.roomTypes.forEach((type: string, index: number) => {
dropdown.append($('<option>').text(Util.toSentenceCase(type)).val(index));
@@ -331,9 +331,9 @@ export class RoomModeController {
* Loads all object types that are allowed in the current room into the menu.
*/
private populateAllowedObjectTypes(): void {
- let addObjectsLabel = $("#add-objects-label");
- let noObjectsInfo = $("#no-objects-info");
- let allowedObjectTypes = this.roomTypeMap[this.currentRoom.roomType];
+ const addObjectsLabel = $("#add-objects-label");
+ const noObjectsInfo = $("#no-objects-info");
+ const allowedObjectTypes = this.roomTypeMap[this.currentRoom.roomType];
$(".dc-component-container").addClass("hidden");
@@ -379,4 +379,4 @@ export class RoomModeController {
return legality;
}
-} \ No newline at end of file
+}
diff --git a/src/scripts/controllers/scaleindicator.ts b/src/scripts/controllers/scaleindicator.ts
index 0ff83486..789f2cc7 100644
--- a/src/scripts/controllers/scaleindicator.ts
+++ b/src/scripts/controllers/scaleindicator.ts
@@ -24,7 +24,7 @@ export class ScaleIndicatorController {
}
public update(): void {
- let currentZoom = this.mapView.mapContainer.scaleX;
+ const currentZoom = this.mapView.mapContainer.scaleX;
let newWidth;
do {
newWidth = (currentZoom * CELL_SIZE) / this.currentDivisor;
diff --git a/src/scripts/controllers/simulation/chart.ts b/src/scripts/controllers/simulation/chart.ts
index 84009622..5f94f412 100644
--- a/src/scripts/controllers/simulation/chart.ts
+++ b/src/scripts/controllers/simulation/chart.ts
@@ -52,7 +52,7 @@ export class ChartController {
room.tiles.forEach((tile: ITile) => {
if (tile.object !== undefined && tile.objectType === "RACK" && this.rackSeries[tile.objectId] === undefined) {
- let objectName = (<IRack>tile.object).name;
+ const objectName = (<IRack>tile.object).name;
this.names["ra" + tile.objectId] = objectName === "" || objectName === undefined ?
"Unnamed rack" : objectName;
@@ -177,7 +177,7 @@ export class ChartController {
machineId = this.mapController.nodeModeController.currentMachine.id;
}
- let unloads: string[] = [];
+ const unloads: string[] = [];
for (let id in this.names) {
if (this.names.hasOwnProperty(id)) {
if (machineId === -1) {
@@ -211,17 +211,17 @@ export class ChartController {
}
public tickUpdated(tick: number): void {
- let roomStates: IRoomState[] = this.simulationController.stateCache.stateList[tick].roomStates;
+ const roomStates: IRoomState[] = this.simulationController.stateCache.stateList[tick].roomStates;
roomStates.forEach((roomState: IRoomState) => {
ChartController.insertAtIndex(this.roomSeries[roomState.roomId].loadFractions, tick + 1, roomState.loadFraction);
});
- let rackStates: IRackState[] = this.simulationController.stateCache.stateList[tick].rackStates;
+ const rackStates: IRackState[] = this.simulationController.stateCache.stateList[tick].rackStates;
rackStates.forEach((rackState: IRackState) => {
ChartController.insertAtIndex(this.rackSeries[rackState.rackId].loadFractions, tick + 1, rackState.loadFraction);
});
- let machineStates: IMachineState[] = this.simulationController.stateCache.stateList[tick].machineStates;
+ const machineStates: IMachineState[] = this.simulationController.stateCache.stateList[tick].machineStates;
machineStates.forEach((machineState: IMachineState) => {
ChartController.insertAtIndex(this.machineSeries[machineState.machineId].loadFractions, tick + 1, machineState.loadFraction);
});
@@ -238,4 +238,4 @@ export class ChartController {
list[index] = data;
}
-} \ No newline at end of file
+}
diff --git a/src/scripts/controllers/simulation/statecache.ts b/src/scripts/controllers/simulation/statecache.ts
index 06dbd424..19fe0d8f 100644
--- a/src/scripts/controllers/simulation/statecache.ts
+++ b/src/scripts/controllers/simulation/statecache.ts
@@ -73,7 +73,7 @@ export class StateCache {
}
private cache(): void {
- let tick = this.lastCachedTick + 1;
+ const tick = this.lastCachedTick + 1;
this.updateLastTick().then(() => {
// Check if end of simulated region has been reached
@@ -85,7 +85,7 @@ export class StateCache {
this.stateList = data;
// Determine last cached tick
- let ticks = Object.keys(this.stateList).sort((a, b) => {
+ const ticks = Object.keys(this.stateList).sort((a, b) => {
return parseInt(a) - parseInt(b);
});
if (ticks.length > 0) {
@@ -209,7 +209,7 @@ export class StateCache {
);
return Promise.all(promises).then(() => {
- let tickStates: {[key: number]: ITickState} = {};
+ const tickStates: {[key: number]: ITickState} = {};
machineStates.forEach((machineState: IMachineState) => {
if (tickStates[machineState.tick] === undefined) {
@@ -269,7 +269,7 @@ export class StateCache {
}
private fetchAllStatesOfTick(tick: number): Promise<ITickState> {
- let tickState: ITickState = {
+ const tickState: ITickState = {
tick,
machineStates: [],
rackStates: [],
diff --git a/src/scripts/controllers/simulation/timeline.ts b/src/scripts/controllers/simulation/timeline.ts
index 950973a9..ec3d8cb4 100644
--- a/src/scripts/controllers/simulation/timeline.ts
+++ b/src/scripts/controllers/simulation/timeline.ts
@@ -45,8 +45,8 @@ export class TimelineController {
});
$(".timeline-container .timeline").on("click", (event: JQueryEventObject) => {
- let parentOffset = $(event.target).closest(".timeline").offset();
- let clickX = event.pageX - parentOffset.left;
+ const parentOffset = $(event.target).closest(".timeline").offset();
+ const clickX = event.pageX - parentOffset.left;
let newTick = Math.round(clickX / (this.timelineWidth * this.timeUnitFraction));
@@ -111,7 +111,7 @@ export class TimelineController {
private updateTaskIndicators(): void {
$(".task-indicator").remove();
- let tickStateTypes = {
+ const tickStateTypes = {
"queueEntryTick": "task-queued",
"startTick": "task-started",
"finishedTick": "task-finished"
@@ -121,7 +121,7 @@ export class TimelineController {
return;
}
- let indicatorCountList = new Array(this.simulationController.stateCache.lastCachedTick);
+ const indicatorCountList = new Array(this.simulationController.stateCache.lastCachedTick);
let indicator;
this.simulationController.currentExperiment.trace.tasks.forEach((task: ITask) => {
for (let tickStateType in tickStateTypes) {
diff --git a/src/scripts/controllers/simulationcontroller.ts b/src/scripts/controllers/simulationcontroller.ts
index 9f06df97..bb46575c 100644
--- a/src/scripts/controllers/simulationcontroller.ts
+++ b/src/scripts/controllers/simulationcontroller.ts
@@ -278,7 +278,7 @@ export class SimulationController {
return;
}
- let row = $(event.target).closest(".experiment-row");
+ const row = $(event.target).closest(".experiment-row");
this.prepareAndLaunchExperiment(this.experiments[row.index()]);
});
@@ -298,7 +298,7 @@ export class SimulationController {
});
$("#new-experiment-btn").click(() => {
- let nameInput = $("#new-experiment-name-input");
+ const nameInput = $("#new-experiment-name-input");
if (nameInput.val() === "") {
$(".experiment-name-alert").show();
return;
@@ -306,7 +306,7 @@ export class SimulationController {
$(".experiment-name-alert").hide();
}
- let newExperiment: IExperiment = {
+ const newExperiment: IExperiment = {
id: -1,
name: nameInput.val(),
pathId: parseInt($("#new-experiment-path-select").val()),
@@ -394,7 +394,7 @@ export class SimulationController {
* Populates the list of experiments.
*/
private populateExperimentsList(): void {
- let table = $(".experiment-list .list-body");
+ const table = $(".experiment-list .list-body");
table.empty();
console.log("EXPERIMENT", this.experiments);
@@ -531,7 +531,7 @@ export class SimulationController {
$("#room-name-field").text(this.mapController.roomModeController.currentRoom.name);
$("#room-type-field").text(this.mapController.roomModeController.currentRoom.roomType);
- let container = $(".room-stats-list");
+ const container = $(".room-stats-list");
container.children().remove("div");
@@ -550,13 +550,13 @@ export class SimulationController {
}
private setupColorMenu(): void {
- let html =
+ const html =
'<select class="form-control" title="Color Representation" id="color-representation-select">' +
' <option value="1" selected>Load</option>' +
' <option value="2">Power use</option>' +
'</select>';
- let indicator = $(".color-indicator");
+ const indicator = $(".color-indicator");
indicator["popover"]({
animation: true,
content: html,
@@ -572,7 +572,7 @@ export class SimulationController {
} else {
indicator["popover"]("show");
- let selectElement = $("#color-representation-select");
+ const selectElement = $("#color-representation-select");
selectElement.change(() => {
console.log(selectElement.val());
});