mirror of
https://github.com/fleetbase/fleetbase.git
synced 2026-01-08 07:16:49 +00:00
40 lines
1001 B
JavaScript
40 lines
1001 B
JavaScript
import Component from '@glimmer/component';
|
|
import { tracked } from '@glimmer/tracking';
|
|
import { inject as service } from '@ember/service';
|
|
import { action } from '@ember/object';
|
|
import { isArray } from '@ember/array';
|
|
import { task } from 'ember-concurrency';
|
|
|
|
export default class MetricComponent extends Component {
|
|
@service fetch;
|
|
@tracked isLoading = false;
|
|
@tracked dashboard;
|
|
|
|
constructor() {
|
|
super(...arguments);
|
|
this.loadDashboard.perform();
|
|
}
|
|
|
|
@action onQueryParamsChanged(changedParams) {
|
|
this.loadDashboard.perform(changedParams);
|
|
}
|
|
|
|
@task *loadDashboard(params) {
|
|
let dashboards = [];
|
|
|
|
this.isLoading = true;
|
|
|
|
try {
|
|
dashboards = yield this.fetch.get(this.args.options.endpoint, params, { namespace: '' });
|
|
} catch {
|
|
return;
|
|
}
|
|
|
|
this.isLoading = false;
|
|
|
|
if (isArray(dashboards)) {
|
|
this.dashboard = dashboards.objectAt(0);
|
|
}
|
|
}
|
|
}
|