refactor to use time data from server
diff --git a/ui-modules/app-inspector/app/components/entity-tree/entity-tree.directive.js b/ui-modules/app-inspector/app/components/entity-tree/entity-tree.directive.js
index 5a8017f..f6d3426 100644
--- a/ui-modules/app-inspector/app/components/entity-tree/entity-tree.directive.js
+++ b/ui-modules/app-inspector/app/components/entity-tree/entity-tree.directive.js
@@ -57,14 +57,8 @@
let observers = [];
- let timeData = [];
-
applicationApi.applicationsTree().then((response)=> {
vm.applications = response.data;
- vm.applications.forEach(app => {
- getTimeData(app);
- });
-
observers.push(response.subscribe((response)=> {
response.data
@@ -84,17 +78,7 @@
});
});
- //Unless an app has just been loaded the start time information will be held locally in 'timeData'
- vm.applications = response.data.map(app => {
- const appStartData = timeData.find( item => item.applicationId === app.applicationId);
- if (!appStartData) {
- getTimeData (app)
- }
- return {
- ...app,
- startTimeUtc: appStartData ? appStartData.startTimeUtc : Date.now()
- }
- });
+ vm.applications = response.data;
function spawnNotification(app, opts) {
iconService.get(app).then((icon)=> {
@@ -106,24 +90,6 @@
});
}
}));
-
- //retrieves start time of the app from the entity api.
- function getTimeData(app) {
- //remove entries from timeData relating to apps that have been undeployed
- timeData = timeData.filter(item => vm.applications.find(app => app.applicationId === item.applicationId))
- entityApi.entityActivities(app.applicationId, app.applicationId).then( response => {
- if ((response.data.length === 0) || (timeData.find(item => item.applicationId === app.applicationId))) {
- return;
- };
- timeData.push({
- applicationId: app.applicationId,
- startTimeUtc: response.data[0].startTimeUtc
- });
- app.startTimeUtc = response.data[0].startTimeUtc
- }).catch((error) => {
- console.log(error);
- });
- }
});
$scope.$on('$destroy', ()=> {
diff --git a/ui-modules/app-inspector/app/components/entity-tree/entity-tree.html b/ui-modules/app-inspector/app/components/entity-tree/entity-tree.html
index ea33ed6..67c0ce1 100644
--- a/ui-modules/app-inspector/app/components/entity-tree/entity-tree.html
+++ b/ui-modules/app-inspector/app/components/entity-tree/entity-tree.html
@@ -16,7 +16,7 @@
specific language governing permissions and limitations
under the License.
-->
-<entity-node ng-repeat="application in vm.applications | orderBy: sortReverse? '-startTimeUtc': 'startTimeUtc' track by application.id" entity="application" application-id="application.id"></entity-node>
+<entity-node ng-repeat="application in vm.applications | orderBy: sortReverse? '-creationTimeUtc': 'creationTimeUtc' track by application.id" entity="application" application-id="application.id"></entity-node>
<p class="expand-tree-message text-center" ng-if="vm.applications.length > 0"><small><kbd>shift</kbd> + <kbd>{{navigator.appVersion.indexOf("Mac") !== -1 ? '⌘' : '⊞'}}</kbd> + click to expand all children</small></p>
<div class="empty-tree text-muted text-center" ng-if="vm.applications.length === 0">
<hr />