codeapp-js 0.2.2 → 1.0.0
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/AI/codeapp.agent.md +105 -0
- package/AI/skills/connections/SKILL.md +47 -0
- package/AI/skills/dataverse/SKILL.md +99 -0
- package/AI/skills/environment-variables/SKILL.md +89 -0
- package/AI/skills/frontend-design/SKILL.md +34 -0
- package/AI/skills/jira/SKILL.md +81 -0
- package/AI/skills/office365-groups/SKILL.md +61 -0
- package/AI/skills/office365-outlook/SKILL.md +52 -0
- package/AI/skills/office365-users/SKILL.md +78 -0
- package/AI/skills/sharepoint/SKILL.md +77 -0
- package/AI/skills/sql/SKILL.md +85 -0
- package/AI/skills/start/SKILL.md +46 -0
- package/AI/skills/teams/SKILL.md +55 -0
- package/codeApp/.power/schemas/appschemas/dataSourcesInfo.ts +6275 -0
- package/codeApp/.power/schemas/jira/jira.Schema.json +6903 -0
- package/codeApp/.power/schemas/keyvault/keyvault.Schema.json +1600 -0
- package/{examples/combined demo/.power/schemas/office365groups/office365groups.Schema.json → codeApp/.power/schemas/office365groups/office365groups.Schema.json} +2203 -2203
- package/codeApp/.power/schemas/teams/teams.Schema.json +11112 -0
- package/codeApp/dist/codeapp.js +103 -1043
- package/codeApp/dist/connectors/azureKeyvault.js +459 -0
- package/codeApp/dist/connectors/jira.js +1247 -0
- package/codeApp/dist/connectors/office365groups.js +642 -0
- package/codeApp/dist/connectors/office365users.js +513 -0
- package/codeApp/dist/connectors/outlook.js +1393 -0
- package/{examples/kanban/dist → codeApp/dist/connectors}/sharepoint.js +466 -339
- package/codeApp/dist/connectors/sql.js +149 -0
- package/codeApp/dist/connectors/teams.js +280 -0
- package/codeApp/dist/index.js +1 -1
- package/codeApp/dist/power-apps-data.js +725 -176
- package/codeApp/src/generated/index.ts +12 -0
- package/codeApp/src/generated/models/AzureKeyVaultModel.ts +107 -0
- package/codeApp/src/generated/models/JiraModel.ts +501 -0
- package/codeApp/src/generated/services/AzureKeyVaultService.ts +257 -0
- package/codeApp/src/generated/services/JiraService.ts +1124 -0
- package/examples/{kanban → apps/kanban}/dist/dataverse.js +94 -94
- package/examples/{kanban → apps/kanban}/dist/index.css +605 -605
- package/examples/{kanban → apps/kanban}/dist/index.html +21 -21
- package/examples/{kanban → apps/kanban}/dist/index.js +860 -860
- package/examples/{kanban → apps/kanban}/dist/office365groups.js +97 -97
- package/examples/apps/kanban/dist/office365users.js +451 -0
- package/examples/{kanban → apps/kanban}/dist/outlook.js +162 -162
- package/examples/{planning Poker/dist/power-apps-data.js → apps/kanban/dist/power-apps-data.js} +2953 -2953
- package/{dev files/sharepoint.js → examples/apps/kanban/dist/sharepoint.js} +195 -99
- package/examples/{kanban → apps/kanban}/power.config.json +35 -35
- package/examples/{planning Poker → apps/planning Poker}/additional files/customizations (tables).xml +6428 -6428
- package/examples/{planning Poker → apps/planning Poker}/additional files/dataverse-tables.json +165 -165
- package/examples/{planning Poker → apps/planning Poker}/additional files/readme.md +122 -122
- package/examples/{planning Poker → apps/planning Poker}/dist/dataverse.js +78 -78
- package/examples/{planning Poker → apps/planning Poker}/dist/index.html +198 -198
- package/examples/{planning Poker → apps/planning Poker}/dist/index.js +954 -954
- package/examples/{kanban/dist/power-apps-data.js → apps/planning Poker/dist/power-apps-data.js } +2953 -2953
- package/examples/{planning Poker → apps/planning Poker}/dist/styles.css +815 -815
- package/examples/{planning Poker → apps/planning Poker}/power.config.json +50 -50
- package/examples/{solution explorer → apps/solution explorer}/dist/codeapp.js +1098 -1098
- package/examples/{solution explorer → apps/solution explorer}/dist/index.html +80 -80
- package/examples/{solution explorer → apps/solution explorer}/dist/index.js +735 -735
- package/examples/{solution explorer → apps/solution explorer}/dist/styles.css +571 -571
- package/examples/{solution explorer → apps/solution explorer}/power.config.json +150 -150
- package/examples/{todo → apps/todo}/dist/dataverse.js +64 -64
- package/examples/{todo → apps/todo}/dist/index.html +75 -75
- package/examples/{todo → apps/todo}/dist/index.js +8 -8
- package/examples/{todo → apps/todo}/dist/power-apps-data.js +2953 -2953
- package/examples/{todo → apps/todo}/dist/renderer.js +375 -375
- package/examples/{todo → apps/todo}/dist/styles.css +691 -691
- package/examples/{todo → apps/todo}/power.config.json +34 -34
- package/examples/combined demo/.power/schemas/appschemas/dataSourcesInfo.ts +6275 -7830
- package/examples/combined demo/.power/schemas/jira/jira.Schema.json +6903 -0
- package/examples/combined demo/.power/schemas/keyvault/keyvault.Schema.json +1600 -0
- package/examples/combined demo/.power/schemas/teams/teams.Schema.json +11112 -0
- package/examples/combined demo/dist/codeapp.js +394 -1098
- package/examples/combined demo/dist/index.html +29 -511
- package/examples/combined demo/dist/index.js +490 -470
- package/examples/combined demo/dist/office365users.js +513 -0
- package/examples/combined demo/dist/outlook.js +1393 -0
- package/examples/combined demo/dist/power-apps-data.js +3079 -3006
- package/examples/combined demo/dist/styles.css +483 -0
- package/examples/combined demo/power.config.json +33 -42
- package/examples/combined demo/src/generated/index.ts +12 -14
- package/examples/combined demo/src/generated/models/AzureKeyVaultModel.ts +107 -0
- package/examples/combined demo/src/generated/models/JiraModel.ts +501 -0
- package/examples/combined demo/src/generated/services/AzureKeyVaultService.ts +257 -0
- package/examples/combined demo/src/generated/services/JiraService.ts +1124 -0
- package/examples/dataverse Demo/dist/codeapp.js +394 -1085
- package/examples/{outlook Demo2/OutlookDemo_1_0_0_1.zip → dataverse Demo/dist/icon-512.png} +0 -0
- package/examples/dataverse Demo/dist/index.html +146 -54
- package/examples/dataverse Demo/dist/index.js +693 -83
- package/examples/dataverse Demo/dist/power-apps-data.js +3079 -2911
- package/examples/dataverse Demo/dist/styles.css +528 -0
- package/examples/dataverse Demo/power.config.json +41 -35
- package/examples/dataverse Demo/readme.md +79 -79
- package/examples/groups Demo/dist/codeapp.js +394 -1085
- package/examples/groups Demo/dist/icon-512.png +0 -0
- package/examples/groups Demo/dist/index.html +21 -25
- package/examples/groups Demo/dist/index.js +304 -113
- package/examples/groups Demo/dist/office365groups.js +642 -0
- package/examples/groups Demo/dist/power-apps-data.js +3079 -2911
- package/examples/groups Demo/dist/styles.css +509 -0
- package/examples/groups Demo/power.config.json +25 -25
- package/examples/myProfile/dist/codeapp.js +398 -0
- package/examples/myProfile/dist/index.html +21 -184
- package/examples/myProfile/dist/index.js +324 -141
- package/examples/myProfile/dist/office365users.js +517 -169
- package/examples/myProfile/dist/power-apps-data.js +3080 -2953
- package/examples/myProfile/dist/styles.css +458 -0
- package/examples/myProfile/power.config.json +24 -23
- package/examples/outlook Demo/dist/codeapp.js +394 -1085
- package/examples/outlook Demo/dist/index.html +150 -35
- package/examples/outlook Demo/dist/index.js +516 -170
- package/examples/outlook Demo/dist/outlook.js +1393 -121
- package/examples/outlook Demo/dist/power-apps-data.js +3079 -2911
- package/examples/outlook Demo/dist/styles.css +408 -84
- package/examples/outlook Demo/power.config.json +24 -23
- package/examples/outlook Demo/readme.md +92 -82
- package/examples/sharePoint Demo/dist/codeapp.js +394 -1085
- package/examples/sharePoint Demo/dist/icon-512.png +0 -0
- package/examples/sharePoint Demo/dist/index.html +22 -255
- package/examples/sharePoint Demo/dist/index.js +899 -262
- package/examples/sharePoint Demo/dist/power-apps-data.js +3079 -2911
- package/examples/sharePoint Demo/dist/sharepoint.js +466 -0
- package/examples/sharePoint Demo/dist/styles.css +587 -0
- package/examples/sharePoint Demo/power.config.json +23 -22
- package/package.json +1 -1
- package/readme.md +479 -61
- package/.github/instructions/wyattdave.instructions.md +0 -39
- package/.vscode/settings.json +0 -6
- package/dev files/dataverse.js +0 -105
- package/dev files/office365groups.js +0 -65
- package/dev files/office365users.js +0 -169
- package/dev files/outlook.js +0 -330
- package/examples/combined demo/.power/schemas/office365/office365.Schema.json +0 -21098
- package/examples/combined demo/.power/schemas/office365users/office365users.Schema.json +0 -2094
- package/examples/kanban/agent/decision-log.md +0 -9
- package/examples/kanban/agent/mockup-01-editorial-glass.html +0 -159
- package/examples/kanban/agent/mockup-02-dark-rail.html +0 -147
- package/examples/kanban/agent/mockup-03-paper-grid.html +0 -114
- package/examples/kanban/agent/mockup-04-neon-minimal.html +0 -141
- package/examples/kanban/agent/mockup-05-mono-architect.html +0 -119
- package/examples/kanban/dist/environmentVar.js +0 -55
- package/examples/kanban/dist/office365users.js +0 -169
- package/examples/kanban/src/generated/index.ts +0 -14
- package/examples/outlook Demo2/agent/decision-log.md +0 -7
- package/examples/outlook Demo2/dist/codeapp.js +0 -1334
- package/examples/outlook Demo2/dist/index.html +0 -98
- package/examples/outlook Demo2/dist/index.js +0 -346
- package/examples/outlook Demo2/dist/styles.css +0 -639
- package/examples/outlook Demo2/power.config.json +0 -23
- package/examples/planning Poker/.vscode/settings.json +0 -5
- package/examples/sharePoint Demo/agent/decision-log.md +0 -17
- package/examples/solution explorer/agent/decision-log.md +0 -27
- package/examples/solution explorer/agent/mockup-01-swiss-grid.html +0 -452
- package/examples/solution explorer/agent/mockup-02-dark-glass.html +0 -496
- package/examples/solution explorer/agent/mockup-03-paper-console.html +0 -510
- package/examples/solution explorer/agent/mockup-04-neon-noir.html +0 -546
- package/examples/solution explorer/agent/mockup-05-zen-garden.html +0 -534
- package/examples/solution explorer/dist/power-apps-data.js +0 -3007
- package/scripts/build-power-sdk.mjs +0 -69
- /package/{examples/kanban → codeApp}/src/generated/models/Office365GroupsModel.ts +0 -0
- /package/{examples/kanban → codeApp}/src/generated/models/Office365OutlookModel.ts +0 -0
- /package/{examples/kanban → codeApp}/src/generated/models/Office365UsersModel.ts +0 -0
- /package/{examples/kanban → codeApp}/src/generated/services/Office365GroupsService.ts +0 -0
- /package/{examples/kanban → codeApp}/src/generated/services/Office365OutlookService.ts +0 -0
- /package/{examples/kanban → codeApp}/src/generated/services/Office365UsersService.ts +0 -0
- /package/{dev files → examples/apps/kanban/dist}/environmentVar.js +0 -0
- /package/examples/{outlook Demo2 → apps/kanban}/src/generated/index.ts +0 -0
- /package/examples/{outlook Demo2 → apps/kanban}/src/generated/models/Office365GroupsModel.ts +0 -0
- /package/examples/{outlook Demo2 → apps/kanban}/src/generated/models/Office365OutlookModel.ts +0 -0
- /package/examples/{outlook Demo2 → apps/kanban}/src/generated/models/Office365UsersModel.ts +0 -0
- /package/examples/{outlook Demo2 → apps/kanban}/src/generated/services/Office365GroupsService.ts +0 -0
- /package/examples/{outlook Demo2 → apps/kanban}/src/generated/services/Office365OutlookService.ts +0 -0
- /package/examples/{outlook Demo2 → apps/kanban}/src/generated/services/Office365UsersService.ts +0 -0
- /package/examples/{planning Poker → apps/planning Poker}/additional files/AgilePoker_1_0_0_1.zip +0 -0
- /package/examples/{planning Poker → apps/planning Poker}/additional files/PokerTables_1_0_0_1.zip +0 -0
- /package/examples/{outlook Demo2 → apps/solution explorer}/dist/icon-512.png +0 -0
- /package/examples/{outlook Demo2 → apps/solution explorer}/dist/power-apps-data.js +0 -0
- /package/examples/{todo → apps/todo}/dist/icon192.png +0 -0
- /package/examples/{solution explorer → combined demo}/dist/icon-512.png +0 -0
|
@@ -1,142 +1,325 @@
|
|
|
1
|
-
import { getMyProfile, getUserPhoto
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
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
|
-
|
|
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
|
-
|
|
1
|
+
import { getMyProfile, getUserPhoto } from './office365users.js';
|
|
2
|
+
import { enableDebugger } from "./codeapp.js";
|
|
3
|
+
|
|
4
|
+
enableDebugger();
|
|
5
|
+
|
|
6
|
+
const eRoot = document.getElementById('root');
|
|
7
|
+
const aProfileSelect = [
|
|
8
|
+
'id',
|
|
9
|
+
'displayName',
|
|
10
|
+
'givenName',
|
|
11
|
+
'surname',
|
|
12
|
+
'mail',
|
|
13
|
+
'userPrincipalName',
|
|
14
|
+
'jobTitle',
|
|
15
|
+
'department',
|
|
16
|
+
'officeLocation',
|
|
17
|
+
'mobilePhone',
|
|
18
|
+
'businessPhones',
|
|
19
|
+
'city',
|
|
20
|
+
'state',
|
|
21
|
+
'country',
|
|
22
|
+
'companyName',
|
|
23
|
+
'preferredLanguage'
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
const oState = {
|
|
27
|
+
bLoading: true,
|
|
28
|
+
sError: '',
|
|
29
|
+
oProfile: null,
|
|
30
|
+
sPhotoSrc: '',
|
|
31
|
+
sLastUpdated: ''
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
function escapeHtml(oValue) {
|
|
35
|
+
return String(oValue || '')
|
|
36
|
+
.replace(new RegExp('&', 'g'), '&')
|
|
37
|
+
.replace(new RegExp('<', 'g'), '<')
|
|
38
|
+
.replace(new RegExp('>', 'g'), '>')
|
|
39
|
+
.replace(new RegExp('"', 'g'), '"');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function isNonEmptyString(oValue) {
|
|
43
|
+
return typeof oValue === 'string' && oValue.trim() !== '';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function toTextOrEmpty(oValue) {
|
|
47
|
+
return isNonEmptyString(oValue) ? oValue.trim() : '';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function toArray(oValue) {
|
|
51
|
+
return Array.isArray(oValue) ? oValue.filter(Boolean) : [];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function getDisplayName(oProfile) {
|
|
55
|
+
return toTextOrEmpty(oProfile.displayName) || toTextOrEmpty(oProfile.mail) || 'Your profile';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function getProfileId(oProfile) {
|
|
59
|
+
return toTextOrEmpty(oProfile.id) || toTextOrEmpty(oProfile.mail) || toTextOrEmpty(oProfile.userPrincipalName);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getInitials(sName) {
|
|
63
|
+
const aParts = String(sName || '')
|
|
64
|
+
.split(/\s+/)
|
|
65
|
+
.filter(Boolean)
|
|
66
|
+
.slice(0, 2);
|
|
67
|
+
|
|
68
|
+
if (aParts.length === 0) return 'ME';
|
|
69
|
+
return aParts.map(function (sPart) {
|
|
70
|
+
return sPart.charAt(0).toUpperCase();
|
|
71
|
+
}).join('');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function getHeadline(oProfile) {
|
|
75
|
+
const aParts = [
|
|
76
|
+
toTextOrEmpty(oProfile.jobTitle),
|
|
77
|
+
toTextOrEmpty(oProfile.department),
|
|
78
|
+
toTextOrEmpty(oProfile.officeLocation)
|
|
79
|
+
].filter(Boolean);
|
|
80
|
+
|
|
81
|
+
return aParts.join(' | ') || 'Signed-in Office 365 profile';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function getLocationLabel(oProfile) {
|
|
85
|
+
const aParts = [
|
|
86
|
+
toTextOrEmpty(oProfile.city),
|
|
87
|
+
toTextOrEmpty(oProfile.state),
|
|
88
|
+
toTextOrEmpty(oProfile.country)
|
|
89
|
+
].filter(Boolean);
|
|
90
|
+
|
|
91
|
+
return aParts.join(', ') || 'Location not available';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function getPhoneLabel(oProfile) {
|
|
95
|
+
const aBusinessPhones = toArray(oProfile.businessPhones);
|
|
96
|
+
return toTextOrEmpty(oProfile.mobilePhone) || aBusinessPhones.join(', ') || 'No phone listed';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function normalizePhotoSource(oPhotoResult) {
|
|
100
|
+
let sValue = '';
|
|
101
|
+
|
|
102
|
+
if (typeof oPhotoResult === 'string') {
|
|
103
|
+
sValue = oPhotoResult;
|
|
104
|
+
} else if (oPhotoResult && typeof oPhotoResult === 'object') {
|
|
105
|
+
sValue = toTextOrEmpty(oPhotoResult.value) || toTextOrEmpty(oPhotoResult.$content) || toTextOrEmpty(oPhotoResult.content);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (!sValue) return '';
|
|
109
|
+
if (sValue.indexOf('data:') === 0 || sValue.indexOf('blob:') === 0 || sValue.indexOf('http') === 0) return sValue;
|
|
110
|
+
return 'data:image/jpeg;base64,' + sValue;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function formatUpdatedTime() {
|
|
114
|
+
return new Date().toLocaleTimeString([], {
|
|
115
|
+
hour: '2-digit',
|
|
116
|
+
minute: '2-digit'
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function renderActionLink(sHref, sLabel) {
|
|
121
|
+
if (!sHref || !sLabel) return '';
|
|
122
|
+
return '<a class="button button-secondary" href="' + escapeHtml(sHref) + '">' + escapeHtml(sLabel) + '</a>';
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function renderInfoItems(aItems) {
|
|
126
|
+
return aItems.filter(function (oItem) {
|
|
127
|
+
return Boolean(oItem.sValue);
|
|
128
|
+
}).map(function (oItem) {
|
|
129
|
+
let sValueHtml = escapeHtml(oItem.sValue);
|
|
130
|
+
|
|
131
|
+
if (oItem.sHref) {
|
|
132
|
+
sValueHtml = '<a href="' + escapeHtml(oItem.sHref) + '">' + sValueHtml + '</a>';
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return '<li class="info-item">'
|
|
136
|
+
+ '<span class="info-label">' + escapeHtml(oItem.sLabel) + '</span>'
|
|
137
|
+
+ '<div class="info-value">' + sValueHtml + '</div>'
|
|
138
|
+
+ '</li>';
|
|
139
|
+
}).join('');
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function renderSummaryCard(sLabel, sValue, sNote) {
|
|
143
|
+
return '<article class="summary-card">'
|
|
144
|
+
+ '<p class="summary-label">' + escapeHtml(sLabel) + '</p>'
|
|
145
|
+
+ '<p class="summary-value">' + escapeHtml(sValue) + '</p>'
|
|
146
|
+
+ '<p class="summary-note">' + escapeHtml(sNote) + '</p>'
|
|
147
|
+
+ '</article>';
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function bindEvents() {
|
|
151
|
+
const eRefresh = document.getElementById('refreshProfile');
|
|
152
|
+
if (eRefresh) {
|
|
153
|
+
eRefresh.onclick = function () {
|
|
154
|
+
loadProfile();
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function renderLoading() {
|
|
160
|
+
eRoot.innerHTML = '<section class="status-shell">'
|
|
161
|
+
+ '<div class="status-card" role="status" aria-live="polite">'
|
|
162
|
+
+ '<p class="eyebrow">Office 365 Users Demo</p>'
|
|
163
|
+
+ '<h1 class="status-title">Loading your Microsoft 365 profile</h1>'
|
|
164
|
+
+ '<p class="status-text">The app is calling the Office 365 Users connector for your profile details and profile photo.</p>'
|
|
165
|
+
+ '<div class="status-actions"><button class="button" id="refreshProfile" disabled>Loading...</button></div>'
|
|
166
|
+
+ '</div>'
|
|
167
|
+
+ '</section>';
|
|
168
|
+
bindEvents();
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function renderError() {
|
|
172
|
+
eRoot.innerHTML = '<section class="status-shell">'
|
|
173
|
+
+ '<div class="status-card is-error">'
|
|
174
|
+
+ '<p class="eyebrow">Office 365 Users Demo</p>'
|
|
175
|
+
+ '<h1 class="status-title">Unable to load your profile</h1>'
|
|
176
|
+
+ '<p class="status-text">' + escapeHtml(oState.sError) + '</p>'
|
|
177
|
+
+ '<div class="status-actions"><button class="button" id="refreshProfile">Try again</button></div>'
|
|
178
|
+
+ '</div>'
|
|
179
|
+
+ '</section>';
|
|
180
|
+
bindEvents();
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function renderApp() {
|
|
184
|
+
if (!eRoot) return;
|
|
185
|
+
|
|
186
|
+
if (oState.bLoading) {
|
|
187
|
+
renderLoading();
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (oState.sError) {
|
|
192
|
+
renderError();
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const oProfile = oState.oProfile || {};
|
|
197
|
+
const sDisplayName = getDisplayName(oProfile);
|
|
198
|
+
const sHeadline = getHeadline(oProfile);
|
|
199
|
+
const sInitials = getInitials(sDisplayName);
|
|
200
|
+
const aChips = [
|
|
201
|
+
toTextOrEmpty(oProfile.department),
|
|
202
|
+
toTextOrEmpty(oProfile.officeLocation),
|
|
203
|
+
toTextOrEmpty(oProfile.companyName),
|
|
204
|
+
toTextOrEmpty(oProfile.preferredLanguage)
|
|
205
|
+
].filter(Boolean);
|
|
206
|
+
const aIdentityItems = [
|
|
207
|
+
{ sLabel: 'Name', sValue: sDisplayName },
|
|
208
|
+
{ sLabel: 'Job title', sValue: toTextOrEmpty(oProfile.jobTitle) || 'Not listed' },
|
|
209
|
+
{ sLabel: 'Department', sValue: toTextOrEmpty(oProfile.department) || 'Not listed' },
|
|
210
|
+
{ sLabel: 'Company', sValue: toTextOrEmpty(oProfile.companyName) || 'Not listed' }
|
|
211
|
+
];
|
|
212
|
+
const aContactItems = [
|
|
213
|
+
{ sLabel: 'Email', sValue: toTextOrEmpty(oProfile.mail), sHref: toTextOrEmpty(oProfile.mail) ? 'mailto:' + toTextOrEmpty(oProfile.mail) : '' },
|
|
214
|
+
{ sLabel: 'Mobile phone', sValue: toTextOrEmpty(oProfile.mobilePhone), sHref: toTextOrEmpty(oProfile.mobilePhone) ? 'tel:' + toTextOrEmpty(oProfile.mobilePhone) : '' },
|
|
215
|
+
{ sLabel: 'Business phones', sValue: toArray(oProfile.businessPhones).join(', ') },
|
|
216
|
+
{ sLabel: 'User principal name', sValue: toTextOrEmpty(oProfile.userPrincipalName) }
|
|
217
|
+
];
|
|
218
|
+
const aWorkItems = [
|
|
219
|
+
{ sLabel: 'Office', sValue: toTextOrEmpty(oProfile.officeLocation) || 'Not listed' },
|
|
220
|
+
{ sLabel: 'Location', sValue: getLocationLabel(oProfile) },
|
|
221
|
+
{ sLabel: 'Preferred language', sValue: toTextOrEmpty(oProfile.preferredLanguage) || 'Not listed' },
|
|
222
|
+
{ sLabel: 'Profile photo', sValue: oState.sPhotoSrc ? 'Available' : 'Not available' }
|
|
223
|
+
];
|
|
224
|
+
const iFilledFields = aProfileSelect.reduce(function (iCount, sKey) {
|
|
225
|
+
const oValue = oProfile[sKey];
|
|
226
|
+
if (Array.isArray(oValue)) return iCount + (oValue.filter(Boolean).length > 0 ? 1 : 0);
|
|
227
|
+
return iCount + (toTextOrEmpty(oValue) ? 1 : 0);
|
|
228
|
+
}, 0);
|
|
229
|
+
const sEmailHref = toTextOrEmpty(oProfile.mail) ? 'mailto:' + toTextOrEmpty(oProfile.mail) : '';
|
|
230
|
+
const sPhotoMarkup = oState.sPhotoSrc
|
|
231
|
+
? '<img class="photo-image" src="' + escapeHtml(oState.sPhotoSrc) + '" alt="' + escapeHtml(sDisplayName) + ' profile photo" />'
|
|
232
|
+
: '<div class="photo-fallback" aria-label="Avatar fallback">' + escapeHtml(sInitials) + '</div>';
|
|
233
|
+
const sChipMarkup = aChips.map(function (sChip) {
|
|
234
|
+
return '<li class="hero-chip">' + escapeHtml(sChip) + '</li>';
|
|
235
|
+
}).join('');
|
|
236
|
+
|
|
237
|
+
eRoot.innerHTML = '<main class="page-shell">'
|
|
238
|
+
+ '<section class="hero-card">'
|
|
239
|
+
+ '<div class="photo-column">'
|
|
240
|
+
+ '<div class="photo-frame">' + sPhotoMarkup + '</div>'
|
|
241
|
+
+ '<div class="photo-caption">'
|
|
242
|
+
+ '<p class="caption-label">Profile image</p>'
|
|
243
|
+
+ '<p class="caption-value">' + escapeHtml(oState.sPhotoSrc ? 'Synced from Office 365 Users' : 'Using initials fallback') + '</p>'
|
|
244
|
+
+ '</div>'
|
|
245
|
+
+ '</div>'
|
|
246
|
+
+ '<div class="hero-copy">'
|
|
247
|
+
+ '<p class="eyebrow">Office 365 Users Demo</p>'
|
|
248
|
+
+ '<h1 class="hero-title">' + escapeHtml(sDisplayName) + '</h1>'
|
|
249
|
+
+ '<p class="hero-subtitle">' + escapeHtml(sHeadline) + '</p>'
|
|
250
|
+
+ '<ul class="hero-chips">' + sChipMarkup + '</ul>'
|
|
251
|
+
+ '<div class="action-row">'
|
|
252
|
+
+ '<button class="button" id="refreshProfile">Refresh profile</button>'
|
|
253
|
+
+ renderActionLink(sEmailHref, 'Email me')
|
|
254
|
+
+ '</div>'
|
|
255
|
+
+ '</div>'
|
|
256
|
+
+ '</section>'
|
|
257
|
+
+ '<section class="summary-grid">'
|
|
258
|
+
+ renderSummaryCard('Fields loaded', String(iFilledFields), 'Values returned across the selected Office 365 profile fields.')
|
|
259
|
+
+ renderSummaryCard('Best contact', getPhoneLabel(oProfile), 'Primary phone detail chosen from mobile or business phone fields.')
|
|
260
|
+
+ renderSummaryCard('Last updated', oState.sLastUpdated || '--:--', 'Timestamp from the latest successful connector refresh in this session.')
|
|
261
|
+
+ '</section>'
|
|
262
|
+
+ '<section class="detail-grid">'
|
|
263
|
+
+ '<article class="panel">'
|
|
264
|
+
+ '<h2 class="panel-title">Identity</h2>'
|
|
265
|
+
+ '<p class="panel-text">The essentials returned for the signed-in user account.</p>'
|
|
266
|
+
+ '<ul class="info-list">' + renderInfoItems(aIdentityItems) + '</ul>'
|
|
267
|
+
+ '</article>'
|
|
268
|
+
+ '<article class="panel">'
|
|
269
|
+
+ '<h2 class="panel-title">Contact</h2>'
|
|
270
|
+
+ '<p class="panel-text">Direct contact values from the Office 365 Users connector response.</p>'
|
|
271
|
+
+ '<ul class="info-list">' + renderInfoItems(aContactItems) + '</ul>'
|
|
272
|
+
+ '</article>'
|
|
273
|
+
+ '<article class="panel panel-accent">'
|
|
274
|
+
+ '<h2 class="panel-title">Account Snapshot</h2>'
|
|
275
|
+
+ '<p class="panel-text">A small readout of the fields that usually matter first in a profile demo.</p>'
|
|
276
|
+
+ '<div class="account-highlight">'
|
|
277
|
+
+ '<div class="highlight-item"><p class="highlight-label">Office</p><p class="highlight-value">' + escapeHtml(toTextOrEmpty(oProfile.officeLocation) || 'No office listed') + '</p></div>'
|
|
278
|
+
+ '<div class="highlight-item"><p class="highlight-label">Location</p><p class="highlight-value">' + escapeHtml(getLocationLabel(oProfile)) + '</p></div>'
|
|
279
|
+
+ '<div class="highlight-item"><p class="highlight-label">Profile status</p><p class="highlight-value">' + escapeHtml(oState.sPhotoSrc ? 'Photo and key fields available' : 'Key fields available, photo fallback active') + '</p></div>'
|
|
280
|
+
+ '</div>'
|
|
281
|
+
+ '<ul class="info-list">' + renderInfoItems(aWorkItems) + '</ul>'
|
|
282
|
+
+ '<p class="footer-note">The demo reads your signed-in profile and converts the returned photo payload into an image source when a photo is available.</p>'
|
|
283
|
+
+ '</article>'
|
|
284
|
+
+ '</section>'
|
|
285
|
+
+ '</main>';
|
|
286
|
+
|
|
287
|
+
bindEvents();
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
async function loadProfile() {
|
|
291
|
+
oState.bLoading = true;
|
|
292
|
+
oState.sError = '';
|
|
293
|
+
renderApp();
|
|
294
|
+
|
|
295
|
+
try {
|
|
296
|
+
const oProfile = await getMyProfile({ select: aProfileSelect });
|
|
297
|
+
const sUserId = getProfileId(oProfile);
|
|
298
|
+
let sPhotoSrc = '';
|
|
299
|
+
|
|
300
|
+
if (sUserId) {
|
|
301
|
+
try {
|
|
302
|
+
const oPhotoResult = await getUserPhoto(sUserId);
|
|
303
|
+
sPhotoSrc = normalizePhotoSource(oPhotoResult);
|
|
304
|
+
} catch (oPhotoError) {
|
|
305
|
+
sPhotoSrc = '';
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
oState.oProfile = oProfile;
|
|
310
|
+
oState.sPhotoSrc = sPhotoSrc;
|
|
311
|
+
oState.sLastUpdated = formatUpdatedTime();
|
|
312
|
+
} catch (oError) {
|
|
313
|
+
oState.sError = oError && oError.message ? oError.message : 'An unexpected error occurred while loading your Office 365 profile.';
|
|
314
|
+
} finally {
|
|
315
|
+
oState.bLoading = false;
|
|
316
|
+
renderApp();
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
async function boot() {
|
|
321
|
+
renderApp();
|
|
322
|
+
await loadProfile();
|
|
323
|
+
}
|
|
324
|
+
|
|
142
325
|
boot();
|