Skip to content

Commit

Permalink
greatly speed up admin events page
Browse files Browse the repository at this point in the history
thanks for tips by @msuozzo
  • Loading branch information
thehesiod committed Oct 26, 2018
1 parent 023e622 commit 8921958
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// limitations under the License.

goog.provide('upvote.admin.events.module');
goog.require('upvote.admin.blockables.BlockableResource');
goog.require('upvote.admin.events.EventQueryResource');
goog.require('upvote.admin.events.EventResource');
goog.require('upvote.admin.events.uvEventCard');
Expand All @@ -24,5 +23,4 @@ upvote.admin.events.module =
angular.module('upvote.admin.events', ['ngResource'])
.factory('eventResource', upvote.admin.events.EventResource)
.factory('eventQueryResource', upvote.admin.events.EventQueryResource)
.factory('blockableResource', upvote.admin.blockables.BlockableResource)
.directive('uvEventCard', upvote.admin.events.uvEventCard);
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ upvote.admin.eventpage.EventController = class extends ModelController {
/**
* @param {!angular.Resource} eventResource
* @param {!angular.Resource} eventQueryResource
* @param {!angular.Resource} blockableResource
* @param {!angular.$routeParams} $routeParams
* @param {!angular.Scope} $scope
* @param {!angular.$location} $location
* @param {!upvote.shared.Page} page Details about the active webpage
* @ngInject
*/
constructor(
eventResource, eventQueryResource, blockableResource, $routeParams, $scope, $location,
eventResource, eventQueryResource, $routeParams, $scope, $location,
page) {
super(eventResource, eventQueryResource, $routeParams, $scope, $location);

Expand All @@ -46,51 +45,14 @@ upvote.admin.eventpage.EventController = class extends ModelController {

// Add the hostId param to the request before loadData is called by init.
this.requestData['hostId'] = this.hostId;

this.blockableResource = blockableResource;
this.requestData['withContext'] = true;

page.title = this.pageTitle;

// Initialize the controller.
this.init();
}

/** @override */
loadData(opt_more) {
let dataPromise = super.loadData(opt_more);
let blockableResource = this.blockableResource;

return (!dataPromise) ? dataPromise : dataPromise.then((results) => {
if(!results) {
return null;
}

results.forEach(function(item) {
if (!!item['blockableId']) {
blockableResource
.get({'id': item['blockableId']})['$promise']
.then((blockable) => {
item.blockable = blockable;

if (!!blockable['certId']) {
blockableResource
.get({'id': blockable['certId']})['$promise']
.then((cert) => {
item.cert = cert;
})
.catch((response) => {
this.errorService_.createToastFromError(response);
});
}
})
.catch((response) => {
this.errorService_.createToastFromError(response);
});
}
});
});
}

/**
* Navigate to the Blockable page associated with the selected Event.
* @export
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,26 +75,26 @@
<uv-listing-header hide show-gt-md flex="15">Count</uv-listing-header>
</listing-header>
<listing-body>
<uv-listing-row on-select="eventCtrl.selectItem(item.key, true)" ng-repeat="item in eventCtrl.content">
<uv-listing-cell>{{item.fileName}}</uv-listing-cell>
<uv-listing-cell>{{item.recordedDt | date:'medium'}}</uv-listing-cell>
<uv-listing-cell>{{item.eventType}}</uv-listing-cell>
<uv-listing-row on-select="eventCtrl.selectItem(item.event.key, true)" ng-repeat="item in eventCtrl.content">
<uv-listing-cell>{{item.event.fileName}}</uv-listing-cell>
<uv-listing-cell>{{item.event.recordedDt | date:'medium'}}</uv-listing-cell>
<uv-listing-cell>{{item.event.eventType}}</uv-listing-cell>
<uv-listing-cell>
<uv-state-chip state="item.blockable.state" vote="item.vote" cert="item.cert" is-pending="item.isPending"></uv-state-chip>
</uv-listing-cell>
<uv-listing-cell>{{item.executingUser}}</uv-listing-cell>
<uv-listing-cell>{{item.publisher}}</uv-listing-cell>
<uv-listing-cell>{{item.count}}</uv-listing-cell>
<uv-listing-cell>{{item.event.executingUser}}</uv-listing-cell>
<uv-listing-cell>{{item.event.publisher}}</uv-listing-cell>
<uv-listing-cell>{{item.event.count}}</uv-listing-cell>
<md-tooltip layout="column">
Filename: {{item.fileName}},
Recorded: {{item.recordedDt | date:'medium'}},
{{item.recordedDt | timeSince}},
Type: {{item.eventType}},
Host ID: {{item.hostId | prettifyUuid}},
Path: {{item.filePath}},
Publisher: {{item.publisher}},
Version: {{item.version}},
Executing User: {{item.executingUser}}
Filename: {{item.event.fileName}},
Recorded: {{item.event.recordedDt | date:'medium'}},
{{item.event.recordedDt | timeSince}},
Type: {{item.event.eventType}},
Host ID: {{item.event.hostId | prettifyUuid}},
Path: {{item.event.filePath}},
Publisher: {{item.event.publisher}},
Version: {{item.event.version}},
Executing User: {{item.event.executingUser}}
</md-tooltip>
</listing-body>
</uv-listing>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ upvote.events.EventQueryResource =
'cursor': '@cursor',
'perPage': '@perPage',
'asAdmin': '@asAdmin',
'withContext': '@withContext'
}
}
});
Expand Down

0 comments on commit 8921958

Please sign in to comment.