settings-vue-settings-admin-basic-settings.mjs.map 13 KB

1
  1. {"version":3,"file":"settings-vue-settings-admin-basic-settings.mjs","sources":["../apps/settings/src/components/BasicSettings/ProfileSettings.vue","../apps/settings/src/components/BasicSettings/BackgroundJob.vue","../apps/settings/src/main-admin-basic-settings.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors\n - SPDX-License-Identifier: AGPL-3.0-or-later\n-->\n\n<template>\n\t<div id=\"profile-settings\"\n\t\tclass=\"section\">\n\t\t<h2 class=\"inlineblock\">\n\t\t\t{{ t('settings', 'Profile') }}\n\t\t</h2>\n\n\t\t<p class=\"settings-hint\">\n\t\t\t{{ t('settings', 'Enable or disable profile by default for new accounts.') }}\n\t\t</p>\n\n\t\t<NcCheckboxRadioSwitch type=\"switch\"\n\t\t\t:checked.sync=\"initialProfileEnabledByDefault\"\n\t\t\t@update:checked=\"onProfileDefaultChange\">\n\t\t\t{{ t('settings', 'Enable') }}\n\t\t</NcCheckboxRadioSwitch>\n\t</div>\n</template>\n\n<script>\nimport { loadState } from '@nextcloud/initial-state'\nimport { showError } from '@nextcloud/dialogs'\n\nimport { saveProfileDefault } from '../../service/ProfileService.js'\nimport { validateBoolean } from '../../utils/validate.js'\nimport logger from '../../logger.ts'\n\nimport NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'\n\nconst profileEnabledByDefault = loadState('settings', 'profileEnabledByDefault', true)\n\nexport default {\n\tname: 'ProfileSettings',\n\n\tcomponents: {\n\t\tNcCheckboxRadioSwitch,\n\t},\n\n\tdata() {\n\t\treturn {\n\t\t\tinitialProfileEnabledByDefault: profileEnabledByDefault,\n\t\t}\n\t},\n\n\tmethods: {\n\t\tasync onProfileDefaultChange(isEnabled) {\n\t\t\tif (validateBoolean(isEnabled)) {\n\t\t\t\tawait this.updateProfileDefault(isEnabled)\n\t\t\t}\n\t\t},\n\n\t\tasync updateProfileDefault(isEnabled) {\n\t\t\ttry {\n\t\t\t\tconst responseData = await saveProfileDefault(isEnabled)\n\t\t\t\tthis.handleResponse({\n\t\t\t\t\tisEnabled,\n\t\t\t\t\tstatus: responseData.ocs?.meta?.status,\n\t\t\t\t})\n\t\t\t} catch (e) {\n\t\t\t\tthis.handleResponse({\n\t\t\t\t\terrorMessage: t('settings', 'Unable to update profile default setting'),\n\t\t\t\t\terror: e,\n\t\t\t\t})\n\t\t\t}\n\t\t},\n\n\t\thandleResponse({ isEnabled, status, errorMessage, error }) {\n\t\t\tif (status === 'ok') {\n\t\t\t\tthis.initialProfileEnabledByDefault = isEnabled\n\t\t\t} else {\n\t\t\t\tshowError(errorMessage)\n\t\t\t\tlogger.error(errorMessage, error)\n\t\t\t}\n\t\t},\n\t},\n}\n</script>\n\n<style lang=\"scss\" scoped>\n</style>\n","<!--\n - SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors\n - SPDX-License-Identifier: AGPL-3.0-or-later\n-->\n\n<template>\n\t<NcSettingsSection :name=\"t('settings', 'Background jobs')\"\n\t\t:description=\"t('settings', 'For the server to work properly, it\\'s important to configure background jobs correctly. Cron is the recommended setting. Please see the documentation for more information.')\"\n\t\t:doc-url=\"backgroundJobsDocUrl\">\n\t\t<template v-if=\"lastCron !== 0\">\n\t\t\t<NcNoteCard v-if=\"oldExecution\" type=\"error\">\n\t\t\t\t{{ t('settings', 'Last job execution ran {time}. Something seems wrong.', {time: relativeTime}) }}\n\t\t\t</NcNoteCard>\n\n\t\t\t<NcNoteCard v-else-if=\"longExecutionCron\" type=\"warning\">\n\t\t\t\t{{ t('settings', \"Some jobs have not been executed since {maxAgeRelativeTime}. Please consider increasing the execution frequency.\", {maxAgeRelativeTime}) }}\n\t\t\t</NcNoteCard>\n\n\t\t\t<NcNoteCard v-else-if=\"longExecutionNotCron\" type=\"warning\">\n\t\t\t\t{{ t('settings', \"Some jobs have not been executed since {maxAgeRelativeTime}. Please consider switching to system cron.\", {maxAgeRelativeTime}) }}\n\t\t\t</NcNoteCard>\n\n\t\t\t<NcNoteCard v-else type=\"success\">\n\t\t\t\t{{ t('settings', 'Last job ran {relativeTime}.', {relativeTime}) }}\n\t\t\t</NcNoteCard>\n\t\t</template>\n\n\t\t<NcNoteCard v-else type=\"error\">\n\t\t\t{{ t('settings', 'Background job did not run yet!') }}\n\t\t</NcNoteCard>\n\n\t\t<NcCheckboxRadioSwitch type=\"radio\"\n\t\t\t:checked.sync=\"backgroundJobsMode\"\n\t\t\tname=\"backgroundJobsMode\"\n\t\t\tvalue=\"ajax\"\n\t\t\tclass=\"ajaxSwitch\"\n\t\t\t@update:checked=\"onBackgroundJobModeChanged\">\n\t\t\t{{ t('settings', 'AJAX') }}\n\t\t</NcCheckboxRadioSwitch>\n\t\t<em>{{ t('settings', 'Execute one task with each page loaded. Use case: Single account instance.') }}</em>\n\n\t\t<NcCheckboxRadioSwitch type=\"radio\"\n\t\t\t:checked.sync=\"backgroundJobsMode\"\n\t\t\tname=\"backgroundJobsMode\"\n\t\t\tvalue=\"webcron\"\n\t\t\t@update:checked=\"onBackgroundJobModeChanged\">\n\t\t\t{{ t('settings', 'Webcron') }}\n\t\t</NcCheckboxRadioSwitch>\n\t\t<em>{{ t('settings', 'cron.php is registered at a webcron service to call cron.php every 5 minutes over HTTP. Use case: Very small instance (1–5 accounts depending on the usage).') }}</em>\n\n\t\t<NcCheckboxRadioSwitch type=\"radio\"\n\t\t\t:disabled=\"!cliBasedCronPossible\"\n\t\t\t:checked.sync=\"backgroundJobsMode\"\n\t\t\tvalue=\"cron\"\n\t\t\tname=\"backgroundJobsMode\"\n\t\t\t@update:checked=\"onBackgroundJobModeChanged\">\n\t\t\t{{ t('settings', 'Cron (Recommended)') }}\n\t\t</NcCheckboxRadioSwitch>\n\t\t<em v-html=\"cronLabel\" />\n\t</NcSettingsSection>\n</template>\n\n<script>\nimport { loadState } from '@nextcloud/initial-state'\nimport { showError } from '@nextcloud/dialogs'\nimport NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'\nimport NcSettingsSection from '@nextcloud/vue/dist/Components/NcSettingsSection.js'\nimport NcNoteCard from '@nextcloud/vue/dist/Components/NcNoteCard.js'\nimport moment from '@nextcloud/moment'\nimport axios from '@nextcloud/axios'\nimport { generateOcsUrl } from '@nextcloud/router'\nimport { confirmPassword } from '@nextcloud/password-confirmation'\nimport '@nextcloud/password-confirmation/dist/style.css'\n\nconst lastCron = loadState('settings', 'lastCron')\nconst cronMaxAge = loadState('settings', 'cronMaxAge', '')\nconst backgroundJobsMode = loadState('settings', 'backgroundJobsMode', 'cron')\nconst cliBasedCronPossible = loadState('settings', 'cliBasedCronPossible', true)\nconst cliBasedCronUser = loadState('settings', 'cliBasedCronUser', 'www-data')\nconst backgroundJobsDocUrl = loadState('settings', 'backgroundJobsDocUrl')\n\nexport default {\n\tname: 'BackgroundJob',\n\n\tcomponents: {\n\t\tNcCheckboxRadioSwitch,\n\t\tNcSettingsSection,\n\t\tNcNoteCard,\n\t},\n\n\tdata() {\n\t\treturn {\n\t\t\tlastCron,\n\t\t\tcronMaxAge,\n\t\t\tbackgroundJobsMode,\n\t\t\tcliBasedCronPossible,\n\t\t\tcliBasedCronUser,\n\t\t\tbackgroundJobsDocUrl,\n\t\t\trelativeTime: moment(lastCron * 1000).fromNow(),\n\t\t\tmaxAgeRelativeTime: moment(cronMaxAge * 1000).fromNow(),\n\t\t}\n\t},\n\tcomputed: {\n\t\tcronLabel() {\n\t\t\tlet desc = t('settings', 'Use system cron service to call the cron.php file every 5 minutes.')\n\t\t\tif (this.cliBasedCronPossible) {\n\t\t\t\tdesc += '<br>' + t('settings', 'The cron.php needs to be executed by the system account \"{user}\".', { user: this.cliBasedCronUser })\n\t\t\t} else {\n\t\t\t\tdesc += '<br>' + t('settings', 'The PHP POSIX extension is required. See {linkstart}PHP documentation{linkend} for more details.', {\n\t\t\t\t\tlinkstart: '<a target=\"_blank\" rel=\"noreferrer nofollow\" class=\"external\" href=\"https://www.php.net/manual/en/book.posix.php\">',\n\t\t\t\t\tlinkend: '</a>',\n\t\t\t\t}, undefined, { escape: false, sanitize: false })\n\t\t\t}\n\t\t\treturn desc\n\t\t},\n\t\toldExecution() {\n\t\t\treturn Date.now() / 1000 - this.lastCron > 600\n\t\t},\n\t\tlongExecutionNotCron() {\n\t\t\treturn Date.now() / 1000 - this.cronMaxAge > 12 * 3600 && this.backgroundJobsMode !== 'cron'\n\t\t},\n\t\tlongExecutionCron() {\n\t\t\treturn Date.now() / 1000 - this.cronMaxAge > 24 * 3600 && this.backgroundJobsMode === 'cron'\n\t\t},\n\t},\n\tmethods: {\n\t\tasync onBackgroundJobModeChanged(backgroundJobsMode) {\n\t\t\tconst url = generateOcsUrl('/apps/provisioning_api/api/v1/config/apps/{appId}/{key}', {\n\t\t\t\tappId: 'core',\n\t\t\t\tkey: 'backgroundjobs_mode',\n\t\t\t})\n\n\t\t\tawait confirmPassword()\n\n\t\t\ttry {\n\t\t\t\tconst { data } = await axios.post(url, {\n\t\t\t\t\tvalue: backgroundJobsMode,\n\t\t\t\t})\n\t\t\t\tthis.handleResponse({\n\t\t\t\t\tstatus: data.ocs?.meta?.status,\n\t\t\t\t})\n\t\t\t} catch (e) {\n\t\t\t\tthis.handleResponse({\n\t\t\t\t\terrorMessage: t('settings', 'Unable to update background job mode'),\n\t\t\t\t\terror: e,\n\t\t\t\t})\n\t\t\t}\n\t\t},\n\t\tasync handleResponse({ status, errorMessage, error }) {\n\t\t\tif (status === 'ok') {\n\t\t\t\tawait this.deleteError()\n\t\t\t} else {\n\t\t\t\tshowError(errorMessage)\n\t\t\t\tconsole.error(errorMessage, error)\n\t\t\t}\n\t\t},\n\t\tasync deleteError() {\n\t\t\t// clear cron errors on background job mode change\n\t\t\tconst url = generateOcsUrl('/apps/provisioning_api/api/v1/config/apps/{appId}/{key}', {\n\t\t\t\tappId: 'core',\n\t\t\t\tkey: 'cronErrors',\n\t\t\t})\n\n\t\t\tawait confirmPassword()\n\n\t\t\ttry {\n\t\t\t\tawait axios.delete(url)\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error(error)\n\t\t\t}\n\t\t},\n\t},\n}\n</script>\n\n<style lang=\"scss\" scoped>\n.error {\n\tmargin-top: 8px;\n\tpadding: 5px;\n\tborder-radius: var(--border-radius);\n\tcolor: var(--color-primary-element-text);\n\tbackground-color: var(--color-error);\n\twidth: initial;\n}\n.warning {\n\tmargin-top: 8px;\n\tpadding: 5px;\n\tborder-radius: var(--border-radius);\n\tcolor: var(--color-primary-element-text);\n\tbackground-color: var(--color-warning);\n\twidth: initial;\n}\n.ajaxSwitch {\n\tmargin-top: 1rem;\n}\n</style>\n","/**\n * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport Vue from 'vue'\nimport { loadState } from '@nextcloud/initial-state'\nimport { translate as t } from '@nextcloud/l10n'\n\nimport logger from './logger.ts'\n\nimport ProfileSettings from './components/BasicSettings/ProfileSettings.vue'\nimport BackgroundJob from './components/BasicSettings/BackgroundJob.vue'\n\nconst profileEnabledGlobally = loadState('settings', 'profileEnabledGlobally', true)\n\nVue.mixin({\n\tprops: {\n\t\tlogger,\n\t},\n\tmethods: {\n\t\tt,\n\t},\n})\n\nconst BackgroundJobView = Vue.extend(BackgroundJob)\nnew BackgroundJobView().$mount('#vue-admin-background-job')\n\nif (profileEnabledGlobally) {\n\tconst ProfileSettingsView = Vue.extend(ProfileSettings)\n\tnew ProfileSettingsView().$mount('#vue-admin-profile-settings')\n}\n"],"names":["profileEnabledByDefault","loadState","_sfc_main","NcCheckboxRadioSwitch","isEnabled","validateBoolean","responseData","saveProfileDefault","e","status","errorMessage","error","showError","logger","lastCron","cronMaxAge","backgroundJobsMode","cliBasedCronPossible","cliBasedCronUser","backgroundJobsDocUrl","NcSettingsSection","NcNoteCard","moment","desc","url","generateOcsUrl","confirmPassword","data","axios","profileEnabledGlobally","Vue","t","BackgroundJobView","Background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