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

Dataset cone-search plot add background images

parent 9e22b2af
......@@ -115,6 +115,43 @@
<input class="custom-control-input" type="checkbox" id="plot_enabled" name="plot_enabled" [ngModel]="model.config.cone_search.plot_enabled" [disabled]="!ngForm.form.value.cone_search_enabled">
<label class="custom-control-label" for="plot_enabled">Activate plot</label>
</div>
<div *ngIf="ngForm.form.value.plot_enabled" class="mt-2 table-responsive">
<table class="table">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Enabled</th>
<th scope="col">Display</th>
</tr>
</thead>
<tbody>
<tr>
<td class="align-middle">SDSS (DR16)</td>
<td class="align-middle">
<div class="custom-control custom-switch">
<input class="custom-control-input" type="checkbox" id="sdss_enabled" name="sdss_enabled" [ngModel]="model.config.cone_search.sdss_enabled">
<label class="custom-control-label" for="sdss_enabled"></label>
</div>
</td>
<td class="align-middle">
<input id="sdss_display" type="number" class="form-control" name="sdss_display" value="10" [ngModel]="model.config.cone_search.sdss_display">
</td>
</tr>
<tr *ngFor="let image of datasetImages">
<td class="align-middle">{{ image.name }}</td>
<td class="align-middle">
<div class="custom-control custom-switch">
<input class="custom-control-input" type="checkbox" id="{{ image.id }}_enabled" name="{{ image.id }}_enabled" [ngModel]="getBackgroundEnabled(image)">
<label class="custom-control-label" for="{{ image.id }}_enabled"></label>
</div>
</td>
<td class="align-middle">
<input id="{{ image.id }}_display" type="number" class="form-control" name="{{ image.id }}_display" [ngModel]="getBackgroundDisplay(image)">
</td>
</tr>
</tbody>
</table>
</div>
</accordion-group>
<accordion-group heading="Download configuration">
<div class="custom-control custom-switch">
......
......@@ -105,13 +105,17 @@ export class FormDatasetComponent implements OnChanges {
selectImage(): void {
const name = this.datasetFileExplorerPath + '/' + this.imageSelected.name;
this.datasetImages.push({ name, size: this.imageSelected.size, ...this.imageLimit });
let id = 1;
if (this.datasetImages.length > 0) {
id = Math.max(...this.datasetImages.map(i => i.id)) + 1;
}
this.datasetImages.push({ id, name, size: this.imageSelected.size, ...this.imageLimit });
this.modalRef.hide();
this.ngForm.controls['data_path'].markAsDirty();
}
deleteImage(image): void {
this.datasetImages = this.datasetImages.filter(i => i.name !== image.name);
this.datasetImages = this.datasetImages.filter(i => i.id !== image.id);
this.ngForm.controls['data_path'].markAsDirty();
}
......@@ -123,6 +127,24 @@ export class FormDatasetComponent implements OnChanges {
return this.datasetFamilyList.find(datasetFamily => datasetFamily.id === this.idDatasetFamilyQueryParam);
}
getBackgroundEnabled(image) {
const m = this.model.config.cone_search.background.find(i => i.id === image.id);
if (m) {
return m.enabled;
} else {
return false;
}
}
getBackgroundDisplay(image) {
const m = this.model.config.cone_search.background.find(i => i.id === image.id);
if (m) {
return m.display;
} else {
return image.id * 10;
}
}
onChange(surveyName: string): void {
this.changeSurvey.emit(this.surveyList.find(survey => survey.name === surveyName).id_database);
}
......@@ -146,7 +168,14 @@ export class FormDatasetComponent implements OnChanges {
opened: this.ngForm.form.value.cone_search_opened,
column_ra: +this.ngForm.form.value.column_ra,
column_dec: +this.ngForm.form.value.column_dec,
plot_enabled: this.ngForm.form.value.plot_enabled
plot_enabled: this.ngForm.form.value.plot_enabled,
sdss_enabled: this.ngForm.form.value.sdss_enabled,
sdss_display: this.ngForm.form.value.sdss_display,
background: this.datasetImages.map((v, i) => {
const e = `${v.id}_enabled`;
const d = `${v.id}_display`;
return {id: v.id, enabled: this.ngForm.form.value[e], display: this.ngForm.form.value[d]}
})
},
download: {
enabled: this.ngForm.form.value.download_enabled,
......
......@@ -21,6 +21,9 @@ export class Dataset implements Displayable {
column_ra: number;
column_dec: number;
plot_enabled: boolean;
sdss_enabled: boolean;
sdss_display: number;
background: {id: number, enabled: boolean, display: number}[];
},
download: {
enabled: boolean;
......@@ -58,7 +61,10 @@ export class Dataset implements Displayable {
opened: false,
column_ra: null,
column_dec: null,
plot_enabled: false
plot_enabled: false,
sdss_enabled: false,
sdss_display: 10,
background: []
},
download: {
enabled: true,
......
export interface Image {
id: number;
name: string;
size: number;
ra_min: number;
......
Markdown is supported
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