eca0e7bf56
* button styles * Further styles including global toggle adjustment * sidebar funcs and header * Functioning task logs in high-level sidebars * same-lineify the show tasks toggle * Changelog * Full-height sidebar calc in css, plz drop soon container queries * Active status and query params for allocations page * Reactive shouldShowLogs getter and added to client and task group pages * Higher order func passing, thanks @DingoEatingFuzz * Non-service job types get allocation params passed * Keyframe animation for task log sidebar * Acceptance test * A few more sub-row tests * Lintfix
93 lines
2.2 KiB
JavaScript
93 lines
2.2 KiB
JavaScript
import Ember from 'ember';
|
|
import Component from '@glimmer/component';
|
|
import { inject as service } from '@ember/service';
|
|
import { action } from '@ember/object';
|
|
import { computed } from '@ember/object';
|
|
import { alias } from '@ember/object/computed';
|
|
import { task, timeout } from 'ember-concurrency';
|
|
import { tracked } from '@glimmer/tracking';
|
|
|
|
export default class TaskSubRowComponent extends Component {
|
|
@service store;
|
|
@service router;
|
|
@service('stats-trackers-registry') statsTrackersRegistry;
|
|
|
|
constructor() {
|
|
super(...arguments);
|
|
// Kick off stats polling
|
|
const allocation = this.task.allocation;
|
|
if (allocation) {
|
|
this.fetchStats.perform();
|
|
} else {
|
|
this.fetchStats.cancelAll();
|
|
}
|
|
}
|
|
|
|
@alias('args.taskState') task;
|
|
|
|
@action
|
|
gotoTask(allocation, task) {
|
|
this.router.transitionTo('allocations.allocation.task', allocation, task);
|
|
}
|
|
|
|
// Since all tasks for an allocation share the same tracker, use the registry
|
|
@computed('task.{allocation,isRunning}')
|
|
get stats() {
|
|
if (!this.task.isRunning) return undefined;
|
|
|
|
return this.statsTrackersRegistry.getTracker(this.task.allocation);
|
|
}
|
|
|
|
// Internal state
|
|
@tracked statsError = false;
|
|
|
|
@computed
|
|
get enablePolling() {
|
|
return !Ember.testing;
|
|
}
|
|
|
|
@computed('task.name', 'stats.tasks.[]')
|
|
get taskStats() {
|
|
if (!this.stats) return undefined;
|
|
|
|
return this.stats.tasks.findBy('task', this.task.name);
|
|
}
|
|
|
|
@alias('taskStats.cpu.lastObject') cpu;
|
|
@alias('taskStats.memory.lastObject') memory;
|
|
|
|
@(task(function* () {
|
|
do {
|
|
if (this.stats) {
|
|
try {
|
|
yield this.stats.poll.linked().perform();
|
|
this.statsError = false;
|
|
} catch (error) {
|
|
this.statsError = true;
|
|
}
|
|
}
|
|
|
|
yield timeout(500);
|
|
} while (this.enablePolling);
|
|
}).drop())
|
|
fetchStats;
|
|
|
|
//#region Logs Sidebar
|
|
|
|
@alias('args.active') shouldShowLogs;
|
|
|
|
@action handleTaskLogsClick(task) {
|
|
if (this.args.onSetActiveTask) {
|
|
this.args.onSetActiveTask(task);
|
|
}
|
|
}
|
|
|
|
@action closeSidebar() {
|
|
if (this.args.onSetActiveTask) {
|
|
this.args.onSetActiveTask(null);
|
|
}
|
|
}
|
|
|
|
//#endregion Logs Sidebar
|
|
}
|