/
ActivityTab-8179f03c.mjs.map
1 lines (1 loc) · 5.94 KB
/
ActivityTab-8179f03c.mjs.map
1
{"version":3,"file":"ActivityTab-8179f03c.mjs","sources":["../src/views/ActivityTab.vue"],"sourcesContent":["<!--\n - @copyright Copyright (c) 2021 Louis Chemineau <louis@chmn.me>\n -\n - @author Louis Chemineau <louis@chmn.me>\n -\n - @license AGPL-3.0-or-later\n -\n - This program is free software: you can redistribute it and/or modify\n - it under the terms of the GNU Affero General Public License as\n - published by the Free Software Foundation, either version 3 of the\n - License, or (at your option) any later version.\n -\n - This program is distributed in the hope that it will be useful,\n - but WITHOUT ANY WARRANTY; without even the implied warranty of\n - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n - GNU Affero General Public License for more details.\n -\n - You should have received a copy of the GNU Affero General Public License\n - along with this program. If not, see <http://www.gnu.org/licenses/>.\n -\n -->\n\n<template>\n\t<div :class=\"{ 'icon-loading': loading }\">\n\t\t<!-- error message -->\n\t\t<NcEmptyContent v-if=\"error\" :title=\"error\">\n\t\t\t<template #icon>\n\t\t\t\t<NcIconSvgWrapper :svg=\"lightningBoltSVG\" />\n\t\t\t</template>\n\t\t</NcEmptyContent>\n\t\t<template v-else>\n\t\t\t<!-- activities content -->\n\t\t\t<NcEmptyContent v-if=\"loading\"\n\t\t\t\t:name=\"t('activity', 'Loading activities')\">\n\t\t\t\t<template #icon>\n\t\t\t\t\t<NcLoadingIcon />\n\t\t\t\t</template>\n\t\t\t</NcEmptyContent>\n\t\t\t<NcEmptyContent v-else-if=\"activities.length === 0\"\n\t\t\t\t:name=\"t('activity', 'No activity yet')\">\n\t\t\t\t<template #icon>\n\t\t\t\t\t<span class=\"icon-activity\" />\n\t\t\t\t</template>\n\t\t\t</NcEmptyContent>\n\t\t\t<ul v-else>\n\t\t\t\t<Activity v-for=\"activity in activities\"\n\t\t\t\t\t:key=\"activity.id\"\n\t\t\t\t\t:activity=\"activity\" />\n\t\t\t</ul>\n\t\t</template>\n\t</div>\n</template>\n\n<script>\nimport axios from '@nextcloud/axios'\n\nimport { generateOcsUrl } from '@nextcloud/router'\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcEmptyContent, NcIconSvgWrapper, NcLoadingIcon } from '@nextcloud/vue'\n\nimport Activity from '../components/Activity.vue'\nimport ActivityModel from '../models/ActivityModel.ts'\n\nimport lightningBoltSVG from '@mdi/svg/svg/lightning-bolt.svg?raw'\n\nimport logger from '../logger.js'\n\nexport default {\n\tname: 'ActivityTab',\n\tcomponents: {\n\t\tActivity,\n\t\tNcEmptyContent,\n\t\tNcIconSvgWrapper,\n\t\tNcLoadingIcon,\n\t},\n\tdata() {\n\t\treturn {\n\t\t\terror: '',\n\t\t\tloading: true,\n\t\t\tfileInfo: null,\n\t\t\tactivities: [],\n\t\t\tlightningBoltSVG,\n\t\t}\n\t},\n\tmethods: {\n\t\t/**\n\t\t * Update current fileInfo and fetch new activities\n\t\t *\n\t\t * @param {object} fileInfo the current file FileInfo\n\t\t */\n\t\tasync update(fileInfo) {\n\t\t\tthis.fileInfo = fileInfo\n\t\t\tthis.resetState()\n\t\t\tawait this.getActivities()\n\t\t},\n\t\t/**\n\t\t * Get the existing activities\n\t\t */\n\t\tasync getActivities() {\n\t\t\ttry {\n\t\t\t\tthis.loading = true\n\n\t\t\t\tconst activities = await axios.get(\n\t\t\t\t\tgenerateOcsUrl('apps/activity/api/v2/activity/filter'),\n\t\t\t\t\t{\n\t\t\t\t\t\tparams: {\n\t\t\t\t\t\t\tformat: 'json',\n\t\t\t\t\t\t\tobject_type: 'files',\n\t\t\t\t\t\t\tobject_id: this.fileInfo.id,\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\n\t\t\t\tthis.loading = false\n\n\t\t\t\tthis.processActivities(activities)\n\t\t\t} catch (error) {\n\t\t\t\t// Status 304 is not an error.\n\t\t\t\tif (error.response !== undefined && error.response.status === 304) {\n\t\t\t\t\tthis.loading = false\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.error = t('activity', 'Unable to load the activity list')\n\t\t\t\tthis.loading = false\n\t\t\t\tconsole.error('Error loading the activity list', error)\n\t\t\t}\n\t\t},\n\t\t/**\n\t\t * Reset the current view to its default state\n\t\t */\n\t\tresetState() {\n\t\t\tthis.loading = true\n\t\t\tthis.error = ''\n\t\t\tthis.activities = []\n\t\t},\n\t\t/**\n\t\t * Process the current activity data\n\t\t * and init activities[]\n\t\t *\n\t\t * @param {object} activity the activity ocs api request data\n\t\t * @param {object} activity.data the request data\n\t\t */\n\t\tprocessActivities({ data }) {\n\t\t\tif (data.ocs && data.ocs.data && data.ocs.data.length > 0) {\n\t\t\t\t// create Activity objects and sort by newest\n\t\t\t\tthis.activities = data.ocs.data\n\t\t\t\t\t.map(activity => new ActivityModel(activity))\n\t\t\t\t\t.sort((a, b) => b.timestamp - a.timestamp)\n\n\t\t\t\tlogger.debug(`Processed ${this.activities.length} activity(ies)`, { activities: this.activities, fileInfo: this.fileInfo })\n\t\t\t}\n\t\t},\n\n\t\tt,\n\t},\n}\n</script>\n\n<style scoped lang=\"scss\">\n::v-deep .empty-content__icon span {\n\tbackground-size: 64px;\n\twidth: 64px;\n\theight: 64px;\n}\n</style>\n"],"names":["_sfc_main","Activity","NcEmptyContent","NcIconSvgWrapper","NcLoadingIcon","lightningBoltSVG","fileInfo","activities","axios","generateOcsUrl","error","t","data","activity","ActivityModel","a","b","logger"],"mappings":";iOAmEAA,EAAA,CACA,KAAA,cACA,WAAA,CACA,SAAAC,EACA,eAAAC,EACA,iBAAAC,EACA,cAAAC,CACA,EACA,MAAA,CACA,MAAA,CACA,MAAA,GACA,QAAA,GACA,SAAA,KACA,WAAA,CAAA,EACA,iBAAAC,CACA,CACA,EACA,QAAA,CAMA,MAAA,OAAAC,EAAA,CACA,KAAA,SAAAA,EACA,KAAA,WAAA,EACA,MAAA,KAAA,cAAA,CACA,EAIA,MAAA,eAAA,CACA,GAAA,CACA,KAAA,QAAA,GAEA,MAAAC,EAAA,MAAAC,EAAA,IACAC,EAAA,sCAAA,EACA,CACA,OAAA,CACA,OAAA,OACA,YAAA,QACA,UAAA,KAAA,SAAA,EACA,CACA,CAAA,EAEA,KAAA,QAAA,GAEA,KAAA,kBAAAF,CAAA,CACA,OAAAG,EAAA,CAEA,GAAAA,EAAA,WAAA,QAAAA,EAAA,SAAA,SAAA,IAAA,CACA,KAAA,QAAA,GACA,MACA,CACA,KAAA,MAAAC,EAAA,WAAA,kCAAA,EACA,KAAA,QAAA,GACA,QAAA,MAAA,kCAAAD,CAAA,CACA,CACA,EAIA,YAAA,CACA,KAAA,QAAA,GACA,KAAA,MAAA,GACA,KAAA,WAAA,CAAA,CACA,EAQA,kBAAA,CAAA,KAAAE,GAAA,CACAA,EAAA,KAAAA,EAAA,IAAA,MAAAA,EAAA,IAAA,KAAA,OAAA,IAEA,KAAA,WAAAA,EAAA,IAAA,KACA,IAAAC,GAAA,IAAAC,EAAAD,CAAA,CAAA,EACA,KAAA,CAAAE,EAAAC,IAAAA,EAAA,UAAAD,EAAA,SAAA,EAEAE,EAAA,MAAA,aAAA,KAAA,WAAA,MAAA,iBAAA,CAAA,WAAA,KAAA,WAAA,SAAA,KAAA,SAAA,EAEA,EAEA,EAAAN,CACA,CACA"}