mirror of https://github.com/sualko/cloud_bbb
parent
93154c9556
commit
da6657b2a0
|
@ -1,9 +1,9 @@
|
||||||
import axios from '@nextcloud/axios';
|
import axios from '@nextcloud/axios';
|
||||||
|
|
||||||
export enum ShareType {
|
export enum ShareType {
|
||||||
User = OC.Share.SHARE_TYPE_USER,
|
User = 0, // OC.Share.SHARE_TYPE_USER
|
||||||
Group = OC.Share.SHARE_TYPE_GROUP,
|
Group = 1, // OC.Share.SHARE_TYPE_GROUP
|
||||||
Circle = OC.Share.SHARE_TYPE_CIRCLE
|
Circle = 7, // OC.Share.SHARE_TYPE_CIRCLE
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum Permission { Admin, Moderator, User }
|
export enum Permission { Admin, Moderator, User }
|
||||||
|
|
118
ts/filelist.ts
118
ts/filelist.ts
|
@ -1,78 +1,76 @@
|
||||||
import axios from '@nextcloud/axios';
|
import axios from '@nextcloud/axios';
|
||||||
import { generateOcsUrl, generateUrl } from '@nextcloud/router';
|
import { generateOcsUrl, generateUrl } from '@nextcloud/router';
|
||||||
import { Room } from './Common/Api';
|
import { api } from './Common/Api';
|
||||||
|
|
||||||
declare const OCA: any;
|
declare const OCA: any;
|
||||||
|
|
||||||
class BigBlueButton {
|
const mimeTypes = [
|
||||||
public async getRooms(): Promise<Room[]> {
|
'application/pdf',
|
||||||
const response = await axios.get(OC.generateUrl('/apps/bbb/rooms'));
|
'application/vnd.oasis.opendocument.presentation',
|
||||||
|
'application/vnd.oasis.opendocument.text',
|
||||||
|
'application/vnd.oasis.opendocument.spreadsheet',
|
||||||
|
'application/vnd.oasis.opendocument.graphics',
|
||||||
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||||
|
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||||
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||||
|
'application/msword',
|
||||||
|
'application/vnd.ms-powerpoint',
|
||||||
|
'application/vnd.ms-excel',
|
||||||
|
'image/jpeg',
|
||||||
|
'image/png',
|
||||||
|
'text/plain',
|
||||||
|
'text/rtf',
|
||||||
|
];
|
||||||
|
|
||||||
return response.data;
|
async function createDirectShare(fileId: number): Promise<string> {
|
||||||
}
|
const url = generateOcsUrl('apps/dav/api/v1', 1) + 'direct';
|
||||||
|
const createResponse = await axios.post(url, {
|
||||||
|
fileId,
|
||||||
|
});
|
||||||
|
|
||||||
|
return createResponse.data?.ocs?.data?.url;
|
||||||
}
|
}
|
||||||
|
|
||||||
$(() => {
|
async function share(fileId: number, filename: string, roomUid) {
|
||||||
|
const shareUrl = await createDirectShare(fileId);
|
||||||
|
const joinUrl = generateUrl('/apps/bbb/b/{uid}?u={url}&filename={filename}', {
|
||||||
|
uid: roomUid,
|
||||||
|
url: shareUrl,
|
||||||
|
filename,
|
||||||
|
});
|
||||||
|
|
||||||
|
window.open(joinUrl, '_blank', 'noopener,noreferrer');
|
||||||
|
}
|
||||||
|
|
||||||
|
function registerFileAction(mime, id, uid, name) {
|
||||||
|
OCA.Files.fileActions.registerAction({
|
||||||
|
name: 'bbb-' + id,
|
||||||
|
displayName: name,
|
||||||
|
mime,
|
||||||
|
permissions: OC.PERMISSION_SHARE,
|
||||||
|
icon: OC.imagePath('bbb', 'app-dark.svg'),
|
||||||
|
actionHandler: (fileName, context) => {
|
||||||
|
share(context.fileInfoModel.id, fileName, uid);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function addRoomsAsFileAction() {
|
||||||
if (!OCA?.Files?.fileActions) {
|
if (!OCA?.Files?.fileActions) {
|
||||||
|
console.warn('[BBB] "OCA.Files.fileActions" not available');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const mimeTypes = [
|
api.getRooms().then(rooms => {
|
||||||
'application/pdf',
|
|
||||||
'application/vnd.oasis.opendocument.presentation',
|
|
||||||
'application/vnd.oasis.opendocument.text',
|
|
||||||
'application/vnd.oasis.opendocument.spreadsheet',
|
|
||||||
'application/vnd.oasis.opendocument.graphics',
|
|
||||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
||||||
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
||||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
||||||
'application/msword',
|
|
||||||
'application/vnd.ms-powerpoint',
|
|
||||||
'application/vnd.ms-excel',
|
|
||||||
'image/jpeg',
|
|
||||||
'image/png',
|
|
||||||
'text/plain',
|
|
||||||
'text/rtf',
|
|
||||||
];
|
|
||||||
const bbb = new BigBlueButton();
|
|
||||||
|
|
||||||
bbb.getRooms().then(rooms => {
|
|
||||||
rooms.forEach(room => {
|
rooms.forEach(room => {
|
||||||
mimeTypes.forEach(mime => registerFileAction(mime, room.id, room.uid, room.name));
|
mimeTypes.forEach(mime => registerFileAction(mime, room.id, room.uid, room.name));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function registerFileAction(mime, id, uid, name) {
|
if (document.readyState === 'complete') {
|
||||||
OCA.Files.fileActions.registerAction({
|
addRoomsAsFileAction();
|
||||||
name: 'bbb-' + id,
|
} else {
|
||||||
displayName: name,
|
document.addEventListener('DOMContentLoaded', addRoomsAsFileAction);
|
||||||
mime,
|
}
|
||||||
permissions: OC.PERMISSION_SHARE,
|
|
||||||
icon: OC.imagePath('bbb', 'app-dark.svg'),
|
|
||||||
actionHandler: (fileName, context) => {
|
|
||||||
share(context.fileInfoModel.id, fileName, uid);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function share(fileId: number, filename: string, roomUid) {
|
|
||||||
const shareUrl = await createDirectShare(fileId);
|
|
||||||
const joinUrl = generateUrl('/apps/bbb/b/{uid}?u={url}&filename={filename}', {
|
|
||||||
uid: roomUid,
|
|
||||||
url: shareUrl,
|
|
||||||
filename,
|
|
||||||
});
|
|
||||||
|
|
||||||
window.open(joinUrl, '_blank', 'noopener,noreferrer');
|
|
||||||
}
|
|
||||||
|
|
||||||
async function createDirectShare(fileId: number): Promise<string> {
|
|
||||||
const url = generateOcsUrl('apps/dav/api/v1', 1) + 'direct';
|
|
||||||
const createResponse = await axios.post(url, {
|
|
||||||
fileId,
|
|
||||||
});
|
|
||||||
|
|
||||||
return createResponse.data?.ocs?.data?.url;
|
|
||||||
}
|
|
||||||
});
|
|
Loading…
Reference in New Issue