Fixed calculator, prefilled data

master
Ben Grabau 2 years ago
parent 8e68f02527
commit a0583b1709

@ -1,9 +1,4 @@
{ {
"extras": {
"firewall": true,
"quota": 1500,
"rdscals": 0
},
"servers": [ "servers": [
{ {
"cost": 914, "cost": 914,
@ -11,26 +6,19 @@
"vcpus": 8, "vcpus": 8,
"ram": 32, "ram": 32,
"disk": 200, "disk": 200,
"windows": true "windows": true,
}, "ip": false
{
"cost": 914,
"name": "GPG-RDS-02",
"vcpus": 8,
"ram": 32,
"disk": 200,
"windows": true
}, },
{ {
"cost": 236, "cost": 233,
"name": "GPG-BRK-02", "name": "GPG-BRK-02",
"vcpus": 2, "vcpus": 2,
"ram": 8, "ram": 8,
"disk": 100, "disk": 80,
"windows": true "windows": true
}, },
{ {
"cost": 1837, "cost": 1176,
"name": "GPG-SQL-02", "name": "GPG-SQL-02",
"vcpus": 4, "vcpus": 4,
"ram": 16, "ram": 16,
@ -39,11 +27,11 @@
"sql": true "sql": true
}, },
{ {
"cost": 236, "cost": 292,
"name": "GPG-DC-03", "name": "GPG-DC-03",
"vcpus": 2, "vcpus": 4,
"ram": 8, "ram": 8,
"disk": 100, "disk": 200,
"windows": true "windows": true
}, },
{ {
@ -56,12 +44,17 @@
"ip": true "ip": true
}, },
{ {
"cost": 75.75, "cost": 141.75,
"name": "GPG-L2T-01", "name": "GPG-L2T-01",
"vcpus": 2, "vcpus": 4,
"ram": 2, "ram": 4,
"disk": 10, "disk": 10,
"ip": true "ip": true
} }
] ],
"extras": {
"firewall": true,
"quota": 1000,
"rdscals": 20
}
} }

@ -200,8 +200,8 @@
<th>{{serverTotals('vcpus')}}</th> <th>{{serverTotals('vcpus')}}</th>
<th>{{serverTotals('ram')}} GB</th> <th>{{serverTotals('ram')}} GB</th>
<th>{{serverTotals('disk')}} GB</th> <th>{{serverTotals('disk')}} GB</th>
<th style="text-align: center">{{serverTotals('windows')}}</th> <th style="text-align: center" title="Total number of Windows VMs * vCPU cores / 2">{{serverTotals('windows')}}</th>
<th style="text-align: center">{{serverTotals('sql')}}</th> <th style="text-align: center" title="Total number of Windows VMs with SQL Server Standard * vCPU cores / 2">{{serverTotals('sql')}}</th>
<th style="text-align: center">{{serverTotals('ip')}}</th> <th style="text-align: center">{{serverTotals('ip')}}</th>
<th>{{serverTotals('cost') | currency}}</th> <th>{{serverTotals('cost') | currency}}</th>
<th> <th>

@ -38,8 +38,8 @@ app.controller('Servers', function ($scope, $window, $http) {
((server.vcpus || 0) * $scope.serverPricing.vcpu) + ((server.vcpus || 0) * $scope.serverPricing.vcpu) +
((server.ram || 0) * $scope.serverPricing.ram) + ((server.ram || 0) * $scope.serverPricing.ram) +
((server.disk || 0) * $scope.serverPricing.disk) + ((server.disk || 0) * $scope.serverPricing.disk) +
(Math.ceil((server.windows ? 1 : 0) * $scope.serverPricing.windows * (server.vcpus || 0) / 2) * 2) + (Math.floor((server.windows ? 1 : 0) * $scope.serverPricing.windows * (server.vcpus || 0) / 2) * 2) +
(Math.ceil((server.sql ? 1 : 0) * $scope.serverPricing.sql * (server.vcpus || 0) / 2) * 2) + (Math.floor((server.sql ? 1 : 0) * $scope.serverPricing.sql * (server.vcpus || 0) / 2)) +
((server.ip ? 1 : 0) * $scope.serverPricing.ip) ((server.ip ? 1 : 0) * $scope.serverPricing.ip)
); );
// console.log(server.cost) // console.log(server.cost)
@ -48,7 +48,13 @@ app.controller('Servers', function ($scope, $window, $http) {
$scope.serverTotals = (type) => { $scope.serverTotals = (type) => {
localStorage.setItem("servers", angular.toJson($scope.servers)); localStorage.setItem("servers", angular.toJson($scope.servers));
return $scope.servers?.reduce(function (a, b) { return $scope.servers?.reduce(function (a, b) {
if (type == "windows") {
return a + ((b?.windows ?? 0) * (b.vcpus ?? 0) / 2 ?? 0);
} else if (type == "sql") {
return a + ((b?.sql ?? 0) * (b.vcpus ?? 0) / 2 ?? 0);
} else {
return a + (b?.[type] ?? 0); return a + (b?.[type] ?? 0);
}
}, 0); }, 0);
} }
$scope.servicesTotals = () => { $scope.servicesTotals = () => {

Loading…
Cancel
Save