mirror of
https://github.com/ansible/awx.git
synced 2026-03-01 00:38:45 -03:30
Added subtitle to the activity stream
This commit is contained in:
@@ -275,6 +275,22 @@ table, tbody {
|
|||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.List-titleLockup {
|
||||||
|
margin-left: 4px;
|
||||||
|
margin-right: 6px;
|
||||||
|
display: inline-block;
|
||||||
|
margin-top: 0px;
|
||||||
|
padding-bottom: 2px;
|
||||||
|
vertical-align: bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
.List-titleLockup:before {
|
||||||
|
content: "\007C";
|
||||||
|
color: #d7d7d7;
|
||||||
|
display: block;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
.List-staticColumn--smallStatus {
|
.List-staticColumn--smallStatus {
|
||||||
width: 25px;
|
width: 25px;
|
||||||
padding-right: 0px!important;
|
padding-right: 0px!important;
|
||||||
|
|||||||
@@ -9,13 +9,21 @@
|
|||||||
* @name controllers.function:Activity Stream
|
* @name controllers.function:Activity Stream
|
||||||
* @description This controller controls the activity stream.
|
* @description This controller controls the activity stream.
|
||||||
*/
|
*/
|
||||||
function activityStreamController($scope, Stream) {
|
function activityStreamController($scope, $state, subTitle, Stream, GetTargetTitle) {
|
||||||
|
|
||||||
|
// subTitle is passed in via a resolve on the route. If there is no subtitle
|
||||||
|
// generated in the resolve then we go get the targets generic title.
|
||||||
|
|
||||||
|
// Get the streams sub-title based on the target. This scope variable is leveraged
|
||||||
|
// when we define the activity stream list. Specifically it is included in the list
|
||||||
|
// title.
|
||||||
|
$scope.streamSubTitle = subTitle ? subTitle : GetTargetTitle($state.params.target);
|
||||||
|
|
||||||
// Open the stream
|
// Open the stream
|
||||||
Stream({
|
Stream({
|
||||||
scope: $scope
|
scope: $scope
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ['$scope', 'Stream', activityStreamController];
|
export default ['$scope', '$state', 'subTitle', 'Stream', 'GetTargetTitle', activityStreamController];
|
||||||
|
|||||||
@@ -14,4 +14,39 @@ export default {
|
|||||||
ncyBreadcrumb: {
|
ncyBreadcrumb: {
|
||||||
label: "ACTIVITY STREAM"
|
label: "ACTIVITY STREAM"
|
||||||
},
|
},
|
||||||
|
resolve: {
|
||||||
|
subTitle:
|
||||||
|
[ '$stateParams',
|
||||||
|
'Rest',
|
||||||
|
'ModelToPlural',
|
||||||
|
'GetBasePath',
|
||||||
|
'ProcessErrors',
|
||||||
|
function($stateParams, rest, ModelToPlural, getBasePath, ProcessErrors) {
|
||||||
|
// If we have a target and an ID then we want to go grab the name of the object
|
||||||
|
// that we're examining with the activity stream. This name will be used in the
|
||||||
|
// subtitle.
|
||||||
|
if ($stateParams.target && $stateParams.id) {
|
||||||
|
var target = $stateParams.target;
|
||||||
|
var id = $stateParams.id;
|
||||||
|
|
||||||
|
var url = getBasePath(ModelToPlural(target)) + id + '/';
|
||||||
|
rest.setUrl(url);
|
||||||
|
return rest.get()
|
||||||
|
.then(function(data) {
|
||||||
|
// Return the name or the username depending on which is available.
|
||||||
|
return (data.data.name || data.data.username);
|
||||||
|
}).catch(function (response) {
|
||||||
|
ProcessErrors(null, response.data, response.status, null, {
|
||||||
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to get title info. GET returned status: ' +
|
||||||
|
response.status
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -185,7 +185,9 @@ var tower = angular.module('Tower', [
|
|||||||
'pendolytics',
|
'pendolytics',
|
||||||
'ui.router',
|
'ui.router',
|
||||||
'ncy-angular-breadcrumb',
|
'ncy-angular-breadcrumb',
|
||||||
'scheduler'
|
'scheduler',
|
||||||
|
'ApiModelHelper',
|
||||||
|
'ActivityStreamHelper'
|
||||||
])
|
])
|
||||||
|
|
||||||
.constant('AngularScheduler.partials', urlPrefix + 'lib/angular-scheduler/lib/')
|
.constant('AngularScheduler.partials', urlPrefix + 'lib/angular-scheduler/lib/')
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ import RelatedSearch from "./helpers/related-search";
|
|||||||
import Search from "./helpers/search";
|
import Search from "./helpers/search";
|
||||||
import Teams from "./helpers/teams";
|
import Teams from "./helpers/teams";
|
||||||
import AdhocHelper from "./helpers/Adhoc";
|
import AdhocHelper from "./helpers/Adhoc";
|
||||||
|
import ApiModelHelper from "./helpers/ApiModel";
|
||||||
|
import ActivityStreamHelper from "./helpers/ActivityStream";
|
||||||
|
|
||||||
export
|
export
|
||||||
{ AboutAnsible,
|
{ AboutAnsible,
|
||||||
@@ -76,5 +78,7 @@ export
|
|||||||
RelatedSearch,
|
RelatedSearch,
|
||||||
Search,
|
Search,
|
||||||
Teams,
|
Teams,
|
||||||
AdhocHelper
|
AdhocHelper,
|
||||||
|
ApiModelHelper,
|
||||||
|
ActivityStreamHelper
|
||||||
};
|
};
|
||||||
|
|||||||
58
awx/ui/client/src/helpers/ActivityStream.js
Normal file
58
awx/ui/client/src/helpers/ActivityStream.js
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2016 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc function
|
||||||
|
* @name helpers.function:ActivityStream
|
||||||
|
* @description Helper functions for the activity stream
|
||||||
|
*/
|
||||||
|
|
||||||
|
export default
|
||||||
|
angular.module('ActivityStreamHelper', ['Utilities'])
|
||||||
|
.factory('GetTargetTitle', [
|
||||||
|
function () {
|
||||||
|
return function (target) {
|
||||||
|
|
||||||
|
var rtnTitle = 'DASHBOARD';
|
||||||
|
|
||||||
|
switch(target) {
|
||||||
|
case 'project':
|
||||||
|
rtnTitle = 'PROJECTS';
|
||||||
|
break;
|
||||||
|
case 'inventory':
|
||||||
|
rtnTitle = 'INVENTORIES';
|
||||||
|
break;
|
||||||
|
case 'job_template':
|
||||||
|
rtnTitle = 'JOB TEMPLATES';
|
||||||
|
break;
|
||||||
|
case 'credential':
|
||||||
|
rtnTitle = 'CREDENTIALS';
|
||||||
|
break;
|
||||||
|
case 'user':
|
||||||
|
rtnTitle = 'USERS';
|
||||||
|
break;
|
||||||
|
case 'team':
|
||||||
|
rtnTitle = 'TEAMS';
|
||||||
|
break;
|
||||||
|
case 'organization':
|
||||||
|
rtnTitle = 'ORGANIZATIONS';
|
||||||
|
break;
|
||||||
|
case 'management_job':
|
||||||
|
rtnTitle = 'MANAGEMENT JOBS';
|
||||||
|
break;
|
||||||
|
case 'inventory_script':
|
||||||
|
rtnTitle = 'INVENTORY SCRIPTS';
|
||||||
|
break;
|
||||||
|
case 'schedule':
|
||||||
|
rtnTitle = 'SCHEDULES';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rtnTitle;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
]);
|
||||||
100
awx/ui/client/src/helpers/ApiModel.js
Normal file
100
awx/ui/client/src/helpers/ApiModel.js
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Copyright (c) 2016 Ansible, Inc.
|
||||||
|
*
|
||||||
|
* All Rights Reserved
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngdoc function
|
||||||
|
* @name helpers.function:ApiModel
|
||||||
|
* @description Helper functions to convert singular/plural versions of our models to the opposite
|
||||||
|
*/
|
||||||
|
|
||||||
|
export default
|
||||||
|
angular.module('ApiModelHelper', ['Utilities'])
|
||||||
|
.factory('ModelToSingular', [
|
||||||
|
function () {
|
||||||
|
return function (model) {
|
||||||
|
// This function takes in the plural model string and spits out the singular
|
||||||
|
// version.
|
||||||
|
|
||||||
|
var singularModel;
|
||||||
|
|
||||||
|
switch(model) {
|
||||||
|
case 'projects':
|
||||||
|
singularModel = 'project';
|
||||||
|
break;
|
||||||
|
case 'inventories':
|
||||||
|
singularModel = 'inventory';
|
||||||
|
break;
|
||||||
|
case 'job_templates':
|
||||||
|
singularModel = 'job_template';
|
||||||
|
break;
|
||||||
|
case 'credentials':
|
||||||
|
singularModel = 'credential';
|
||||||
|
break;
|
||||||
|
case 'users':
|
||||||
|
singularModel = 'user';
|
||||||
|
break;
|
||||||
|
case 'teams':
|
||||||
|
singularModel = 'team';
|
||||||
|
break;
|
||||||
|
case 'organizations':
|
||||||
|
singularModel = 'organization';
|
||||||
|
break;
|
||||||
|
case 'management_jobs':
|
||||||
|
singularModel = 'management_job';
|
||||||
|
break;
|
||||||
|
case 'inventory_scripts':
|
||||||
|
singularModel = 'inventory_script';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return singularModel;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
])
|
||||||
|
.factory('ModelToPlural', [
|
||||||
|
function () {
|
||||||
|
return function (model) {
|
||||||
|
// This function takes in the singular model string and spits out the plural
|
||||||
|
// version.
|
||||||
|
|
||||||
|
var pluralModel;
|
||||||
|
|
||||||
|
switch(model) {
|
||||||
|
case 'project':
|
||||||
|
pluralModel = 'projects';
|
||||||
|
break;
|
||||||
|
case 'inventory':
|
||||||
|
pluralModel = 'inventories';
|
||||||
|
break;
|
||||||
|
case 'job_template':
|
||||||
|
pluralModel = 'job_templates';
|
||||||
|
break;
|
||||||
|
case 'credential':
|
||||||
|
pluralModel = 'credentials';
|
||||||
|
break;
|
||||||
|
case 'user':
|
||||||
|
pluralModel = 'users';
|
||||||
|
break;
|
||||||
|
case 'team':
|
||||||
|
pluralModel = 'teams';
|
||||||
|
break;
|
||||||
|
case 'organization':
|
||||||
|
pluralModel = 'organizations';
|
||||||
|
break;
|
||||||
|
case 'management_job':
|
||||||
|
pluralModel = 'management_jobs';
|
||||||
|
break;
|
||||||
|
case 'inventory_script':
|
||||||
|
pluralModel = 'inventory_scripts';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pluralModel;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
]);
|
||||||
@@ -12,7 +12,7 @@ export default
|
|||||||
name: 'activities',
|
name: 'activities',
|
||||||
iterator: 'activity',
|
iterator: 'activity',
|
||||||
editTitle: 'Activity Stream',
|
editTitle: 'Activity Stream',
|
||||||
listTitle: 'Activity Stream',
|
listTitle: 'Activity Stream<span ng-show="streamSubTitle"><div class="List-titleLockup"></div>{{streamSubTitle}}<span>',
|
||||||
listTitleBadge: false,
|
listTitleBadge: false,
|
||||||
selectInstructions: '',
|
selectInstructions: '',
|
||||||
index: false,
|
index: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user