Commit 6199091b authored by Caillat Michel's avatar Caillat Michel
Browse files

Now modals containing measurements results have a copy and copy as json...

Now modals containing measurements results have a copy and copy as json buttons to store the contents of the modals in the clipboard
parent 5e5581f3
......@@ -608,13 +608,8 @@ var _marker_styles_f = function(feature) {
var coordinates = selectedFeature.getGeometry().getCoordinates();
let properties = selectedFeature.get("properties");
let level = properties["level"]["value"].toExponential(3);
let levelUnit = properties["level"]["unit"];
let title = 'Contour level at ' + level + ' ' + levelUnit;
infos_line.innerHTML = title;
if ("measurements" in properties) {
populateInfosBlock(title, properties["measurements"]);
infos_line.innerHTML += ' <button type="button" class="btn btn-outline-link btn-sm" data-toggle="modal" data-target="#ModalInfosBlock">etc.</button>';
yAFITSContoursViewer.highlight(selectedFeature);
yAFITSContoursViewer.selected(selectedFeature);
}
else {
document.getElementById('loading').style.display="block";
......@@ -629,9 +624,7 @@ var _marker_styles_f = function(feature) {
console.log(resp["result"]);
properties["measurements"]=resp["result"];
selectedFeature.set("properties",properties);
populateInfosBlock(title, properties["measurements"]);
infos_line.innerHTML += ' <button type="button" class="btn btn-outline-link btn-sm" data-toggle="modal" data-target="#ModalInfosBlock">etc.</button>';
yAFITSContoursViewer.highlight(selectedFeature);
yAFITSContoursViewer.selected(selectedFeature);
}
console.log('measureContour callback : exiting');
});
......@@ -1142,13 +1135,13 @@ $( document ).ready(function() {
markerFactory = new MarkerFactory(sliceViewer);
customControls.addButton(markerFactory.getButton());
yAFITSContoursViewer = new ContoursViewer(relFITSFilePath, sliceViewer);
yAFITSContoursViewer = new ContoursViewer(sliceViewer, infosBlock);
customControls.addButton(yAFITSContoursViewer.getButton());
yAFITSContoursGUI = new ContoursGUI();
yAFITSContoursGUI.connect(yAFITSContoursViewer, sliceViewer);
boxFactory = new BoxFactory(sliceViewer);
boxFactory = new BoxFactory(sliceViewer, infosBlock);
customControls.addButton(boxFactory.getButton());
$('a#rccap').click(function () {sliceViewer.refresh()});
......
<script>
class BoxFactory {
constructor (sliceViewer) {
constructor (sliceViewer, infosBlock) {
console.log("BoxFactory ctor: entering");
this.source;
......@@ -73,6 +73,8 @@ class BoxFactory {
this.button.onclick = f.bind(this);
this.isOpened = false;
this.infosBlock = infosBlock;
/*
** This is our dragbox interaction
*/
......@@ -204,9 +206,8 @@ class BoxFactory {
console.log("selected : entering");
let properties = feature.get("properties");
let title = "Flux in box : " + properties["measurements"]["sum"]["value"].toExponential(4) + " " + properties["measurements"]["sum"]["unit"];
infos_line.innerHTML = title;
infos_line.innerHTML += ' <button type="button" class="btn btn-outline-link btn-sm" data-toggle="modal" data-target="#ModalInfosBlock">etc.</button>';
populateInfosBlock(title, properties["measurements"]);
this.infosBlock.headline(title)
this.infosBlock.populate(title, properties["measurements"]);
this.highlight(feature);
console.log("selected : exiting");
}
......
<script>
class ContoursViewer {
constructor (relFITSFilePath, sliceViewer) {
constructor (sliceViewer, infosBlock) {
console.log("ContoursViewer ctor: entering");console.trace();
this.infosBlock = infosBlock;
this.source;
this.layer;
this.relFITSFilePath = relFITSFilePath;
this.sliceViewer = sliceViewer;
this.relFITSFilePath = this.sliceViewer.getRelFITSFilePath();
this.sliceIndex = this.sliceViewer.getSliceIndex();
this.map = sliceViewer.getMap();
this.infosBlock = infosBlock;
this.highlightStyle = new ol.style.Style({
fill: new ol.style.Fill({
......@@ -130,7 +134,6 @@ class ContoursViewer {
coordinates.push(coordinates[0]);
features.push(new ol.Feature( { geometry : new ol.geom.LineString(coordinates),
properties : contour["properties"]}))});
console.log("Number of features " + features.length);
this.source.addFeatures(features);
this.show();
console.log("importYAFITSContours: exiting");
......@@ -155,6 +158,18 @@ class ContoursViewer {
this.source.clear();
console.log("clear : exiting");
}
selected(feature) {
console.log("selected : entering");
let properties = feature.get("properties");
let level = properties["level"]["value"].toExponential(3);
let levelUnit = properties["level"]["unit"];
let title = 'Contour level at ' + level + ' ' + levelUnit;
this.infosBlock.headline(title)
this.infosBlock.populate(title, properties["measurements"]);
this.highlight(feature);
console.log("selected : exiting");
}
}; // End of class ContoursViewer
class ContoursGUI {
......@@ -496,7 +511,6 @@ class ContoursGUI {
</div>
</div>
<label class="control-label">Enter cumulative distribution function value[s] (comma separated if more than one)</label>
<div>
<input class="form-control" id="text_of_quantiles"></input>
</div>
......@@ -511,8 +525,6 @@ class ContoursGUI {
<button type="button" class="btn btn-success" id="clear-contours">Clear</button>
</div>
</div>
</form>
</div>
</div><!-- /.modal-content -->
......
......@@ -10,8 +10,12 @@
</div>
<div class="modal-body" id="ModalInfosBlockBody">
</div>
<textarea id="ModalHiddenInfosBlock" style="height:0px;width:0px;opacity:0">
</textarea>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" id="verbatimCopy" class="btn btn-primary btn-sm fas fa-files-o" data-tooltip="tooltip" title="Copy verbatim"></button>
<button type="button" id="jsonCopy" class="btn btn-primary btn-sm">Copy as JSON</button>
<button type="button" class="btn btn-primary btn-sm" data-dismiss="modal">Close</button>
</div>
</div>
</div>
......@@ -20,7 +24,60 @@
<script>
class InfosBlock {
constructor (sliceViewer) {
this.infosLine = document.getElementById('infos-line');
this.infosBlock = document.getElementById('ModalInfosBlockBody');
this.hiddenInfosBlock = document.getElementById('ModalHiddenInfosBlock');
this.verbatimCopyBtn = document.getElementById('verbatimCopy');
this.jsonCopyBtn = document.getElementById('jsonCopy');
$(sliceViewer.getMap().getTargetElement()).append($("#ModalInfosBlock"));
this.verbatimCopyBtn.onclick = this.verbatimCopy.bind(this);
this.jsonCopyBtn.onclick = this.jsonCopy.bind(this);
}
headline(title) {
this.infosLine.innerHTML = title;
this.infosLine.innerHTML += ' <button type="button" class="btn btn-outline-link btn-sm" data-toggle="modal" data-target="#ModalInfosBlock">etc.</button>';
}
populate(title, collection) {
console.log("populate: entering");
this.title = title;
this.collection = collection;
this.infosBlock.innerHTML = "<b>"+title+" <br><br>";
for (var k in collection) {
this.infosBlock.innerHTML += k + ":" + format(collection[k]["value"]) + " " + collection[k]["unit"] + "<br>";
}
console.log("populate: exiting");
}
verbatimCopy() {
console.log("verbatimCopy : entering");
this.hiddenInfosBlock.value = this.title + "\r\n\r\n";
for (var k in this.collection) {
this.hiddenInfosBlock.value += k + ":" + format(this.collection[k]["value"]) + " " + this.collection[k]["unit"] + "\r\n";
}
this.hiddenInfosBlock.select();
try {
var success = document.execCommand('copy');
}
catch (err){
alert("Copy failed. " + err);
}
console.log("verbatimCopy : exiting");
}
jsonCopy() {
console.log("jsonCopy : entering");
this.hiddenInfosBlock.value = JSON.stringify(this.collection);
this.hiddenInfosBlock.select();
try {
var success = document.execCommand('copy');
}
catch (err){
alert("Copy failed. " + err);
}
console.log("jsonCopy : exiting");
}
}
</script>
<script>
class Reset {
constructor(sliceViewer) {
constructor(sliceViewer, infosBlock) {
this.button = document.createElement("button");
this.button.setAttribute("type","button");
this.button.setAttribute("class", "btn btn-primary btn-sm");
this.button.setAttribute("data-tooltip", "tooltip");
this.button.setAttribute("title", "Reset zoom and position");
this.infosBlock = infosBlock;
let x = document.createElement("span");
x.setAttribute("class", "fas fa-home");
this.button.appendChild(x);
$(this.button).on("click", function(event) {sliceViewer.reset()});
}
......
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