Skip to content

Commit

Permalink
add state to list of events
Browse files Browse the repository at this point in the history
  • Loading branch information
thehesiod committed Oct 24, 2018
1 parent 1fc6bb9 commit 9a8ea96
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
Expand Up @@ -13,7 +13,7 @@
// 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,4 +24,5 @@ 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);
Expand Up @@ -26,14 +26,15 @@ 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, $routeParams, $scope, $location,
eventResource, eventQueryResource, blockableResource, $routeParams, $scope, $location,
page) {
super(eventResource, eventQueryResource, $routeParams, $scope, $location);

Expand All @@ -45,12 +46,50 @@ 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;

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
Expand Up @@ -68,6 +68,7 @@
<uv-listing-header flex-gt-md="15" flex="25">Name</uv-listing-header>
<uv-listing-header flex-gt-md="15" flex="25">Recorded</uv-listing-header>
<uv-listing-header flex-gt-md="15" flex="25">Type</uv-listing-header>
<uv-listing-header flex-gt-md="15" flex="25">State</uv-listing-header>
<uv-listing-header flex-gt-md="15" flex="25">User</uv-listing-header>
<uv-listing-header hide show-gt-md flex="15">Filename</uv-listing-header>
<uv-listing-header hide show-gt-md flex="15">Publisher</uv-listing-header>
Expand All @@ -77,6 +78,7 @@
<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-cell>{{ item.blockable.state | toUiState: item.vote:item.cert | stateToDisplay }}</uv-listing-cell>
<uv-listing-cell>{{item.executingUser}}</uv-listing-cell>
<uv-listing-cell>{{item.publisher}}</uv-listing-cell>
<md-tooltip layout="column">
Expand Down

0 comments on commit 9a8ea96

Please sign in to comment.