meeting-pane 2.5.0 → 2.5.1-5b509701

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,950 +0,0 @@
1
- "use strict";
2
-
3
- /* Meeting materials and tools Pane
4
- **
5
- ** Putting together some of the tools we have to manage a Meeting
6
- */
7
-
8
- // const VideoRoomPrefix = 'https://appear.in/'
9
- var logic = require('solid-logic');
10
- var VideoRoomPrefix = 'https://meet.jit.si/';
11
- var UI = require('solid-ui');
12
- var ns = UI.ns;
13
- var $rdf = require('rdflib');
14
- var meetingDetailsFormText = require('./meetingDetailsForm.js');
15
- module.exports = {
16
- icon: UI.icons.iconBase + 'noun_66617.svg',
17
- name: 'meeting',
18
- audience: [ns.solid('PowerUser')],
19
- label: function label(subject, context) {
20
- var kb = context.session.store;
21
- var ns = UI.ns;
22
- if (kb.holds(subject, ns.rdf('type'), ns.meeting('Meeting'))) {
23
- return 'Meeting';
24
- }
25
- return null; // Suppress pane otherwise
26
- },
27
- // Create a new Meeting thing
28
- //
29
- // returns: A promise of a meeting object
30
- //
31
-
32
- mintClass: UI.ns.meeting('Meeting'),
33
- mintNew: function mintNew(context, options) {
34
- return new Promise(function (resolve, reject) {
35
- var kb = context.session.store;
36
- var ns = UI.ns;
37
- options.newInstance = options.newInstance || kb.sym(options.newBase + 'index.ttl#this');
38
- var meeting = options.newInstance;
39
- var meetingDoc = meeting.doc();
40
- var me = logic.authn.currentUser();
41
- if (me) {
42
- kb.add(meeting, ns.dc('author'), me, meetingDoc);
43
- }
44
- kb.add(meeting, ns.rdf('type'), ns.meeting('Meeting'), meetingDoc);
45
- kb.add(meeting, ns.dc('created'), new Date(), meetingDoc);
46
- kb.add(meeting, ns.ui('backgroundColor'), new $rdf.Literal('#ddddcc', undefined, ns.xsd('color')), meetingDoc);
47
- var toolList = new $rdf.Collection();
48
- kb.add(meeting, ns.meeting('toolList'), toolList, meetingDoc);
49
- toolList.elements.push(meeting); // Add the meeting itself - see renderMain()
50
-
51
- kb.updater.put(meetingDoc, kb.statementsMatching(undefined, undefined, undefined, meetingDoc), 'text/turtle', function (uri2, ok, message) {
52
- if (ok) {
53
- resolve(options);
54
- } else {
55
- reject(new Error('Error writing meeting configuration: ' + message));
56
- }
57
- });
58
- });
59
- },
60
- // Returns a div
61
-
62
- render: function render(subject, dataBrowserContext) {
63
- var dom = dataBrowserContext.dom;
64
- var kb = dataBrowserContext.session.store;
65
- var ns = UI.ns;
66
- var updater = kb.updater;
67
- var thisPane = this;
68
- var complain = function complain(message, color) {
69
- console.log(message);
70
- var pre = dom.createElement('pre');
71
- pre.setAttribute('style', 'background-color: ' + color || '#eed' + ';');
72
- div.appendChild(pre);
73
- pre.appendChild(dom.createTextNode(message));
74
- };
75
- var complainIfBad = function complainIfBad(ok, message) {
76
- if (!ok) complain(message);
77
- };
78
- var meeting = subject;
79
- var meetingDoc = subject.doc();
80
- var meetingBase = subject.dir().uri;
81
- var div = dom.createElement('div');
82
- var table = div.appendChild(dom.createElement('table'));
83
- table.style = 'width: 100%; height: 100%; margin:0;';
84
- var topTR = table.appendChild(dom.createElement('tr'));
85
- topTR.appendChild(dom.createElement('div')); // topDiv
86
- var mainTR = table.appendChild(dom.createElement('tr'));
87
- var toolBar0 = table.appendChild(dom.createElement('td'));
88
- var toolBar1 = toolBar0.appendChild(dom.createElement('table'));
89
- var toolBar = toolBar1.appendChild(dom.createElement('tr'));
90
- topTR.setAttribute('style', 'height: 2em;'); // spacer if notthing else
91
-
92
- var me = null; // @@ Put code to find out logged in person
93
-
94
- var saveBackMeetingDoc = function saveBackMeetingDoc() {
95
- updater.put(meetingDoc, kb.statementsMatching(undefined, undefined, undefined, meetingDoc), 'text/turtle', function (uri2, ok, message) {
96
- if (ok) {
97
- tabs.refresh();
98
- resetTools();
99
- } else {
100
- message = 'FAILED to save new thing at: ' + meetingDoc + ' : ' + message;
101
- complain(message);
102
- }
103
- });
104
- };
105
- var saveAppDocumentLinkAndAddNewThing = function saveAppDocumentLinkAndAddNewThing(tool, thing, pred) {
106
- var appDoc = thing.doc();
107
- if (pred) {
108
- kb.add(meeting, pred, thing, appDoc); // Specific Link back to meeting
109
- }
110
- kb.add(thing, ns.meeting('parentMeeting'), meeting, appDoc); // Generic link back to meeting
111
- updater.put(appDoc, kb.statementsMatching(undefined, undefined, undefined, appDoc), 'text/turtle', function (uri2, ok, message) {
112
- if (ok) {
113
- saveBackMeetingDoc();
114
- } else {
115
- complain('FAILED to save new tool at: ' + thing + ' : ' + message);
116
- }
117
- });
118
- };
119
- var makeToolNode = function makeToolNode(target, pred, label, iconURI) {
120
- if (pred) {
121
- kb.add(meeting, pred, target, meetingDoc);
122
- }
123
- var x = UI.widgets.newThing(meetingDoc);
124
- if (label) kb.add(x, ns.rdfs('label'), label, meetingDoc);
125
- if (iconURI) kb.add(x, ns.meeting('icon'), kb.sym(iconURI), meetingDoc);
126
- kb.add(x, ns.rdf('type'), ns.meeting('Tool'), meetingDoc);
127
- kb.add(x, ns.meeting('target'), target, meetingDoc);
128
- var toolList = kb.the(meeting, ns.meeting('toolList'));
129
- toolList.elements.push(x);
130
- return x;
131
- };
132
-
133
- // Map from end-user non-iframeable Google maps URI to G Maps API
134
- // Input: like https://www.google.co.uk/maps/place/Mastercard/@53.2717971,-6.2042699,17z/...
135
- // Output:
136
- function googleMapsSpecial(page) {
137
- var initialPrefix = /https:\/\/www\.google\..*\/maps\//;
138
- var finalPrefix = 'https://www.google.com/maps/embed/v1/';
139
- var myPersonalApiKEY = 'AIzaSyB8aaT6bY9tcLCmc2oPCkdUYLmTOWM8R54'; // Get your own key!
140
- // GET YOUR KEY AT https://developers.google.com/maps/documentation/javascript/
141
- var uri = page.uri;
142
- if (!uri.match(initialPrefix)) return page;
143
- if (uri.startsWith(finalPrefix)) return page; // Already done
144
- var map = uri.replace(initialPrefix, finalPrefix) + '&key=' + myPersonalApiKEY;
145
- console.log('Converted Google Map URI! ' + map);
146
- return $rdf.sym(map);
147
- }
148
-
149
- // //////////////////// DRAG and Drop
150
-
151
- var handleDroppedThing = function handleDroppedThing(target) {
152
- // @@ idea: look
153
- return new Promise(function (resolve) {
154
- // Add a meeting tab for a web resource. Alas many resource canot be framed
155
- // as they block framing, or are insecure.
156
- var addIframeTool = function addIframeTool(target) {
157
- var tool = makeToolNode(target, UI.ns.wf('attachment'), UI.utils.label(target), null);
158
- kb.add(tool, UI.ns.meeting('view'), 'iframe', meetingDoc);
159
- };
160
- var addLink = function addLink(target) {
161
- var pred = ns.wf('attachment');
162
- kb.add(subject, pred, target, subject.doc());
163
- var toolObject = {
164
- icon: 'noun_160581.svg',
165
- // right arrow "link"
166
- limit: 1,
167
- shareTab: true // but many things behind it
168
- };
169
- var newPaneOptions = {
170
- newInstance: subject,
171
- // kb.sym(subject.doc().uri + '#LinkListTool'),
172
- pane: dataBrowserContext.session.paneRegistry.byName('link'),
173
- // the pane to be used to mint a new thing
174
- predicate: ns.meeting('attachmentTool'),
175
- tabTitle: 'Links',
176
- view: 'link',
177
- // The pane to be used when it is viewed
178
- noIndexHTML: true
179
- };
180
- return makeNewPaneTool(toolObject, newPaneOptions);
181
- };
182
-
183
- // When paerson added to he meeting, make an ad hoc group
184
- // of meeting participants is one does not already exist, and add them
185
- var addParticipant = function addParticipant(target) {
186
- var pref = kb.any(target, ns.foaf('preferredURI'));
187
- var obj = pref ? kb.sym(pref) : target;
188
- var group = kb.any(meeting, ns.meeting('attendeeGroup'));
189
- var addPersonToGroup = function addPersonToGroup(obj, group) {
190
- var ins = [$rdf.st(group, UI.ns.vcard('hasMember'), obj, group.doc())]; // @@@ Complex rules about webid?
191
- var name = kb.any(obj, ns.vcard('fn')) || kb.any(obj, ns.foaf('name'));
192
- if (name) {
193
- ins.push($rdf.st(obj, UI.ns.vcard('fn'), name, group.doc()));
194
- }
195
- kb.fetcher.nowOrWhenFetched(group.doc(), undefined, function (ok, _body) {
196
- if (!ok) {
197
- complain("Can't read group to add person" + group);
198
- return;
199
- }
200
- kb.updater.update([], ins, function (uri, ok, body) {
201
- complainIfBad(ok, body);
202
- if (ok) {
203
- console.log('Addded to particpants OK: ' + obj);
204
- }
205
- });
206
- });
207
- };
208
- if (group) {
209
- addPersonToGroup(obj, group);
210
- return;
211
- }
212
- makeParticipantsGroup().then(function (options) {
213
- var group = options.newInstance;
214
- addPersonToGroup(obj, group);
215
- kb.fetcher.putBack(meetingDoc, {
216
- contentType: 'text/turtle'
217
- }).then(function (_xhr) {
218
- console.log('Particiants Group created: ' + group);
219
- });
220
- })["catch"](function (err) {
221
- complain(err);
222
- });
223
- };
224
- console.log('Dropped on thing ' + target); // icon was: UI.icons.iconBase + 'noun_25830.svg'
225
- var u = target.uri;
226
- if (u.startsWith('http:') && u.indexOf('#') < 0) {
227
- // insecure Plain document
228
- addLink(target);
229
- return resolve(target);
230
- }
231
- kb.fetcher.nowOrWhenFetched(target, function (ok, mess) {
232
- function addAttachmentTab(target) {
233
- target = googleMapsSpecial(target);
234
- console.log('make web page attachement tab ' + target); // icon was: UI.icons.iconBase + 'noun_25830.svg'
235
- var tool = makeToolNode(target, UI.ns.wf('attachment'), UI.utils.label(target), null);
236
- kb.add(tool, UI.ns.meeting('view'), 'iframe', meetingDoc);
237
- return resolve(target);
238
- }
239
- if (!ok) {
240
- console.log('Error looking up dropped thing, will just add it anyway. ' + target + ': ' + mess);
241
- return addAttachmentTab(target); // You can still try iframing it. (Could also add to list of links in PersonTR widgets)
242
- } else {
243
- var obj = target;
244
- var types = kb.findTypeURIs(obj);
245
- for (var ty in types) {
246
- console.log(' drop object type includes: ' + ty);
247
- }
248
- if (ns.vcard('Individual').uri in types || ns.foaf('Person').uri in types || ns.foaf('Agent').uri in types) {
249
- addParticipant(target);
250
- return resolve(target);
251
- }
252
- if (u.startsWith('https:') && u.indexOf('#') < 0) {
253
- // Plain secure document
254
- // can we iframe it?
255
- var hh = kb.fetcher.getHeader(target, 'x-frame-options');
256
- var ok2 = true;
257
- if (hh) {
258
- for (var j = 0; j < hh.length; j++) {
259
- console.log('x-frame-options: ' + hh[j]);
260
- if (hh[j].indexOf('sameorigin') < 0) {
261
- // (and diff origin @@)
262
- ok2 = false;
263
- }
264
- if (hh[j].indexOf('deny') < 0) {
265
- ok2 = false;
266
- }
267
- }
268
- }
269
- if (ok2) {
270
- target = googleMapsSpecial(target); // tweak Google maps to embed OK
271
- addIframeTool(target); // Something we can maybe iframe
272
- return resolve(target);
273
- }
274
- } // Something we cannot iframe, and must link to:
275
- console.log('Default: assume web page attachement ' + target); // icon was: UI.icons.iconBase + 'noun_25830.svg'
276
- return addAttachmentTab(target);
277
- }
278
- });
279
- }); // promise
280
- };
281
-
282
- // When a set of URIs are dropped on the tabs
283
- var droppedURIHandler = function droppedURIHandler(uris) {
284
- Promise.all(uris.map(function (u) {
285
- var target = $rdf.sym(u); // Attachment needs text label to disinguish I think not icon.
286
- return handleDroppedThing(target); // can add to meetingDoc but must be sync
287
- })).then(function (_a) {
288
- saveBackMeetingDoc();
289
- });
290
- };
291
- var droppedFileHandler = function droppedFileHandler(files) {
292
- UI.widgets.uploadFiles(kb.fetcher, files, meeting.dir().uri + 'Files', meeting.dir().uri + 'Pictures', function (theFile, _destURI) {
293
- if (theFile.type.startsWith('image/')) {
294
- makePicturesFolder('Files'); // If necessary
295
- } else {
296
- makeMaterialsFolder('Pictures');
297
- }
298
- });
299
- };
300
-
301
- // ////////////////////////////////////////////////////// end of drag drop
302
-
303
- var makeGroup = function makeGroup(_toolObject) {
304
- var newBase = meetingBase + 'Group/';
305
- var kb = dataBrowserContext.session.store;
306
- var group = kb.any(meeting, ns.meeting('particpants'));
307
- if (!group) {
308
- group = $rdf.sym(newBase + 'index.ttl#this');
309
- }
310
- console.log('Participant group: ' + group);
311
- var tool = makeToolNode(group, ns.meeting('particpants'), 'Particpants', UI.icons.iconBase + 'noun_339237.svg'); // group: noun_339237.svg 'noun_15695.svg'
312
- kb.add(tool, UI.ns.meeting('view'), 'peoplePicker', meetingDoc);
313
- saveBackMeetingDoc();
314
- };
315
- /*
316
- var makeAddressBook = function (toolObject) {
317
- var newBase = meetingBase + 'Group/'
318
- var kb = store
319
- var group = kb.any(meeting, ns.meeting('addressBook'))
320
- if (!group) {
321
- group = $rdf.sym(newBase + 'index.ttl#this')
322
- }
323
- // Create a tab for the addressbook
324
- var div = dom.createElement('div')
325
- var context = { dom: dom, div: div }
326
- var book
327
- UI.login.findAppInstances(context, ns.vcard('AddressBook')).then(
328
- function (context) {
329
- if (context.instances.length === 0) {
330
- complain('You have no solid address book. It is really handy to have one to keep track of people and groups')
331
- } else if (context.instances.length > 1) {
332
- var s = context.instances.map(function (x) { return '' + x }).join(', ')
333
- complain('You have more than one solid address book: ' + s + ' Not supported yet.')
334
- } else { // addressbook
335
- book = context.instances[0]
336
- var tool = makeToolNode(book, ns.meeting('addressBook'), 'Address Book', UI.icons.iconBase + 'noun_15695.svg') // group: noun_339237.svg
337
- kb.add(tool, UI.ns.meeting('view'), 'contact', meetingDoc)
338
- saveBackMeetingDoc()
339
- }
340
- }
341
- )
342
- }
343
- */
344
- var makePoll = function makePoll(toolObject) {
345
- var newPaneOptions = {
346
- useExisting: meeting,
347
- // Regard the meeting as being the schedulable event itself.
348
- // newInstance: meeting,
349
- pane: dataBrowserContext.session.paneRegistry.byName('schedule'),
350
- view: 'schedule',
351
- // predicate: ns.meeting('schedulingPoll'),
352
- // newBase: meetingBase + 'Schedule/', Not needed as uses existing meeting
353
- tabTitle: 'Schedule poll',
354
- noIndexHTML: true
355
- };
356
- return makeNewPaneTool(toolObject, newPaneOptions);
357
- };
358
- var makePicturesFolder = function makePicturesFolder(folderName) {
359
- var toolObject = {
360
- icon: 'noun_598334.svg',
361
- // Slideshow @@ find a "picture" icon?
362
- limit: 1,
363
- shareTab: true // but many things behind it
364
- };
365
- var newPaneOptions = {
366
- newInstance: kb.sym(meeting.dir().uri + folderName + '/'),
367
- pane: dataBrowserContext.session.paneRegistry.byName('folder'),
368
- // @@ slideshow??
369
- predicate: ns.meeting('pictures'),
370
- shareTab: true,
371
- tabTitle: folderName,
372
- view: 'slideshow',
373
- noIndexHTML: true
374
- };
375
- return makeNewPaneTool(toolObject, newPaneOptions);
376
- };
377
- var makeMaterialsFolder = function makeMaterialsFolder(_folderName) {
378
- var toolObject = {
379
- icon: 'noun_681601.svg',
380
- // Document
381
- limit: 1,
382
- shareTab: true // but many things behind it
383
- };
384
- var options = {
385
- newInstance: kb.sym(meeting.dir().uri + 'Files/'),
386
- pane: dataBrowserContext.session.paneRegistry.byName('folder'),
387
- predicate: ns.meeting('materialsFolder'),
388
- tabTitle: 'Materials',
389
- noIndexHTML: true
390
- };
391
- return makeNewPaneTool(toolObject, options);
392
- };
393
- var makeParticipantsGroup = function makeParticipantsGroup() {
394
- var toolObject = {
395
- icon: 'noun_339237.svg',
396
- // Group of people
397
- limit: 1,
398
- // Only one tab
399
- shareTab: true // but many things behind it
400
- };
401
- var options = {
402
- newInstance: kb.sym(meeting.dir().uri + 'Attendees/index.ttl#this'),
403
- pane: dataBrowserContext.session.paneRegistry.byName('contact'),
404
- predicate: ns.meeting('attendeeGroup'),
405
- tabTitle: 'Attendees',
406
- instanceClass: ns.vcard('Group'),
407
- instanceName: UI.utils.label(subject) + ' attendees',
408
- noIndexHTML: true
409
- };
410
- return makeNewPaneTool(toolObject, options);
411
- };
412
-
413
- // Make Pad for notes of meeting
414
-
415
- var makePad = function makePad(toolObject) {
416
- var newPaneOptions = {
417
- newBase: meetingBase + 'SharedNotes/',
418
- predicate: UI.ns.meeting('sharedNotes'),
419
- tabTitle: 'Shared Notes',
420
- pane: dataBrowserContext.session.paneRegistry.byName('pad')
421
- };
422
- return makeNewPaneTool(toolObject, newPaneOptions);
423
- };
424
-
425
- // Make Sub-meeting of meeting
426
-
427
- var makeMeeting = function makeMeeting(toolObject) {
428
- UI.widgets.askName(dom, kb, parameterCell, ns.foaf('name'), UI.ns.meeting('Meeting')).then(function (name) {
429
- if (!name) {
430
- return resetTools();
431
- }
432
- var URIsegment = encodeURIComponent(name);
433
- var options = {
434
- newBase: meetingBase + URIsegment + '/',
435
- // @@@ sanitize
436
- predicate: UI.ns.meeting('subMeeting'),
437
- tabTitle: name,
438
- pane: dataBrowserContext.session.paneRegistry.byName('meeting')
439
- };
440
- return makeNewPaneTool(toolObject, options);
441
- })["catch"](function (e) {
442
- complain('Error making new sub-meeting: ' + e);
443
- });
444
- };
445
-
446
- // Returns promise of newPaneOptions
447
- // In: options.
448
- // me?, predicate, newInstance ?, newBase, instanceClass
449
- // out: options. the above plus
450
- // me, newInstance
451
-
452
- function makeNewPaneTool(toolObject, options) {
453
- return new Promise(function (resolve, reject) {
454
- var kb = dataBrowserContext.session.store;
455
- if (!options.useExisting) {
456
- // useExisting means use existing object in new role
457
- var existing = kb.any(meeting, options.predicate);
458
- if (existing) {
459
- if (toolObject.limit && toolObject.limit === 1 && !toolObject.shareTab) {
460
- complain('Already have ' + existing + ' as ' + UI.utils.label(options.predicate));
461
- complain('Cant have two');
462
- return resolve(null);
463
- }
464
- if (toolObject.shareTab) {
465
- // return existing one
466
- console.log('Using existing ' + existing + ' as ' + UI.utils.label(options.predicate));
467
- return resolve({
468
- me: me,
469
- newInstance: existing,
470
- instanceClass: options.instanceClass
471
- });
472
- }
473
- }
474
- }
475
- if (!me && !options.me) {
476
- reject(new Error('Username not defined for new tool'));
477
- }
478
- options.me = options.me || me;
479
- options.newInstance = options.useExisting || options.newInstance || kb.sym(options.newBase + 'index.ttl#this');
480
- options.pane.mintNew(dataBrowserContext, options).then(function (options) {
481
- var tool = makeToolNode(options.newInstance, options.predicate, options.tabTitle, options.pane.icon);
482
- if (options.view) {
483
- kb.add(tool, UI.ns.meeting('view'), options.view, meetingDoc);
484
- }
485
- saveBackMeetingDoc();
486
- kb.fetcher.putBack(meetingDoc, {
487
- contentType: 'text/turtle'
488
- }).then(function (_xhr) {
489
- resolve(options);
490
- })["catch"](function (err) {
491
- reject(err);
492
- });
493
- })["catch"](function (err) {
494
- complain(err);
495
- reject(err);
496
- });
497
- });
498
- }
499
- var makeAgenda = function makeAgenda(_toolObject) {
500
- // selectTool(icon)
501
- };
502
- var makeActions = function makeActions(_toolObject) {
503
- var newBase = meetingBase + 'Actions/';
504
- var kb = dataBrowserContext.session.store;
505
- if (kb.holds(meeting, ns.meeting('actions'))) {
506
- console.log('Ignored - already have actions');
507
- return; // already got one
508
- }
509
- var appDoc = kb.sym(newBase + 'config.ttl');
510
- var newInstance = kb.sym(newBase + 'config.ttl#this');
511
- var stateStore = kb.sym(newBase + 'state.ttl');
512
- kb.add(newInstance, ns.dc('title'), (kb.anyValue(meeting, ns.cal('summary')) || 'Meeting ') + ' actions', appDoc);
513
- kb.add(newInstance, ns.wf('issueClass'), ns.wf('Task'), appDoc);
514
- kb.add(newInstance, ns.wf('initialState'), ns.wf('Open'), appDoc);
515
- kb.add(newInstance, ns.wf('stateStore'), stateStore, appDoc);
516
- kb.add(newInstance, ns.wf('assigneeClass'), ns.foaf('Person'), appDoc); // @@ set to people in the meeting?
517
-
518
- kb.add(newInstance, ns.rdf('type'), ns.wf('Tracker'), appDoc);
519
-
520
- // Flag its type in the chat itself as well as in the master meeting config file
521
- kb.add(newInstance, ns.rdf('type'), ns.wf('Tracker'), appDoc);
522
- var tool = makeToolNode(newInstance, ns.meeting('actions'), 'Actions', UI.icons.iconBase + 'noun_17020.svg');
523
- saveAppDocumentLinkAndAddNewThing(tool, newInstance, ns.meeting('actions'));
524
- };
525
- var makeChat = function makeChat(_toolObject) {
526
- var newBase = meetingBase + 'Chat/';
527
- var kb = dataBrowserContext.session.store;
528
- if (kb.holds(meeting, ns.meeting('chat'))) {
529
- console.log('Ignored - already have chat');
530
- return; // already got one
531
- }
532
- var messageStore = kb.sym(newBase + 'chat.ttl');
533
- kb.add(messageStore, ns.rdf('type'), ns.meeting('Chat'), messageStore);
534
- var tool = makeToolNode(messageStore, ns.meeting('chat'), 'Chat', UI.icons.iconBase + 'noun_346319.svg');
535
- saveAppDocumentLinkAndAddNewThing(tool, messageStore, ns.meeting('chat'));
536
- };
537
- var makeVideoCall = function makeVideoCall(_toolObject) {
538
- var kb = dataBrowserContext.session.store;
539
- var newInstance = $rdf.sym(VideoRoomPrefix + UI.utils.genUuid());
540
- if (kb.holds(meeting, ns.meeting('videoCallPage'))) {
541
- console.log('Ignored - already have a videoCallPage');
542
- return; // already got one
543
- }
544
- kb.add(newInstance, ns.rdf('type'), ns.meeting('VideoCallPage'), meetingDoc);
545
- var tool = makeToolNode(newInstance, ns.meeting('videoCallPage'), 'Video call', UI.icons.iconBase + 'noun_260227.svg');
546
- kb.add(tool, ns.meeting('view'), 'iframe', meetingDoc);
547
- saveBackMeetingDoc();
548
- };
549
- var makeAttachment = function makeAttachment(_toolObject) {
550
- UI.widgets.askName(dom, kb, parameterCell, ns.log('uri'), UI.ns.rdf('Resource')).then(function (uri) {
551
- if (!uri) {
552
- return resetTools();
553
- }
554
- var kb = dataBrowserContext.session.store;
555
- var ns = UI.ns;
556
- var target = kb.sym(uri);
557
- var tool = makeToolNode(target, ns.wf('attachment'), UI.utils.label(target), null);
558
- kb.add(tool, ns.meeting('view'), 'iframe', meetingDoc);
559
- saveBackMeetingDoc();
560
- })["catch"](function (e) {
561
- complain('Error making new sub-meeting: ' + e);
562
- });
563
- };
564
- var makeSharing = function makeSharing(toolObject) {
565
- var kb = dataBrowserContext.session.store;
566
- var ns = UI.ns;
567
- var target = meeting.dir();
568
- if (toolObject.limit && toolObject.limit === 1 && kb.holds(meeting, ns.wf('sharingControl'))) {
569
- complain('Ignored - already have ' + UI.utils.label(options.predicate));
570
- return;
571
- }
572
- var tool = makeToolNode(target, ns.wf('sharingControl'), 'Sharing', UI.icons.iconBase + 'noun_123691.svg');
573
- kb.add(tool, ns.meeting('view'), 'sharing', meetingDoc);
574
- saveBackMeetingDoc();
575
- };
576
- var makeNewMeeting = function makeNewMeeting() {
577
- // @@@ make option of continuing series
578
- var appDetails = {
579
- noun: 'meeting'
580
- };
581
- var gotWS = function gotWS(ws, base) {
582
- thisPane.mintNew(dataBrowserContext, {
583
- newBase: base
584
- }).then(function (options) {
585
- var newInstance = options.newInstance;
586
- parameterCell.removeChild(mintUI);
587
- var p = parameterCell.appendChild(dom.createElement('p'));
588
- p.setAttribute('style', 'font-size: 140%;');
589
- p.innerHTML = "Your <a target='_blank' href='" + newInstance.uri + "'><b>new meeting</b></a> is ready to be set up. " + "<br/><br/><a target='_blank' href='" + newInstance.uri + "'>Go to your new meeting.</a>";
590
- })["catch"](function (err) {
591
- parameterCell.removeChild(mintUI);
592
- parameterCell.appendChild(UI.widgets.errorMessageBlock(dom, err));
593
- });
594
- };
595
- var mintUI = UI.login.selectWorkspace(dom, appDetails, gotWS);
596
- parameterCell.appendChild(mintUI);
597
- };
598
-
599
- // //////////////////////////////////////////////////////////// end of new tab creation functions
600
-
601
- var toolIcons = [{
602
- icon: 'noun_339237.svg',
603
- maker: makeGroup,
604
- hint: 'Make a group of people',
605
- limit: 1
606
- }, {
607
- icon: 'noun_346777.svg',
608
- maker: makePoll,
609
- hint: 'Make a poll to schedule the meeting'
610
- },
611
- // When meet THIS or NEXT time
612
- {
613
- icon: 'noun_48218.svg',
614
- maker: makeAgenda,
615
- limit: 1,
616
- hint: 'Add an agenda list',
617
- disabled: true
618
- },
619
- // When meet THIS or NEXT time
620
- {
621
- icon: 'noun_79217.svg',
622
- maker: makePad,
623
- hint: 'Add a shared notepad'
624
- }, {
625
- icon: 'noun_346319.svg',
626
- maker: makeChat,
627
- limit: 1,
628
- hint: 'Add a chat channel for the meeting'
629
- }, {
630
- icon: 'noun_17020.svg',
631
- maker: makeActions,
632
- limit: 1,
633
- hint: 'Add a list of action items'
634
- },
635
- // When meet THIS or NEXT time
636
- {
637
- icon: 'noun_260227.svg',
638
- maker: makeVideoCall,
639
- limit: 1,
640
- hint: 'Add a video call for the meeting'
641
- }, {
642
- icon: 'noun_25830.svg',
643
- maker: makeAttachment,
644
- hint: 'Attach meeting materials',
645
- disabled: false
646
- }, {
647
- icon: 'noun_123691.svg',
648
- maker: makeSharing,
649
- limit: 1,
650
- hint: 'Control Sharing',
651
- disabled: false
652
- }, {
653
- icon: 'noun_66617.svg',
654
- maker: makeMeeting,
655
- hint: 'Make a sub meeting',
656
- disabled: false
657
- }]; // 'noun_66617.svg'
658
-
659
- var settingsForm = $rdf.sym('https://solid.github.io/solid-panes/meeting/meetingDetailsForm.ttl#settings');
660
- $rdf.parse(meetingDetailsFormText, kb, settingsForm.doc().uri, 'text/turtle'); // Load form directly
661
-
662
- var iconStyle = 'padding: 1em; width: 3em; height: 3em;';
663
- var iconCell = toolBar.appendChild(dom.createElement('td'));
664
- var parameterCell = toolBar.appendChild(dom.createElement('td'));
665
- var star = iconCell.appendChild(dom.createElement('img'));
666
- var visible = false; // the inividual tools tools
667
-
668
- star.setAttribute('src', UI.icons.iconBase + 'noun_19460_green.svg'); // noun_272948.svg
669
- star.setAttribute('style', iconStyle + 'opacity: 50%;');
670
- star.setAttribute('title', 'Add another tool to the meeting');
671
- var selectNewTool = function selectNewTool(_event) {
672
- visible = !visible;
673
- star.setAttribute('style', iconStyle + (visible ? 'background-color: yellow;' : ''));
674
- styleTheIcons(visible ? '' : 'display: none;');
675
- };
676
- var loginOutButton;
677
- logic.authn.checkUser().then(function (webId) {
678
- if (webId) {
679
- me = webId;
680
- star.addEventListener('click', selectNewTool);
681
- star.setAttribute('style', iconStyle);
682
- return;
683
- }
684
- loginOutButton = UI.login.loginStatusBox(dom, function (webIdUri) {
685
- if (webIdUri) {
686
- me = kb.sym(webIdUri);
687
- parameterCell.removeChild(loginOutButton);
688
- // loginOutButton.setAttribute('',iconStyle) // make it match the icons
689
- star.addEventListener('click', selectNewTool);
690
- star.setAttribute('style', iconStyle);
691
- } else {
692
- console.log('(Logged out)');
693
- me = null;
694
- }
695
- });
696
- loginOutButton.setAttribute('style', 'margin: 0.5em 1em;');
697
- parameterCell.appendChild(loginOutButton);
698
- });
699
- var iconArray = [];
700
- for (var i = 0; i < toolIcons.length; i++) {
701
- var foo = function foo() {
702
- var toolObject = toolIcons[i];
703
- var icon = iconCell.appendChild(dom.createElement('img'));
704
- icon.setAttribute('src', UI.icons.iconBase + toolObject.icon);
705
- icon.setAttribute('style', iconStyle + 'display: none;');
706
- iconArray.push(icon);
707
- icon.tool = toolObject;
708
- var maker = toolObject.maker;
709
- if (!toolObject.disabled) {
710
- icon.addEventListener('click', function (_event) {
711
- selectTool(icon);
712
- maker(toolObject);
713
- });
714
- }
715
- };
716
- foo();
717
- }
718
- var styleTheIcons = function styleTheIcons(style) {
719
- for (var i = 0; i < iconArray.length; i++) {
720
- var st = iconStyle + style;
721
- if (toolIcons[i].disabled) {
722
- st += 'opacity: 0.3;';
723
- }
724
- iconArray[i].setAttribute('style', st); // eg 'background-color: #ccc;'
725
- }
726
- };
727
- var resetTools = function resetTools() {
728
- styleTheIcons('display: none;');
729
- star.setAttribute('style', iconStyle);
730
- };
731
- var selectTool = function selectTool(icon) {
732
- styleTheIcons('display: none;'); // 'background-color: #ccc;'
733
- icon.setAttribute('style', iconStyle + 'background-color: yellow;');
734
- };
735
-
736
- // //////////////////////////////
737
-
738
- var renderTab = function renderTab(div, item) {
739
- if (kb.holds(item, ns.rdf('type'), ns.meeting('Tool'))) {
740
- var target = kb.any(item, ns.meeting('target'));
741
- var label = kb.any(item, ns.rdfs('label'));
742
- label = label ? label.value : UI.utils.label(target);
743
- var s = div.appendChild(dom.createElement('div'));
744
- s.textContent = label;
745
- s.setAttribute('style', 'margin-left: 0.7em');
746
- var icon = kb.any(item, ns.meeting('icon'));
747
- if (icon) {
748
- // Make sure the icon is cleanly on the left of the label
749
- var table = div.appendChild(dom.createElement('table'));
750
- var tr = table.appendChild(dom.createElement('tr'));
751
- var left = tr.appendChild(dom.createElement('td'));
752
- var right = tr.appendChild(dom.createElement('td'));
753
- // var img = div.appendChild(dom.createElement('img'))
754
- var img = left.appendChild(dom.createElement('img'));
755
- img.setAttribute('src', icon.uri);
756
- // img.setAttribute('style', 'max-width: 1.5em; max-height: 1.5em;') // @@ SVG shrinks to 0
757
- img.setAttribute('style', 'width: 1.5em; height: 1.5em;'); // @
758
- img.setAttribute('title', label);
759
- right.appendChild(s);
760
- } else {
761
- div.appendChild(s);
762
- }
763
- } else {
764
- div.textContent = UI.utils.label(item);
765
- }
766
- };
767
- var tipDiv = function tipDiv(text) {
768
- var d = dom.createElement('div');
769
- var p = d.appendChild(dom.createElement('p'));
770
- p.setAttribute('style', 'margin: 0em; padding:3em; color: #888;');
771
- p.textContent = 'Tip: ' + text;
772
- return d;
773
- };
774
- var renderTabSettings = function renderTabSettings(containerDiv, subject) {
775
- containerDiv.innerHTML = '';
776
- containerDiv.style += 'border-color: #eed;';
777
- containerDiv.appendChild(dom.createElement('h3')).textContent = 'Adjust this tab';
778
- if (kb.holds(subject, ns.rdf('type'), ns.meeting('Tool'))) {
779
- var form = $rdf.sym('https://solid.github.io/solid-panes/meeting/meetingDetailsForm.ttl#settings');
780
- UI.widgets.appendForm(document, containerDiv, {}, subject, form, meeting.doc(), complainIfBad);
781
- var delButton = UI.widgets.deleteButtonWithCheck(dom, containerDiv, 'tab', function () {
782
- var toolList = kb.the(meeting, ns.meeting('toolList'));
783
- for (var i = 0; i < toolList.elements.length; i++) {
784
- if (toolList.elements[i].sameTerm(subject)) {
785
- toolList.elements.splice(i, 1);
786
- break;
787
- }
788
- }
789
- var target = kb.any(subject, ns.meeting('target'));
790
- var ds = kb.statementsMatching(subject).concat(kb.statementsMatching(undefined, undefined, subject)).concat(kb.statementsMatching(meeting, undefined, target));
791
- kb.remove(ds); // Remove all links to and from the tab node
792
- saveBackMeetingDoc();
793
- });
794
- delButton.setAttribute('style', 'width: 1.5em; height: 1.5em;');
795
- // delButton.setAttribute('class', '')
796
- // delButton.setAttribute('style', 'height: 2em; width: 2em; margin: 1em; border-radius: 0.5em; padding: 1em; font-size: 120%; background-color: red; color: white;')
797
- // delButton.textContent = 'Delete this tab'
798
- } else {
799
- containerDiv.appendChild(dom.createElement('h4')).textContent = '(No adjustments available)';
800
- }
801
- };
802
- var renderMain = function renderMain(containerDiv, subject) {
803
- var pane = null;
804
- var table;
805
- var selectedGroup = null;
806
- containerDiv.innerHTML = '';
807
- var complainIfBad = function complainIfBad(ok, message) {
808
- if (!ok) {
809
- containerDiv.textContent = '' + message;
810
- }
811
- };
812
- var showIframe = function showIframe(target) {
813
- var iframe = containerDiv.appendChild(dom.createElement('iframe'));
814
- // iframe.setAttribute('sandbox', '') // All restrictions
815
- iframe.setAttribute('src', target.uri);
816
- // See https://stackoverflow.com/questions/325273/make-iframe-to-fit-100-of-containers-remaining-height
817
- // Set the container position (sic) so it becaomes a 100% reference for the size of the iframe height 100%
818
- /* For now at least , leave the container style as set by the tab system. 20200115b
819
- containerDiv.setAttribute(
820
- 'style',
821
- 'position: relative; top: 0px; left:0px; right:0px; resize: both; overflow:scroll; min-width: 30em; min-height: 30em;'
822
- )
823
- */
824
- // iframe.setAttribute('style', 'height: 350px; border: 0; margin: 0; padding: 0; resize:both; overflow:scroll; width: 100%;')
825
- // iframe.setAttribute('style', 'border: none; margin: 0; padding: 0; height: 100%; width: 100%; resize: both; overflow:scroll;')
826
- iframe.setAttribute('style', 'border: none; margin: 0; padding: 0; height: 100%; width: 100%;');
827
- // Following https://dev.chromium.org/Home/chromium-security/deprecating-permissions-in-cross-origin-iframes :
828
- iframe.setAttribute('allow', 'microphone camera'); // Allow iframe to request camera and mic
829
- // containerDiv.style.resize = 'none' // Remove scroll bars on outer div - don't seem to work so well
830
- iframe.setAttribute('name', 'disable-x-frame-options'); // For electron: see https://github.com/electron/electron/pull/573
831
- containerDiv.style.padding = 0;
832
- };
833
- var renderPeoplePicker = function renderPeoplePicker() {
834
- var context = {
835
- div: containerDiv,
836
- dom: dom
837
- };
838
- containerDiv.appendChild(dom.createElement('h4')).textContent = 'Meeting Participants';
839
- var groupPickedCb = function groupPickedCb(group) {
840
- var toIns = [$rdf.st(meeting, ns.meeting('particpantGroup'), group, meeting.doc())];
841
- kb.updater.update([], toIns, function (uri, ok, message) {
842
- if (ok) {
843
- selectedGroup = group;
844
- } else {
845
- complain('Cant save participants group: ' + message);
846
- }
847
- });
848
- };
849
- selectedGroup = kb.any(meeting, ns.meeting('particpantGroup'));
850
- logic.loadTypeIndexes(context).then(function () {
851
- // Assumes that the type index has an entry for addressbook
852
- var options = {
853
- defaultNewGroupName: 'Meeting Participants',
854
- selectedGroup: selectedGroup
855
- };
856
- var picker = new UI.widgets.PeoplePicker(context.div, context.index["private"][0], groupPickedCb, options);
857
- picker.render();
858
- });
859
- };
860
- var renderDetails = function renderDetails() {
861
- containerDiv.appendChild(dom.createElement('h3')).textContent = 'Details of meeting';
862
- var form = $rdf.sym('https://solid.github.io/solid-panes/meeting/meetingDetailsForm.ttl#main');
863
- UI.widgets.appendForm(document, containerDiv, {}, meeting, form, meeting.doc(), complainIfBad);
864
- containerDiv.appendChild(tipDiv('Drag URL-bar icons of web pages into the tab bar on the left to add new meeting materials.'));
865
- me = logic.authn.currentUser();
866
- if (me) {
867
- kb.add(meeting, ns.dc('author'), me, meetingDoc); // @@ should nly be on initial creation?
868
- }
869
- var context = {
870
- noun: 'meeting',
871
- me: me,
872
- statusArea: containerDiv,
873
- div: containerDiv,
874
- dom: dom
875
- };
876
- UI.login.registrationControl(context, meeting, ns.meeting('Meeting')).then(function (_context) {
877
- console.log('Registration control finsished.');
878
- });
879
- var options = {};
880
- UI.pad.manageParticipation(dom, containerDiv, meetingDoc, meeting, me, options);
881
-
882
- // "Make a new meeting" button
883
- var imageStyle = 'height: 2em; width: 2em; margin:0.5em;';
884
- var detailsBottom = containerDiv.appendChild(dom.createElement('div'));
885
- var spawn = detailsBottom.appendChild(dom.createElement('img'));
886
- spawn.setAttribute('src', UI.icons.iconBase + 'noun_145978.svg');
887
- spawn.setAttribute('title', 'Make a fresh new meeting');
888
- spawn.addEventListener('click', makeNewMeeting);
889
- spawn.setAttribute('style', imageStyle);
890
-
891
- // "Fork me on Github" button
892
- var forka = detailsBottom.appendChild(dom.createElement('a'));
893
- forka.setAttribute('href', 'https://github.com/solid/solid-panes'); // @@ Move when code moves
894
- forka.setAttribute('target', '_blank');
895
- var fork = forka.appendChild(dom.createElement('img'));
896
- fork.setAttribute('src', UI.icons.iconBase + 'noun_368567.svg');
897
- fork.setAttribute('title', 'Fork me on github');
898
- fork.setAttribute('style', imageStyle + 'opacity: 50%;');
899
- };
900
- if (kb.holds(subject, ns.rdf('type'), ns.meeting('Tool'))) {
901
- var target = kb.any(subject, ns.meeting('target'));
902
- if (target.sameTerm(meeting) && !kb.any(subject, ns.meeting('view'))) {
903
- // self reference? force details form
904
- renderDetails(); // Legacy meeting instances
905
- } else {
906
- var view = kb.any(subject, ns.meeting('view'));
907
- view = view ? view.value : null;
908
- if (view === 'details') {
909
- renderDetails();
910
- } else if (view === 'peoplePicker') {
911
- renderPeoplePicker();
912
- } else if (view === 'iframe') {
913
- showIframe(target);
914
- } else {
915
- pane = view ? dataBrowserContext.session.paneRegistry.byName(view) : null;
916
- table = containerDiv.appendChild(dom.createElement('table'));
917
- table.style.width = '100%';
918
- dataBrowserContext.getOutliner(dom).GotoSubject(target, true, pane, false, undefined, table);
919
- }
920
- }
921
- } else if (subject.sameTerm(meeting)) {
922
- // self reference? force details form
923
- renderDetails();
924
- } else if (subject.sameTerm(subject.doc()) && !kb.holds(subject, UI.ns.rdf('type'), UI.ns.meeting('Chat')) && !kb.holds(subject, UI.ns.rdf('type'), UI.ns.meeting('PaneView'))
925
- // eslint-disable-next-line no-empty
926
- ) {} else {
927
- table = containerDiv.appendChild(dom.createElement('table'));
928
- dataBrowserContext.getOutliner(dom).GotoSubject(subject, true, undefined, false, undefined, table);
929
- }
930
- };
931
- var options = {
932
- dom: dom
933
- };
934
- options.predicate = ns.meeting('toolList');
935
- options.subject = subject;
936
- options.ordered = true;
937
- options.orientation = 1; // tabs on LHS
938
- options.renderMain = renderMain;
939
- options.renderTab = renderTab;
940
- options.renderTabSettings = renderTabSettings;
941
- options.backgroundColor = kb.anyValue(subject, ns.ui('backgroundColor')) || '#ddddcc';
942
- var tabs = mainTR.appendChild(UI.tabs.tabWidget(options));
943
- UI.aclControl.preventBrowserDropEvents(dom);
944
- UI.widgets.makeDropTarget(tabs.tabContainer, droppedURIHandler, droppedFileHandler);
945
- UI.widgets.makeDropTarget(iconCell, droppedURIHandler, droppedFileHandler);
946
- return div;
947
- }
948
- };
949
- // ends
950
- //# sourceMappingURL=meetingPane.js.map