2023-04-10 15:36:59 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*/
|
|
|
|
|
2020-05-04 19:25:49 +00:00
|
|
|
import AllocationRow from 'nomad-ui/components/allocation-row';
|
2020-06-10 13:49:16 +00:00
|
|
|
import classic from 'ember-classic-decorator';
|
2022-03-08 17:28:36 +00:00
|
|
|
import { attributeBindings } from '@ember-decorators/component';
|
2020-05-04 19:25:49 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@classic
|
2022-03-08 17:28:36 +00:00
|
|
|
@attributeBindings(
|
|
|
|
'data-test-controller-allocation',
|
|
|
|
'data-test-node-allocation'
|
|
|
|
)
|
2020-06-10 13:49:16 +00:00
|
|
|
export default class PluginAllocationRow extends AllocationRow {
|
|
|
|
pluginAllocation = null;
|
|
|
|
allocation = null;
|
2020-05-12 02:59:38 +00:00
|
|
|
|
|
|
|
didReceiveAttrs() {
|
2020-05-13 04:29:27 +00:00
|
|
|
// Allocation is always set through pluginAllocation
|
|
|
|
this.set('allocation', null);
|
2020-05-12 02:59:38 +00:00
|
|
|
this.setAllocation();
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2020-05-12 02:59:38 +00:00
|
|
|
|
|
|
|
// The allocation for the plugin's controller or storage plugin needs
|
|
|
|
// to be imperatively fetched since these plugins are Fragments which
|
|
|
|
// can't have relationships.
|
|
|
|
async setAllocation() {
|
|
|
|
if (this.pluginAllocation && !this.allocation) {
|
|
|
|
const allocation = await this.pluginAllocation.getAllocation();
|
|
|
|
if (!this.isDestroyed) {
|
|
|
|
this.set('allocation', allocation);
|
|
|
|
this.updateStatsTracker();
|
|
|
|
}
|
|
|
|
}
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
|
|
|
}
|