Filtering for tasks
This commit is contained in:
parent
122eadc0de
commit
5b9d2e615b
|
@ -148,6 +148,15 @@ angular.module('ffffngAdmin').config(function(NgAdminConfigurationProvider, Rest
|
||||||
nga.field('runningSince').map(formatMoment).cssClasses(taskClasses),
|
nga.field('runningSince').map(formatMoment).cssClasses(taskClasses),
|
||||||
nga.field('lastRunStarted').map(formatMoment).cssClasses(taskClasses)
|
nga.field('lastRunStarted').map(formatMoment).cssClasses(taskClasses)
|
||||||
])
|
])
|
||||||
|
.filters([
|
||||||
|
nga.field('q')
|
||||||
|
.label('')
|
||||||
|
.pinned(true)
|
||||||
|
.template(
|
||||||
|
'<div class="input-group">' +
|
||||||
|
'<input type="text" ng-model="value" placeholder="Search" class="form-control"></input>' +
|
||||||
|
'<span class="input-group-addon"><i class="fa fa-search"></i></span></div>'),
|
||||||
|
])
|
||||||
.listActions(
|
.listActions(
|
||||||
'<fa-task-action-button action="run" task="entry" button="primary" label="run" size="sm"></fa-task-action-button> ' +
|
'<fa-task-action-button action="run" task="entry" button="primary" label="run" size="sm"></fa-task-action-button> ' +
|
||||||
'<fa-task-action-button ng-if="!entry.values.enabled" button="success" action="enable" icon="power-off" task="entry" label="enable" size="sm"></fa-task-action-button> ' +
|
'<fa-task-action-button ng-if="!entry.values.enabled" button="success" action="enable" icon="power-off" task="entry" label="enable" size="sm"></fa-task-action-button> ' +
|
||||||
|
|
|
@ -84,9 +84,14 @@ angular.module('ffffng').factory('TaskResource', function (
|
||||||
['id', 'name', 'schedule', 'state', 'runningSince', 'lastRunStarted'],
|
['id', 'name', 'schedule', 'state', 'runningSince', 'lastRunStarted'],
|
||||||
restParams
|
restParams
|
||||||
);
|
);
|
||||||
var total = tasks.length;
|
var filteredTasks = Resources.filter(
|
||||||
|
tasks,
|
||||||
|
['id', 'name', 'schedule', 'state'],
|
||||||
|
restParams
|
||||||
|
);
|
||||||
|
var total = filteredTasks.length;
|
||||||
|
|
||||||
var pageTasks = Resources.getPageEntities(tasks, restParams);
|
var pageTasks = Resources.getPageEntities(filteredTasks, restParams);
|
||||||
|
|
||||||
res.set('X-Total-Count', total);
|
res.set('X-Total-Count', total);
|
||||||
return Resources.success(res, _.map(pageTasks, toExternalTask));
|
return Resources.success(res, _.map(pageTasks, toExternalTask));
|
||||||
|
|
|
@ -47,6 +47,10 @@ angular.module('ffffng').factory('Resources', function (_, Constraints, Validato
|
||||||
return _.filter(entities, function (entity) {
|
return _.filter(entities, function (entity) {
|
||||||
return _.some(allowedFilterFields, function (field) {
|
return _.some(allowedFilterFields, function (field) {
|
||||||
var value = entity[field];
|
var value = entity[field];
|
||||||
|
if (_.isNumber(value)) {
|
||||||
|
value = value.toString();
|
||||||
|
}
|
||||||
|
|
||||||
if (!_.isString(value) || _.isEmpty(value)) {
|
if (!_.isString(value) || _.isEmpty(value)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue