core-recommendedapps.mjs 4.8 KB

12
  1. /*! third party licenses: dist/vendor.LICENSE.txt */
  2. import{bS as a,bT as i,F as d,b_ as m,bR as r,bZ as p,aV as c}from"./core-common.mjs";import{l as s}from"./chunks/logger-7CwbMBAx.mjs";import{p as u}from"./chunks/index-BhGDpaQm.mjs";import{n as g}from"./chunks/icons-TElqpmA8.mjs";import"./chunks/index-CiG5J8j_.mjs";const o={calendar:{description:a("core","Schedule work & meetings, synced with all your devices."),icon:i("core","places/calendar.svg")},contacts:{description:a("core","Keep your colleagues and friends in one place without leaking their private info."),icon:i("core","places/contacts.svg")},mail:{description:a("core","Simple email app nicely integrated with Files, Contacts and Calendar."),icon:i("core","actions/mail.svg")},spreed:{description:a("core","Chatting, video calls, screensharing, online meetings and web conferencing – in your browser and with mobile apps."),icon:i("core","apps/spreed.svg")},richdocuments:{name:"Nextcloud Office",description:a("core","Collaborative documents, spreadsheets and presentations, built on Collabora Online."),icon:i("core","apps/richdocuments.svg")},notes:{description:a("core","Distraction free note taking app."),icon:i("core","apps/notes.svg")},richdocumentscode:{hidden:!0}},h=Object.keys(o),f={name:"RecommendedApps",components:{NcButton:d},data(){return{showInstallButton:!1,installingApps:!1,loadingApps:!0,loadingAppsError:!1,apps:[],defaultPageUrl:m("core","defaultPageUrl")}},computed:{recommendedApps(){return this.apps.filter(e=>h.includes(e.id))}},async mounted(){try{const{data:e}=await r.get(p("settings/apps/list"));s.info("".concat(e.apps.length," apps fetched")),this.apps=e.apps.map(n=>Object.assign(n,{loading:!1,installationError:!1})),s.debug("".concat(this.recommendedApps.length," recommended apps found"),{apps:this.recommendedApps}),this.showInstallButton=!0}catch(e){s.error("could not fetch app list",{error:e}),this.loadingAppsError=!0}finally{this.loadingApps=!1}},methods:{installApps(){this.showInstallButton=!1,this.installingApps=!0;const e=u(1),n=this.recommendedApps.filter(t=>!t.active&&t.isCompatible&&t.canInstall).map(t=>e(()=>(s.info("installing ".concat(t.id)),t.loading=!0,r.post(p("settings/apps/enable"),{appIds:[t.id],groups:[]}).catch(l=>{s.error("could not install ".concat(t.id),{error:l}),t.installationError=!0}).then(()=>{s.info("installed ".concat(t.id)),t.loading=!1}))));s.debug("installing ".concat(n.length," recommended apps")),Promise.all(n).then(()=>{s.info("all recommended apps installed, redirecting …"),window.location=this.defaultPageUrl}).catch(t=>s.error("could not install recommended apps",{error:t}))},customIcon(e){return!(e in o)||!o[e].icon?(s.warn("no app icon for recommended app ".concat(e)),i("core","places/default-app-icon.svg")):o[e].icon},customName(e){return e.id in o&&o[e.id].name||e.name},customDescription(e){return e in o?o[e].description:(s.warn("no app description for recommended app ".concat(e)),"")},isHidden(e){return e in o?!!o[e].hidden:!1}}};var v=function(){var e=this,n=e._self._c;return n("div",{staticClass:"guest-box"},[n("h2",[e._v(e._s(e.t("core","Recommended apps")))]),e.loadingApps?n("p",{staticClass:"loading text-center"},[e._v(" "+e._s(e.t("core","Loading apps …"))+" ")]):e.loadingAppsError?n("p",{staticClass:"loading-error text-center"},[e._v(" "+e._s(e.t("core","Could not fetch list of apps from the App Store."))+" ")]):e.installingApps?n("p",{staticClass:"text-center"},[e._v(" "+e._s(e.t("core","Installing apps …"))+" ")]):e._e(),e._l(e.recommendedApps,function(t){return n("div",{key:t.id,staticClass:"app"},[e.isHidden(t.id)?e._e():[n("img",{attrs:{src:e.customIcon(t.id),alt:""}}),n("div",{staticClass:"info"},[n("h3",[e._v(" "+e._s(e.customName(t))+" "),t.loading?n("span",{staticClass:"icon icon-loading-small-dark"}):t.active?n("span",{staticClass:"icon icon-checkmark-white"}):e._e()]),n("p",{domProps:{innerHTML:e._s(e.customDescription(t.id))}}),t.installationError?n("p",[n("strong",[e._v(e._s(e.t("core","App download or installation failed")))])]):t.isCompatible?t.canInstall?e._e():n("p",[n("strong",[e._v(e._s(e.t("core","Cannot install this app")))])]):n("p",[n("strong",[e._v(e._s(e.t("core","Cannot install this app because it is not compatible")))])])])]],2)}),n("div",{staticClass:"dialog-row"},[e.showInstallButton?n("NcButton",{attrs:{type:"tertiary",role:"link",href:e.defaultPageUrl}},[e._v(" "+e._s(e.t("core","Skip"))+" ")]):e._e(),e.showInstallButton?n("NcButton",{attrs:{type:"primary"},on:{click:function(t){return t.stopPropagation(),t.preventDefault(),e.installApps.apply(null,arguments)}}},[e._v(" "+e._s(e.t("core","Install recommended apps"))+" ")]):e._e()],1)],2)},_=[],b=g(f,v,_,!1,null,"aa74520e");const w=b.exports;c.mixin({methods:{t:a}});const A=c.extend(w);new A().$mount("#recommended-apps"),s.debug("recommended apps view rendered");