mirror of https://github.com/sualko/cloud_bbb
feat: add option to store room url as shortcut
parent
cd959b1c0f
commit
728ebae956
|
@ -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<Room[]> {
|
||||
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'> {
|
||||
|
|
|
@ -95,6 +95,7 @@ const App: React.FC<Props> = () => {
|
|||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th />
|
||||
<th />
|
||||
<th />
|
||||
<th onClick={() => onOrderBy('name')}>
|
||||
|
@ -120,7 +121,7 @@ const App: React.FC<Props> = () => {
|
|||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colSpan={2}>
|
||||
<td colSpan={3}>
|
||||
{!areRoomsLoaded && <span className="icon icon-loading-small icon-visible"></span>}
|
||||
</td>
|
||||
<td>
|
||||
|
|
|
@ -106,12 +106,32 @@ const RoomRow: React.FC<Props> = (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> = (props) => {
|
|||
<td className="start icon-col">
|
||||
<a href={api.getUrl(`b/${room.uid}`)} className="icon icon-play icon-visible" target="_blank" rel="noopener noreferrer"></a>
|
||||
</td>
|
||||
<td className="store icon-col">
|
||||
<a onClick={() => storeRoom()} className="icon icon-download icon-visible"></a>
|
||||
</td>
|
||||
<td className="name">
|
||||
{edit('name')}
|
||||
</td>
|
||||
|
@ -199,7 +222,7 @@ const RoomRow: React.FC<Props> = (props) => {
|
|||
</td>
|
||||
</tr>
|
||||
{showRecordings && <tr className="recordings-row">
|
||||
<td colSpan={8}>
|
||||
<td colSpan={9}>
|
||||
<table>
|
||||
<tbody>
|
||||
{recordings?.map(recording => <RecordingRow key={recording.id} recording={recording} deleteRecording={deleteRecording} storeRecording={storeRecording} />)}
|
||||
|
|
Loading…
Reference in New Issue