|
@@ -35,19 +35,20 @@ const typeArray = [
|
|
|
["Oggetto", "Object"],
|
|
|
["Lettera", "Letter"],
|
|
|
["Opera d'Arte", "OA"],
|
|
|
- ["Persona", "Person"],
|
|
|
- ["Luogo", "Place"]
|
|
|
+ ["Persona", "Person"]
|
|
|
];
|
|
|
|
|
|
const graphArray = [
|
|
|
- ["ASPO - Datini", "http://dev.restore.ovi.cnr.it:8890/aspo/datini"],
|
|
|
- ["ASPO - Ospedale", "http://dev.restore.ovi.cnr.it:8890/aspo/ospedale"],
|
|
|
- ["ASPO - Marcovaldi", "http://dev.restore.ovi.cnr.it:8890/aspo/marcovaldi"],
|
|
|
- ["ASPO - Gettatelli", "http://dev.restore.ovi.cnr.it:8890/aspo/gettatelli"],
|
|
|
- ["MPP - Collezione Martini", "http://dev.restore.ovi.cnr.it:8890/mpp/martini"],
|
|
|
- ["MPP - Collezione Ospedale", "http://dev.restore.ovi.cnr.it:8890/mpp/ospedale"],
|
|
|
- ["MPP - Collezione Datini", "http://dev.restore.ovi.cnr.it:8890/mpp/datini"],
|
|
|
- ["OVI - Lettere", "http://dev.restore.ovi.cnr.it:8890/ovi/datini"]
|
|
|
+ ["ASPO - Datini", "http://dev.restore.ovi.cnr.it:8890/aspo/datini", "Object"],
|
|
|
+ ["ASPO - Ospedale", "http://dev.restore.ovi.cnr.it:8890/aspo/ospedale", "Object"],
|
|
|
+ ["ASPO - Marcovaldi", "http://dev.restore.ovi.cnr.it:8890/aspo/marcovaldi", "Object"],
|
|
|
+ ["ASPO - Onomastica Ospedale", "http://dev.restore.ovi.cnr.it:8890/aspo/gettatelli", "Person"],
|
|
|
+ ["ASPO - Onomastica Datini", "http://dev.restore.ovi.cnr.it:8890/aspo/onomastica", "Person"],
|
|
|
+ ["MPP - Artisti", "http://dev.restore.ovi.cnr.it:8890/mpp/autori", "Person"],
|
|
|
+ ["MPP - Collezione Martini", "http://dev.restore.ovi.cnr.it:8890/mpp/martini", "Artwork"],
|
|
|
+ ["MPP - Collezione Ospedale", "http://dev.restore.ovi.cnr.it:8890/mpp/ospedale", "Artwork"],
|
|
|
+ ["MPP - Collezione Datini", "http://dev.restore.ovi.cnr.it:8890/mpp/datini", "Artwork"],
|
|
|
+ ["OVI - Lettere", "http://dev.restore.ovi.cnr.it:8890/ovi/datini", "Letter"]
|
|
|
];
|
|
|
|
|
|
const objectArray = [];
|
|
@@ -73,16 +74,6 @@ $(document).ready(function () {
|
|
|
type_selector.add(opt);
|
|
|
}
|
|
|
|
|
|
- let y = graphArray.length;
|
|
|
-
|
|
|
- for(var i=0; i<y; i++) {
|
|
|
- var opt = document.createElement("option");
|
|
|
- opt.value= graphArray[i][1];
|
|
|
- opt.innerHTML = graphArray[i][0]; // whatever property it has
|
|
|
-
|
|
|
- // then append it to the select element
|
|
|
- collection_selector.add(opt);
|
|
|
- }
|
|
|
|
|
|
let z = choiceArray.length;
|
|
|
|
|
@@ -120,24 +111,30 @@ $(document).ready(function () {
|
|
|
$( ".container_choice" ).remove();
|
|
|
if (selOpt == "Object") {
|
|
|
addToListObject();
|
|
|
+ populateSelGraph("Object");
|
|
|
}
|
|
|
- if (selOpt == "OA") {
|
|
|
+ else if (selOpt == "OA") {
|
|
|
addToListOA();
|
|
|
+ populateSelGraph("Artwork");
|
|
|
}
|
|
|
- if (selOpt == "Person") {
|
|
|
+ else if (selOpt == "Person") {
|
|
|
addToListPerson();
|
|
|
+ populateSelGraph("Person");
|
|
|
}
|
|
|
- if (selOpt == "Letter") {
|
|
|
+ else if (selOpt == "Letter") {
|
|
|
addToListLetter();
|
|
|
- }
|
|
|
+ populateSelGraph("Letter");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ addToList();
|
|
|
+ populateSelGraph("General");
|
|
|
+ }
|
|
|
}).change();
|
|
|
|
|
|
/*$('[name=sel-parent]').on('change', function() {
|
|
|
$(this).attr("id", 'example' + $(this).name());
|
|
|
});*/
|
|
|
|
|
|
- addToList();
|
|
|
-
|
|
|
});
|
|
|
|
|
|
|
|
@@ -236,20 +233,25 @@ function addToListPlace() {
|
|
|
|
|
|
//Get parameters from select and input options to build the query
|
|
|
function getParameters() {
|
|
|
- const arr = [];
|
|
|
- const collection = document.getElementsByClassName("advanced-form-select");
|
|
|
- for (let i = 0; i < collection.length; i++) {
|
|
|
- var x = collection[i].id;
|
|
|
- var t = document.getElementById(x);
|
|
|
- var e = t.options[t.selectedIndex].text;
|
|
|
- var numberId= x.split("-")[1]
|
|
|
- var inputId = "inputchoiceSelector_" + numberId;
|
|
|
- var inputText = document.getElementById(inputId).value;
|
|
|
- var el = [e, inputText];
|
|
|
- arr.push(el);
|
|
|
+ var cc = document.getElementById("type_selector").value;
|
|
|
+ if (cc != "General") {
|
|
|
+ const arr = [];
|
|
|
+ const collection = document.getElementsByClassName("advanced-form-select");
|
|
|
+ for (let i = 0; i < collection.length; i++) {
|
|
|
+ var x = collection[i].id;
|
|
|
+ var t = document.getElementById(x);
|
|
|
+ var e = t.options[t.selectedIndex].text;
|
|
|
+ var numberId= x.split("-")[1]
|
|
|
+ var inputId = "inputchoiceSelector_" + numberId;
|
|
|
+ var inputText = document.getElementById(inputId).value;
|
|
|
+ var el = [e, inputText];
|
|
|
+ arr.push(el);
|
|
|
+ }
|
|
|
+ constructQuery(arr);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ alert("Seleziona una categoria")
|
|
|
}
|
|
|
-
|
|
|
- constructQuery(arr);
|
|
|
/*$('#query_results').append(arr);
|
|
|
testo = $('input#writeText').val();*/
|
|
|
}
|
|
@@ -924,6 +926,40 @@ function query_handle_json(json, choosen_type) {
|
|
|
document.getElementById("n_res").innerHTML = i;
|
|
|
}
|
|
|
|
|
|
+function populateSelGraph(graphType) {
|
|
|
+ let y = graphArray.length;
|
|
|
+
|
|
|
+ collection_selector.innerHTML = "";
|
|
|
+
|
|
|
+ if (graphType != "General") {
|
|
|
+ collection_selector.style.color = '#202122';
|
|
|
+ collection_selector.style.cursor = 'pointer';
|
|
|
+ collection_selector.style.backgroundColor = '#f8f9fa';
|
|
|
+ collection_selector.style.backgroundImage = 'linear-gradient(to top, #fff, #fff 33%)';
|
|
|
+ } else {
|
|
|
+ collection_selector.style.color = '#a1a1a1';
|
|
|
+ collection_selector.style.cursor = 'not-allowed';
|
|
|
+ collection_selector.style.backgroundColor = '#eee';
|
|
|
+ collection_selector.style.backgroundImage = 'linear-gradient(to top, #ddd, #eee 33%)';
|
|
|
+ }
|
|
|
+
|
|
|
+ var genOpt = document.createElement("option");
|
|
|
+ genOpt.value= "";
|
|
|
+ genOpt.innerHTML = "Tutte le Collezioni";
|
|
|
+ collection_selector.add(genOpt);
|
|
|
+
|
|
|
+ for(var i=0; i<y; i++) {
|
|
|
+ if (graphType == graphArray[i][2]) {
|
|
|
+ var opt = document.createElement("option");
|
|
|
+ opt.value= graphArray[i][1];
|
|
|
+ opt.innerHTML = graphArray[i][0]; // whatever property it has
|
|
|
+
|
|
|
+ // then append it to the select element
|
|
|
+ collection_selector.add(opt);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
function renameCol(param) {
|
|
|
if (param == "label") {
|
|
|
return ("Denominazione");
|
|
@@ -1022,3 +1058,33 @@ function renameCol(param) {
|
|
|
return (param);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+function download_table_as_csv(separator = ',') {
|
|
|
+ // Select rows from table_id
|
|
|
+ var rows = document.querySelectorAll('#query_results .row');
|
|
|
+ // Construct csv
|
|
|
+ var csv = [];
|
|
|
+ for (var i = 0; i < rows.length; i++) {
|
|
|
+ var row = [], cols = rows[i].querySelectorAll('.col-auto');
|
|
|
+ for (var j = 0; j < cols.length; j++) {
|
|
|
+ // Clean innertext to remove multiple spaces and jumpline (break csv)
|
|
|
+ var data = cols[j].innerText.replace(/(\r\n|\n|\r)/gm, '').replace(/(\s\s)/gm, ' ')
|
|
|
+ // Escape double-quote with double-double-quote (see https://stackoverflow.com/questions/17808511/properly-escape-a-double-quote-in-csv)
|
|
|
+ data = data.replace(/"/g, '""');
|
|
|
+ // Push escaped string
|
|
|
+ row.push('"' + data + '"');
|
|
|
+ }
|
|
|
+ csv.push(row.join(separator));
|
|
|
+ }
|
|
|
+ var csv_string = csv.join('\n');
|
|
|
+ // Download it
|
|
|
+ var filename = 'export_queryResults_' + new Date().toLocaleDateString() + '.csv';
|
|
|
+ var link = document.createElement('a');
|
|
|
+ link.style.display = 'none';
|
|
|
+ link.setAttribute('target', '_blank');
|
|
|
+ link.setAttribute('href', 'data:text/csv;charset=utf-8,' + encodeURIComponent(csv_string));
|
|
|
+ link.setAttribute('download', filename);
|
|
|
+ document.body.appendChild(link);
|
|
|
+ link.click();
|
|
|
+ document.body.removeChild(link);
|
|
|
+}
|