mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 09:57:35 -02:30
Display timestamp from API in column headers
This commit is contained in:
@@ -7,23 +7,53 @@
|
|||||||
export default
|
export default
|
||||||
function flatCompare(facts, nameKey, compareKeys) {
|
function flatCompare(facts, nameKey, compareKeys) {
|
||||||
|
|
||||||
var leftFacts = facts[0];
|
// Make sure we always start comparison against
|
||||||
var rightFacts = facts[1];
|
// 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
|
||||||
|
//
|
||||||
|
|
||||||
return rightFacts.reduce(function(arr, rightFact) {
|
// 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) {
|
||||||
var searcher = {};
|
var searcher = {};
|
||||||
searcher[nameKey] = rightFact[nameKey];
|
searcher[nameKey] = basisFact[nameKey];
|
||||||
|
|
||||||
var isNewFactValue = false;
|
var isNewFactValue = false;
|
||||||
|
|
||||||
var matchingFact = _.where(leftFacts, searcher);
|
var matchingFact = _.where(comparatorFacts, searcher);
|
||||||
var diffs;
|
var diffs;
|
||||||
|
|
||||||
if (_.isEmpty(matchingFact)) {
|
if (_.isEmpty(matchingFact)) {
|
||||||
isNewFactValue = true;
|
isNewFactValue = true;
|
||||||
|
|
||||||
diffs =
|
diffs =
|
||||||
_.map(rightFact, function(value, key) {
|
_.map(basisFact, function(value, key) {
|
||||||
return { keyName: key,
|
return { keyName: key,
|
||||||
value1: value,
|
value1: value,
|
||||||
value2: ''
|
value2: ''
|
||||||
@@ -34,8 +64,18 @@ export default
|
|||||||
|
|
||||||
diffs = _(compareKeys)
|
diffs = _(compareKeys)
|
||||||
.map(function(key) {
|
.map(function(key) {
|
||||||
var leftValue = rightFact[key];
|
var basisValue = basisFact[key];
|
||||||
var rightValue = matchingFact[key];
|
var comparatorValue = matchingFact[key];
|
||||||
|
var leftValue, rightValue;
|
||||||
|
|
||||||
|
if (basisFacts.position === 'left') {
|
||||||
|
leftValue = basisValue;
|
||||||
|
rightValue = comparatorValue;
|
||||||
|
} else {
|
||||||
|
rightValue = basisValue;
|
||||||
|
leftValue = comparatorValue;
|
||||||
|
}
|
||||||
|
|
||||||
if (leftValue !== rightValue) {
|
if (leftValue !== rightValue) {
|
||||||
return {
|
return {
|
||||||
keyName: key,
|
keyName: key,
|
||||||
@@ -49,7 +89,7 @@ export default
|
|||||||
}
|
}
|
||||||
|
|
||||||
var descriptor =
|
var descriptor =
|
||||||
{ displayKeyPath: rightFact[nameKey],
|
{ displayKeyPath: basisFact[nameKey],
|
||||||
isNew: isNewFactValue,
|
isNew: isNewFactValue,
|
||||||
nestingLevel: 0,
|
nestingLevel: 0,
|
||||||
facts: diffs
|
facts: diffs
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ function (Rest, GetBasePath, ProcessErrors, _) {
|
|||||||
return version
|
return version
|
||||||
.then(function(versionData) {
|
.then(function(versionData) {
|
||||||
if (_.isEmpty(versionData)) {
|
if (_.isEmpty(versionData)) {
|
||||||
return [];
|
return { fact: [] };
|
||||||
} else {
|
} else {
|
||||||
return getFacts(versionData);
|
return getFacts(versionData);
|
||||||
}
|
}
|
||||||
@@ -26,8 +26,8 @@ function (Rest, GetBasePath, ProcessErrors, _) {
|
|||||||
var promise;
|
var promise;
|
||||||
Rest.setUrl(version.related.fact_view);
|
Rest.setUrl(version.related.fact_view);
|
||||||
promise = Rest.get();
|
promise = Rest.get();
|
||||||
return promise.then(function (data) {
|
return promise.then(function (response) {
|
||||||
return data.data.fact;
|
return response.data;
|
||||||
}).catch(function (response) {
|
}).catch(function (response) {
|
||||||
ProcessErrors(null, response.data, response.status, null, {
|
ProcessErrors(null, response.data, response.status, null, {
|
||||||
hdr: 'Error!',
|
hdr: 'Error!',
|
||||||
|
|||||||
@@ -50,8 +50,7 @@ export default
|
|||||||
|
|
||||||
return getHostFacts(params);
|
return getHostFacts(params);
|
||||||
}).then(function(hostFacts) {
|
}).then(function(hostFacts) {
|
||||||
hostFacts.moduleOptions = moduleOptions;
|
return [moduleOptions, hostFacts];
|
||||||
return hostFacts;
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export function searchDateRange(dateString) {
|
|||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
from: date.startOf('day'),
|
from: date.clone().startOf('day'),
|
||||||
to: date.endOf('day')
|
to: date.clone().endOf('day')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,17 +33,17 @@ function controller($rootScope,
|
|||||||
var viewType = hostIds.length > 1 ? 'multiHost' : 'singleHost';
|
var viewType = hostIds.length > 1 ? 'multiHost' : 'singleHost';
|
||||||
|
|
||||||
var searchConfig =
|
var searchConfig =
|
||||||
{ leftDate: initialFactData.leftDate,
|
{ leftRange: initialFactData.leftSearchRange,
|
||||||
rightDate: initialFactData.rightDate
|
rightRange: initialFactData.rightSearchRange
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.leftDate = initialFactData.leftDate.from;
|
$scope.leftDate = initialFactData.leftSearchRange.from;
|
||||||
$scope.rightDate = initialFactData.rightDate.from;
|
$scope.rightDate = initialFactData.rightSearchRange.from;
|
||||||
|
|
||||||
function setHeaderValues(viewType) {
|
function setHeaderValues(viewType) {
|
||||||
if (viewType === 'singleHost') {
|
if (viewType === 'singleHost') {
|
||||||
$scope.comparisonLeftHeader = $scope.leftDate;
|
$scope.comparisonLeftHeader = $scope.leftScanDate;
|
||||||
$scope.comparisonRightHeader = $scope.rightDate;
|
$scope.comparisonRightHeader = $scope.rightScanDate;
|
||||||
} else {
|
} else {
|
||||||
$scope.comparisonLeftHeader = hosts[0].name;
|
$scope.comparisonLeftHeader = hosts[0].name;
|
||||||
$scope.comparisonRightHeader = hosts[1].name;
|
$scope.comparisonRightHeader = hosts[1].name;
|
||||||
@@ -54,16 +54,26 @@ function controller($rootScope,
|
|||||||
searchConfig = _.merge({}, searchConfig, params);
|
searchConfig = _.merge({}, searchConfig, params);
|
||||||
|
|
||||||
var factData = initialData;
|
var factData = initialData;
|
||||||
var leftDate = searchConfig.leftDate;
|
var leftRange = searchConfig.leftRange;
|
||||||
var rightDate = searchConfig.rightDate;
|
var rightRange = searchConfig.rightRange;
|
||||||
var activeModule = searchConfig.module;
|
var activeModule = searchConfig.module;
|
||||||
|
|
||||||
if (!factData) {
|
if (!factData) {
|
||||||
factData = getDataForComparison(
|
factData =
|
||||||
hostIds,
|
getDataForComparison(
|
||||||
activeModule.name,
|
hostIds,
|
||||||
leftDate,
|
activeModule.name,
|
||||||
rightDate);
|
leftRange,
|
||||||
|
rightRange)
|
||||||
|
.thenAll(function(factDataAndModules) {
|
||||||
|
var responses = factDataAndModules[1];
|
||||||
|
var data = _.pluck(responses, 'fact');
|
||||||
|
|
||||||
|
$scope.leftScanDate = moment(responses[0].timestamp);
|
||||||
|
$scope.rightScanDate = moment(responses[1].timestamp);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
waitIndicator('start');
|
waitIndicator('start');
|
||||||
@@ -122,9 +132,9 @@ function controller($rootScope,
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.$watch('leftDate', dateWatcher('leftDate'), true);
|
$scope.$watch('leftDate', dateWatcher('leftRange'), true);
|
||||||
|
|
||||||
$scope.$watch('rightDate', dateWatcher('rightDate'), true);
|
$scope.$watch('rightDate', dateWatcher('rightRange'), true);
|
||||||
|
|
||||||
$scope.setActiveModule(initialFactData.moduleName, initialFactData);
|
$scope.setActiveModule(initialFactData.moduleName, initialFactData);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,8 +35,8 @@
|
|||||||
</section>
|
</section>
|
||||||
<section class="FactDataTable" ng-unless="error">
|
<section class="FactDataTable" ng-unless="error">
|
||||||
<div class="FactDataTable-row">
|
<div class="FactDataTable-row">
|
||||||
<h3 class="FactDataTable-column FactDataTable-column--offsetLeft">{{comparisonLeftHeader|stringOrDate:'L'}}</h3>
|
<h3 class="FactDataTable-column FactDataTable-column--offsetLeft">{{comparisonLeftHeader|stringOrDate:'L LT'}}</h3>
|
||||||
<h3 class="FactDataTable-column">{{comparisonRightHeader|stringOrDate:'L'}}</h3>
|
<h3 class="FactDataTable-column">{{comparisonRightHeader|stringOrDate:'L LT'}}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="FactDataTable-factGroup FactDataGroup" ng-repeat="group in factData | orderBy: 'displayKeyPath'">
|
<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">
|
<div class="FactDataTable-row FactDataGroup-headings" ng-switch="group.nestingLevel" ng-if="group.displayKeyPath">
|
||||||
|
|||||||
@@ -30,13 +30,23 @@ export default {
|
|||||||
|
|
||||||
var data =
|
var data =
|
||||||
getDataForComparison(hostIds, moduleParam, leftDate, rightDate).
|
getDataForComparison(hostIds, moduleParam, leftDate, rightDate).
|
||||||
thenThru(function(factData) {
|
thenAll(function(factDataAndModules) {
|
||||||
factData.leftDate = leftDate;
|
var moduleOptions = factDataAndModules[0];
|
||||||
factData.rightDate = rightDate;
|
var factResponses = factDataAndModules[1];
|
||||||
factData.moduleName = moduleParam;
|
var factData = _.pluck(factResponses, 'fact');
|
||||||
return factData;
|
|
||||||
})
|
factData.leftSearchRange = leftDate;
|
||||||
.value();
|
factData.rightSearchRange = rightDate;
|
||||||
|
|
||||||
|
factData.leftScanDate = moment(factResponses[0].timestamp);
|
||||||
|
factData.rightScanDate = moment(factResponses[0].timestamp);
|
||||||
|
|
||||||
|
factData.moduleName = moduleParam;
|
||||||
|
factData.moduleOptions = moduleOptions;
|
||||||
|
|
||||||
|
return factData;
|
||||||
|
}, true)
|
||||||
|
.value();
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user