Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dedicated.server): dont call orderable endpoint if not orderable #12152

Merged
merged 2 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default /* @ngInject */ ($stateProvider) => {
$stateParams,
BandwidthVrackOrderService,
Server,
server,
) =>
$q
.all({
Expand All @@ -27,7 +28,7 @@ export default /* @ngInject */ ($stateProvider) => {
$stateParams.productId,
),
bandwidthVrackOrderOptions: BandwidthVrackOrderService.getOrderableBandwidths(
$stateParams.productId,
server,
),
})
.then(
Expand Down Expand Up @@ -262,15 +263,14 @@ export default /* @ngInject */ ($stateProvider) => {
$stateParams,
ServerOrderTrafficService,
ServerTrafficService,
server,
) =>
$q.all({
traffic: ServerTrafficService.getTraffic($stateParams.productId),
trafficOption: ServerOrderTrafficService.getOption(
$stateParams.productId,
),
trafficOrderables: ServerOrderTrafficService.getOrderables(
$stateParams.productId,
),
trafficOrderables: ServerOrderTrafficService.getOrderables(server),
}),
goToTrafficOrder: /* @ngInject */ ($state, serverName) => () =>
$state.go('app.dedicated-server.server.dashboard.traffic-order', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ export default class ServerOrderTrafficService {
this.Server = Server;
}

getOrderables(productId) {
return this.Server.getOrderables(productId, 'traffic')
getOrderables(server) {
if (!server.canOrderQuota) {
return this.$q.resolve(null);
}
return this.Server.getOrderables(server.name, 'traffic')
.then((response) =>
this.acceptResponse(this.transformOrderables(response.traffic)),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ export default class BandwidthVrackOrderService extends BaseDedicatedService {
this.Server = Server;
}

getOrderableBandwidths(productId) {
return this.Server.getOrderables(productId, 'bandwidthvRack')
getOrderableBandwidths(server) {
if (!server.canOrderVrackBandwith) {
return this.$q.resolve(null);
}
return this.Server.getOrderables(server.name, 'bandwidthvRack')
.then((response) =>
super.acceptResponse(this.transformOrderableBandwidths(response.vrack)),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,16 +414,16 @@ export default class ServerCtrl {

this.$scope.$broadcast('dedicated.server.refreshTabs');

return this.Server.getUsbStorageInformations(
this.$stateParams.productId,
).then((usbStorageInformations) => {
if (
isArray(usbStorageInformations) &&
usbStorageInformations[1].usbKeys
) {
this.$scope.disable.usbStorageTab = true;
}
});
return this.Server.getUsbStorageInformations(this.server).then(
(usbStorageInformations) => {
if (
isArray(usbStorageInformations) &&
usbStorageInformations[1].usbKeys
) {
this.$scope.disable.usbStorageTab = true;
}
},
);
}

getTaskInProgress() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1337,12 +1337,17 @@ export default class Server {
});
}

getUsbStorageInformations(productId) {
const orderable = this.get(productId, 'orderable/usbKey', {
proxypass: true,
});
getUsbStorageInformations(server) {
let orderable;
if (!server.canOrderUsbDisk) {
orderable = this.$q.resolve(null);
} else {
orderable = this.get(server.name, 'orderable/usbKey', {
proxypass: true,
});
}

const specification = this.get(productId, 'specifications/hardware', {
const specification = this.get(server.name, 'specifications/hardware', {
proxypass: true,
});

Expand Down
Loading