@admin-layout/timetracker-module-server 1.0.3-alpha.7 → 1.0.3-alpha.72
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/containers/containers.d.ts +3 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +597 -151
- package/lib/index.js.map +1 -1
- package/lib/interfaces/timerecord-repository.d.ts +5 -5
- package/lib/interfaces/timerecord-service.d.ts +3 -3
- package/lib/interfaces/timesheet-repository.d.ts +1 -0
- package/lib/interfaces/timesheet-service.d.ts +1 -0
- package/lib/plugins/index.d.ts +2 -0
- package/lib/plugins/timerecord-moleculer-service.d.ts +8 -0
- package/lib/plugins/timesheet-moleculer-service.d.ts +9 -0
- package/lib/preferences/permissions/timing-roles-permission-overwrite.d.ts +0 -1
- package/lib/services/index.d.ts +2 -0
- package/lib/services/timerecord-proxy-service.d.ts +20 -0
- package/lib/services/timerecord-service.d.ts +2 -4
- package/lib/services/timesheet-proxy-service.d.ts +19 -0
- package/lib/services/timesheet-service.d.ts +4 -2
- package/lib/store/models/timerecords-model.d.ts +8 -0
- package/lib/store/models/timesheets-model.d.ts +8 -0
- package/lib/store/repository/timerecord-repository.d.ts +8 -8
- package/lib/store/repository/timesheet-repository.d.ts +3 -2
- package/package.json +4 -6
package/lib/index.js
CHANGED
@@ -126,7 +126,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
126
126
|
o[k2] = m[k];
|
127
127
|
}));
|
128
128
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
129
|
-
for (var p in m) if (p !== "default" && !
|
129
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
130
130
|
};
|
131
131
|
Object.defineProperty(exports, "__esModule", { value: true });
|
132
132
|
__exportStar(__webpack_require__(/*! ./config */ "./src/config/config.ts"), exports);
|
@@ -199,7 +199,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
199
199
|
o[k2] = m[k];
|
200
200
|
}));
|
201
201
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
202
|
-
for (var p in m) if (p !== "default" && !
|
202
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
203
203
|
};
|
204
204
|
Object.defineProperty(exports, "__esModule", { value: true });
|
205
205
|
__exportStar(__webpack_require__(/*! ./constants */ "./src/constants/constants.ts"), exports);
|
@@ -217,20 +217,32 @@ __exportStar(__webpack_require__(/*! ./constants */ "./src/constants/constants.t
|
|
217
217
|
"use strict";
|
218
218
|
|
219
219
|
Object.defineProperty(exports, "__esModule", { value: true });
|
220
|
-
exports.timeTrackerModule = void 0;
|
220
|
+
exports.timeTrackerProxyModule = exports.timeTrackerModule = exports.timeTrackerMailModule = exports.timeTrackerStoreModule = void 0;
|
221
221
|
const inversify_1 = __webpack_require__(/*! inversify */ "inversify");
|
222
222
|
const constants_1 = __webpack_require__(/*! ../constants */ "./src/constants/index.ts");
|
223
223
|
const services_1 = __webpack_require__(/*! ../services */ "./src/services/index.ts");
|
224
224
|
const repository_1 = __webpack_require__(/*! ../store/repository */ "./src/store/repository/index.ts");
|
225
225
|
const migration_1 = __webpack_require__(/*! ../migration */ "./src/migration/index.ts");
|
226
|
-
|
227
|
-
bind(constants_1.TYPES.ITimeRecordRepository).to(repository_1.TimeRecordRepository).inSingletonScope()
|
228
|
-
bind(constants_1.TYPES.ITimesheetRepository).to(repository_1.TimesheetRepository).inSingletonScope()
|
229
|
-
|
230
|
-
|
226
|
+
const timeTrackerStoreModule = (setting) => new inversify_1.ContainerModule((bind) => {
|
227
|
+
bind(constants_1.TYPES.ITimeRecordRepository).to(repository_1.TimeRecordRepository).inSingletonScope();
|
228
|
+
bind(constants_1.TYPES.ITimesheetRepository).to(repository_1.TimesheetRepository).inSingletonScope();
|
229
|
+
});
|
230
|
+
exports.timeTrackerStoreModule = timeTrackerStoreModule;
|
231
|
+
const timeTrackerMailModule = (setting) => new inversify_1.ContainerModule((bind) => {
|
231
232
|
bind('MongodbMigration').to(migration_1.TimesheetApprovalMailTemplate).whenTargetNamed(migration_1.TimesheetApprovalMailTemplate.name);
|
232
233
|
bind('MongodbMigration').to(migration_1.TimesheetSubmitMailTemplate).whenTargetNamed(migration_1.TimesheetSubmitMailTemplate.name);
|
233
234
|
});
|
235
|
+
exports.timeTrackerMailModule = timeTrackerMailModule;
|
236
|
+
const timeTrackerModule = (setting) => new inversify_1.ContainerModule((bind) => {
|
237
|
+
bind(constants_1.TYPES.ITimeRecordService).to(services_1.TimeRecordService).inSingletonScope();
|
238
|
+
bind(constants_1.TYPES.ITimesheetService).to(services_1.TimesheetService).inSingletonScope();
|
239
|
+
});
|
240
|
+
exports.timeTrackerModule = timeTrackerModule;
|
241
|
+
const timeTrackerProxyModule = (setting) => new inversify_1.ContainerModule((bind) => {
|
242
|
+
bind(constants_1.TYPES.ITimeRecordService).to(services_1.TimeRecordProxyService).inSingletonScope();
|
243
|
+
bind(constants_1.TYPES.ITimesheetService).to(services_1.TimesheetProxyService).inSingletonScope();
|
244
|
+
});
|
245
|
+
exports.timeTrackerProxyModule = timeTrackerProxyModule;
|
234
246
|
|
235
247
|
|
236
248
|
/***/ }),
|
@@ -252,7 +264,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
252
264
|
o[k2] = m[k];
|
253
265
|
}));
|
254
266
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
255
|
-
for (var p in m) if (p !== "default" && !
|
267
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
256
268
|
};
|
257
269
|
Object.defineProperty(exports, "__esModule", { value: true });
|
258
270
|
__exportStar(__webpack_require__(/*! ./containers */ "./src/containers/containers.ts"), exports);
|
@@ -277,7 +289,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
277
289
|
o[k2] = m[k];
|
278
290
|
}));
|
279
291
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
280
|
-
for (var p in m) if (p !== "default" && !
|
292
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
281
293
|
};
|
282
294
|
Object.defineProperty(exports, "__esModule", { value: true });
|
283
295
|
const server_core_1 = __webpack_require__(/*! @common-stack/server-core */ "@common-stack/server-core");
|
@@ -285,6 +297,7 @@ const module_1 = __webpack_require__(/*! ./module */ "./src/module.ts");
|
|
285
297
|
__exportStar(__webpack_require__(/*! ./constants */ "./src/constants/index.ts"), exports);
|
286
298
|
__exportStar(__webpack_require__(/*! ./store/repository */ "./src/store/repository/index.ts"), exports);
|
287
299
|
__exportStar(__webpack_require__(/*! ./store/models/timetracker-model */ "./src/store/models/timetracker-model.ts"), exports);
|
300
|
+
__exportStar(__webpack_require__(/*! ./containers */ "./src/containers/index.ts"), exports);
|
288
301
|
exports.default = new server_core_1.Feature(module_1.default);
|
289
302
|
|
290
303
|
|
@@ -307,7 +320,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
307
320
|
o[k2] = m[k];
|
308
321
|
}));
|
309
322
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
310
|
-
for (var p in m) if (p !== "default" && !
|
323
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
311
324
|
};
|
312
325
|
Object.defineProperty(exports, "__esModule", { value: true });
|
313
326
|
__exportStar(__webpack_require__(/*! ./service-initialization */ "./src/initialization/service-initialization.ts"), exports);
|
@@ -329,7 +342,7 @@ exports.mainLoadConfigurationPre = void 0;
|
|
329
342
|
const core_1 = __webpack_require__(/*! @workbench-stack/core */ "@workbench-stack/core");
|
330
343
|
const core_2 = __webpack_require__(/*! @common-stack/core */ "@common-stack/core");
|
331
344
|
const preferences_1 = __webpack_require__(/*! ../preferences */ "./src/preferences/index.ts");
|
332
|
-
|
345
|
+
const mainLoadConfigurationPre = async (_, container) => {
|
333
346
|
const logger = container.get(core_2.CommonType.LOGGER);
|
334
347
|
logger.info('PRESTART START: -- load TimeTrackerContribution to registry');
|
335
348
|
const registry = container.get(core_1.TYPES.IRegistry);
|
@@ -337,6 +350,7 @@ exports.mainLoadConfigurationPre = async (_, container) => {
|
|
337
350
|
configurationRegistry.registerConfiguration(preferences_1.TimeTrackerContribution);
|
338
351
|
logger.info('PRESTART ENDS: -- load TimeTrackerContribution to registry');
|
339
352
|
};
|
353
|
+
exports.mainLoadConfigurationPre = mainLoadConfigurationPre;
|
340
354
|
|
341
355
|
|
342
356
|
/***/ }),
|
@@ -371,7 +385,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
371
385
|
o[k2] = m[k];
|
372
386
|
}));
|
373
387
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
374
|
-
for (var p in m) if (p !== "default" && !
|
388
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
375
389
|
};
|
376
390
|
Object.defineProperty(exports, "__esModule", { value: true });
|
377
391
|
__exportStar(__webpack_require__(/*! ./mail-template */ "./src/migration/mail-template.ts"), exports);
|
@@ -507,6 +521,7 @@ const resolvers_1 = __webpack_require__(/*! ./resolvers */ "./src/resolvers/inde
|
|
507
521
|
const constants_1 = __webpack_require__(/*! ./constants */ "./src/constants/index.ts");
|
508
522
|
const initialization_1 = __webpack_require__(/*! ./initialization */ "./src/initialization/index.ts");
|
509
523
|
const preferences_1 = __webpack_require__(/*! ./preferences */ "./src/preferences/index.ts");
|
524
|
+
const plugins_1 = __webpack_require__(/*! ./plugins */ "./src/plugins/index.ts");
|
510
525
|
const createServiceFunc = (container) => ({
|
511
526
|
timeRecordService: container.get(constants_1.TYPES.ITimeRecordService),
|
512
527
|
timesheetService: container.get(constants_1.TYPES.ITimesheetService),
|
@@ -514,8 +529,10 @@ const createServiceFunc = (container) => ({
|
|
514
529
|
exports.default = new server_core_1.Feature({
|
515
530
|
schema: schema_1.schema,
|
516
531
|
createResolversFunc: resolvers_1.resolvers,
|
517
|
-
createContainerFunc: [containers_1.
|
532
|
+
createContainerFunc: [containers_1.timeTrackerProxyModule, containers_1.timeTrackerMailModule],
|
533
|
+
createHemeraContainerFunc: [containers_1.timeTrackerModule, containers_1.timeTrackerStoreModule],
|
518
534
|
createServiceFunc,
|
535
|
+
addBrokerClientServiceClass: [plugins_1.TimeRecordMoleculerService, plugins_1.TimesheetMoleculerService],
|
519
536
|
preStartFunc: [initialization_1.mainLoadConfigurationPre],
|
520
537
|
addPermissions: {
|
521
538
|
createPermissions: [preferences_1.TimeTrackerRolesContribution],
|
@@ -526,6 +543,206 @@ exports.default = new server_core_1.Feature({
|
|
526
543
|
});
|
527
544
|
|
528
545
|
|
546
|
+
/***/ }),
|
547
|
+
|
548
|
+
/***/ "./src/plugins/index.ts":
|
549
|
+
/*!******************************!*\
|
550
|
+
!*** ./src/plugins/index.ts ***!
|
551
|
+
\******************************/
|
552
|
+
/*! no static exports found */
|
553
|
+
/***/ (function(module, exports, __webpack_require__) {
|
554
|
+
|
555
|
+
"use strict";
|
556
|
+
|
557
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
558
|
+
if (k2 === undefined) k2 = k;
|
559
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
560
|
+
}) : (function(o, m, k, k2) {
|
561
|
+
if (k2 === undefined) k2 = k;
|
562
|
+
o[k2] = m[k];
|
563
|
+
}));
|
564
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
565
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
566
|
+
};
|
567
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
568
|
+
__exportStar(__webpack_require__(/*! ./timesheet-moleculer-service */ "./src/plugins/timesheet-moleculer-service.ts"), exports);
|
569
|
+
__exportStar(__webpack_require__(/*! ./timerecord-moleculer-service */ "./src/plugins/timerecord-moleculer-service.ts"), exports);
|
570
|
+
|
571
|
+
|
572
|
+
/***/ }),
|
573
|
+
|
574
|
+
/***/ "./src/plugins/timerecord-moleculer-service.ts":
|
575
|
+
/*!*****************************************************!*\
|
576
|
+
!*** ./src/plugins/timerecord-moleculer-service.ts ***!
|
577
|
+
\*****************************************************/
|
578
|
+
/*! no static exports found */
|
579
|
+
/***/ (function(module, exports, __webpack_require__) {
|
580
|
+
|
581
|
+
"use strict";
|
582
|
+
|
583
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
584
|
+
var t = {};
|
585
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
586
|
+
t[p] = s[p];
|
587
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
588
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
589
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
590
|
+
t[p[i]] = s[p[i]];
|
591
|
+
}
|
592
|
+
return t;
|
593
|
+
};
|
594
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
595
|
+
exports.TimeRecordMoleculerService = void 0;
|
596
|
+
const moleculer_1 = __webpack_require__(/*! moleculer */ "moleculer");
|
597
|
+
const constants_1 = __webpack_require__(/*! ../constants */ "./src/constants/index.ts");
|
598
|
+
class TimeRecordMoleculerService extends moleculer_1.Service {
|
599
|
+
constructor(broker, _a) {
|
600
|
+
var { container } = _a, settings = __rest(_a, ["container"]);
|
601
|
+
super(broker);
|
602
|
+
const topic = "TimeRecord" /* TimeRecord */;
|
603
|
+
this.timerecordService = container.get(constants_1.TYPES.ITimeRecordService);
|
604
|
+
this.parseServiceSchema({
|
605
|
+
name: topic,
|
606
|
+
actions: {
|
607
|
+
["getTimeRecords" /* getTimeRecords */]: {
|
608
|
+
handler: async (ctx) => {
|
609
|
+
return await this.timerecordService.getTimeRecords(ctx.params.orgId, ctx.params.userId);
|
610
|
+
}
|
611
|
+
},
|
612
|
+
["getDurationTimeRecords" /* getDurationTimeRecords */]: {
|
613
|
+
handler: async (ctx) => {
|
614
|
+
return await this.timerecordService.getDurationTimeRecords(ctx.params.orgId, ctx.params.startTime, ctx.params.endTime, ctx.params.userId);
|
615
|
+
}
|
616
|
+
},
|
617
|
+
["getPlayingTimeRecord" /* getPlayingTimeRecord */]: {
|
618
|
+
handler: async (ctx) => {
|
619
|
+
return await this.timerecordService.getPlayingTimeRecord(ctx.params.userId, ctx.params.orgId);
|
620
|
+
}
|
621
|
+
},
|
622
|
+
["createTimeRecord" /* createTimeRecord */]: {
|
623
|
+
handler: async (ctx) => {
|
624
|
+
return await this.timerecordService.createTimeRecord(ctx.params.userId, ctx.params.orgId, ctx.params.request);
|
625
|
+
}
|
626
|
+
},
|
627
|
+
["updateTimeRecord" /* updateTimeRecord */]: {
|
628
|
+
handler: async (ctx) => {
|
629
|
+
return await this.timerecordService.updateTimeRecord(ctx.params.userId, ctx.params.orgId, ctx.params.recordId, ctx.params.request);
|
630
|
+
}
|
631
|
+
},
|
632
|
+
["removeTimeRecord" /* removeTimeRecord */]: {
|
633
|
+
handler: async (ctx) => {
|
634
|
+
return await this.timerecordService.removeTimeRecord(ctx.params.userId, ctx.params.orgId, ctx.params.recordId);
|
635
|
+
}
|
636
|
+
},
|
637
|
+
["removeDurationTimeRecords" /* removeDurationTimeRecords */]: {
|
638
|
+
handler: async (ctx) => {
|
639
|
+
return await this.timerecordService.removeDurationTimeRecords(ctx.params.userId, ctx.params.orgId, ctx.params.startTime, ctx.params.endTime, ctx.params.projectId);
|
640
|
+
}
|
641
|
+
},
|
642
|
+
["approveTimeRecords" /* approveTimeRecords */]: {
|
643
|
+
handler: async (ctx) => {
|
644
|
+
return await this.timerecordService.approveTimeRecords(ctx.params.orgId, ctx.params.sheetId, ctx.params.timeRecordsId);
|
645
|
+
}
|
646
|
+
},
|
647
|
+
["disapproveTimeRecords" /* disapproveTimeRecords */]: {
|
648
|
+
handler: async (ctx) => {
|
649
|
+
return await this.timerecordService.disapproveTimeRecords(ctx.params.orgId, ctx.params.sheetId);
|
650
|
+
}
|
651
|
+
},
|
652
|
+
},
|
653
|
+
});
|
654
|
+
}
|
655
|
+
}
|
656
|
+
exports.TimeRecordMoleculerService = TimeRecordMoleculerService;
|
657
|
+
|
658
|
+
|
659
|
+
/***/ }),
|
660
|
+
|
661
|
+
/***/ "./src/plugins/timesheet-moleculer-service.ts":
|
662
|
+
/*!****************************************************!*\
|
663
|
+
!*** ./src/plugins/timesheet-moleculer-service.ts ***!
|
664
|
+
\****************************************************/
|
665
|
+
/*! no static exports found */
|
666
|
+
/***/ (function(module, exports, __webpack_require__) {
|
667
|
+
|
668
|
+
"use strict";
|
669
|
+
|
670
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
671
|
+
var t = {};
|
672
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
673
|
+
t[p] = s[p];
|
674
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
675
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
676
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
677
|
+
t[p[i]] = s[p[i]];
|
678
|
+
}
|
679
|
+
return t;
|
680
|
+
};
|
681
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
682
|
+
exports.TimesheetMoleculerService = void 0;
|
683
|
+
const moleculer_1 = __webpack_require__(/*! moleculer */ "moleculer");
|
684
|
+
const core_1 = __webpack_require__(/*! @common-stack/core */ "@common-stack/core");
|
685
|
+
const constants_1 = __webpack_require__(/*! ../constants */ "./src/constants/index.ts");
|
686
|
+
class TimesheetMoleculerService extends moleculer_1.Service {
|
687
|
+
constructor(broker, _a) {
|
688
|
+
var { container } = _a, settings = __rest(_a, ["container"]);
|
689
|
+
super(broker);
|
690
|
+
this.container = container;
|
691
|
+
const topic = "Timesheet" /* Timesheet */;
|
692
|
+
this.container.bind(core_1.ClientTypes.ApolloClient).toConstantValue(this.apolloClient);
|
693
|
+
this.timesheetService = this.container.get(constants_1.TYPES.ITimesheetService);
|
694
|
+
this.parseServiceSchema({
|
695
|
+
name: topic,
|
696
|
+
events: {
|
697
|
+
["onRemoveTimeRecordIdFromTimesheet" /* onRemoveTimeRecordIdFromTimesheet */]: {
|
698
|
+
handler: async (ctx) => {
|
699
|
+
return await this.timesheetService.removeTimeRecordIdFromTimesheet(ctx.params.recordId, ctx.params.orgId);
|
700
|
+
}
|
701
|
+
}
|
702
|
+
},
|
703
|
+
actions: {
|
704
|
+
["getTimesheets" /* getTimesheets */]: {
|
705
|
+
handler: async (ctx) => {
|
706
|
+
return await this.timesheetService.getTimesheets(ctx.params.orgId);
|
707
|
+
}
|
708
|
+
},
|
709
|
+
["getTimesheetsWithTotalHours" /* getTimesheetsWithTotalHours */]: {
|
710
|
+
handler: async (ctx) => {
|
711
|
+
return await this.timesheetService.getTimesheetsWithTotalHours(ctx.params.orgId, ctx.params.userId);
|
712
|
+
}
|
713
|
+
},
|
714
|
+
["getDurationTimesheets" /* getDurationTimesheets */]: {
|
715
|
+
handler: async (ctx) => {
|
716
|
+
return await this.timesheetService.getDurationTimesheets(ctx.params.orgId, ctx.params.start, ctx.params.end);
|
717
|
+
}
|
718
|
+
},
|
719
|
+
["createTimesheet" /* createTimesheet */]: {
|
720
|
+
handler: async (ctx) => {
|
721
|
+
return await this.timesheetService.createTimesheet(ctx.params.userId, ctx.params.orgId, ctx.params.request);
|
722
|
+
}
|
723
|
+
},
|
724
|
+
["updateTimesheet" /* updateTimesheet */]: {
|
725
|
+
handler: async (ctx) => {
|
726
|
+
return await this.timesheetService.updateTimesheet(ctx.params.userId, ctx.params.orgId, ctx.params.sheetId, ctx.params.request, ctx.params.userContext);
|
727
|
+
}
|
728
|
+
},
|
729
|
+
["removeTimesheet" /* removeTimesheet */]: {
|
730
|
+
handler: async (ctx) => {
|
731
|
+
return await this.timesheetService.removeTimesheet(ctx.params.userId, ctx.params.orgId, ctx.params.sheetId);
|
732
|
+
}
|
733
|
+
},
|
734
|
+
["updateTimesheetStatus" /* updateTimesheetStatus */]: {
|
735
|
+
handler: async (ctx) => {
|
736
|
+
return await this.timesheetService.updateTimesheetStatus(ctx.params.orgId, ctx.params.sheetId, ctx.params.state);
|
737
|
+
}
|
738
|
+
},
|
739
|
+
},
|
740
|
+
});
|
741
|
+
}
|
742
|
+
}
|
743
|
+
exports.TimesheetMoleculerService = TimesheetMoleculerService;
|
744
|
+
|
745
|
+
|
529
746
|
/***/ }),
|
530
747
|
|
531
748
|
/***/ "./src/preferences/index.ts":
|
@@ -545,7 +762,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
545
762
|
o[k2] = m[k];
|
546
763
|
}));
|
547
764
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
548
|
-
for (var p in m) if (p !== "default" && !
|
765
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
549
766
|
};
|
550
767
|
Object.defineProperty(exports, "__esModule", { value: true });
|
551
768
|
__exportStar(__webpack_require__(/*! ./settings */ "./src/preferences/settings/index.ts"), exports);
|
@@ -571,7 +788,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
571
788
|
o[k2] = m[k];
|
572
789
|
}));
|
573
790
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
574
|
-
for (var p in m) if (p !== "default" && !
|
791
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
575
792
|
};
|
576
793
|
Object.defineProperty(exports, "__esModule", { value: true });
|
577
794
|
__exportStar(__webpack_require__(/*! ./timing-permissions-contribution */ "./src/preferences/permissions/timing-permissions-contribution.ts"), exports);
|
@@ -1219,7 +1436,7 @@ exports.resolvers = [timerecord_resolver_1.resolver, timesheet_resolver_1.resolv
|
|
1219
1436
|
Object.defineProperty(exports, "__esModule", { value: true });
|
1220
1437
|
exports.resolver = void 0;
|
1221
1438
|
const graphql_subscriptions_1 = __webpack_require__(/*! graphql-subscriptions */ "graphql-subscriptions");
|
1222
|
-
|
1439
|
+
const resolver = (options) => ({
|
1223
1440
|
TimeRecord: {
|
1224
1441
|
id: (root) => root.id || root._id,
|
1225
1442
|
},
|
@@ -1274,6 +1491,7 @@ exports.resolver = (options) => ({
|
|
1274
1491
|
},
|
1275
1492
|
},
|
1276
1493
|
});
|
1494
|
+
exports.resolver = resolver;
|
1277
1495
|
|
1278
1496
|
|
1279
1497
|
/***/ }),
|
@@ -1290,7 +1508,7 @@ exports.resolver = (options) => ({
|
|
1290
1508
|
Object.defineProperty(exports, "__esModule", { value: true });
|
1291
1509
|
exports.resolver = void 0;
|
1292
1510
|
/* eslint-disable no-underscore-dangle */
|
1293
|
-
|
1511
|
+
const resolver = (options) => ({
|
1294
1512
|
Query: {
|
1295
1513
|
getTimesheets: (root, args, { timesheetService, userContext }) => {
|
1296
1514
|
options.logger.trace('(Query.getTimeSheets) args %j', args);
|
@@ -1322,6 +1540,7 @@ exports.resolver = (options) => ({
|
|
1322
1540
|
},
|
1323
1541
|
},
|
1324
1542
|
});
|
1543
|
+
exports.resolver = resolver;
|
1325
1544
|
|
1326
1545
|
|
1327
1546
|
/***/ }),
|
@@ -1369,7 +1588,7 @@ exports.schema = schema;
|
|
1369
1588
|
|
1370
1589
|
"use strict";
|
1371
1590
|
__webpack_require__.r(__webpack_exports__);
|
1372
|
-
/* harmony default export */ __webpack_exports__["default"] = ("type TimeRecord {\n id:
|
1591
|
+
/* harmony default export */ __webpack_exports__["default"] = ("type TimeRecord {\n id: ID\n startTime: DateTime\n endTime: DateTime\n taskId: String\n taskName: String\n description: String\n tags: [String]\n isBillable: Boolean\n projectId: String\n clientId: String\n userId: String\n orgId: String\n timesheetId: String\n editable: Boolean\n isPause: Boolean\n isTimeout: Boolean\n pauseStatus: [PauseStatus]\n}\n\nenum PauseStatusDescription {\n BY_USER\n DUE_TO_INACTIVITY\n}\n\ntype PauseStatus {\n pausedTime: DateTime\n restartTime: DateTime\n status: PauseStatusDescription\n}\n\ninput PauseStatus_Input {\n pausedTime: DateTime\n restartTime: DateTime\n status: PauseStatusDescription\n}\n\ninput TimeRecordRequest {\n userId: String\n startTime: DateTime\n endTime: DateTime\n taskName: String\n description: String\n tags: [String]\n isBillable: Boolean\n projectId: String\n clientId: String\n timesheetId: String\n isPause: Boolean\n isTimeout: Boolean\n pauseStatus: [PauseStatus_Input]\n}\n\n\"\"\"\n Subscription event for timer\n\"\"\"\nenum TimeRecordPubSubEvents {\n TimeRecordCreated\n TimeRecordUpdated\n TimeRecordStopped\n TimeRecordDeleted\n TimeRecordConfigurationUpdate\n}\n\ntype SubscriptionTimeRecord {\n mutation: TimeRecordPubSubEvents\n timeRecord: TimeRecord\n}\n\nextend type Query {\n getTimeRecords(userId: String): [TimeRecord] @addAccountContext\n getDurationTimeRecords(startTime: DateTime, endTime: DateTime, userId: String): [TimeRecord] @addAccountContext\n getPlayingTimeRecord: TimeRecord @addAccountContext\n}\n\nextend type Mutation {\n createTimeRecord(request: TimeRecordRequest): String @addAccountContext\n updateTimeRecord(recordId: String!, request: TimeRecordRequest): Boolean @addAccountContext\n removeTimeRecord(recordId: String!): Boolean @addAccountContext\n removeDurationTimeRecords(startTime: DateTime, endTime: DateTime, projectId: String): Boolean @addAccountContext\n}\n\nextend type Subscription {\n SubscribeToTimeTracker(orgName: String, userId: String): SubscriptionTimeRecord\n}\n");
|
1373
1592
|
|
1374
1593
|
/***/ }),
|
1375
1594
|
|
@@ -1382,7 +1601,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
1382
1601
|
|
1383
1602
|
"use strict";
|
1384
1603
|
__webpack_require__.r(__webpack_exports__);
|
1385
|
-
/* harmony default export */ __webpack_exports__["default"] = ("# scalar DateTime\nenum TimesheetState {\n OPEN\n APPROVED_PENDING\n APPROVED\n APPROVED_FINALIZED # --- which means no going back\n DENYED\n SUBMITTED\n DENYED_FINALIZED # --- which means no going back\n}\n\ntype Timesheet {\n id: ID\n userId: String\n startDate: DateTime\n endDate: DateTime\n state: TimesheetState\n submittedOn: DateTime\n approvedOn: DateTime\n approvedBy: String\n updatedBy: String # ---> userId\n updatedOn: DateTime\n}\n\ninput TimesheetCreateRequest {\n userId: String\n startDate: DateTime\n endDate: DateTime\n state: TimesheetState\n submittedOn: DateTime\n approvedOn: DateTime\n approvedBy: String\n updatedBy: String # ---> userId\n updatedOn: DateTime\n}\n\ntype TimesheetResponse {\n id: ID\n startDate: DateTime\n endDate: DateTime\n state: TimesheetState\n submittedOn: DateTime\n approvedOn: DateTime\n approvedBy: String\n updatedBy: String # ---> userId\n updatedOn: DateTime\n userId: String\n orgId: String\n totalDuration: Int\n}\n\nextend type Query {\n getTimesheets(userId: String, withTotalHours: Boolean): [TimesheetResponse] @addAccountContext\n getDurationTimesheets(start: DateTime, end: DateTime): [TimesheetResponse] @addAccountContext\n}\n\nextend type Mutation {\n createTimesheet(request: TimesheetCreateRequest): Boolean @addAccountContext\n updateTimesheet(sheetId: String, request: TimesheetCreateRequest): Boolean @addAccountContext\n removeTimesheet(sheetId: String): Boolean @addAccountContext\n updateTimesheetStatus(sheetId: String, state: TimesheetState): Boolean @addAccountContext\n}\n");
|
1604
|
+
/* harmony default export */ __webpack_exports__["default"] = ("# scalar DateTime\nenum TimesheetState {\n OPEN\n APPROVED_PENDING\n APPROVED\n APPROVED_FINALIZED # --- which means no going back\n DENYED\n SUBMITTED\n DENYED_FINALIZED # --- which means no going back\n}\n\ntype Timesheet {\n id: ID\n orgId: String\n userId: String\n startDate: DateTime\n endDate: DateTime\n state: TimesheetState\n submittedOn: DateTime\n approvedOn: DateTime\n approvedBy: String\n updatedBy: String # ---> userId\n updatedOn: DateTime\n timeRecordsId: [String]\n}\n\ninput TimesheetCreateRequest {\n userId: String\n startDate: DateTime\n endDate: DateTime\n state: TimesheetState\n submittedOn: DateTime\n approvedOn: DateTime\n approvedBy: String\n updatedBy: String # ---> userId\n updatedOn: DateTime\n timeRecordsId: [String]\n}\n\ntype TimesheetResponse {\n id: ID\n startDate: DateTime\n endDate: DateTime\n state: TimesheetState\n submittedOn: DateTime\n approvedOn: DateTime\n approvedBy: String\n updatedBy: String # ---> userId\n updatedOn: DateTime\n userId: String\n orgId: String\n timeRecordsId: [String]\n totalDuration: Int\n}\n\nextend type Query {\n getTimesheets(userId: String, withTotalHours: Boolean): [TimesheetResponse] @addAccountContext\n getDurationTimesheets(start: DateTime, end: DateTime): [TimesheetResponse] @addAccountContext\n}\n\nextend type Mutation {\n createTimesheet(request: TimesheetCreateRequest): Boolean @addAccountContext\n updateTimesheet(sheetId: String, request: TimesheetCreateRequest): Boolean @addAccountContext\n removeTimesheet(sheetId: String): Boolean @addAccountContext\n updateTimesheetStatus(sheetId: String, state: TimesheetState): Boolean @addAccountContext\n}\n");
|
1386
1605
|
|
1387
1606
|
/***/ }),
|
1388
1607
|
|
@@ -1416,11 +1635,88 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
1416
1635
|
o[k2] = m[k];
|
1417
1636
|
}));
|
1418
1637
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
1419
|
-
for (var p in m) if (p !== "default" && !
|
1638
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
1420
1639
|
};
|
1421
1640
|
Object.defineProperty(exports, "__esModule", { value: true });
|
1422
1641
|
__exportStar(__webpack_require__(/*! ./timesheet-service */ "./src/services/timesheet-service.ts"), exports);
|
1423
1642
|
__exportStar(__webpack_require__(/*! ./timerecord-service */ "./src/services/timerecord-service.ts"), exports);
|
1643
|
+
__exportStar(__webpack_require__(/*! ./timerecord-proxy-service */ "./src/services/timerecord-proxy-service.ts"), exports);
|
1644
|
+
__exportStar(__webpack_require__(/*! ./timesheet-proxy-service */ "./src/services/timesheet-proxy-service.ts"), exports);
|
1645
|
+
|
1646
|
+
|
1647
|
+
/***/ }),
|
1648
|
+
|
1649
|
+
/***/ "./src/services/timerecord-proxy-service.ts":
|
1650
|
+
/*!**************************************************!*\
|
1651
|
+
!*** ./src/services/timerecord-proxy-service.ts ***!
|
1652
|
+
\**************************************************/
|
1653
|
+
/*! no static exports found */
|
1654
|
+
/***/ (function(module, exports, __webpack_require__) {
|
1655
|
+
|
1656
|
+
"use strict";
|
1657
|
+
|
1658
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
1659
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
1660
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
1661
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
1662
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
1663
|
+
};
|
1664
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
1665
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
1666
|
+
};
|
1667
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
1668
|
+
exports.TimeRecordProxyService = void 0;
|
1669
|
+
const inversify_1 = __webpack_require__(/*! inversify */ "inversify");
|
1670
|
+
const core_1 = __webpack_require__(/*! @common-stack/core */ "@common-stack/core");
|
1671
|
+
let TimeRecordProxyService = class TimeRecordProxyService {
|
1672
|
+
constructor(broker, logger) {
|
1673
|
+
this.broker = broker;
|
1674
|
+
this.topic = "TimeRecord" /* TimeRecord */;
|
1675
|
+
this.logger = logger.child({ className: 'TimeRecordProxyService' });
|
1676
|
+
}
|
1677
|
+
approveTimeRecords(orgId, sheetId, timeRecordsId) {
|
1678
|
+
return this.callAction("approveTimeRecords" /* approveTimeRecords */, { orgId, sheetId, timeRecordsId });
|
1679
|
+
}
|
1680
|
+
createTimeRecord(userId, orgId, request) {
|
1681
|
+
return this.callAction("createTimeRecord" /* createTimeRecord */, { userId, orgId, request });
|
1682
|
+
}
|
1683
|
+
disapproveTimeRecords(orgId, sheetId) {
|
1684
|
+
return this.callAction("disapproveTimeRecords" /* disapproveTimeRecords */, { orgId, sheetId });
|
1685
|
+
}
|
1686
|
+
getDurationTimeRecords(orgId, startTime, endTime, userId) {
|
1687
|
+
return this.callAction("getDurationTimeRecords" /* getDurationTimeRecords */, { orgId, startTime, endTime, userId });
|
1688
|
+
}
|
1689
|
+
getPlayingTimeRecord(userId, orgId) {
|
1690
|
+
return this.callAction("getPlayingTimeRecord" /* getPlayingTimeRecord */, { userId, orgId });
|
1691
|
+
}
|
1692
|
+
getTimeRecords(orgId, userId) {
|
1693
|
+
return this.callAction("getTimeRecords" /* getTimeRecords */, { orgId, userId });
|
1694
|
+
}
|
1695
|
+
removeDurationTimeRecords(userId, orgId, startTime, endTime, projectId) {
|
1696
|
+
return this.callAction("removeDurationTimeRecords" /* removeDurationTimeRecords */, {
|
1697
|
+
userId,
|
1698
|
+
orgId,
|
1699
|
+
startTime,
|
1700
|
+
endTime,
|
1701
|
+
projectId,
|
1702
|
+
});
|
1703
|
+
}
|
1704
|
+
removeTimeRecord(userId, orgId, recordId) {
|
1705
|
+
return this.callAction("removeTimeRecord" /* removeTimeRecord */, { userId, orgId, recordId });
|
1706
|
+
}
|
1707
|
+
updateTimeRecord(userId, orgId, recordId, request) {
|
1708
|
+
return this.callAction("updateTimeRecord" /* updateTimeRecord */, { userId, orgId, recordId, request });
|
1709
|
+
}
|
1710
|
+
async callAction(command, params) {
|
1711
|
+
return this.broker.call(`${this.topic}.${command}`, params);
|
1712
|
+
}
|
1713
|
+
};
|
1714
|
+
TimeRecordProxyService = __decorate([
|
1715
|
+
inversify_1.injectable(),
|
1716
|
+
__param(0, inversify_1.inject(core_1.CommonType.MOLECULER_BROKER)),
|
1717
|
+
__param(1, inversify_1.inject('Logger'))
|
1718
|
+
], TimeRecordProxyService);
|
1719
|
+
exports.TimeRecordProxyService = TimeRecordProxyService;
|
1424
1720
|
|
1425
1721
|
|
1426
1722
|
/***/ }),
|
@@ -1446,13 +1742,15 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
1446
1742
|
Object.defineProperty(exports, "__esModule", { value: true });
|
1447
1743
|
exports.TimeRecordService = void 0;
|
1448
1744
|
const inversify_1 = __webpack_require__(/*! inversify */ "inversify");
|
1449
|
-
const core_1 = __webpack_require__(/*! @
|
1450
|
-
const core_2 = __webpack_require__(/*! @common-stack/core */ "@common-stack/core");
|
1745
|
+
const core_1 = __webpack_require__(/*! @common-stack/core */ "@common-stack/core");
|
1451
1746
|
const constants_1 = __webpack_require__(/*! ../constants */ "./src/constants/index.ts");
|
1747
|
+
const moment = __webpack_require__(/*! moment */ "moment");
|
1452
1748
|
let TimeRecordService = class TimeRecordService {
|
1453
|
-
constructor(timeRecordRepository,
|
1749
|
+
constructor(timeRecordRepository,
|
1750
|
+
// @inject(ServerTypes.IPreferenceEditorService)
|
1751
|
+
// private preferencesService: IPreferencesService,
|
1752
|
+
broker, pubsub, logger) {
|
1454
1753
|
this.timeRecordRepository = timeRecordRepository;
|
1455
|
-
this.preferencesService = preferencesService;
|
1456
1754
|
this.broker = broker;
|
1457
1755
|
this.pubsub = pubsub;
|
1458
1756
|
this.logger = logger;
|
@@ -1461,7 +1759,7 @@ let TimeRecordService = class TimeRecordService {
|
|
1461
1759
|
return this.timeRecordRepository.getTimeRecords(orgId, userId);
|
1462
1760
|
}
|
1463
1761
|
async getDurationTimeRecords(orgId, startTime, endTime, userId) {
|
1464
|
-
const timeRecords = await this.timeRecordRepository.getTimeRecords(orgId, userId, startTime, endTime);
|
1762
|
+
const timeRecords = await this.timeRecordRepository.getTimeRecords(orgId, userId, startTime && moment(startTime).toDate(), endTime && moment(endTime).toDate());
|
1465
1763
|
return timeRecords.filter((r) => r.endTime !== null);
|
1466
1764
|
}
|
1467
1765
|
async getPlayingTimeRecord(userId, orgId) {
|
@@ -1469,13 +1767,12 @@ let TimeRecordService = class TimeRecordService {
|
|
1469
1767
|
}
|
1470
1768
|
async createTimeRecord(userId, orgId, request) {
|
1471
1769
|
const data = await this.timeRecordRepository.createTimeRecord(userId, orgId, request);
|
1472
|
-
|
1473
|
-
if (timeRecord) {
|
1770
|
+
if (data) {
|
1474
1771
|
const record = {
|
1475
1772
|
orgName: data.orgId,
|
1476
|
-
userId:
|
1773
|
+
userId: data.userId,
|
1477
1774
|
mutation: "TimeRecordCreated" /* TimeRecordCreated */,
|
1478
|
-
timeRecord,
|
1775
|
+
timeRecord: data,
|
1479
1776
|
};
|
1480
1777
|
this.pubsub.publish("TimeRecordCreated" /* TimeRecordCreated */, { SubscribeToTimeTracker: record });
|
1481
1778
|
}
|
@@ -1483,13 +1780,12 @@ let TimeRecordService = class TimeRecordService {
|
|
1483
1780
|
}
|
1484
1781
|
async updateTimeRecord(userId, orgId, recordId, request) {
|
1485
1782
|
const data = await this.timeRecordRepository.updateTimeRecord(userId, orgId, recordId, request);
|
1486
|
-
|
1487
|
-
if (timeRecord) {
|
1783
|
+
if (data) {
|
1488
1784
|
const record = {
|
1489
1785
|
orgName: data.orgId,
|
1490
|
-
userId:
|
1786
|
+
userId: data.userId,
|
1491
1787
|
mutation: "TimeRecordUpdated" /* TimeRecordUpdated */,
|
1492
|
-
timeRecord,
|
1788
|
+
timeRecord: data,
|
1493
1789
|
};
|
1494
1790
|
this.pubsub.publish("TimeRecordUpdated" /* TimeRecordUpdated */, { SubscribeToTimeTracker: record });
|
1495
1791
|
}
|
@@ -1501,16 +1797,43 @@ let TimeRecordService = class TimeRecordService {
|
|
1501
1797
|
orgName: data.orgId,
|
1502
1798
|
userId: data.userId,
|
1503
1799
|
mutation: "TimeRecordDeleted" /* TimeRecordDeleted */,
|
1504
|
-
timeRecord: data
|
1800
|
+
timeRecord: data,
|
1505
1801
|
};
|
1802
|
+
// remove record activities
|
1803
|
+
await this.broker.broadcast("onRemoveTimeRecord" /* onRemoveTimeRecord */, { userId, orgId, recordId }, [
|
1804
|
+
"TimeRecord" /* TimeRecord */,
|
1805
|
+
"Timesheet" /* Timesheet */,
|
1806
|
+
"Activity" /* Activity */,
|
1807
|
+
]);
|
1808
|
+
//remove record id from timesheet
|
1809
|
+
await this.broker.broadcast("onRemoveTimeRecordIdFromTimesheet" /* onRemoveTimeRecordIdFromTimesheet */, { recordId, orgId }, [
|
1810
|
+
"TimeRecord" /* TimeRecord */,
|
1811
|
+
"Timesheet" /* Timesheet */,
|
1812
|
+
]);
|
1506
1813
|
this.pubsub.publish("TimeRecordDeleted" /* TimeRecordDeleted */, { SubscribeToTimeTracker: record });
|
1507
1814
|
return true;
|
1508
1815
|
}
|
1509
1816
|
async removeDurationTimeRecords(userId, orgId, startTime, endTime, projectId) {
|
1510
|
-
|
1817
|
+
const records = await this.timeRecordRepository.getTimeRecords(orgId, userId);
|
1818
|
+
if (records && records.length > 0) {
|
1819
|
+
const timeRecords = records.filter((tr) => tr.startTime > moment(startTime) && tr.startTime < moment(endTime) && tr.projectId === projectId);
|
1820
|
+
for (const record of timeRecords) {
|
1821
|
+
await this.broker.broadcast("onRemoveTimeRecord" /* onRemoveTimeRecord */, { userId, orgId, recordId: record._id }, [
|
1822
|
+
"TimeRecord" /* TimeRecord */,
|
1823
|
+
"Timesheet" /* Timesheet */,
|
1824
|
+
"Activity" /* Activity */,
|
1825
|
+
]);
|
1826
|
+
//remove record id from timesheet
|
1827
|
+
await this.broker.broadcast("onRemoveTimeRecordIdFromTimesheet" /* onRemoveTimeRecordIdFromTimesheet */, { recordId: record._id, orgId }, [
|
1828
|
+
"TimeRecord" /* TimeRecord */,
|
1829
|
+
"Timesheet" /* Timesheet */,
|
1830
|
+
]);
|
1831
|
+
}
|
1832
|
+
}
|
1833
|
+
return this.timeRecordRepository.removeDurationTimeRecords(userId, orgId, moment(startTime), moment(endTime), projectId);
|
1511
1834
|
}
|
1512
|
-
async approveTimeRecords(orgId, sheetId,
|
1513
|
-
this.timeRecordRepository.approveTimeRecords(orgId, sheetId,
|
1835
|
+
async approveTimeRecords(orgId, sheetId, timeRecordsId) {
|
1836
|
+
this.timeRecordRepository.approveTimeRecords(orgId, sheetId, timeRecordsId);
|
1514
1837
|
}
|
1515
1838
|
async disapproveTimeRecords(orgId, sheetId) {
|
1516
1839
|
this.timeRecordRepository.disapproveTimeRecords(orgId, sheetId);
|
@@ -1519,14 +1842,79 @@ let TimeRecordService = class TimeRecordService {
|
|
1519
1842
|
TimeRecordService = __decorate([
|
1520
1843
|
inversify_1.injectable(),
|
1521
1844
|
__param(0, inversify_1.inject(constants_1.TYPES.ITimeRecordRepository)),
|
1522
|
-
__param(1, inversify_1.inject(core_1.
|
1523
|
-
__param(2, inversify_1.inject(
|
1524
|
-
__param(3, inversify_1.inject('
|
1525
|
-
__param(4, inversify_1.inject('Logger'))
|
1845
|
+
__param(1, inversify_1.inject(core_1.CommonType.MOLECULER_BROKER)),
|
1846
|
+
__param(2, inversify_1.inject('PubSub')),
|
1847
|
+
__param(3, inversify_1.inject('Logger'))
|
1526
1848
|
], TimeRecordService);
|
1527
1849
|
exports.TimeRecordService = TimeRecordService;
|
1528
1850
|
|
1529
1851
|
|
1852
|
+
/***/ }),
|
1853
|
+
|
1854
|
+
/***/ "./src/services/timesheet-proxy-service.ts":
|
1855
|
+
/*!*************************************************!*\
|
1856
|
+
!*** ./src/services/timesheet-proxy-service.ts ***!
|
1857
|
+
\*************************************************/
|
1858
|
+
/*! no static exports found */
|
1859
|
+
/***/ (function(module, exports, __webpack_require__) {
|
1860
|
+
|
1861
|
+
"use strict";
|
1862
|
+
|
1863
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
1864
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
1865
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
1866
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
1867
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
1868
|
+
};
|
1869
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
1870
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
1871
|
+
};
|
1872
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
1873
|
+
exports.TimesheetProxyService = void 0;
|
1874
|
+
const inversify_1 = __webpack_require__(/*! inversify */ "inversify");
|
1875
|
+
const core_1 = __webpack_require__(/*! @common-stack/core */ "@common-stack/core");
|
1876
|
+
let TimesheetProxyService = class TimesheetProxyService {
|
1877
|
+
constructor(broker, logger) {
|
1878
|
+
this.broker = broker;
|
1879
|
+
this.topic = "Timesheet" /* Timesheet */;
|
1880
|
+
this.logger = logger.child({ className: 'TimesheetProxyService' });
|
1881
|
+
}
|
1882
|
+
createTimesheet(userId, orgId, request) {
|
1883
|
+
return this.callAction("createTimesheet" /* createTimesheet */, { userId, orgId, request });
|
1884
|
+
}
|
1885
|
+
getDurationTimesheets(orgId, start, end) {
|
1886
|
+
return this.callAction("getDurationTimesheets" /* getDurationTimesheets */, { orgId, start, end });
|
1887
|
+
}
|
1888
|
+
getTimesheets(orgId) {
|
1889
|
+
return this.callAction("getTimesheets" /* getTimesheets */, { orgId });
|
1890
|
+
}
|
1891
|
+
getTimesheetsWithTotalHours(orgId, userId) {
|
1892
|
+
return this.callAction("getTimesheetsWithTotalHours" /* getTimesheetsWithTotalHours */, { orgId, userId });
|
1893
|
+
}
|
1894
|
+
removeTimesheet(userId, orgId, sheetId) {
|
1895
|
+
return this.callAction("removeTimesheet" /* removeTimesheet */, { userId, orgId, sheetId });
|
1896
|
+
}
|
1897
|
+
removeTimeRecordIdFromTimesheet(recordId, orgId) {
|
1898
|
+
return this.callAction("removeTimeRecordIdFromTimesheet" /* removeTimeRecordIdFromTimesheet */, { recordId, orgId });
|
1899
|
+
}
|
1900
|
+
updateTimesheet(userId, orgId, sheetId, request, userContext) {
|
1901
|
+
return this.callAction("updateTimesheet" /* updateTimesheet */, { userId, orgId, sheetId, request });
|
1902
|
+
}
|
1903
|
+
updateTimesheetStatus(orgId, sheetId, state) {
|
1904
|
+
return this.callAction("updateTimesheetStatus" /* updateTimesheetStatus */, { orgId, sheetId, state });
|
1905
|
+
}
|
1906
|
+
async callAction(command, params) {
|
1907
|
+
return this.broker.call(`${this.topic}.${command}`, params);
|
1908
|
+
}
|
1909
|
+
};
|
1910
|
+
TimesheetProxyService = __decorate([
|
1911
|
+
inversify_1.injectable(),
|
1912
|
+
__param(0, inversify_1.inject(core_1.CommonType.MOLECULER_BROKER)),
|
1913
|
+
__param(1, inversify_1.inject('Logger'))
|
1914
|
+
], TimesheetProxyService);
|
1915
|
+
exports.TimesheetProxyService = TimesheetProxyService;
|
1916
|
+
|
1917
|
+
|
1530
1918
|
/***/ }),
|
1531
1919
|
|
1532
1920
|
/***/ "./src/services/timesheet-service.ts":
|
@@ -1573,7 +1961,7 @@ let TimesheetService = class TimesheetService {
|
|
1573
1961
|
const timeRecords = await this.timeRecordRepository.getTimeRecords(orgId, userId);
|
1574
1962
|
return timesheets.map((timesheet) => {
|
1575
1963
|
const sheetTotalDuration = timeRecords
|
1576
|
-
.filter((tr) =>
|
1964
|
+
.filter((tr) => { var _a; return (_a = timesheet.timeRecordsId) === null || _a === void 0 ? void 0 : _a.includes(tr._id.toString()); })
|
1577
1965
|
.reduce((duration, tr) => duration + Math.floor((moment(tr.endTime).valueOf() - moment(tr.startTime).valueOf()) / 1000), 0);
|
1578
1966
|
return {
|
1579
1967
|
id: timesheet.id,
|
@@ -1587,6 +1975,7 @@ let TimesheetService = class TimesheetService {
|
|
1587
1975
|
submittedOn: timesheet.submittedOn,
|
1588
1976
|
updatedBy: timesheet.updatedBy,
|
1589
1977
|
updatedOn: timesheet.updatedOn,
|
1978
|
+
timeRecordsId: timesheet.timeRecordsId,
|
1590
1979
|
totalDuration: sheetTotalDuration,
|
1591
1980
|
};
|
1592
1981
|
});
|
@@ -1604,7 +1993,7 @@ let TimesheetService = class TimesheetService {
|
|
1604
1993
|
await this.timesheetRepository.updateTimesheet(orgId, sheetId, request);
|
1605
1994
|
if (request.state === "APPROVED" /* APPROVED */) {
|
1606
1995
|
// approve time records from startDate to endDate
|
1607
|
-
this.timeRecordService.approveTimeRecords(orgId, sheetId, request.
|
1996
|
+
this.timeRecordService.approveTimeRecords(orgId, sheetId, request.timeRecordsId);
|
1608
1997
|
}
|
1609
1998
|
else if (request.state === "DENYED" /* DENYED */) {
|
1610
1999
|
// approve time records from startDate to endDate
|
@@ -1618,7 +2007,7 @@ let TimesheetService = class TimesheetService {
|
|
1618
2007
|
if (request.state === "APPROVED" /* APPROVED */ &&
|
1619
2008
|
settings.timetracker.notifications.approvalNotifications &&
|
1620
2009
|
settings.timetracker.notifications.enableTimetrackerNotifications) {
|
1621
|
-
const mailTopic = '
|
2010
|
+
const mailTopic = 'Timesheet approved';
|
1622
2011
|
const mailTo = userContext.emailId;
|
1623
2012
|
const mailFrom = config_1.config.MAIL_SEND_DEFAULT_EMAIL;
|
1624
2013
|
const templateId = constants_1.EmailTemplateCodes.TIMESHEET_APPROVAL;
|
@@ -1634,7 +2023,7 @@ let TimesheetService = class TimesheetService {
|
|
1634
2023
|
if (request.state === "SUBMITTED" /* SUBMITTED */ &&
|
1635
2024
|
settings.timetracker.notifications.submitNotifications &&
|
1636
2025
|
settings.timetracker.notifications.enableTimetrackerNotifications) {
|
1637
|
-
const mailTopic = '
|
2026
|
+
const mailTopic = 'Timesheet submitted';
|
1638
2027
|
const mailTo = userContext.emailId;
|
1639
2028
|
const mailFrom = config_1.config.MAIL_SEND_DEFAULT_EMAIL;
|
1640
2029
|
const templateId = constants_1.EmailTemplateCodes.SUBMIT_TIME;
|
@@ -1681,6 +2070,9 @@ let TimesheetService = class TimesheetService {
|
|
1681
2070
|
},
|
1682
2071
|
}, "MailService" /* MailService */);
|
1683
2072
|
}
|
2073
|
+
async removeTimeRecordIdFromTimesheet(recordId, orgId) {
|
2074
|
+
return await this.timesheetRepository.removeTimeRecordIdFromTimesheet(recordId, orgId);
|
2075
|
+
}
|
1684
2076
|
async callAction(command, params, topic, opts) {
|
1685
2077
|
return this.broker.call(`${topic}.${command}@${this.settings.adminApiNamespace}`, params, opts);
|
1686
2078
|
}
|
@@ -1699,6 +2091,108 @@ TimesheetService = __decorate([
|
|
1699
2091
|
exports.TimesheetService = TimesheetService;
|
1700
2092
|
|
1701
2093
|
|
2094
|
+
/***/ }),
|
2095
|
+
|
2096
|
+
/***/ "./src/store/models/timerecords-model.ts":
|
2097
|
+
/*!***********************************************!*\
|
2098
|
+
!*** ./src/store/models/timerecords-model.ts ***!
|
2099
|
+
\***********************************************/
|
2100
|
+
/*! no static exports found */
|
2101
|
+
/***/ (function(module, exports, __webpack_require__) {
|
2102
|
+
|
2103
|
+
"use strict";
|
2104
|
+
|
2105
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
2106
|
+
exports.TimeRecordsModelFunc = void 0;
|
2107
|
+
const mongoose_1 = __webpack_require__(/*! mongoose */ "mongoose");
|
2108
|
+
var PauseStatusDescription;
|
2109
|
+
(function (PauseStatusDescription) {
|
2110
|
+
PauseStatusDescription["BY_USER"] = "BY_USER";
|
2111
|
+
PauseStatusDescription["DUE_TO_INACTIVITY"] = "DUE_TO_INACTIVITY";
|
2112
|
+
})(PauseStatusDescription || (PauseStatusDescription = {}));
|
2113
|
+
const PauseStatusSchema = new mongoose_1.Schema({
|
2114
|
+
pausedTime: { type: Date },
|
2115
|
+
restartTime: { type: Date },
|
2116
|
+
status: { type: PauseStatusDescription },
|
2117
|
+
});
|
2118
|
+
// ===> TimeRecord
|
2119
|
+
const TimeRecordSchema = new mongoose_1.Schema({
|
2120
|
+
orgId: { type: String, index: true },
|
2121
|
+
userId: { type: String, index: true },
|
2122
|
+
startTime: { type: Date, index: true },
|
2123
|
+
endTime: { type: Date, default: null, index: true },
|
2124
|
+
taskName: { type: String },
|
2125
|
+
description: { type: String },
|
2126
|
+
taskId: { type: String },
|
2127
|
+
tags: { type: [String] },
|
2128
|
+
isBillable: { type: Boolean },
|
2129
|
+
projectId: { type: String },
|
2130
|
+
timesheetId: { type: String, index: true },
|
2131
|
+
isPause: { type: Boolean, default: false },
|
2132
|
+
isTimeout: { type: Boolean, default: false },
|
2133
|
+
pauseStatus: { type: [PauseStatusSchema] }
|
2134
|
+
});
|
2135
|
+
TimeRecordSchema.index({ endTime: 1, startTime: 1, userId: 1 });
|
2136
|
+
TimeRecordSchema.virtual('id').get(function () {
|
2137
|
+
return this._id.toHexString();
|
2138
|
+
});
|
2139
|
+
TimeRecordSchema.set('toJSON', {
|
2140
|
+
virtuals: true,
|
2141
|
+
});
|
2142
|
+
TimeRecordSchema.set('toObject', { virtuals: true });
|
2143
|
+
const TimeRecordsModelFunc = (db) => db.model('timerecords', TimeRecordSchema);
|
2144
|
+
exports.TimeRecordsModelFunc = TimeRecordsModelFunc;
|
2145
|
+
|
2146
|
+
|
2147
|
+
/***/ }),
|
2148
|
+
|
2149
|
+
/***/ "./src/store/models/timesheets-model.ts":
|
2150
|
+
/*!**********************************************!*\
|
2151
|
+
!*** ./src/store/models/timesheets-model.ts ***!
|
2152
|
+
\**********************************************/
|
2153
|
+
/*! no static exports found */
|
2154
|
+
/***/ (function(module, exports, __webpack_require__) {
|
2155
|
+
|
2156
|
+
"use strict";
|
2157
|
+
|
2158
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
2159
|
+
exports.TimesheetsModelFunc = void 0;
|
2160
|
+
const mongoose_1 = __webpack_require__(/*! mongoose */ "mongoose");
|
2161
|
+
var TimesheetState;
|
2162
|
+
(function (TimesheetState) {
|
2163
|
+
TimesheetState[TimesheetState["OPEN"] = 0] = "OPEN";
|
2164
|
+
TimesheetState[TimesheetState["APPROVED_PENDING"] = 1] = "APPROVED_PENDING";
|
2165
|
+
TimesheetState[TimesheetState["APPROVED"] = 2] = "APPROVED";
|
2166
|
+
TimesheetState[TimesheetState["APPROVED_FINALIZED"] = 3] = "APPROVED_FINALIZED";
|
2167
|
+
TimesheetState[TimesheetState["DENYED"] = 4] = "DENYED";
|
2168
|
+
TimesheetState[TimesheetState["SUBMITTED"] = 5] = "SUBMITTED";
|
2169
|
+
TimesheetState[TimesheetState["DENYED_FINALIZED"] = 6] = "DENYED_FINALIZED";
|
2170
|
+
})(TimesheetState || (TimesheetState = {}));
|
2171
|
+
// ===> Timesheet
|
2172
|
+
const TimesheetSchema = new mongoose_1.Schema({
|
2173
|
+
orgId: { type: String, index: true },
|
2174
|
+
userId: { type: String, index: true },
|
2175
|
+
startDate: { type: Date },
|
2176
|
+
endDate: { type: Date },
|
2177
|
+
state: { type: TimesheetState },
|
2178
|
+
submittedOn: { type: Date },
|
2179
|
+
approvedOn: { type: Date },
|
2180
|
+
approvedBy: { type: String },
|
2181
|
+
updatedBy: { type: String },
|
2182
|
+
updatedOn: { type: Date },
|
2183
|
+
timeRecordsId: { type: [String] },
|
2184
|
+
});
|
2185
|
+
TimesheetSchema.virtual('id').get(function () {
|
2186
|
+
return this._id.toHexString();
|
2187
|
+
});
|
2188
|
+
TimesheetSchema.set('toJSON', {
|
2189
|
+
virtuals: true,
|
2190
|
+
});
|
2191
|
+
TimesheetSchema.set('toObject', { virtuals: true });
|
2192
|
+
const TimesheetsModelFunc = (db) => db.model('timesheets', TimesheetSchema);
|
2193
|
+
exports.TimesheetsModelFunc = TimesheetsModelFunc;
|
2194
|
+
|
2195
|
+
|
1702
2196
|
/***/ }),
|
1703
2197
|
|
1704
2198
|
/***/ "./src/store/models/timetracker-model.ts":
|
@@ -1750,7 +2244,7 @@ const TimeRecordSchema = new mongoose_1.Schema({
|
|
1750
2244
|
activities: [TimeActivitySchema],
|
1751
2245
|
isPause: { type: Boolean, default: false },
|
1752
2246
|
isTimeout: { type: Boolean, default: false },
|
1753
|
-
pauseStatus: { type: [PauseStatusSchema] }
|
2247
|
+
pauseStatus: { type: [PauseStatusSchema] }
|
1754
2248
|
});
|
1755
2249
|
TimeRecordSchema.index({ endTime: 1, startTime: 1, userId: 1 });
|
1756
2250
|
// ===> Timesheet
|
@@ -1764,6 +2258,7 @@ const TimesheetSchema = new mongoose_1.Schema({
|
|
1764
2258
|
approvedBy: { type: String },
|
1765
2259
|
updatedBy: { type: String },
|
1766
2260
|
updatedOn: { type: Date },
|
2261
|
+
timeRecordsId: { type: [String] },
|
1767
2262
|
});
|
1768
2263
|
const TimeTrackerSchema = new mongoose_1.Schema({
|
1769
2264
|
orgId: { type: String, index: true },
|
@@ -1783,7 +2278,8 @@ TimeTrackerSchema.set('toJSON', {
|
|
1783
2278
|
virtuals: true,
|
1784
2279
|
});
|
1785
2280
|
TimeTrackerSchema.set('toObject', { virtuals: true });
|
1786
|
-
|
2281
|
+
const TimeTrackerModelFunc = (db) => db.model('timetracker', TimeTrackerSchema);
|
2282
|
+
exports.TimeTrackerModelFunc = TimeTrackerModelFunc;
|
1787
2283
|
|
1788
2284
|
|
1789
2285
|
/***/ }),
|
@@ -1805,7 +2301,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
1805
2301
|
o[k2] = m[k];
|
1806
2302
|
}));
|
1807
2303
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
1808
|
-
for (var p in m) if (p !== "default" && !
|
2304
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
1809
2305
|
};
|
1810
2306
|
Object.defineProperty(exports, "__esModule", { value: true });
|
1811
2307
|
__exportStar(__webpack_require__(/*! ./timerecord-repository */ "./src/store/repository/timerecord-repository.ts"), exports);
|
@@ -1835,82 +2331,60 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
1835
2331
|
Object.defineProperty(exports, "__esModule", { value: true });
|
1836
2332
|
exports.TimeRecordRepository = void 0;
|
1837
2333
|
const inversify_1 = __webpack_require__(/*! inversify */ "inversify");
|
1838
|
-
const
|
1839
|
-
const timetracker_model_1 = __webpack_require__(/*! ../models/timetracker-model */ "./src/store/models/timetracker-model.ts");
|
2334
|
+
const timerecords_model_1 = __webpack_require__(/*! ../models/timerecords-model */ "./src/store/models/timerecords-model.ts");
|
1840
2335
|
let TimeRecordRepository = class TimeRecordRepository {
|
1841
2336
|
constructor(db, logger) {
|
1842
2337
|
this.logger = logger.child({ className: 'TimeRecordRepository' });
|
1843
|
-
this.
|
2338
|
+
this.timeRecordsModel = timerecords_model_1.TimeRecordsModelFunc(db);
|
1844
2339
|
}
|
1845
2340
|
async getTimeRecords(orgId, userId, from, until) {
|
1846
2341
|
if (!userId) {
|
1847
2342
|
userId = /.*/;
|
1848
2343
|
}
|
1849
2344
|
let match = {
|
1850
|
-
'
|
2345
|
+
'userId': userId,
|
1851
2346
|
};
|
1852
2347
|
if (from) {
|
1853
|
-
match = Object.assign(Object.assign({}, match), { '
|
2348
|
+
match = Object.assign(Object.assign({}, match), { 'startTime': { $gte: from } });
|
1854
2349
|
}
|
1855
2350
|
if (until) {
|
1856
|
-
match = Object.assign(Object.assign({}, match), { '
|
2351
|
+
match = Object.assign(Object.assign({}, match), { 'endTime': { $lte: until } });
|
1857
2352
|
}
|
1858
|
-
const result = await this.
|
2353
|
+
const result = await this.timeRecordsModel.aggregate([
|
1859
2354
|
{
|
1860
2355
|
$match: {
|
1861
2356
|
orgId,
|
1862
2357
|
},
|
1863
2358
|
},
|
1864
|
-
{
|
1865
|
-
$unwind: '$timeRecords',
|
1866
|
-
},
|
1867
2359
|
{
|
1868
2360
|
$match: Object.assign({}, match),
|
1869
2361
|
},
|
1870
|
-
{
|
1871
|
-
$group: {
|
1872
|
-
_id: '$orgId',
|
1873
|
-
timeRecords: {
|
1874
|
-
$push: '$timeRecords',
|
1875
|
-
},
|
1876
|
-
},
|
1877
|
-
},
|
1878
|
-
{
|
1879
|
-
$project: {
|
1880
|
-
orgId: 1,
|
1881
|
-
timeRecords: 1,
|
1882
|
-
},
|
1883
|
-
},
|
1884
2362
|
]);
|
1885
2363
|
if (result.length === 0) {
|
1886
2364
|
return [];
|
1887
2365
|
}
|
1888
|
-
return result
|
2366
|
+
return result;
|
1889
2367
|
}
|
1890
2368
|
async getOrganizationTimeRecords(orgId) {
|
1891
|
-
const trackDoc = await this.
|
1892
|
-
if (trackDoc
|
1893
|
-
return trackDoc
|
2369
|
+
const trackDoc = await this.timeRecordsModel.find({ orgId });
|
2370
|
+
if (trackDoc) {
|
2371
|
+
return trackDoc;
|
1894
2372
|
}
|
1895
2373
|
return [];
|
1896
2374
|
}
|
1897
2375
|
async getPlayingTimeRecord(userId, orgId) {
|
1898
|
-
const trackDoc = await this.
|
2376
|
+
const trackDoc = await this.timeRecordsModel.find({ orgId });
|
1899
2377
|
if (trackDoc) {
|
1900
2378
|
let res;
|
1901
|
-
if (trackDoc
|
1902
|
-
res = trackDoc.
|
2379
|
+
if (trackDoc)
|
2380
|
+
res = trackDoc.find((tr) => tr.userId === userId && tr.endTime === null);
|
1903
2381
|
return res;
|
1904
2382
|
}
|
1905
2383
|
return null;
|
1906
2384
|
}
|
1907
2385
|
async createTimeRecord(userId, orgId, request) {
|
1908
2386
|
try {
|
1909
|
-
const response = await this.
|
1910
|
-
upsert: true,
|
1911
|
-
new: true,
|
1912
|
-
projection: { userId, orgId, timeRecords: { $elemMatch: { startTime: request.startTime } } },
|
1913
|
-
});
|
2387
|
+
const response = await this.timeRecordsModel.create(Object.assign(Object.assign({}, request), { orgId, userId }));
|
1914
2388
|
return response.toObject();
|
1915
2389
|
}
|
1916
2390
|
catch (err) {
|
@@ -1921,21 +2395,12 @@ let TimeRecordRepository = class TimeRecordRepository {
|
|
1921
2395
|
try {
|
1922
2396
|
if (recordId === null || recordId === undefined)
|
1923
2397
|
throw new Error('TimeRecord id not specified!');
|
1924
|
-
|
1925
|
-
|
1926
|
-
setRequest = Object.assign(Object.assign({}, setRequest), { [`timeRecords.$.${key}`]: value });
|
1927
|
-
});
|
1928
|
-
const response = await this.timeTrackerModel.findOneAndUpdate({ orgId, timeRecords: { $elemMatch: { _id: recordId } } }, {
|
1929
|
-
$set: Object.assign({}, setRequest),
|
2398
|
+
const response = await this.timeRecordsModel.findOneAndUpdate({ orgId, _id: recordId }, {
|
2399
|
+
$set: Object.assign({}, request),
|
1930
2400
|
}, {
|
1931
2401
|
new: true,
|
1932
|
-
projection: {
|
1933
|
-
userId,
|
1934
|
-
orgId,
|
1935
|
-
timeRecords: { $elemMatch: { _id: recordId } },
|
1936
|
-
},
|
1937
2402
|
});
|
1938
|
-
return response.toObject();
|
2403
|
+
return response === null || response === void 0 ? void 0 : response.toObject();
|
1939
2404
|
}
|
1940
2405
|
catch (err) {
|
1941
2406
|
throw new Error(err.message);
|
@@ -1943,15 +2408,11 @@ let TimeRecordRepository = class TimeRecordRepository {
|
|
1943
2408
|
}
|
1944
2409
|
async removeTimeRecord(userId, orgId, recordId) {
|
1945
2410
|
try {
|
1946
|
-
const result = await this.
|
1947
|
-
|
1948
|
-
}, {
|
1949
|
-
$pull: { timeRecords: { _id: recordId } },
|
1950
|
-
});
|
1951
|
-
if (result.nModified !== 1) {
|
2411
|
+
const result = await this.timeRecordsModel.remove({ userId, orgId, _id: recordId });
|
2412
|
+
if (result.n !== 1) {
|
1952
2413
|
throw new Error('TimeRecord is not modified');
|
1953
2414
|
}
|
1954
|
-
return { userId, orgId,
|
2415
|
+
return { userId, orgId, _id: recordId };
|
1955
2416
|
}
|
1956
2417
|
catch (err) {
|
1957
2418
|
throw new Error(err.message);
|
@@ -1959,14 +2420,12 @@ let TimeRecordRepository = class TimeRecordRepository {
|
|
1959
2420
|
}
|
1960
2421
|
async removeDurationTimeRecords(userId, orgId, startTime, endTime, projectId) {
|
1961
2422
|
try {
|
1962
|
-
const trackerDoc = await this.
|
2423
|
+
const trackerDoc = await this.timeRecordsModel.find({ orgId });
|
1963
2424
|
if (trackerDoc && trackerDoc.length > 0) {
|
1964
|
-
const timeRecords = trackerDoc
|
1965
|
-
|
1966
|
-
|
1967
|
-
}
|
1968
|
-
timeRecords,
|
1969
|
-
});
|
2425
|
+
const timeRecords = trackerDoc.filter((tr) => tr.startTime > startTime && tr.startTime < endTime && tr.projectId === projectId);
|
2426
|
+
for (const record of timeRecords) {
|
2427
|
+
await this.timeRecordsModel.remove({ _id: record._id });
|
2428
|
+
}
|
1970
2429
|
return true;
|
1971
2430
|
}
|
1972
2431
|
return false;
|
@@ -1975,20 +2434,11 @@ let TimeRecordRepository = class TimeRecordRepository {
|
|
1975
2434
|
throw new Error(err.message);
|
1976
2435
|
}
|
1977
2436
|
}
|
1978
|
-
async approveTimeRecords(orgId, sheetId,
|
2437
|
+
async approveTimeRecords(orgId, sheetId, timeRecordsId) {
|
1979
2438
|
try {
|
1980
|
-
|
1981
|
-
orgId,
|
1982
|
-
}
|
1983
|
-
multi: true,
|
1984
|
-
arrayFilters: [
|
1985
|
-
{
|
1986
|
-
'el.startTime': { $gte: startDate },
|
1987
|
-
'el.endTime': { $lte: endDate },
|
1988
|
-
'el.timesheetId': null,
|
1989
|
-
},
|
1990
|
-
],
|
1991
|
-
});
|
2439
|
+
for (const id of timeRecordsId) {
|
2440
|
+
const res = await this.timeRecordsModel.updateOne({ orgId, _id: id }, { $set: { 'timesheetId': sheetId } });
|
2441
|
+
}
|
1992
2442
|
}
|
1993
2443
|
catch (e) {
|
1994
2444
|
this.logger.debug('approveTimeRecords =>', e.message);
|
@@ -1997,15 +2447,11 @@ let TimeRecordRepository = class TimeRecordRepository {
|
|
1997
2447
|
}
|
1998
2448
|
async disapproveTimeRecords(orgId, sheetId) {
|
1999
2449
|
try {
|
2000
|
-
await this.
|
2450
|
+
const res = await this.timeRecordsModel.updateMany({
|
2001
2451
|
orgId,
|
2002
|
-
|
2452
|
+
timesheetId: sheetId
|
2453
|
+
}, { $set: { 'timesheetId': null } }, {
|
2003
2454
|
multi: true,
|
2004
|
-
arrayFilters: [
|
2005
|
-
{
|
2006
|
-
'el.timesheetId': sheetId,
|
2007
|
-
},
|
2008
|
-
],
|
2009
2455
|
});
|
2010
2456
|
}
|
2011
2457
|
catch (e) {
|
@@ -2046,17 +2492,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
2046
2492
|
exports.TimesheetRepository = void 0;
|
2047
2493
|
const inversify_1 = __webpack_require__(/*! inversify */ "inversify");
|
2048
2494
|
const core_1 = __webpack_require__(/*! @common-stack/core */ "@common-stack/core");
|
2049
|
-
const
|
2495
|
+
const timesheets_model_1 = __webpack_require__(/*! ../models/timesheets-model */ "./src/store/models/timesheets-model.ts");
|
2050
2496
|
let TimesheetRepository = class TimesheetRepository {
|
2051
2497
|
constructor(db, logger, broker) {
|
2052
2498
|
this.broker = broker;
|
2053
2499
|
this.logger = logger.child({ className: 'TimesheetRepository' });
|
2054
|
-
this.
|
2500
|
+
this.timesheetsModel = timesheets_model_1.TimesheetsModelFunc(db);
|
2055
2501
|
}
|
2056
2502
|
async getOrganizationTimesheets(orgId) {
|
2057
|
-
const trackDoc = await this.
|
2058
|
-
if (trackDoc && trackDoc
|
2059
|
-
return trackDoc
|
2503
|
+
const trackDoc = await this.timesheetsModel.find({ orgId });
|
2504
|
+
if (trackDoc && trackDoc) {
|
2505
|
+
return trackDoc;
|
2060
2506
|
}
|
2061
2507
|
return [];
|
2062
2508
|
}
|
@@ -2066,7 +2512,7 @@ let TimesheetRepository = class TimesheetRepository {
|
|
2066
2512
|
}
|
2067
2513
|
async createTimesheet(userId, orgId, request) {
|
2068
2514
|
try {
|
2069
|
-
const response = await this.
|
2515
|
+
const response = await this.timesheetsModel.create(Object.assign({ orgId }, request));
|
2070
2516
|
return true;
|
2071
2517
|
}
|
2072
2518
|
catch (err) {
|
@@ -2075,7 +2521,7 @@ let TimesheetRepository = class TimesheetRepository {
|
|
2075
2521
|
}
|
2076
2522
|
async updateTimesheet(orgId, sheetId, request) {
|
2077
2523
|
try {
|
2078
|
-
const response = await this.
|
2524
|
+
const response = await this.timesheetsModel.update({ orgId, _id: sheetId }, { $set: Object.assign({}, request) });
|
2079
2525
|
return response;
|
2080
2526
|
}
|
2081
2527
|
catch (err) {
|
@@ -2084,12 +2530,12 @@ let TimesheetRepository = class TimesheetRepository {
|
|
2084
2530
|
}
|
2085
2531
|
async updateTimesheetStatus(orgId, sheetId, state) {
|
2086
2532
|
try {
|
2087
|
-
const response = await this.
|
2533
|
+
const response = await this.timesheetsModel.update({
|
2088
2534
|
orgId,
|
2089
|
-
|
2535
|
+
_id: sheetId,
|
2090
2536
|
}, {
|
2091
2537
|
$set: {
|
2092
|
-
'
|
2538
|
+
'status': state,
|
2093
2539
|
},
|
2094
2540
|
});
|
2095
2541
|
return response;
|
@@ -2100,17 +2546,17 @@ let TimesheetRepository = class TimesheetRepository {
|
|
2100
2546
|
}
|
2101
2547
|
async removeTimesheet(userId, orgId, sheetId) {
|
2102
2548
|
try {
|
2103
|
-
await this.
|
2104
|
-
orgId,
|
2105
|
-
}, {
|
2106
|
-
$pull: { timesheets: { _id: sheetId } },
|
2107
|
-
});
|
2549
|
+
await this.timesheetsModel.remove({ orgId, _id: sheetId });
|
2108
2550
|
return true;
|
2109
2551
|
}
|
2110
2552
|
catch (err) {
|
2111
2553
|
throw new Error(err.message);
|
2112
2554
|
}
|
2113
2555
|
}
|
2556
|
+
async removeTimeRecordIdFromTimesheet(recordId, orgId) {
|
2557
|
+
const res = await this.timesheetsModel.updateMany({ orgId, timeRecordsId: recordId }, { $pullAll: { timeRecordsId: [recordId] } });
|
2558
|
+
return true;
|
2559
|
+
}
|
2114
2560
|
};
|
2115
2561
|
TimesheetRepository = __decorate([
|
2116
2562
|
inversify_1.injectable(),
|
@@ -2211,14 +2657,14 @@ module.exports = require("inversify");
|
|
2211
2657
|
|
2212
2658
|
/***/ }),
|
2213
2659
|
|
2214
|
-
/***/ "
|
2215
|
-
|
2216
|
-
!*** external "
|
2217
|
-
|
2660
|
+
/***/ "moleculer":
|
2661
|
+
/*!****************************!*\
|
2662
|
+
!*** external "moleculer" ***!
|
2663
|
+
\****************************/
|
2218
2664
|
/*! no static exports found */
|
2219
2665
|
/***/ (function(module, exports) {
|
2220
2666
|
|
2221
|
-
module.exports = require("
|
2667
|
+
module.exports = require("moleculer");
|
2222
2668
|
|
2223
2669
|
/***/ }),
|
2224
2670
|
|