mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 17:37:37 -02:30
@@ -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;
|
|
||||||
};
|
|
||||||
}]);
|
|
||||||
15
awx/ui/client/src/shared/filters/append.filter.js
Normal file
15
awx/ui/client/src/shared/filters/append.filter.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
export default function() {
|
||||||
|
return function(string, append) {
|
||||||
|
if (string) {
|
||||||
|
if (append) {
|
||||||
|
return string + append;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
12
awx/ui/client/src/shared/filters/capitalize.filter.js
Normal file
12
awx/ui/client/src/shared/filters/capitalize.filter.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
/*************************************************
|
||||||
|
* 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;
|
||||||
|
};
|
||||||
|
}];
|
||||||
@@ -12,5 +12,3 @@ export default
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
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;
|
||||||
|
};
|
||||||
|
}
|
||||||
17
awx/ui/client/src/shared/filters/long-date.filter.js
Normal file
17
awx/ui/client/src/shared/filters/long-date.filter.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
export default ['moment', function(moment) {
|
||||||
|
return function(input) {
|
||||||
|
var date;
|
||||||
|
if(input === null || input === undefined){
|
||||||
|
return "";
|
||||||
|
}else {
|
||||||
|
date = moment(input);
|
||||||
|
return date.format('l LTS');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}];
|
||||||
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);
|
||||||
15
awx/ui/client/src/shared/filters/prepend.filter.js
Normal file
15
awx/ui/client/src/shared/filters/prepend.filter.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
export default function() {
|
||||||
|
return function(string, prepend) {
|
||||||
|
if (string) {
|
||||||
|
if(prepend) {
|
||||||
|
return prepend + string;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
12
awx/ui/client/src/shared/filters/xss-sanitizer.filter.js
Normal file
12
awx/ui/client/src/shared/filters/xss-sanitizer.filter.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2015 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
export default [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,10 +0,0 @@
|
|||||||
export default function() {
|
|
||||||
return function(string, append) {
|
|
||||||
if (string) {
|
|
||||||
return string + append;
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -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,9 +0,0 @@
|
|||||||
export default function() {
|
|
||||||
return function(string, prepend) {
|
|
||||||
if (string) {
|
|
||||||
return prepend + string;
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -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) {
|
||||||
|
|||||||
25
awx/ui/tests/spec/shared/filters/append.filter-test.js
Normal file
25
awx/ui/tests/spec/shared/filters/append.filter-test.js
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
describe('Filter: append', () => {
|
||||||
|
var filter;
|
||||||
|
|
||||||
|
beforeEach(angular.mock.module('Tower'));
|
||||||
|
|
||||||
|
beforeEach(function(){
|
||||||
|
inject(function($injector){
|
||||||
|
filter = $injector.get('$filter')('append');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should append the two parameters passed', function(){
|
||||||
|
expect(filter("foo", "bar")).toBe("foobar");
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return string if no append param passed', function(){
|
||||||
|
expect(filter("foo")).toBe("foo");
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return empty string if no params passed', function(){
|
||||||
|
expect(filter()).toBe("");
|
||||||
|
});
|
||||||
|
});
|
||||||
20
awx/ui/tests/spec/shared/filters/capitalize.filter-test.js
Normal file
20
awx/ui/tests/spec/shared/filters/capitalize.filter-test.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
describe('Filter: capitalize', () => {
|
||||||
|
var filter;
|
||||||
|
|
||||||
|
beforeEach(angular.mock.module('Tower'));
|
||||||
|
|
||||||
|
beforeEach(function(){
|
||||||
|
inject(function($injector){
|
||||||
|
filter = $injector.get('$filter')('capitalize');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should capitalize the first letter', function(){
|
||||||
|
expect(filter("foo")).toBe("Foo");
|
||||||
|
expect(filter("Foo")).toBe("Foo");
|
||||||
|
expect(filter("FOO")).toBe("Foo");
|
||||||
|
expect(filter("FoO")).toBe("Foo");
|
||||||
|
});
|
||||||
|
});
|
||||||
18
awx/ui/tests/spec/shared/filters/format-epoch.filter-test.js
Normal file
18
awx/ui/tests/spec/shared/filters/format-epoch.filter-test.js
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
describe('Filter: formatEpoch', () => {
|
||||||
|
var filter;
|
||||||
|
|
||||||
|
beforeEach(angular.mock.module('Tower'));
|
||||||
|
|
||||||
|
beforeEach(function(){
|
||||||
|
inject(function($injector){
|
||||||
|
filter = $injector.get('$filter')('formatEpoch');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should convert epoch to datetime string', function(){
|
||||||
|
expect(filter(11111)).toBe("Dec 31, 1969 10:05 PM");
|
||||||
|
expect(filter(610430400)).toBe("May 6, 1989 12:00 AM");
|
||||||
|
});
|
||||||
|
});
|
||||||
18
awx/ui/tests/spec/shared/filters/is-empty.filter-test.js
Normal file
18
awx/ui/tests/spec/shared/filters/is-empty.filter-test.js
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
describe('Filter: isEmpty', () => {
|
||||||
|
var filter;
|
||||||
|
|
||||||
|
beforeEach(angular.mock.module('Tower'));
|
||||||
|
|
||||||
|
beforeEach(function(){
|
||||||
|
inject(function($injector){
|
||||||
|
filter = $injector.get('$filter')('isEmpty');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('check if an object is empty', function(){
|
||||||
|
expect(filter({})).toBe(true);
|
||||||
|
expect(filter({foo: 'bar'})).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
20
awx/ui/tests/spec/shared/filters/long-date.filter-test.js
Normal file
20
awx/ui/tests/spec/shared/filters/long-date.filter-test.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
describe('Filter: longDate', () => {
|
||||||
|
var filter;
|
||||||
|
|
||||||
|
beforeEach(angular.mock.module('Tower'));
|
||||||
|
|
||||||
|
beforeEach(function(){
|
||||||
|
inject(function($injector){
|
||||||
|
filter = $injector.get('$filter')('longDate');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should convert the timestamp to a UI friendly date and time', function(){
|
||||||
|
expect(filter("2017-02-13T22:00:14.106Z")).toBe("2/13/2017 5:00:14 PM");
|
||||||
|
});
|
||||||
|
it('should return an empty string if no timestamp is passed', function(){
|
||||||
|
expect(filter()).toBe("");
|
||||||
|
});
|
||||||
|
});
|
||||||
25
awx/ui/tests/spec/shared/filters/prepend.filter-test.js
Normal file
25
awx/ui/tests/spec/shared/filters/prepend.filter-test.js
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
describe('Filter: prepend', () => {
|
||||||
|
var filter;
|
||||||
|
|
||||||
|
beforeEach(angular.mock.module('Tower'));
|
||||||
|
|
||||||
|
beforeEach(function(){
|
||||||
|
inject(function($injector){
|
||||||
|
filter = $injector.get('$filter')('prepend');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should prepend the second param to the first', function(){
|
||||||
|
expect(filter("foo", "bar")).toBe("barfoo");
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return string if no prepend param passed', function(){
|
||||||
|
expect(filter("foo")).toBe("foo");
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return empty string if no params passed', function(){
|
||||||
|
expect(filter()).toBe("");
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
describe('Filter: sanitize', () => {
|
||||||
|
var filter;
|
||||||
|
|
||||||
|
beforeEach(angular.mock.module('Tower'));
|
||||||
|
|
||||||
|
beforeEach(function(){
|
||||||
|
inject(function($injector){
|
||||||
|
filter = $injector.get('$filter')('sanitize');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should sanitize xss-vulnerable strings', function(){
|
||||||
|
expect(filter("<div>foobar</div>")).toBe("<div>foobar</div>");
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user