diff --git a/EnvelopeGenerator.Web/wwwroot/js/api-service.js b/EnvelopeGenerator.Web/wwwroot/js/api-service.js index e8de8cd6..07e8fead 100644 --- a/EnvelopeGenerator.Web/wwwroot/js/api-service.js +++ b/EnvelopeGenerator.Web/wwwroot/js/api-service.js @@ -9,6 +9,7 @@ const url = { share: `/api/readonly` }; +//#region request helper methods function submitForm(form) { fetch(form.action, { method: form.method, @@ -35,6 +36,11 @@ function createPost(url, body, contentType = 'application/json') { return createRequest('POST', url, body, contentType); } +function redirect(url) { + return window.location.href = url; +} +//#endregion + function signEnvelope(annotations) { return createPost(`/api/annotation`, annotations, contentType) } @@ -43,10 +49,6 @@ function rejectEnvelope(reason) { return createPost(url.reject, reason, Content.JSON); } -function redirect(url) { - return window.location.href = url; -} - function redirRejected() { return redirect(url.rejectRedir); } diff --git a/EnvelopeGenerator.Web/wwwroot/js/api-service.min.js b/EnvelopeGenerator.Web/wwwroot/js/api-service.min.js index c4c43c41..3af140fb 100644 --- a/EnvelopeGenerator.Web/wwwroot/js/api-service.min.js +++ b/EnvelopeGenerator.Web/wwwroot/js/api-service.min.js @@ -1 +1 @@ -function submitForm(n){fetch(n.action,{method:n.method,body:new FormData(n),headers:{"X-Requested-With":"XMLHttpRequest"}})}function createRequest(n,t,i,r="application/json"){return fetch(t,{credentials:"include",method:n,headers:{"Content-Type":r,"X-XSRF-TOKEN":env.xsrfToken},body:JSON.stringify(i)})}function createPost(n,t,i="application/json"){return createRequest("POST",n,t,i)}function signEnvelope(n){return createPost(`/api/annotation`,n,contentType)}function rejectEnvelope(n){return createPost(url.reject,n,Content.JSON)}function redirect(n){return window.location.href=n}function redirRejected(){return redirect(url.rejectRedir)}function shareEnvelope(n,t){return createPost(url.share,{receiverMail:n,dateValid:t},Content.JSON)}const env={xsrfToken:document.getElementsByName("__RequestVerificationToken")[0].value,envKey:document.querySelector('meta[name="env-key"]').getAttribute("content")},url={reject:`/api/annotation/reject`,rejectRedir:`/envelope/${env.envKey}`,share:`/api/readonly`}; \ No newline at end of file +function submitForm(n){fetch(n.action,{method:n.method,body:new FormData(n),headers:{"X-Requested-With":"XMLHttpRequest"}})}function createRequest(n,t,i,r="application/json"){return fetch(t,{credentials:"include",method:n,headers:{"Content-Type":r,"X-XSRF-TOKEN":env.xsrfToken},body:JSON.stringify(i)})}function createPost(n,t,i="application/json"){return createRequest("POST",n,t,i)}function redirect(n){return window.location.href=n}function signEnvelope(n){return createPost(`/api/annotation`,n,contentType)}function rejectEnvelope(n){return createPost(url.reject,n,Content.JSON)}function redirRejected(){return redirect(url.rejectRedir)}function shareEnvelope(n,t){return createPost(url.share,{receiverMail:n,dateValid:t},Content.JSON)}const env={xsrfToken:document.getElementsByName("__RequestVerificationToken")[0].value,envKey:document.querySelector('meta[name="env-key"]').getAttribute("content")},url={reject:`/api/annotation/reject`,rejectRedir:`/envelope/${env.envKey}`,share:`/api/readonly`}; \ No newline at end of file