Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
feat(search): adds summary tables
Browse files Browse the repository at this point in the history
- adds a breakdown of file info

Closes #381
  • Loading branch information
Daniel Stern authored and Shane Wilson committed Feb 28, 2015
1 parent 1fa8e22 commit 82a9421
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 9 deletions.
10 changes: 9 additions & 1 deletion app/scripts/search/search.controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -35,13 +37,15 @@ module ngApp.search.controllers {
class SearchController implements ISearchController {
files: IFiles;
participants: IParticipants;
summary: any;
tabSwitch: boolean = false;

/* @ngInject */
constructor(private $scope: ISearchScope,
private $state: ng.ui.IStateService,
public State: IState,
public CartService: ICartService,
public SearchService: ISearchService,
public FilesService: IFilesService,
public ParticipantsService: IParticipantsService,
private LocationService: ILocationService,
Expand Down Expand Up @@ -75,6 +79,10 @@ module ngApp.search.controllers {
return;
}

this.SearchService.getSummary().then((data) => {
this.summary = data;
});

this.FilesService.getFiles({
fields: [
"access",
Expand Down Expand Up @@ -196,7 +204,7 @@ module ngApp.search.controllers {
filters: angular.toJson(f)
};
}
console.log(stateParams);

this.$state.go("query.summary", stateParams, { inherit: true });
}

Expand Down
25 changes: 23 additions & 2 deletions app/scripts/search/search.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
}
103 changes: 97 additions & 6 deletions app/scripts/search/templates/search.summary.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,111 @@
<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>
</tr>
</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>

0 comments on commit 82a9421

Please sign in to comment.