summaryrefslogtreecommitdiff
path: root/frontend/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/util')
-rw-r--r--frontend/src/util/date-time.js17
-rw-r--r--frontend/src/util/date-time.test.js2
-rw-r--r--frontend/src/util/room-types.js7
-rw-r--r--frontend/src/util/tile-calculations.js18
-rw-r--r--frontend/src/util/timeline.js14
-rw-r--r--frontend/src/util/unit-specifications.js46
6 files changed, 58 insertions, 46 deletions
diff --git a/frontend/src/util/date-time.js b/frontend/src/util/date-time.js
index d176ebef..66efdf5b 100644
--- a/frontend/src/util/date-time.js
+++ b/frontend/src/util/date-time.js
@@ -39,10 +39,7 @@ export function formatDateTime(dateTime) {
'/' +
addPaddingToTwo(dateTime.getFullYear())
- if (
- dateTime.getFullYear() === currentDate.getFullYear() &&
- dateTime.getMonth() === currentDate.getMonth()
- ) {
+ if (dateTime.getFullYear() === currentDate.getFullYear() && dateTime.getMonth() === currentDate.getMonth()) {
if (dateTime.getDate() === currentDate.getDate()) {
date = 'Today'
} else if (dateTime.getDate() === currentDate.getDate() - 1) {
@@ -50,13 +47,7 @@ export function formatDateTime(dateTime) {
}
}
- return (
- date +
- ', ' +
- addPaddingToTwo(dateTime.getHours()) +
- ':' +
- addPaddingToTwo(dateTime.getMinutes())
- )
+ return date + ', ' + addPaddingToTwo(dateTime.getHours()) + ':' + addPaddingToTwo(dateTime.getMinutes())
}
/**
@@ -83,9 +74,7 @@ export function convertSecondsToFormattedTime(seconds) {
} else if (hour === 0) {
return minute + 'm' + addPaddingToTwo(second) + 's'
} else {
- return (
- hour + 'h' + addPaddingToTwo(minute) + 'm' + addPaddingToTwo(second) + 's'
- )
+ return hour + 'h' + addPaddingToTwo(minute) + 'm' + addPaddingToTwo(second) + 's'
}
}
diff --git a/frontend/src/util/date-time.test.js b/frontend/src/util/date-time.test.js
index 9274d4b7..3d95eba6 100644
--- a/frontend/src/util/date-time.test.js
+++ b/frontend/src/util/date-time.test.js
@@ -15,7 +15,7 @@ describe('date-time parsing', () => {
})
describe('tick formatting', () => {
- it('returns \'0s\' for numbers <= 0', () => {
+ it("returns '0s' for numbers <= 0", () => {
expect(convertSecondsToFormattedTime(-1)).toEqual('0s')
expect(convertSecondsToFormattedTime(0)).toEqual('0s')
})
diff --git a/frontend/src/util/room-types.js b/frontend/src/util/room-types.js
deleted file mode 100644
index ff69d013..00000000
--- a/frontend/src/util/room-types.js
+++ /dev/null
@@ -1,7 +0,0 @@
-export const ROOM_TYPE_TO_NAME_MAP = {
- SERVER: 'Server room',
- HALLWAY: 'Hallway',
- OFFICE: 'Office',
- POWER: 'Power room',
- COOLING: 'Cooling room',
-}
diff --git a/frontend/src/util/tile-calculations.js b/frontend/src/util/tile-calculations.js
index 3ef1cff6..764ae6ac 100644
--- a/frontend/src/util/tile-calculations.js
+++ b/frontend/src/util/tile-calculations.js
@@ -7,7 +7,7 @@ function getWallSegments(tiles) {
const verticalWalls = {}
const horizontalWalls = {}
- tiles.forEach(tile => {
+ tiles.forEach((tile) => {
const x = tile.positionX,
y = tile.positionY
@@ -19,10 +19,7 @@ function getWallSegments(tiles) {
let doInsert = true
for (let tileIndex in tiles) {
- if (
- tiles[tileIndex].positionX === x + dX &&
- tiles[tileIndex].positionY === y + dY
- ) {
+ if (tiles[tileIndex].positionX === x + dX && tiles[tileIndex].positionY === y + dY) {
doInsert = false
break
}
@@ -143,7 +140,7 @@ export function deriveValidNextTilePositions(rooms, selectedTiles) {
newPosition = { x: 0, y: 0 }
let isSurroundingTile
- selectedTiles.forEach(tile => {
+ selectedTiles.forEach((tile) => {
const x = tile.positionX
const y = tile.positionY
result.push({ x, y })
@@ -168,10 +165,7 @@ export function deriveValidNextTilePositions(rooms, selectedTiles) {
}
}
- if (
- isSurroundingTile &&
- findPositionInRooms(rooms, newPosition.x, newPosition.y) === -1
- ) {
+ if (isSurroundingTile && findPositionInRooms(rooms, newPosition.x, newPosition.y) === -1) {
result.push({ x: newPosition.x, y: newPosition.y })
}
}
@@ -231,8 +225,8 @@ export function calculateRoomListBounds(rooms) {
const min = { x: Number.MAX_VALUE, y: Number.MAX_VALUE }
const max = { x: -1, y: -1 }
- rooms.forEach(room => {
- room.tiles.forEach(tile => {
+ rooms.forEach((room) => {
+ room.tiles.forEach((tile) => {
if (tile.positionX < min.x) {
min.x = tile.positionX
}
diff --git a/frontend/src/util/timeline.js b/frontend/src/util/timeline.js
index 21258e23..7c8a3ef0 100644
--- a/frontend/src/util/timeline.js
+++ b/frontend/src/util/timeline.js
@@ -2,18 +2,8 @@ export function convertTickToPercentage(tick, maxTick) {
if (maxTick === 0) {
return '0%'
} else if (tick > maxTick) {
- return maxTick / (maxTick + 1) * 100 + '%'
+ return (maxTick / (maxTick + 1)) * 100 + '%'
}
- return tick / (maxTick + 1) * 100 + '%'
-}
-
-export function getDatacenterIdOfTick(tick, sections) {
- for (let i in sections.reverse()) {
- if (tick >= sections[i].startTick) {
- return sections[i].datacenterId
- }
- }
-
- return -1
+ return (tick / (maxTick + 1)) * 100 + '%'
}
diff --git a/frontend/src/util/unit-specifications.js b/frontend/src/util/unit-specifications.js
new file mode 100644
index 00000000..43c45b7e
--- /dev/null
+++ b/frontend/src/util/unit-specifications.js
@@ -0,0 +1,46 @@
+export const CPU_UNITS = {
+ 'cpu-1': {
+ _id: 'cpu-1',
+ name: 'Intel i7 v6 6700k',
+ clockRateMhz: 4100,
+ numberOfCores: 4,
+ energyConsumptionW: 70,
+ },
+ 'cpu-2': {
+ _id: 'cpu-2',
+ name: 'Intel i5 v6 6700k',
+ clockRateMhz: 3500,
+ numberOfCores: 2,
+ energyConsumptionW: 50,
+ },
+}
+
+export const GPU_UNITS = {
+ 'gpu-1': {
+ _id: 'gpu-1',
+ name: 'NVIDIA GTX 4 1080',
+ clockRateMhz: 1200,
+ numberOfCores: 200,
+ energyConsumptionW: 250,
+ },
+}
+
+export const MEMORY_UNITS = {
+ 'memory-1': {
+ _id: 'memory-1',
+ name: 'Samsung PC DRAM K4A4G045WD',
+ speedMbPerS: 16000,
+ sizeMb: 4000,
+ energyConsumptionW: 10,
+ },
+}
+
+export const STORAGE_UNITS = {
+ 'storage-1': {
+ _id: 'storage-1',
+ name: 'Samsung EVO 2016 SATA III',
+ speedMbPerS: 6000,
+ sizeMb: 250000,
+ energyConsumptionW: 10,
+ },
+}