mirror of https://github.com/rancher/ui.git
Clear audit log timer on deactivate
This commit is contained in:
parent
6bea59b1b2
commit
d52fefd9c0
|
|
@ -1,6 +1,6 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
const INTERVALCOUNT = 30000;
|
||||
const INTERVALCOUNT = 15000;
|
||||
|
||||
export default Ember.Route.extend({
|
||||
queryParams: {
|
||||
|
|
@ -27,54 +27,43 @@ export default Ember.Route.extend({
|
|||
}
|
||||
},
|
||||
|
||||
runLaterId : null,
|
||||
timer : null,
|
||||
userHasPaged : null,
|
||||
|
||||
actions: {
|
||||
filterLogs: function() {
|
||||
Ember.run.cancel(this.get('runLaterId'));
|
||||
this.set('runLaterId', null);
|
||||
filterLogs() {
|
||||
this.cancelLogUpdate();
|
||||
},
|
||||
logsSorted: function() {
|
||||
Ember.run.cancel(this.get('runLaterId'));
|
||||
this.set('runLaterId', null);
|
||||
|
||||
logsSorted() {
|
||||
this.cancelLogUpdate();
|
||||
},
|
||||
next: function() {
|
||||
|
||||
Ember.run.cancel(this.get('runLaterId'));
|
||||
|
||||
next() {
|
||||
this.cancelLogUpdate();
|
||||
this.set('userHasPaged', true);
|
||||
this.set('runLaterId', null);
|
||||
|
||||
this.controller.model.auditLog.followPagination('next').then((response) => {
|
||||
|
||||
this.controller.set('model.auditLog', response);
|
||||
});
|
||||
},
|
||||
first: function() {
|
||||
|
||||
first() {
|
||||
this.set('userHasPaged', false);
|
||||
this.refresh();
|
||||
this.scheduleLogUpdate();
|
||||
}
|
||||
},
|
||||
|
||||
deactivate: function() {
|
||||
|
||||
Ember.run.cancel(this.get('runLaterId'));
|
||||
|
||||
deactivate() {
|
||||
this.cancelLogUpdate();
|
||||
this.set('userHasPaged', false);
|
||||
this.set('runLaterId', null);
|
||||
},
|
||||
|
||||
model: function(params) {
|
||||
model(params) {
|
||||
this.cancelLogUpdate();
|
||||
|
||||
if (this.get('runLaterId')) {
|
||||
Ember.run.cancel(this.get('runLaterId'));
|
||||
this.set('runLaterId', null);
|
||||
}
|
||||
return this.get('userStore').find('auditLog', null, this.parseFilters(params)).then((response) => {
|
||||
|
||||
var resourceTypes = this.get('userStore').all('schema').filterBy('links.collection').map((x) => { return x.get('_id'); });
|
||||
|
||||
return Ember.Object.create({
|
||||
|
|
@ -84,34 +73,37 @@ export default Ember.Route.extend({
|
|||
});
|
||||
},
|
||||
|
||||
setupController: function(controller, model) {
|
||||
|
||||
setupController(controller, model) {
|
||||
this._super(controller, model);
|
||||
this.scheduleLogUpdate();
|
||||
|
||||
},
|
||||
|
||||
scheduleLogUpdate: function() {
|
||||
scheduleLogUpdate() {
|
||||
Ember.run.cancel(this.get('timer'));
|
||||
|
||||
this.set('runLaterId',
|
||||
Ember.run.later(() => {
|
||||
var params = this.paramsFor('admin-tab.audit-logs');
|
||||
this.set('timer', Ember.run.later(() => {
|
||||
var params = this.paramsFor('admin-tab.audit-logs');
|
||||
|
||||
this.get('userStore').find('auditLog', null, this.parseFilters(params)).then((response) => {
|
||||
this.get('userStore').find('auditLog', null, this.parseFilters(params)).then((response) => {
|
||||
// We can get into a state where the user paged but we have an unresolved promise from the previous
|
||||
// run. If thats the case we dont want to replace the page with this unresolved promise.
|
||||
if (!this.get('userHasPaged')) {
|
||||
|
||||
// We can get into a state where the user paged but we have an unresolved promise from the previous
|
||||
// run. If thats the case we dont want to replace the page with this unresolved promise.
|
||||
if (!this.get('userHasPaged')) {
|
||||
|
||||
this.controller.set('model.auditLog', response);
|
||||
this.controller.set('model.auditLog', response);
|
||||
if ( this.get('timer') ) {
|
||||
this.scheduleLogUpdate();
|
||||
}
|
||||
}, (/* error */) => {});
|
||||
|
||||
}, INTERVALCOUNT));
|
||||
}
|
||||
}, (/* error */) => {});
|
||||
}, INTERVALCOUNT));
|
||||
},
|
||||
|
||||
parseFilters: function(params) {
|
||||
cancelLogUpdate() {
|
||||
Ember.run.cancel(this.get('timer'));
|
||||
this.set('timer', null);
|
||||
},
|
||||
|
||||
parseFilters(params) {
|
||||
var returnValue = {
|
||||
filter : {},
|
||||
limit : 100,
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ export default Ember.Route.extend({
|
|||
|
||||
deactivate() {
|
||||
Ember.run.cancel(this.get('timer'));
|
||||
this.set('timer', null); // This prevents scheduleTimer from rescheduling if deactivate happened at just the wrong time.
|
||||
},
|
||||
|
||||
timer: null,
|
||||
|
|
@ -21,9 +22,10 @@ export default Ember.Route.extend({
|
|||
this.set('timer', Ember.run.later(() => {
|
||||
this.get('userStore').find('clustermembership', null, {forceReload: true}).then((response) => {
|
||||
this.controller.set('model', response);
|
||||
this.scheduleTimer();
|
||||
if ( this.get('timer') ) {
|
||||
this.scheduleTimer();
|
||||
}
|
||||
});
|
||||
}, INTERVAL));
|
||||
},
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ export default Ember.Route.extend({
|
|||
}
|
||||
},
|
||||
|
||||
intervalId: null,
|
||||
timer: null,
|
||||
|
||||
redirect: function() {
|
||||
this.transitionTo('admin-tab.processes.index', {
|
||||
|
|
@ -50,19 +50,22 @@ export default Ember.Route.extend({
|
|||
},
|
||||
|
||||
scheduleTimer: function() {
|
||||
Ember.run.cancel(this.get('intervalId'));
|
||||
this.set('intervalId', Ember.run.later(() => {
|
||||
Ember.run.cancel(this.get('timer'));
|
||||
this.set('timer', Ember.run.later(() => {
|
||||
var params = this.paramsFor('admin-tab.processes');
|
||||
|
||||
this.get('userStore').find('processinstance', null, this.parseParams(params)).then((response) => {
|
||||
this.controller.get('model.processInstance').replaceWith(response);
|
||||
this.scheduleTimer();
|
||||
if ( this.get('timer') ) {
|
||||
this.scheduleTimer();
|
||||
}
|
||||
}, ( /*error*/ ) => {});
|
||||
}, INTERVALCOUNT));
|
||||
},
|
||||
|
||||
deactivate: function() {
|
||||
Ember.run.cancel(this.get('intervalId'));
|
||||
Ember.run.cancel(this.get('timer'));
|
||||
this.set('timer', null); // This prevents scheduleTimer from rescheduling if deactivate happened at just the wrong time.
|
||||
},
|
||||
|
||||
parseParams: function(params) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import Ember from 'ember';
|
||||
import FilteredSorted from 'ui/utils/filtered-sorted-array-proxy';
|
||||
import C from 'ui/utils/constants';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
model: function() {
|
||||
|
|
@ -7,8 +8,9 @@ export default Ember.Route.extend({
|
|||
return this.get('store').findAll('kubernetesstack').then((stacks) => {
|
||||
return FilteredSorted.create({
|
||||
sourceContent: stacks,
|
||||
dependentKeys: ['sourceContent.@each.namespace','sourceContent.@each.state'],
|
||||
filterFn: function(stack) {
|
||||
return stack.get('namespace') === ns.get('id');
|
||||
return stack.get('namespace') === ns.get('id') && !C.REMOVEDISH_STATES.includes(stack.get('state'));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ function labelsMatching(ary,key,val) {
|
|||
|
||||
export default Ember.Mixin.create({
|
||||
groupedInstances: function() {
|
||||
console.log('groupedInstances',this.get('model.id'));
|
||||
var groups = [];
|
||||
|
||||
function getOrCreateGroup(id, name, isK8s)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "ui",
|
||||
"version": "1.2.39",
|
||||
"version": "1.3.0",
|
||||
"private": true,
|
||||
"directories": {
|
||||
"doc": "doc",
|
||||
|
|
|
|||
Loading…
Reference in New Issue