Commit 90bfb5fb authored by François Agneray's avatar François Agneray
Browse files

Adapt result page with new dataset config

parent 64918290
......@@ -26,19 +26,35 @@ export interface Dataset {
config: {
cone_search: {
enabled: boolean;
opened: boolean;
column_ra: number;
column_dec: number;
plot_enabled: boolean;
};
result_page_modules: {
results_server_link: boolean;
opened_datatable: boolean;
selectable_row: boolean;
}
results_format: {
},
download: {
enabled: boolean;
opened: boolean;
csv: boolean;
ascii: boolean;
vo: boolean;
};
archive: boolean;
},
summary: {
enabled: boolean;
opened: boolean;
},
server_link: {
enabled: boolean;
opened: boolean;
},
samp: {
enabled: boolean;
opened: boolean;
},
datatable: {
enabled: boolean;
opened: boolean;
selectable_row: boolean;
}
};
}
......@@ -5,31 +5,21 @@
<div class="w-100 d-block d-xl-none"></div>
<div class="col">
<div class="row justify-content-around">
<div *ngIf="getConfigDownloadResultFormat('csv')" class="col-auto mb-2">
<div *ngIf="dataset.config.download.csv" class="col-auto mb-2">
<a [href]="getUrl('csv')" class="btn btn-lg btn-block dl-btn">
<span [inlineSVG]="'assets/logo_csv.svg'" title="Download results in CSV format"></span>
</a>
</div>
<div *ngIf="getConfigDownloadResultFormat('ascii')" class="col-auto mb-2">
<div *ngIf="dataset.config.download.ascii" class="col-auto mb-2">
<a [href]="getUrl('ascii')" target="_blank" class="btn btn-lg btn-block dl-btn">
<span [inlineSVG]="'assets/logo_ascii.svg'" title="Download results in ASCII format"></span>
</a>
</div>
<div *ngIf="getConfigDownloadResultFormat('vo')" class="col-auto mb-2">
<div *ngIf="dataset.config.download.vo" class="col-auto mb-2">
<button class="btn btn-lg btn-block dl-btn">
<span [inlineSVG]="'assets/logo_vo.svg'" title="Download results in VO format"></span>
</button>
</div>
<div *ngIf="getConfigDownloadResultFormat('spectra')" class="col-auto mb-2">
<button class="btn btn-lg btn-block dl-btn">
<span [inlineSVG]="'assets/logo_spectra.svg'" title="Download SPECTRA archive"></span>
</button>
</div>
<div *ngIf="getConfigDownloadResultFormat('stamp')" class="col-auto mb-2">
<button class="btn btn-lg btn-block dl-btn">
<span [inlineSVG]="'assets/logo_stamp.svg'" title="Download STAMP archive"></span>
</button>
</div>
</div>
</div>
</div>
\ No newline at end of file
......@@ -21,13 +21,6 @@ describe('[SearchMultiple][Result] Component: DownloadSectionComponent', () => {
expect(component).toBeTruthy();
});
it('#getConfigDownloadResultFormat() should return if download button has to be displayed for the given format', () => {
component.dataset = DATASET;
expect(component.getConfigDownloadResultFormat('csv')).toBeTruthy();
component.dataset = DATASET_LIST.find(d => d.name === 'cat_2');
expect(component.getConfigDownloadResultFormat('csv')).toBeFalsy();
});
it('#getUrl(format) should construct url with format parameter', () => {
component.dataset = DATASET;
component.outputList = [1, 2, 3];
......
......@@ -28,20 +28,6 @@ export class DownloadSectionComponent {
@Input() coneSearch: ConeSearch;
@Input() outputList: number[];
/**
* Checks if configuration allowed downloading for the given format.
*
* @param {string} format - The format.
*
* @return boolean
*/
getConfigDownloadResultFormat(format: string): boolean {
if (this.dataset.config && this.dataset.config.results_format && this.dataset.config.results_format[format]) {
return this.dataset.config.results_format[format];
}
return false;
}
/**
* Returns URL to download data in the given format.
*
......
<accordion *ngIf="coneSearchEnabled()" [isAnimated]="true">
<accordion-group #ag [panelClass]="'custom-accordion'" [isOpen]="true" class="my-2">
<accordion-group #ag [panelClass]="'custom-accordion'" [isOpen]="coneSearchOpened()" class="my-2">
<button class="btn btn-link btn-block clearfix" accordion-heading>
<span class="pull-left float-left">
Cone search
......
......@@ -34,9 +34,16 @@ export class ConeSearchTabComponent {
*/
coneSearchEnabled(): boolean {
const config = this.datasetList.find(d => d.name === this.datasetName).config;
if (config !== null && 'cone_search' in config) {
return config.cone_search.enabled;
}
return false;
return config.cone_search.enabled;
}
/**
* Checks if accordion is opened.
*
* @return boolean
*/
coneSearchOpened(): boolean {
const config = this.datasetList.find(d => d.name === this.datasetName).config;
return config.cone_search.opened;
}
}
<accordion *ngIf="dataLength > 0 && dataLengthIsLoaded && checkDisplayPlot() && isConeSearchAdded" [isAnimated]="true">
<accordion-group #ag [isOpen]="isDatatableOpened()" [panelClass]="'custom-accordion'" class="my-2">
<accordion-group #ag [isOpen]="isConeSearchOpened()" [panelClass]="'custom-accordion'" class="my-2">
<button class="btn btn-link btn-block clearfix" accordion-heading>
<span class="pull-left float-left">
Cone-search plot
......
......@@ -32,13 +32,9 @@ export class ConeSearchPlotTabComponent {
*
* @return boolean
*/
isDatatableOpened(): boolean {
isConeSearchOpened(): boolean {
const config = this.getDataset().config;
config.result_page_modules.opened_datatable;
if (config && config.result_page_modules) {
return config.result_page_modules.opened_datatable;
}
return false;
return config.cone_search.opened;
}
/**
......
<accordion *ngIf="dataLength > 0 && _dataLengthIsLoaded" [isAnimated]="true">
<accordion *ngIf="dataLength > 0 && _dataLengthIsLoaded && isDatatableEnabled()" [isAnimated]="true">
<accordion-group #ag [isOpen]="isDatatableOpened()" [panelClass]="'custom-accordion'" class="my-2">
<button class="btn btn-link btn-block clearfix" accordion-heading>
<span class="pull-left float-left">
......
......@@ -59,6 +59,11 @@ export class DatatableTabComponent {
_dataLengthIsLoaded: boolean = false;
isDatatableEnabled(): boolean {
const config = this.getDataset().config;
return config.datatable.enabled;
}
/**
* Checks if datatable accordion should be open.
*
......@@ -66,11 +71,7 @@ export class DatatableTabComponent {
*/
isDatatableOpened(): boolean {
const config = this.getDataset().config;
config.result_page_modules.opened_datatable;
if (config && config.result_page_modules) {
return config.result_page_modules.opened_datatable;
}
return false;
return config.datatable.opened;
}
/**
......
......@@ -2,38 +2,55 @@
<div class="lead">
Dataset <span class="bold">{{ getDatasetLabel() }}</span> selected with <span class="bold">{{ dataLength }}</span> objects found.
</div>
<hr *ngIf="isDownloadActivated()" class="my-4">
<div *ngIf="isDownloadActivated()" class="row">
<div class="col-auto align-self-center">
<p>Download results just here:</p>
</div>
<accordion *ngIf="dataLengthIsLoaded && isDownloadActivated()" [isAnimated]="true">
<accordion-group #ag [isOpen]="isDownloadOpened()" [panelClass]="'custom-accordion'" class="my-2">
<button class="btn btn-link btn-block clearfix" accordion-heading>
<span class="pull-left float-left">
Download results
&nbsp;
<span *ngIf="ag.isOpen">
<span class="fas fa-chevron-up"></span>
</span>
<span *ngIf="!ag.isOpen">
<span class="fas fa-chevron-down"></span>
</span>
</span>
</button>
<div>
<div class="row">
<div class="col-auto align-self-center">
<p>Download results just here:</p>
</div>
<div class="col">
<a *ngIf="getConfigDownloadResultFormat('csv')" [href]="getUrl('csv')" class="btn btn-outline-primary" title="Download results in CSV format">
<i class="fas fa-file-csv"></i> Download csv
</a>
&nbsp;
<a *ngIf="getConfigDownloadResultFormat('ascii')" [href]="getUrl('ascii')" target="_blank" class="btn btn-outline-primary" title="Download results in ASCII format">
<i class="fas fa-file"></i> Download ascii
</a>
&nbsp;
<a *ngIf="getConfigDownloadResultFormat('vo')" [href]="getUrl('votable')" target="_blank" class="btn btn-outline-primary" title="Download results in VO format">
<i class="fas fa-file"></i> Download votable
</a>
&nbsp;
<button *ngIf="getConfigDownloadResultFormat('vo')" [disabled]="!sampRegistered" (click)="broadcastVotable()" class="btn btn-outline-primary" title="Broadcast samp votable">
<i class="fas fa-broadcast-tower"></i> Broadcast votable
</button>
</div>
</div>
<hr *ngIf="getConfigDownloadResultFormat('archive')" class="my-4">
<div *ngIf="getConfigDownloadResultFormat('archive')" class="row">
<div class="col-auto align-self-center">
<p>Download archive files just here:</p>
</div>
<div class="col">
<a [href]="getUrlArchive()" class="btn btn-outline-primary" title="Download an archive with all files">
<i class="fas fa-archive"></i> Download files archive
</a>
</div>
</div>
</div>
<div class="col">
<a *ngIf="getConfigDownloadResultFormat('csv')" [href]="getUrl('csv')" class="btn btn-outline-primary" title="Download results in CSV format">
<i class="fas fa-file-csv"></i> Download csv
</a>
&nbsp;
<a *ngIf="getConfigDownloadResultFormat('ascii')" [href]="getUrl('ascii')" target="_blank" class="btn btn-outline-primary" title="Download results in ASCII format">
<i class="fas fa-file"></i> Download ascii
</a>
&nbsp;
<a *ngIf="getConfigDownloadResultFormat('vo')" [href]="getUrl('votable')" target="_blank" class="btn btn-outline-primary" title="Download results in VO format">
<i class="fas fa-file"></i> Download votable
</a>
&nbsp;
<button *ngIf="getConfigDownloadResultFormat('vo')" [disabled]="!sampRegistered" (click)="broadcastVotable()" class="btn btn-outline-primary" title="Broadcast samp votable">
<i class="fas fa-broadcast-tower"></i> Broadcast votable
</button>
</div>
</div>
<hr class="my-4">
<div class="row">
<div class="col-auto align-self-center">
<p>Download archive files just here:</p>
</div>
<div class="col">
<a [href]="getUrlArchive()" class="btn btn-outline-primary" title="Download an archive with all files">
<i class="fas fa-archive"></i> Download files archive
</a>
</div>
</div>
</div>
\ No newline at end of file
</accordion-group>
</accordion>
......@@ -54,14 +54,12 @@ export class DownloadComponent implements OnInit {
isDownloadActivated(): boolean {
const dataset = this.datasetList.find(dataset => dataset.name === this.datasetName);
if (dataset.config && dataset.config.results_format) {
for (const [key, value] of Object.entries(dataset.config.results_format)) {
if (value) {
return true;
}
}
}
return false;
return dataset.config.download.enabled;
}
isDownloadOpened(): boolean {
const dataset = this.datasetList.find(dataset => dataset.name === this.datasetName);
return dataset.config.download.opened;
}
/**
......@@ -73,10 +71,7 @@ export class DownloadComponent implements OnInit {
*/
getConfigDownloadResultFormat(format: string): boolean {
const dataset = this.datasetList.find(dataset => dataset.name === this.datasetName);
if (dataset.config && dataset.config.results_format && dataset.config.results_format[format]) {
return dataset.config.results_format[format];
}
return false;
return dataset.config.download[format];
}
/**
......
<accordion *ngIf="dataLengthIsLoaded" [isAnimated]="true">
<accordion-group #ag [isOpen]="false" [panelClass]="'custom-accordion'" class="my-2">
<accordion *ngIf="dataLengthIsLoaded && isSummaryActivated()" [isAnimated]="true">
<accordion-group #ag [isOpen]="isSummaryOpened()" [panelClass]="'custom-accordion'" class="my-2">
<button class="btn btn-link btn-block clearfix" accordion-heading>
<span class="pull-left float-left">
Search summary
......
......@@ -10,7 +10,7 @@
import { Component, Input } from '@angular/core';
import { Criterion } from '../../store/model';
import { Attribute, Category, Family } from '../../../metamodel/model';
import { Dataset, Attribute, Category, Family } from '../../../metamodel/model';
import { printCriterion as print } from '../../../shared/utils'
import { ConeSearch } from '../../../shared/cone-search/store/model';
......@@ -24,6 +24,8 @@ import { ConeSearch } from '../../../shared/cone-search/store/model';
* @classdesc Search result reminder component.
*/
export class ReminderComponent {
@Input() datasetName: string;
@Input() datasetList: Dataset[];
@Input() datasetAttributeList: Attribute[];
@Input() dataLengthIsLoaded:boolean;
@Input() isConeSearchAdded: boolean;
......@@ -34,6 +36,16 @@ export class ReminderComponent {
@Input() categoryList: Category[];
@Input() outputList: number[];
isSummaryActivated(): boolean {
const dataset = this.datasetList.find(dataset => dataset.name === this.datasetName);
return dataset.config.summary.enabled;
}
isSummaryOpened(): boolean {
const dataset = this.datasetList.find(dataset => dataset.name === this.datasetName);
return dataset.config.summary.opened;
}
/**
* Returns total of added criteria.
*
......
<accordion [isAnimated]="true">
<accordion-group #ag [isOpen]="false" [panelClass]="'custom-accordion'" class="my-2">
<accordion *ngIf="isSampActivated()" [isAnimated]="true">
<accordion-group #ag [isOpen]="isSampOpened()" [panelClass]="'custom-accordion'" class="my-2">
<button class="btn btn-link btn-block clearfix" accordion-heading>
<span class="pull-left float-left">
<span [style.color]="getColor()">
......
......@@ -9,6 +9,8 @@
import { Component, Input, ChangeDetectionStrategy, Output, EventEmitter } from '@angular/core';
import { Dataset } from '../../../metamodel/model';
@Component({
selector: 'app-samp',
templateUrl: 'samp.component.html',
......@@ -19,10 +21,22 @@ import { Component, Input, ChangeDetectionStrategy, Output, EventEmitter } from
* @classdesc Samp component.
*/
export class SampComponent {
@Input() datasetName: string;
@Input() datasetList: Dataset[];
@Input() sampRegistered: boolean;
@Output() sampRegister: EventEmitter<{}> = new EventEmitter();
@Output() sampUnregister: EventEmitter<{}> = new EventEmitter();
isSampActivated(): boolean {
const dataset = this.datasetList.find(dataset => dataset.name === this.datasetName);
return dataset.config.samp.enabled;
}
isSampOpened(): boolean {
const dataset = this.datasetList.find(dataset => dataset.name === this.datasetName);
return dataset.config.samp.opened;
}
getColor(): string {
if (this.sampRegistered) {
return 'green';
......
<accordion *ngIf="urlDisplayEnabled() && dataLengthIsLoaded" [isAnimated]="true">
<accordion-group #ag [isOpen]="true" [panelClass]="'custom-accordion'" class="my-2">
<accordion-group #ag [isOpen]="urlDisplayOpened()" [panelClass]="'custom-accordion'" class="my-2">
<button class="btn btn-link btn-block clearfix" accordion-heading>
<span class="pull-left float-left">
Direct link to the result (JSON)
......
......@@ -43,11 +43,12 @@ export class UrlDisplaySectionComponent {
*/
urlDisplayEnabled(): boolean {
const config = this.datasetList.find(d => d.name === this.datasetName).config;
config.result_page_modules.opened_datatable;
if (config && config.result_page_modules) {
return config.result_page_modules.results_server_link;
}
return false;
return config.server_link.enabled;
}
urlDisplayOpened(): boolean {
const config = this.datasetList.find(d => d.name === this.datasetName).config;
return config.server_link.opened;
}
/**
......
......@@ -20,6 +20,8 @@
(broadcast)="broadcastVotable($event)">
</app-result-download>
<app-reminder
[datasetName]="datasetName | async"
[datasetList]="datasetList | async"
[datasetAttributeList]="attributeList | async"
[dataLengthIsLoaded]="dataLengthIsLoaded | async"
[isConeSearchAdded]="isConeSearchAdded | async"
......@@ -31,6 +33,8 @@
[outputList]="outputList | async">
</app-reminder>
<app-samp
[datasetName]="datasetName | async"
[datasetList]="datasetList | async"
[sampRegistered]="sampRegistered | async"
(sampRegister)="sampRegister()"
(sampUnregister)="sampUnregister()">
......
......@@ -3,7 +3,7 @@
<span class="sr-only">Loading...</span>
</div>
<div *ngIf="requiredParams()">
<div *ngIf="dataset.config.result_page_modules.selectable_row" class="mb-2">
<div *ngIf="dataset.config.datatable.selectable_row" class="mb-2">
<button [disabled]="noSelectedData() || processWip" (click)="executeProcess.emit('csv')"
class="btn btn-sm btn-outline-primary">
To CSV
......@@ -20,7 +20,7 @@
<table class="table table-bordered table-hover">
<thead>
<tr>
<th *ngIf="dataset.config.result_page_modules.selectable_row">#</th>
<th *ngIf="dataset.config.datatable.selectable_row">#</th>
<th *ngFor="let attribute of getOutputList()" scope="col" class="clickable" (click)="sort(attribute.id)">
{{ attribute.label }}
<span *ngIf="attribute.id === sortedCol" class="pl-2">
......@@ -44,7 +44,7 @@
</thead>
<tbody>
<tr *ngFor="let datum of data">
<td *ngIf="dataset.config.result_page_modules.selectable_row" class="data-selected"
<td *ngIf="dataset.config.datatable.selectable_row" class="data-selected"
(click)="toggleSelection(datum)">
<button class="btn btn-block text-left p-0 m-0">
<span *ngIf="!isSelected(datum)">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment