Files
crater/public/build/assets/UpdateAppSetting.0045e27a.js
Mohit Panjwani 3a1f5a417f new build 506
2021-12-10 17:48:34 +05:30

2 lines
6.6 KiB
JavaScript

import{g as M,i as d,j as I,k as P,r as f,o as n,s as j,w as b,t,x as s,y as a,b as g,v as U,A as v,Z as R,al as O,c as r,F as L,H as V,z as Y}from"./vendor.e9042f2c.js";import{u as Z,c as G,t as J,h as T}from"./main.f55cd568.js";import{L as Q}from"./LoadingIcon.edb4fe20.js";const W={class:"pb-8 ml-0"},X={class:"text-sm not-italic font-medium input-label"},ee={class:"box-border flex w-16 p-3 my-2 text-sm text-gray-600 bg-gray-200 border border-gray-200 border-solid rounded-md version"},te={key:1,class:"mt-4 content"},se={class:"rounded-md bg-primary-50 p-4 mb-3"},ae={class:"flex"},ne={class:"flex-shrink-0"},ie={class:"ml-3"},re={class:"text-sm font-medium text-primary-800"},le={class:"mt-2 text-sm text-primary-700"},oe={class:"text-sm not-italic font-medium input-label"},de=t("br",null,null,-1),pe={class:"box-border flex w-16 p-3 my-2 text-sm text-gray-600 bg-gray-200 border border-gray-200 border-solid rounded-md version"},ue=["innerHTML"],ce={class:"text-sm not-italic font-medium input-label"},me={class:"w-1/2 mt-2 border-2 border-gray-200 BaseTable-fixed"},_e={width:"70%",class:"p-2 text-sm truncate"},fe={width:"30%",class:"p-2 text-sm text-right"},ge={key:0,class:"inline-block w-4 h-4 ml-3 mr-2 bg-green-500 rounded-full"},ve={key:1,class:"inline-block w-4 h-4 ml-3 mr-2 bg-red-500 rounded-full"},he={key:2,class:"relative flex justify-between mt-4 content"},ye={class:"m-0 mb-3 font-medium sw-section-title"},be={class:"mb-8 text-sm leading-snug text-gray-500",style:{"max-width":"480px"}},xe={key:3,class:"w-full p-0 list-none"},we={class:"m-0 text-sm leading-8"},ke={class:"flex flex-row items-center"},Be={key:0,class:"mr-3 text-xs text-gray-500"},Ke={setup(Ue){const x=Z(),{t:w,tm:$e}=M();G(),J();let h=d(!1),u=d(!1),$=d(""),k=d(""),c=d(null),C=d(null),l=d(!1);const B=I([{translationKey:"settings.update_app.download_zip_file",stepUrl:"/api/v1/update/download",time:null,started:!1,completed:!1},{translationKey:"settings.update_app.unzipping_package",stepUrl:"/api/v1/update/unzip",time:null,started:!1,completed:!1},{translationKey:"settings.update_app.copying_files",stepUrl:"/api/v1/update/copy",time:null,started:!1,completed:!1},{translationKey:"settings.update_app.deleting_files",stepUrl:"/api/v1/update/delete",time:null,started:!1,completed:!1},{translationKey:"settings.update_app.running_migrations",stepUrl:"/api/v1/update/migrate",time:null,started:!1,completed:!1},{translationKey:"settings.update_app.finishing_update",stepUrl:"/api/v1/update/finish",time:null,started:!1,completed:!1}]),y=I({isMinor:Boolean,installed:"",version:""});let q=d(null);window.addEventListener("beforeunload",e=>{l.value&&(e.returnValue="Update is in progress!")}),window.axios.get("/api/v1/app/version").then(e=>{k.value=e.data.version});const z=P(()=>c.value!==null?Object.keys(c.value).every(e=>c.value[e]):!0);function D(e){switch(N(e)){case"pending":return"text-primary-800 bg-gray-200";case"finished":return"text-teal-500 bg-teal-100";case"running":return"text-blue-400 bg-blue-100";case"error":return"text-danger bg-red-200";default:return""}}async function E(){try{u.value=!0;let e=await window.axios.get("/api/v1/check/update");if(u.value=!1,!e.data.version){x.showNotification({title:"Info!",type:"info",message:w("settings.update_app.latest_message")});return}e.data&&(y.isMinor=e.data.is_minor,y.version=e.data.version.version,$.value=e.data.version.description,c.value=e.data.version.extensions,h.value=!0,q.value=e.data.version.minimum_php_version,C.value=e.data.version.deleted_files)}catch(e){h.value=!1,u.value=!1,T(e)}}async function S(){let e=null;if(!z.value)return x.showNotification({type:"error",message:"Your current configuration does not match the update requirements. Please try again after all the requirements are fulfilled."}),!0;for(let p=0;p<B.length;p++){let i=B[p];try{l.value=!0,i.started=!0;let m={version:y.version,installed:k.value,deleted_files:C.value,path:e||null},_=await window.axios.post(i.stepUrl,m);i.completed=!0,_.data&&_.data.path&&(e=_.data.path),i.translationKey=="settings.update_app.finishing_update"&&(l.value=!1,x.showNotification({type:"success",message:w("settings.update_app.update_success")}),setTimeout(()=>{location.reload()},3e3))}catch(m){return i.started=!1,i.completed=!0,T(m),H(i.translationKey),!1}}}function H(e){if(w(e).value){S();return}l.value=!1}function N(e){return e.started&&e.completed?"finished":e.started&&!e.completed?"running":!e.started&&!e.completed?"pending":"error"}return(e,p)=>{const i=f("BaseButton"),m=f("BaseDivider"),_=f("BaseHeading"),A=f("BaseIcon"),F=f("BaseSettingCard");return n(),j(F,{title:e.$t("settings.update_app.title"),description:e.$t("settings.update_app.description")},{default:b(()=>[t("div",W,[t("label",X,s(e.$t("settings.update_app.current_version")),1),t("div",ee,s(a(k)),1),g(i,{loading:a(u),disabled:a(u)||a(l),variant:"primary-outline",class:"mt-6",onClick:E},{default:b(()=>[U(s(e.$t("settings.update_app.check_update")),1)]),_:1},8,["loading","disabled"]),a(h)?(n(),j(m,{key:0,class:"mt-6 mb-4"})):v("",!0),a(h)?R((n(),r("div",te,[g(_,{type:"heading-title",class:"mb-2"},{default:b(()=>[U(s(e.$t("settings.update_app.avail_update")),1)]),_:1}),t("div",se,[t("div",ae,[t("div",ne,[g(A,{name:"InformationCircleIcon",class:"h-5 w-5 text-primary-400","aria-hidden":"true"})]),t("div",ie,[t("h3",re,s(e.$t("general.note")),1),t("div",le,[t("p",null,s(e.$t("settings.update_app.update_warning")),1)])])])]),t("label",oe,s(e.$t("settings.update_app.next_version")),1),de,t("div",pe,s(a(y).version),1),t("div",{class:"pl-5 mt-4 mb-8 text-sm leading-snug text-gray-500 update-description",style:{"white-space":"pre-wrap","max-width":"480px"},innerHTML:a($)},null,8,ue),t("label",ce,s(e.$t("settings.update_app.requirements")),1),t("table",me,[(n(!0),r(L,null,V(a(c),(o,K)=>(n(),r("tr",{key:K,class:"p-2 border-2 border-gray-200"},[t("td",_e,s(K),1),t("td",fe,[o?(n(),r("span",ge)):(n(),r("span",ve))])]))),128))]),g(i,{class:"mt-10",variant:"primary",onClick:S},{default:b(()=>[U(s(e.$t("settings.update_app.update")),1)]),_:1})],512)),[[O,!a(l)]]):v("",!0),a(l)?(n(),r("div",he,[t("div",null,[t("h6",ye,s(e.$t("settings.update_app.update_progress")),1),t("p",be,s(e.$t("settings.update_app.progress_text")),1)]),g(Q,{class:"absolute right-0 h-6 m-1 animate-spin text-primary-400"})])):v("",!0),a(l)?(n(),r("ul",xe,[(n(!0),r(L,null,V(a(B),o=>(n(),r("li",{key:o.stepUrl,class:"flex justify-between w-full py-3 border-b border-gray-200 border-solid last:border-b-0"},[t("p",we,s(e.$t(o.translationKey)),1),t("div",ke,[o.time?(n(),r("span",Be,s(o.time),1)):v("",!0),t("span",{class:Y([D(o),"block py-1 text-sm text-center uppercase rounded-full"]),style:{width:"88px"}},s(N(o)),3)])]))),128))])):v("",!0)])]),_:1},8,["title","description"])}}};export{Ke as default};