mirror of https://github.com/rancher/ui.git
58 lines
1.6 KiB
JavaScript
58 lines
1.6 KiB
JavaScript
import { get, set } from '@ember/object';
|
|
import Component from '@ember/component';
|
|
import { inject as service } from '@ember/service';
|
|
import { reads } from '@ember/object/computed';
|
|
|
|
export default Component.extend({
|
|
globalStore: service(),
|
|
scope: service(),
|
|
clusterId: reads('scope.currentCluster.id'),
|
|
|
|
init() {
|
|
this._super(...arguments);
|
|
const resourceKinds = get(this, 'globalStore')
|
|
.getById('schema', 'targetevent')
|
|
.optionsFor('resourceKind').sort().map(value => ({
|
|
label: value,
|
|
value,
|
|
}));
|
|
const systemServices = get(this, 'globalStore')
|
|
.getById('schema', 'targetsystemservice')
|
|
.optionsFor('condition').sort().map(value => ({
|
|
label: value,
|
|
value,
|
|
}));
|
|
this.set('resourceKinds', resourceKinds);
|
|
this.set('systemServices', systemServices);
|
|
},
|
|
|
|
nodes: function() {
|
|
const clusterId = get(this, 'clusterId');
|
|
return get(this, 'globalStore').all('node').filterBy('clusterId', clusterId);
|
|
}.property('clusterId'),
|
|
|
|
isEventTarget: function() {
|
|
const t = get(this, 'model._targetType');
|
|
return t === 'warningEvent' || t === 'normalEvent';
|
|
}.property('model._targetType'),
|
|
|
|
setEventType(t) {
|
|
if (t === 'warningEvent') {
|
|
set(this, 'model.targetEvent.eventType', 'Warning');
|
|
}
|
|
if (t === 'normalEvent') {
|
|
set(this, 'model.targetEvent.eventType', 'Normal');
|
|
}
|
|
},
|
|
targetTypeChanged: function() {
|
|
const t = get(this, 'model._targetType');
|
|
this.setEventType(t);
|
|
}.observes('model._targetType'),
|
|
|
|
actions: {
|
|
// todo, don't know that this is needed
|
|
noop() {
|
|
},
|
|
}
|
|
});
|