@intellias/menu 1.0.2 → 1.0.5

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 (175) hide show
  1. package/README.md +44 -9
  2. package/dist/css/main.css +155 -2
  3. package/dist/index.html +9 -0
  4. package/dist/js/{1.js → kudosForm.js} +24 -58
  5. package/dist/js/main.js +654 -689
  6. package/dist/js/rejectComponent.js +363 -0
  7. package/dist/js/{6.js → vendors~kudosForm.js} +5 -5
  8. package/dist/js/{0.js → vendors~kudosForm~rejectComponent.js} +27 -27
  9. package/dist/js/vue.js +2 -2
  10. package/package.json +100 -112
  11. package/Menu.ts +0 -625
  12. package/assets/icons/arrow-down.svg +0 -13
  13. package/assets/icons/arrow-left.svg +0 -3
  14. package/assets/icons/arrow-submenu.svg +0 -8
  15. package/assets/icons/close.svg +0 -3
  16. package/assets/icons/delete.svg +0 -13
  17. package/assets/icons/faq-new.svg +0 -4
  18. package/assets/icons/kudos.svg +0 -14
  19. package/assets/icons/loading-spinner.svg +0 -40
  20. package/assets/icons/notification.svg +0 -11
  21. package/assets/icons/notifications/assessment.svg +0 -10
  22. package/assets/icons/notifications/buddy_program.svg +0 -8
  23. package/assets/icons/notifications/compensation_packages.svg +0 -10
  24. package/assets/icons/notifications/dsat.svg +0 -8
  25. package/assets/icons/notifications/feedback.svg +0 -7
  26. package/assets/icons/notifications/kudos.svg +0 -4
  27. package/assets/icons/notifications/overtime_requests.svg +0 -15
  28. package/assets/icons/notifications/pdu_program.svg +0 -4
  29. package/assets/icons/notifications/profile_update.svg +0 -6
  30. package/assets/icons/notifications/recommendation_program.svg +0 -7
  31. package/assets/icons/notifications/reminders.svg +0 -4
  32. package/assets/icons/notifications/sick_leaves.svg +0 -5
  33. package/assets/icons/notifications/smarts.svg +0 -4
  34. package/assets/icons/notifications/survey.svg +0 -8
  35. package/assets/icons/notifications/unpaid_leave.svg +0 -4
  36. package/assets/icons/notifications/vacations.svg +0 -4
  37. package/assets/icons/pause.svg +0 -13
  38. package/assets/icons/play.svg +0 -13
  39. package/assets/icons/smart.svg +0 -14
  40. package/assets/icons/smarts-kudos.svg +0 -11
  41. package/assets/icons/spinner-solid.svg +0 -1
  42. package/assets/icons/vacation.svg +0 -14
  43. package/assets/icons/visibility.svg +0 -1
  44. package/assets/intems-logo.svg +0 -3
  45. package/babel.config.js +0 -6
  46. package/buses/eventBus.ts +0 -19
  47. package/buses/events/GiveKudosEvent.ts +0 -7
  48. package/components/buttons/action-button/ActionButton.scss +0 -133
  49. package/components/buttons/action-button/ActionButton.ts +0 -57
  50. package/components/buttons/action-button/ActionButton.vue +0 -50
  51. package/components/buttons/secondary-button/SecondaryButton.scss +0 -48
  52. package/components/buttons/secondary-button/SecondaryButton.ts +0 -28
  53. package/components/buttons/secondary-button/SecondaryButton.vue +0 -27
  54. package/components/confirm/Confirm.scss +0 -44
  55. package/components/confirm/Confirm.ts +0 -82
  56. package/components/confirm/Confirm.vue +0 -64
  57. package/components/give-kudos-form/GiveKudosForm.scss +0 -114
  58. package/components/give-kudos-form/GiveKudosForm.ts +0 -159
  59. package/components/give-kudos-form/GiveKudosForm.vue +0 -131
  60. package/components/give-kudos-form/mixins/UserSelectMixin.ts +0 -57
  61. package/components/give-kudos-form/models/KudosShareModel.ts +0 -6
  62. package/components/give-kudos-form/models/UserListModel.ts +0 -5
  63. package/components/give-kudos-form/validators/InEnglishValidatorRegex.ts +0 -17
  64. package/components/give-kudos-form/validators/KudosBalance.ts +0 -10
  65. package/components/modal/Modal.scss +0 -53
  66. package/components/modal/Modal.ts +0 -70
  67. package/components/modal/Modal.vue +0 -28
  68. package/components/notifications-sidebar/NotificationsSidebar.scss +0 -665
  69. package/components/notifications-sidebar/NotificationsSidebar.ts +0 -203
  70. package/components/notifications-sidebar/NotificationsSidebar.vue +0 -171
  71. package/components/notifications-sidebar/models/BroadcastNotificationPayload.ts +0 -8
  72. package/components/notifications-sidebar/models/TotalCounter.ts +0 -50
  73. package/components/notifications-sidebar/notification/Notification.ts +0 -17
  74. package/components/notifications-sidebar/notification/Notification.vue +0 -87
  75. package/components/play-pause/PlayPause.scss +0 -33
  76. package/components/play-pause/PlayPause.ts +0 -156
  77. package/components/play-pause/PlayPause.vue +0 -36
  78. package/components/play-pause/PlayPauseStatus.ts +0 -4
  79. package/components/play-pause/helpers/LatestTrackedTimeDurationHelper.ts +0 -55
  80. package/components/play-pause/helpers/PauseHelper.ts +0 -55
  81. package/components/play-pause/helpers/TrackedTimeHelper.ts +0 -80
  82. package/components/preloader/Preloader.vue +0 -34
  83. package/components/request-loader/RequestLoader.scss +0 -20
  84. package/components/request-loader/RequestLoader.ts +0 -80
  85. package/components/request-loader/RequestLoader.vue +0 -15
  86. package/components/sub-menu/SubMenu.scss +0 -33
  87. package/components/sub-menu/SubMenu.ts +0 -38
  88. package/components/sub-menu/SubMenu.vue +0 -21
  89. package/components/time-ago/TimeAgo.ts +0 -34
  90. package/components/time-ago/TimeAgo.vue +0 -9
  91. package/components/user-picture/UserPicture.scss +0 -62
  92. package/components/user-picture/UserPicture.ts +0 -105
  93. package/components/user-picture/UserPicture.vue +0 -23
  94. package/components/v-select-intems/VSelectIntems.ts +0 -112
  95. package/components/v-select-intems/VSelectIntems.vue +0 -68
  96. package/components/v-select-intems/open-indicator/OpenIndicator.vue +0 -3
  97. package/dist/css/1.css +0 -85
  98. package/dist/css/2.css +0 -34
  99. package/dist/css/3.css +0 -34
  100. package/dist/css/4.css +0 -34
  101. package/dist/css/5.css +0 -34
  102. package/dist/html/app.html +0 -19
  103. package/dist/html/styles.html +0 -1
  104. package/dist/js/2.js +0 -217
  105. package/dist/js/3.js +0 -181
  106. package/dist/js/4.js +0 -181
  107. package/dist/js/5.js +0 -181
  108. package/helpers/GeneralHelper.ts +0 -61
  109. package/helpers/PublisherSubscriber.ts +0 -34
  110. package/helpers/QueryFilter.ts +0 -204
  111. package/helpers/TimeHelper.ts +0 -54
  112. package/helpers/Validations.ts +0 -7
  113. package/helpers/model/ModelHelper.ts +0 -155
  114. package/helpers/model/decorators/AsCollection.ts +0 -26
  115. package/helpers/model/decorators/AsModel.ts +0 -25
  116. package/helpers/model/decorators/DateTime.ts +0 -26
  117. package/helpers/model/decorators/TimeDuration.ts +0 -33
  118. package/helpers/moment/Duration.ts +0 -64
  119. package/helpers/moment/Moment.ts +0 -17
  120. package/helpers/moment/index.d.ts +0 -20
  121. package/helpers/response/AxiosProxy.ts +0 -72
  122. package/helpers/response/ErrorsToToastHelper.ts +0 -42
  123. package/helpers/response/ResponseCode.ts +0 -16
  124. package/helpers/response/ResponseHelper.ts +0 -42
  125. package/helpers/response/ResponseInterface.ts +0 -34
  126. package/helpers/response/ResponseState.ts +0 -6
  127. package/jsconfig.json +0 -19
  128. package/mixins/IntemsMath.ts +0 -29
  129. package/mixins/notifications/ActionProcessing.ts +0 -134
  130. package/mixins/notifications/confirms/AssetRejectionConfirm.vue +0 -59
  131. package/mixins/notifications/confirms/SickLeaveRejectionConfirm.vue +0 -31
  132. package/mixins/notifications/confirms/UnpaidLeaveRejectionConfirm.vue +0 -31
  133. package/mixins/notifications/confirms/VacationRejectionConfirm.vue +0 -31
  134. package/models/AssetModel.ts +0 -80
  135. package/models/AssetRequestModel.ts +0 -25
  136. package/models/ConfigModel.ts +0 -20
  137. package/models/EmployeeStartEndDateModel.ts +0 -16
  138. package/models/EmploymentTypeModel.ts +0 -95
  139. package/models/LogoutModel.ts +0 -3
  140. package/models/Model.ts +0 -12
  141. package/models/ModuleOptions.ts +0 -24
  142. package/models/PublicInfoModel.ts +0 -38
  143. package/models/PublicLocationModel.ts +0 -36
  144. package/models/StatusModel.ts +0 -8
  145. package/models/TrackedTimeModel.ts +0 -32
  146. package/models/location/PublicLocationModel.ts +0 -36
  147. package/models/timezones/LocalTimezoneHistoryModel.ts +0 -8
  148. package/models/timezones/TimezoneModel.ts +0 -9
  149. package/models/user/ExtendedInfoModel.ts +0 -37
  150. package/models/user/NotificationActionModel.ts +0 -53
  151. package/models/user/NotificationModel.ts +0 -84
  152. package/models/user/PublicInfoModel.ts +0 -38
  153. package/models/user/WelcomeProgram.ts +0 -4
  154. package/repositories/BaseRepository.ts +0 -42
  155. package/repositories/BaseUrl.ts +0 -107
  156. package/repositories/Repository.ts +0 -291
  157. package/repositories/ResourceRepository.ts +0 -99
  158. package/repositories/TrackedTimeRepository.ts +0 -43
  159. package/repositories/UserRepository.ts +0 -75
  160. package/repositories/subscribers/CreateSubscribers.ts +0 -28
  161. package/repositories/subscribers/DefaultSubscribers.ts +0 -82
  162. package/repositories/subscribers/DeleteSubscribers.ts +0 -28
  163. package/repositories/subscribers/DownloadSubscribers.ts +0 -28
  164. package/repositories/subscribers/Subscribers.ts +0 -13
  165. package/repositories/subscribers/UpdateSubscribers.ts +0 -32
  166. package/scss/components/_global.scss +0 -66
  167. package/scss/components/_mixins.scss +0 -31
  168. package/scss/components/_tooltip.scss +0 -45
  169. package/scss/components/_utils.scss +0 -26
  170. package/scss/components/_variables.scss +0 -103
  171. package/scss/main.scss +0 -7
  172. package/shims-vue.d.ts +0 -9
  173. package/tsconfig.json +0 -31
  174. package/webpack.config.js +0 -126
  175. package/wrapper.ts +0 -51
@@ -1,107 +0,0 @@
1
- export enum BaseUrl {
2
- Default = "",
3
- LoggedInUser = "/api/users/me",
4
- ProgressBar = "/api/users/me/progress-bar",
5
- LogOut = "/logout",
6
- SessionMessages = "/api/session-messages",
7
- Config = "/api/config",
8
- DescribedTime = "/api/described-times",
9
- TrackedTimes = "/api/tracked-times",
10
- Holidays = "/api/holidays",
11
- News = "/api/news",
12
- Tags = "/api/tags",
13
- Roles = "/api/roles",
14
- ScheduledMaintenance = "/api/scheduled-maintenance",
15
- StatsFilter = "api/stats/filter",
16
- MinReportDate = "api/stats/min-date",
17
- AnniversaryUsers = "/api/anniversary-users",
18
- RequestedDays = "/api/requested-days",
19
- WallOfGlory = "/api/wall-of-glory",
20
- WorkingNorm = "api/users/working-norm",
21
- BirthdayUsers = "/api/birthday-users",
22
- SendRecommendation = "/api/send-recommendation",
23
- Stats = "/api/stats",
24
- TalentPlanner = "/api/talent-planner",
25
- Projects = "api/projects",
26
- ProjectsTree = "api/projects-tree",
27
- ImportEffort = "api/users/import-effort",
28
- JobProfileGroup = "/api/users/job-profiles",
29
- WelcomeProgram = "/api/welcome-program",
30
- Rotation = "api/rotation",
31
- Cities = "api/cities",
32
- ReleaseNotes = "api/release-notes",
33
- ZabbixMap = "api/network-map",
34
- Sows = "/api/sows",
35
- Clients = "/api/clients",
36
- Engagements = "/api/engagements",
37
- OrganisationStructure = "/api/organisation-structure",
38
- NewCollegues = "/api/new-collegues",
39
- OvertimeRequests = "/api/overtime-requests",
40
- CompensationPackage = "/api/users/me/compensation-package",
41
- BabyBorn = "/api/baby-born",
42
- WeddingUser = "/api/wedding-user",
43
- CostCenters = "/api/cost-centers",
44
- Users = "/api/users",
45
- KudosAndSmartsStatistic = "/api/kudos-and-smarts/statistic",
46
- MyReferrals = "/api/referrals/my-referrals",
47
- MyReferralLogs = "/api/referrals/my-referral-logs",
48
- TopRecommenders = "/api/referrals/top-recommenders",
49
- LastActions = "/api/kudos-and-smarts/last-actions",
50
- GiveKudos = "/api/kudos-and-smarts/give-kudos",
51
- CostCenterCategory = "/api/cost-center-category",
52
- Department = "/api/departments",
53
- GiveKudosUsersList = "/api/kudos-and-smarts/users-list",
54
- Tasks = "/api/tasks",
55
- Folder = "api/tasks/folder",
56
- DonationCampaign = "/api/donation-campaign",
57
- Donation = "/api/donation-transaction",
58
- Upload = "/api/upload",
59
- DonationAttachment = "/api/donation-attachment",
60
- PipeDriveOption = "/api/pipedrive-option",
61
- Banner = "/api/banners",
62
- Assets = "/api/users/assets",
63
- PositionSubscription = "/api/position-subscription",
64
- Currency = "/api/currency",
65
- Rate = "/api/rates",
66
- Timesheet = "/api/timesheets",
67
- TimesheetDiscount = "/api/timesheets/discount",
68
- TimesheetReimbursed = "/api/timesheets/reimbursed",
69
- JobProfile = "/api/job-profile",
70
- EmployeeReport = "/api/report/employees",
71
- Locations = "/api/location",
72
- MyProfile = "/api/users/my-profile",
73
- Employees = "/api/employees",
74
- EmploymentTypes = "/api/employment-types",
75
- EmergencyContacts = "/api/emergency-contact",
76
- LeavesAndAbsences = "/api/leaves-and-absences",
77
- Delivery = "/api/delivery-address",
78
- Trainings = "/api/events",
79
- Skills = "/api/skills",
80
- JiraSatisfactionSurvey = "/api/enps-survey",
81
- IntelliStoreCategory = "/api/smart-catalog/category",
82
- IntelliStoreType = "/api/smart-catalog/type",
83
- IntelliStoreAttribute = "/api/smart-catalog/attribute",
84
- IntelliStoreProduct = "/api/smart-catalog/product",
85
- IntelliStoreOrder = "/api/smart-catalog/order",
86
- IntelliStoreStat = "/api/smart-catalog/statistic",
87
- IntelliStoreClient = "/api/smart-catalog/shop",
88
- IntelliStoreWishlist = "/api/smart-catalog/wish-list",
89
- Dictionary = "/api/dictionary",
90
- Offices = "/api/offices",
91
- Calendars = "/api/calendars",
92
- ImprovementsHub = "/api/improvements-hub",
93
- ViewLogs = "/api/logs",
94
- TotalRewardsPortal = "/api/total-rewards-portal",
95
- CompensationPackages = "/api/compensation-package",
96
- Timezones = "/api/available-timezones",
97
- AccessCards = "/api/access_card",
98
- ValidationCompensation = "/api/validation-compensations",
99
- VacationAndSickBalance = "/api/vacation-and-sick-balance",
100
- TechnicalWorks = "/api/technical-work",
101
- PDUSystem = "/api/pdu-system",
102
- Logger = "/api/logger",
103
- BenefitsPackages = "/api/benefits-package",
104
- OnCallRate = "/api/on-call-rate",
105
- OnCallSupport = "/api/on-call-support",
106
- OnCallSupportEmployee = "/api/on-call-support-employee",
107
- }
@@ -1,291 +0,0 @@
1
- import { AxiosRequestConfig, AxiosResponse } from "axios";
2
- import * as moment from "moment";
3
- import { Collection } from "collect.js";
4
- import DefaultSubscribers from "./subscribers/DefaultSubscribers";
5
- import { BaseUrl } from "./BaseUrl";
6
- import AxiosProxy from "../helpers/response/AxiosProxy";
7
- import * as Response from "../helpers/response/ResponseInterface";
8
- import * as ModelHelper from "../helpers/model/ModelHelper";
9
- import { ResponseCode } from "../helpers/response/ResponseCode";
10
- import { Meta } from "../helpers/response/ResponseInterface";
11
- import NotificationModel from "../models/user/NotificationModel";
12
- import Model from "../models/Model";
13
- import ResponseHelper, {
14
- DefaultContext,
15
- } from "../helpers/response/ResponseHelper";
16
-
17
- export type PaginatedResponse = {
18
- collection: Collection<Model>;
19
- meta: Meta;
20
- };
21
- export default abstract class Repository {
22
- protected baseUrl: BaseUrl;
23
- protected responseHelper: ResponseHelper;
24
- protected axiosProxy: AxiosProxy;
25
-
26
- protected constructor(baseUrl: BaseUrl) {
27
- this.baseUrl = baseUrl;
28
- this.responseHelper = new ResponseHelper();
29
- this.responseHelper.applySubscribers(
30
- new DefaultSubscribers(),
31
- DefaultContext
32
- );
33
- this.axiosProxy = new AxiosProxy(this.responseHelper);
34
- }
35
-
36
- getResponseHelper() {
37
- return this.responseHelper;
38
- }
39
-
40
- protected async getData<TData>(
41
- resource = "",
42
- parameters?,
43
- context: string = DefaultContext
44
- ) {
45
- const response = await this.axiosProxy.get<TData>(
46
- this.getUrl(resource),
47
- this.getConfig({ params: parameters }),
48
- context
49
- );
50
-
51
- return response.data;
52
- }
53
-
54
- protected async getResource<TData>(
55
- model,
56
- resource = "",
57
- parameters?,
58
- context: string = DefaultContext
59
- ) {
60
- const response = await this.axiosProxy.get<Response.Read<TData>>(
61
- this.getUrl(resource),
62
- this.getConfig({ params: parameters }),
63
- context
64
- );
65
-
66
- if (response.data.data === undefined) {
67
- console.error(
68
- 'Key "data" does not exist in response from API',
69
- response.data
70
- );
71
- }
72
-
73
- return response.status < ResponseCode.BadRequest
74
- ? this.map(model, response.data.data)
75
- : null;
76
- }
77
-
78
- protected async getPaginatedResource<TData>(
79
- model: typeof Model,
80
- resource = "",
81
- parameters?: Record<string, unknown>,
82
- context: string = DefaultContext
83
- ): Promise<PaginatedResponse> {
84
- const response = await this.axiosProxy.get<{
85
- data: { data: Record<string, unknown> };
86
- meta: Meta;
87
- }>(this.getUrl(resource), this.getConfig({ params: parameters }), context);
88
- if (response.status < ResponseCode.BadRequest) {
89
- return {
90
- collection: this.map(
91
- model !== undefined ? model : NotificationModel,
92
- response.data.data
93
- ),
94
- meta: response.data.meta,
95
- };
96
- }
97
-
98
- return null;
99
- }
100
-
101
- protected async getFile<TData>(
102
- model,
103
- resource = "",
104
- parameters?,
105
- context: string = DefaultContext
106
- ) {
107
- const response = await this.axiosProxy.get<Response.Read<TData>>(
108
- this.getUrl(resource),
109
- this.getConfig({ params: parameters, responseType: "blob" }),
110
- context
111
- );
112
- return response.status < ResponseCode.BadRequest
113
- ? this.map(model, response.data)
114
- : null;
115
- }
116
-
117
- protected async postData<TData>(
118
- resource = "",
119
- data?,
120
- parameters?,
121
- context: string = DefaultContext
122
- ) {
123
- const response = await this.axiosProxy.post<TData>(
124
- this.getUrl(resource),
125
- data,
126
- this.getConfig({ params: parameters }),
127
- context
128
- );
129
- return response.data;
130
- }
131
-
132
- protected async post<TData>(
133
- resource = "",
134
- data?,
135
- parameters?,
136
- context: string = DefaultContext
137
- ): Promise<AxiosResponse<TData>> {
138
- return this.axiosProxy.post<TData>(
139
- this.getUrl(resource),
140
- data,
141
- this.getConfig({ params: parameters }),
142
- context
143
- );
144
- }
145
-
146
- protected async putResource<TData>(
147
- model,
148
- resource = "",
149
- data?,
150
- context: string = DefaultContext
151
- ) {
152
- const response = await this.axiosProxy.put<Response.Read<TData>>(
153
- this.getUrl(resource),
154
- data,
155
- this.getConfig({ params: {} }),
156
- context
157
- );
158
-
159
- return response.status < ResponseCode.BadRequest
160
- ? this.map(model, response.data.data)
161
- : null;
162
- }
163
-
164
- protected async postResource<TData>(
165
- model,
166
- resource = "",
167
- data?,
168
- context: string = DefaultContext
169
- ) {
170
- const response = await this.axiosProxy.post<Response.Read<TData>>(
171
- this.getUrl(resource),
172
- data,
173
- this.getConfig({ params: {} }),
174
- context
175
- );
176
-
177
- return response.status < ResponseCode.BadRequest
178
- ? this.map(model, response.data.data)
179
- : null;
180
- }
181
-
182
- protected async putData<TData>(
183
- resource = "",
184
- data?,
185
- parameters?,
186
- context: string = DefaultContext
187
- ) {
188
- const response = await this.axiosProxy.put<TData>(
189
- this.getUrl(resource),
190
- data,
191
- this.getConfig({ params: parameters }),
192
- context
193
- );
194
-
195
- return response.data;
196
- }
197
-
198
- protected async put<TData>(
199
- resource = "",
200
- data?,
201
- parameters?,
202
- context: string = DefaultContext
203
- ): Promise<AxiosResponse<TData>> {
204
- return this.axiosProxy.put<TData>(
205
- this.getUrl(resource),
206
- data,
207
- this.getConfig({ params: parameters }),
208
- context
209
- );
210
- }
211
-
212
- protected async deleteData(
213
- resource = "",
214
- parameters?: unknown,
215
- context: string = DefaultContext
216
- ) {
217
- const response = await this.axiosProxy.delete(
218
- this.getUrl(resource),
219
- this.getConfig({ params: parameters }),
220
- context
221
- );
222
-
223
- return response.data;
224
- }
225
-
226
- protected async deleteResource(
227
- resource = "",
228
- parameters?: unknown,
229
- context: string = DefaultContext
230
- ): Promise<AxiosResponse> {
231
- return this.axiosProxy.delete(
232
- this.getUrl(resource),
233
- this.getConfig({ params: parameters }),
234
- context
235
- );
236
- }
237
-
238
- protected async patch(resource = "", context: string = DefaultContext) {
239
- return this.axiosProxy.patch(
240
- this.getUrl(resource),
241
- this.getConfig(),
242
- context
243
- );
244
- }
245
-
246
- protected async patchData<TData>(
247
- resource = "",
248
- data?,
249
- parameters?,
250
- context: string = DefaultContext
251
- ) {
252
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
253
- const response = await this.axiosProxy.patch<TData>(
254
- this.getUrl(resource),
255
- { ...data, ...this.getConfig({ params: parameters }) },
256
- context
257
- );
258
- return response.data;
259
- }
260
-
261
- protected map(model, resource) {
262
- // Todo: model must be specified each time, remove this!!!
263
- if (!model) {
264
- return resource;
265
- }
266
- return ModelHelper.map(model, resource);
267
- }
268
- protected getUrl(resource: string): string {
269
- if (this.baseUrl === null) {
270
- throw new Error("baseUrl is not specified");
271
- }
272
- return this.baseUrl + resource;
273
- }
274
-
275
- protected getQueryString(params): string {
276
- return Object.keys(params)
277
- .map((key) => `${key}=${params[key]}`)
278
- .join("&");
279
- }
280
-
281
- protected getConfig(
282
- parameters?: Record<string, unknown>
283
- ): AxiosRequestConfig {
284
- return {
285
- ...parameters,
286
- headers: {
287
- tz: moment.tz?.guess(),
288
- },
289
- };
290
- }
291
- }
@@ -1,99 +0,0 @@
1
- import { Collection } from "collect.js";
2
- import { ResponseCode } from "../helpers/response/ResponseCode";
3
- import { BaseUrl } from "./BaseUrl";
4
- import { Read } from "../helpers/response/ResponseInterface";
5
- import { DefaultContext } from "../helpers/response/ResponseHelper";
6
- import CreateSubscribers from "./subscribers/CreateSubscribers";
7
- import UpdateSubscribers from "./subscribers/UpdateSubscribers";
8
- import DeleteSubscribers from "./subscribers/DeleteSubscribers";
9
- import Repository from "./Repository";
10
- import DownloadSubscribers from "./subscribers/DownloadSubscribers";
11
-
12
- export type Config = {
13
- resourceName?: string;
14
- successMessage?: string;
15
- };
16
-
17
- export const CreateContext = "create";
18
- export const UpdateContext = "update";
19
- export const DeleteContext = "delete";
20
- export const DownloadContext = "download";
21
- export const RejectContext = "reject";
22
- export const ConfirmContext = "confirm";
23
- export const ApproveContext = "approve";
24
- export const HeadContext = "head";
25
-
26
- export default abstract class ResourceRepository<
27
- TModel extends new (...args: any) => any
28
- > extends Repository {
29
- protected model: TModel;
30
- protected config: Config;
31
-
32
- protected constructor(baseUrl: BaseUrl, model: TModel, config?: Config) {
33
- super(baseUrl);
34
- this.model = model;
35
- this.responseHelper.applySubscribers(
36
- new CreateSubscribers(config?.resourceName),
37
- CreateContext
38
- );
39
- this.responseHelper.applySubscribers(
40
- new UpdateSubscribers(config?.resourceName, config?.successMessage),
41
- UpdateContext
42
- );
43
- this.responseHelper.applySubscribers(
44
- new DeleteSubscribers(config?.resourceName),
45
- DeleteContext
46
- );
47
- this.responseHelper.applySubscribers(
48
- new DownloadSubscribers(config?.resourceName),
49
- DownloadContext
50
- );
51
- }
52
-
53
- async getById(
54
- id: number | string,
55
- context: string = DefaultContext
56
- ): Promise<TModel> {
57
- return await this.getResource(this.model, `/${id}`, {}, context);
58
- }
59
-
60
- async all(
61
- parameters?,
62
- context: string = DefaultContext
63
- ): Promise<Collection<TModel>> {
64
- return await this.getResource(this.model, "", parameters, context);
65
- }
66
-
67
- async create(model: TModel) {
68
- const response = await this.axiosProxy.post<Read<TModel>>(
69
- this.getUrl(""),
70
- model,
71
- this.getConfig(),
72
- CreateContext
73
- );
74
- return response.status === ResponseCode.Created
75
- ? this.map(this.model, response.data.data)
76
- : null;
77
- }
78
-
79
- async update(id: number | string, model: InstanceType<TModel>) {
80
- const response = await this.axiosProxy.put<Read<TModel>>(
81
- this.getUrl(`/${id}`),
82
- model,
83
- this.getConfig(),
84
- UpdateContext
85
- );
86
- return response.status === ResponseCode.Ok
87
- ? this.map(this.model, response.data.data)
88
- : null;
89
- }
90
-
91
- async delete(id: number | string) {
92
- const response = await this.axiosProxy.delete(
93
- this.getUrl(`/${id}`),
94
- this.getConfig(),
95
- DeleteContext
96
- );
97
- return response.status === ResponseCode.NoContent;
98
- }
99
- }
@@ -1,43 +0,0 @@
1
- import TrackedTimeModel from "../models/TrackedTimeModel";
2
- import * as Response from "../helpers/response/ResponseInterface";
3
- import { ResponseCode } from "../helpers/response/ResponseCode";
4
- import ResourceRepository from "./ResourceRepository";
5
- import { BaseUrl } from "./BaseUrl";
6
-
7
- export const PlayContext = "play";
8
- export const PauseContext = "pause";
9
-
10
- export default class TrackedTimeRepository extends ResourceRepository<
11
- typeof TrackedTimeModel
12
- > {
13
- constructor() {
14
- super(BaseUrl.TrackedTimes, TrackedTimeModel, {
15
- resourceName: "Worked Time",
16
- });
17
- }
18
-
19
- async latest(): Promise<TrackedTimeModel> {
20
- return await this.getResource(this.model, "/latest");
21
- }
22
-
23
- async play() {
24
- const response = await this.axiosProxy.post<
25
- Response.Read<TrackedTimeModel>
26
- >(this.baseUrl, {}, this.getConfig(), PlayContext);
27
- return response.status === ResponseCode.Created
28
- ? this.map(this.model, response.data.data)
29
- : null;
30
- }
31
-
32
- async pause() {
33
- const response = await this.axiosProxy.put<Response.Read<string>>(
34
- this.baseUrl,
35
- {},
36
- this.getConfig(),
37
- PauseContext
38
- );
39
- return response.status === ResponseCode.Ok
40
- ? this.map(this.model, response.data.data)
41
- : null;
42
- }
43
- }
@@ -1,75 +0,0 @@
1
- import { AxiosResponse } from "axios";
2
- import { Collection } from "collect.js";
3
- import { BaseUrl } from "./BaseUrl";
4
- import BaseRepository from "./BaseRepository";
5
- import ExtendedInfoModel from "../models/user/ExtendedInfoModel";
6
- import NotificationModel from "../models/user/NotificationModel";
7
- import QueryFilter from "../helpers/QueryFilter";
8
- import { DefaultContext } from "../helpers/response/ResponseHelper";
9
- import { UpdateContext } from "./ResourceRepository";
10
- import { NotificationTotal } from "../components/notifications-sidebar/models/TotalCounter";
11
- import { ResponseCode } from "../helpers/response/ResponseCode";
12
- import { Meta } from "../helpers/response/ResponseInterface";
13
-
14
- // Todo: maybe rename or what, because this repository is only to get logged in user data
15
- export default class UserRepository extends BaseRepository<
16
- typeof ExtendedInfoModel
17
- > {
18
- constructor() {
19
- super(BaseUrl.LoggedInUser, ExtendedInfoModel);
20
- }
21
-
22
- async notifications(filter: QueryFilter, model = undefined) {
23
- const response = await this.axiosProxy.get<{
24
- data: { data: Record<string, unknown> };
25
- total_unread: NotificationTotal;
26
- total: number;
27
- meta: Meta;
28
- }>(
29
- this.getUrl(`/notifications`),
30
- { params: filter.toObject() },
31
- DefaultContext
32
- );
33
- if (response.status < ResponseCode.BadRequest) {
34
- return {
35
- collection: this.map(
36
- model !== undefined ? model : NotificationModel,
37
- response.data.data
38
- ),
39
- total: response.data.total_unread,
40
- meta: response.data.meta,
41
- };
42
- }
43
-
44
- return null;
45
- }
46
-
47
- async readNotifications(
48
- notifications?: Collection<NotificationModel>
49
- ): Promise<AxiosResponse> {
50
- let data = {};
51
- if (notifications) {
52
- data = { notifications: notifications.pluck("id").all() };
53
- }
54
- return this.putData(`/notifications/read-all`, data, {}, UpdateContext);
55
- }
56
-
57
- async dismissNotifications(
58
- notification?: NotificationModel
59
- ): Promise<AxiosResponse> {
60
- return this.patch(
61
- `/notifications/dismiss-all${notification ? `/${notification.id}` : ""}`,
62
- UpdateContext
63
- );
64
- }
65
-
66
- async processNotifications(
67
- notification?: NotificationModel
68
- ): Promise<AxiosResponse> {
69
- return this.patch(
70
- `/notifications/process/${notification.id}`,
71
- UpdateContext
72
- );
73
- }
74
-
75
- }
@@ -1,28 +0,0 @@
1
- import { AxiosResponse } from "axios";
2
- import { ResponseState } from "../../helpers/response/ResponseState";
3
- import { ResponseCode } from "../../helpers/response/ResponseCode";
4
- import { Subscribers, SubscribersEvents } from "./Subscribers";
5
- import { myOptions } from "../../wrapper";
6
-
7
- export default class CreateSubscribers implements Subscribers {
8
- private readonly resourceName: string;
9
- constructor(resourceName = "Item") {
10
- this.resourceName = resourceName;
11
- }
12
-
13
- generate(): SubscribersEvents {
14
- return {
15
- [ResponseState.Resolved]: (result: AxiosResponse) => {
16
- if (result.status === ResponseCode.Created) {
17
- myOptions.storeAdapter.Toasts.mutations.addMessage(
18
- `${this.resourceName} was successfully created`
19
- );
20
- } else if (result.status !== ResponseCode.Ok) {
21
- myOptions.storeAdapter.Toasts.mutations.addError(
22
- `Unable to create ${this.resourceName}`
23
- );
24
- }
25
- },
26
- };
27
- }
28
- }