diff --git a/assets/js/editor-assets.js b/assets/js/editor-assets.js index 6a209916..f209ab91 100644 --- a/assets/js/editor-assets.js +++ b/assets/js/editor-assets.js @@ -99,7 +99,15 @@ import { getElmById } from "./helper.mjs"; const emulateEditor = "F11"; const deleteEditor = "Delete"; const closeEditors = "F12"; + const approveRecord = "ArrowDown"; + let approve = document.getElementById("editor-online-true"); switch (event.key) { + case approveRecord: + if (approve) { + event.preventDefault(); + approve.click(); + } + break; case refresher: event.preventDefault(); location.reload(); diff --git a/public/js/editor-assets.min.js b/public/js/editor-assets.min.js index 09ceacca..c55adeed 100644 --- a/public/js/editor-assets.min.js +++ b/public/js/editor-assets.min.js @@ -1,2 +1,2 @@ /* editor-assets.min.js © Defacto2 2024 */ -(()=>{function d(r){let t=document.getElementById(r);if(t==null){console.error(`The ${r} for getElmById() element is null.`);return}return t}var L="is-invalid",v="d-none",R=100,y=1024*1024,C=100*y;async function q(r){if(r==null)throw new Error("The file value of checkSHA is null.");let t=await V(r),o=await fetch(`/uploader/sha384/${t}`,{method:"PATCH",headers:{"Content-Type":"text/plain"},body:t});if(!o.ok)throw new Error(`Hashing is not possible, server response: ${o.status}`);return await o.text()}async function V(r){if(r==null)throw new Error("The file value of sha384 is null.");try{let t=await r.arrayBuffer(),o=await crypto.subtle.digest("SHA-384",t);return Array.from(new Uint8Array(o)).map(c=>c.toString(16).padStart(2,"0")).join("")}catch(t){throw new Error(`Could not use arrayBuffer or crypto.subtle: ${t}`)}}function x(r,t){if(r==null)throw new Error("The formId value of progress is null.");if(t==null)throw new Error("The elementId value of progress is null.");htmx.on(`#${r}`,"htmx:xhr:progress",function(o){o.target.id==`${r}`&&htmx.find(`#${t}`).setAttribute("value",o.detail.loaded/o.detail.total*R)})}function S(r){if(r==null)throw new Error("The file value of checkSize is null.");return r.size>C?`The chosen file is too big at ${Math.round(r.size/y)}MB, maximum size is ${C/y}MB.`:""}function F(r,t,o,c){if(r==null)throw new Error("The errors value of checkErrors is null.");if(t==null)throw new Error("The alert value of checkErrors is null.");if(o==null)throw new Error("The fileInput value of checkErrors is null.");if(c==null)throw new Error("The results value of checkErrors is null.");r=r.filter(h=>h!=""),!(r.length<=0)&&(t.innerText=r.join(" "),t.classList.remove(v),o.innerText="",o.classList.add(L),c.classList.add(v))}async function A(r,t,o,c){if(r==null)throw new Error("The file value of checkDuplicate is null.");if(t==null)throw new Error("The alert value of checkDuplicate is null.");if(o==null)throw new Error("The fileInput value of checkDuplicate is null.");if(c==null)throw new Error("The results value of checkDuplicate is null.");let h=()=>{t.classList.remove(v),o.innerText="",o.classList.add(L),c.classList.add(v)},T="";try{let u=await q(r);if(u==""){t.innerText="";return}T=u}catch(u){console.log(`${u}`),t.innerText=`${u}`,h();return}t.innerText="The chosen file already exists in the database: ";let f=document.createElement("a");f.href=`/f/${T}`,f.innerText=`${r.name}`,t.appendChild(f),h()}function z(r,t,o){if(r==null)throw new Error("The fileInput value of resetInput is null.");if(t==null)throw new Error("The alert value of resetInput is null.");if(o==null)throw new Error("The results value of resetInput is null.");r.innerText="",r.classList.remove(L),t.innerText="",t.classList.add(v),o.innerText="",o.classList.add(v)}(()=>{"use strict";x("artifact-editor-dl-form","artifact-editor-dl-progress"),x("artifact-editor-preview-form","artifact-editor-preview-progress");let r=d("artifact-editor-preview-reset"),t=d("artifact-editor-replace-preview"),o=d("artifact-editor-preview-submit"),c=d("artifact-editor-dl-alert"),h=d("artifact-editor-dl-reset"),T=d("artifact-editor-last-modified"),f=d("artifact-editor-dl-results"),u=d("artifact-editor-dl-up");u.addEventListener("change",U);async function U(){z(u,c,f);let e=this.files[0],s=[S(e)];F(s,c,u,f),A(e,c,u,f);let n=e.lastModified,a=new Date().getTime(),i=60*60*1e3;a-n{location.reload()},500);return}if(e.detail.failed&&e.detail.xhr){a.classList.add(i),a.innerText=`Something on the server is not working, ${g.status} status: ${g.responseText}.`;return}a.classList.add(i),a.innerText="Something with the browser is not working, please try again or refresh the page."}function I(e,s,n,a){if(e.detail.elt===null||e.detail.elt.id!==`${s}`)return;let i=document.getElementById(n);if(i===null)throw new Error(`The htmx successful input element ${n} is null`);let l=document.getElementById(a);if(l===null)throw new Error(`The htmx successful feedback element ${a} is null`);if(e.detail.successful)return j(e,i,l);if(e.detail.failed&&e.detail.xhr)return H(e,i,l);P(i,l)}function j(e,s,n){let a=e.detail.xhr;n.innerText=`${a.responseText}`,n.classList.remove("invalid-feedback"),n.classList.add("valid-feedback"),s.classList.remove("is-invalid"),s.classList.add("is-valid"),setTimeout(()=>{location.reload()},500)}function H(e,s,n){let a=e.detail.xhr;n.innerText=`Something on the server is not working, ${a.status} status: ${a.responseText}.`,n.classList.remove("valid-feedback"),n.classList.add("invalid-feedback"),s.classList.remove("is-valid"),s.classList.add("is-invalid")}function P(e,s){e.classList.remove("is-valid"),e.classList.add("is-invalid"),s.innerText="Something with the browser is not working, please try again or refresh the page.",s.classList.remove("d-none")}h.addEventListener("click",function(){c.innerText="",c.classList.add("d-none"),u.value="",u.classList.remove("is-invalid","is-valid")}),r.addEventListener("click",function(){t.value="",t.classList.remove("is-invalid","is-valid")}),t.addEventListener("change",function(e){e.target.value.trim()!==""&&(console.log("Submitting the image or photo preview form"),o.click())})})();})(); +(()=>{function d(r){let t=document.getElementById(r);if(t==null){console.error(`The ${r} for getElmById() element is null.`);return}return t}var L="is-invalid",v="d-none",V=100,y=1024*1024,S=100*y;async function Y(r){if(r==null)throw new Error("The file value of checkSHA is null.");let t=await O(r),a=await fetch(`/uploader/sha384/${t}`,{method:"PATCH",headers:{"Content-Type":"text/plain"},body:t});if(!a.ok)throw new Error(`Hashing is not possible, server response: ${a.status}`);return await a.text()}async function O(r){if(r==null)throw new Error("The file value of sha384 is null.");try{let t=await r.arrayBuffer(),a=await crypto.subtle.digest("SHA-384",t);return Array.from(new Uint8Array(a)).map(c=>c.toString(16).padStart(2,"0")).join("")}catch(t){throw new Error(`Could not use arrayBuffer or crypto.subtle: ${t}`)}}function x(r,t){if(r==null)throw new Error("The formId value of progress is null.");if(t==null)throw new Error("The elementId value of progress is null.");htmx.on(`#${r}`,"htmx:xhr:progress",function(a){a.target.id==`${r}`&&htmx.find(`#${t}`).setAttribute("value",a.detail.loaded/a.detail.total*V)})}function F(r){if(r==null)throw new Error("The file value of checkSize is null.");return r.size>S?`The chosen file is too big at ${Math.round(r.size/y)}MB, maximum size is ${S/y}MB.`:""}function A(r,t,a,c){if(r==null)throw new Error("The errors value of checkErrors is null.");if(t==null)throw new Error("The alert value of checkErrors is null.");if(a==null)throw new Error("The fileInput value of checkErrors is null.");if(c==null)throw new Error("The results value of checkErrors is null.");r=r.filter(h=>h!=""),!(r.length<=0)&&(t.innerText=r.join(" "),t.classList.remove(v),a.innerText="",a.classList.add(L),c.classList.add(v))}async function z(r,t,a,c){if(r==null)throw new Error("The file value of checkDuplicate is null.");if(t==null)throw new Error("The alert value of checkDuplicate is null.");if(a==null)throw new Error("The fileInput value of checkDuplicate is null.");if(c==null)throw new Error("The results value of checkDuplicate is null.");let h=()=>{t.classList.remove(v),a.innerText="",a.classList.add(L),c.classList.add(v)},T="";try{let u=await Y(r);if(u==""){t.innerText="";return}T=u}catch(u){console.log(`${u}`),t.innerText=`${u}`,h();return}t.innerText="The chosen file already exists in the database: ";let f=document.createElement("a");f.href=`/f/${T}`,f.innerText=`${r.name}`,t.appendChild(f),h()}function U(r,t,a){if(r==null)throw new Error("The fileInput value of resetInput is null.");if(t==null)throw new Error("The alert value of resetInput is null.");if(a==null)throw new Error("The results value of resetInput is null.");r.innerText="",r.classList.remove(L),t.innerText="",t.classList.add(v),a.innerText="",a.classList.add(v)}(()=>{"use strict";x("artifact-editor-dl-form","artifact-editor-dl-progress"),x("artifact-editor-preview-form","artifact-editor-preview-progress");let r=d("artifact-editor-preview-reset"),t=d("artifact-editor-replace-preview"),a=d("artifact-editor-preview-submit"),c=d("artifact-editor-dl-alert"),h=d("artifact-editor-dl-reset"),T=d("artifact-editor-last-modified"),f=d("artifact-editor-dl-results"),u=d("artifact-editor-dl-up");u.addEventListener("change",j);async function j(){U(u,c,f);let e=this.files[0],i=[F(e)];A(i,c,u,f),z(e,c,u,f);let n=e.lastModified,o=new Date().getTime(),s=60*60*1e3;o-n{location.reload()},500);return}if(e.detail.failed&&e.detail.xhr){o.classList.add(s),o.innerText=`Something on the server is not working, ${g.status} status: ${g.responseText}.`;return}o.classList.add(s),o.innerText="Something with the browser is not working, please try again or refresh the page."}function I(e,i,n,o){if(e.detail.elt===null||e.detail.elt.id!==`${i}`)return;let s=document.getElementById(n);if(s===null)throw new Error(`The htmx successful input element ${n} is null`);let l=document.getElementById(o);if(l===null)throw new Error(`The htmx successful feedback element ${o} is null`);if(e.detail.successful)return H(e,s,l);if(e.detail.failed&&e.detail.xhr)return R(e,s,l);P(s,l)}function H(e,i,n){let o=e.detail.xhr;n.innerText=`${o.responseText}`,n.classList.remove("invalid-feedback"),n.classList.add("valid-feedback"),i.classList.remove("is-invalid"),i.classList.add("is-valid"),setTimeout(()=>{location.reload()},500)}function R(e,i,n){let o=e.detail.xhr;n.innerText=`Something on the server is not working, ${o.status} status: ${o.responseText}.`,n.classList.remove("valid-feedback"),n.classList.add("invalid-feedback"),i.classList.remove("is-valid"),i.classList.add("is-invalid")}function P(e,i){e.classList.remove("is-valid"),e.classList.add("is-invalid"),i.innerText="Something with the browser is not working, please try again or refresh the page.",i.classList.remove("d-none")}h.addEventListener("click",function(){c.innerText="",c.classList.add("d-none"),u.value="",u.classList.remove("is-invalid","is-valid")}),r.addEventListener("click",function(){t.value="",t.classList.remove("is-invalid","is-valid")}),t.addEventListener("change",function(e){e.target.value.trim()!==""&&(console.log("Submitting the image or photo preview form"),a.click())})})();})(); diff --git a/view/app/artifactlock.tmpl b/view/app/artifactlock.tmpl index 185d500f..7d8ae1bd 100644 --- a/view/app/artifactlock.tmpl +++ b/view/app/artifactlock.tmpl @@ -24,7 +24,7 @@

⛔ This new record is hidden from public access.
{{- if eq $disableApproval ""}} - If the data and images are correct, it can be approved. + If the data and images are correct, it can be approved. {{- end}}

{{- else}}