|
|
|
|
@ -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);
|
|
|
|
|
}
|
|
|
|
|
});
|