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.
Files changed (94) hide show
  1. package/@types/allTypes.d.ts +1 -0
  2. package/controls/JitzGrid.tsx +639 -0
  3. package/controls/JitzImage.tsx +38 -0
  4. package/controls/JitzPeoplePicker.tsx +419 -0
  5. package/controls/JitzPersonInfo.tsx +114 -0
  6. package/controls/JitzPersona.tsx +53 -0
  7. package/data/context/CommonRepository.ts +287 -0
  8. package/data/context/JitzContext.ts +33 -0
  9. package/data/context/JitzSPContext.ts +16 -0
  10. package/data/context/JitzSPHttpClient.ts +133 -0
  11. package/data/context/List.ts +415 -0
  12. package/data/context/Repository.ts +395 -0
  13. package/data/interfaces/ICommonRepository.ts +7 -0
  14. package/data/interfaces/IJitzContext.ts +11 -0
  15. package/data/interfaces/IJitzSPContext.ts +7 -0
  16. package/data/interfaces/IJitzSPHttpClient.ts +6 -0
  17. package/data/interfaces/IList.ts +41 -0
  18. package/data/interfaces/IModels.ts +33 -0
  19. package/data/interfaces/IRepository.ts +31 -0
  20. package/lib/common/IModels.d.ts +9 -1
  21. package/lib/common/IObjects.d.ts +72 -0
  22. package/lib/common/IObjects.js +30 -0
  23. package/lib/controls/JitzGrid.d.ts +75 -0
  24. package/lib/controls/JitzGrid.js +606 -0
  25. package/lib/controls/JitzImage.d.ts +14 -0
  26. package/lib/controls/JitzImage.js +37 -0
  27. package/lib/controls/JitzPeoplePicker.d.ts +49 -0
  28. package/lib/controls/JitzPeoplePicker.js +311 -0
  29. package/lib/controls/JitzPersonInfo.d.ts +32 -0
  30. package/lib/controls/JitzPersonInfo.js +98 -0
  31. package/lib/controls/JitzPersona.d.ts +23 -0
  32. package/lib/controls/JitzPersona.js +48 -0
  33. package/lib/data/Activities.d.ts +6 -0
  34. package/lib/data/Activities.js +36 -0
  35. package/lib/data/Attachments.d.ts +6 -0
  36. package/lib/data/Attachments.js +30 -0
  37. package/lib/data/Configurations.d.ts +6 -0
  38. package/lib/data/Configurations.js +30 -0
  39. package/lib/data/CustomStylesheet.d.ts +6 -0
  40. package/lib/data/CustomStylesheet.js +30 -0
  41. package/lib/data/EmailTemplates.d.ts +6 -0
  42. package/lib/data/EmailTemplates.js +31 -0
  43. package/lib/data/FAQs.d.ts +6 -0
  44. package/lib/data/FAQs.js +30 -0
  45. package/lib/data/HomePageTexts.d.ts +6 -0
  46. package/lib/data/HomePageTexts.js +30 -0
  47. package/lib/data/TicketCategories.d.ts +6 -0
  48. package/lib/data/TicketCategories.js +26 -0
  49. package/lib/data/TicketComments.d.ts +6 -0
  50. package/lib/data/TicketComments.js +32 -0
  51. package/lib/data/TicketPriorities.d.ts +6 -0
  52. package/lib/data/TicketPriorities.js +31 -0
  53. package/lib/data/TicketStatuses.d.ts +6 -0
  54. package/lib/data/TicketStatuses.js +31 -0
  55. package/lib/data/TicketSubcategories.d.ts +6 -0
  56. package/lib/data/TicketSubcategories.js +26 -0
  57. package/lib/data/Tickets.d.ts +6 -0
  58. package/lib/data/Tickets.js +45 -0
  59. package/lib/data/context/CommonRepository.d.ts +17 -0
  60. package/lib/data/context/CommonRepository.js +288 -0
  61. package/lib/data/context/JitzContext.d.ts +13 -0
  62. package/lib/data/context/JitzContext.js +80 -0
  63. package/lib/data/context/JitzSPContext.d.ts +8 -0
  64. package/lib/data/context/JitzSPContext.js +58 -0
  65. package/lib/data/context/JitzSPHttpClient.d.ts +14 -0
  66. package/lib/data/context/JitzSPHttpClient.js +173 -0
  67. package/lib/data/context/List.d.ts +35 -0
  68. package/lib/data/context/List.js +442 -0
  69. package/lib/data/context/Repository.d.ts +19 -0
  70. package/lib/data/context/Repository.js +421 -0
  71. package/lib/data/interfaces/ICommonRepository.d.ts +6 -0
  72. package/lib/data/interfaces/ICommonRepository.js +2 -0
  73. package/lib/data/interfaces/IJitzContext.d.ts +10 -0
  74. package/lib/data/interfaces/IJitzContext.js +2 -0
  75. package/lib/data/interfaces/IJitzSPContext.d.ts +6 -0
  76. package/lib/data/interfaces/IJitzSPContext.js +2 -0
  77. package/lib/data/interfaces/IJitzSPHttpClient.d.ts +6 -0
  78. package/lib/data/interfaces/IJitzSPHttpClient.js +2 -0
  79. package/lib/data/interfaces/IList.d.ts +25 -0
  80. package/lib/data/interfaces/IList.js +2 -0
  81. package/lib/data/interfaces/IModels.d.ts +32 -0
  82. package/lib/data/interfaces/IModels.js +2 -0
  83. package/lib/data/interfaces/IRepository.d.ts +14 -0
  84. package/lib/data/interfaces/IRepository.js +2 -0
  85. package/lib/jitzSPHttpClient.js +5 -3
  86. package/lib/repositories/CommonRepository.js +89 -33
  87. package/lib/repositories/Repository.js +22 -21
  88. package/lib/services/GraphService.d.ts +10 -0
  89. package/lib/services/GraphService.js +105 -0
  90. package/lib/services/UserService.d.ts +1 -1
  91. package/lib/services/UserService.js +9 -9
  92. package/lib/services/UtilityService.d.ts +18 -12
  93. package/lib/services/UtilityService.js +157 -58
  94. 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(context) {
6
- this._context = context;
7
- this._webAbsoluteUrl = context.siteUrl;
6
+ function UtilityService() {
8
7
  }
9
- UtilityService.monthNames = [
10
- "Jan",
11
- "Feb",
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() + validMinutes);
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.formatDateToMonthAndDate = function (date) {
85
- return date.getDate() + " " + UtilityService.monthNames[date.getMonth()];
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.getMonthFullNameOfTheDate = function (date) {
88
- return UtilityService.monthNamesFull[date.getMonth()];
75
+ UtilityService.getMonthShortString = function (month) {
76
+ var monthStr = _a.getMonthsArrayShort();
77
+ return monthStr[month];
89
78
  };
90
- UtilityService.getMonthOfTheDate = function (date) {
91
- return UtilityService.monthNames[date.getMonth()];
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 newDate = new Date(date.toDateString());
95
- return new Date(newDate.setMonth(newDate.getMonth() + months));
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.addDaysToDate = function (date, days) {
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 d = new Date().getTime();
108
- var uuid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
109
- var r = (d + Math.random() * 16) % 16 | 0;
110
- d = Math.floor(d / 16);
111
- return (c == "x" ? r : (r & 0x7) | 0x8).toString(16);
112
- });
113
- return uuid;
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 + ".xlsx");
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": "1.11.2",
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
- "@microsoft/sp-core-library": ">=1.9.1",
14
- "@microsoft/sp-lodash-subset": ">=1.9.1",
15
- "@microsoft/sp-office-ui-fabric-core": ">=1.9.1",
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": "^3.5.2"
31
+ "typescript": "^5.5.4"
30
32
  }
31
33
  }