jitz-sharepoint-utilities 1.11.2 → 2.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/@types/allTypes.d.ts +1 -0
- package/controls/JitzGrid.tsx +639 -0
- package/controls/JitzImage.tsx +38 -0
- package/controls/JitzPeoplePicker.tsx +419 -0
- package/controls/JitzPersonInfo.tsx +114 -0
- package/controls/JitzPersona.tsx +53 -0
- package/data/context/CommonRepository.ts +287 -0
- package/data/context/JitzContext.ts +33 -0
- package/data/context/JitzSPContext.ts +16 -0
- package/data/context/JitzSPHttpClient.ts +133 -0
- package/data/context/List.ts +415 -0
- package/data/context/Repository.ts +395 -0
- package/data/interfaces/ICommonRepository.ts +7 -0
- package/data/interfaces/IJitzContext.ts +11 -0
- package/data/interfaces/IJitzSPContext.ts +7 -0
- package/data/interfaces/IJitzSPHttpClient.ts +6 -0
- package/data/interfaces/IList.ts +41 -0
- package/data/interfaces/IModels.ts +33 -0
- package/data/interfaces/IRepository.ts +31 -0
- package/lib/common/IModels.d.ts +9 -1
- 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/Activities.d.ts +6 -0
- package/lib/data/Activities.js +36 -0
- package/lib/data/Attachments.d.ts +6 -0
- package/lib/data/Attachments.js +30 -0
- package/lib/data/Configurations.d.ts +6 -0
- package/lib/data/Configurations.js +30 -0
- package/lib/data/CustomStylesheet.d.ts +6 -0
- package/lib/data/CustomStylesheet.js +30 -0
- package/lib/data/EmailTemplates.d.ts +6 -0
- package/lib/data/EmailTemplates.js +31 -0
- package/lib/data/FAQs.d.ts +6 -0
- package/lib/data/FAQs.js +30 -0
- package/lib/data/HomePageTexts.d.ts +6 -0
- package/lib/data/HomePageTexts.js +30 -0
- package/lib/data/TicketCategories.d.ts +6 -0
- package/lib/data/TicketCategories.js +26 -0
- package/lib/data/TicketComments.d.ts +6 -0
- package/lib/data/TicketComments.js +32 -0
- package/lib/data/TicketPriorities.d.ts +6 -0
- package/lib/data/TicketPriorities.js +31 -0
- package/lib/data/TicketStatuses.d.ts +6 -0
- package/lib/data/TicketStatuses.js +31 -0
- package/lib/data/TicketSubcategories.d.ts +6 -0
- package/lib/data/TicketSubcategories.js +26 -0
- package/lib/data/Tickets.d.ts +6 -0
- package/lib/data/Tickets.js +45 -0
- package/lib/data/context/CommonRepository.d.ts +17 -0
- package/lib/data/context/CommonRepository.js +288 -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 +35 -0
- package/lib/data/context/List.js +442 -0
- package/lib/data/context/Repository.d.ts +19 -0
- package/lib/data/context/Repository.js +421 -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 +25 -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 +14 -0
- package/lib/data/interfaces/IRepository.js +2 -0
- package/lib/jitzSPHttpClient.js +5 -3
- package/lib/repositories/CommonRepository.js +89 -33
- package/lib/repositories/Repository.js +22 -21
- package/lib/services/GraphService.d.ts +10 -0
- package/lib/services/GraphService.js +105 -0
- package/lib/services/UserService.d.ts +1 -1
- package/lib/services/UserService.js +9 -9
- package/lib/services/UtilityService.d.ts +18 -12
- package/lib/services/UtilityService.js +157 -58
- package/package.json +7 -5
@@ -1,45 +1,17 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
var sp_core_library_1 = require("@microsoft/sp-core-library");
|
3
4
|
var XLSX = require("xlsx");
|
4
5
|
var UtilityService = /** @class */ (function () {
|
5
|
-
function UtilityService(
|
6
|
-
this._context = context;
|
7
|
-
this._webAbsoluteUrl = context.siteUrl;
|
6
|
+
function UtilityService() {
|
8
7
|
}
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
"Mar",
|
13
|
-
"Apr",
|
14
|
-
"May",
|
15
|
-
"Jun",
|
16
|
-
"Jul",
|
17
|
-
"Aug",
|
18
|
-
"Sep",
|
19
|
-
"Oct",
|
20
|
-
"Nov",
|
21
|
-
"Dec",
|
22
|
-
];
|
23
|
-
UtilityService.monthNamesFull = [
|
24
|
-
"January",
|
25
|
-
"February",
|
26
|
-
"March",
|
27
|
-
"April",
|
28
|
-
"May",
|
29
|
-
"June",
|
30
|
-
"July",
|
31
|
-
"August",
|
32
|
-
"September",
|
33
|
-
"October",
|
34
|
-
"November",
|
35
|
-
"December",
|
36
|
-
];
|
37
|
-
UtilityService.setCookie = function (name, val, validMinutes) {
|
38
|
-
if (validMinutes === void 0) { validMinutes = 604800; }
|
8
|
+
var _a;
|
9
|
+
_a = UtilityService;
|
10
|
+
UtilityService.setCookie = function (name, val) {
|
39
11
|
var date = new Date();
|
40
12
|
var value = val;
|
41
13
|
// Set it expire in 7 days
|
42
|
-
date.setTime(date.getTime() +
|
14
|
+
date.setTime(date.getTime() + 7 * 24 * 60 * 60 * 1000);
|
43
15
|
// Set it
|
44
16
|
document.cookie =
|
45
17
|
name + "=" + value + "; expires=" + date.toUTCString() + "; path=/";
|
@@ -60,7 +32,16 @@ var UtilityService = /** @class */ (function () {
|
|
60
32
|
};
|
61
33
|
UtilityService.formatDate = function (date) {
|
62
34
|
date = new Date(date.toString());
|
63
|
-
var monthArr =
|
35
|
+
var monthArr = _a.getMonthsArrayShort();
|
36
|
+
var dateStr = date.getDate() +
|
37
|
+
" " +
|
38
|
+
monthArr[date.getMonth()] +
|
39
|
+
" " +
|
40
|
+
date.getFullYear();
|
41
|
+
return dateStr;
|
42
|
+
};
|
43
|
+
UtilityService.getMonthsArrayShort = function () {
|
44
|
+
return [
|
64
45
|
"Jan",
|
65
46
|
"Feb",
|
66
47
|
"Mar",
|
@@ -74,27 +55,61 @@ var UtilityService = /** @class */ (function () {
|
|
74
55
|
"Nov",
|
75
56
|
"Dec",
|
76
57
|
];
|
77
|
-
var dateStr = date.getDate() +
|
78
|
-
" " +
|
79
|
-
monthArr[date.getMonth()] +
|
80
|
-
" " +
|
81
|
-
date.getFullYear();
|
82
|
-
return dateStr;
|
83
58
|
};
|
84
|
-
UtilityService.
|
85
|
-
return
|
59
|
+
UtilityService.getMonthsArrayFullString = function () {
|
60
|
+
return [
|
61
|
+
"January",
|
62
|
+
"February",
|
63
|
+
"March",
|
64
|
+
"April",
|
65
|
+
"May",
|
66
|
+
"June",
|
67
|
+
"July",
|
68
|
+
"August",
|
69
|
+
"September",
|
70
|
+
"October",
|
71
|
+
"November",
|
72
|
+
"December",
|
73
|
+
];
|
86
74
|
};
|
87
|
-
UtilityService.
|
88
|
-
|
75
|
+
UtilityService.getMonthShortString = function (month) {
|
76
|
+
var monthStr = _a.getMonthsArrayShort();
|
77
|
+
return monthStr[month];
|
89
78
|
};
|
90
|
-
UtilityService.
|
91
|
-
|
79
|
+
UtilityService.getMonthFullString = function (month) {
|
80
|
+
var monthStr = _a.getMonthsArrayFullString();
|
81
|
+
return monthStr[month];
|
82
|
+
};
|
83
|
+
UtilityService.getPastMonthsArrayShort = function (num) {
|
84
|
+
num = num <= 0 ? 1 : num;
|
85
|
+
var monthArr = [];
|
86
|
+
for (var i = num - 1; i >= 0; i--) {
|
87
|
+
var date = new Date();
|
88
|
+
monthArr.push(_a.getMonthShortString(_a.addMonthsToDate(date, -1 * i).getMonth()));
|
89
|
+
}
|
90
|
+
return monthArr;
|
92
91
|
};
|
93
92
|
UtilityService.addMonthsToDate = function (date, months) {
|
94
|
-
var
|
95
|
-
|
93
|
+
var n = date.getDate();
|
94
|
+
date.setDate(1);
|
95
|
+
date.setMonth(date.getMonth() + months);
|
96
|
+
date.setDate(Math.min(n, _a.getDaysInMonth(date.getFullYear(), date.getMonth())));
|
97
|
+
return date;
|
98
|
+
// debugger;
|
99
|
+
// date.setMonth(date.getMonth() + months);
|
100
|
+
// debugger;
|
101
|
+
// var newDate = new Date(date.toString());
|
102
|
+
// return newDate;
|
96
103
|
};
|
97
|
-
UtilityService.
|
104
|
+
UtilityService.getStartOfTheDay = function (date) {
|
105
|
+
date.setHours(0, 0, 0, 0);
|
106
|
+
return date;
|
107
|
+
};
|
108
|
+
UtilityService.getEndOfTheDay = function (date) {
|
109
|
+
date.setHours(23, 59, 59, 999);
|
110
|
+
return date;
|
111
|
+
};
|
112
|
+
UtilityService.addDaysToMonth = function (date, days) {
|
98
113
|
return new Date(date.getTime() + days * 24 * 60 * 60 * 1000);
|
99
114
|
};
|
100
115
|
UtilityService.addHoursToDate = function (date, hours) {
|
@@ -103,14 +118,74 @@ var UtilityService = /** @class */ (function () {
|
|
103
118
|
UtilityService.addMinutesToDate = function (date, minutes) {
|
104
119
|
return new Date(date.getTime() + minutes * 60 * 1000);
|
105
120
|
};
|
121
|
+
UtilityService.addSecondsToDate = function (date, seconds) {
|
122
|
+
return new Date(date.getTime() + seconds * 1000);
|
123
|
+
};
|
124
|
+
UtilityService.getFirstDayOfTheMonth = function (date) {
|
125
|
+
return new Date(date.getFullYear(), date.getMonth(), 1);
|
126
|
+
};
|
127
|
+
UtilityService.getLastDayOfTheMonth = function (date) {
|
128
|
+
return _a.addSecondsToDate(new Date(date.getFullYear(), date.getMonth() + 1, 1), -1);
|
129
|
+
};
|
130
|
+
UtilityService.getDaysInMonth = function (year, month) {
|
131
|
+
return [
|
132
|
+
31,
|
133
|
+
_a.isLeapYear(year) ? 29 : 28,
|
134
|
+
31,
|
135
|
+
30,
|
136
|
+
31,
|
137
|
+
30,
|
138
|
+
31,
|
139
|
+
31,
|
140
|
+
30,
|
141
|
+
31,
|
142
|
+
30,
|
143
|
+
31,
|
144
|
+
][month];
|
145
|
+
};
|
146
|
+
UtilityService.isLeapYear = function (year) {
|
147
|
+
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
|
148
|
+
};
|
106
149
|
UtilityService.generateGUID = function () {
|
107
|
-
var
|
108
|
-
var
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
150
|
+
var myGuidObj = sp_core_library_1.Guid.newGuid();
|
151
|
+
var newGuid = myGuidObj.toString();
|
152
|
+
// console.log(newGuid);
|
153
|
+
return newGuid;
|
154
|
+
};
|
155
|
+
UtilityService.generateTimeString = function (date) {
|
156
|
+
var timeStr = "A few seconds ago";
|
157
|
+
var timeDiffNum = Math.floor(new Date().getTime() - date.getTime()) / (1000 * 60 * 60 * 24);
|
158
|
+
if (parseInt(timeDiffNum.toString()) > 365) {
|
159
|
+
timeDiffNum = timeDiffNum / 365;
|
160
|
+
timeStr = "".concat(timeDiffNum.toFixed(0), " year").concat(timeDiffNum >= 2 ? "s" : "", " ago");
|
161
|
+
}
|
162
|
+
else if (parseInt(timeDiffNum.toString()) >= 2) {
|
163
|
+
timeStr = "".concat(parseInt(timeDiffNum.toString()).toFixed(0), " days ago");
|
164
|
+
}
|
165
|
+
else if (parseInt(timeDiffNum.toString()) == 1) {
|
166
|
+
timeStr = "Yesterday";
|
167
|
+
}
|
168
|
+
else {
|
169
|
+
timeDiffNum = timeDiffNum * 24;
|
170
|
+
if (parseInt(timeDiffNum.toString()) >= 2) {
|
171
|
+
timeStr = "".concat(timeDiffNum.toFixed(0), " hours ago");
|
172
|
+
}
|
173
|
+
else if (parseInt(timeDiffNum.toString()) >= 1 &&
|
174
|
+
parseInt(timeDiffNum.toString()) < 2) {
|
175
|
+
timeStr = "About an hour ago";
|
176
|
+
}
|
177
|
+
else {
|
178
|
+
timeDiffNum = timeDiffNum * 60;
|
179
|
+
if (parseInt(timeDiffNum.toString()) >= 2) {
|
180
|
+
timeStr = "".concat(timeDiffNum.toFixed(0), " minutes ago");
|
181
|
+
}
|
182
|
+
else if (parseInt(timeDiffNum.toString()) >= 1 &&
|
183
|
+
parseInt(timeDiffNum.toString()) < 2) {
|
184
|
+
timeStr = "About a minute ago";
|
185
|
+
}
|
186
|
+
}
|
187
|
+
}
|
188
|
+
return timeStr;
|
114
189
|
};
|
115
190
|
UtilityService.exportJsonAsExcelSheet = function (json, fileTitle) {
|
116
191
|
var worksheet = XLSX.utils.json_to_sheet(json);
|
@@ -118,7 +193,7 @@ var UtilityService = /** @class */ (function () {
|
|
118
193
|
Sheets: { data: worksheet },
|
119
194
|
SheetNames: ["data"],
|
120
195
|
};
|
121
|
-
XLSX.writeFile(workbook, fileTitle
|
196
|
+
XLSX.writeFile(workbook, "".concat(fileTitle, ".xlsx"));
|
122
197
|
};
|
123
198
|
UtilityService.LightenDarkenColor = function (col, amt) {
|
124
199
|
var usePound = false;
|
@@ -144,6 +219,30 @@ var UtilityService = /** @class */ (function () {
|
|
144
219
|
g = 0;
|
145
220
|
return (usePound ? "#" : "") + (g | (b << 8) | (r << 16)).toString(16);
|
146
221
|
};
|
222
|
+
UtilityService.getProfilePictureUrl = function (siteUrl, email, apiType, size) {
|
223
|
+
if (apiType === void 0) { apiType = "2"; }
|
224
|
+
if (size === void 0) { size = "L"; }
|
225
|
+
var api = "";
|
226
|
+
switch (apiType) {
|
227
|
+
case "2": {
|
228
|
+
api = "".concat(siteUrl, "/_vti_bin/DelveApi.ashx/people/profileimage?size=").concat(size, "&userId=").concat(email);
|
229
|
+
break;
|
230
|
+
}
|
231
|
+
default: {
|
232
|
+
api = "".concat(siteUrl, "/_layouts/15/userphoto.aspx?size=").concat(size, "&accountname=").concat(email);
|
233
|
+
break;
|
234
|
+
}
|
235
|
+
}
|
236
|
+
return api;
|
237
|
+
};
|
238
|
+
UtilityService.getRandomColorCode = function () {
|
239
|
+
var letters = "0123456789ABCDEF".split("");
|
240
|
+
var color = "#";
|
241
|
+
for (var i = 0; i < 6; i++) {
|
242
|
+
color += letters[Math.floor(Math.random() * 16)];
|
243
|
+
}
|
244
|
+
return color;
|
245
|
+
};
|
147
246
|
return UtilityService;
|
148
247
|
}());
|
149
248
|
exports.default = UtilityService;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "jitz-sharepoint-utilities",
|
3
|
-
"version": "
|
3
|
+
"version": "2.0.0",
|
4
4
|
"description": "Essential SharePoint utilities for SharePoint Add-in and SPFx development",
|
5
5
|
"author": "Jithendra Mani",
|
6
6
|
"license": "ISC",
|
@@ -10,9 +10,11 @@
|
|
10
10
|
"build": "tsc"
|
11
11
|
},
|
12
12
|
"dependencies": {
|
13
|
-
"@
|
14
|
-
"@microsoft/sp-
|
15
|
-
"@microsoft/sp-
|
13
|
+
"@fluentui/react": "^8.106.4",
|
14
|
+
"@microsoft/sp-core-library": "^1.19.0",
|
15
|
+
"@microsoft/sp-lodash-subset": "^1.19.0",
|
16
|
+
"@microsoft/sp-office-ui-fabric-core": "^1.19.0",
|
17
|
+
"@microsoft/sp-webpart-base": "^1.19.0",
|
16
18
|
"@types/file-saver": "^2.0.1",
|
17
19
|
"axios": "^0.19.2",
|
18
20
|
"file-saver": "^2.0.2",
|
@@ -26,6 +28,6 @@
|
|
26
28
|
"ajv": "~5.2.2",
|
27
29
|
"gulp": "^4.0.2",
|
28
30
|
"gulp-typescript": "^5.0.1",
|
29
|
-
"typescript": "^
|
31
|
+
"typescript": "^5.5.4"
|
30
32
|
}
|
31
33
|
}
|