mirror of https://github.com/rancher/ui.git
fix issues in audit logs
This commit is contained in:
parent
ca39a5ed0b
commit
d792e127c4
|
|
@ -1,11 +1,10 @@
|
||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
import Sortable from 'ui/mixins/sortable';
|
import Sortable from 'ui/mixins/sortable';
|
||||||
import { debouncedObserver } from 'ui/utils/debounce';
|
|
||||||
import C from 'ui/utils/constants';
|
import C from 'ui/utils/constants';
|
||||||
|
|
||||||
export default Ember.Controller.extend(Sortable, {
|
export default Ember.Controller.extend(Sortable, {
|
||||||
application: Ember.inject.controller(),
|
application: Ember.inject.controller(),
|
||||||
queryParams: ['sortBy', 'sortOrder', 'limit', 'forceReload', 'depaginate'],
|
queryParams: ['sortBy', 'sortOrder', 'eventType', 'resourceType', 'resourceId', 'clientIp', 'authType'],
|
||||||
|
|
||||||
sortableContent: Ember.computed.alias('model.auditLog'),
|
sortableContent: Ember.computed.alias('model.auditLog'),
|
||||||
resourceTypeAndId: null,
|
resourceTypeAndId: null,
|
||||||
|
|
@ -21,6 +20,16 @@ export default Ember.Controller.extend(Sortable, {
|
||||||
changeSort: function(name) {
|
changeSort: function(name) {
|
||||||
this._super(name);
|
this._super(name);
|
||||||
},
|
},
|
||||||
|
search: function() {
|
||||||
|
this.setProperties({
|
||||||
|
eventType: this.get('filters.eventType'),
|
||||||
|
resourceType: this.get('filters.resourceType'),
|
||||||
|
resourceId: this.get('filters.resourceId'),
|
||||||
|
clientIp: this.get('filters.clientIp'),
|
||||||
|
authType: this.get('filters.authType'),
|
||||||
|
});
|
||||||
|
this.send('filterLogs');
|
||||||
|
},
|
||||||
showResponseObjects: function(request, response) {
|
showResponseObjects: function(request, response) {
|
||||||
this.get('application').setProperties({
|
this.get('application').setProperties({
|
||||||
showAuditLogResponses: true,
|
showAuditLogResponses: true,
|
||||||
|
|
@ -44,6 +53,13 @@ export default Ember.Controller.extend(Sortable, {
|
||||||
resourceType: null,
|
resourceType: null,
|
||||||
runtime: null,
|
runtime: null,
|
||||||
});
|
});
|
||||||
|
this.setProperties({
|
||||||
|
eventType: null,
|
||||||
|
resourceType: null,
|
||||||
|
resourceId: null,
|
||||||
|
clientIp: null,
|
||||||
|
authType: null,
|
||||||
|
});
|
||||||
this.setProperties({
|
this.setProperties({
|
||||||
sortBy: 'created',
|
sortBy: 'created',
|
||||||
sortOrder: 'desc',
|
sortOrder: 'desc',
|
||||||
|
|
@ -57,8 +73,11 @@ export default Ember.Controller.extend(Sortable, {
|
||||||
sortOrder: 'desc',
|
sortOrder: 'desc',
|
||||||
descending: true,
|
descending: true,
|
||||||
limit: 100,
|
limit: 100,
|
||||||
forceReload: true,
|
eventType: null,
|
||||||
depaginate: false,
|
resourceType: null,
|
||||||
|
resourceId: null,
|
||||||
|
clientIp: null,
|
||||||
|
authType: null,
|
||||||
authTypes: null,
|
authTypes: null,
|
||||||
authTypeReadable: null,
|
authTypeReadable: null,
|
||||||
filters: {
|
filters: {
|
||||||
|
|
@ -69,6 +88,7 @@ export default Ember.Controller.extend(Sortable, {
|
||||||
created: null,
|
created: null,
|
||||||
description: null,
|
description: null,
|
||||||
eventType: null,
|
eventType: null,
|
||||||
|
clientIp: null,
|
||||||
id: null,
|
id: null,
|
||||||
kind: null,
|
kind: null,
|
||||||
resourceId: null,
|
resourceId: null,
|
||||||
|
|
@ -89,10 +109,6 @@ export default Ember.Controller.extend(Sortable, {
|
||||||
|
|
||||||
}.on('init'),
|
}.on('init'),
|
||||||
|
|
||||||
filtersHaveChanged: debouncedObserver('filters.accountId','filters.authType','filters.authenticatedAsAccountId','filters.authenticatedAsIdentityId','filters.created','filters.description','filters.eventType','filters.id','filters.kind','filters.resourceId','filters.resourceType','filters.runtime', function() {
|
|
||||||
this.send('filterLogs');
|
|
||||||
}, 500),
|
|
||||||
|
|
||||||
setSortOrderObserver: function() {
|
setSortOrderObserver: function() {
|
||||||
var out = 'asc';
|
var out = 'asc';
|
||||||
|
|
||||||
|
|
@ -105,6 +121,14 @@ export default Ember.Controller.extend(Sortable, {
|
||||||
|
|
||||||
}.observes('descending'),
|
}.observes('descending'),
|
||||||
|
|
||||||
|
resourceIdReady: function() {
|
||||||
|
if (this.get('filters.resourceType')) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}.property('filters.resourceType'),
|
||||||
|
|
||||||
showPagination: function() {
|
showPagination: function() {
|
||||||
var pagination = this.get('model.auditLog.pagination');
|
var pagination = this.get('model.auditLog.pagination');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,21 @@ export default Ember.Route.extend({
|
||||||
sortOrder: {
|
sortOrder: {
|
||||||
refreshModel: true
|
refreshModel: true
|
||||||
},
|
},
|
||||||
limit: {
|
eventType: {
|
||||||
refreshModel: true
|
refreshModel: true
|
||||||
},
|
},
|
||||||
|
resourceType: {
|
||||||
|
refreshModel: true
|
||||||
|
},
|
||||||
|
resourceId: {
|
||||||
|
refreshModel: true
|
||||||
|
},
|
||||||
|
clientIp: {
|
||||||
|
refreshModel: true
|
||||||
|
},
|
||||||
|
authType: {
|
||||||
|
refreshModel: true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
runLaterId: null,
|
runLaterId: null,
|
||||||
|
|
@ -21,8 +33,6 @@ export default Ember.Route.extend({
|
||||||
filterLogs: function() {
|
filterLogs: function() {
|
||||||
Ember.run.cancel(this.get('runLaterId'));
|
Ember.run.cancel(this.get('runLaterId'));
|
||||||
this.set('runLaterId', null);
|
this.set('runLaterId', null);
|
||||||
|
|
||||||
this.refresh();
|
|
||||||
},
|
},
|
||||||
logsSorted: function() {
|
logsSorted: function() {
|
||||||
Ember.run.cancel(this.get('runLaterId'));
|
Ember.run.cancel(this.get('runLaterId'));
|
||||||
|
|
@ -54,18 +64,15 @@ export default Ember.Route.extend({
|
||||||
|
|
||||||
this.set('userHasPaged', false);
|
this.set('userHasPaged', false);
|
||||||
this.set('runLaterId', null);
|
this.set('runLaterId', null);
|
||||||
this.set('runLaterId', null);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
model: function(params) {
|
model: function(params) {
|
||||||
var filters;
|
|
||||||
|
|
||||||
if (this.controller) {
|
if (this.get('runLaterId')) {
|
||||||
|
Ember.run.cancel(this.get('runLaterId'));
|
||||||
filters = this.controller.get('filters');
|
this.set('runLaterId', null);
|
||||||
}
|
}
|
||||||
|
return this.store.find('auditLog', null, this.parseFilters(params)).then((response) => {
|
||||||
return this.store.find('auditLog', null, this.parseFilters(params, filters)).then((response) => {
|
|
||||||
|
|
||||||
var resourceTypes = this.get('store').all('schema').filterBy('links.collection').map((x) => { return x.get('_id'); });
|
var resourceTypes = this.get('store').all('schema').filterBy('links.collection').map((x) => { return x.get('_id'); });
|
||||||
|
|
||||||
|
|
@ -84,15 +91,15 @@ export default Ember.Route.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
scheduleLogUpdate: function() {
|
scheduleLogUpdate: function() {
|
||||||
const intervalCount = 2000;
|
const intervalCount = 30000;
|
||||||
|
|
||||||
this.set('runLaterId',
|
this.set('runLaterId',
|
||||||
Ember.run.later(() => {
|
Ember.run.later(() => {
|
||||||
var params = this.paramsFor('admin-tab.audit-logs');
|
var params = this.paramsFor('admin-tab.audit-logs');
|
||||||
var filters = this.controller.get('filters');
|
//var filters = this.controller.get('filters');
|
||||||
|
|
||||||
|
|
||||||
this.store.find('auditLog', null, this.parseFilters(params, filters)).then((response) => {
|
this.store.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
|
// 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.
|
// run. If thats the case we dont want to replace the page with this unresolved promise.
|
||||||
|
|
@ -106,34 +113,28 @@ export default Ember.Route.extend({
|
||||||
}, intervalCount));
|
}, intervalCount));
|
||||||
},
|
},
|
||||||
|
|
||||||
parseFilters: function(params, filters) {
|
parseFilters: function(params) {
|
||||||
var paramsOut = params;
|
var returnValue = {
|
||||||
paramsOut.include = 'account';
|
filter: {
|
||||||
|
},
|
||||||
if (filters) {
|
limit: 100,
|
||||||
Object.keys(filters).forEach((key) => {
|
depaginate: false,
|
||||||
/* do we have a non-null filter?*/
|
forceReload: true
|
||||||
if (filters[key]) {
|
};
|
||||||
|
if (params) {
|
||||||
/*does the filter exist in the current params - if so add new filters to it*/
|
_.forEach(params, (item, key) => {
|
||||||
if (params.filter) {
|
if (key !== 'sortBy' && key !== 'sortOrder' && key !== 'forceReload') {
|
||||||
paramsOut.filter[key] = filters[key];
|
if (item) {
|
||||||
|
returnValue.filter[key] = item;
|
||||||
} else {
|
} else {
|
||||||
/*it doesnt so create it*/
|
delete returnValue.filter[key];
|
||||||
paramsOut.filter = {};
|
|
||||||
paramsOut.filter[key] = filters[key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/*did we remove the filter by hand?*/
|
|
||||||
if (!filters[key] && (paramsOut.filter && paramsOut.filter[key])) {
|
|
||||||
/*delete it*/
|
|
||||||
delete paramsOut.filter[key];
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
returnValue[key] = item;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return paramsOut;
|
return returnValue;
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
{{input class="form-control input-sm r-mr5" value=filters.eventType placeholder="Event Type"}}
|
{{input class="form-control input-sm r-mr5" value=filters.eventType placeholder="Event Type"}}
|
||||||
<div class="input-group r-mr5">
|
<div class="input-group r-mr5">
|
||||||
<span class="input-group-btn">
|
<span class="input-group-btn">
|
||||||
|
{{input class="form-control input-sm pull-right" value=filters.resourceId placeholder="Resource ID" disabled=resourceIdReady}}
|
||||||
<button type="button" class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">{{if filters.resourceType filters.resourceType 'Resource Type:'}} <i class="icon icon-chevron-down"></i></button>
|
<button type="button" class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">{{if filters.resourceType filters.resourceType 'Resource Type:'}} <i class="icon icon-chevron-down"></i></button>
|
||||||
<ul class="dropdown-menu" role="menu">
|
<ul class="dropdown-menu" role="menu">
|
||||||
<li role="presentation" class="dropdown-header">
|
<li role="presentation" class="dropdown-header">
|
||||||
|
|
@ -21,7 +22,6 @@
|
||||||
</li>
|
</li>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ul>
|
</ul>
|
||||||
{{input class="form-control input-sm" value=filters.resourceId placeholder="Resource ID"}}
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{{input class="form-control input-sm r-mr5" value=filters.clientIp placeholder="Request IP"}}
|
{{input class="form-control input-sm r-mr5" value=filters.clientIp placeholder="Request IP"}}
|
||||||
|
|
@ -38,7 +38,8 @@
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ul>
|
</ul>
|
||||||
</span>
|
</span>
|
||||||
<a class="btn btn-sm btn-primary r-ml5" {{action "clearAll"}} style="margin-right: 8px;"><i class="icon icon-close icon-sm"></i> Clear All</a>
|
<a class="btn btn-sm btn-danger r-ml5" {{action "clearAll"}}> Clear All</a>
|
||||||
|
<a class="btn btn-sm btn-primary r-ml5" {{action "search"}}> Search</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<table class="grid fixed table table-hover r-mb15">
|
<table class="grid fixed table table-hover r-mb15">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue