@kwiz/common 1.0.132 → 1.0.134
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/lib/cjs/helpers/promises.js +4 -3
- package/lib/cjs/helpers/promises.js.map +1 -1
- package/lib/cjs/utils/sharepoint.rest/web.js +10 -2
- package/lib/cjs/utils/sharepoint.rest/web.js.map +1 -1
- package/lib/esm/helpers/promises.js +4 -3
- package/lib/esm/helpers/promises.js.map +1 -1
- package/lib/esm/utils/sharepoint.rest/web.js +7 -0
- package/lib/esm/utils/sharepoint.rest/web.js.map +1 -1
- package/lib/types/helpers/promises.d.ts +1 -1
- package/lib/types/utils/sharepoint.rest/web.d.ts +1 -0
- package/package.json +3 -2
- package/.github/workflows/npm-publish.yml +0 -24
- package/src/_dependencies.ts +0 -13
- package/src/config.ts +0 -19
- package/src/exports-index.ts +0 -4
- package/src/helpers/Guid.ts +0 -182
- package/src/helpers/base64.ts +0 -174
- package/src/helpers/browser.test.js +0 -13
- package/src/helpers/browser.ts +0 -1505
- package/src/helpers/browserinfo.ts +0 -293
- package/src/helpers/collections.base.test.js +0 -26
- package/src/helpers/collections.base.ts +0 -438
- package/src/helpers/collections.ts +0 -108
- package/src/helpers/color.ts +0 -55
- package/src/helpers/cookies.ts +0 -60
- package/src/helpers/date.test.js +0 -120
- package/src/helpers/date.ts +0 -189
- package/src/helpers/debug.ts +0 -187
- package/src/helpers/diagrams.ts +0 -44
- package/src/helpers/emails.ts +0 -7
- package/src/helpers/eval.ts +0 -5
- package/src/helpers/exports-index.ts +0 -30
- package/src/helpers/file.test.js +0 -51
- package/src/helpers/file.ts +0 -64
- package/src/helpers/flatted.ts +0 -150
- package/src/helpers/functions.ts +0 -17
- package/src/helpers/graph/calendar.types.ts +0 -11
- package/src/helpers/graph/exports-index.ts +0 -1
- package/src/helpers/http.ts +0 -70
- package/src/helpers/images.ts +0 -23
- package/src/helpers/json.ts +0 -45
- package/src/helpers/md5.ts +0 -190
- package/src/helpers/objects.test.js +0 -34
- package/src/helpers/objects.ts +0 -275
- package/src/helpers/promises.test.js +0 -38
- package/src/helpers/promises.ts +0 -166
- package/src/helpers/random.ts +0 -27
- package/src/helpers/scheduler/exports-index.ts +0 -1
- package/src/helpers/scheduler/scheduler.test.js +0 -104
- package/src/helpers/scheduler/scheduler.ts +0 -132
- package/src/helpers/sharepoint.ts +0 -797
- package/src/helpers/strings.test.js +0 -123
- package/src/helpers/strings.ts +0 -338
- package/src/helpers/typecheckers.test.js +0 -35
- package/src/helpers/typecheckers.ts +0 -267
- package/src/helpers/url.test.js +0 -44
- package/src/helpers/url.ts +0 -208
- package/src/helpers/urlhelper.ts +0 -112
- package/src/index.ts +0 -6
- package/src/types/auth.ts +0 -63
- package/src/types/common.types.ts +0 -16
- package/src/types/exports-index.ts +0 -15
- package/src/types/flatted.types.ts +0 -60
- package/src/types/globals.types.ts +0 -7
- package/src/types/graph/calendar.types.ts +0 -81
- package/src/types/graph/exports-index.ts +0 -1
- package/src/types/knownscript.types.ts +0 -19
- package/src/types/libs/datajs.types.ts +0 -29
- package/src/types/libs/exports-index.ts +0 -3
- package/src/types/libs/ics.types.ts +0 -31
- package/src/types/libs/msal.types.ts +0 -58
- package/src/types/locales.ts +0 -126
- package/src/types/localstoragecache.types.ts +0 -9
- package/src/types/location.types.ts +0 -28
- package/src/types/moment.ts +0 -12
- package/src/types/regex.types.ts +0 -17
- package/src/types/rest.types.ts +0 -96
- package/src/types/sharepoint.types.ts +0 -1467
- package/src/types/sharepoint.utils.types.ts +0 -307
- package/src/utils/auth/common.ts +0 -119
- package/src/utils/auth/discovery.test.js +0 -13
- package/src/utils/auth/discovery.ts +0 -132
- package/src/utils/auth/exports-index.ts +0 -2
- package/src/utils/base64.ts +0 -28
- package/src/utils/consolelogger.ts +0 -334
- package/src/utils/date.ts +0 -173
- package/src/utils/emails.ts +0 -25
- package/src/utils/exports-index.ts +0 -11
- package/src/utils/knownscript.ts +0 -287
- package/src/utils/localstoragecache.ts +0 -447
- package/src/utils/rest.ts +0 -502
- package/src/utils/script.ts +0 -171
- package/src/utils/sharepoint.rest/common.ts +0 -160
- package/src/utils/sharepoint.rest/date.ts +0 -63
- package/src/utils/sharepoint.rest/exports-index.ts +0 -11
- package/src/utils/sharepoint.rest/file.folder.ts +0 -685
- package/src/utils/sharepoint.rest/item.ts +0 -547
- package/src/utils/sharepoint.rest/list.ts +0 -1572
- package/src/utils/sharepoint.rest/listutils/GetListItemsByCaml.ts +0 -775
- package/src/utils/sharepoint.rest/listutils/GetListItemsById.ts +0 -275
- package/src/utils/sharepoint.rest/listutils/common.ts +0 -207
- package/src/utils/sharepoint.rest/listutils/exports-index.ts +0 -3
- package/src/utils/sharepoint.rest/location.ts +0 -142
- package/src/utils/sharepoint.rest/navigation-links.ts +0 -87
- package/src/utils/sharepoint.rest/user-search.ts +0 -253
- package/src/utils/sharepoint.rest/user.ts +0 -559
- package/src/utils/sharepoint.rest/web.ts +0 -1385
- package/src/utils/sod.ts +0 -195
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { isNullOrEmptyString, isNullOrUndefined } from "../../helpers/typecheckers";
|
|
2
|
-
import { INavLinkInfo } from "../../types/sharepoint.types";
|
|
3
|
-
import { ConsoleLogger } from "../consolelogger";
|
|
4
|
-
import { GetJson } from "../rest";
|
|
5
|
-
import { GetRestBaseUrl, GetSiteUrl } from "./common";
|
|
6
|
-
|
|
7
|
-
const logger = ConsoleLogger.get("SharePoint.Rest.Navigation-Links");
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Get all navigation links in the top and side navigation of a SharePoint site
|
|
11
|
-
* @param siteUrl The URL of the SharePoint site
|
|
12
|
-
* @returns An array containing all navigation links
|
|
13
|
-
*/
|
|
14
|
-
export async function GetNavigationLinks(siteUrl?: string): Promise<INavLinkInfo[]> {
|
|
15
|
-
siteUrl = GetSiteUrl(siteUrl);
|
|
16
|
-
const topNavUrl = `${GetRestBaseUrl(siteUrl)}/web/navigation/topnavigationbar`;
|
|
17
|
-
const sideNavUrl = `${GetRestBaseUrl(siteUrl)}/web/navigation/quicklaunch`;
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
const topNavResponse = await GetJson<{ d: { results: INavLinkInfo[] } }>(topNavUrl);
|
|
21
|
-
const sideNavResponse = await GetJson<{ d: { results: INavLinkInfo[] } }>(sideNavUrl);
|
|
22
|
-
|
|
23
|
-
const topNavLinks: INavLinkInfo[] = topNavResponse.d.results.map((link: INavLinkInfo) => ({ ...link, Location: "topnavigationbar" }));
|
|
24
|
-
const sideNavLinks: INavLinkInfo[] = sideNavResponse.d.results.map((link: INavLinkInfo) => ({ ...link, Location: "quicklaunch" }));
|
|
25
|
-
|
|
26
|
-
return [...topNavLinks, ...sideNavLinks];
|
|
27
|
-
} catch (error) {
|
|
28
|
-
logger.error(`Error fetching navigation links: ${error.message}`);
|
|
29
|
-
}
|
|
30
|
-
return [];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Add a navigation link to the specified location (top navigation or side navigation)
|
|
35
|
-
* @param title The title of the navigation link
|
|
36
|
-
* @param url The url of the navigation link
|
|
37
|
-
* @param location The location where the link will be added ('topnavigationbar' or 'quicklaunch'). Default is 'quicklaunch'.
|
|
38
|
-
* @Logs If the location is invalid or if adding the link fails
|
|
39
|
-
*/
|
|
40
|
-
export async function AddNavigationLink(title: string, url: string, location: 'topnavigationbar' | 'quicklaunch' = 'quicklaunch'): Promise<INavLinkInfo> {
|
|
41
|
-
try {
|
|
42
|
-
let siteUrl = GetSiteUrl();
|
|
43
|
-
let navigationUrl = "";
|
|
44
|
-
navigationUrl = `${GetRestBaseUrl(siteUrl)}/web/navigation/${location}`;
|
|
45
|
-
const response = await GetJson<{ d: INavLinkInfo }>(navigationUrl, JSON.stringify({
|
|
46
|
-
'__metadata': { 'type': 'SP.NavigationNode' },
|
|
47
|
-
'Title': title,
|
|
48
|
-
'Url': url
|
|
49
|
-
}), {
|
|
50
|
-
spWebUrl: siteUrl,
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (!isNullOrUndefined(response) && !isNullOrUndefined(response.d)) {
|
|
55
|
-
return response.d;
|
|
56
|
-
}
|
|
57
|
-
} catch (error) {
|
|
58
|
-
logger.error('Error adding link');
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Delete navigation links by title and URL
|
|
64
|
-
* @param navLinks An array of navigation links to be deleted
|
|
65
|
-
* @Logs If the location is invalid or if deleting the links fails
|
|
66
|
-
*/
|
|
67
|
-
export async function DeleteNavigationLinks(navLinks: INavLinkInfo[]): Promise<void> {
|
|
68
|
-
try {
|
|
69
|
-
const siteUrl = GetSiteUrl();
|
|
70
|
-
for (const navLink of navLinks) {
|
|
71
|
-
const navigationUrl = `${GetRestBaseUrl(siteUrl)}/web/Navigation/GetNodeById(${navLink.Id})`;
|
|
72
|
-
// Use the same convention to make the DELETE request
|
|
73
|
-
const response = await GetJson<any>(navigationUrl, null, {
|
|
74
|
-
method: 'POST',
|
|
75
|
-
spWebUrl: siteUrl,
|
|
76
|
-
xHttpMethod: 'DELETE'
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
if (!isNullOrEmptyString(response) && !response.ok) {
|
|
80
|
-
logger.error('Failed to delete link');
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
logger.info('Navigation links deleted successfully');
|
|
84
|
-
} catch (error) {
|
|
85
|
-
logger.error('Error deleting links');
|
|
86
|
-
}
|
|
87
|
-
}
|
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import { firstIndexOf } from "../../helpers/collections.base";
|
|
2
|
-
import { contentTypes, jsonTypes } from "../../types/rest.types";
|
|
3
|
-
import { PrincipalType } from "../../types/sharepoint.types";
|
|
4
|
-
import { IUserInfo } from "../../types/sharepoint.utils.types";
|
|
5
|
-
import { GetJson } from "../rest";
|
|
6
|
-
import { EnsureUser } from "./user";
|
|
7
|
-
|
|
8
|
-
export interface iPeoplePickerUserItem {
|
|
9
|
-
/** LoginName or Id of the principal in the site. */
|
|
10
|
-
id: string;
|
|
11
|
-
/** LoginName of the principal. */
|
|
12
|
-
loginName: string;
|
|
13
|
-
imageUrl: string;
|
|
14
|
-
imageInitials: string;
|
|
15
|
-
text: string; // name
|
|
16
|
-
secondaryText: string; // role
|
|
17
|
-
tertiaryText: string; // status
|
|
18
|
-
optionalText: string; // anything
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Service implementation to search people in SharePoint
|
|
22
|
-
*/
|
|
23
|
-
export class SPPeopleSearchService {
|
|
24
|
-
private cachedLocalUsers: { [siteUrl: string]: IUserInfo[] };
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Service constructor
|
|
28
|
-
*/
|
|
29
|
-
constructor(private context: { siteUrl }) {
|
|
30
|
-
this.cachedLocalUsers = {};
|
|
31
|
-
this.cachedLocalUsers[this.context.siteUrl] = [];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Generate the user photo link using SharePoint user photo endpoint.
|
|
36
|
-
*
|
|
37
|
-
* @param value
|
|
38
|
-
*/
|
|
39
|
-
public generateUserPhotoLink(value: string, size: "S" | "M" = "M"): string {
|
|
40
|
-
return `${this.context.siteUrl}/_layouts/15/userphoto.aspx?accountname=${encodeURIComponent(value)}&size=M`;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Generate sum of principal types
|
|
45
|
-
*
|
|
46
|
-
* PrincipalType controls the type of entities that are returned in the results.
|
|
47
|
-
* Choices are All - 15, Distribution List - 2 , Security Groups - 4, SharePoint Groups - 8, User - 1.
|
|
48
|
-
* These values can be combined (example: 13 is security + SP groups + users)
|
|
49
|
-
*
|
|
50
|
-
* @param principalTypes
|
|
51
|
-
*/
|
|
52
|
-
public getSumOfPrincipalTypes(principalTypes: PrincipalType[]) {
|
|
53
|
-
return !!principalTypes && principalTypes.length > 0 ? principalTypes.reduce((a, b) => a + b, 0) : 1;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Retrieve the specified group
|
|
58
|
-
*
|
|
59
|
-
* @param groupName
|
|
60
|
-
* @param siteUrl
|
|
61
|
-
*/
|
|
62
|
-
public async getGroupId(groupName: string, siteUrl: string = null): Promise<number | null> {
|
|
63
|
-
// if (Environment.type === EnvironmentType.Local) {
|
|
64
|
-
// return 1;
|
|
65
|
-
// } else {
|
|
66
|
-
const groups = await this.searchTenant(siteUrl, groupName, 1, [PrincipalType.SharePointGroup], false, 0);
|
|
67
|
-
return (groups && groups.length > 0) ? parseInt(groups[0].id) : null;
|
|
68
|
-
//}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Search person by its email or login name
|
|
73
|
-
*/
|
|
74
|
-
public async searchPersonByEmailOrLogin(email: string, principalTypes: PrincipalType[], siteUrl: string = null, groupId: number = null, ensureUser: boolean = false): Promise<iPeoplePickerUserItem> {
|
|
75
|
-
// if (Environment.type === EnvironmentType.Local) {
|
|
76
|
-
// // If the running environment is local, load the data from the mock
|
|
77
|
-
// const mockUsers = await this.searchPeopleFromMock(email);
|
|
78
|
-
// return (mockUsers && mockUsers.length > 0) ? mockUsers[0] : null;
|
|
79
|
-
// } else {
|
|
80
|
-
const userResults = await this.searchTenant(siteUrl, email, 1, principalTypes, ensureUser, groupId);
|
|
81
|
-
return (userResults && userResults.length > 0) ? userResults[0] : null;
|
|
82
|
-
//}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Search All Users from the SharePoint People database
|
|
87
|
-
*/
|
|
88
|
-
public async searchPeople(query: string, maximumSuggestions: number, principalTypes: PrincipalType[], siteUrl: string = null, groupId: number = null, ensureUser: boolean = false): Promise<iPeoplePickerUserItem[]> {
|
|
89
|
-
// if (Environment.type === EnvironmentType.Local) {
|
|
90
|
-
// // If the running environment is local, load the data from the mock
|
|
91
|
-
// return this.searchPeopleFromMock(query);
|
|
92
|
-
// } else {
|
|
93
|
-
return await this.searchTenant(siteUrl, query, maximumSuggestions, principalTypes, ensureUser, groupId);
|
|
94
|
-
//}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Tenant search
|
|
99
|
-
*/
|
|
100
|
-
private async searchTenant(siteUrl: string, query: string, maximumSuggestions: number, principalTypes: PrincipalType[], ensureUser: boolean, groupId: number): Promise<iPeoplePickerUserItem[]> {
|
|
101
|
-
try {
|
|
102
|
-
// If the running env is SharePoint, loads from the peoplepicker web service
|
|
103
|
-
const userRequestUrl: string = `${siteUrl || this.context.siteUrl}/_api/SP.UI.ApplicationPages.ClientPeoplePickerWebServiceInterface.clientPeoplePickerSearchUser`;
|
|
104
|
-
const searchBody = {
|
|
105
|
-
queryParams: {
|
|
106
|
-
AllowEmailAddresses: true,
|
|
107
|
-
AllowMultipleEntities: false,
|
|
108
|
-
AllUrlZones: false,
|
|
109
|
-
MaximumEntitySuggestions: maximumSuggestions,
|
|
110
|
-
PrincipalSource: 15,
|
|
111
|
-
PrincipalType: this.getSumOfPrincipalTypes(principalTypes),
|
|
112
|
-
QueryString: query
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
// Search on the local site when "0"
|
|
117
|
-
if (siteUrl) {
|
|
118
|
-
searchBody.queryParams["SharePointGroupID"] = 0;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Check if users need to be searched in a specific group
|
|
122
|
-
if (groupId) {
|
|
123
|
-
searchBody.queryParams["SharePointGroupID"] = groupId;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Do the call against the People REST API endpoint
|
|
127
|
-
const userDataResp = await GetJson<{ value: string; }>(
|
|
128
|
-
userRequestUrl,
|
|
129
|
-
JSON.stringify(searchBody),
|
|
130
|
-
{
|
|
131
|
-
headers: {
|
|
132
|
-
Accept: jsonTypes.standard,
|
|
133
|
-
"content-type": contentTypes.json
|
|
134
|
-
}
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
if (userDataResp && userDataResp.value && userDataResp.value.length > 0) {
|
|
138
|
-
let values: any = userDataResp.value;
|
|
139
|
-
|
|
140
|
-
if (typeof userDataResp.value === "string") {
|
|
141
|
-
values = JSON.parse(userDataResp.value);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// Filter out "UNVALIDATED_EMAIL_ADDRESS"
|
|
145
|
-
values = values.filter(v => !(v.EntityData && v.EntityData.PrincipalType && v.EntityData.PrincipalType === "UNVALIDATED_EMAIL_ADDRESS"));
|
|
146
|
-
|
|
147
|
-
// Check if local user IDs need to be retrieved
|
|
148
|
-
if (ensureUser) {
|
|
149
|
-
for (const value of values) {
|
|
150
|
-
// Only ensure the user if it is not a SharePoint group
|
|
151
|
-
if (!value.EntityData || (value.EntityData && typeof value.EntityData.SPGroupID === "undefined")) {
|
|
152
|
-
const id = await this.ensureUser(value.Key);
|
|
153
|
-
value.LoginName = value.Key;
|
|
154
|
-
value.Key = id;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// Filter out NULL keys
|
|
160
|
-
values = values.filter(v => v.Key !== null);
|
|
161
|
-
const userResults = values.map(element => {
|
|
162
|
-
switch (element.EntityType) {
|
|
163
|
-
case 'User':
|
|
164
|
-
return {
|
|
165
|
-
id: element.Key,
|
|
166
|
-
loginName: element.LoginName ? element.LoginName : element.Key,
|
|
167
|
-
imageUrl: this.generateUserPhotoLink(element.Description || ""),
|
|
168
|
-
imageInitials: this.getFullNameInitials(element.DisplayText),
|
|
169
|
-
text: element.DisplayText, // name
|
|
170
|
-
secondaryText: element.EntityData.Email || element.Description, // email
|
|
171
|
-
tertiaryText: "", // status
|
|
172
|
-
optionalText: "" // anything
|
|
173
|
-
} as iPeoplePickerUserItem;
|
|
174
|
-
case 'SecGroup':
|
|
175
|
-
return {
|
|
176
|
-
id: element.Key,
|
|
177
|
-
loginName: element.LoginName ? element.LoginName : element.Key,
|
|
178
|
-
imageInitials: this.getFullNameInitials(element.DisplayText),
|
|
179
|
-
text: element.DisplayText,
|
|
180
|
-
secondaryText: element.ProviderName
|
|
181
|
-
} as iPeoplePickerUserItem;
|
|
182
|
-
case 'FormsRole':
|
|
183
|
-
return {
|
|
184
|
-
id: element.Key,
|
|
185
|
-
loginName: element.LoginName ? element.LoginName : element.Key,
|
|
186
|
-
imageInitials: this.getFullNameInitials(element.DisplayText),
|
|
187
|
-
text: element.DisplayText,
|
|
188
|
-
secondaryText: element.ProviderName
|
|
189
|
-
} as iPeoplePickerUserItem;
|
|
190
|
-
default:
|
|
191
|
-
return {
|
|
192
|
-
id: element.EntityData.SPGroupID,
|
|
193
|
-
loginName: element.EntityData.AccountName,
|
|
194
|
-
imageInitials: this.getFullNameInitials(element.DisplayText),
|
|
195
|
-
text: element.DisplayText,
|
|
196
|
-
secondaryText: element.EntityData.AccountName
|
|
197
|
-
} as iPeoplePickerUserItem;
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
return userResults;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
// Nothing to return
|
|
206
|
-
return [];
|
|
207
|
-
} catch (e) {
|
|
208
|
-
console.error("PeopleSearchService::searchTenant: error occured while fetching the users.");
|
|
209
|
-
return [];
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Retrieves the local user ID
|
|
215
|
-
*
|
|
216
|
-
* @param userId
|
|
217
|
-
*/
|
|
218
|
-
private async ensureUser(userId: string): Promise<number> {
|
|
219
|
-
const siteUrl = this.context.siteUrl;
|
|
220
|
-
if (this.cachedLocalUsers && this.cachedLocalUsers[siteUrl]) {
|
|
221
|
-
const users = this.cachedLocalUsers[siteUrl];
|
|
222
|
-
const userIdx = firstIndexOf(users, u => u.LoginName === userId);
|
|
223
|
-
if (userIdx !== -1) {
|
|
224
|
-
return users[userIdx].Id;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
const user = await EnsureUser(siteUrl, userId)
|
|
229
|
-
if (user && user.Id) {
|
|
230
|
-
this.cachedLocalUsers[siteUrl].push(user);
|
|
231
|
-
return user.Id;
|
|
232
|
-
}
|
|
233
|
-
return null;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Generates Initials from a full name
|
|
238
|
-
*/
|
|
239
|
-
private getFullNameInitials(fullName: string): string {
|
|
240
|
-
if (fullName === null) {
|
|
241
|
-
return fullName;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
const words: string[] = fullName.split(' ');
|
|
245
|
-
if (words.length === 0) {
|
|
246
|
-
return '';
|
|
247
|
-
} else if (words.length === 1) {
|
|
248
|
-
return words[0].charAt(0);
|
|
249
|
-
} else {
|
|
250
|
-
return (words[0].charAt(0) + words[1].charAt(0));
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|