2020-07-20 21:08:20 +00:00
|
|
|
class ContainerInstanceDetailsController {
|
|
|
|
/* @ngInject */
|
|
|
|
constructor($state, AzureService, ContainerGroupService, Notifications, ResourceGroupService, SubscriptionService) {
|
|
|
|
Object.assign(this, { $state, AzureService, ContainerGroupService, Notifications, ResourceGroupService, SubscriptionService });
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
loading: false,
|
|
|
|
};
|
|
|
|
|
|
|
|
this.container = null;
|
|
|
|
this.subscription = null;
|
|
|
|
this.resourceGroup = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
async $onInit() {
|
|
|
|
this.state.loading = true;
|
|
|
|
const { id } = this.$state.params;
|
|
|
|
const { subscriptionId, resourceGroupId, containerGroupId } = parseId(id);
|
|
|
|
try {
|
|
|
|
this.subscription = await this.SubscriptionService.subscription(subscriptionId);
|
|
|
|
this.container = await this.ContainerGroupService.containerGroup(subscriptionId, resourceGroupId, containerGroupId);
|
|
|
|
this.resourceGroup = await this.ResourceGroupService.resourceGroup(subscriptionId, resourceGroupId);
|
|
|
|
} catch (err) {
|
2021-10-14 12:42:10 +00:00
|
|
|
this.Notifications.error('Failure', err, 'Unable to retrieve container instance details');
|
2020-07-20 21:08:20 +00:00
|
|
|
}
|
|
|
|
this.state.loading = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function parseId(id) {
|
|
|
|
const [, subscriptionId, resourceGroupId, , containerGroupId] = id.match(/^\/subscriptions\/(.+)\/resourceGroups\/(.+)\/providers\/(.+)\/containerGroups\/(.+)$/);
|
|
|
|
|
|
|
|
return { subscriptionId, resourceGroupId, containerGroupId };
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ContainerInstanceDetailsController;
|