2019-02-21 13:10:53 +00:00
|
|
|
import Controller from '@ember/controller';
|
2019-03-22 17:24:40 +00:00
|
|
|
import { get, set } from '@ember/object';
|
|
|
|
import { inject as service } from '@ember/service';
|
|
|
|
import WithEventSource, { listen } from 'consul-ui/mixins/with-event-source';
|
2019-02-21 13:10:53 +00:00
|
|
|
|
2019-03-22 17:24:40 +00:00
|
|
|
export default Controller.extend(WithEventSource, {
|
|
|
|
notify: service('flashMessages'),
|
2019-02-21 13:10:53 +00:00
|
|
|
setProperties: function() {
|
|
|
|
this._super(...arguments);
|
|
|
|
// This method is called immediately after `Route::setupController`, and done here rather than there
|
|
|
|
// as this is a variable used purely for view level things, if the view was different we might not
|
|
|
|
// need this variable
|
|
|
|
set(this, 'selectedTab', 'service-checks');
|
|
|
|
},
|
2019-03-22 17:24:40 +00:00
|
|
|
item: listen('item').catch(function(e) {
|
|
|
|
if (e.target.readyState === 1) {
|
|
|
|
// OPEN
|
|
|
|
if (get(e, 'error.errors.firstObject.status') === '404') {
|
|
|
|
get(this, 'notify').add({
|
|
|
|
destroyOnClick: false,
|
|
|
|
sticky: true,
|
|
|
|
type: 'warning',
|
|
|
|
action: 'update',
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}),
|
2019-02-21 13:10:53 +00:00
|
|
|
actions: {
|
|
|
|
change: function(e) {
|
|
|
|
set(this, 'selectedTab', e.target.value);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|