mirror of
https://github.com/ansible/awx.git
synced 2026-03-27 22:05:07 -02:30
Display error messages when no scan jobs are found
This commit is contained in:
@@ -7,38 +7,8 @@
|
|||||||
export default
|
export default
|
||||||
function flatCompare(facts, nameKey, compareKeys) {
|
function flatCompare(facts, nameKey, compareKeys) {
|
||||||
|
|
||||||
// Make sure we always start comparison against
|
var comparatorFacts = facts[0];
|
||||||
// a non-empty array
|
var basisFacts = facts[1];
|
||||||
//
|
|
||||||
// Partition with _.isEmpty will give me an array
|
|
||||||
// with empty arrays in index 0, and non-empty
|
|
||||||
// arrays in index 1
|
|
||||||
//
|
|
||||||
|
|
||||||
// Save the position of the data so we
|
|
||||||
// don't lose it later
|
|
||||||
|
|
||||||
facts[0].position = 'left';
|
|
||||||
facts[1].position = 'right';
|
|
||||||
|
|
||||||
var splitFacts = _.partition(facts, _.isEmpty);
|
|
||||||
var emptyScans = splitFacts[0];
|
|
||||||
var nonEmptyScans = splitFacts[1];
|
|
||||||
var basisFacts, comparatorFacts;
|
|
||||||
|
|
||||||
if (_.isEmpty(nonEmptyScans)) {
|
|
||||||
// we have NO data, so don't bother!
|
|
||||||
return [];
|
|
||||||
} else if (_.isEmpty(emptyScans)) {
|
|
||||||
// both scans have facts, rejoice!
|
|
||||||
comparatorFacts = nonEmptyScans[0];
|
|
||||||
basisFacts = nonEmptyScans[1];
|
|
||||||
} else {
|
|
||||||
// only one scan has facts, so we use that
|
|
||||||
// as the basis for our comparison
|
|
||||||
basisFacts = nonEmptyScans[0];
|
|
||||||
comparatorFacts = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
return basisFacts.reduce(function(arr, basisFact) {
|
return basisFacts.reduce(function(arr, basisFact) {
|
||||||
var searcher = {};
|
var searcher = {};
|
||||||
|
|||||||
@@ -51,12 +51,15 @@ function controller($rootScope,
|
|||||||
}
|
}
|
||||||
|
|
||||||
function reloadData(params, initialData) {
|
function reloadData(params, initialData) {
|
||||||
|
|
||||||
searchConfig = _.merge({}, searchConfig, params);
|
searchConfig = _.merge({}, searchConfig, params);
|
||||||
|
|
||||||
var factData = initialData;
|
var factData = initialData;
|
||||||
var leftRange = searchConfig.leftRange;
|
var leftRange = searchConfig.leftRange;
|
||||||
var rightRange = searchConfig.rightRange;
|
var rightRange = searchConfig.rightRange;
|
||||||
var activeModule = searchConfig.module;
|
var activeModule = searchConfig.module;
|
||||||
|
var leftScanDate, rightScanDate;
|
||||||
|
|
||||||
|
|
||||||
if (!factData) {
|
if (!factData) {
|
||||||
factData =
|
factData =
|
||||||
@@ -69,8 +72,8 @@ function controller($rootScope,
|
|||||||
var responses = factDataAndModules[1];
|
var responses = factDataAndModules[1];
|
||||||
var data = _.pluck(responses, 'fact');
|
var data = _.pluck(responses, 'fact');
|
||||||
|
|
||||||
$scope.leftScanDate = moment(responses[0].timestamp);
|
leftScanDate = moment(responses[0].timestamp);
|
||||||
$scope.rightScanDate = moment(responses[1].timestamp);
|
rightScanDate = moment(responses[1].timestamp);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}, true);
|
}, true);
|
||||||
@@ -78,18 +81,62 @@ function controller($rootScope,
|
|||||||
|
|
||||||
waitIndicator('start');
|
waitIndicator('start');
|
||||||
|
|
||||||
_(factData)
|
return _(factData)
|
||||||
.thenAll(_.partial(compareFacts, activeModule))
|
.thenAll(function(facts) {
|
||||||
|
// Make sure we always start comparison against
|
||||||
|
// a non-empty array
|
||||||
|
//
|
||||||
|
// Partition with _.isEmpty will give me an array
|
||||||
|
// with empty arrays in index 0, and non-empty
|
||||||
|
// arrays in index 1
|
||||||
|
//
|
||||||
|
|
||||||
|
// Save the position of the data so we
|
||||||
|
// don't lose it later
|
||||||
|
|
||||||
|
facts[0].position = 'left';
|
||||||
|
facts[1].position = 'right';
|
||||||
|
|
||||||
|
var splitFacts = _.partition(facts, _.isEmpty);
|
||||||
|
var emptyScans = splitFacts[0];
|
||||||
|
var nonEmptyScans = splitFacts[1];
|
||||||
|
|
||||||
|
if (_.isEmpty(nonEmptyScans)) {
|
||||||
|
// we have NO data, throw an error
|
||||||
|
throw {
|
||||||
|
name: 'NoScanData',
|
||||||
|
message: 'No scans ran on eithr of the dates you selected. Please try selecting different dates.',
|
||||||
|
dateValues:
|
||||||
|
{ leftDate: $scope.leftDate.clone(),
|
||||||
|
rightDate: $scope.rightDate.clone()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else if (nonEmptyScans.length === 1) {
|
||||||
|
// one of them is not empty, throw an error
|
||||||
|
throw {
|
||||||
|
name: 'InsufficientScanData',
|
||||||
|
message: 'No scans ran on one of the selected dates. Please try selecting a different date.',
|
||||||
|
dateValue: emptyScans[0].position === 'left' ? $scope.leftDate.clone() : $scope.rightDate.clone()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// all scans have data, rejoice!
|
||||||
|
return facts;
|
||||||
|
|
||||||
|
})
|
||||||
|
.then(_.partial(compareFacts, activeModule))
|
||||||
.then(function(info) {
|
.then(function(info) {
|
||||||
|
|
||||||
|
// Clear out any errors from the previous run...
|
||||||
|
$scope.error = null;
|
||||||
|
|
||||||
$scope.factData = info;
|
$scope.factData = info;
|
||||||
|
|
||||||
setHeaderValues(viewType);
|
setHeaderValues(viewType, leftScanDate, rightScanDate);
|
||||||
|
|
||||||
}).finally(function() {
|
}).finally(function() {
|
||||||
waitIndicator('stop');
|
waitIndicator('stop');
|
||||||
})
|
});
|
||||||
.value();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.setActiveModule = function(newModuleName, initialData) {
|
$scope.setActiveModule = function(newModuleName, initialData) {
|
||||||
@@ -107,9 +154,12 @@ function controller($rootScope,
|
|||||||
$location.replace();
|
$location.replace();
|
||||||
$location.search('module', newModuleName);
|
$location.search('module', newModuleName);
|
||||||
|
|
||||||
reloadData(
|
reloadData({ module: newModule
|
||||||
{ module: newModule
|
}, initialData)
|
||||||
}, initialData);
|
|
||||||
|
.catch(function(error) {
|
||||||
|
$scope.error = error;
|
||||||
|
}).value();
|
||||||
};
|
};
|
||||||
|
|
||||||
function dateWatcher(dateProperty) {
|
function dateWatcher(dateProperty) {
|
||||||
@@ -128,7 +178,10 @@ function controller($rootScope,
|
|||||||
var params = {};
|
var params = {};
|
||||||
params[dateProperty] = newDate;
|
params[dateProperty] = newDate;
|
||||||
|
|
||||||
reloadData(params);
|
reloadData(params)
|
||||||
|
.catch(function(error) {
|
||||||
|
$scope.error = error;
|
||||||
|
}).value();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,84 +1,92 @@
|
|||||||
<breadcrumbs>
|
<section class="SystemTrackingContainer">
|
||||||
<breadcrumb path="/inventories" title="Inventories"></breadcrumb>
|
<breadcrumbs>
|
||||||
<breadcrumb path="/inventories/{{inventory.id}}/manage" title="{{inventory.name}}"></breadcrumb>
|
<breadcrumb path="/inventories" title="Inventories"></breadcrumb>
|
||||||
<breadcrumb path="/inventories/{{inventory.id}}/system-tracking/{{hostIds}}" title="System Tracking" current="true"></breadcrumb>
|
<breadcrumb path="/inventories/{{inventory.id}}/manage" title="{{inventory.name}}"></breadcrumb>
|
||||||
</breadcrumbs>
|
<breadcrumb path="/inventories/{{inventory.id}}/system-tracking/{{hostIds}}" title="System Tracking" current="true"></breadcrumb>
|
||||||
|
</breadcrumbs>
|
||||||
|
|
||||||
<div class="FactModulePickers">
|
<div class="FactModulePickers">
|
||||||
<div class="FactModulePickers-dateContainer FactModulePickers-dateContainer--left">
|
<div class="FactModulePickers-dateContainer FactModulePickers-dateContainer--left">
|
||||||
<span class="FactModulePickers-label">{{ factModulePickersLabelLeft }}</span>
|
<span class="FactModulePickers-label">{{ factModulePickersLabelLeft }}</span>
|
||||||
<date-picker date="leftDate"></date-picker>
|
<date-picker date="leftDate"></date-picker>
|
||||||
</div>
|
|
||||||
<div class="FactModulePickers-dateContainer FactModulePickers-dateContainer--right">
|
|
||||||
<span class="FactModulePickers-label">{{ factModulePickersLabelRight }}</span>
|
|
||||||
<date-picker date="rightDate"></date-picker>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<nav class="btn-group FactModuleFilter">
|
|
||||||
<button
|
|
||||||
ng-class="{ 'btn': true,
|
|
||||||
'btn-default': true,
|
|
||||||
'FactModuleFilter-module': true,
|
|
||||||
'FactModuleFilter-module--isActive': module.isActive,
|
|
||||||
}"
|
|
||||||
ng-click="setActiveModule(module.name)"
|
|
||||||
ng-repeat="module in modules | orderBy: 'sortKey'">
|
|
||||||
{{module.displayName}}
|
|
||||||
</button>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<section class="FactDataError" ng-if="error" ng-switch="error">
|
|
||||||
<p class="FactDataError-message" ng-switch-when="NoFactsForModule">
|
|
||||||
There were no facts collected for that module in the selected date range. Please pick a different range or module and try again.
|
|
||||||
</p>
|
|
||||||
</section>
|
|
||||||
<section class="FactDataTable" ng-unless="error">
|
|
||||||
<div class="FactDataTable-row">
|
|
||||||
<h3 class="FactDataTable-column FactDataTable-column--offsetLeft">{{comparisonLeftHeader|stringOrDate:'L LT'}}</h3>
|
|
||||||
<h3 class="FactDataTable-column">{{comparisonRightHeader|stringOrDate:'L LT'}}</h3>
|
|
||||||
</div>
|
|
||||||
<div class="FactDataTable-factGroup FactDataGroup" ng-repeat="group in factData | orderBy: 'displayKeyPath'">
|
|
||||||
<div class="FactDataTable-row FactDataGroup-headings" ng-switch="group.nestingLevel" ng-if="group.displayKeyPath">
|
|
||||||
<h2 class="FactDataTable-column FactDataTable-column--full FactDataGroup-header" ng-class="{ 'FactDataGroup-header--new': group.isNew }" ng-switch-when="0">
|
|
||||||
{{group.displayKeyPath}}
|
|
||||||
</h2>
|
|
||||||
<h3 class="FactDataTable-column FactDataTable-column--full" ng-switch-when="1">
|
|
||||||
{{group.displayKeyPath}}
|
|
||||||
</h3>
|
|
||||||
<h4 class="FactDataTable-column FactDataTable-column--full" ng-switch-when="2">
|
|
||||||
{{group.displayKeyPath}}
|
|
||||||
</h4>
|
|
||||||
<h5 class="FactDataTable-column FactDataTable-column--full" ng-switch-when="3">
|
|
||||||
{{group.displayKeyPath}}
|
|
||||||
</h5>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="FactDataGroup-facts" data-facts="{{group.facts}}">
|
<div class="FactModulePickers-dateContainer FactModulePickers-dateContainer--right">
|
||||||
<div class="FactDataTable-arrayGroup" ng-if="group.isFactArray" ng-repeat="arrayGroup in group.facts" data-array-group="{{arrayGroup}}">
|
<span class="FactModulePickers-label">{{ factModulePickersLabelRight }}</span>
|
||||||
<div class="FactDataTable-row FactDatum" ng-class="{'FactDatum--divergent': fact.isDivergent }" ng-repeat="fact in arrayGroup" data-fact="{{fact}}">
|
<date-picker date="rightDate"></date-picker>
|
||||||
<p class="FactDatum-keyName FactDataTable-column">
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<nav class="btn-group FactModuleFilter">
|
||||||
|
<button
|
||||||
|
ng-class="{ 'btn': true,
|
||||||
|
'btn-default': true,
|
||||||
|
'FactModuleFilter-module': true,
|
||||||
|
'FactModuleFilter-module--isActive': module.isActive,
|
||||||
|
}"
|
||||||
|
ng-click="setActiveModule(module.name)"
|
||||||
|
ng-repeat="module in modules | orderBy: 'sortKey'">
|
||||||
|
{{module.displayName}}
|
||||||
|
</button>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<section class="FactDataError SystemTrackingContainer-main" ng-if="error" ng-switch="error.name">
|
||||||
|
<p class="FactDataError-message" ng-switch-when="NoScanData">
|
||||||
|
There were no facts collected on the dates you selected ({{error.dateValues.leftDate|amDateFormat:'L'}} and {{error.dateValues.rightDate|amDateFormat:'L'}}). Please pick a different range or module and try again.
|
||||||
|
</p>
|
||||||
|
<p class="FactDataError-message" ng-switch-when="InsufficientScanData">
|
||||||
|
There were no facts collected on one of the dates you selected ({{error.dateValue|amDateFormat:'L'}}). Please select a different date and try again.
|
||||||
|
</p>
|
||||||
|
<p class="FactDataError-note">
|
||||||
|
To setup or run scan jobs, edit the "<a link-to="inventoryEdit" model="{ inventory_id: inventory }">{{inventory.name}}</a>" inventory and select "Scan Jobs Templates".
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
<section class="FactDataTable SystemTrackingContainer-main" ng-if="!error">
|
||||||
|
<div class="FactDataTable-row">
|
||||||
|
<h3 class="FactDataTable-column FactDataTable-column--offsetLeft">{{comparisonLeftHeader|stringOrDate:'L LT'}}</h3>
|
||||||
|
<h3 class="FactDataTable-column">{{comparisonRightHeader|stringOrDate:'L LT'}}</h3>
|
||||||
|
</div>
|
||||||
|
<div class="FactDataTable-factGroup FactDataGroup" ng-repeat="group in factData | orderBy: 'displayKeyPath'">
|
||||||
|
<div class="FactDataTable-row FactDataGroup-headings" ng-switch="group.nestingLevel" ng-if="group.displayKeyPath">
|
||||||
|
<h2 class="FactDataTable-column FactDataTable-column--full FactDataGroup-header" ng-class="{ 'FactDataGroup-header--new': group.isNew }" ng-switch-when="0">
|
||||||
|
{{group.displayKeyPath}}
|
||||||
|
</h2>
|
||||||
|
<h3 class="FactDataTable-column FactDataTable-column--full" ng-switch-when="1">
|
||||||
|
{{group.displayKeyPath}}
|
||||||
|
</h3>
|
||||||
|
<h4 class="FactDataTable-column FactDataTable-column--full" ng-switch-when="2">
|
||||||
|
{{group.displayKeyPath}}
|
||||||
|
</h4>
|
||||||
|
<h5 class="FactDataTable-column FactDataTable-column--full" ng-switch-when="3">
|
||||||
|
{{group.displayKeyPath}}
|
||||||
|
</h5>
|
||||||
|
</div>
|
||||||
|
<div class="FactDataGroup-facts" data-facts="{{group.facts}}">
|
||||||
|
<div class="FactDataTable-arrayGroup" ng-if="group.isFactArray" ng-repeat="arrayGroup in group.facts" data-array-group="{{arrayGroup}}">
|
||||||
|
<div class="FactDataTable-row FactDatum" ng-class="{'FactDatum--divergent': fact.isDivergent }" ng-repeat="fact in arrayGroup" data-fact="{{fact}}">
|
||||||
|
<p class="FactDatum-keyName FactDataTable-column">
|
||||||
|
{{fact.keyName}}
|
||||||
|
</p>
|
||||||
|
<p class="FactDatum-value FactDataTable-column" style="word-break: break-all">
|
||||||
|
{{fact.value1}}
|
||||||
|
</p>
|
||||||
|
<p class="FactDatum-value FactDataTable-column" style="word-break: break-all">
|
||||||
|
{{fact.value2}}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="FactDataTable-row FactDatum" ng-class="{'FactDatum--divergent': fact.isDivergent }" ng-repeat="fact in group.facts" ng-unless="group.isFactArray" data-fact="{{fact}}">
|
||||||
|
<p class="FactDataTable-column FactDatum-keyName">
|
||||||
{{fact.keyName}}
|
{{fact.keyName}}
|
||||||
</p>
|
</p>
|
||||||
<p class="FactDatum-value FactDataTable-column" style="word-break: break-all">
|
<p class="FactDataTable-column FactDatum-value" style="word-break: break-all">
|
||||||
{{fact.value1}}
|
{{fact.value1}}
|
||||||
</p>
|
</p>
|
||||||
<p class="FactDatum-value FactDataTable-column" style="word-break: break-all">
|
<p class="FactDataTable-column FactDatum-value" style="word-break: break-all">
|
||||||
{{fact.value2}}
|
{{fact.value2}}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="FactDataTable-row FactDatum" ng-class="{'FactDatum--divergent': fact.isDivergent }" ng-repeat="fact in group.facts" ng-unless="group.isFactArray" data-fact="{{fact}}">
|
|
||||||
<p class="FactDataTable-column FactDatum-keyName">
|
|
||||||
{{fact.keyName}}
|
|
||||||
</p>
|
|
||||||
<p class="FactDataTable-column FactDatum-value" style="word-break: break-all">
|
|
||||||
{{fact.value1}}
|
|
||||||
</p>
|
|
||||||
<p class="FactDataTable-column FactDatum-value" style="word-break: break-all">
|
|
||||||
{{fact.value2}}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Reference in New Issue
Block a user