mirror of
https://github.com/ansible/awx.git
synced 2026-02-14 01:34:45 -03:30
Filters organization
This commit is contained in:
@@ -39,7 +39,6 @@ if ($basePath) {
|
|||||||
// Modules
|
// Modules
|
||||||
import './forms';
|
import './forms';
|
||||||
import './lists';
|
import './lists';
|
||||||
import './filters';
|
|
||||||
import portalMode from './portal-mode/main';
|
import portalMode from './portal-mode/main';
|
||||||
import systemTracking from './system-tracking/main';
|
import systemTracking from './system-tracking/main';
|
||||||
import inventories from './inventories/main';
|
import inventories from './inventories/main';
|
||||||
@@ -135,7 +134,6 @@ var tower = angular.module('Tower', [
|
|||||||
'InventoryFormDefinition',
|
'InventoryFormDefinition',
|
||||||
'InventoryGroupsDefinition',
|
'InventoryGroupsDefinition',
|
||||||
'InventoryHostsDefinition',
|
'InventoryHostsDefinition',
|
||||||
'AWFilters',
|
|
||||||
'HostFormDefinition',
|
'HostFormDefinition',
|
||||||
'HostListDefinition',
|
'HostListDefinition',
|
||||||
'GroupFormDefinition',
|
'GroupFormDefinition',
|
||||||
@@ -166,7 +164,6 @@ var tower = angular.module('Tower', [
|
|||||||
'lrInfiniteScroll',
|
'lrInfiniteScroll',
|
||||||
'PortalJobsListDefinition',
|
'PortalJobsListDefinition',
|
||||||
'features',
|
'features',
|
||||||
'longDateFilter',
|
|
||||||
'pendolytics',
|
'pendolytics',
|
||||||
scheduler.name,
|
scheduler.name,
|
||||||
'WorkflowFormDefinition',
|
'WorkflowFormDefinition',
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
/*************************************************
|
|
||||||
* Copyright (c) 2015 Ansible, Inc.
|
|
||||||
*
|
|
||||||
* All Rights Reserved
|
|
||||||
*************************************************/
|
|
||||||
|
|
||||||
import sanitizeFilter from './shared/xss-sanitizer.filter';
|
|
||||||
import capitalizeFilter from './shared/capitalize.filter';
|
|
||||||
import longDateFilter from './shared/long-date.filter';
|
|
||||||
export {
|
|
||||||
sanitizeFilter,
|
|
||||||
capitalizeFilter,
|
|
||||||
longDateFilter
|
|
||||||
};
|
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function InventoriesList($scope, $rootScope, $location, $log,
|
function InventoriesList($scope, $rootScope, $location, $log,
|
||||||
$stateParams, $compile, $filter, sanitizeFilter, Rest, Alert, InventoryList, Prompt,
|
$stateParams, $compile, $filter, Rest, Alert, InventoryList, Prompt,
|
||||||
ClearScope, ProcessErrors, GetBasePath, Wait, Find, Empty, $state, rbacUiControlService, Dataset) {
|
ClearScope, ProcessErrors, GetBasePath, Wait, Find, Empty, $state, rbacUiControlService, Dataset) {
|
||||||
|
|
||||||
let list = InventoryList,
|
let list = InventoryList,
|
||||||
@@ -304,6 +304,6 @@ function InventoriesList($scope, $rootScope, $location, $log,
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default ['$scope', '$rootScope', '$location', '$log',
|
export default ['$scope', '$rootScope', '$location', '$log',
|
||||||
'$stateParams', '$compile', '$filter', 'sanitizeFilter', 'Rest', 'Alert', 'InventoryList',
|
'$stateParams', '$compile', '$filter', 'Rest', 'Alert', 'InventoryList',
|
||||||
'Prompt', 'ClearScope', 'ProcessErrors', 'GetBasePath', 'Wait', 'Find', 'Empty', '$state', 'rbacUiControlService', 'Dataset', InventoriesList
|
'Prompt', 'ClearScope', 'ProcessErrors', 'GetBasePath', 'Wait', 'Find', 'Empty', '$state', 'rbacUiControlService', 'Dataset', InventoriesList
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
|
|
||||||
export default
|
export default
|
||||||
angular.module('AllJobsDefinition', ['sanitizeFilter', 'capitalizeFilter'])
|
angular.module('AllJobsDefinition', [])
|
||||||
.factory('AllJobsList', ['i18n', function(i18n) {
|
.factory('AllJobsList', ['i18n', function(i18n) {
|
||||||
return {
|
return {
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
|
|
||||||
export default
|
export default
|
||||||
angular.module('CompletedJobsDefinition', ['sanitizeFilter'])
|
angular.module('CompletedJobsDefinition', [])
|
||||||
.factory('CompletedJobsList', ['i18n', function(i18n) {
|
.factory('CompletedJobsList', ['i18n', function(i18n) {
|
||||||
return {
|
return {
|
||||||
// These tooltip fields are consumed to build disabled related tabs tooltips in the form > add view
|
// These tooltip fields are consumed to build disabled related tabs tooltips in the form > add view
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
|
|
||||||
export default
|
export default
|
||||||
angular.module('ScheduledJobsDefinition', ['sanitizeFilter'])
|
angular.module('ScheduledJobsDefinition', [])
|
||||||
.factory('ScheduledJobsList', ['i18n', function(i18n) {
|
.factory('ScheduledJobsList', ['i18n', function(i18n) {
|
||||||
return {
|
return {
|
||||||
|
|
||||||
|
|||||||
@@ -5,11 +5,11 @@
|
|||||||
*************************************************/
|
*************************************************/
|
||||||
|
|
||||||
export default ['$scope', '$rootScope', '$location', '$log',
|
export default ['$scope', '$rootScope', '$location', '$log',
|
||||||
'$stateParams', '$compile', '$filter', 'sanitizeFilter', 'Rest', 'Alert', 'InventoryList',
|
'$stateParams', '$compile', '$filter', 'Rest', 'Alert', 'InventoryList',
|
||||||
'generateList', 'Prompt', 'ReturnToCaller', 'OrgInventoryDataset', 'OrgInventoryList',
|
'generateList', 'Prompt', 'ReturnToCaller', 'OrgInventoryDataset', 'OrgInventoryList',
|
||||||
'ClearScope', 'ProcessErrors', 'GetBasePath', 'Wait', 'Find', 'Empty', '$state',
|
'ClearScope', 'ProcessErrors', 'GetBasePath', 'Wait', 'Find', 'Empty', '$state',
|
||||||
function($scope, $rootScope, $location, $log,
|
function($scope, $rootScope, $location, $log,
|
||||||
$stateParams, $compile, $filter, sanitizeFilter, Rest, Alert, InventoryList,
|
$stateParams, $compile, $filter, Rest, Alert, InventoryList,
|
||||||
generateList, Prompt, ReturnToCaller, Dataset, OrgInventoryList,
|
generateList, Prompt, ReturnToCaller, Dataset, OrgInventoryList,
|
||||||
ClearScope, ProcessErrors, GetBasePath, Wait,
|
ClearScope, ProcessErrors, GetBasePath, Wait,
|
||||||
Find, Empty, $state) {
|
Find, Empty, $state) {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
|
|
||||||
export default
|
export default
|
||||||
angular.module('Utilities', ['RestServices', 'Utilities', 'sanitizeFilter'])
|
angular.module('Utilities', ['RestServices', 'Utilities'])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ngdoc method
|
* @ngdoc method
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
/*************************************************
|
|
||||||
* Copyright (c) 2015 Ansible, Inc.
|
|
||||||
*
|
|
||||||
* All Rights Reserved
|
|
||||||
*************************************************/
|
|
||||||
|
|
||||||
export default
|
|
||||||
angular.module('capitalizeFilter', []).filter('capitalize', function() {
|
|
||||||
return function(input) {
|
|
||||||
input = input.charAt(0).toUpperCase() + input.substr(1).toLowerCase();
|
|
||||||
return input;
|
|
||||||
};
|
|
||||||
});
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
/*************************************************
|
|
||||||
* Copyright (c) 2015 Ansible, Inc.
|
|
||||||
*
|
|
||||||
* All Rights Reserved
|
|
||||||
*************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ngdoc function
|
|
||||||
* @name shared.function:filters
|
|
||||||
* @description
|
|
||||||
* Custom filters
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default
|
|
||||||
angular.module('AWFilters', [])
|
|
||||||
|
|
||||||
// Object is empty / undefined / null
|
|
||||||
.filter('isEmpty', function () {
|
|
||||||
var key;
|
|
||||||
return function (obj) {
|
|
||||||
for (key in obj) {
|
|
||||||
if (obj.hasOwnProperty(key)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
})
|
|
||||||
|
|
||||||
//
|
|
||||||
// capitalize -capitalize the first letter of each word
|
|
||||||
//
|
|
||||||
.filter('capitalize', [ function () {
|
|
||||||
return function (input) {
|
|
||||||
var values, result, i;
|
|
||||||
if (input) {
|
|
||||||
values = input.replace(/\_/g, ' ').split(" ");
|
|
||||||
result = "";
|
|
||||||
for (i = 0; i < values.length; i++) {
|
|
||||||
result += values[i].charAt(0).toUpperCase() + values[i].substr(1) + ' ';
|
|
||||||
}
|
|
||||||
return result.trim();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}])
|
|
||||||
|
|
||||||
//
|
|
||||||
// Filter an object of objects by id using an array of id values
|
|
||||||
// Created specifically for Filter Events on job detail page.
|
|
||||||
//
|
|
||||||
.filter('FilterById', [ function() {
|
|
||||||
return function(input, list) {
|
|
||||||
var results = [];
|
|
||||||
if (input && list.length > 0) {
|
|
||||||
list.forEach(function(itm) {
|
|
||||||
input.forEach(function(row) {
|
|
||||||
if (row.id === itm) {
|
|
||||||
results.push(row);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
return input;
|
|
||||||
};
|
|
||||||
}])
|
|
||||||
|
|
||||||
.filter('FilterByField', [ function() {
|
|
||||||
return function(input, list) {
|
|
||||||
var fld, key, search = {}, results = {};
|
|
||||||
for (fld in list) {
|
|
||||||
if (list[fld]) {
|
|
||||||
search[fld] = list[fld];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Object.keys(search).length > 0) {
|
|
||||||
for (fld in search) {
|
|
||||||
for (key in input) {
|
|
||||||
if (input[key][fld] === search[fld]) {
|
|
||||||
results[key] = input[key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
return input;
|
|
||||||
};
|
|
||||||
}])
|
|
||||||
|
|
||||||
.filter('FilterFailedEvents', [ function() {
|
|
||||||
return function(input, liveEventProcessing, searchAllStatus) {
|
|
||||||
var results = [];
|
|
||||||
if (liveEventProcessing) {
|
|
||||||
// while live events are happening, we don't want angular to filter out anything
|
|
||||||
return input;
|
|
||||||
}
|
|
||||||
else if (searchAllStatus === 'failed') {
|
|
||||||
// filter by failed
|
|
||||||
input.forEach(function(row) {
|
|
||||||
if (row.status === 'failed') {
|
|
||||||
results.push(row);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
return input;
|
|
||||||
};
|
|
||||||
}]);
|
|
||||||
20
awx/ui/client/src/shared/filters/capitalize.filter.js
Normal file
20
awx/ui/client/src/shared/filters/capitalize.filter.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
export default [function() {
|
||||||
|
return function(input) {
|
||||||
|
input = input.charAt(0).toUpperCase() + input.substr(1).toLowerCase();
|
||||||
|
return input;
|
||||||
|
};
|
||||||
|
}];
|
||||||
|
|
||||||
|
// export default
|
||||||
|
// angular.module('capitalizeFilter', []).filter('capitalize', function() {
|
||||||
|
// return function(input) {
|
||||||
|
// input = input.charAt(0).toUpperCase() + input.substr(1).toLowerCase();
|
||||||
|
// return input;
|
||||||
|
// };
|
||||||
|
// });
|
||||||
17
awx/ui/client/src/shared/filters/is-empty.filter.js
Normal file
17
awx/ui/client/src/shared/filters/is-empty.filter.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2017 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
export default function() {
|
||||||
|
return function (obj) {
|
||||||
|
var key;
|
||||||
|
for (key in obj) {
|
||||||
|
if (obj.hasOwnProperty(key)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
}
|
||||||
37
awx/ui/client/src/shared/filters/long-date.filter.js
Normal file
37
awx/ui/client/src/shared/filters/long-date.filter.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
export default ['moment', function(moment) {
|
||||||
|
return function(input) {
|
||||||
|
var date;
|
||||||
|
if(input === null){
|
||||||
|
return "";
|
||||||
|
}else {
|
||||||
|
date = moment(input);
|
||||||
|
return date.format('l LTS');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
// function longDateFilter(moment, input) {
|
||||||
|
// var date;
|
||||||
|
// if(input === null){
|
||||||
|
// return "";
|
||||||
|
// }else {
|
||||||
|
// date = moment(input);
|
||||||
|
// return date.format('l LTS');
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// export default
|
||||||
|
// angular.module('longDateFilter', [])
|
||||||
|
// .filter('longDate',
|
||||||
|
// [ 'moment',
|
||||||
|
// function(moment) {
|
||||||
|
// return _.partial(longDateFilter, moment);
|
||||||
|
// }
|
||||||
|
// ]);
|
||||||
17
awx/ui/client/src/shared/filters/main.js
Normal file
17
awx/ui/client/src/shared/filters/main.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import prepend from './prepend.filter';
|
||||||
|
import append from './append.filter';
|
||||||
|
import isEmpty from './is-empty.filter';
|
||||||
|
import capitalize from './capitalize.filter';
|
||||||
|
import longDate from './long-date.filter';
|
||||||
|
import sanitize from './xss-sanitizer.filter';
|
||||||
|
import formatEpoch from './format-epoch.filter';
|
||||||
|
|
||||||
|
export default
|
||||||
|
angular.module('stringFilters', [])
|
||||||
|
.filter('prepend', prepend)
|
||||||
|
.filter('append', append)
|
||||||
|
.filter('isEmpty', isEmpty)
|
||||||
|
.filter('capitalize', capitalize)
|
||||||
|
.filter('longDate', longDate)
|
||||||
|
.filter('sanitize', sanitize)
|
||||||
|
.filter('formatEpoch', formatEpoch);
|
||||||
20
awx/ui/client/src/shared/filters/xss-sanitizer.filter.js
Normal file
20
awx/ui/client/src/shared/filters/xss-sanitizer.filter.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
export default [function() {
|
||||||
|
return function(input) {
|
||||||
|
input = $("<span>").text(input)[0].innerHTML;
|
||||||
|
return input;
|
||||||
|
};
|
||||||
|
}];
|
||||||
|
|
||||||
|
// export default
|
||||||
|
// angular.module('sanitizeFilter', []).filter('sanitize', function() {
|
||||||
|
// return function(input) {
|
||||||
|
// input = $("<span>").text(input)[0].innerHTML;
|
||||||
|
// return input;
|
||||||
|
// };
|
||||||
|
// });
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
import formatEpoch from './format-epoch.filter';
|
|
||||||
import moment from '../moment/main';
|
|
||||||
|
|
||||||
export default
|
|
||||||
angular.module('formatEpoch',
|
|
||||||
[ moment.name
|
|
||||||
])
|
|
||||||
.filter('formatEpoch', formatEpoch);
|
|
||||||
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
/*************************************************
|
|
||||||
* Copyright (c) 2015 Ansible, Inc.
|
|
||||||
*
|
|
||||||
* All Rights Reserved
|
|
||||||
*************************************************/
|
|
||||||
|
|
||||||
function longDateFilter(moment, input) {
|
|
||||||
var date;
|
|
||||||
if(input === null){
|
|
||||||
return "";
|
|
||||||
}else {
|
|
||||||
date = moment(input);
|
|
||||||
return date.format('l LTS');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default
|
|
||||||
angular.module('longDateFilter', [])
|
|
||||||
.filter('longDate',
|
|
||||||
[ 'moment',
|
|
||||||
function(moment) {
|
|
||||||
return _.partial(longDateFilter, moment);
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ import smartSearch from './smart-search/main';
|
|||||||
import paginate from './paginate/main';
|
import paginate from './paginate/main';
|
||||||
import columnSort from './column-sort/main';
|
import columnSort from './column-sort/main';
|
||||||
import lodashAsPromised from './lodash-as-promised';
|
import lodashAsPromised from './lodash-as-promised';
|
||||||
import stringFilters from './string-filters/main';
|
import filters from './filters/main';
|
||||||
import truncatedText from './truncated-text.directive';
|
import truncatedText from './truncated-text.directive';
|
||||||
import stateExtender from './stateExtender.provider';
|
import stateExtender from './stateExtender.provider';
|
||||||
import rbacUiControl from './rbacUiControl';
|
import rbacUiControl from './rbacUiControl';
|
||||||
@@ -28,7 +28,6 @@ import moment from './moment/main';
|
|||||||
import config from './config/main';
|
import config from './config/main';
|
||||||
import PromptDialog from './prompt-dialog';
|
import PromptDialog from './prompt-dialog';
|
||||||
import directives from './directives';
|
import directives from './directives';
|
||||||
import filters from './filters';
|
|
||||||
import features from './features/main';
|
import features from './features/main';
|
||||||
import 'angular-duration-format';
|
import 'angular-duration-format';
|
||||||
|
|
||||||
@@ -39,7 +38,7 @@ angular.module('shared', [listGenerator.name,
|
|||||||
smartSearch.name,
|
smartSearch.name,
|
||||||
paginate.name,
|
paginate.name,
|
||||||
columnSort.name,
|
columnSort.name,
|
||||||
stringFilters.name,
|
filters.name,
|
||||||
'ui.router',
|
'ui.router',
|
||||||
rbacUiControl.name,
|
rbacUiControl.name,
|
||||||
socket.name,
|
socket.name,
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export default
|
export default
|
||||||
angular.module('PromptDialog', ['Utilities', 'sanitizeFilter'])
|
angular.module('PromptDialog', ['Utilities'])
|
||||||
.factory('Prompt', [
|
.factory('Prompt', [
|
||||||
function () {
|
function () {
|
||||||
return function (params) {
|
return function (params) {
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
import prepend from './prepend.filter';
|
|
||||||
import append from './append.filter';
|
|
||||||
|
|
||||||
export default
|
|
||||||
angular.module('stringFilters', [])
|
|
||||||
.filter('prepend', prepend)
|
|
||||||
.filter('append', append);
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
/*************************************************
|
|
||||||
* Copyright (c) 2015 Ansible, Inc.
|
|
||||||
*
|
|
||||||
* All Rights Reserved
|
|
||||||
*************************************************/
|
|
||||||
|
|
||||||
export default
|
|
||||||
angular.module('sanitizeFilter', []).filter('sanitize', function() {
|
|
||||||
return function(input) {
|
|
||||||
input = $("<span>").text(input)[0].innerHTML;
|
|
||||||
return input;
|
|
||||||
};
|
|
||||||
});
|
|
||||||
@@ -1,7 +1,4 @@
|
|||||||
import stringFilters from '../../shared/string-filters/main';
|
var $injector = angular.injector(['ng']);
|
||||||
import formatEpoch from '../../shared/format-epoch/main';
|
|
||||||
|
|
||||||
var $injector = angular.injector(['ng', stringFilters.name, formatEpoch.name]);
|
|
||||||
var $interpolate = $injector.get('$interpolate');
|
var $interpolate = $injector.get('$interpolate');
|
||||||
|
|
||||||
function FactTemplate(templateString) {
|
function FactTemplate(templateString) {
|
||||||
|
|||||||
Reference in New Issue
Block a user