diff options
Diffstat (limited to 'src/scripts/views')
| -rw-r--r-- | src/scripts/views/layers/dcobject.ts | 18 | ||||
| -rw-r--r-- | src/scripts/views/layers/dcprogressbar.ts | 6 | ||||
| -rw-r--r-- | src/scripts/views/layers/gray.ts | 6 | ||||
| -rw-r--r-- | src/scripts/views/layers/room.ts | 6 | ||||
| -rw-r--r-- | src/scripts/views/layers/roomtext.ts | 6 | ||||
| -rw-r--r-- | src/scripts/views/mapview.ts | 48 |
6 files changed, 44 insertions, 46 deletions
diff --git a/src/scripts/views/layers/dcobject.ts b/src/scripts/views/layers/dcobject.ts index 6cec1f7e..f883a218 100644 --- a/src/scripts/views/layers/dcobject.ts +++ b/src/scripts/views/layers/dcobject.ts @@ -31,7 +31,7 @@ export class DCObjectLayer implements Layer { public static drawHoverRack(position: IGridPosition): createjs.Container { - let result = new createjs.Container(); + const result = new createjs.Container(); DCObjectLayer.drawItemRectangle( position, Colors.RACK_BACKGROUND, Colors.RACK_BORDER, result @@ -47,7 +47,7 @@ export class DCObjectLayer implements Layer { } public static drawHoverPSU(position: IGridPosition): createjs.Container { - let result = new createjs.Container(); + const result = new createjs.Container(); DCObjectLayer.drawItemRectangle( position, Colors.PSU_BACKGROUND, Colors.PSU_BORDER, result @@ -57,7 +57,7 @@ export class DCObjectLayer implements Layer { } public static drawHoverCoolingItem(position: IGridPosition): createjs.Container { - let result = new createjs.Container(); + const result = new createjs.Container(); DCObjectLayer.drawItemRectangle( position, Colors.COOLING_ITEM_BACKGROUND, Colors.COOLING_ITEM_BORDER, result @@ -77,7 +77,7 @@ export class DCObjectLayer implements Layer { */ private static drawItemRectangle(position: IGridPosition, color: string, borderColor: string, container: createjs.Container): createjs.Shape { - let shape = new createjs.Shape(); + const shape = new createjs.Shape(); shape.graphics.beginStroke(borderColor); shape.graphics.setStrokeStyle(DCObjectLayer.STROKE_WIDTH); shape.graphics.beginFill(color); @@ -101,7 +101,7 @@ export class DCObjectLayer implements Layer { */ private static drawItemIcon(position: IGridPosition, container: createjs.Container, originBitmap: createjs.Bitmap): createjs.Bitmap { - let bitmap = originBitmap.clone(); + const bitmap = originBitmap.clone(); container.addChild(bitmap); bitmap.x = position.x * CELL_SIZE + DCObjectLayer.ITEM_MARGIN + DCObjectLayer.ITEM_PADDING * 1.5; bitmap.y = position.y * CELL_SIZE + DCObjectLayer.ITEM_MARGIN + DCObjectLayer.ITEM_PADDING * 1.5; @@ -157,7 +157,7 @@ export class DCObjectLayer implements Layer { this.mapView.currentDatacenter.rooms.forEach((room: IRoom) => { room.tiles.forEach((tile: ITile) => { if (tile.object !== undefined) { - let index = tile.position.y * MapView.MAP_SIZE + tile.position.x; + const index = tile.position.y * MapView.MAP_SIZE + tile.position.x; switch (tile.objectType) { case "RACK": @@ -194,15 +194,13 @@ export class DCObjectLayer implements Layer { } public draw(): void { - let currentObject; - this.container.removeAllChildren(); this.container.cursor = "pointer"; for (let property in this.dcObjectMap) { if (this.dcObjectMap.hasOwnProperty(property)) { - currentObject = this.dcObjectMap[property]; + const currentObject = this.dcObjectMap[property]; switch (currentObject.type) { case "RACK": @@ -249,4 +247,4 @@ export class DCObjectLayer implements Layer { this.mapView.updateScene = true; } -}
\ No newline at end of file +} diff --git a/src/scripts/views/layers/dcprogressbar.ts b/src/scripts/views/layers/dcprogressbar.ts index d0ec4397..e518ead4 100644 --- a/src/scripts/views/layers/dcprogressbar.ts +++ b/src/scripts/views/layers/dcprogressbar.ts @@ -30,7 +30,7 @@ export class DCProgressBar { public static drawItemProgressRectangle(position: IGridPosition, color: string, container: createjs.Container, distanceFromBottom: number, fractionFilled: number): createjs.Shape { - let shape = new createjs.Shape(); + const shape = new createjs.Shape(); shape.graphics.beginFill(color); let x = position.x * CELL_SIZE + DCObjectLayer.ITEM_MARGIN + DCObjectLayer.ITEM_PADDING; let y = (position.y + 1) * CELL_SIZE - DCObjectLayer.ITEM_MARGIN - DCObjectLayer.ITEM_PADDING - @@ -67,7 +67,7 @@ export class DCProgressBar { */ public static drawProgressbarIcon(position: IGridPosition, container: createjs.Container, originBitmap: createjs.Bitmap, distanceFromBottom: number): createjs.Bitmap { - let bitmap = originBitmap.clone(); + const bitmap = originBitmap.clone(); container.addChild(bitmap); bitmap.x = (position.x + 0.5) * CELL_SIZE - DCProgressBar.PROGRESS_BAR_WIDTH * 0.5; bitmap.y = (position.y + 1) * CELL_SIZE - DCObjectLayer.ITEM_MARGIN - DCObjectLayer.ITEM_PADDING - @@ -96,4 +96,4 @@ export class DCProgressBar { DCProgressBar.drawProgressbarIcon(this.position, this.container, this.bitmap, this.distanceFromBottom); } -}
\ No newline at end of file +} diff --git a/src/scripts/views/layers/gray.ts b/src/scripts/views/layers/gray.ts index ed3c9429..63911d19 100644 --- a/src/scripts/views/layers/gray.ts +++ b/src/scripts/views/layers/gray.ts @@ -33,9 +33,9 @@ export class GrayLayer implements Layer { this.container.removeAllChildren(); - let roomBounds = Util.calculateRoomBounds(this.currentRoom); + const roomBounds = Util.calculateRoomBounds(this.currentRoom); - let shape = new createjs.Shape(); + const shape = new createjs.Shape(); shape.graphics.beginFill(Colors.GRAYED_OUT_AREA); shape.cursor = "pointer"; @@ -142,4 +142,4 @@ export class GrayLayer implements Layer { public isGrayedOut(): boolean { return this.currentRoom !== undefined; } -}
\ No newline at end of file +} diff --git a/src/scripts/views/layers/room.ts b/src/scripts/views/layers/room.ts index 0e31fee0..c1989206 100644 --- a/src/scripts/views/layers/room.ts +++ b/src/scripts/views/layers/room.ts @@ -65,7 +65,7 @@ export class RoomLayer implements Layer { public addSelectedTile(tile: ITile): void { this.selectedTiles.push(tile); - let tileObject = MapView.drawRectangle(tile.position, Colors.ROOM_SELECTED, this.container); + const tileObject = MapView.drawRectangle(tile.position, Colors.ROOM_SELECTED, this.container); this.selectedTileObjects.push({ position: {x: tile.position.x, y: tile.position.y}, tileObject: tileObject @@ -84,7 +84,7 @@ export class RoomLayer implements Layer { * @param objectIndex The index of the tile in the selectedTileObjects array */ public removeSelectedTile(position: IGridPosition, objectIndex: number): void { - let index = Util.tileListPositionIndexOf(this.selectedTiles, position); + const index = Util.tileListPositionIndexOf(this.selectedTiles, position); // Check whether the given position doesn't belong to an already removed tile if (index === -1) { @@ -174,4 +174,4 @@ export class RoomLayer implements Layer { tileObj.tileObject.cursor = value ? "pointer" : "default"; }); } -}
\ No newline at end of file +} diff --git a/src/scripts/views/layers/roomtext.ts b/src/scripts/views/layers/roomtext.ts index 65ea0735..63fab0ed 100644 --- a/src/scripts/views/layers/roomtext.ts +++ b/src/scripts/views/layers/roomtext.ts @@ -42,15 +42,15 @@ export class RoomTextLayer implements Layer { return; } - let textPos = Util.calculateRoomNamePosition(room); + const textPos = Util.calculateRoomNamePosition(room); - let bottomY = this.renderText(room.name, "12px Arial", textPos, + const bottomY = this.renderText(room.name, "12px Arial", textPos, textPos.topLeft.y * CELL_SIZE + RoomTextLayer.TEXT_PADDING); this.renderText("Type: " + Util.toSentenceCase(room.roomType), "10px Arial", textPos, bottomY + 5); } private renderText(text: string, font: string, textPos: IRoomNamePos, startY: number): number { - let name = new createjs.Text(text, font, Colors.ROOM_NAME_COLOR); + const name = new createjs.Text(text, font, Colors.ROOM_NAME_COLOR); if (name.getMeasuredWidth() > textPos.length * CELL_SIZE - RoomTextLayer.TEXT_PADDING * 2) { name.scaleX = name.scaleY = (textPos.length * CELL_SIZE - RoomTextLayer.TEXT_PADDING * 2) / diff --git a/src/scripts/views/mapview.ts b/src/scripts/views/mapview.ts index ae7fd5cb..50fc2e45 100644 --- a/src/scripts/views/mapview.ts +++ b/src/scripts/views/mapview.ts @@ -70,7 +70,7 @@ export class MapView { */ public static drawLine(x1: number, y1: number, x2: number, y2: number, lineWidth: number, color: string, container: createjs.Container): createjs.Shape { - let line = new createjs.Shape(); + const line = new createjs.Shape(); line.graphics.setStrokeStyle(lineWidth).beginStroke(color); line.graphics.moveTo(x1, y1); line.graphics.lineTo(x2, y2); @@ -89,7 +89,7 @@ export class MapView { */ public static drawRectangle(position: IGridPosition, color: string, container: createjs.Container, sizeX?: number, sizeY?: number): createjs.Shape { - let tile = new createjs.Shape(); + const tile = new createjs.Shape(); tile.graphics.setStrokeStyle(0); tile.graphics.beginFill(color); tile.graphics.drawRect( @@ -125,14 +125,14 @@ export class MapView { constructor(simulation: ISimulation, stage: createjs.Stage) { this.simulation = simulation; - let path = this.simulation.paths[this.simulation.paths.length - 1]; + const path = this.simulation.paths[this.simulation.paths.length - 1]; this.currentDatacenter = path.sections[path.sections.length - 1].datacenter; this.stage = stage; console.log("THE DATA", simulation); - let canvas = $("#main-canvas"); + const canvas = $("#main-canvas"); this.canvasWidth = canvas.width(); this.canvasHeight = canvas.height(); @@ -207,22 +207,22 @@ export class MapView { // Calculate position difference if zoomed, in order to later compensate for this // unwanted movement - let oldPosition = [ + const oldPosition = [ position[0] - this.mapContainer.x, position[1] - this.mapContainer.y ]; - let newPosition = [ + const newPosition = [ (oldPosition[0] / this.mapContainer.scaleX) * newZoom, (oldPosition[1] / this.mapContainer.scaleX) * newZoom ]; - let positionDelta = [ + const positionDelta = [ newPosition[0] - oldPosition[0], newPosition[1] - oldPosition[1] ]; // Apply the transformation operation to keep the selected position static - let newX = this.mapContainer.x - positionDelta[0]; - let newY = this.mapContainer.y - positionDelta[1]; + const newX = this.mapContainer.x - positionDelta[0]; + const newY = this.mapContainer.y - positionDelta[1]; - let finalPos = this.mapController.checkCanvasMovement(newX, newY, newZoom); + const finalPos = this.mapController.checkCanvasMovement(newX, newY, newZoom); if (!this.animating) { this.animate(this.mapContainer, { @@ -270,24 +270,24 @@ export class MapView { * @param rooms The array of rooms to be viewed */ private zoomInOnRooms(rooms: IRoom[]): void { - let bounds = Util.calculateRoomListBounds(rooms); - let newScale = this.calculateNewScale(bounds); + const bounds = Util.calculateRoomListBounds(rooms); + const newScale = this.calculateNewScale(bounds); // Coordinates of the center of the room, relative to the global origin of the map - let roomCenterCoords = [ + const roomCenterCoords = [ bounds.center[0] * CELL_SIZE * newScale, bounds.center[1] * CELL_SIZE * newScale ]; // Coordinates of the center of the stage (the visible part of the canvas), relative to the global map origin - let stageCenterCoords = [ + const stageCenterCoords = [ -this.mapContainer.x + this.canvasWidth / 2, -this.mapContainer.y + this.canvasHeight / 2 ]; - let newX = this.mapContainer.x - roomCenterCoords[0] + stageCenterCoords[0]; - let newY = this.mapContainer.y - roomCenterCoords[1] + stageCenterCoords[1]; + const newX = this.mapContainer.x - roomCenterCoords[0] + stageCenterCoords[0]; + const newY = this.mapContainer.y - roomCenterCoords[1] + stageCenterCoords[1]; - let newPosition = this.mapController.checkCanvasMovement(newX, newY, newScale); + const newPosition = this.mapController.checkCanvasMovement(newX, newY, newScale); this.animate(this.mapContainer, { scaleX: newScale, scaleY: newScale, @@ -299,11 +299,11 @@ export class MapView { const viewPadding = 30; const sideMenuWidth = 350; - let width = bounds.max[0] - bounds.min[0]; - let height = bounds.max[1] - bounds.min[1]; + const width = bounds.max[0] - bounds.min[0]; + const height = bounds.max[1] - bounds.min[1]; - let scaleX = (this.canvasWidth - 2 * sideMenuWidth) / (width * CELL_SIZE + 2 * viewPadding); - let scaleY = this.canvasHeight / (height * CELL_SIZE + 2 * viewPadding); + const scaleX = (this.canvasWidth - 2 * sideMenuWidth) / (width * CELL_SIZE + 2 * viewPadding); + const scaleY = this.canvasHeight / (height * CELL_SIZE + 2 * viewPadding); let newScale = Math.min(scaleX, scaleY); @@ -321,10 +321,10 @@ export class MapView { */ private drawMap(): void { // Create and draw the container for the entire map - let gridPixelSize = CELL_SIZE * MapView.MAP_SIZE; + const gridPixelSize = CELL_SIZE * MapView.MAP_SIZE; // Add a white background to the entire container - let background = new createjs.Shape(); + const background = new createjs.Shape(); background.graphics.beginFill("#fff"); background.graphics.drawRect(0, 0, gridPixelSize, gridPixelSize); @@ -370,4 +370,4 @@ export class MapView { } }); } -}
\ No newline at end of file +} |
