1 |
- {"version":3,"file":"core-recommendedapps.mjs","sources":["../core/src/components/setup/RecommendedApps.vue","../core/src/recommendedapps.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors\n - SPDX-License-Identifier: AGPL-3.0-or-later\n-->\n\n<template>\n\t<div class=\"guest-box\">\n\t\t<h2>{{ t('core', 'Recommended apps') }}</h2>\n\t\t<p v-if=\"loadingApps\" class=\"loading text-center\">\n\t\t\t{{ t('core', 'Loading apps …') }}\n\t\t</p>\n\t\t<p v-else-if=\"loadingAppsError\" class=\"loading-error text-center\">\n\t\t\t{{ t('core', 'Could not fetch list of apps from the App Store.') }}\n\t\t</p>\n\t\t<p v-else-if=\"installingApps\" class=\"text-center\">\n\t\t\t{{ t('core', 'Installing apps …') }}\n\t\t</p>\n\n\t\t<div v-for=\"app in recommendedApps\" :key=\"app.id\" class=\"app\">\n\t\t\t<template v-if=\"!isHidden(app.id)\">\n\t\t\t\t<img :src=\"customIcon(app.id)\" alt=\"\">\n\t\t\t\t<div class=\"info\">\n\t\t\t\t\t<h3>\n\t\t\t\t\t\t{{ customName(app) }}\n\t\t\t\t\t\t<span v-if=\"app.loading\" class=\"icon icon-loading-small-dark\" />\n\t\t\t\t\t\t<span v-else-if=\"app.active\" class=\"icon icon-checkmark-white\" />\n\t\t\t\t\t</h3>\n\t\t\t\t\t<p v-html=\"customDescription(app.id)\" />\n\t\t\t\t\t<p v-if=\"app.installationError\">\n\t\t\t\t\t\t<strong>{{ t('core', 'App download or installation failed') }}</strong>\n\t\t\t\t\t</p>\n\t\t\t\t\t<p v-else-if=\"!app.isCompatible\">\n\t\t\t\t\t\t<strong>{{ t('core', 'Cannot install this app because it is not compatible') }}</strong>\n\t\t\t\t\t</p>\n\t\t\t\t\t<p v-else-if=\"!app.canInstall\">\n\t\t\t\t\t\t<strong>{{ t('core', 'Cannot install this app') }}</strong>\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\t\t\t</template>\n\t\t</div>\n\n\t\t<div class=\"dialog-row\">\n\t\t\t<NcButton v-if=\"showInstallButton\"\n\t\t\t\ttype=\"tertiary\"\n\t\t\t\trole=\"link\"\n\t\t\t\t:href=\"defaultPageUrl\">\n\t\t\t\t{{ t('core', 'Skip') }}\n\t\t\t</NcButton>\n\n\t\t\t<NcButton v-if=\"showInstallButton\"\n\t\t\t\ttype=\"primary\"\n\t\t\t\t@click.stop.prevent=\"installApps\">\n\t\t\t\t{{ t('core', 'Install recommended apps') }}\n\t\t\t</NcButton>\n\t\t</div>\n\t</div>\n</template>\n\n<script>\nimport axios from '@nextcloud/axios'\nimport { generateUrl, imagePath } from '@nextcloud/router'\nimport { loadState } from '@nextcloud/initial-state'\nimport pLimit from 'p-limit'\nimport { translate as t } from '@nextcloud/l10n'\n\nimport NcButton from '@nextcloud/vue/dist/Components/NcButton.js'\n\nimport logger from '../../logger.js'\n\nconst recommended = {\n\tcalendar: {\n\t\tdescription: t('core', 'Schedule work & meetings, synced with all your devices.'),\n\t\ticon: imagePath('core', 'places/calendar.svg'),\n\t},\n\tcontacts: {\n\t\tdescription: t('core', 'Keep your colleagues and friends in one place without leaking their private info.'),\n\t\ticon: imagePath('core', 'places/contacts.svg'),\n\t},\n\tmail: {\n\t\tdescription: t('core', 'Simple email app nicely integrated with Files, Contacts and Calendar.'),\n\t\ticon: imagePath('core', 'actions/mail.svg'),\n\t},\n\tspreed: {\n\t\tdescription: t('core', 'Chatting, video calls, screensharing, online meetings and web conferencing – in your browser and with mobile apps.'),\n\t\ticon: imagePath('core', 'apps/spreed.svg'),\n\t},\n\trichdocuments: {\n\t\tname: 'Nextcloud Office',\n\t\tdescription: t('core', 'Collaborative documents, spreadsheets and presentations, built on Collabora Online.'),\n\t\ticon: imagePath('core', 'apps/richdocuments.svg'),\n\t},\n\tnotes: {\n\t\tdescription: t('core', 'Distraction free note taking app.'),\n\t\ticon: imagePath('core', 'apps/notes.svg'),\n\t},\n\trichdocumentscode: {\n\t\thidden: true,\n\t},\n}\nconst recommendedIds = Object.keys(recommended)\n\nexport default {\n\tname: 'RecommendedApps',\n\tcomponents: {\n\t\tNcButton,\n\t},\n\tdata() {\n\t\treturn {\n\t\t\tshowInstallButton: false,\n\t\t\tinstallingApps: false,\n\t\t\tloadingApps: true,\n\t\t\tloadingAppsError: false,\n\t\t\tapps: [],\n\t\t\tdefaultPageUrl: loadState('core', 'defaultPageUrl')\n\t\t}\n\t},\n\tcomputed: {\n\t\trecommendedApps() {\n\t\t\treturn this.apps.filter(app => recommendedIds.includes(app.id))\n\t\t},\n\t},\n\tasync mounted() {\n\t\ttry {\n\t\t\tconst { data } = await axios.get(generateUrl('settings/apps/list'))\n\t\t\tlogger.info(`${data.apps.length} apps fetched`)\n\n\t\t\tthis.apps = data.apps.map(app => Object.assign(app, { loading: false, installationError: false }))\n\t\t\tlogger.debug(`${this.recommendedApps.length} recommended apps found`, { apps: this.recommendedApps })\n\n\t\t\tthis.showInstallButton = true\n\t\t} catch (error) {\n\t\t\tlogger.error('could not fetch app list', { error })\n\n\t\t\tthis.loadingAppsError = true\n\t\t} finally {\n\t\t\tthis.loadingApps = false\n\t\t}\n\t},\n\tmethods: {\n\t\tinstallApps() {\n\t\t\tthis.showInstallButton = false\n\t\t\tthis.installingApps = true\n\n\t\t\tconst limit = pLimit(1)\n\t\t\tconst installing = this.recommendedApps\n\t\t\t\t.filter(app => !app.active && app.isCompatible && app.canInstall)\n\t\t\t\t.map(app => limit(() => {\n\t\t\t\t\tlogger.info(`installing ${app.id}`)\n\t\t\t\t\tapp.loading = true\n\t\t\t\t\treturn axios.post(generateUrl('settings/apps/enable'), { appIds: [app.id], groups: [] })\n\t\t\t\t\t\t.catch(error => {\n\t\t\t\t\t\t\tlogger.error(`could not install ${app.id}`, { error })\n\t\t\t\t\t\t\tapp.installationError = true\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.then(() => {\n\t\t\t\t\t\t\tlogger.info(`installed ${app.id}`)\n\t\t\t\t\t\t\tapp.loading = false\n\t\t\t\t\t\t})\n\t\t\t\t}))\n\t\t\tlogger.debug(`installing ${installing.length} recommended apps`)\n\t\t\tPromise.all(installing)\n\t\t\t\t.then(() => {\n\t\t\t\t\tlogger.info('all recommended apps installed, redirecting …')\n\n\t\t\t\t\twindow.location = this.defaultPageUrl\n\t\t\t\t})\n\t\t\t\t.catch(error => logger.error('could not install recommended apps', { error }))\n\t\t},\n\t\tcustomIcon(appId) {\n\t\t\tif (!(appId in recommended) || !recommended[appId].icon) {\n\t\t\t\tlogger.warn(`no app icon for recommended app ${appId}`)\n\t\t\t\treturn imagePath('core', 'places/default-app-icon.svg')\n\t\t\t}\n\t\t\treturn recommended[appId].icon\n\t\t},\n\t\tcustomName(app) {\n\t\t\tif (!(app.id in recommended)) {\n\t\t\t\treturn app.name\n\t\t\t}\n\t\t\treturn recommended[app.id].name || app.name\n\t\t},\n\t\tcustomDescription(appId) {\n\t\t\tif (!(appId in recommended)) {\n\t\t\t\tlogger.warn(`no app description for recommended app ${appId}`)\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\treturn recommended[appId].description\n\t\t},\n\t\tisHidden(appId) {\n\t\t\tif (!(appId in recommended)) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\treturn !!recommended[appId].hidden\n\t\t},\n\t},\n}\n</script>\n\n<style lang=\"scss\" scoped>\n.dialog-row {\n\tdisplay: flex;\n\tjustify-content: end;\n\tmargin-top: 8px;\n}\n\np {\n\t&.loading,\n\t&.loading-error {\n\t\theight: 100px;\n\t}\n\n\t&:last-child {\n\t\tmargin-top: 10px;\n\t}\n}\n\n.text-center {\n\ttext-align: center;\n}\n\n.app {\n\tdisplay: flex;\n\tflex-direction: row;\n\n\timg {\n\t\theight: 50px;\n\t\twidth: 50px;\n\t\tfilter: var(--background-invert-if-dark);\n\t}\n\n\timg, .info {\n\t\tpadding: 12px;\n\t}\n\n\t.info {\n\t\th3, p {\n\t\t\ttext-align: left;\n\t\t}\n\n\t\th3 {\n\t\t\tmargin-top: 0;\n\t\t}\n\n\t\th3 > span.icon {\n\t\t\tdisplay: inline-block;\n\t\t}\n\t}\n}\n</style>\n","/**\n * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport { translate as t } from '@nextcloud/l10n'\nimport Vue from 'vue'\n\nimport logger from './logger.js'\nimport RecommendedApps from './components/setup/RecommendedApps.vue'\n\nVue.mixin({\n\tmethods: {\n\t\tt,\n\t},\n})\n\nconst View = Vue.extend(RecommendedApps)\nnew View().$mount('#recommended-apps')\n\nlogger.debug('recommended apps view rendered')\n"],"names":["recommended","t","imagePath","recommendedIds","_sfc_main","NcButton","loadState","app","data","axios","generateUrl","logger","error","limit","pLimit","installing","appId","Vue","View","RecommendedApps"],"mappings":";2QAqEA,MAAAA,EAAA,CACA,SAAA,CACA,YAAAC,EAAA,OAAA,yDAAA,EACA,KAAAC,EAAA,OAAA,qBAAA,CACA,EACA,SAAA,CACA,YAAAD,EAAA,OAAA,mFAAA,EACA,KAAAC,EAAA,OAAA,qBAAA,CACA,EACA,KAAA,CACA,YAAAD,EAAA,OAAA,uEAAA,EACA,KAAAC,EAAA,OAAA,kBAAA,CACA,EACA,OAAA,CACA,YAAAD,EAAA,OAAA,oHAAA,EACA,KAAAC,EAAA,OAAA,iBAAA,CACA,EACA,cAAA,CACA,KAAA,mBACA,YAAAD,EAAA,OAAA,qFAAA,EACA,KAAAC,EAAA,OAAA,wBAAA,CACA,EACA,MAAA,CACA,YAAAD,EAAA,OAAA,mCAAA,EACA,KAAAC,EAAA,OAAA,gBAAA,CACA,EACA,kBAAA,CACA,OAAA,EACA,CACA,EACAC,EAAA,OAAA,KAAAH,CAAA,EAEAI,EAAA,CACA,KAAA,kBACA,WAAA,CACA,SAAAC,CACA,EACA,MAAA,CACA,MAAA,CACA,kBAAA,GACA,eAAA,GACA,YAAA,GACA,iBAAA,GACA,KAAA,CAAA,EACA,eAAAC,EAAA,OAAA,gBAAA,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