restyle & modularize Portal Mode, resolves #940 & #939

freeze codebase before separating PortalJobs & PortalJobTemplates into separate views
This commit is contained in:
Leigh Johnson
2016-03-30 21:22:00 -04:00
parent b6706662a4
commit 7ed44ec167
12 changed files with 156 additions and 53 deletions

View File

@@ -24,7 +24,7 @@ import {Home, HomeGroups, HomeHosts} from './controllers/Home';
import {SocketsController} from './controllers/Sockets'; import {SocketsController} from './controllers/Sockets';
import {CredentialsAdd, CredentialsEdit, CredentialsList} from './controllers/Credentials'; import {CredentialsAdd, CredentialsEdit, CredentialsList} from './controllers/Credentials';
import {JobsListController} from './controllers/Jobs'; import {JobsListController} from './controllers/Jobs';
import {PortalController} from './controllers/Portal'; 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';
import inventoryScripts from './inventory-scripts/main'; import inventoryScripts from './inventory-scripts/main';
@@ -109,6 +109,7 @@ var tower = angular.module('Tower', [
standardOut.name, standardOut.name,
access.name, access.name,
JobTemplates.name, JobTemplates.name,
portalMode.name,
'templates', 'templates',
'Utilities', 'Utilities',
'OrganizationFormDefinition', 'OrganizationFormDefinition',
@@ -291,20 +292,6 @@ var tower = angular.module('Tower', [
} }
}). }).
state('portal', {
url: '/portal',
templateUrl: urlPrefix + 'partials/portal.html',
controller: PortalController,
ncyBreadcrumb: {
label: "PORTAL"
},
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}).
state('projects', { state('projects', {
url: '/projects', url: '/projects',
templateUrl: urlPrefix + 'partials/projects.html', templateUrl: urlPrefix + 'partials/projects.html',
@@ -828,7 +815,7 @@ var tower = angular.module('Tower', [
$rootScope.$emit('JobStatusChange-jobDetails', data); $rootScope.$emit('JobStatusChange-jobDetails', data);
} else if ($state.is('dashboard')) { } else if ($state.is('dashboard')) {
$rootScope.$emit('JobStatusChange-home', data); $rootScope.$emit('JobStatusChange-home', data);
} else if ($state.is('portal')) { } else if ($state.is('portalMode')) {
$rootScope.$emit('JobStatusChange-portal', data); $rootScope.$emit('JobStatusChange-portal', data);
} else if ($state.is('projects')) { } else if ($state.is('projects')) {
$rootScope.$emit('JobStatusChange-projects', data); $rootScope.$emit('JobStatusChange-projects', data);

View File

@@ -381,8 +381,7 @@ export default
mode: 'edit', mode: 'edit',
id: id, id: id,
scope: scope, scope: scope,
showSearch: false, showSearch: false
title: false
}); });
SearchInit({ SearchInit({

View File

@@ -13,6 +13,7 @@ export default
iterator: 'job_template', iterator: 'job_template',
// selectTitle: 'Add Job Template', // selectTitle: 'Add Job Template',
editTitle: 'Job Templates', editTitle: 'Job Templates',
listTitle: 'Job Templates',
// selectInstructions: "Click on a row to select it, and click Finished when done. Use the <i class=\"icon-plus\"></i> " + // selectInstructions: "Click on a row to select it, and click Finished when done. Use the <i class=\"icon-plus\"></i> " +
// "button to create a new job template.", // "button to create a new job template.",
index: false, index: false,
@@ -22,9 +23,9 @@ export default
fields: { fields: {
name: { name: {
key: true, key: true,
noLink: true,
label: 'Name', label: 'Name',
columnClass: 'col-lg-5 col-md-5 col-sm-9 col-xs-8' columnClass: 'col-lg-5 col-md-5 col-sm-9 col-xs-8',
linkTo: '/#/job_templates/{{job_template.id}}'
}, },
description: { description: {
label: 'Description', label: 'Description',

View File

@@ -16,6 +16,7 @@ export default
index: false, index: false,
hover: true, hover: true,
well: true, well: true,
listTitle: 'Jobs',
fields: { fields: {
status: { status: {
@@ -34,39 +35,31 @@ export default
{ name: "Canceled", value: "canceled" } { name: "Canceled", value: "canceled" }
] ]
}, },
/*
id: { id: {
label: 'ID', label: 'ID',
key: true, key: true,
noLink: true, //undocumented: 'key' above will automatically made the fields a link, but 'noLink' will override this setting noLink: true, //undocumented: 'key' above will automatically made the fields a link, but 'noLink' will override this setting
desc: true, desc: true,
searchType: 'int', searchType: 'int',
columnClass: 'col-lg-1 col-md-1 col-sm-2 col-xs-2 List-staticColumnAdjacent', columnClass: 'col-xs-2 List-staticColumnAdjacent',
}, },
*/
name: { name: {
label: 'Name', label: 'Name',
columnClass: 'col-lg-4 col-md-4 col-sm-4 col-xs-6', columnClass: 'col-lg-4 col-md-4 col-sm-4 col-xs-6',
defaultSearchField: true defaultSearchField: true,
linkTo: '/#/jobs/{{portal_job.id}}'
}, },
started: { started: {
label: 'Started', label: 'Started',
noLink: true, noLink: true,
searchable: false, searchable: false,
filter: "longDate", filter: "longDate",
columnClass: "col-lg-4 col-md-4 col-sm-3 xs-hidden" nosort: true,
columnClass: "col-lg-4 col-md-4 col-sm-3 hidden-xs"
} }
}, },
actions: { }, actions: { }
fieldActions: {
columnClass: 'col-lg-3 col-md-4 col-sm-3 col-xs-4',
job_details: {
mode: 'all',
ngClick: "viewJobDetails(portal_job)",
awToolTip: 'View job details',
dataPlacement: 'top'
}
}
}); });

View File

@@ -58,6 +58,14 @@
SETTINGS SETTINGS
</span> </span>
</a> </a>
<a class="MainMenu-item"
id="main_menu_setup_mobile_link"
ui-sref="portalMode"
ng-class="{'is-currentRoute' : isCurrentRoute('portalMode')}">
<span class="MainMenu-itemText">
PORTAL MODE
</span>
</a>
<a class="MainMenu-item" <a class="MainMenu-item"
id="main_menu_docs_mobile_link" id="main_menu_docs_mobile_link"
ng-href="http://docs.ansible.com/ansible-tower/" ng-href="http://docs.ansible.com/ansible-tower/"
@@ -127,7 +135,7 @@
</a> </a>
<a class="MainMenu-item MainMenu-item--notMobile MainMenu-item--right" <a class="MainMenu-item MainMenu-item--notMobile MainMenu-item--right"
id="main_menu_setup_link" id="main_menu_setup_link"
ng-href="/#/setup" ui-href="/#/setup"
ng-class="{'is-currentRoute' : isCurrentRoute('setup'), 'is-loggedOut' : !$root.current_user.username}" ng-class="{'is-currentRoute' : isCurrentRoute('setup'), 'is-loggedOut' : !$root.current_user.username}"
aw-tool-tip="Settings" aw-tool-tip="Settings"
data-placement="bottom" data-placement="bottom"
@@ -137,6 +145,18 @@
alt="Settings"> alt="Settings">
</i> </i>
</a> </a>
<a class="MainMenu-item MainMenu-item--notMobile MainMenu-item--right"
id="main_menu_portal_link"
ng-href="/#/portal"
ng-class="{'is-currentRoute' : isCurrentRoute('portalMode'), 'is-loggedOut' : !$root.current_user.username}"
aw-tool-tip="Portal Mode"
data-placement="bottom"
data-trigger="hover"
data-container="body">
<i class="MainMenu-itemImage MainMenu-itemImage--settings fa fa-columns"
alt="Portal Mode">
</i>
</a>
<a class="MainMenu-item MainMenu-item--notMobile MainMenu-item--right" <a class="MainMenu-item MainMenu-item--notMobile MainMenu-item--right"
id="main_menu_docs_link" id="main_menu_docs_link"
ng-href="http://docs.ansible.com/ansible-tower/" ng-href="http://docs.ansible.com/ansible-tower/"

View File

@@ -0,0 +1,15 @@
/*************************************************
* Copyright (c) 2016 Ansible, Inc.
*
* All Rights Reserved
*************************************************/
import route from './portal-mode.route';
import {PortalModeController} from './portal-mode.controller';
export default
angular.module('portalMode', [])
.controller('PortalModeController', PortalModeController)
.run(['$stateExtender', function($stateExtender){
$stateExtender.addState(route);
}]);

View File

@@ -0,0 +1,19 @@
@import "awx/ui/client/src/shared/layouts/one-plus-one.less";
.PortalMode-container{
.OnePlusOne-container;
}
.PortalMode-panel--left{
.OnePlusOne-panel--left;
}
.PortalMode-panel--right{
.OnePlusOne-panel--right;
}
.PortalMode-panelHeader{
.OnePlusOne-panelHeader;
}
@media(max-width: 767px){
table {word-wrap: normal !important};
}

View File

@@ -19,12 +19,13 @@
* *
* *
*/ */
export function PortalController($scope, $compile, $stateParams, $rootScope, $location, $log, Wait, ClearScope, Rest, GetBasePath, ProcessErrors, export function PortalModeController($scope, $compile, $stateParams, $rootScope, $location, $log, Wait, ClearScope, Rest, GetBasePath, ProcessErrors,
PortalJobsWidget, GenerateList, PortalJobTemplateList, SearchInit, PaginateInit, PlaybookRun){ PortalJobsWidget, GenerateList, PortalJobTemplateList, SearchInit, PaginateInit, PlaybookRun){
ClearScope('portal'); ClearScope('portal');
var jobs_scope, var jobs_scope,
pageSize = 12,
list = PortalJobTemplateList, list = PortalJobTemplateList,
view= GenerateList, view= GenerateList,
defaultUrl = GetBasePath('job_templates'), defaultUrl = GetBasePath('job_templates'),
@@ -43,6 +44,7 @@ export function PortalController($scope, $compile, $stateParams, $rootScope, $lo
}); });
$scope.job_templatePageSize = $scope.getMaxRows(); $scope.job_templatePageSize = $scope.getMaxRows();
console.log($scope.job_templatePageSize);
SearchInit({ SearchInit({
scope: $scope, scope: $scope,
@@ -54,7 +56,7 @@ export function PortalController($scope, $compile, $stateParams, $rootScope, $lo
scope: $scope, scope: $scope,
list: list, list: list,
url: defaultUrl, url: defaultUrl,
pageSize: $scope.job_templatePageSize pageSize: pageSize
}); });
$scope.search(list.iterator); $scope.search(list.iterator);
@@ -137,6 +139,6 @@ export function PortalController($scope, $compile, $stateParams, $rootScope, $lo
} }
PortalController.$inject = ['$scope', '$compile', '$stateParams', '$rootScope', '$location', '$log','Wait', 'ClearScope', 'Rest', 'GetBasePath', 'ProcessErrors', PortalModeController.$inject = ['$scope', '$compile', '$stateParams', '$rootScope', '$location', '$log','Wait', 'ClearScope', 'Rest', 'GetBasePath', 'ProcessErrors',
'PortalJobsWidget', 'generateList' , 'PortalJobTemplateList', 'SearchInit', 'PaginateInit', 'PlaybookRun' 'PortalJobsWidget', 'generateList' , 'PortalJobTemplateList', 'SearchInit', 'PaginateInit', 'PlaybookRun'
]; ];

View File

@@ -1,4 +1,4 @@
<div class="tab-pane" > <div class="tab-pane PortalMode" >
<div ng-cloak id="portal-landing"> <div ng-cloak id="portal-landing">
<div id="refresh-row" class="row"> <div id="refresh-row" class="row">
<div class="col-lg-12"> <div class="col-lg-12">
@@ -14,17 +14,15 @@
</div> </div>
</div> </div>
</div> </div>
<div class="row"> <div class="PortalMode-container">
<div class="left-side col-sm-6 col-xs-12"> <div class="PortalMode-panel--left">
<div id="portal-container-job-templates" class="portal-container"> <div id="portal-container-job-templates" class="Panel">
<span class="portal-header">Job Templates</span>
<div id="portal-job-templates" > <div id="portal-job-templates" >
</div> </div>
</div> </div>
</div> </div>
<div class="right-side col-sm-6 col-xs-12"> <div class="PortalMode-panel--right">
<div id="portal-container-jobs" class="portal-container"> <div id="portal-container-jobs" class="Panel">
<span class="portal-header">Jobs</span>
<div id="portal-jobs" > <div id="portal-jobs" >
</div> </div>
</div> </div>

View File

@@ -0,0 +1,16 @@
import {templateUrl} from '../shared/template-url/template-url.factory';
export default {
name: 'portalMode',
url: '/portal',
templateUrl: templateUrl('portal-mode/portal-mode'),
controller: 'PortalModeController',
ncyBreadcrumb: {
label: "PORTAL MODE"
},
resolve: {
features: ['FeaturesService', function(FeaturesService) {
return FeaturesService.get();
}]
}
}

View File

@@ -0,0 +1,53 @@
/*
* Large resolution 1/2 + 1/2 width panels
* Small resolution: 100% width panels, stacked
* Options: static height, custom breakpoint
*/
@import "awx/ui/client/src/shared/branding/colors.default.less";
.OnePlusOne-container(@height: 100%; @breakpoint: 900px){
height: @height;
display: flex;
flex-diration: row;
@media screen and(max-width: @breakpoint){
flex-direction: column;
}
}
.OnePlusOne-panel--left(@height: 100%; @breakpoint: 900px){
flex: 1 1;
height: @height;
width: 100%;
margin-right: 20px;
.Panel{
height: 100%;
}
@media screen and (max-width @breakpoint){
margin-right: 0px;
height: inherit;
}
}
.OnePlusOne-panel--right(@height: 100%; @breakpoint: 900px){
flex: 1 1;
height: @height;
width: 100%;
margin-right: 0px;
.Panel{
height: 100%;
}
@media screen and (max-width @breakpoint){
height: inherit;
}
}
.OnePlusOne-panelHeader{
color: @default-interface-txt;
font-size: 14px;
font-weight: bold;
margin-right: 10px;
text-transform: uppercase;
display: flex;
}

View File

@@ -24,6 +24,7 @@ angular.module('PortalJobsWidget', ['RestServices', 'Utilities'])
choicesCount = 0, choicesCount = 0,
listCount = 0, listCount = 0,
jobs_scope = scope.$new(true), jobs_scope = scope.$new(true),
pageSize = 12,
max_rows, max_rows,
user, user,
html, e, html, e,
@@ -56,7 +57,7 @@ angular.module('PortalJobsWidget', ['RestServices', 'Utilities'])
list: PortalJobsList, list: PortalJobsList,
id: 'active-jobs', id: 'active-jobs',
url: url , //GetBasePath('jobs')+'?created_by='+user, url: url , //GetBasePath('jobs')+'?created_by='+user,
pageSize: max_rows, pageSize: pageSize,
spinner: true spinner: true
}); });
@@ -71,7 +72,7 @@ angular.module('PortalJobsWidget', ['RestServices', 'Utilities'])
scope.removeChoicesReady = scope.$on('choicesReady', function() { scope.removeChoicesReady = scope.$on('choicesReady', function() {
choicesCount++; choicesCount++;
if (choicesCount === 2) { if (choicesCount === 2) {
setPortalJobsHeight(); //setPortalJobsHeight();
scope.$emit('buildJobsList'); scope.$emit('buildJobsList');
} }
}); });
@@ -136,6 +137,7 @@ angular.module('PortalJobsWidget', ['RestServices', 'Utilities'])
// Set the height of each container and calc max number of rows containers can hold // Set the height of each container and calc max number of rows containers can hold
/*
function setPortalJobsHeight() { function setPortalJobsHeight() {
var docw = $(window).width(), var docw = $(window).width(),
box_height, available_height, search_row, page_row, height, header, row_height; box_height, available_height, search_row, page_row, height, header, row_height;
@@ -191,9 +193,7 @@ angular.module('PortalJobsWidget', ['RestServices', 'Utilities'])
scope[PortalJobTemplateList.iterator + 'PageSize'] = max_rows; scope[PortalJobTemplateList.iterator + 'PageSize'] = max_rows;
scope.changePageSize(PortalJobTemplateList.name, PortalJobTemplateList.iterator, false); scope.changePageSize(PortalJobTemplateList.name, PortalJobTemplateList.iterator, false);
} }
*/
}; };
} }
]); ]);