mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 01:47:35 -02:30
adding controller for portal mode.
handles the refresh of the page and loading of the job widgets
This commit is contained in:
@@ -1,191 +1,140 @@
|
|||||||
// /************************************
|
/************************************
|
||||||
// * Copyright (c) 2014 AnsibleWorks, Inc.
|
* Copyright (c) 2014 AnsibleWorks, Inc.
|
||||||
// *
|
*
|
||||||
// *
|
*
|
||||||
// * Portal.js
|
* Portal.js
|
||||||
// *
|
*
|
||||||
// * Controller functions for portal mode
|
* Controller functions for portal mode
|
||||||
// *
|
*
|
||||||
// */
|
*/
|
||||||
|
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * @ngdoc function
|
* @ngdoc function
|
||||||
// * @name controllers.function:Portal
|
* @name controllers.function:Portal
|
||||||
// * @description This controller's for portal mode
|
* @description This controller's for portal mode
|
||||||
// */
|
*/
|
||||||
// 'use strict';
|
'use strict';
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * @ngdoc method
|
* @ngdoc method
|
||||||
// * @name controllers.function:Portal#Portal
|
* @name controllers.function:Portal#Portal
|
||||||
// * @methodOf controllers.function:Portal
|
* @methodOf controllers.function:Portal
|
||||||
// * @description portal mode woohoo
|
* @description portal mode woohoo
|
||||||
// *
|
*
|
||||||
// *
|
*
|
||||||
// */
|
*/
|
||||||
// function Portal($scope, $compile, $routeParams, $rootScope, $location, $log, Wait,
|
function PortalController($scope, $compile, $routeParams, $rootScope, $location, $log, Wait, ClearScope, Stream, Rest, GetBasePath, ProcessErrors,
|
||||||
// ClearScope, Stream, Rest, GetBasePath, ProcessErrors, Button){
|
Button, PortalJobTemplate, GenerateList, JobTemplateList, SearchInit, PaginateInit, PlaybookRun){
|
||||||
|
|
||||||
// ClearScope('portal');
|
ClearScope('portal');
|
||||||
|
|
||||||
// // var buttons, html, e, waitCount, loadedCount,borderStyles, jobs_scope, schedule_scope;
|
var html,
|
||||||
|
e,
|
||||||
|
winHeight,
|
||||||
|
available_height,
|
||||||
|
list = JobTemplateList,
|
||||||
|
view= GenerateList,
|
||||||
|
defaultUrl = GetBasePath('job_templates'),
|
||||||
|
buttons = {
|
||||||
|
refresh: {
|
||||||
|
mode: 'all',
|
||||||
|
awToolTip: "Refresh the page",
|
||||||
|
ngClick: "refresh()",
|
||||||
|
ngShow:"socketStatus == 'error'"
|
||||||
|
}
|
||||||
|
// ,
|
||||||
|
// stream: {
|
||||||
|
// ngClick: "showActivity()",
|
||||||
|
// awToolTip: "View Activity Stream",
|
||||||
|
// mode: 'all'
|
||||||
|
// }
|
||||||
|
};
|
||||||
|
|
||||||
// // // Add buttons to the top of the Home page. We're using lib/ansible/generator_helpers.js-> Buttons()
|
html = Button({
|
||||||
// // // to build buttons dynamically and insure all styling and icons match the rest of the application.
|
btn: buttons.refresh,
|
||||||
// // buttons = {
|
action: 'refresh',
|
||||||
// // refresh: {
|
toolbar: true
|
||||||
// // mode: 'all',
|
});
|
||||||
// // awToolTip: "Refresh the page",
|
|
||||||
// // ngClick: "refresh()",
|
|
||||||
// // ngShow:"socketStatus == 'error'"
|
|
||||||
// // },
|
|
||||||
// // stream: {
|
|
||||||
// // ngClick: "showActivity()",
|
|
||||||
// // awToolTip: "View Activity Stream",
|
|
||||||
// // mode: 'all'
|
|
||||||
// // }
|
|
||||||
// // };
|
|
||||||
|
|
||||||
// // html = Button({
|
// html += Button({
|
||||||
// // btn: buttons.refresh,
|
// btn: buttons.stream,
|
||||||
// // action: 'refresh',
|
// action: 'stream',
|
||||||
// // toolbar: true
|
// toolbar: true
|
||||||
// // });
|
// });
|
||||||
|
|
||||||
// // html += Button({
|
e = angular.element(document.getElementById('portal-list-actions'));
|
||||||
// // btn: buttons.stream,
|
e.html(html);
|
||||||
// // action: 'stream',
|
$compile(e)($scope);
|
||||||
// // toolbar: true
|
|
||||||
// // });
|
|
||||||
|
|
||||||
// // e = angular.element(document.getElementById('home-list-actions'));
|
if ($scope.removeLoadPortal) {
|
||||||
// // e.html(html);
|
$scope.removeLoadPortal();
|
||||||
// // $compile(e)($scope);
|
}
|
||||||
|
$scope.removeLoadPortal = $scope.$on('LoadPortal', function () {
|
||||||
|
winHeight = $(window).height();
|
||||||
|
available_height = Math.floor(winHeight - $('#main-menu-container .navbar').outerHeight() - $('#refresh-row').outerHeight() - 45);
|
||||||
|
$('.portal-container').height(available_height);
|
||||||
|
|
||||||
// // waitCount = 4;
|
view.inject( list, {
|
||||||
// // loadedCount = 0;
|
id : 'portal-job-template',
|
||||||
|
mode: 'edit',
|
||||||
|
scope: $scope,
|
||||||
|
breadCrumbs: false,
|
||||||
|
searchSize: 'col-lg-6 col-md-6'
|
||||||
|
});
|
||||||
|
|
||||||
// // if (!$routeParams.login) {
|
$rootScope.flashMessage = null;
|
||||||
// // // If we're not logging in, start the Wait widget. Otherwise, it's already running.
|
|
||||||
// // //Wait('start');
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// // if ($scope.removeWidgetLoaded) {
|
SearchInit({
|
||||||
// // $scope.removeWidgetLoaded();
|
scope: $scope,
|
||||||
// // }
|
set: 'job_templates',
|
||||||
// // $scope.removeWidgetLoaded = $scope.$on('WidgetLoaded', function (e, label, jobscope, schedulescope) {
|
list: list,
|
||||||
// // // Once all the widgets report back 'loaded', turn off Wait widget
|
url: defaultUrl
|
||||||
// // if(label==="dashboard_jobs"){
|
});
|
||||||
// // jobs_scope = jobscope;
|
PaginateInit({
|
||||||
// // schedule_scope = schedulescope;
|
scope: $scope,
|
||||||
// // }
|
list: list,
|
||||||
// // loadedCount++;
|
url: defaultUrl
|
||||||
// // if (loadedCount === waitCount) {
|
});
|
||||||
// // $(window).resize(_.debounce(function() {
|
|
||||||
// // $scope.$emit('ResizeJobGraph');
|
|
||||||
// // $scope.$emit('ResizeHostGraph');
|
|
||||||
// // $scope.$emit('ResizeHostPieGraph');
|
|
||||||
// // Wait('stop');
|
|
||||||
// // }, 500));
|
|
||||||
// // $(window).resize();
|
|
||||||
// // }
|
|
||||||
// // });
|
|
||||||
|
|
||||||
// // if ($scope.removeDashboardReady) {
|
// Called from Inventories tab, host failed events link:
|
||||||
// // $scope.removeDashboardReady();
|
if ($routeParams.name) {
|
||||||
// // }
|
$scope[list.iterator + 'SearchField'] = 'name';
|
||||||
// // $scope.removeDashboardReady = $scope.$on('dashboardReady', function (e, data) {
|
$scope[list.iterator + 'SearchValue'] = $routeParams.name;
|
||||||
// // nv.dev=false;
|
$scope[list.iterator + 'SearchFieldLabel'] = list.fields.name.label;
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.search(list.iterator);
|
||||||
|
|
||||||
// // borderStyles = {"border": "1px solid #A9A9A9",
|
PortalJobTemplate({
|
||||||
// // "border-radius": "4px",
|
scope: $scope,
|
||||||
// // "padding": "5px",
|
target: 'portal-jobs',
|
||||||
// // "margin-bottom": "15px"};
|
// dashboard: data
|
||||||
// // $('.graph-container').css(borderStyles);
|
});
|
||||||
|
|
||||||
// // var winHeight = $(window).height(),
|
});
|
||||||
// // available_height = winHeight - $('#main-menu-container .navbar').outerHeight() - $('#count-container').outerHeight() - 120;
|
$scope.submitJob = function (id) {
|
||||||
// // $('.graph-container').height(available_height/2);
|
PlaybookRun({ scope: $scope, id: id });
|
||||||
// // // // chart.update();
|
};
|
||||||
|
|
||||||
// // DashboardCounts({
|
$scope.refresh = function () {
|
||||||
// // scope: $scope,
|
$scope.$emit('LoadPortal');
|
||||||
// // target: 'dash-counts',
|
// Wait('start');
|
||||||
// // dashboard: data
|
// loadedCount = 0;
|
||||||
// // });
|
// Rest.setUrl(GetBasePath('dashboard'));
|
||||||
|
// Rest.get()
|
||||||
|
// .success(function (data) {
|
||||||
|
// $scope.$emit('dashboardReady', data);
|
||||||
|
// })
|
||||||
|
// .error(function (data, status) {
|
||||||
|
// ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard: ' + status });
|
||||||
|
// });
|
||||||
|
};
|
||||||
|
|
||||||
// // JobStatusGraph({
|
$scope.refresh();
|
||||||
// // scope: $scope,
|
|
||||||
// // target: 'dash-job-status-graph',
|
|
||||||
// // dashboard: data
|
|
||||||
// // });
|
|
||||||
|
|
||||||
// // if ($rootScope.user_is_superuser === true) {
|
}
|
||||||
// // waitCount = 5;
|
|
||||||
// // HostGraph({
|
|
||||||
// // scope: $scope,
|
|
||||||
// // target: 'dash-host-count-graph',
|
|
||||||
// // dashboard: data
|
|
||||||
// // });
|
|
||||||
// // }
|
|
||||||
// // else{
|
|
||||||
// // $('#dash-host-count-graph').remove(); //replaceWith("<div id='dash-host-count-graph' class='left-side col-sm-12 col-xs-12'></div>");
|
|
||||||
// // }
|
|
||||||
// // DashboardJobs({
|
|
||||||
// // scope: $scope,
|
|
||||||
// // target: 'dash-jobs-list',
|
|
||||||
// // dashboard: data
|
|
||||||
// // });
|
|
||||||
// // HostPieChart({
|
|
||||||
// // scope: $scope,
|
|
||||||
// // target: 'dash-host-status-graph',
|
|
||||||
// // dashboard: data
|
|
||||||
// // });
|
|
||||||
|
|
||||||
// // });
|
PortalController.$inject = ['$scope', '$compile', '$routeParams', '$rootScope', '$location', '$log','Wait', 'ClearScope', 'Stream', 'Rest', 'GetBasePath', 'ProcessErrors',
|
||||||
|
'Button', 'PortalJobTemplate', 'GenerateList' , 'JobTemplateList', 'SearchInit', 'PaginateInit', 'PlaybookRun'
|
||||||
// // if ($rootScope.removeJobStatusChange) {
|
];
|
||||||
// // $rootScope.removeJobStatusChange();
|
|
||||||
// // }
|
|
||||||
// // $rootScope.removeJobStatusChange = $rootScope.$on('JobStatusChange', function() {
|
|
||||||
// // jobs_scope.refreshJobs();
|
|
||||||
// // $scope.$emit('ReloadJobStatusGraph');
|
|
||||||
|
|
||||||
// // });
|
|
||||||
|
|
||||||
// // if ($rootScope.removeScheduleChange) {
|
|
||||||
// // $rootScope.removeScheduleChange();
|
|
||||||
// // }
|
|
||||||
// // $rootScope.removeScheduleChange = $rootScope.$on('ScheduleChange', function() {
|
|
||||||
// // schedule_scope.refreshSchedules();
|
|
||||||
// // $scope.$emit('ReloadJobStatusGraph');
|
|
||||||
// // });
|
|
||||||
|
|
||||||
// // $scope.showActivity = function () {
|
|
||||||
// // Stream({
|
|
||||||
// // scope: $scope
|
|
||||||
// // });
|
|
||||||
// // };
|
|
||||||
|
|
||||||
// // $scope.refresh = function () {
|
|
||||||
// // Wait('start');
|
|
||||||
// // loadedCount = 0;
|
|
||||||
// // Rest.setUrl(GetBasePath('dashboard'));
|
|
||||||
// // Rest.get()
|
|
||||||
// // .success(function (data) {
|
|
||||||
// // $scope.$emit('dashboardReady', data);
|
|
||||||
// // })
|
|
||||||
// // .error(function (data, status) {
|
|
||||||
// // ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard: ' + status });
|
|
||||||
// // });
|
|
||||||
// // };
|
|
||||||
|
|
||||||
// // $scope.refresh();
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Home.$inject = ['$scope', '$compile', '$routeParams', '$rootScope', '$location', '$log','Wait',
|
|
||||||
// 'ClearScope', 'Stream', 'Rest', 'GetBasePath', 'ProcessErrors', 'Button'
|
|
||||||
// ];
|
|
||||||
|
|||||||
Reference in New Issue
Block a user