From 82a9421a87c5be0f20d6c067a18f5dac1be46b0e Mon Sep 17 00:00:00 2001 From: Daniel Stern <dstern@oicr.on.ca> Date: Thu, 26 Feb 2015 12:05:26 -0500 Subject: [PATCH] feat(search): adds summary tables - adds a breakdown of file info Closes #381 --- app/scripts/search/search.controllers.ts | 10 +- app/scripts/search/search.services.ts | 25 ++++- .../search/templates/search.summary.html | 103 +++++++++++++++++- 3 files changed, 129 insertions(+), 9 deletions(-) diff --git a/app/scripts/search/search.controllers.ts b/app/scripts/search/search.controllers.ts index ca23e44ac..d29169153 100755 --- a/app/scripts/search/search.controllers.ts +++ b/app/scripts/search/search.controllers.ts @@ -12,11 +12,13 @@ module ngApp.search.controllers { import ICartService = ngApp.cart.services.ICartService; import ILocationService = ngApp.components.location.services.ILocationService; import IUserService = ngApp.components.user.services.IUserService; + import ISearchService = ngApp.search.services.ISearchService; import TableiciousConfig = ngApp.components.tables.directives.tableicious.TableiciousConfig; export interface ISearchController { files: IFiles; participants: IParticipants; + summary: any; State: IState; CartService: ICartService; addFilesKeyPress(event: any, type: string): void; @@ -35,6 +37,7 @@ module ngApp.search.controllers { class SearchController implements ISearchController { files: IFiles; participants: IParticipants; + summary: any; tabSwitch: boolean = false; /* @ngInject */ @@ -42,6 +45,7 @@ module ngApp.search.controllers { private $state: ng.ui.IStateService, public State: IState, public CartService: ICartService, + public SearchService: ISearchService, public FilesService: IFilesService, public ParticipantsService: IParticipantsService, private LocationService: ILocationService, @@ -75,6 +79,10 @@ module ngApp.search.controllers { return; } + this.SearchService.getSummary().then((data) => { + this.summary = data; + }); + this.FilesService.getFiles({ fields: [ "access", @@ -196,7 +204,7 @@ module ngApp.search.controllers { filters: angular.toJson(f) }; } - console.log(stateParams); + this.$state.go("query.summary", stateParams, { inherit: true }); } diff --git a/app/scripts/search/search.services.ts b/app/scripts/search/search.services.ts index 8fb954309..5bb66afd0 100644 --- a/app/scripts/search/search.services.ts +++ b/app/scripts/search/search.services.ts @@ -41,7 +41,7 @@ module ngApp.search.services { _.each(this[section], function (section: ITab) { section.active = false; }); - console.log('h33!'); + if (!(section === "facets" && tab==="summary")) { this[section][tab].active = true; } @@ -50,7 +50,28 @@ module ngApp.search.services { } } + + export interface ISearchService { + getSummary(); + } + + class SearchService implements ISearchService { + private ds: restangular.IElement; + + /* @ngInject */ + constructor(Restangular: restangular.IService) { + this.ds = Restangular.all("ui/search"); + } + + getSummary() { + return this.ds.get('summary', {}).then((response) => { + return response; + }); + } + } + angular .module("search.services", []) - .service("State", State); + .service("State", State) + .service("SearchService", SearchService); } diff --git a/app/scripts/search/templates/search.summary.html b/app/scripts/search/templates/search.summary.html index d2894cc3c..dabbe9617 100644 --- a/app/scripts/search/templates/search.summary.html +++ b/app/scripts/search/templates/search.summary.html @@ -1,13 +1,18 @@ -<div class="col-lg-4"> - <h2>Summary</h2> +<div class="col-lg-12"> + <h2> + Query Result Summary + </h2> - <table id="summary-table" - class="table table-striped table-hover table-condensed table-bordered table-vertical col-lg-1"> + <table id="summary-table" class="table table-striped table-hover table-bordered table-vertical"> <tbody> <tr> - <th scope="row" data-translate>Files</th> + <th scope="row" data-translate># of Files</th> <td>{{ sc.files.pagination.total }}</td> </tr> + <tr> + <th scope="row" data-translate>File Size (GB)</th> + <td>{{ sc.summary.fs.value | size}}</td> + </tr> <tr> <th scope="row" data-translate>Participants</th> <td>{{ sc.participants.pagination.total }}</td> @@ -15,6 +20,92 @@ <h2>Summary</h2> </tbody> </table> - <div add-to-cart-all data-files="sc.files" data-paging="sc.files.pagination" data-add-all-only=true></div> + <div data-add-to-cart-all data-files="sc.files" data-paging="sc.files.pagination" + data-add-all-only=true></div> + + <h3> + Breakdowns + </h3> + + <div class="row"> + <div class="col-lg-6"> + <table id="summary-table-dt" class="col-lg-6 table table-striped table-hover table-bordered"> + <thead> + <tr> + <th>Data Type</th> + <th># Files</th> + <th> + File Size + </th> + </tr> + </thead> + <tbody> + <tr data-ng-repeat='type in sc.summary.data_type.buckets'> + <th scope="row" data-translate>{{type.key | humanify: true:true }}</th> + <td>{{ type.doc_count }}</td> + <td>{{ type.file_size.value | size}}</td> + </tr> + </tbody> + </table> + </div> + <div class="col-lg-6"> + <table id="summary-table-es" class="table table-striped table-hover table-bordered"> + <thead> + <tr> + <th>Experimental Strategy</th> + <th># Files</th> + <th>File Size</th> + </tr> + </thead> + <tbody> + <tr data-ng-repeat='type in sc.summary.experimental_strategy.buckets'> + <th scope="row" data-translate>{{type.key | humanify: true:true }}</th> + <td>{{ type.doc_count }}</td> + <td>{{ type.file_size.value | size}}</td> + </tr> + </tbody> + </table> + </div> + </div> + + <div class="row"> + <div class="col-lg-6"> + + <table id="summary-table-df" class="table table-striped table-hover table-bordered"> + <thead> + <tr> + <th>Data Format</th> + <th># Files</th> + <th>File Size</th> + </tr> + </thead> + <tbody> + <tr data-ng-repeat='type in sc.summary.data_format.buckets'> + <th scope="row" data-translate>{{type.key | humanify: true:true }}</th> + <td>{{ type.doc_count }}</td> + <td>{{ type.file_size.value | size}}</td> + </tr> + </tbody> + </table> + </div> + <div class="col-lg-6"> + <table id="summary-table-da" class="table table-striped table-hover table-bordered"> + <thead> + <tr> + <th>Data Access</th> + <th># Files</th> + <th>File Size</th> + </tr> + </thead> + <tbody> + <tr data-ng-repeat='type in sc.summary.access.buckets'> + <th scope="row" data-translate>{{type.key | humanify: true:true }}</th> + <td>{{ type.doc_count }}</td> + <td>{{ type.file_size.value | size}}</td> + </tr> + </tbody> + </table> + </div> + </div> </div>