From 728ebae9566484bfb6cb327b663451f21de09c7c Mon Sep 17 00:00:00 2001 From: sualko Date: Sun, 17 May 2020 16:51:26 +0200 Subject: [PATCH] feat: add option to store room url as shortcut --- ts/Manager/Api.ts | 21 ++++++++++++++++++--- ts/Manager/App.tsx | 3 ++- ts/Manager/RoomRow.tsx | 31 +++++++++++++++++++++++++++---- 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/ts/Manager/Api.ts b/ts/Manager/Api.ts index 10d89aa..6f85076 100644 --- a/ts/Manager/Api.ts +++ b/ts/Manager/Api.ts @@ -27,6 +27,10 @@ class Api { return OC.generateUrl(`apps/bbb/${endpoint}`); } + public getRoomUrl(room: Room) { + return window.location.origin + api.getUrl(`b/${room.uid}`); + } + public async getRooms(): Promise { const response = await axios.get(this.getUrl('rooms')); @@ -70,10 +74,21 @@ class Api { public async storeRecording(recording: Recording, path: string) { const startDate = new Date(recording.startTime); - const url = `/remote.php/dav/files/${OC.currentUser}${path}/${encodeURIComponent(recording.name + ' ' + startDate.toISOString())}.url`; - const response = await axios.put(url, `[InternetShortcut]\nURL=${recording.url}`); + const filename = `${encodeURIComponent(recording.name + ' ' + startDate.toISOString())}.url`; + const url = `/remote.php/dav/files/${OC.currentUser}${path}/${filename}`; - return response.data; + await axios.put(url, `[InternetShortcut]\nURL=${recording.url}`); + + return filename; + } + + public async storeRoom(room: Room, path: string) { + const filename = `${encodeURIComponent(room.name)}.url`; + const url = `/remote.php/dav/files/${OC.currentUser}${path}/${filename}`; + + await axios.put(url, `[InternetShortcut]\nURL=${this.getRoomUrl(room)}`); + + return filename; } public async checkServer(url: string, secret: string): Promise<'success'|'invalid-url'|'invalid:secret'> { diff --git a/ts/Manager/App.tsx b/ts/Manager/App.tsx index 6206593..b4b2309 100644 --- a/ts/Manager/App.tsx +++ b/ts/Manager/App.tsx @@ -95,6 +95,7 @@ const App: React.FC = () => { + - + @@ -199,7 +222,7 @@ const RoomRow: React.FC = (props) => { {showRecordings && -
onOrderBy('name')}> @@ -120,7 +121,7 @@ const App: React.FC = () => {
+ {!areRoomsLoaded && } diff --git a/ts/Manager/RoomRow.tsx b/ts/Manager/RoomRow.tsx index a452650..b047111 100644 --- a/ts/Manager/RoomRow.tsx +++ b/ts/Manager/RoomRow.tsx @@ -106,12 +106,32 @@ const RoomRow: React.FC = (props) => { ); } + function storeRoom() { + OC.dialogs.filepicker(t('bbb', 'Select target folder'), (path: string) => { + api.storeRoom(room, path).then((filename) => { + OC.dialogs.info( + t('bbb', 'Room URL was stored in "{path}" as "{filename}".', { path: path + '/', filename }), + t('bbb', 'Link stored'), + () => undefined, + ); + }).catch(err => { + console.warn('Could not store room', err); + + OC.dialogs.alert( + t('bbb', 'URL to room could not be stored.'), + t('bbb', 'Error'), + () => undefined + ); + }); + }, undefined, 'httpd/unix-directory'); + } + function storeRecording(recording: Recording) { OC.dialogs.filepicker(t('bbb', 'Select target folder'), (path: string) => { - api.storeRecording(recording, path).then(() => { + api.storeRecording(recording, path).then((filename) => { OC.dialogs.info( - t('bbb', 'URL to presentation was stored in "{path}"', { path: path + '/' }), - t('bbb', 'File stored'), + t('bbb', 'URL to presentation was stored in "{path}" as "{filename}".', { path: path + '/', filename }), + t('bbb', 'Link stored'), () => undefined, ); }).catch(err => { @@ -178,6 +198,9 @@ const RoomRow: React.FC = (props) => { + storeRoom()} className="icon icon-download icon-visible"> + {edit('name')}
+ {recordings?.map(recording => )}