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

@ -200,8 +200,8 @@
<th>{{serverTotals('vcpus')}}</th>
<th>{{serverTotals('ram')}} GB</th>
<th>{{serverTotals('disk')}} GB</th>
<th style="text-align: center">{{serverTotals('windows')}}</th>
<th style="text-align: center">{{serverTotals('sql')}}</th>
<th style="text-align: center" title="Total number of Windows VMs * vCPU cores / 2">{{serverTotals('windows')}}</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>{{serverTotals('cost') | currency}}</th>
<th>
@ -357,7 +357,7 @@
<div class="column">
<i class="huge fire alternate icon"></i>
<h3 class="ui inverted header">Advanced Firewall</h3>
<p>With an advanced firewall, we can protect your internal services frome xternal threats.</p>
<p>With an advanced firewall, we can protect your internal services from external threats.</p>
</div>
<div class="column">
<i class="huge windows icon"></i>

@ -1,11 +1,11 @@
var app = angular.module('instantQuote', []);
app.controller('Servers', function ($scope, $window, $http) {
$scope.servers = JSON.parse(localStorage.getItem("servers")) ?? [{ cost: 0 }]
$scope.extras = JSON.parse(localStorage.getItem("extras")) ?? {firewall: true, quota: 100}
$scope.extras = JSON.parse(localStorage.getItem("extras")) ?? { firewall: true, quota: 100 }
params = new URLSearchParams(window.location.search)
$scope.preload = params.get('preload')
if ($scope.preload && $scope.preload.match(/[0-9A-Z\-]+/g)) {
$http({
url: `preload/${$scope.preload}.json`
@ -38,8 +38,8 @@ app.controller('Servers', function ($scope, $window, $http) {
((server.vcpus || 0) * $scope.serverPricing.vcpu) +
((server.ram || 0) * $scope.serverPricing.ram) +
((server.disk || 0) * $scope.serverPricing.disk) +
(Math.ceil((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.windows ? 1 : 0) * $scope.serverPricing.windows * (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)
);
// console.log(server.cost)
@ -48,18 +48,24 @@ app.controller('Servers', function ($scope, $window, $http) {
$scope.serverTotals = (type) => {
localStorage.setItem("servers", angular.toJson($scope.servers));
return $scope.servers?.reduce(function (a, b) {
return a + (b?.[type] ?? 0);
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);
}
}, 0);
}
$scope.servicesTotals = () => {
localStorage.setItem("extras", angular.toJson($scope.extras));
return (
($scope.extras.firewall * $scope.serverPricing.firewall) +
($scope.extras.rdscals * $scope.serverPricing.rdscals) +
($scope.extras.firewall * $scope.serverPricing.firewall) +
($scope.extras.rdscals * $scope.serverPricing.rdscals) +
($scope.extras.quota * $scope.serverPricing.quota)
)
}
$scope.deleteServer = (server) => {
$scope.servers.splice(server,1);
$scope.servers.splice(server, 1);
}
});
Loading…
Cancel
Save