jitz-sharepoint-utilities 2.0.14 → 2.0.16
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/data/context/List.ts +5 -8
- package/data/interfaces/IList.ts +2 -2
- package/lib/common/IModels.d.ts +40 -0
- package/lib/common/IModels.js +2 -0
- package/lib/common/IObjects.d.ts +72 -0
- package/lib/common/IObjects.js +30 -0
- package/lib/controls/JitzGrid.d.ts +75 -0
- package/lib/controls/JitzGrid.js +606 -0
- package/lib/controls/JitzImage.d.ts +14 -0
- package/lib/controls/JitzImage.js +37 -0
- package/lib/controls/JitzPeoplePicker.d.ts +49 -0
- package/lib/controls/JitzPeoplePicker.js +311 -0
- package/lib/controls/JitzPersonInfo.d.ts +32 -0
- package/lib/controls/JitzPersonInfo.js +98 -0
- package/lib/controls/JitzPersona.d.ts +23 -0
- package/lib/controls/JitzPersona.js +48 -0
- package/lib/data/context/CommonRepository.d.ts +17 -0
- package/lib/data/context/CommonRepository.js +287 -0
- package/lib/data/context/JitzContext.d.ts +13 -0
- package/lib/data/context/JitzContext.js +80 -0
- package/lib/data/context/JitzSPContext.d.ts +8 -0
- package/lib/data/context/JitzSPContext.js +58 -0
- package/lib/data/context/JitzSPHttpClient.d.ts +14 -0
- package/lib/data/context/JitzSPHttpClient.js +173 -0
- package/lib/data/context/List.d.ts +39 -0
- package/lib/data/context/List.js +492 -0
- package/lib/data/context/Repository.d.ts +22 -0
- package/lib/data/context/Repository.js +486 -0
- package/lib/data/interfaces/ICommonRepository.d.ts +6 -0
- package/lib/data/interfaces/ICommonRepository.js +2 -0
- package/lib/data/interfaces/IJitzContext.d.ts +10 -0
- package/lib/data/interfaces/IJitzContext.js +2 -0
- package/lib/data/interfaces/IJitzSPContext.d.ts +6 -0
- package/lib/data/interfaces/IJitzSPContext.js +2 -0
- package/lib/data/interfaces/IJitzSPHttpClient.d.ts +6 -0
- package/lib/data/interfaces/IJitzSPHttpClient.js +2 -0
- package/lib/data/interfaces/IList.d.ts +26 -0
- package/lib/data/interfaces/IList.js +2 -0
- package/lib/data/interfaces/IModels.d.ts +32 -0
- package/lib/data/interfaces/IModels.js +2 -0
- package/lib/data/interfaces/IRepository.d.ts +17 -0
- package/lib/data/interfaces/IRepository.js +2 -0
- package/lib/jitzHttpClient.d.ts +11 -0
- package/lib/jitzHttpClient.js +37 -0
- package/lib/jitzSPHttpClient.d.ts +30 -0
- package/lib/jitzSPHttpClient.js +193 -0
- package/lib/repositories/CommonRepository.d.ts +17 -0
- package/lib/repositories/CommonRepository.js +287 -0
- package/lib/repositories/ICommonRepository.d.ts +6 -0
- package/lib/repositories/ICommonRepository.js +2 -0
- package/lib/repositories/IRepository.d.ts +13 -0
- package/lib/repositories/IRepository.js +2 -0
- package/lib/repositories/Repository.d.ts +18 -0
- package/lib/repositories/Repository.js +392 -0
- package/lib/services/GraphService.d.ts +10 -0
- package/lib/services/GraphService.js +103 -0
- package/lib/services/UserService.d.ts +15 -0
- package/lib/services/UserService.js +202 -0
- package/lib/services/UtilityService.d.ts +29 -0
- package/lib/services/UtilityService.js +254 -0
- package/package.json +1 -1
@@ -0,0 +1,202 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
var UserService = /** @class */ (function () {
|
4
|
+
function UserService(context) {
|
5
|
+
var _this = this;
|
6
|
+
this.getCurrentUser = function () {
|
7
|
+
return _this._context.client
|
8
|
+
.get(_this._webAbsoluteUrl + "/_api/web/CurrentUser/?$expand=groups")
|
9
|
+
.then(function (response) {
|
10
|
+
if (response.status >= 200 && response.status <= 300) {
|
11
|
+
return response.data.d;
|
12
|
+
}
|
13
|
+
else {
|
14
|
+
return Promise.reject(new Error(JSON.stringify(response)));
|
15
|
+
}
|
16
|
+
})
|
17
|
+
.then(function (data) {
|
18
|
+
var user = {
|
19
|
+
Id: data.Id,
|
20
|
+
Email: data.Email,
|
21
|
+
EMail: data.EMail,
|
22
|
+
Name: data.Name,
|
23
|
+
LoginName: data.LoginName,
|
24
|
+
Title: data.Title,
|
25
|
+
IsGroup: false,
|
26
|
+
};
|
27
|
+
var groups = [];
|
28
|
+
if (data.Groups != undefined && data.Groups.results != undefined) {
|
29
|
+
data.Groups.results.map(function (group) {
|
30
|
+
groups.push({
|
31
|
+
Id: group.Id,
|
32
|
+
Email: "",
|
33
|
+
EMail: "",
|
34
|
+
Name: group.Name,
|
35
|
+
IsGroup: true,
|
36
|
+
LoginName: group.LoginName,
|
37
|
+
Title: group.Title,
|
38
|
+
});
|
39
|
+
});
|
40
|
+
}
|
41
|
+
// user.Groups = groups;
|
42
|
+
return user;
|
43
|
+
});
|
44
|
+
};
|
45
|
+
this.getUserProperties = function (accountName) {
|
46
|
+
return _this._context.client
|
47
|
+
.get(_this._webAbsoluteUrl +
|
48
|
+
"/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='".concat(encodeURIComponent(accountName), "'"))
|
49
|
+
.then(function (response) {
|
50
|
+
if (response.status >= 200 && response.status <= 300) {
|
51
|
+
return response.data.d;
|
52
|
+
}
|
53
|
+
else {
|
54
|
+
return Promise.reject(new Error(JSON.stringify(response)));
|
55
|
+
}
|
56
|
+
})
|
57
|
+
.then(function (data) {
|
58
|
+
return data;
|
59
|
+
});
|
60
|
+
};
|
61
|
+
this.getUserPropertiesByEmail = function (email) {
|
62
|
+
return _this._context.client
|
63
|
+
.get(_this._webAbsoluteUrl + "/_api/Web/SiteUsers?$filter=Email eq '".concat(email, "'"))
|
64
|
+
.then(function (response) {
|
65
|
+
if (response.status >= 200 && response.status <= 300) {
|
66
|
+
return response.data.d;
|
67
|
+
}
|
68
|
+
else {
|
69
|
+
return Promise.reject(new Error(JSON.stringify(response)));
|
70
|
+
}
|
71
|
+
})
|
72
|
+
.then(function (data) {
|
73
|
+
return data;
|
74
|
+
});
|
75
|
+
};
|
76
|
+
this.getUserById = function (id) {
|
77
|
+
return _this._context.client
|
78
|
+
.get(_this._webAbsoluteUrl + "/_api/web/getUserById(".concat(id, ")?$expand=groups"))
|
79
|
+
.then(function (response) {
|
80
|
+
if (response.status >= 200 && response.status <= 300) {
|
81
|
+
return response.data.d;
|
82
|
+
}
|
83
|
+
else {
|
84
|
+
return Promise.reject(new Error(JSON.stringify(response)));
|
85
|
+
}
|
86
|
+
})
|
87
|
+
.then(function (data) {
|
88
|
+
var user = {
|
89
|
+
Id: data.Id,
|
90
|
+
Email: data.Email,
|
91
|
+
EMail: data.EMail,
|
92
|
+
Name: data.Name,
|
93
|
+
LoginName: data.LoginName,
|
94
|
+
Title: data.Title,
|
95
|
+
IsGroup: false,
|
96
|
+
};
|
97
|
+
var groups = [];
|
98
|
+
if (data.Groups != undefined && data.Groups.results != undefined) {
|
99
|
+
data.Groups.results.map(function (group) {
|
100
|
+
groups.push({
|
101
|
+
Id: group.Id,
|
102
|
+
Email: "",
|
103
|
+
EMail: "",
|
104
|
+
Name: group.Name,
|
105
|
+
IsGroup: true,
|
106
|
+
LoginName: group.LoginName,
|
107
|
+
Title: group.Title,
|
108
|
+
});
|
109
|
+
});
|
110
|
+
}
|
111
|
+
// user.Groups = groups;
|
112
|
+
return user;
|
113
|
+
});
|
114
|
+
};
|
115
|
+
this.getCurrentUserPermissions = function () {
|
116
|
+
var requestUrl = "".concat(_this._context.siteUrl, "/_api/Web/effectiveBasePermissions");
|
117
|
+
return _this._context.client
|
118
|
+
.get(requestUrl)
|
119
|
+
.then(function (response) {
|
120
|
+
if (response.status >= 200 && response.status <= 300) {
|
121
|
+
return response.data.d;
|
122
|
+
}
|
123
|
+
else {
|
124
|
+
return Promise.reject(new Error(JSON.stringify(response)));
|
125
|
+
}
|
126
|
+
})
|
127
|
+
.then(function (data) {
|
128
|
+
return data;
|
129
|
+
});
|
130
|
+
};
|
131
|
+
this._context = context;
|
132
|
+
this._webAbsoluteUrl = context.siteUrl;
|
133
|
+
}
|
134
|
+
UserService.prototype.getCurrentUserGroups = function () {
|
135
|
+
var requestUrl = "".concat(this._context.siteUrl, "/_api/web/currentuser/?$expand=groups");
|
136
|
+
return this._context.client
|
137
|
+
.get(requestUrl)
|
138
|
+
.then(function (response) {
|
139
|
+
if (response.status >= 200 && response.status <= 300) {
|
140
|
+
return response.data.d;
|
141
|
+
}
|
142
|
+
else {
|
143
|
+
return Promise.reject(new Error(JSON.stringify(response)));
|
144
|
+
}
|
145
|
+
})
|
146
|
+
.then(function (data) {
|
147
|
+
var groups = [];
|
148
|
+
data.Groups.results.map(function (group) {
|
149
|
+
groups.push({
|
150
|
+
Id: group.Id,
|
151
|
+
Email: "",
|
152
|
+
EMail: "",
|
153
|
+
Name: group.Name,
|
154
|
+
IsGroup: true,
|
155
|
+
LoginName: group.LoginName,
|
156
|
+
Title: group.Title,
|
157
|
+
});
|
158
|
+
});
|
159
|
+
return groups;
|
160
|
+
});
|
161
|
+
};
|
162
|
+
UserService.prototype.checkIfCurrentUserInGroup = function (groupName) {
|
163
|
+
var requestUrl = "".concat(this._context.siteUrl, "/_api/web/currentuser/?$expand=groups");
|
164
|
+
return this._context.client
|
165
|
+
.get(requestUrl)
|
166
|
+
.then(function (response) {
|
167
|
+
if (response.status >= 200 && response.status <= 300) {
|
168
|
+
return response.data.d;
|
169
|
+
}
|
170
|
+
else {
|
171
|
+
return Promise.reject(new Error(JSON.stringify(response)));
|
172
|
+
}
|
173
|
+
})
|
174
|
+
.then(function (data) {
|
175
|
+
var filteredArr = data.Groups.filter(function (g) {
|
176
|
+
return g.Title == groupName;
|
177
|
+
});
|
178
|
+
return filteredArr.length > 0;
|
179
|
+
});
|
180
|
+
};
|
181
|
+
UserService.prototype.checkIfUserIsInGroup = function (userId, groupName) {
|
182
|
+
var requestUrl = "".concat(this._context.siteUrl, "/_api/web/getUserById(").concat(userId, ")?$expand=groups");
|
183
|
+
return this._context.client
|
184
|
+
.get(requestUrl)
|
185
|
+
.then(function (response) {
|
186
|
+
if (response.status >= 200 && response.status <= 300) {
|
187
|
+
return response.data.d;
|
188
|
+
}
|
189
|
+
else {
|
190
|
+
return Promise.reject(new Error(JSON.stringify(response)));
|
191
|
+
}
|
192
|
+
})
|
193
|
+
.then(function (data) {
|
194
|
+
var filteredArr = data.Groups.filter(function (g) {
|
195
|
+
return g.Title == groupName;
|
196
|
+
});
|
197
|
+
return filteredArr.length > 0;
|
198
|
+
});
|
199
|
+
};
|
200
|
+
return UserService;
|
201
|
+
}());
|
202
|
+
exports.default = UserService;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
export default class UtilityService {
|
2
|
+
static setCookie: (name: string, val: string, validMilliSeconds?: number) => void;
|
3
|
+
static getCookie: (name: string) => string | undefined;
|
4
|
+
static deleteCookie: (name: string) => void;
|
5
|
+
static formatDate: (date: Date) => string;
|
6
|
+
static getMonthsArrayShort: () => string[];
|
7
|
+
static getMonthsArrayFullString: () => string[];
|
8
|
+
static getMonthShortString: (month: number) => string;
|
9
|
+
static getMonthFullString: (month: number) => string;
|
10
|
+
static getPastMonthsArrayShort: (num: number) => string[];
|
11
|
+
static addMonthsToDate: (date: Date, months: number) => Date;
|
12
|
+
static getStartOfTheDay: (date: Date) => Date;
|
13
|
+
static getEndOfTheDay: (date: Date) => Date;
|
14
|
+
static addDaysToMonth: (date: Date, days: number) => Date;
|
15
|
+
static addHoursToDate: (date: Date, hours: number) => Date;
|
16
|
+
static addMinutesToDate: (date: Date, minutes: number) => Date;
|
17
|
+
static addSecondsToDate: (date: Date, seconds: number) => Date;
|
18
|
+
static getFirstDayOfTheMonth: (date: Date) => Date;
|
19
|
+
static getLastDayOfTheMonth: (date: Date) => Date;
|
20
|
+
static getDaysInMonth: (year: number, month: number) => number;
|
21
|
+
static isLeapYear: (year: number) => boolean;
|
22
|
+
static generateGUID: () => any;
|
23
|
+
static generateTimeString: (date: Date) => string;
|
24
|
+
static exportJsonAsExcelSheet: (json: any[], fileTitle: string) => void;
|
25
|
+
static LightenDarkenColor: (col: string, amt: number) => string;
|
26
|
+
static getProfilePictureUrl: (siteUrl: string, email: string, apiType?: string, size?: string) => string;
|
27
|
+
static getRandomColorCode: () => string;
|
28
|
+
static transparentize(value: string, opacity: number): string;
|
29
|
+
}
|
@@ -0,0 +1,254 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
var sp_core_library_1 = require("@microsoft/sp-core-library");
|
4
|
+
var color_1 = require("@kurkle/color");
|
5
|
+
var XLSX = require("xlsx");
|
6
|
+
var UtilityService = /** @class */ (function () {
|
7
|
+
function UtilityService() {
|
8
|
+
}
|
9
|
+
UtilityService.transparentize = function (value, opacity) {
|
10
|
+
var alpha = opacity === undefined ? 0.5 : 1 - opacity;
|
11
|
+
return (0, color_1.default)(value).alpha(alpha).rgbString();
|
12
|
+
};
|
13
|
+
var _a;
|
14
|
+
_a = UtilityService;
|
15
|
+
UtilityService.setCookie = function (name, val, validMilliSeconds) {
|
16
|
+
if (validMilliSeconds === void 0) { validMilliSeconds = 604800000; }
|
17
|
+
var date = new Date();
|
18
|
+
var value = val;
|
19
|
+
// Set it expire in 7 days
|
20
|
+
date.setTime(date.getTime() + validMilliSeconds);
|
21
|
+
// Set it
|
22
|
+
document.cookie =
|
23
|
+
name + "=" + value + "; expires=" + date.toUTCString() + "; path=/";
|
24
|
+
};
|
25
|
+
UtilityService.getCookie = function (name) {
|
26
|
+
var value = "; " + document.cookie;
|
27
|
+
var parts = value.split("; " + name + "=");
|
28
|
+
if (parts.length == 2) {
|
29
|
+
return parts.pop().split(";").shift();
|
30
|
+
}
|
31
|
+
};
|
32
|
+
UtilityService.deleteCookie = function (name) {
|
33
|
+
var date = new Date();
|
34
|
+
// Set it expire in -1 days
|
35
|
+
date.setTime(date.getTime() + -1 * 24 * 60 * 60 * 1000);
|
36
|
+
// Set it
|
37
|
+
document.cookie = name + "=; expires=" + date.toUTCString() + "; path=/";
|
38
|
+
};
|
39
|
+
UtilityService.formatDate = function (date) {
|
40
|
+
date = new Date(date.toString());
|
41
|
+
var monthArr = _a.getMonthsArrayShort();
|
42
|
+
var dateStr = date.getDate() +
|
43
|
+
" " +
|
44
|
+
monthArr[date.getMonth()] +
|
45
|
+
" " +
|
46
|
+
date.getFullYear();
|
47
|
+
return dateStr;
|
48
|
+
};
|
49
|
+
UtilityService.getMonthsArrayShort = function () {
|
50
|
+
return [
|
51
|
+
"Jan",
|
52
|
+
"Feb",
|
53
|
+
"Mar",
|
54
|
+
"Apr",
|
55
|
+
"May",
|
56
|
+
"Jun",
|
57
|
+
"Jul",
|
58
|
+
"Aug",
|
59
|
+
"Sep",
|
60
|
+
"Oct",
|
61
|
+
"Nov",
|
62
|
+
"Dec",
|
63
|
+
];
|
64
|
+
};
|
65
|
+
UtilityService.getMonthsArrayFullString = function () {
|
66
|
+
return [
|
67
|
+
"January",
|
68
|
+
"February",
|
69
|
+
"March",
|
70
|
+
"April",
|
71
|
+
"May",
|
72
|
+
"June",
|
73
|
+
"July",
|
74
|
+
"August",
|
75
|
+
"September",
|
76
|
+
"October",
|
77
|
+
"November",
|
78
|
+
"December",
|
79
|
+
];
|
80
|
+
};
|
81
|
+
UtilityService.getMonthShortString = function (month) {
|
82
|
+
var monthStr = _a.getMonthsArrayShort();
|
83
|
+
return monthStr[month];
|
84
|
+
};
|
85
|
+
UtilityService.getMonthFullString = function (month) {
|
86
|
+
var monthStr = _a.getMonthsArrayFullString();
|
87
|
+
return monthStr[month];
|
88
|
+
};
|
89
|
+
UtilityService.getPastMonthsArrayShort = function (num) {
|
90
|
+
num = num <= 0 ? 1 : num;
|
91
|
+
var monthArr = [];
|
92
|
+
for (var i = num - 1; i >= 0; i--) {
|
93
|
+
var date = new Date();
|
94
|
+
monthArr.push(_a.getMonthShortString(_a.addMonthsToDate(date, -1 * i).getMonth()));
|
95
|
+
}
|
96
|
+
return monthArr;
|
97
|
+
};
|
98
|
+
UtilityService.addMonthsToDate = function (date, months) {
|
99
|
+
var n = date.getDate();
|
100
|
+
date.setDate(1);
|
101
|
+
date.setMonth(date.getMonth() + months);
|
102
|
+
date.setDate(Math.min(n, _a.getDaysInMonth(date.getFullYear(), date.getMonth())));
|
103
|
+
return date;
|
104
|
+
// debugger;
|
105
|
+
// date.setMonth(date.getMonth() + months);
|
106
|
+
// debugger;
|
107
|
+
// var newDate = new Date(date.toString());
|
108
|
+
// return newDate;
|
109
|
+
};
|
110
|
+
UtilityService.getStartOfTheDay = function (date) {
|
111
|
+
date.setHours(0, 0, 0, 0);
|
112
|
+
return date;
|
113
|
+
};
|
114
|
+
UtilityService.getEndOfTheDay = function (date) {
|
115
|
+
date.setHours(23, 59, 59, 999);
|
116
|
+
return date;
|
117
|
+
};
|
118
|
+
UtilityService.addDaysToMonth = function (date, days) {
|
119
|
+
return new Date(date.getTime() + days * 24 * 60 * 60 * 1000);
|
120
|
+
};
|
121
|
+
UtilityService.addHoursToDate = function (date, hours) {
|
122
|
+
return new Date(date.getTime() + hours * 60 * 60 * 1000);
|
123
|
+
};
|
124
|
+
UtilityService.addMinutesToDate = function (date, minutes) {
|
125
|
+
return new Date(date.getTime() + minutes * 60 * 1000);
|
126
|
+
};
|
127
|
+
UtilityService.addSecondsToDate = function (date, seconds) {
|
128
|
+
return new Date(date.getTime() + seconds * 1000);
|
129
|
+
};
|
130
|
+
UtilityService.getFirstDayOfTheMonth = function (date) {
|
131
|
+
return new Date(date.getFullYear(), date.getMonth(), 1);
|
132
|
+
};
|
133
|
+
UtilityService.getLastDayOfTheMonth = function (date) {
|
134
|
+
return _a.addSecondsToDate(new Date(date.getFullYear(), date.getMonth() + 1, 1), -1);
|
135
|
+
};
|
136
|
+
UtilityService.getDaysInMonth = function (year, month) {
|
137
|
+
return [
|
138
|
+
31,
|
139
|
+
_a.isLeapYear(year) ? 29 : 28,
|
140
|
+
31,
|
141
|
+
30,
|
142
|
+
31,
|
143
|
+
30,
|
144
|
+
31,
|
145
|
+
31,
|
146
|
+
30,
|
147
|
+
31,
|
148
|
+
30,
|
149
|
+
31,
|
150
|
+
][month];
|
151
|
+
};
|
152
|
+
UtilityService.isLeapYear = function (year) {
|
153
|
+
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
|
154
|
+
};
|
155
|
+
UtilityService.generateGUID = function () {
|
156
|
+
var myGuidObj = sp_core_library_1.Guid.newGuid();
|
157
|
+
var newGuid = myGuidObj.toString();
|
158
|
+
// console.log(newGuid);
|
159
|
+
return newGuid;
|
160
|
+
};
|
161
|
+
UtilityService.generateTimeString = function (date) {
|
162
|
+
var timeStr = "A few seconds ago";
|
163
|
+
var timeDiffNum = Math.floor(new Date().getTime() - date.getTime()) / (1000 * 60 * 60 * 24);
|
164
|
+
if (parseInt(timeDiffNum.toString()) > 365) {
|
165
|
+
timeDiffNum = timeDiffNum / 365;
|
166
|
+
timeStr = "".concat(timeDiffNum.toFixed(0), " year").concat(timeDiffNum >= 2 ? "s" : "", " ago");
|
167
|
+
}
|
168
|
+
else if (parseInt(timeDiffNum.toString()) >= 2) {
|
169
|
+
timeStr = "".concat(parseInt(timeDiffNum.toString()).toFixed(0), " days ago");
|
170
|
+
}
|
171
|
+
else if (parseInt(timeDiffNum.toString()) == 1) {
|
172
|
+
timeStr = "Yesterday";
|
173
|
+
}
|
174
|
+
else {
|
175
|
+
timeDiffNum = timeDiffNum * 24;
|
176
|
+
if (parseInt(timeDiffNum.toString()) >= 2) {
|
177
|
+
timeStr = "".concat(timeDiffNum.toFixed(0), " hours ago");
|
178
|
+
}
|
179
|
+
else if (parseInt(timeDiffNum.toString()) >= 1 &&
|
180
|
+
parseInt(timeDiffNum.toString()) < 2) {
|
181
|
+
timeStr = "About an hour ago";
|
182
|
+
}
|
183
|
+
else {
|
184
|
+
timeDiffNum = timeDiffNum * 60;
|
185
|
+
if (parseInt(timeDiffNum.toString()) >= 2) {
|
186
|
+
timeStr = "".concat(timeDiffNum.toFixed(0), " minutes ago");
|
187
|
+
}
|
188
|
+
else if (parseInt(timeDiffNum.toString()) >= 1 &&
|
189
|
+
parseInt(timeDiffNum.toString()) < 2) {
|
190
|
+
timeStr = "About a minute ago";
|
191
|
+
}
|
192
|
+
}
|
193
|
+
}
|
194
|
+
return timeStr;
|
195
|
+
};
|
196
|
+
UtilityService.exportJsonAsExcelSheet = function (json, fileTitle) {
|
197
|
+
var worksheet = XLSX.utils.json_to_sheet(json);
|
198
|
+
var workbook = {
|
199
|
+
Sheets: { data: worksheet },
|
200
|
+
SheetNames: ["data"],
|
201
|
+
};
|
202
|
+
XLSX.writeFile(workbook, "".concat(fileTitle, ".xlsx"));
|
203
|
+
};
|
204
|
+
UtilityService.LightenDarkenColor = function (col, amt) {
|
205
|
+
var usePound = false;
|
206
|
+
if (col[0] == "#") {
|
207
|
+
col = col.slice(1);
|
208
|
+
usePound = true;
|
209
|
+
}
|
210
|
+
var num = parseInt(col, 16);
|
211
|
+
var r = (num >> 16) + amt;
|
212
|
+
if (r > 255)
|
213
|
+
r = 255;
|
214
|
+
else if (r < 0)
|
215
|
+
r = 0;
|
216
|
+
var b = ((num >> 8) & 0x00ff) + amt;
|
217
|
+
if (b > 255)
|
218
|
+
b = 255;
|
219
|
+
else if (b < 0)
|
220
|
+
b = 0;
|
221
|
+
var g = (num & 0x0000ff) + amt;
|
222
|
+
if (g > 255)
|
223
|
+
g = 255;
|
224
|
+
else if (g < 0)
|
225
|
+
g = 0;
|
226
|
+
return (usePound ? "#" : "") + (g | (b << 8) | (r << 16)).toString(16);
|
227
|
+
};
|
228
|
+
UtilityService.getProfilePictureUrl = function (siteUrl, email, apiType, size) {
|
229
|
+
if (apiType === void 0) { apiType = "2"; }
|
230
|
+
if (size === void 0) { size = "L"; }
|
231
|
+
var api = "";
|
232
|
+
switch (apiType) {
|
233
|
+
case "2": {
|
234
|
+
api = "".concat(siteUrl, "/_vti_bin/DelveApi.ashx/people/profileimage?size=").concat(size, "&userId=").concat(email);
|
235
|
+
break;
|
236
|
+
}
|
237
|
+
default: {
|
238
|
+
api = "".concat(siteUrl, "/_layouts/15/userphoto.aspx?size=").concat(size, "&accountname=").concat(email);
|
239
|
+
break;
|
240
|
+
}
|
241
|
+
}
|
242
|
+
return api;
|
243
|
+
};
|
244
|
+
UtilityService.getRandomColorCode = function () {
|
245
|
+
var letters = "0123456789ABCDEF".split("");
|
246
|
+
var color = "#";
|
247
|
+
for (var i = 0; i < 6; i++) {
|
248
|
+
color += letters[Math.floor(Math.random() * 16)];
|
249
|
+
}
|
250
|
+
return color;
|
251
|
+
};
|
252
|
+
return UtilityService;
|
253
|
+
}());
|
254
|
+
exports.default = UtilityService;
|