Skip to content

Commit

Permalink
Added folder creation after application initialization
Browse files Browse the repository at this point in the history
Signed-off-by: Mikhail Sazanov <m@sazanof.ru>
  • Loading branch information
Mikhail Sazanov committed Jan 25, 2023
1 parent 54ccf48 commit e087fab
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/Controller/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function index():TemplateResponse {
$showWeekNumbers = $this->config->getUserValue($this->userId, $this->appName, 'showWeekNr', $defaultWeekNumbers) === 'yes';
$skipPopover = $this->config->getUserValue($this->userId, $this->appName, 'skipPopover', $defaultSkipPopover) === 'yes';
$timezone = $this->config->getUserValue($this->userId, $this->appName, 'timezone', $defaultTimezone);
$attachmentsFolder = $this->config->getUserValue($this->userId, 'dav', 'attachmentsFolder', '/');
$attachmentsFolder = $this->config->getUserValue($this->userId, 'dav', 'attachmentsFolder', '/Calendar');
$slotDuration = $this->config->getUserValue($this->userId, $this->appName, 'slotDuration', $defaultSlotDuration);
$defaultReminder = $this->config->getUserValue($this->userId, $this->appName, 'defaultReminder', $defaultDefaultReminder);
$showTasks = $this->config->getUserValue($this->userId, $this->appName, 'showTasks', $defaultShowTasks) === 'yes';
Expand Down
15 changes: 15 additions & 0 deletions src/services/attachmentService.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@ const shareFileWith = async function(path, sharedWith, permissions = 17) {
}
}

const createFolder = async function(folderName, userId) {
const url = `/remote.php/dav/files/${userId}/${folderName}`
await axios({
method: 'MKCOL',
url: url.replace('//', '/'),
}).catch(e => {
if (e.response.status !== 405) {
showError(t('calendar', 'Error creating a folder {folder}', {
folder: folderName,
}))
}
})
}

const uploadLocalAttachment = async function(folder, event, dav, componentAttachments) {
const files = event.target.files
const attachments = []
Expand Down Expand Up @@ -155,4 +169,5 @@ export {
shareFile,
shareFileWith,
uploadLocalAttachment,
createFolder,
}
16 changes: 12 additions & 4 deletions src/views/Calendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ import '@nextcloud/dialogs/styles/toast.scss'
import Trashbin from '../components/AppNavigation/CalendarList/Trashbin.vue'
import AppointmentConfigList from '../components/AppNavigation/AppointmentConfigList.vue'

import { createFolder } from '../services/attachmentService.js'

export default {
name: 'Calendar',
components: {
Expand All @@ -125,6 +127,7 @@ export default {
data() {
return {
loadingCalendars: true,
loadingUser: true,
timeFrameCacheExpiryJob: null,
showEmptyCalendarScreen: false,
}
Expand All @@ -133,6 +136,7 @@ export default {
...mapGetters({
timezoneId: 'getResolvedTimezone',
hasTrashBin: 'hasTrashBin',
currentUserPrincipal: 'getCurrentUserPrincipal',
},
),
...mapState({
Expand Down Expand Up @@ -184,6 +188,14 @@ export default {
return null
},
},
watch: {
currentUserPrincipal() {
if (this.currentUserPrincipal !== undefined && this.loadingUser) {
createFolder(this.attachmentsFolder, this.currentUserPrincipal.userId)
this.loadingUser = false
}
},
},
created() {
this.timeFrameCacheExpiryJob = setInterval(() => {
const timestamp = (getUnixTimestampFromDate(dateFactory()) - 60 * 10)
Expand Down Expand Up @@ -219,12 +231,8 @@ export default {
hideEventExport: loadState('calendar', 'hide_event_export'),
forceEventAlarmType: loadState('calendar', 'force_event_alarm_type', false),
disableAppointments: loadState('calendar', 'disable_appointments', false),
<<<<<<< HEAD
canSubscribeLink: loadState('calendar', 'can_subscribe_link', false),
=======
canSubscribeLink: loadState('calendar', 'can_subscribe_link'),
attachmentsFolder: loadState('calendar', 'attachments_folder', false),
>>>>>>> Now users can configure default attachments folder
})
this.$store.dispatch('initializeCalendarJsConfig')

Expand Down

0 comments on commit e087fab

Please sign in to comment.