mirror of
https://github.com/ansible/awx.git
synced 2026-03-09 21:49:27 -02:30
AC-463. Reduced refresh button to automatic page refreh every 10 sec. Duration btwn refreshes can be adjusted in config.js.
This commit is contained in:
@@ -235,6 +235,11 @@ angular.module('ansible', [
|
|||||||
function($cookieStore, $rootScope, CheckLicense, $location, Authorization, LoadBasePaths, ViewLicense) {
|
function($cookieStore, $rootScope, CheckLicense, $location, Authorization, LoadBasePaths, ViewLicense) {
|
||||||
|
|
||||||
LoadBasePaths();
|
LoadBasePaths();
|
||||||
|
|
||||||
|
if ( !(typeof $AnsibleConfig.refresh_rate == 'number' && $AnsibleConfig.refresh_rate >= 3
|
||||||
|
&& $AnsibleConfig.refresh_rate <= 99) ) {
|
||||||
|
$AnsibleConfig.refresh_rate = 10;
|
||||||
|
}
|
||||||
|
|
||||||
$rootScope.breadcrumbs = new Array();
|
$rootScope.breadcrumbs = new Array();
|
||||||
$rootScope.crumbCache = new Array();
|
$rootScope.crumbCache = new Array();
|
||||||
@@ -252,6 +257,7 @@ angular.module('ansible', [
|
|||||||
}
|
}
|
||||||
CheckLicense();
|
CheckLicense();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make the correct tab active
|
// Make the correct tab active
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
var base = $location.path().replace(/^\//,'').split('/')[0];
|
||||||
if (base == '') {
|
if (base == '') {
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ var $AnsibleConfig =
|
|||||||
|
|
||||||
debug_mode: true, // Enable console logging messages
|
debug_mode: true, // Enable console logging messages
|
||||||
|
|
||||||
|
refresh_rate: 10, // Number of seconds before refreshing a page. Integer between 3 and 99, inclusive.
|
||||||
|
// Used by awRefresh directive to automatically refresh Jobs and Projects pages.
|
||||||
|
|
||||||
password_strength: 45 // User password strength. Integer between 0 and 100, 100 being impossibly strong.
|
password_strength: 45 // User password strength. Integer between 0 and 100, 100 being impossibly strong.
|
||||||
// This value controls progress bar colors:
|
// This value controls progress bar colors:
|
||||||
// 0 to password_strength - 15 = red;
|
// 0 to password_strength - 15 = red;
|
||||||
|
|||||||
@@ -141,6 +141,22 @@ function JobEventsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
cDate = new Date(set[i].created);
|
cDate = new Date(set[i].created);
|
||||||
set[i].created = FormatDate(cDate);
|
set[i].created = FormatDate(cDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// need job_status so we can show/hide refresh button
|
||||||
|
Rest.setUrl(GetBasePath('jobs') + scope.job_id);
|
||||||
|
Rest.get()
|
||||||
|
.success( function(data, status, headers, config) {
|
||||||
|
scope.job_status = data.status;
|
||||||
|
if (!(data.status == 'pending' || data.status == 'waiting' || data.status == 'running')) {
|
||||||
|
if ($rootScope.timer) {
|
||||||
|
clearInterval($rootScope.timer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.error( function(data, status, headers, config) {
|
||||||
|
ProcessErrors(scope, data, status, null,
|
||||||
|
{ hdr: 'Error!', msg: 'Failed to get job status for job: ' + scope.job_id + '. GET status: ' + status });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
SearchInit({ scope: scope, set: 'jobevents', list: list, url: defaultUrl });
|
SearchInit({ scope: scope, set: 'jobevents', list: list, url: defaultUrl });
|
||||||
|
|||||||
@@ -50,7 +50,24 @@ function JobHostSummaryList ($scope, $rootScope, $location, $log, $routeParams,
|
|||||||
for( var i=0; i < scope.jobhosts.length; i++) {
|
for( var i=0; i < scope.jobhosts.length; i++) {
|
||||||
scope.jobhosts[i].host_name = scope.jobhosts[i].summary_fields.host.name;
|
scope.jobhosts[i].host_name = scope.jobhosts[i].summary_fields.host.name;
|
||||||
scope.jobhosts[i].status = (scope.jobhosts[i].failed) ? 'error' : 'success';
|
scope.jobhosts[i].status = (scope.jobhosts[i].failed) ? 'error' : 'success';
|
||||||
}
|
}
|
||||||
|
if (scope.host_id == null) {
|
||||||
|
// need job_status so we can show/hide refresh button
|
||||||
|
Rest.setUrl(GetBasePath('jobs') + scope.job_id);
|
||||||
|
Rest.get()
|
||||||
|
.success( function(data, status, headers, config) {
|
||||||
|
scope.job_status = data.status;
|
||||||
|
if (!(data.status == 'pending' || data.status == 'waiting' || data.status == 'running')) {
|
||||||
|
if ($rootScope.timer) {
|
||||||
|
clearInterval($rootScope.timer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.error( function(data, status, headers, config) {
|
||||||
|
ProcessErrors(scope, data, status, null,
|
||||||
|
{ hdr: 'Error!', msg: 'Failed to get job status for job: ' + scope.job_id + '. GET status: ' + status });
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
SearchInit({ scope: scope, set: 'jobhosts', list: list, url: defaultUrl });
|
SearchInit({ scope: scope, set: 'jobhosts', list: list, url: defaultUrl });
|
||||||
|
|||||||
@@ -262,6 +262,12 @@ function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
scope.playbook_options = null;
|
scope.playbook_options = null;
|
||||||
scope.playbook = null;
|
scope.playbook = null;
|
||||||
|
|
||||||
|
function calcRows (content) {
|
||||||
|
var n = content.match(/\n/g);
|
||||||
|
var rows = (n) ? n.length : 1;
|
||||||
|
return (rows > 15) ? 15 : rows;
|
||||||
|
}
|
||||||
|
|
||||||
// Retrieve detail record and prepopulate the form
|
// Retrieve detail record and prepopulate the form
|
||||||
Rest.setUrl(defaultUrl + ':id/');
|
Rest.setUrl(defaultUrl + ':id/');
|
||||||
Rest.get({ params: {id: id} })
|
Rest.get({ params: {id: id} })
|
||||||
@@ -336,17 +342,20 @@ function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
relatedSets[set] = { url: related[set], iterator: form.related[set].iterator };
|
relatedSets[set] = { url: related[set], iterator: form.related[set].iterator };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calc row size of stdout and traceback textarea fields
|
// Calc row size of stdout and traceback textarea fields
|
||||||
var n = scope['result_stdout'].match(/\n/g);
|
//var n = scope['result_stdout'].match(/\n/g);
|
||||||
var rows = (n) ? n.length : 1;
|
//var rows = (n) ? n.length : 1;
|
||||||
rows = (rows > 15) ? 15 : rows;
|
//rows = (rows > 15) ? 15 : rows;
|
||||||
scope['stdout_rows'] = rows;
|
//rows;
|
||||||
|
|
||||||
n = scope['result_traceback'].match(/\n/g);
|
scope['stdout_rows'] = calcRows(scope['result_stdout']);
|
||||||
var rows = (n) ? n.length : 1;
|
|
||||||
rows = (rows > 15) ? 15 : rows;
|
//n = scope['result_traceback'].match(/\n/g);
|
||||||
scope['traceback_rows'] = rows;
|
//var rows = (n) ? n.length : 1;
|
||||||
|
//rows = (rows > 15) ? 15 : rows;
|
||||||
|
|
||||||
|
scope['traceback_rows'] = calcRows(scope['result_traceback']);
|
||||||
|
|
||||||
LookUpInit({
|
LookUpInit({
|
||||||
scope: scope,
|
scope: scope,
|
||||||
@@ -461,6 +470,13 @@ function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
scope.status = data.status;
|
scope.status = data.status;
|
||||||
scope.result_stdout = data.result_stdout;
|
scope.result_stdout = data.result_stdout;
|
||||||
scope.result_traceback = data.result_traceback;
|
scope.result_traceback = data.result_traceback;
|
||||||
|
scope['stdout_rows'] = calcRows(scope['result_stdout']);
|
||||||
|
scope['traceback_rows'] = calcRows(scope['result_traceback']);
|
||||||
|
if (!(data.status == 'pending' || data.status == 'waiting' || data.status == 'running')) {
|
||||||
|
if ($rootScope.timer) {
|
||||||
|
clearInterval($rootScope.timer);
|
||||||
|
}
|
||||||
|
}
|
||||||
scope.statusSearchSpin = false;
|
scope.statusSearchSpin = false;
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error( function(data, status, headers, config) {
|
||||||
|
|||||||
@@ -27,8 +27,11 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
|
|
||||||
var url = (base == 'teams') ? GetBasePath('teams') + $routeParams.team_id + '/projects/' : defaultUrl;
|
var url = (base == 'teams') ? GetBasePath('teams') + $routeParams.team_id + '/projects/' : defaultUrl;
|
||||||
SelectionInit({ scope: scope, list: list, url: url, returnToCaller: 1 });
|
|
||||||
|
|
||||||
|
if (mode == 'select') {
|
||||||
|
SelectionInit({ scope: scope, list: list, url: url, returnToCaller: 1 });
|
||||||
|
}
|
||||||
|
|
||||||
if (scope.projectsPostRefresh) {
|
if (scope.projectsPostRefresh) {
|
||||||
scope.projectsPostRefresh();
|
scope.projectsPostRefresh();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -291,12 +291,9 @@ angular.module('JobFormDefinition', [])
|
|||||||
},
|
},
|
||||||
|
|
||||||
statusActions: {
|
statusActions: {
|
||||||
refresh: {
|
refresh: {
|
||||||
label: 'Refresh',
|
awRefresh: true,
|
||||||
icon: 'icon-refresh',
|
ngShow: "(status == 'pending' || status == 'waiting' || status == 'running')",
|
||||||
ngClick: "refresh()",
|
|
||||||
"class": 'btn-sm btn-primary',
|
|
||||||
awToolTip: 'Refresh job status & output',
|
|
||||||
mode: 'all'
|
mode: 'all'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,22 +133,24 @@ angular.module('SelectionHelper', ['Utilities', 'RestServices'])
|
|||||||
scope.SelectPostRefreshRemove();
|
scope.SelectPostRefreshRemove();
|
||||||
}
|
}
|
||||||
scope.SelectPostRefreshRemove = scope.$on('PostRefresh', function() {
|
scope.SelectPostRefreshRemove = scope.$on('PostRefresh', function() {
|
||||||
for (var i=0; i < scope[list.name].length; i++) {
|
if (scope[list.name]) {
|
||||||
var found = false;
|
for (var i=0; i < scope[list.name].length; i++) {
|
||||||
for (var j=0; j < scope.selected.length; j++) {
|
var found = false;
|
||||||
if (scope.selected[j].id == scope[list.name][i].id) {
|
for (var j=0; j < scope.selected.length; j++) {
|
||||||
found = true;
|
if (scope.selected[j].id == scope[list.name][i].id) {
|
||||||
break;
|
found = true;
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
if (found) {
|
}
|
||||||
scope[list.name][i]['checked'] = '1';
|
if (found) {
|
||||||
scope[list.name][i]['success_class'] = 'success';
|
scope[list.name][i]['checked'] = '1';
|
||||||
}
|
scope[list.name][i]['success_class'] = 'success';
|
||||||
else {
|
}
|
||||||
scope[list.name][i]['checked'] = '0';
|
else {
|
||||||
scope[list.name][i]['success_class'] = '';
|
scope[list.name][i]['checked'] = '0';
|
||||||
}
|
scope[list.name][i]['success_class'] = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,11 +72,8 @@ angular.module('JobEventsListDefinition', [])
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
refresh: {
|
refresh: {
|
||||||
ngClick: "refresh()",
|
awRefresh: true,
|
||||||
icon: 'icon-refresh',
|
ngShow: "job_status == 'pending' || job_status == 'waiting' || job_status == 'running'",
|
||||||
label: 'Refresh',
|
|
||||||
awToolTip: 'Refresh the page',
|
|
||||||
"class": 'btn-sm btn-primary',
|
|
||||||
mode: 'all'
|
mode: 'all'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -79,11 +79,8 @@ angular.module('JobHostDefinition', [])
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
refresh: {
|
refresh: {
|
||||||
label: 'Refresh',
|
awRefresh: true,
|
||||||
icon: 'icon-refresh',
|
ngShow: "host_id == null && (job_status == 'pending' || job_status == 'waiting' || job_status == 'running')",
|
||||||
ngClick: "refresh()",
|
|
||||||
"class": 'btn-primary btn-sm',
|
|
||||||
awToolTip: 'Refresh the page',
|
|
||||||
mode: 'all'
|
mode: 'all'
|
||||||
},
|
},
|
||||||
help: {
|
help: {
|
||||||
|
|||||||
@@ -59,11 +59,7 @@ angular.module('JobsListDefinition', [])
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
refresh: {
|
refresh: {
|
||||||
label: 'Refresh',
|
awRefresh: true,
|
||||||
"class": 'btn-primary btn-sm',
|
|
||||||
ngClick: "refreshJob(\{\{ job.id \}\})",
|
|
||||||
icon: 'icon-refresh',
|
|
||||||
awToolTip: 'Refresh the page',
|
|
||||||
mode: 'all'
|
mode: 'all'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ angular.module('ProjectsListDefinition', [])
|
|||||||
fields: {
|
fields: {
|
||||||
name: {
|
name: {
|
||||||
key: true,
|
key: true,
|
||||||
label: 'Name',
|
label: 'Name'
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
label: 'Description',
|
label: 'Description',
|
||||||
@@ -53,11 +53,7 @@ angular.module('ProjectsListDefinition', [])
|
|||||||
awToolTip: 'Create a new project'
|
awToolTip: 'Create a new project'
|
||||||
},
|
},
|
||||||
refresh: {
|
refresh: {
|
||||||
label: 'Refresh',
|
awRefresh: true,
|
||||||
"class": 'btn-primary btn-sm',
|
|
||||||
ngClick: "refresh(\{\{ job.id \}\})",
|
|
||||||
icon: 'icon-refresh',
|
|
||||||
awToolTip: 'Refresh the page',
|
|
||||||
mode: 'all'
|
mode: 'all'
|
||||||
},
|
},
|
||||||
help: {
|
help: {
|
||||||
|
|||||||
@@ -145,6 +145,18 @@ td.actions {
|
|||||||
border-color: #ddd;
|
border-color: #ddd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.refresh-grp {
|
||||||
|
display: inline-block;
|
||||||
|
margin-left: 10px;
|
||||||
|
margin-top: 0;
|
||||||
|
padding: 0;
|
||||||
|
line-height: normal;
|
||||||
|
|
||||||
|
.refresh-msg {
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.btn-light:hover {
|
.btn-light:hover {
|
||||||
color: #333;
|
color: #333;
|
||||||
background-color: #ccc;
|
background-color: #ccc;
|
||||||
@@ -392,7 +404,6 @@ legend {
|
|||||||
.status-actions {
|
.status-actions {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
height: 25px;
|
height: 25px;
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-spin {
|
.status-spin {
|
||||||
|
|||||||
@@ -154,7 +154,6 @@ angular.module('Utilities',[])
|
|||||||
|
|
||||||
//Keep a list of path/title mappings. When we see /organizations/XX in the path, for example,
|
//Keep a list of path/title mappings. When we see /organizations/XX in the path, for example,
|
||||||
//we'll know the actual organization name it maps to.
|
//we'll know the actual organization name it maps to.
|
||||||
console.log($rootScope.crumbCache);
|
|
||||||
if (crumb !== null && crumb !== undefined) {
|
if (crumb !== null && crumb !== undefined) {
|
||||||
var found = false;
|
var found = false;
|
||||||
for (var i=0; i < $rootScope.crumbCache.length; i++) {
|
for (var i=0; i < $rootScope.crumbCache.length; i++) {
|
||||||
|
|||||||
@@ -11,34 +11,45 @@ angular.module('ApiLoader', ['ngCookies'])
|
|||||||
.factory('LoadBasePaths', ['$http', '$rootScope', '$cookieStore', 'ProcessErrors',
|
.factory('LoadBasePaths', ['$http', '$rootScope', '$cookieStore', 'ProcessErrors',
|
||||||
function($http, $rootScope, $cookieStore, ProcessErrors) {
|
function($http, $rootScope, $cookieStore, ProcessErrors) {
|
||||||
return function() {
|
return function() {
|
||||||
$http.get('/api/')
|
if (!$rootScope['defaultUrls'])
|
||||||
.success( function(data, status, headers, config) {
|
// if 'defaultUrls', the data used by GetBasePath(), is not in $rootScope, then we need to
|
||||||
var base = data.current_version;
|
// restore it from cookieStore or by querying the API. it goes missing from $rootScope
|
||||||
$http.get(base)
|
// when user hits browser refresh
|
||||||
.success( function(data, status, headers, config) {
|
if (!$cookieStore.get('api')) {
|
||||||
data['base'] = base;
|
// if it's not in cookieStore, then we need to retrieve it from the API
|
||||||
$rootScope['defaultUrls'] = data;
|
$http.get('/api/')
|
||||||
$cookieStore.remove('api');
|
.success( function(data, status, headers, config) {
|
||||||
$cookieStore.put('api',data); //Preserve in cookie to prevent against
|
var base = data.current_version;
|
||||||
//loss during browser refresh
|
$http.get(base)
|
||||||
})
|
.success( function(data, status, headers, config) {
|
||||||
.error ( function(data, status, headers, config) {
|
data['base'] = base;
|
||||||
$rootScope['defaultUrls'] = { status: 'error' };
|
$rootScope['defaultUrls'] = data;
|
||||||
ProcessErrors(null, data, status, null,
|
$cookieStore.remove('api');
|
||||||
{ hdr: 'Error', msg: 'Failed to read ' + base + '. GET status: ' + status });
|
$cookieStore.put('api',data); //Preserve in cookie to prevent against
|
||||||
});
|
//loss during browser refresh
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error ( function(data, status, headers, config) {
|
||||||
$rootScope['defaultUrls'] = { status: 'error' };
|
$rootScope['defaultUrls'] = { status: 'error' };
|
||||||
ProcessErrors(null, data, status, null,
|
ProcessErrors(null, data, status, null,
|
||||||
{ hdr: 'Error', msg: 'Failed to read /api. GET status: ' + status });
|
{ hdr: 'Error', msg: 'Failed to read ' + base + '. GET status: ' + status });
|
||||||
});
|
});
|
||||||
|
})
|
||||||
|
.error( function(data, status, headers, config) {
|
||||||
|
$rootScope['defaultUrls'] = { status: 'error' };
|
||||||
|
ProcessErrors(null, data, status, null,
|
||||||
|
{ hdr: 'Error', msg: 'Failed to read /api. GET status: ' + status });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$rootScope['defaultUrls'] = $cookieStore.get('api');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}])
|
}])
|
||||||
|
|
||||||
.factory('GetBasePath', ['$rootScope', '$cookieStore', 'LoadBasePaths',
|
.factory('GetBasePath', ['$rootScope', '$cookieStore', 'LoadBasePaths',
|
||||||
function($rootScope, $cookieStore, LoadBasePaths) {
|
function($rootScope, $cookieStore, LoadBasePaths) {
|
||||||
return function(set) {
|
return function(set) {
|
||||||
|
// use /api/v1/ results to construct API URLs.
|
||||||
var answer;
|
var answer;
|
||||||
if ($rootScope['defaultUrls'] == null || $rootScope['defaultUrls'] == undefined) {
|
if ($rootScope['defaultUrls'] == null || $rootScope['defaultUrls'] == undefined) {
|
||||||
// browser refresh must have occurred. use what's in session cookie and refresh
|
// browser refresh must have occurred. use what's in session cookie and refresh
|
||||||
|
|||||||
@@ -408,6 +408,42 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Hos
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}])
|
||||||
|
|
||||||
|
//
|
||||||
|
// awRefresh
|
||||||
|
//
|
||||||
|
// Creates a timer to call scope.refresh(iterator) ever N seconds, where
|
||||||
|
// N is a setting in config.js
|
||||||
|
//
|
||||||
|
.directive('awRefresh', [ '$rootScope', function($rootScope) {
|
||||||
|
return {
|
||||||
|
link: function(scope, elm, attrs, ctrl) {
|
||||||
|
function msg() {
|
||||||
|
var num = '' + scope.refreshCnt;
|
||||||
|
while (num.length < 2) {
|
||||||
|
num = '0' + num;
|
||||||
|
}
|
||||||
|
return 'Refresh in ' + num + ' sec.';
|
||||||
|
}
|
||||||
|
scope.refreshCnt = $AnsibleConfig.refresh_rate;
|
||||||
|
scope.refreshMsg = msg();
|
||||||
|
if ($rootScope.timer) {
|
||||||
|
clearInterval($rootScope.timer);
|
||||||
|
}
|
||||||
|
$rootScope.timer = setInterval( function() {
|
||||||
|
scope.refreshCnt--;
|
||||||
|
if (scope.refreshCnt <= 0) {
|
||||||
|
scope.refresh();
|
||||||
|
scope.refreshCnt = $AnsibleConfig.refresh_rate;
|
||||||
|
}
|
||||||
|
scope.refreshMsg = msg();
|
||||||
|
if (!scope.$$phase) {
|
||||||
|
scope.$digest();
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
|
angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
|
||||||
.factory('GenerateForm', [ '$location', '$cookieStore', '$compile', 'SearchWidget', 'PaginateWidget', 'Attr', 'Icon', 'Column',
|
.factory('GenerateForm', [ '$location', '$cookieStore', '$compile', 'SearchWidget', 'PaginateWidget', 'Attr', 'Icon', 'Column',
|
||||||
'NavigationLink', 'HelpCollapse',
|
'NavigationLink', 'HelpCollapse', 'Button',
|
||||||
function($location, $cookieStore, $compile, SearchWidget, PaginateWidget, Attr, Icon, Column, NavigationLink, HelpCollapse) {
|
function($location, $cookieStore, $compile, SearchWidget, PaginateWidget, Attr, Icon, Column, NavigationLink, HelpCollapse, Button) {
|
||||||
return {
|
return {
|
||||||
|
|
||||||
setForm: function(form) {
|
setForm: function(form) {
|
||||||
@@ -86,6 +86,7 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
|
|||||||
$('.tooltip').each( function(index) {
|
$('.tooltip').each( function(index) {
|
||||||
$(this).remove();
|
$(this).remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.popover').each(function(index) {
|
$('.popover').each(function(index) {
|
||||||
// remove lingering popover <div>. Seems to be a bug in TB3 RC1
|
// remove lingering popover <div>. Seems to be a bug in TB3 RC1
|
||||||
$(this).remove();
|
$(this).remove();
|
||||||
@@ -277,7 +278,7 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
|
|||||||
return html;
|
return html;
|
||||||
},
|
},
|
||||||
|
|
||||||
button: function(btn, topOrBottom) {
|
/*button: function(btn, topOrBottom) {
|
||||||
// pass in a button object and get back an html string containing
|
// pass in a button object and get back an html string containing
|
||||||
// a <button> element.
|
// a <button> element.
|
||||||
var html = '';
|
var html = '';
|
||||||
@@ -297,7 +298,9 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return html;
|
return html;
|
||||||
},
|
},*/
|
||||||
|
|
||||||
|
button: Button,
|
||||||
|
|
||||||
navigationLink: NavigationLink,
|
navigationLink: NavigationLink,
|
||||||
|
|
||||||
@@ -854,21 +857,14 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
|
|||||||
// Add status fields section (used in Jobs form)
|
// Add status fields section (used in Jobs form)
|
||||||
html += "<div class=\"well\">\n";
|
html += "<div class=\"well\">\n";
|
||||||
if (this.form.statusActions) {
|
if (this.form.statusActions) {
|
||||||
html += "<div class=\"status-actions\">\n";
|
//html += "<div class=\"status-actions\">\n";
|
||||||
var act;
|
var act;
|
||||||
for (action in this.form.statusActions) {
|
for (action in this.form.statusActions) {
|
||||||
act = this.form.statusActions[action];
|
act = this.form.statusActions[action];
|
||||||
html += "<button type=\"button\" " + this.attr(act, 'ngClick') + "class=\"btn btn-small";
|
html += this.button(act);
|
||||||
html += (act['class']) ? " " + act['class'] : "";
|
}
|
||||||
html += "\" ";
|
//html += "</div>\n";
|
||||||
html += (act.awToolTip) ? this.attr(act,'awToolTip') : "";
|
//html += "<div class=\"status-spin\"><i class=\"icon-spinner icon-spin\" ng-show=\"statusSearchSpin == true\"></i></div>\n";
|
||||||
html += (act.awToolTip) ? "data-placement=\"top\" " : "";
|
|
||||||
html += " >" + this.icon(act.icon);
|
|
||||||
html += (act.label) ? act.label : "";
|
|
||||||
html += "</button> ";
|
|
||||||
}
|
|
||||||
html += "</div>\n";
|
|
||||||
html += "<div class=\"status-spin\"><i class=\"icon-spinner icon-spin\" ng-show=\"statusSearchSpin == true\"></i></div>\n";
|
|
||||||
}
|
}
|
||||||
html += "<div class=\"form-horizontal status-fields\">\n";
|
html += "<div class=\"form-horizontal status-fields\">\n";
|
||||||
for (var fld in this.form.statusFields) {
|
for (var fld in this.form.statusFields) {
|
||||||
@@ -899,7 +895,7 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
|
|||||||
html += "<div>\n";
|
html += "<div>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.form.navigation) {
|
/* if (this.form.navigation) {
|
||||||
html += "<div class=\"navigation-buttons navigation-buttons-top\">\n";
|
html += "<div class=\"navigation-buttons navigation-buttons-top\">\n";
|
||||||
for (btn in this.form.navigation) {
|
for (btn in this.form.navigation) {
|
||||||
var btn = this.form.navigation[btn];
|
var btn = this.form.navigation[btn];
|
||||||
@@ -908,7 +904,7 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
html += "</div>\n";
|
html += "</div>\n";
|
||||||
}
|
} */
|
||||||
|
|
||||||
// Start the well
|
// Start the well
|
||||||
if ( this.has('well') ) {
|
if ( this.has('well') ) {
|
||||||
@@ -1034,7 +1030,7 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
|
|||||||
html += "</div>\n";
|
html += "</div>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.form.navigation) {
|
/*if (this.form.navigation) {
|
||||||
html += "<div class=\"navigation-buttons navigation-buttons-bottom\">\n";
|
html += "<div class=\"navigation-buttons navigation-buttons-bottom\">\n";
|
||||||
for (btn in this.form.navigation) {
|
for (btn in this.form.navigation) {
|
||||||
var btn = this.form.navigation[btn];
|
var btn = this.form.navigation[btn];
|
||||||
@@ -1043,7 +1039,7 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
html += "</div>\n";
|
html += "</div>\n";
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if ( this.form.collapse && this.form.collapseMode == options.mode ) {
|
if ( this.form.collapse && this.form.collapseMode == options.mode ) {
|
||||||
html += "</div>\n";
|
html += "</div>\n";
|
||||||
|
|||||||
@@ -93,6 +93,54 @@ angular.module('GeneratorHelpers', ['GeneratorHelpers'])
|
|||||||
return "<i class=\"" + icon + "\"></i> ";
|
return "<i class=\"" + icon + "\"></i> ";
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
.factory('Button', ['Attr', function(Attr) {
|
||||||
|
return function(btn) {
|
||||||
|
// pass in button object, get back html
|
||||||
|
var html = '';
|
||||||
|
if (btn.awRefresh) {
|
||||||
|
html += "<div class=\"refresh-grp pull-right\" ";
|
||||||
|
html += (btn.ngShow) ? Attr(btn, 'ngShow') : "";
|
||||||
|
html += ">\n";
|
||||||
|
}
|
||||||
|
html += "<button type=\"button\" " + "class=\"btn";
|
||||||
|
if (btn.awRefresh && !btn['class']) {
|
||||||
|
html += ' btn-primary btn-xs refresh-btn';
|
||||||
|
}
|
||||||
|
else if (btn['class']) {
|
||||||
|
html += ' ' + btn['class'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
html += " btn-sm";
|
||||||
|
}
|
||||||
|
html += (btn['awPopOver']) ? " help-link-white" : "";
|
||||||
|
html += "\" ";
|
||||||
|
html += (btn.ngClick) ? Attr(btn, 'ngClick') : "";
|
||||||
|
html += (btn.awRefresh) ? " ng-click=\"refreshCnt = " + $AnsibleConfig.refresh_rate + "; refresh()\" " : "";
|
||||||
|
html += (btn.id) ? "id=\"" + btn.id + "\" " : "";
|
||||||
|
html += (btn.ngHide) ? Attr(btn,'ngHide') : "";
|
||||||
|
html += (btn.awToolTip) ? Attr(btn,'awToolTip') : "";
|
||||||
|
html += (btn.awToolTip && btn.dataPlacement == undefined) ? "data-placement=\"top\" " : "";
|
||||||
|
html += (btn.awRefresh && !btn.awTooltip) ? "aw-tool-tip=\"Refresh page\" " : "";
|
||||||
|
html += (btn.awPopOver) ? "aw-pop-over=\"" +
|
||||||
|
btn.awPopOver.replace(/[\'\"]/g, '"') + "\" " : "";
|
||||||
|
html += (btn.dataPlacement) ? Attr(btn, 'dataPlacement') : "";
|
||||||
|
html += (btn.dataContainer) ? Attr(btn, 'dataContainer') : "";
|
||||||
|
html += (btn.dataTitle) ? Attr(btn, 'dataTitle') : "";
|
||||||
|
html += (btn.ngShow) ? Attr(btn, 'ngShow') : "";
|
||||||
|
html += (btn.ngHide) ? Attr(btn, 'ngHide') : "";
|
||||||
|
html += " >";
|
||||||
|
html += (btn['icon']) ? Attr(btn,'icon') : "";
|
||||||
|
html += (btn['awRefresh'] && !btn['icon']) ? "<i class=\"icon-refresh\"></i> " : "";
|
||||||
|
html += (btn.label) ? " " + btn.label : "";
|
||||||
|
html += "</button> ";
|
||||||
|
if (btn['awRefresh']) {
|
||||||
|
html += '<span class=\"refresh-msg\" aw-refresh>{{ refreshMsg }}</span>\n';
|
||||||
|
html += "</div><!-- refresh-grp -->\n";
|
||||||
|
}
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
}])
|
||||||
|
|
||||||
.factory('NavigationLink', ['Attr', 'Icon', function(Attr, Icon) {
|
.factory('NavigationLink', ['Attr', 'Icon', function(Attr, Icon) {
|
||||||
return function(link) {
|
return function(link) {
|
||||||
|
|||||||
@@ -9,8 +9,8 @@
|
|||||||
|
|
||||||
angular.module('ListGenerator', ['GeneratorHelpers'])
|
angular.module('ListGenerator', ['GeneratorHelpers'])
|
||||||
.factory('GenerateList', [ '$location', '$compile', '$rootScope', 'SearchWidget', 'PaginateWidget', 'Attr', 'Icon',
|
.factory('GenerateList', [ '$location', '$compile', '$rootScope', 'SearchWidget', 'PaginateWidget', 'Attr', 'Icon',
|
||||||
'Column', 'DropDown', 'NavigationLink',
|
'Column', 'DropDown', 'NavigationLink', 'Button',
|
||||||
function($location, $compile, $rootScope, SearchWidget, PaginateWidget, Attr, Icon, Column, DropDown, NavigationLink) {
|
function($location, $compile, $rootScope, SearchWidget, PaginateWidget, Attr, Icon, Column, DropDown, NavigationLink, Button) {
|
||||||
return {
|
return {
|
||||||
|
|
||||||
setList: function(list) {
|
setList: function(list) {
|
||||||
@@ -29,29 +29,7 @@ angular.module('ListGenerator', ['GeneratorHelpers'])
|
|||||||
$('#lookup-modal').modal('hide');
|
$('#lookup-modal').modal('hide');
|
||||||
},
|
},
|
||||||
|
|
||||||
button: function(btn) {
|
button: Button,
|
||||||
// pass in button object, get back html
|
|
||||||
var html = '';
|
|
||||||
html += "<button type=\"button\" " + this.attr(btn, 'ngClick') + "class=\"btn";
|
|
||||||
html += (btn['class']) ? " " + btn['class'] : " btn-sm";
|
|
||||||
html += (btn['awPopOver']) ? " help-link-white" : "";
|
|
||||||
html += "\" ";
|
|
||||||
html += (btn.id) ? "id=\"" + btn.id + "\" " : "";
|
|
||||||
html += (btn.ngHide) ? this.attr(btn,'ngHide') : "";
|
|
||||||
html += (btn.awToolTip) ? this.attr(btn,'awToolTip') : "";
|
|
||||||
html += (btn.awToolTip && btn.dataPlacement == undefined) ? "data-placement=\"top\" " : "";
|
|
||||||
html += (btn.awPopOver) ? "aw-pop-over=\"" +
|
|
||||||
btn.awPopOver.replace(/[\'\"]/g, '"') + "\" " : "";
|
|
||||||
html += (btn.dataPlacement) ? this.attr(btn, 'dataPlacement') : "";
|
|
||||||
html += (btn.dataContainer) ? this.attr(btn, 'dataContainer') : "";
|
|
||||||
html += (btn.dataTitle) ? this.attr(btn, 'dataTitle') : "";
|
|
||||||
html += (btn.ngShow) ? this.attr(btn, 'ngShow') : "";
|
|
||||||
html += (btn.ngHide) ? this.attr(btn, 'ngHide') : "";
|
|
||||||
html += " >" + this.attr(btn,'icon');
|
|
||||||
html += (btn.label) ? " " + btn.label : "";
|
|
||||||
html += "</button> ";
|
|
||||||
return html;
|
|
||||||
},
|
|
||||||
|
|
||||||
inject: function(list, options) {
|
inject: function(list, options) {
|
||||||
// options.mode = one of edit, select or lookup
|
// options.mode = one of edit, select or lookup
|
||||||
@@ -93,6 +71,10 @@ angular.module('ListGenerator', ['GeneratorHelpers'])
|
|||||||
// remove lingering popover <div>. Seems to be a bug in TB3 RC1
|
// remove lingering popover <div>. Seems to be a bug in TB3 RC1
|
||||||
$(this).remove();
|
$(this).remove();
|
||||||
});
|
});
|
||||||
|
// Remove leftover timer
|
||||||
|
//if (options.mode != 'lookup' && $rootScope.timer) {
|
||||||
|
// clearInterval($rootScope.timer);
|
||||||
|
//}
|
||||||
|
|
||||||
if (options.mode == 'lookup') {
|
if (options.mode == 'lookup') {
|
||||||
// options should include {hdr: <dialog header>, action: <function...> }
|
// options should include {hdr: <dialog header>, action: <function...> }
|
||||||
@@ -169,7 +151,7 @@ angular.module('ListGenerator', ['GeneratorHelpers'])
|
|||||||
if (list.actions[action].mode == 'all' || list.actions[action].mode == options.mode) {
|
if (list.actions[action].mode == 'all' || list.actions[action].mode == options.mode) {
|
||||||
if ( (list.actions[action].basePaths == undefined) ||
|
if ( (list.actions[action].basePaths == undefined) ||
|
||||||
(list.actions[action].basePaths && list.actions[action].basePaths.indexOf(base) > -1) ) {
|
(list.actions[action].basePaths && list.actions[action].basePaths.indexOf(base) > -1) ) {
|
||||||
html += this.button(list.actions[action]);
|
html += this.button(list.actions[action], list.iterator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user