codeapp-js 0.1.1 → 0.2.1
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.
- package/codeApp/dist/codeapp.js +317 -74
- package/codeApp/dist/index.js +1 -1
- package/codeApp/dist/power-apps-data.js +2952 -2531
- package/dev files/customConnector.js +98 -0
- package/dev files/dataverse.js +22 -7
- package/dev files/environmentVar.js +1 -1
- package/dev files/office365groups.js +1 -1
- package/dev files/office365users.js +1 -1
- package/dev files/outlook.js +1 -1
- package/dev files/power-apps-data.js +2952 -0
- package/dev files/sharepoint.js +1 -1
- package/examples/combined demo/dist/codeapp.js +1098 -0
- package/examples/combined demo/dist/index.js +470 -515
- package/examples/combined demo/dist/power-apps-data.js +3007 -2531
- package/examples/dataverse Demo/dist/codeapp.js +1085 -0
- package/examples/dataverse Demo/dist/index.js +38 -26
- package/examples/dataverse Demo/dist/power-apps-data.js +2912 -2531
- package/examples/groups Demo/dist/codeapp.js +1085 -0
- package/examples/groups Demo/dist/index.js +113 -113
- package/examples/groups Demo/dist/power-apps-data.js +2912 -2531
- package/examples/kanban/dist/power-apps-data.js +2953 -2531
- package/examples/myProfile/dist/power-apps-data.js +2953 -2531
- package/examples/outlook Demo/dist/codeapp.js +1085 -0
- package/examples/outlook Demo/dist/index.js +39 -35
- package/examples/outlook Demo/dist/power-apps-data.js +2912 -2531
- package/examples/planning Poker/dist/power-apps-data.js +2953 -2531
- package/examples/sharePoint Demo/dist/codeapp.js +1085 -0
- package/examples/sharePoint Demo/dist/index.js +262 -269
- package/examples/sharePoint Demo/dist/power-apps-data.js +2912 -2531
- package/examples/solution explorer/agent/decision-log.md +27 -0
- package/examples/solution explorer/agent/mockup-01-swiss-grid.html +452 -0
- package/examples/solution explorer/agent/mockup-02-dark-glass.html +496 -0
- package/examples/solution explorer/agent/mockup-03-paper-console.html +510 -0
- package/examples/solution explorer/agent/mockup-04-neon-noir.html +546 -0
- package/examples/solution explorer/agent/mockup-05-zen-garden.html +534 -0
- package/examples/solution explorer/dist/codeapp.js +1098 -0
- package/examples/solution explorer/dist/icon-512.png +0 -0
- package/examples/solution explorer/dist/index.html +80 -0
- package/examples/solution explorer/dist/index.js +735 -0
- package/examples/solution explorer/dist/power-apps-data.js +3007 -0
- package/examples/solution explorer/dist/styles.css +571 -0
- package/examples/solution explorer/power.config.json +151 -0
- package/examples/todo/dist/power-apps-data.js +2953 -2531
- package/package.json +1 -8
- package/.github/instructions/wyattdave.instructions.md +0 -39
- package/docs-mockups/atelier/index.html +0 -120
- package/docs-mockups/atelier/script.js +0 -23
- package/docs-mockups/atelier/styles.css +0 -361
- package/docs-mockups/field-guide/index.html +0 -112
- package/docs-mockups/field-guide/script.js +0 -20
- package/docs-mockups/field-guide/styles.css +0 -272
- package/docs-mockups/index.html +0 -80
- package/docs-mockups/maker-hub/index.html +0 -178
- package/docs-mockups/maker-hub/script.js +0 -20
- package/docs-mockups/maker-hub/styles.css +0 -404
- package/docs-mockups/script.js +0 -26
- package/docs-mockups/signal/index.html +0 -146
- package/docs-mockups/signal/script.js +0 -20
- package/docs-mockups/signal/styles.css +0 -314
- package/docs-mockups/styles.css +0 -287
- package/examples/combined demo/dist/dataverse.js +0 -86
- package/examples/combined demo/dist/environmentVar.js +0 -55
- package/examples/combined demo/dist/office365groups.js +0 -97
- package/examples/combined demo/dist/office365users.js +0 -169
- package/examples/combined demo/dist/outlook.js +0 -162
- package/examples/combined demo/dist/sharepoint.js +0 -339
- package/examples/dataverse Demo/dist/dataverse.js +0 -86
- package/examples/groups Demo/dist/dataverse.js +0 -86
- package/examples/groups Demo/dist/environmentVar.js +0 -55
- package/examples/groups Demo/dist/office365groups.js +0 -97
- package/examples/groups Demo/dist/office365users.js +0 -169
- package/examples/groups Demo/dist/outlook.js +0 -162
- package/examples/groups Demo/dist/sharepoint.js +0 -339
- package/examples/sharePoint Demo/dist/dataverse.js +0 -94
- package/examples/sharePoint Demo/dist/environmentVar.js +0 -55
- package/examples/sharePoint Demo/dist/office365groups.js +0 -97
- package/examples/sharePoint Demo/dist/office365users.js +0 -169
- package/examples/sharePoint Demo/dist/outlook.js +0 -162
- package/examples/sharePoint Demo/dist/sharepoint.js +0 -339
- package/scripts/build-power-sdk.mjs +0 -69
|
@@ -1,515 +1,470 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
let
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function
|
|
155
|
-
if (!
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function
|
|
168
|
-
if (oValue
|
|
169
|
-
return
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if (typeof oValue === 'string') {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (
|
|
181
|
-
return
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (
|
|
185
|
-
return oValue;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
return
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
function
|
|
192
|
-
let
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
if (!
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
let
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
if (
|
|
240
|
-
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
return
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
function
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
setStatus('
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
function attachEvents() {
|
|
475
|
-
if (eRefreshButton) {
|
|
476
|
-
eRefreshButton.addEventListener('click', () => {
|
|
477
|
-
handleRefreshClick().catch((oErr) => {
|
|
478
|
-
setStatus('Refresh failed: ' + (oErr.message || oErr), 'error');
|
|
479
|
-
});
|
|
480
|
-
});
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
if (eScrollComposeButton) {
|
|
484
|
-
eScrollComposeButton.addEventListener('click', handleScrollComposeClick);
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
if (eComposeForm) {
|
|
488
|
-
eComposeForm.addEventListener('submit', (oEvent) => {
|
|
489
|
-
handleComposeSubmit(oEvent).catch((oErr) => {
|
|
490
|
-
setStatus('Send email failed: ' + (oErr.message || oErr), 'error');
|
|
491
|
-
});
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
async function boot() {
|
|
497
|
-
cacheDomElements();
|
|
498
|
-
attachEvents();
|
|
499
|
-
renderProfile();
|
|
500
|
-
renderEmails();
|
|
501
|
-
renderGroups();
|
|
502
|
-
|
|
503
|
-
try {
|
|
504
|
-
getSharedClient();
|
|
505
|
-
await loadDashboard();
|
|
506
|
-
} catch (oErr) {
|
|
507
|
-
setStatus('App failed to start: ' + (oErr.message || oErr), 'error');
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
window.addEventListener('DOMContentLoaded', () => {
|
|
512
|
-
boot().catch((oErr) => {
|
|
513
|
-
setStatus('App failed to start: ' + (oErr.message || oErr), 'error');
|
|
514
|
-
});
|
|
515
|
-
});
|
|
1
|
+
|
|
2
|
+
import { getMyProfile, listEmails, listMyGroups } from './codeapp.js';
|
|
3
|
+
import { getClient } from './power-apps-data.js';
|
|
4
|
+
|
|
5
|
+
// ── SendEmailV2 connector (not yet in codeapp.js) ─────────────
|
|
6
|
+
const SEND_EMAIL_CANDIDATES = ['office365outlook', 'Office365Outlook', 'office365'];
|
|
7
|
+
const SEND_EMAIL_APIS = {
|
|
8
|
+
SendEmailV2: {
|
|
9
|
+
path: '/{connectionId}/v2/Mail',
|
|
10
|
+
method: 'POST',
|
|
11
|
+
parameters: [
|
|
12
|
+
{ name: 'connectionId', in: 'path', required: true },
|
|
13
|
+
{ name: 'emailMessage', in: 'body', required: true }
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
let oSendClient = null;
|
|
19
|
+
|
|
20
|
+
function getSendClient() {
|
|
21
|
+
if (!oSendClient) {
|
|
22
|
+
let oSources = {};
|
|
23
|
+
SEND_EMAIL_CANDIDATES.forEach((sName) => {
|
|
24
|
+
oSources[sName] = {
|
|
25
|
+
tableId: '',
|
|
26
|
+
version: '',
|
|
27
|
+
primaryKey: '',
|
|
28
|
+
dataSourceType: 'Connector',
|
|
29
|
+
apis: SEND_EMAIL_APIS
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
oSendClient = getClient(oSources);
|
|
33
|
+
}
|
|
34
|
+
return oSendClient;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let eStatusMessage = null;
|
|
38
|
+
let eProfileCard = null;
|
|
39
|
+
let eProfileStatus = null;
|
|
40
|
+
let eEmailList = null;
|
|
41
|
+
let eGroupList = null;
|
|
42
|
+
let eEmailCount = null;
|
|
43
|
+
let eGroupCount = null;
|
|
44
|
+
let eRefreshButton = null;
|
|
45
|
+
let eScrollComposeButton = null;
|
|
46
|
+
let eComposeForm = null;
|
|
47
|
+
let eComposeTo = null;
|
|
48
|
+
let eComposeSubject = null;
|
|
49
|
+
let eComposeBody = null;
|
|
50
|
+
let eSendButton = null;
|
|
51
|
+
|
|
52
|
+
let oProfile = null;
|
|
53
|
+
let aEmails = [];
|
|
54
|
+
let aGroups = [];
|
|
55
|
+
|
|
56
|
+
function getElement(sId) {
|
|
57
|
+
return document.getElementById(sId);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function cacheDomElements() {
|
|
61
|
+
eStatusMessage = getElement('statusMessage');
|
|
62
|
+
eProfileCard = getElement('profileCard');
|
|
63
|
+
eProfileStatus = getElement('profileStatus');
|
|
64
|
+
eEmailList = getElement('emailList');
|
|
65
|
+
eGroupList = getElement('groupList');
|
|
66
|
+
eEmailCount = getElement('emailCount');
|
|
67
|
+
eGroupCount = getElement('groupCount');
|
|
68
|
+
eRefreshButton = getElement('refreshButton');
|
|
69
|
+
eScrollComposeButton = getElement('scrollComposeButton');
|
|
70
|
+
eComposeForm = getElement('composeForm');
|
|
71
|
+
eComposeTo = getElement('composeTo');
|
|
72
|
+
eComposeSubject = getElement('composeSubject');
|
|
73
|
+
eComposeBody = getElement('composeBody');
|
|
74
|
+
eSendButton = getElement('sendButton');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function escapeHtml(sValue) {
|
|
78
|
+
let sText = String(sValue == null ? '' : sValue);
|
|
79
|
+
return sText
|
|
80
|
+
.replace(new RegExp('&', 'g'), '&')
|
|
81
|
+
.replace(new RegExp('<', 'g'), '<')
|
|
82
|
+
.replace(new RegExp('>', 'g'), '>')
|
|
83
|
+
.replace(new RegExp('"', 'g'), '"')
|
|
84
|
+
.replace(new RegExp("'", 'g'), ''');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function setStatus(sMessage, sTone = 'info') {
|
|
88
|
+
if (!eStatusMessage) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
eStatusMessage.textContent = sMessage;
|
|
92
|
+
eStatusMessage.className = 'statusBar ' + sTone;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function getInitials(sName) {
|
|
96
|
+
let aParts = String(sName || 'U').trim().split(new RegExp('\\s+', 'g')).filter(Boolean);
|
|
97
|
+
return aParts.slice(0, 2).map((sPart) => sPart.charAt(0).toUpperCase()).join('');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function normalizePayload(oValue) {
|
|
101
|
+
if (oValue == null) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (typeof oValue === 'string') {
|
|
106
|
+
try {
|
|
107
|
+
return JSON.parse(oValue);
|
|
108
|
+
} catch (oErr) {
|
|
109
|
+
return oValue;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (typeof oValue === 'object' && Object.prototype.hasOwnProperty.call(oValue, 'body')) {
|
|
114
|
+
return normalizePayload(oValue.body);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (typeof oValue === 'object' && Object.prototype.hasOwnProperty.call(oValue, 'value') && Array.isArray(oValue.value)) {
|
|
118
|
+
return oValue;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return oValue;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function getArrayFromPayload(oValue) {
|
|
125
|
+
let oPayload = normalizePayload(oValue);
|
|
126
|
+
|
|
127
|
+
if (Array.isArray(oPayload)) {
|
|
128
|
+
return oPayload;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (oPayload && Array.isArray(oPayload.value)) {
|
|
132
|
+
return oPayload.value;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (oPayload && Array.isArray(oPayload.messages)) {
|
|
136
|
+
return oPayload.messages;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (oPayload && Array.isArray(oPayload.items)) {
|
|
140
|
+
return oPayload.items;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return [];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function getProfileFromPayload(oValue) {
|
|
147
|
+
let oPayload = normalizePayload(oValue);
|
|
148
|
+
if (!oPayload || typeof oPayload !== 'object') {
|
|
149
|
+
return {};
|
|
150
|
+
}
|
|
151
|
+
return oPayload.user && typeof oPayload.user === 'object' ? oPayload.user : oPayload;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function formatEmailDate(sValue) {
|
|
155
|
+
if (!sValue) {
|
|
156
|
+
return 'No date';
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
let oDate = new Date(sValue);
|
|
160
|
+
if (Number.isNaN(oDate.getTime())) {
|
|
161
|
+
return String(sValue);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return oDate.toLocaleString();
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function getEmailFromValue(oValue) {
|
|
168
|
+
if (!oValue || typeof oValue !== 'object') {
|
|
169
|
+
return '';
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (typeof oValue.address === 'string') {
|
|
173
|
+
return oValue.address;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (typeof oValue.email === 'string') {
|
|
177
|
+
return oValue.email;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (oValue.emailAddress && typeof oValue.emailAddress.address === 'string') {
|
|
181
|
+
return oValue.emailAddress.address;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (oValue.EmailAddress && typeof oValue.EmailAddress.Address === 'string') {
|
|
185
|
+
return oValue.EmailAddress.Address;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return '';
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function getSenderLabel(oEmail) {
|
|
192
|
+
let oFrom = oEmail.from || oEmail.From || oEmail.sender || oEmail.Sender || {};
|
|
193
|
+
if (oFrom.emailAddress && typeof oFrom.emailAddress === 'object') {
|
|
194
|
+
return oFrom.emailAddress.name || oFrom.emailAddress.address || 'Unknown sender';
|
|
195
|
+
}
|
|
196
|
+
if (oFrom.EmailAddress && typeof oFrom.EmailAddress === 'object') {
|
|
197
|
+
return oFrom.EmailAddress.Name || oFrom.EmailAddress.Address || 'Unknown sender';
|
|
198
|
+
}
|
|
199
|
+
if (typeof oFrom.displayName === 'string') {
|
|
200
|
+
return oFrom.displayName;
|
|
201
|
+
}
|
|
202
|
+
return getEmailFromValue(oFrom) || 'Unknown sender';
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function getGroupTagsMarkup(oGroup) {
|
|
206
|
+
let aTags = Array.isArray(oGroup.groupTypes) ? oGroup.groupTypes : [];
|
|
207
|
+
return aTags.map((sTag) => '<span class="pill">' + escapeHtml(sTag) + '</span>').join('');
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function renderProfile() {
|
|
211
|
+
if (!eProfileCard) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (!oProfile || Object.keys(oProfile).length === 0) {
|
|
216
|
+
eProfileCard.innerHTML = '<div class="emptyState">Profile information was not returned.</div>';
|
|
217
|
+
if (eProfileStatus) {
|
|
218
|
+
eProfileStatus.textContent = 'Unavailable';
|
|
219
|
+
}
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
let sName = oProfile.displayName || oProfile.DisplayName || oProfile.name || 'Unknown user';
|
|
224
|
+
let sEmail = oProfile.mail || oProfile.Mail || oProfile.userPrincipalName || oProfile.UserPrincipalName || '';
|
|
225
|
+
let sJobTitle = oProfile.jobTitle || oProfile.JobTitle || 'No title';
|
|
226
|
+
let sDepartment = oProfile.department || oProfile.Department || 'No department';
|
|
227
|
+
let sPhone = oProfile.mobilePhone || oProfile.MobilePhone || '';
|
|
228
|
+
|
|
229
|
+
eProfileCard.innerHTML = `
|
|
230
|
+
<div class="profileBadge">${escapeHtml(getInitials(sName))}</div>
|
|
231
|
+
<div>
|
|
232
|
+
<h3 class="profileName">${escapeHtml(sName)}</h3>
|
|
233
|
+
<p class="profileMeta">${escapeHtml(sJobTitle)} · ${escapeHtml(sDepartment)}</p>
|
|
234
|
+
<p class="profileSubMeta">${escapeHtml(sEmail || 'No email')}</p>
|
|
235
|
+
<p class="profileSubMeta">${escapeHtml(sPhone || 'No phone')}</p>
|
|
236
|
+
</div>
|
|
237
|
+
`;
|
|
238
|
+
|
|
239
|
+
if (eProfileStatus) {
|
|
240
|
+
eProfileStatus.textContent = 'Ready';
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function renderEmails() {
|
|
245
|
+
if (!eEmailList) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (eEmailCount) {
|
|
250
|
+
eEmailCount.textContent = String(aEmails.length);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (!Array.isArray(aEmails) || aEmails.length === 0) {
|
|
254
|
+
eEmailList.innerHTML = '<div class="emptyState">No emails were returned.</div>';
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
eEmailList.innerHTML = aEmails.map((oEmail) => {
|
|
259
|
+
let sSubject = oEmail.subject || oEmail.Subject || '(No subject)';
|
|
260
|
+
let sPreview = oEmail.bodyPreview || oEmail.BodyPreview || oEmail.body || oEmail.Body || '';
|
|
261
|
+
let sReceived = oEmail.receivedDateTime || oEmail.DateTimeReceived || oEmail.createdDateTime || '';
|
|
262
|
+
let sSender = getSenderLabel(oEmail);
|
|
263
|
+
|
|
264
|
+
return `
|
|
265
|
+
<article class="listCard">
|
|
266
|
+
<h3 class="listTitle">${escapeHtml(sSubject)}</h3>
|
|
267
|
+
<p class="listMeta">From: ${escapeHtml(sSender)} · ${escapeHtml(formatEmailDate(sReceived))}</p>
|
|
268
|
+
<p class="listBody">${escapeHtml(String(sPreview).slice(0, 220) || 'No preview available.')}</p>
|
|
269
|
+
</article>
|
|
270
|
+
`;
|
|
271
|
+
}).join('');
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function renderGroups() {
|
|
275
|
+
if (!eGroupList) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
if (eGroupCount) {
|
|
280
|
+
eGroupCount.textContent = String(aGroups.length);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (!Array.isArray(aGroups) || aGroups.length === 0) {
|
|
284
|
+
eGroupList.innerHTML = '<div class="emptyState">No group memberships were returned.</div>';
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
eGroupList.innerHTML = aGroups.map((oGroup) => {
|
|
289
|
+
let sName = oGroup.displayName || oGroup.DisplayName || 'Unnamed group';
|
|
290
|
+
let sDescription = oGroup.description || oGroup.Description || 'No description';
|
|
291
|
+
let sMail = oGroup.mail || oGroup.Mail || 'No group mailbox';
|
|
292
|
+
|
|
293
|
+
return `
|
|
294
|
+
<article class="listCard">
|
|
295
|
+
<h3 class="listTitle">${escapeHtml(sName)}</h3>
|
|
296
|
+
<p class="listMeta">${escapeHtml(sMail)}</p>
|
|
297
|
+
<p class="listBody">${escapeHtml(sDescription)}</p>
|
|
298
|
+
${getGroupTagsMarkup(oGroup)}
|
|
299
|
+
</article>
|
|
300
|
+
`;
|
|
301
|
+
}).join('');
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
async function loadProfile() {
|
|
305
|
+
oProfile = getProfileFromPayload(await getMyProfile());
|
|
306
|
+
renderProfile();
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
async function loadEmails() {
|
|
310
|
+
aEmails = getArrayFromPayload(await listEmails({ folderId: 'Inbox', top: 15 }));
|
|
311
|
+
renderEmails();
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
async function loadGroups() {
|
|
315
|
+
aGroups = getArrayFromPayload(await listMyGroups());
|
|
316
|
+
renderGroups();
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
async function sendEmailMessage(sTo, sSubject, sBody) {
|
|
320
|
+
let client = getSendClient();
|
|
321
|
+
let aErrors = [];
|
|
322
|
+
|
|
323
|
+
for (let iIndex = 0; iIndex < SEND_EMAIL_CANDIDATES.length; iIndex += 1) {
|
|
324
|
+
let sName = SEND_EMAIL_CANDIDATES[iIndex];
|
|
325
|
+
try {
|
|
326
|
+
let oResult = await client.executeAsync({
|
|
327
|
+
connectorOperation: {
|
|
328
|
+
tableName: sName,
|
|
329
|
+
operationName: 'SendEmailV2',
|
|
330
|
+
parameters: {
|
|
331
|
+
emailMessage: {
|
|
332
|
+
To: sTo,
|
|
333
|
+
Subject: sSubject,
|
|
334
|
+
Body: sBody,
|
|
335
|
+
Importance: 'Normal',
|
|
336
|
+
IsHtml: true
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
if (oResult && oResult.success === false) {
|
|
342
|
+
throw new Error(oResult.error ? (oResult.error.message || JSON.stringify(oResult.error)) : 'Send failed');
|
|
343
|
+
}
|
|
344
|
+
return oResult && Object.prototype.hasOwnProperty.call(oResult, 'data') ? oResult.data : oResult;
|
|
345
|
+
} catch (oErr) {
|
|
346
|
+
let sMessage = oErr.message || String(oErr);
|
|
347
|
+
aErrors.push(sName + ': ' + sMessage);
|
|
348
|
+
if (sMessage.indexOf('Connection reference not found') === -1) {
|
|
349
|
+
throw oErr;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
throw new Error('No Outlook connection reference matched. Tried: ' + aErrors.join(' || '));
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
async function loadDashboard() {
|
|
358
|
+
setStatus('Loading your dashboard…', 'info');
|
|
359
|
+
|
|
360
|
+
let aResults = await Promise.allSettled([
|
|
361
|
+
loadProfile(),
|
|
362
|
+
loadEmails(),
|
|
363
|
+
loadGroups()
|
|
364
|
+
]);
|
|
365
|
+
|
|
366
|
+
let aErrors = aResults
|
|
367
|
+
.filter((oResult) => oResult.status === 'rejected')
|
|
368
|
+
.map((oResult) => oResult.reason?.message || String(oResult.reason));
|
|
369
|
+
|
|
370
|
+
renderProfile();
|
|
371
|
+
renderEmails();
|
|
372
|
+
renderGroups();
|
|
373
|
+
|
|
374
|
+
if (aErrors.length > 0) {
|
|
375
|
+
setStatus('Loaded with connector issues: ' + aErrors.join(' | '), 'error');
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
setStatus('Dashboard loaded successfully.', 'success');
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
async function handleRefreshClick() {
|
|
383
|
+
await loadDashboard();
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function handleScrollComposeClick() {
|
|
387
|
+
let eComposeSection = getElement('composeSection');
|
|
388
|
+
if (eComposeSection) {
|
|
389
|
+
eComposeSection.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
async function handleComposeSubmit(oEvent) {
|
|
394
|
+
oEvent.preventDefault();
|
|
395
|
+
|
|
396
|
+
let sTo = String(eComposeTo?.value || '').trim();
|
|
397
|
+
let sSubject = String(eComposeSubject?.value || '').trim();
|
|
398
|
+
let sBody = String(eComposeBody?.value || '').trim();
|
|
399
|
+
|
|
400
|
+
if (!sTo || !sSubject || !sBody) {
|
|
401
|
+
setStatus('Complete the To, Subject, and Message fields before sending.', 'error');
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
try {
|
|
406
|
+
if (eSendButton) {
|
|
407
|
+
eSendButton.disabled = true;
|
|
408
|
+
eSendButton.textContent = 'Sending...';
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
setStatus('Sending email…', 'info');
|
|
412
|
+
await sendEmailMessage(sTo, sSubject, sBody);
|
|
413
|
+
|
|
414
|
+
if (eComposeForm) {
|
|
415
|
+
eComposeForm.reset();
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
setStatus('Email sent successfully.', 'success');
|
|
419
|
+
await loadEmails();
|
|
420
|
+
} catch (oErr) {
|
|
421
|
+
setStatus('Send email failed: ' + (oErr.message || oErr), 'error');
|
|
422
|
+
} finally {
|
|
423
|
+
if (eSendButton) {
|
|
424
|
+
eSendButton.disabled = false;
|
|
425
|
+
eSendButton.textContent = 'Send email';
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function attachEvents() {
|
|
431
|
+
if (eRefreshButton) {
|
|
432
|
+
eRefreshButton.addEventListener('click', () => {
|
|
433
|
+
handleRefreshClick().catch((oErr) => {
|
|
434
|
+
setStatus('Refresh failed: ' + (oErr.message || oErr), 'error');
|
|
435
|
+
});
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
if (eScrollComposeButton) {
|
|
440
|
+
eScrollComposeButton.addEventListener('click', handleScrollComposeClick);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
if (eComposeForm) {
|
|
444
|
+
eComposeForm.addEventListener('submit', (oEvent) => {
|
|
445
|
+
handleComposeSubmit(oEvent).catch((oErr) => {
|
|
446
|
+
setStatus('Send email failed: ' + (oErr.message || oErr), 'error');
|
|
447
|
+
});
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
async function boot() {
|
|
453
|
+
cacheDomElements();
|
|
454
|
+
attachEvents();
|
|
455
|
+
renderProfile();
|
|
456
|
+
renderEmails();
|
|
457
|
+
renderGroups();
|
|
458
|
+
|
|
459
|
+
try {
|
|
460
|
+
await loadDashboard();
|
|
461
|
+
} catch (oErr) {
|
|
462
|
+
setStatus('App failed to start: ' + (oErr.message || oErr), 'error');
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
window.addEventListener('DOMContentLoaded', () => {
|
|
467
|
+
boot().catch((oErr) => {
|
|
468
|
+
setStatus('App failed to start: ' + (oErr.message || oErr), 'error');
|
|
469
|
+
});
|
|
470
|
+
});
|