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

Add and edit images for dataset => done

parent 405514bc
......@@ -67,7 +67,11 @@
<th scope="col">Size</th>
<th scope="col">RA min/max</th>
<th scope="col">DEC min/max</th>
<th scope="col">Action</th>
<th scope="col">Stretch</th>
<th scope="col">Pmin</th>
<th scope="col">Pmax</th>
<th scope="col">Edit</th>
<th scope="col">Delete</th>
</tr>
</thead>
<tbody>
......@@ -76,6 +80,14 @@
<td class="align-middle">{{ image.size | formatFileSize: false }}</td>
<td class="align-middle">[{{ image.ra_min }} ; {{ image.ra_max }}]</td>
<td class="align-middle">[{{ image.dec_min }} ; {{ image.dec_max }}]</td>
<td class="align-middle">{{ image.stretch }}</td>
<td class="align-middle">{{ image.pmin }}</td>
<td class="align-middle">{{ image.pmax }}</td>
<td class="align-middle">
<button (click)="editImageOpenModal(templateEditImage, image)" title="Edit this image" class="btn btn-outline-primary" type="button">
<span class="fas fa-edit"></span>
</button>
</td>
<td class="align-middle">
<button title="Delete this image" (click)="deleteImage(image)" class="btn btn-outline-danger">
<span class="fas fa-trash-alt"></span>
......@@ -329,4 +341,62 @@
</span>
</button>
</div>
</ng-template>
<ng-template #templateEditImage>
<div class="modal-header">
<h4 class="modal-title pull-left">Edit an image</h4>
</div>
<div class="modal-body">
{{ imageSelected | json }}
<form name="formImage" #fi="ngForm" novalidate>
<div class="form-group">
<label for="name">Name</label>
<input id="name" type="text" class="form-control" name="name" [ngModel]="imageSelected.name" [disabled]="imageSelected.name" required>
</div>
<div class="form-group">
<label for="name">Size</label>
<input id="name" type="text" class="form-control" name="size" [ngModel]="imageSelected.size" [disabled]="imageSelected.size" required>
</div>
<div class="form-group">
<label for="name">Ra min</label>
<input id="name" type="text" class="form-control" name="ra_min" [ngModel]="imageSelected.ra_min" [disabled]="imageSelected.ra_min" required>
</div>
<div class="form-group">
<label for="name">Ra max</label>
<input id="name" type="text" class="form-control" name="ra_max" [ngModel]="imageSelected.ra_max" [disabled]="imageSelected.ra_max" required>
</div>
<div class="form-group">
<label for="name">Dec min</label>
<input id="name" type="text" class="form-control" name="dec_min" [ngModel]="imageSelected.dec_min" [disabled]="imageSelected.dec_min" required>
</div>
<div class="form-group">
<label for="name">Dec max</label>
<input id="name" type="text" class="form-control" name="dec_max" [ngModel]="imageSelected.dec_max" [disabled]="imageSelected.dec_max" required>
</div>
<div class="form-group">
<label for="stretch">Stretch</label>
<select id="stretch" class="form-control" name="stretch" [ngModel]="imageSelected.stretch" required>
<option value="linear">Linear</option>
<option value="sqrt">Sqrt</option>
</select>
</div>
<div class="form-group">
<label for="name">Pmin</label>
<input id="name" type="number" step="0.01" min="0" max="100" class="form-control" name="pmin" [ngModel]="imageSelected.pmin" required>
</div>
<div class="form-group">
<label for="name">Pmax</label>
<input id="name" type="number" step="0.01" min="0" max="100" class="form-control" name="pmax" [ngModel]="imageSelected.pmax" required>
</div>
</form>
</div>
<div class="modal-footer">
<button (click)="modalRef.hide()" class="btn btn-danger">Cancel</button>
&nbsp;
<button [disabled]="!fi.form.valid || fi.form.pristine" (click)="editImage(fi.form.value)"
type="submit" class="btn btn-primary">
<i class="fa fa-database"></i> Update image information
</button>
</div>
</ng-template>
\ No newline at end of file
......@@ -109,7 +109,32 @@ export class FormDatasetComponent implements OnChanges {
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.datasetImages.push({
id,
name,
size: this.imageSelected.size,
...this.imageLimit,
stretch: 'linear',
pmin: 0.25,
pmax: 99.75
});
this.modalRef.hide();
this.ngForm.controls['data_path'].markAsDirty();
}
editImageOpenModal(template: TemplateRef<any>, image) {
this.imageSelected = image;
this.modalRef = this.modalService.show(template);
}
editImage(image) {
this.datasetImages = [
...this.datasetImages.filter(i => i.id !== this.imageSelected.id),
{
...this.imageSelected,
...image
}
];
this.modalRef.hide();
this.ngForm.controls['data_path'].markAsDirty();
}
......
......@@ -6,4 +6,7 @@ export interface Image {
ra_max: number;
dec_min: number;
dec_max: number;
stretch: string;
pmin: number;
pmax: number;
}
\ No newline at end of file
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