@igea/oac_frontend 1.0.62 → 1.0.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@igea/oac_frontend",
3
- "version": "1.0.62",
3
+ "version": "1.0.64",
4
4
  "description": "Frontend service for the OAC project",
5
5
  "main": "src/index.js",
6
6
  "bin": {
Binary file
Binary file
@@ -13,6 +13,8 @@ const sequenceValues = ["$UUID$",
13
13
  "$SEQ4$", "$SEQ5$", "$SEQ6$",
14
14
  "$SEQ7$", "$SEQ8$", "$SEQ9$"
15
15
  ];
16
+
17
+ const uploadValues = ["$UPLOAD$"];
16
18
 
17
19
  document.addEventListener('DOMContentLoaded', () => {
18
20
  const el = document.getElementById(appId);
@@ -181,14 +183,85 @@ document.addEventListener('DOMContentLoaded', () => {
181
183
  const shadow = form.shadowRoot;
182
184
  if (!shadow) return false;
183
185
 
184
- const rokitInputList = Array.from(shadow.querySelectorAll("rokit-input"))
186
+ const rokitSequenceList = Array.from(shadow.querySelectorAll("rokit-input"))
185
187
  .filter(l => sequenceValues.some(v =>
186
188
  (l.placeholder || '').toLowerCase().includes(v.toLowerCase())
187
189
  ));
190
+
191
+ const rokitUploadList = Array.from(shadow.querySelectorAll("rokit-input"))
192
+ .filter(l => uploadValues.some(v =>
193
+ (l.placeholder || '').toLowerCase().includes(v.toLowerCase())
194
+ ));
188
195
 
189
- if (rokitInputList.length == 0) return false;
190
- for(var i=0; i<rokitInputList.length; i++){
191
- const rokitInput = rokitInputList[i];
196
+ if (rokitSequenceList.length + rokitUploadList.length == 0)
197
+ return false;
198
+
199
+ // Uploads
200
+ for(var i=0; i<rokitUploadList.length; i++){
201
+ const rokitInput = rokitUploadList[i];
202
+ const container = rokitInput.closest(".property-instance");
203
+ const label = container.querySelector("label");
204
+ if (rokitInput) {
205
+ rokitInput.setAttribute("disabled", "true");
206
+ rokitInput.style.opacity = "0.0";
207
+ rokitInput.style.pointerEvents = "none";
208
+
209
+ // Aggiungo bottone IMG per upload
210
+ let next = label.nextElementSibling;
211
+ let imgClass = "search-identifier-icon";
212
+ if (!(next && next.tagName === "IMG"
213
+ && next.classList.contains(imgClass))) {
214
+ // creo immagine
215
+ const img = document.createElement("img");
216
+ img.src = "/frontend/images/upload.png";
217
+ img.style.width = "24px"; img.style.height = "24px";
218
+ img.style["margin-left"] = "5px"; img.style["margin-right"] = "5px";
219
+ img.style.cursor = "pointer";
220
+ img.classList.add(imgClass);
221
+ img._mode = "UPLOAD";
222
+ if(rokitInput.value !== "")
223
+ img._mode = "DOWNLOAD";
224
+ img.onclick = function(){
225
+ if(img._mode == "DOWNLOAD"){
226
+ window.open(rokitInput.value,"_BLANK");
227
+ return;
228
+ }
229
+ // Crea un input file nascosto
230
+ const fileInput = document.createElement("input");
231
+ fileInput.type = "file";
232
+ fileInput.style.display = "none";
233
+ document.body.appendChild(fileInput);
234
+ fileInput.onchange = async function() {
235
+ const file = fileInput.files[0];
236
+ if (!file) return;
237
+ const formData = new FormData();
238
+ formData.append("file", file);
239
+ try {
240
+ const response = await axios.post("/backend/fuseki/attachment", formData, {
241
+ headers: { "Content-Type": "multipart/form-data" }
242
+ });
243
+ console.log(response.data);
244
+ if(response.data.success){
245
+ rokitInput.style.opacity = "0.6";
246
+ rokitInput.value = response.data.data;
247
+ img._mode = "DOWNLOAD";
248
+ img.src = "/frontend/images/download.png";
249
+ }
250
+ } catch (error) {
251
+ console.error(error);
252
+ }
253
+ document.body.removeChild(fileInput);
254
+ };
255
+ fileInput.click();
256
+ }
257
+ // inserisco subito dopo la label
258
+ label.insertAdjacentElement("afterend", img);
259
+ }
260
+ }
261
+ }
262
+ // Sequences
263
+ for(var i=0; i<rokitSequenceList.length; i++){
264
+ const rokitInput = rokitSequenceList[i];
192
265
  const container = rokitInput.closest(".property-instance");
193
266
  const label = container.querySelector("label");
194
267
 
@@ -203,8 +276,7 @@ document.addEventListener('DOMContentLoaded', () => {
203
276
  rokitInput.style.pointerEvents = "none";
204
277
 
205
278
  var escludeSearchButton = templateIRIToExcludeFromSearch.includes(rokitInput.placeholder);
206
-
207
- //escludeSearchButton = false;
279
+ escludeSearchButton = true; //FORCED to true (we need to understand if the serach button will require specific placeholders: $SEARCH1$)
208
280
  if(_this.enabled && !escludeSearchButton){
209
281
  // Aggiungo bottone IMG per la ricerca
210
282
  let next = label.nextElementSibling;
@@ -63,32 +63,32 @@
63
63
  <div class="menu-item has-submenu {% if '/search' in currentPath %}open{% endif %}">
64
64
  <a href="#" class="submenu-toggle">
65
65
  <i class="fa-solid fa-magnifying-glass"></i>
66
- <span>{{ t('search.title')|default('Ricerca') }}</span>
66
+ <span>{{ t('search.fast.title')|default('Ricerca') }}</span>
67
67
  <i class="fa-solid fa-chevron-down submenu-arrow"></i>
68
68
  </a>
69
69
  <div class="submenu">
70
- <a href="/{{ root }}/search/advanced" class="{% if '/search/advanced' in currentPath %}active{% endif %}">
71
- <i class="fa-solid fa-magnifying-glass-dollar"></i>
72
- <span>{{ t('search.advanced.title') }}</span>
73
- </a>
70
+
74
71
  <a href="/{{ root }}/search/fast/1" class="{% if '/search/fast/1' in currentPath %}active{% endif %}">
75
- <i class="fa-solid fa-magnifying-glass"></i>
76
- <span>{{ t('search.fast.investigations') }}</span>
72
+ <i></i><span>{{ t('search.fast.investigations') }}</span>
77
73
  </a>
78
74
  <a href="/{{ root }}/search/fast/2" class="{% if '/search/fast/2' in currentPath %}active{% endif %}">
79
- <i class="fa-solid fa-magnifying-glass"></i>
80
- <span>{{ t('search.fast.samples') }}</span>
75
+ <i></i><span>{{ t('search.fast.samples') }}</span>
81
76
  </a>
82
77
  <a href="/{{ root }}/search/fast/3" class="{% if '/search/fast/3' in currentPath %}active{% endif %}">
83
- <i class="fa-solid fa-magnifying-glass"></i>
84
- <span>{{ t('search.fast.diagnostics') }}</span>
78
+ <i></i><span>{{ t('search.fast.diagnostics') }}</span>
85
79
  </a>
86
80
  <a href="/{{ root }}/search/fast/4" class="{% if '/search/fast/4' in currentPath %}active{% endif %}">
87
- <i class="fa-solid fa-magnifying-glass"></i>
88
- <span>{{ t('search.fast.materials') }}</span>
89
- </a>
81
+ <i></i><span>{{ t('search.fast.materials') }}</span>
82
+ </a>
90
83
  </div>
91
84
  </div>
85
+
86
+ <div class="menu-item">
87
+ <a href="/{{ root }}/search/advanced" class="{% if '/search/advanced' in currentPath %}active{% endif %}">
88
+ <i class="fa-solid fa-magnifying-glass-dollar"></i>
89
+ <span>{{ t('search.advanced.title') }}</span>
90
+ </a>
91
+ </div>
92
92
 
93
93
  <hr class="menu-divider">
94
94