/
ActivityTab-006fcfbd.mjs.map
1 lines (1 loc) · 9.37 KB
/
ActivityTab-006fcfbd.mjs.map
1
{"version":3,"file":"ActivityTab-006fcfbd.mjs","sources":["../src/components/ActivitySidebarPlugin.vue","../src/views/ActivityTab.vue"],"sourcesContent":["<!--\n - @copyright Copyright (c) 2023 Ferdinand Thiessen <opensource@fthiessen.de>\n -\n - @author Ferdinand Thiessen <opensource@fthiessen.de>\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 ref=\"attachTarget\" />\n</template>\n\n<script setup lang=\"ts\">\nimport type { IActivitySidebarAction } from '../models/ActivityAPI'\nimport { getCurrentInstance, onBeforeUnmount, onMounted, ref } from 'vue'\n\nconst props = defineProps<{\n\t/** The sidebar plugin */\n\tplugin: IActivitySidebarAction\n fileInfo: object | null\n}>()\n\nconst emit = defineEmits<{\n\t(e: 'reload-activities'): void\n}>()\n\nconst attachTarget = ref<HTMLDivElement>()\n\nonMounted(() => props.plugin.mount(attachTarget.value as HTMLDivElement, {\n\tcontext: getCurrentInstance()?.proxy,\n\tfileInfo: props.fileInfo,\n\treload: () => emit('reload-activities'),\n}))\nonBeforeUnmount(() => props.plugin.unmount())\n</script>\n","<!--\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\" :name=\"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 actions -->\n\t\t\t<div v-if=\"sidebarPlugins.length > 0\" class=\"activity__actions\">\n\t\t\t\t<ActivitySidebarPlugin v-for=\"plugin,index of sidebarPlugins\"\n\t\t\t\t\t:key=\"index\"\n\t\t\t\t\t:plugin=\"plugin\"\n\t\t\t\t\t:file-info=\"fileInfo\"\n\t\t\t\t\t@reload-activities=\"getActivities()\" />\n\t\t\t</div>\n\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\t\t:show-previews=\"false\"\n\t\t\t\t\t@reload=\"getActivities()\" />\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 from '@nextcloud/vue/dist/Components/NcEmptyContent.js'\nimport NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js'\nimport NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'\nimport { getAdditionalEntries, getSidebarActions, getActivityFilters } from '../utils/api.ts'\n\nimport logger from '../utils/logger.ts'\nimport Activity from '../components/Activity.vue'\nimport ActivityModel from '../models/ActivityModel.ts'\nimport ActivitySidebarPlugin from '../components/ActivitySidebarPlugin.vue'\n\nimport lightningBoltSVG from '@mdi/svg/svg/lightning-bolt.svg?raw'\n\nexport default {\n\tname: 'ActivityTab',\n\tcomponents: {\n\t\tActivity,\n\t\tNcEmptyContent,\n\t\tNcIconSvgWrapper,\n\t\tNcLoadingIcon,\n\t\tActivitySidebarPlugin,\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\tsidebarPlugins: [],\n\t\t}\n\t},\n\tmounted() {\n\t\tthis.sidebarPlugins = getSidebarActions()\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 this.processActivities(await this.loadRealActivities())\n\t\t\t\tconst otherEntries = await getAdditionalEntries({ fileInfo: this.fileInfo })\n\t\t\t\tthis.activities = [...activities, ...otherEntries].sort((a, b) => b.timestamp - a.timestamp)\n\t\t\t} catch (error) {\n\t\t\t\tthis.error = t('activity', 'Unable to load the activity list')\n\t\t\t\tconsole.error('Error loading the activity list', error)\n\t\t\t} finally {\n\t\t\t\tthis.loading = false\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\n\t\t/**\n\t\t * Load activites from API\n\t\t */\n\t\tasync loadRealActivities() {\n\t\t\ttry {\n\t\t\t\tconst { data } = 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\t\t\t\t)\n\t\t\t\treturn data.ocs.data\n\t\t\t} catch (e) {\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\treturn []\n\t\t\t\t}\n\t\t\t\tthrow e\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Process the API response activities and apply filter\n\t\t *\n\t\t * @param {any[]} activities the activites\n\t\t */\n\t\tprocessActivities(activities) {\n\t\t\tactivities = activities.map(activity => new ActivityModel(activity))\n\n\t\t\tlogger.debug(`Processed ${activities.length} activity(ies)`, { activities, fileInfo: this.fileInfo })\n\n\t\t\tconst filters = getActivityFilters()\n\t\t\treturn activities.filter((activity) => !filters || filters.every((filter) => filter(activity)))\n\t\t},\n\n\t\tt,\n\t},\n}\n</script>\n\n<style scoped lang=\"scss\">\n:deep(.empty-content__icon span) {\n\tbackground-size: 64px;\n\twidth: 64px;\n\theight: 64px;\n}\n\n.activity__actions {\n\tdisplay: flex;\n\tflex-direction: column;\n\twidth: 100%;\n}\n</style>\n"],"names":["attachTarget","ref","onMounted","props","getCurrentInstance","emit","onBeforeUnmount","_sfc_main","Activity","NcEmptyContent","NcIconSvgWrapper","NcLoadingIcon","ActivitySidebarPlugin","lightningBoltSVG","getSidebarActions","fileInfo","activities","otherEntries","getAdditionalEntries","a","b","error","t","data","axios","generateOcsUrl","e","activity","ActivityModel","logger","filters","getActivityFilters","filter"],"mappings":";ofAwCMA,EAAeC,IAErB,OAAAC,EAAU,IAAMC,EAAM,OAAO,MAAMH,EAAa,MAAyB,CACxE,QAASI,KAAsB,MAC/B,SAAUD,EAAM,SAChB,OAAQ,IAAME,EAAK,mBAAmB,CACtC,CAAA,CAAC,EACFC,EAAgB,IAAMH,EAAM,OAAO,QAAS,CAAA,gNCkC5CI,EAAA,CACA,KAAA,cACA,WAAA,CACA,SAAAC,EACA,eAAAC,EACA,iBAAAC,EACA,cAAAC,EACA,sBAAAC,CACA,EACA,MAAA,CACA,MAAA,CACA,MAAA,GACA,QAAA,GACA,SAAA,KACA,WAAA,CAAA,EACA,iBAAAC,EACA,eAAA,CAAA,CACA,CACA,EACA,SAAA,CACA,KAAA,eAAAC,EAAA,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,MAAA,KAAA,kBAAA,MAAA,KAAA,oBAAA,EACAC,EAAA,MAAAC,EAAA,CAAA,SAAA,KAAA,SAAA,EACA,KAAA,WAAA,CAAA,GAAAF,EAAA,GAAAC,CAAA,EAAA,KAAA,CAAAE,EAAAC,IAAAA,EAAA,UAAAD,EAAA,SAAA,CACA,OAAAE,EAAA,CACA,KAAA,MAAAC,EAAA,WAAA,kCAAA,EACA,QAAA,MAAA,kCAAAD,CAAA,CACA,QAAA,CACA,KAAA,QAAA,EACA,CACA,EAIA,YAAA,CACA,KAAA,QAAA,GACA,KAAA,MAAA,GACA,KAAA,WAAA,CAAA,CACA,EAKA,MAAA,oBAAA,CACA,GAAA,CACA,KAAA,CAAA,KAAAE,CAAA,EAAA,MAAAC,EAAA,IACAC,EAAA,sCAAA,EACA,CACA,OAAA,CACA,OAAA,OACA,YAAA,QACA,UAAA,KAAA,SAAA,EACA,CACA,CACA,EACA,OAAAF,EAAA,IAAA,IACA,OAAAG,EAAA,CAEA,GAAA,MAAA,WAAA,QAAA,MAAA,SAAA,SAAA,IACA,MAAA,CAAA,EAEA,MAAAA,CACA,CACA,EAOA,kBAAAV,EAAA,CACAA,EAAAA,EAAA,IAAAW,GAAA,IAAAC,EAAAD,CAAA,CAAA,EAEAE,EAAA,MAAA,aAAAb,EAAA,MAAA,iBAAA,CAAA,WAAAA,EAAA,SAAA,KAAA,QAAA,CAAA,EAEA,MAAAc,EAAAC,EAAA,EACA,OAAAf,EAAA,OAAAW,GAAA,CAAAG,GAAAA,EAAA,MAAAE,GAAAA,EAAAL,CAAA,CAAA,CAAA,CACA,EAEA,EAAAL,CACA,CACA"}