meeting-pane 2.3.6 → 2.3.7-bbf45639

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