@admin-layout/timetracker-module-server 1.0.3-alpha.7 → 1.0.3-alpha.81
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/config/config.d.ts +1 -0
- package/lib/containers/containers.d.ts +3 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +601 -153
- 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 +5 -6
package/lib/index.js
CHANGED
@@ -104,6 +104,7 @@ const { str, num } = envalid;
|
|
104
104
|
exports.config = envalid.cleanEnv(process.env, {
|
105
105
|
MAIL_SEND_DEFAULT_EMAIL: str(),
|
106
106
|
CLIENT_URL: str(),
|
107
|
+
GRAPHQL_URL: str(),
|
107
108
|
});
|
108
109
|
|
109
110
|
|
@@ -126,7 +127,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
126
127
|
o[k2] = m[k];
|
127
128
|
}));
|
128
129
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
129
|
-
for (var p in m) if (p !== "default" && !
|
130
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
130
131
|
};
|
131
132
|
Object.defineProperty(exports, "__esModule", { value: true });
|
132
133
|
__exportStar(__webpack_require__(/*! ./config */ "./src/config/config.ts"), exports);
|
@@ -199,7 +200,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
199
200
|
o[k2] = m[k];
|
200
201
|
}));
|
201
202
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
202
|
-
for (var p in m) if (p !== "default" && !
|
203
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
203
204
|
};
|
204
205
|
Object.defineProperty(exports, "__esModule", { value: true });
|
205
206
|
__exportStar(__webpack_require__(/*! ./constants */ "./src/constants/constants.ts"), exports);
|
@@ -217,20 +218,32 @@ __exportStar(__webpack_require__(/*! ./constants */ "./src/constants/constants.t
|
|
217
218
|
"use strict";
|
218
219
|
|
219
220
|
Object.defineProperty(exports, "__esModule", { value: true });
|
220
|
-
exports.timeTrackerModule = void 0;
|
221
|
+
exports.timeTrackerProxyModule = exports.timeTrackerModule = exports.timeTrackerMailModule = exports.timeTrackerStoreModule = void 0;
|
221
222
|
const inversify_1 = __webpack_require__(/*! inversify */ "inversify");
|
222
223
|
const constants_1 = __webpack_require__(/*! ../constants */ "./src/constants/index.ts");
|
223
224
|
const services_1 = __webpack_require__(/*! ../services */ "./src/services/index.ts");
|
224
225
|
const repository_1 = __webpack_require__(/*! ../store/repository */ "./src/store/repository/index.ts");
|
225
226
|
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
|
-
|
227
|
+
const timeTrackerStoreModule = (setting) => new inversify_1.ContainerModule((bind) => {
|
228
|
+
bind(constants_1.TYPES.ITimeRecordRepository).to(repository_1.TimeRecordRepository).inSingletonScope();
|
229
|
+
bind(constants_1.TYPES.ITimesheetRepository).to(repository_1.TimesheetRepository).inSingletonScope();
|
230
|
+
});
|
231
|
+
exports.timeTrackerStoreModule = timeTrackerStoreModule;
|
232
|
+
const timeTrackerMailModule = (setting) => new inversify_1.ContainerModule((bind) => {
|
231
233
|
bind('MongodbMigration').to(migration_1.TimesheetApprovalMailTemplate).whenTargetNamed(migration_1.TimesheetApprovalMailTemplate.name);
|
232
234
|
bind('MongodbMigration').to(migration_1.TimesheetSubmitMailTemplate).whenTargetNamed(migration_1.TimesheetSubmitMailTemplate.name);
|
233
235
|
});
|
236
|
+
exports.timeTrackerMailModule = timeTrackerMailModule;
|
237
|
+
const timeTrackerModule = (setting) => new inversify_1.ContainerModule((bind) => {
|
238
|
+
bind(constants_1.TYPES.ITimeRecordService).to(services_1.TimeRecordService).inSingletonScope();
|
239
|
+
bind(constants_1.TYPES.ITimesheetService).to(services_1.TimesheetService).inSingletonScope();
|
240
|
+
});
|
241
|
+
exports.timeTrackerModule = timeTrackerModule;
|
242
|
+
const timeTrackerProxyModule = (setting) => new inversify_1.ContainerModule((bind) => {
|
243
|
+
bind(constants_1.TYPES.ITimeRecordService).to(services_1.TimeRecordProxyService).inSingletonScope();
|
244
|
+
bind(constants_1.TYPES.ITimesheetService).to(services_1.TimesheetProxyService).inSingletonScope();
|
245
|
+
});
|
246
|
+
exports.timeTrackerProxyModule = timeTrackerProxyModule;
|
234
247
|
|
235
248
|
|
236
249
|
/***/ }),
|
@@ -252,7 +265,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
252
265
|
o[k2] = m[k];
|
253
266
|
}));
|
254
267
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
255
|
-
for (var p in m) if (p !== "default" && !
|
268
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
256
269
|
};
|
257
270
|
Object.defineProperty(exports, "__esModule", { value: true });
|
258
271
|
__exportStar(__webpack_require__(/*! ./containers */ "./src/containers/containers.ts"), exports);
|
@@ -277,7 +290,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
277
290
|
o[k2] = m[k];
|
278
291
|
}));
|
279
292
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
280
|
-
for (var p in m) if (p !== "default" && !
|
293
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
281
294
|
};
|
282
295
|
Object.defineProperty(exports, "__esModule", { value: true });
|
283
296
|
const server_core_1 = __webpack_require__(/*! @common-stack/server-core */ "@common-stack/server-core");
|
@@ -285,6 +298,7 @@ const module_1 = __webpack_require__(/*! ./module */ "./src/module.ts");
|
|
285
298
|
__exportStar(__webpack_require__(/*! ./constants */ "./src/constants/index.ts"), exports);
|
286
299
|
__exportStar(__webpack_require__(/*! ./store/repository */ "./src/store/repository/index.ts"), exports);
|
287
300
|
__exportStar(__webpack_require__(/*! ./store/models/timetracker-model */ "./src/store/models/timetracker-model.ts"), exports);
|
301
|
+
__exportStar(__webpack_require__(/*! ./containers */ "./src/containers/index.ts"), exports);
|
288
302
|
exports.default = new server_core_1.Feature(module_1.default);
|
289
303
|
|
290
304
|
|
@@ -307,7 +321,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
307
321
|
o[k2] = m[k];
|
308
322
|
}));
|
309
323
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
310
|
-
for (var p in m) if (p !== "default" && !
|
324
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
311
325
|
};
|
312
326
|
Object.defineProperty(exports, "__esModule", { value: true });
|
313
327
|
__exportStar(__webpack_require__(/*! ./service-initialization */ "./src/initialization/service-initialization.ts"), exports);
|
@@ -329,7 +343,7 @@ exports.mainLoadConfigurationPre = void 0;
|
|
329
343
|
const core_1 = __webpack_require__(/*! @workbench-stack/core */ "@workbench-stack/core");
|
330
344
|
const core_2 = __webpack_require__(/*! @common-stack/core */ "@common-stack/core");
|
331
345
|
const preferences_1 = __webpack_require__(/*! ../preferences */ "./src/preferences/index.ts");
|
332
|
-
|
346
|
+
const mainLoadConfigurationPre = async (_, container) => {
|
333
347
|
const logger = container.get(core_2.CommonType.LOGGER);
|
334
348
|
logger.info('PRESTART START: -- load TimeTrackerContribution to registry');
|
335
349
|
const registry = container.get(core_1.TYPES.IRegistry);
|
@@ -337,6 +351,7 @@ exports.mainLoadConfigurationPre = async (_, container) => {
|
|
337
351
|
configurationRegistry.registerConfiguration(preferences_1.TimeTrackerContribution);
|
338
352
|
logger.info('PRESTART ENDS: -- load TimeTrackerContribution to registry');
|
339
353
|
};
|
354
|
+
exports.mainLoadConfigurationPre = mainLoadConfigurationPre;
|
340
355
|
|
341
356
|
|
342
357
|
/***/ }),
|
@@ -371,7 +386,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
371
386
|
o[k2] = m[k];
|
372
387
|
}));
|
373
388
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
374
|
-
for (var p in m) if (p !== "default" && !
|
389
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
375
390
|
};
|
376
391
|
Object.defineProperty(exports, "__esModule", { value: true });
|
377
392
|
__exportStar(__webpack_require__(/*! ./mail-template */ "./src/migration/mail-template.ts"), exports);
|
@@ -507,6 +522,7 @@ const resolvers_1 = __webpack_require__(/*! ./resolvers */ "./src/resolvers/inde
|
|
507
522
|
const constants_1 = __webpack_require__(/*! ./constants */ "./src/constants/index.ts");
|
508
523
|
const initialization_1 = __webpack_require__(/*! ./initialization */ "./src/initialization/index.ts");
|
509
524
|
const preferences_1 = __webpack_require__(/*! ./preferences */ "./src/preferences/index.ts");
|
525
|
+
const plugins_1 = __webpack_require__(/*! ./plugins */ "./src/plugins/index.ts");
|
510
526
|
const createServiceFunc = (container) => ({
|
511
527
|
timeRecordService: container.get(constants_1.TYPES.ITimeRecordService),
|
512
528
|
timesheetService: container.get(constants_1.TYPES.ITimesheetService),
|
@@ -514,8 +530,10 @@ const createServiceFunc = (container) => ({
|
|
514
530
|
exports.default = new server_core_1.Feature({
|
515
531
|
schema: schema_1.schema,
|
516
532
|
createResolversFunc: resolvers_1.resolvers,
|
517
|
-
createContainerFunc: [containers_1.
|
533
|
+
createContainerFunc: [containers_1.timeTrackerProxyModule, containers_1.timeTrackerMailModule],
|
534
|
+
createHemeraContainerFunc: [containers_1.timeTrackerModule, containers_1.timeTrackerStoreModule],
|
518
535
|
createServiceFunc,
|
536
|
+
addBrokerClientServiceClass: [plugins_1.TimeRecordMoleculerService, plugins_1.TimesheetMoleculerService],
|
519
537
|
preStartFunc: [initialization_1.mainLoadConfigurationPre],
|
520
538
|
addPermissions: {
|
521
539
|
createPermissions: [preferences_1.TimeTrackerRolesContribution],
|
@@ -526,6 +544,186 @@ exports.default = new server_core_1.Feature({
|
|
526
544
|
});
|
527
545
|
|
528
546
|
|
547
|
+
/***/ }),
|
548
|
+
|
549
|
+
/***/ "./src/plugins/index.ts":
|
550
|
+
/*!******************************!*\
|
551
|
+
!*** ./src/plugins/index.ts ***!
|
552
|
+
\******************************/
|
553
|
+
/*! no static exports found */
|
554
|
+
/***/ (function(module, exports, __webpack_require__) {
|
555
|
+
|
556
|
+
"use strict";
|
557
|
+
|
558
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
559
|
+
if (k2 === undefined) k2 = k;
|
560
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
561
|
+
}) : (function(o, m, k, k2) {
|
562
|
+
if (k2 === undefined) k2 = k;
|
563
|
+
o[k2] = m[k];
|
564
|
+
}));
|
565
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
566
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
567
|
+
};
|
568
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
569
|
+
__exportStar(__webpack_require__(/*! ./timesheet-moleculer-service */ "./src/plugins/timesheet-moleculer-service.ts"), exports);
|
570
|
+
__exportStar(__webpack_require__(/*! ./timerecord-moleculer-service */ "./src/plugins/timerecord-moleculer-service.ts"), exports);
|
571
|
+
|
572
|
+
|
573
|
+
/***/ }),
|
574
|
+
|
575
|
+
/***/ "./src/plugins/timerecord-moleculer-service.ts":
|
576
|
+
/*!*****************************************************!*\
|
577
|
+
!*** ./src/plugins/timerecord-moleculer-service.ts ***!
|
578
|
+
\*****************************************************/
|
579
|
+
/*! no static exports found */
|
580
|
+
/***/ (function(module, exports, __webpack_require__) {
|
581
|
+
|
582
|
+
"use strict";
|
583
|
+
|
584
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
585
|
+
var t = {};
|
586
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
587
|
+
t[p] = s[p];
|
588
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
589
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
590
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
591
|
+
t[p[i]] = s[p[i]];
|
592
|
+
}
|
593
|
+
return t;
|
594
|
+
};
|
595
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
596
|
+
exports.TimeRecordMoleculerService = void 0;
|
597
|
+
const moleculer_1 = __webpack_require__(/*! moleculer */ "moleculer");
|
598
|
+
const platform_server_1 = __webpack_require__(/*! @adminide-stack/platform-server */ "@adminide-stack/platform-server");
|
599
|
+
const config_1 = __webpack_require__(/*! ../config */ "./src/config/index.ts");
|
600
|
+
class TimeRecordMoleculerService extends moleculer_1.Service {
|
601
|
+
constructor(broker, _a) {
|
602
|
+
var { container } = _a, settings = __rest(_a, ["container"]);
|
603
|
+
super(broker);
|
604
|
+
const topic = "TimeRecord" /* TimeRecord */;
|
605
|
+
this.parseServiceSchema({
|
606
|
+
name: topic,
|
607
|
+
mixins: [platform_server_1.ApolloClientMixin],
|
608
|
+
settings: {
|
609
|
+
apolloClient: {
|
610
|
+
serverUri: config_1.config.GRAPHQL_URL,
|
611
|
+
},
|
612
|
+
},
|
613
|
+
actions: {
|
614
|
+
["getTimeRecords" /* getTimeRecords */]: {
|
615
|
+
handler: async (ctx) => this.timerecordService.getTimeRecords(ctx.params.orgId, ctx.params.userId),
|
616
|
+
},
|
617
|
+
["getDurationTimeRecords" /* getDurationTimeRecords */]: {
|
618
|
+
handler: async (ctx) => this.timerecordService.getDurationTimeRecords(ctx.params.orgId, ctx.params.startTime, ctx.params.endTime, ctx.params.userId),
|
619
|
+
},
|
620
|
+
["getPlayingTimeRecord" /* getPlayingTimeRecord */]: {
|
621
|
+
handler: async (ctx) => this.timerecordService.getPlayingTimeRecord(ctx.params.userId, ctx.params.orgId),
|
622
|
+
},
|
623
|
+
["createTimeRecord" /* createTimeRecord */]: {
|
624
|
+
handler: async (ctx) => this.timerecordService.createTimeRecord(ctx.params.userId, ctx.params.orgId, ctx.params.request),
|
625
|
+
},
|
626
|
+
["updateTimeRecord" /* updateTimeRecord */]: {
|
627
|
+
handler: async (ctx) => this.timerecordService.updateTimeRecord(ctx.params.userId, ctx.params.orgId, ctx.params.recordId, ctx.params.request),
|
628
|
+
},
|
629
|
+
["removeTimeRecord" /* removeTimeRecord */]: {
|
630
|
+
handler: async (ctx) => this.timerecordService.removeTimeRecord(ctx.params.userId, ctx.params.orgId, ctx.params.recordId),
|
631
|
+
},
|
632
|
+
["removeDurationTimeRecords" /* removeDurationTimeRecords */]: {
|
633
|
+
handler: async (ctx) => this.timerecordService.removeDurationTimeRecords(ctx.params.userId, ctx.params.orgId, ctx.params.startTime, ctx.params.endTime, ctx.params.projectId),
|
634
|
+
},
|
635
|
+
["approveTimeRecords" /* approveTimeRecords */]: {
|
636
|
+
handler: async (ctx) => this.timerecordService.approveTimeRecords(ctx.params.orgId, ctx.params.sheetId, ctx.params.timeRecordsId),
|
637
|
+
},
|
638
|
+
["disapproveTimeRecords" /* disapproveTimeRecords */]: {
|
639
|
+
handler: async (ctx) => this.timerecordService.disapproveTimeRecords(ctx.params.orgId, ctx.params.sheetId),
|
640
|
+
},
|
641
|
+
},
|
642
|
+
});
|
643
|
+
}
|
644
|
+
}
|
645
|
+
exports.TimeRecordMoleculerService = TimeRecordMoleculerService;
|
646
|
+
|
647
|
+
|
648
|
+
/***/ }),
|
649
|
+
|
650
|
+
/***/ "./src/plugins/timesheet-moleculer-service.ts":
|
651
|
+
/*!****************************************************!*\
|
652
|
+
!*** ./src/plugins/timesheet-moleculer-service.ts ***!
|
653
|
+
\****************************************************/
|
654
|
+
/*! no static exports found */
|
655
|
+
/***/ (function(module, exports, __webpack_require__) {
|
656
|
+
|
657
|
+
"use strict";
|
658
|
+
|
659
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
660
|
+
var t = {};
|
661
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
662
|
+
t[p] = s[p];
|
663
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
664
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
665
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
666
|
+
t[p[i]] = s[p[i]];
|
667
|
+
}
|
668
|
+
return t;
|
669
|
+
};
|
670
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
671
|
+
exports.TimesheetMoleculerService = void 0;
|
672
|
+
const moleculer_1 = __webpack_require__(/*! moleculer */ "moleculer");
|
673
|
+
const platform_server_1 = __webpack_require__(/*! @adminide-stack/platform-server */ "@adminide-stack/platform-server");
|
674
|
+
const core_1 = __webpack_require__(/*! @common-stack/core */ "@common-stack/core");
|
675
|
+
const constants_1 = __webpack_require__(/*! ../constants */ "./src/constants/index.ts");
|
676
|
+
const config_1 = __webpack_require__(/*! ../config */ "./src/config/index.ts");
|
677
|
+
class TimesheetMoleculerService extends moleculer_1.Service {
|
678
|
+
constructor(broker, _a) {
|
679
|
+
var { container } = _a, settings = __rest(_a, ["container"]);
|
680
|
+
super(broker);
|
681
|
+
this.container = container;
|
682
|
+
const topic = "Timesheet" /* Timesheet */;
|
683
|
+
this.parseServiceSchema({
|
684
|
+
name: topic,
|
685
|
+
mixins: [platform_server_1.ApolloClientMixin],
|
686
|
+
settings: {
|
687
|
+
apolloClient: {
|
688
|
+
serverUri: config_1.config.GRAPHQL_URL,
|
689
|
+
},
|
690
|
+
},
|
691
|
+
events: {
|
692
|
+
["onRemoveTimeRecordIdFromTimesheet" /* onRemoveTimeRecordIdFromTimesheet */]: {
|
693
|
+
handler: async (ctx) => this.timesheetService.removeTimeRecordIdFromTimesheet(ctx.params.recordId, ctx.params.orgId),
|
694
|
+
},
|
695
|
+
},
|
696
|
+
actions: {
|
697
|
+
["getTimesheets" /* getTimesheets */]: {
|
698
|
+
handler: async (ctx) => this.timesheetService.getTimesheets(ctx.params.orgId),
|
699
|
+
},
|
700
|
+
["getTimesheetsWithTotalHours" /* getTimesheetsWithTotalHours */]: {
|
701
|
+
handler: async (ctx) => this.timesheetService.getTimesheetsWithTotalHours(ctx.params.orgId, ctx.params.userId),
|
702
|
+
},
|
703
|
+
["getDurationTimesheets" /* getDurationTimesheets */]: {
|
704
|
+
handler: async (ctx) => this.timesheetService.getDurationTimesheets(ctx.params.orgId, ctx.params.start, ctx.params.end),
|
705
|
+
},
|
706
|
+
["createTimesheet" /* createTimesheet */]: {
|
707
|
+
handler: async (ctx) => this.timesheetService.createTimesheet(ctx.params.userId, ctx.params.orgId, ctx.params.request),
|
708
|
+
},
|
709
|
+
["updateTimesheet" /* updateTimesheet */]: {
|
710
|
+
handler: async (ctx) => this.timesheetService.updateTimesheet(ctx.params.userId, ctx.params.orgId, ctx.params.sheetId, ctx.params.request, ctx.params.userContext),
|
711
|
+
},
|
712
|
+
["removeTimesheet" /* removeTimesheet */]: {
|
713
|
+
handler: async (ctx) => this.timesheetService.removeTimesheet(ctx.params.userId, ctx.params.orgId, ctx.params.sheetId),
|
714
|
+
},
|
715
|
+
["updateTimesheetStatus" /* updateTimesheetStatus */]: {
|
716
|
+
handler: async (ctx) => this.timesheetService.updateTimesheetStatus(ctx.params.orgId, ctx.params.sheetId, ctx.params.state),
|
717
|
+
},
|
718
|
+
},
|
719
|
+
});
|
720
|
+
this.container.bind(core_1.ClientTypes.ApolloClient).toConstantValue(this.apolloClient);
|
721
|
+
this.timesheetService = this.container.get(constants_1.TYPES.ITimesheetService);
|
722
|
+
}
|
723
|
+
}
|
724
|
+
exports.TimesheetMoleculerService = TimesheetMoleculerService;
|
725
|
+
|
726
|
+
|
529
727
|
/***/ }),
|
530
728
|
|
531
729
|
/***/ "./src/preferences/index.ts":
|
@@ -545,7 +743,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
545
743
|
o[k2] = m[k];
|
546
744
|
}));
|
547
745
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
548
|
-
for (var p in m) if (p !== "default" && !
|
746
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
549
747
|
};
|
550
748
|
Object.defineProperty(exports, "__esModule", { value: true });
|
551
749
|
__exportStar(__webpack_require__(/*! ./settings */ "./src/preferences/settings/index.ts"), exports);
|
@@ -571,7 +769,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
571
769
|
o[k2] = m[k];
|
572
770
|
}));
|
573
771
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
574
|
-
for (var p in m) if (p !== "default" && !
|
772
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
575
773
|
};
|
576
774
|
Object.defineProperty(exports, "__esModule", { value: true });
|
577
775
|
__exportStar(__webpack_require__(/*! ./timing-permissions-contribution */ "./src/preferences/permissions/timing-permissions-contribution.ts"), exports);
|
@@ -1219,7 +1417,7 @@ exports.resolvers = [timerecord_resolver_1.resolver, timesheet_resolver_1.resolv
|
|
1219
1417
|
Object.defineProperty(exports, "__esModule", { value: true });
|
1220
1418
|
exports.resolver = void 0;
|
1221
1419
|
const graphql_subscriptions_1 = __webpack_require__(/*! graphql-subscriptions */ "graphql-subscriptions");
|
1222
|
-
|
1420
|
+
const resolver = (options) => ({
|
1223
1421
|
TimeRecord: {
|
1224
1422
|
id: (root) => root.id || root._id,
|
1225
1423
|
},
|
@@ -1274,6 +1472,7 @@ exports.resolver = (options) => ({
|
|
1274
1472
|
},
|
1275
1473
|
},
|
1276
1474
|
});
|
1475
|
+
exports.resolver = resolver;
|
1277
1476
|
|
1278
1477
|
|
1279
1478
|
/***/ }),
|
@@ -1290,7 +1489,7 @@ exports.resolver = (options) => ({
|
|
1290
1489
|
Object.defineProperty(exports, "__esModule", { value: true });
|
1291
1490
|
exports.resolver = void 0;
|
1292
1491
|
/* eslint-disable no-underscore-dangle */
|
1293
|
-
|
1492
|
+
const resolver = (options) => ({
|
1294
1493
|
Query: {
|
1295
1494
|
getTimesheets: (root, args, { timesheetService, userContext }) => {
|
1296
1495
|
options.logger.trace('(Query.getTimeSheets) args %j', args);
|
@@ -1322,6 +1521,7 @@ exports.resolver = (options) => ({
|
|
1322
1521
|
},
|
1323
1522
|
},
|
1324
1523
|
});
|
1524
|
+
exports.resolver = resolver;
|
1325
1525
|
|
1326
1526
|
|
1327
1527
|
/***/ }),
|
@@ -1369,7 +1569,7 @@ exports.schema = schema;
|
|
1369
1569
|
|
1370
1570
|
"use strict";
|
1371
1571
|
__webpack_require__.r(__webpack_exports__);
|
1372
|
-
/* harmony default export */ __webpack_exports__["default"] = ("type TimeRecord {\n id:
|
1572
|
+
/* 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
1573
|
|
1374
1574
|
/***/ }),
|
1375
1575
|
|
@@ -1382,7 +1582,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
1382
1582
|
|
1383
1583
|
"use strict";
|
1384
1584
|
__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");
|
1585
|
+
/* 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
1586
|
|
1387
1587
|
/***/ }),
|
1388
1588
|
|
@@ -1416,11 +1616,88 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
1416
1616
|
o[k2] = m[k];
|
1417
1617
|
}));
|
1418
1618
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
1419
|
-
for (var p in m) if (p !== "default" && !
|
1619
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
1420
1620
|
};
|
1421
1621
|
Object.defineProperty(exports, "__esModule", { value: true });
|
1422
1622
|
__exportStar(__webpack_require__(/*! ./timesheet-service */ "./src/services/timesheet-service.ts"), exports);
|
1423
1623
|
__exportStar(__webpack_require__(/*! ./timerecord-service */ "./src/services/timerecord-service.ts"), exports);
|
1624
|
+
__exportStar(__webpack_require__(/*! ./timerecord-proxy-service */ "./src/services/timerecord-proxy-service.ts"), exports);
|
1625
|
+
__exportStar(__webpack_require__(/*! ./timesheet-proxy-service */ "./src/services/timesheet-proxy-service.ts"), exports);
|
1626
|
+
|
1627
|
+
|
1628
|
+
/***/ }),
|
1629
|
+
|
1630
|
+
/***/ "./src/services/timerecord-proxy-service.ts":
|
1631
|
+
/*!**************************************************!*\
|
1632
|
+
!*** ./src/services/timerecord-proxy-service.ts ***!
|
1633
|
+
\**************************************************/
|
1634
|
+
/*! no static exports found */
|
1635
|
+
/***/ (function(module, exports, __webpack_require__) {
|
1636
|
+
|
1637
|
+
"use strict";
|
1638
|
+
|
1639
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
1640
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
1641
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
1642
|
+
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;
|
1643
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
1644
|
+
};
|
1645
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
1646
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
1647
|
+
};
|
1648
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
1649
|
+
exports.TimeRecordProxyService = void 0;
|
1650
|
+
const inversify_1 = __webpack_require__(/*! inversify */ "inversify");
|
1651
|
+
const core_1 = __webpack_require__(/*! @common-stack/core */ "@common-stack/core");
|
1652
|
+
let TimeRecordProxyService = class TimeRecordProxyService {
|
1653
|
+
constructor(broker, logger) {
|
1654
|
+
this.broker = broker;
|
1655
|
+
this.topic = "TimeRecord" /* TimeRecord */;
|
1656
|
+
this.logger = logger.child({ className: 'TimeRecordProxyService' });
|
1657
|
+
}
|
1658
|
+
approveTimeRecords(orgId, sheetId, timeRecordsId) {
|
1659
|
+
return this.callAction("approveTimeRecords" /* approveTimeRecords */, { orgId, sheetId, timeRecordsId });
|
1660
|
+
}
|
1661
|
+
createTimeRecord(userId, orgId, request) {
|
1662
|
+
return this.callAction("createTimeRecord" /* createTimeRecord */, { userId, orgId, request });
|
1663
|
+
}
|
1664
|
+
disapproveTimeRecords(orgId, sheetId) {
|
1665
|
+
return this.callAction("disapproveTimeRecords" /* disapproveTimeRecords */, { orgId, sheetId });
|
1666
|
+
}
|
1667
|
+
getDurationTimeRecords(orgId, startTime, endTime, userId) {
|
1668
|
+
return this.callAction("getDurationTimeRecords" /* getDurationTimeRecords */, { orgId, startTime, endTime, userId });
|
1669
|
+
}
|
1670
|
+
getPlayingTimeRecord(userId, orgId) {
|
1671
|
+
return this.callAction("getPlayingTimeRecord" /* getPlayingTimeRecord */, { userId, orgId });
|
1672
|
+
}
|
1673
|
+
getTimeRecords(orgId, userId) {
|
1674
|
+
return this.callAction("getTimeRecords" /* getTimeRecords */, { orgId, userId });
|
1675
|
+
}
|
1676
|
+
removeDurationTimeRecords(userId, orgId, startTime, endTime, projectId) {
|
1677
|
+
return this.callAction("removeDurationTimeRecords" /* removeDurationTimeRecords */, {
|
1678
|
+
userId,
|
1679
|
+
orgId,
|
1680
|
+
startTime,
|
1681
|
+
endTime,
|
1682
|
+
projectId,
|
1683
|
+
});
|
1684
|
+
}
|
1685
|
+
removeTimeRecord(userId, orgId, recordId) {
|
1686
|
+
return this.callAction("removeTimeRecord" /* removeTimeRecord */, { userId, orgId, recordId });
|
1687
|
+
}
|
1688
|
+
updateTimeRecord(userId, orgId, recordId, request) {
|
1689
|
+
return this.callAction("updateTimeRecord" /* updateTimeRecord */, { userId, orgId, recordId, request });
|
1690
|
+
}
|
1691
|
+
async callAction(command, params) {
|
1692
|
+
return this.broker.call(`${this.topic}.${command}`, params);
|
1693
|
+
}
|
1694
|
+
};
|
1695
|
+
TimeRecordProxyService = __decorate([
|
1696
|
+
inversify_1.injectable(),
|
1697
|
+
__param(0, inversify_1.inject(core_1.CommonType.MOLECULER_BROKER)),
|
1698
|
+
__param(1, inversify_1.inject('Logger'))
|
1699
|
+
], TimeRecordProxyService);
|
1700
|
+
exports.TimeRecordProxyService = TimeRecordProxyService;
|
1424
1701
|
|
1425
1702
|
|
1426
1703
|
/***/ }),
|
@@ -1446,13 +1723,15 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
1446
1723
|
Object.defineProperty(exports, "__esModule", { value: true });
|
1447
1724
|
exports.TimeRecordService = void 0;
|
1448
1725
|
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");
|
1726
|
+
const core_1 = __webpack_require__(/*! @common-stack/core */ "@common-stack/core");
|
1451
1727
|
const constants_1 = __webpack_require__(/*! ../constants */ "./src/constants/index.ts");
|
1728
|
+
const moment = __webpack_require__(/*! moment */ "moment");
|
1452
1729
|
let TimeRecordService = class TimeRecordService {
|
1453
|
-
constructor(timeRecordRepository,
|
1730
|
+
constructor(timeRecordRepository,
|
1731
|
+
// @inject(ServerTypes.IPreferenceEditorService)
|
1732
|
+
// private preferencesService: IPreferencesService,
|
1733
|
+
broker, pubsub, logger) {
|
1454
1734
|
this.timeRecordRepository = timeRecordRepository;
|
1455
|
-
this.preferencesService = preferencesService;
|
1456
1735
|
this.broker = broker;
|
1457
1736
|
this.pubsub = pubsub;
|
1458
1737
|
this.logger = logger;
|
@@ -1461,7 +1740,7 @@ let TimeRecordService = class TimeRecordService {
|
|
1461
1740
|
return this.timeRecordRepository.getTimeRecords(orgId, userId);
|
1462
1741
|
}
|
1463
1742
|
async getDurationTimeRecords(orgId, startTime, endTime, userId) {
|
1464
|
-
const timeRecords = await this.timeRecordRepository.getTimeRecords(orgId, userId, startTime, endTime);
|
1743
|
+
const timeRecords = await this.timeRecordRepository.getTimeRecords(orgId, userId, startTime && moment(startTime).toDate(), endTime && moment(endTime).toDate());
|
1465
1744
|
return timeRecords.filter((r) => r.endTime !== null);
|
1466
1745
|
}
|
1467
1746
|
async getPlayingTimeRecord(userId, orgId) {
|
@@ -1469,13 +1748,12 @@ let TimeRecordService = class TimeRecordService {
|
|
1469
1748
|
}
|
1470
1749
|
async createTimeRecord(userId, orgId, request) {
|
1471
1750
|
const data = await this.timeRecordRepository.createTimeRecord(userId, orgId, request);
|
1472
|
-
|
1473
|
-
if (timeRecord) {
|
1751
|
+
if (data) {
|
1474
1752
|
const record = {
|
1475
1753
|
orgName: data.orgId,
|
1476
|
-
userId:
|
1754
|
+
userId: data.userId,
|
1477
1755
|
mutation: "TimeRecordCreated" /* TimeRecordCreated */,
|
1478
|
-
timeRecord,
|
1756
|
+
timeRecord: data,
|
1479
1757
|
};
|
1480
1758
|
this.pubsub.publish("TimeRecordCreated" /* TimeRecordCreated */, { SubscribeToTimeTracker: record });
|
1481
1759
|
}
|
@@ -1483,13 +1761,12 @@ let TimeRecordService = class TimeRecordService {
|
|
1483
1761
|
}
|
1484
1762
|
async updateTimeRecord(userId, orgId, recordId, request) {
|
1485
1763
|
const data = await this.timeRecordRepository.updateTimeRecord(userId, orgId, recordId, request);
|
1486
|
-
|
1487
|
-
if (timeRecord) {
|
1764
|
+
if (data) {
|
1488
1765
|
const record = {
|
1489
1766
|
orgName: data.orgId,
|
1490
|
-
userId:
|
1767
|
+
userId: data.userId,
|
1491
1768
|
mutation: "TimeRecordUpdated" /* TimeRecordUpdated */,
|
1492
|
-
timeRecord,
|
1769
|
+
timeRecord: data,
|
1493
1770
|
};
|
1494
1771
|
this.pubsub.publish("TimeRecordUpdated" /* TimeRecordUpdated */, { SubscribeToTimeTracker: record });
|
1495
1772
|
}
|
@@ -1501,16 +1778,43 @@ let TimeRecordService = class TimeRecordService {
|
|
1501
1778
|
orgName: data.orgId,
|
1502
1779
|
userId: data.userId,
|
1503
1780
|
mutation: "TimeRecordDeleted" /* TimeRecordDeleted */,
|
1504
|
-
timeRecord: data
|
1781
|
+
timeRecord: data,
|
1505
1782
|
};
|
1783
|
+
// remove record activities
|
1784
|
+
await this.broker.broadcast("onRemoveTimeRecord" /* onRemoveTimeRecord */, { userId, orgId, recordId }, [
|
1785
|
+
"TimeRecord" /* TimeRecord */,
|
1786
|
+
"Timesheet" /* Timesheet */,
|
1787
|
+
"Activity" /* Activity */,
|
1788
|
+
]);
|
1789
|
+
//remove record id from timesheet
|
1790
|
+
await this.broker.broadcast("onRemoveTimeRecordIdFromTimesheet" /* onRemoveTimeRecordIdFromTimesheet */, { recordId, orgId }, [
|
1791
|
+
"TimeRecord" /* TimeRecord */,
|
1792
|
+
"Timesheet" /* Timesheet */,
|
1793
|
+
]);
|
1506
1794
|
this.pubsub.publish("TimeRecordDeleted" /* TimeRecordDeleted */, { SubscribeToTimeTracker: record });
|
1507
1795
|
return true;
|
1508
1796
|
}
|
1509
1797
|
async removeDurationTimeRecords(userId, orgId, startTime, endTime, projectId) {
|
1510
|
-
|
1798
|
+
const records = await this.timeRecordRepository.getTimeRecords(orgId, userId);
|
1799
|
+
if (records && records.length > 0) {
|
1800
|
+
const timeRecords = records.filter((tr) => tr.startTime > moment(startTime) && tr.startTime < moment(endTime) && tr.projectId === projectId);
|
1801
|
+
for (const record of timeRecords) {
|
1802
|
+
await this.broker.broadcast("onRemoveTimeRecord" /* onRemoveTimeRecord */, { userId, orgId, recordId: record._id }, [
|
1803
|
+
"TimeRecord" /* TimeRecord */,
|
1804
|
+
"Timesheet" /* Timesheet */,
|
1805
|
+
"Activity" /* Activity */,
|
1806
|
+
]);
|
1807
|
+
//remove record id from timesheet
|
1808
|
+
await this.broker.broadcast("onRemoveTimeRecordIdFromTimesheet" /* onRemoveTimeRecordIdFromTimesheet */, { recordId: record._id, orgId }, [
|
1809
|
+
"TimeRecord" /* TimeRecord */,
|
1810
|
+
"Timesheet" /* Timesheet */,
|
1811
|
+
]);
|
1812
|
+
}
|
1813
|
+
}
|
1814
|
+
return this.timeRecordRepository.removeDurationTimeRecords(userId, orgId, moment(startTime), moment(endTime), projectId);
|
1511
1815
|
}
|
1512
|
-
async approveTimeRecords(orgId, sheetId,
|
1513
|
-
this.timeRecordRepository.approveTimeRecords(orgId, sheetId,
|
1816
|
+
async approveTimeRecords(orgId, sheetId, timeRecordsId) {
|
1817
|
+
this.timeRecordRepository.approveTimeRecords(orgId, sheetId, timeRecordsId);
|
1514
1818
|
}
|
1515
1819
|
async disapproveTimeRecords(orgId, sheetId) {
|
1516
1820
|
this.timeRecordRepository.disapproveTimeRecords(orgId, sheetId);
|
@@ -1519,14 +1823,79 @@ let TimeRecordService = class TimeRecordService {
|
|
1519
1823
|
TimeRecordService = __decorate([
|
1520
1824
|
inversify_1.injectable(),
|
1521
1825
|
__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'))
|
1826
|
+
__param(1, inversify_1.inject(core_1.CommonType.MOLECULER_BROKER)),
|
1827
|
+
__param(2, inversify_1.inject('PubSub')),
|
1828
|
+
__param(3, inversify_1.inject('Logger'))
|
1526
1829
|
], TimeRecordService);
|
1527
1830
|
exports.TimeRecordService = TimeRecordService;
|
1528
1831
|
|
1529
1832
|
|
1833
|
+
/***/ }),
|
1834
|
+
|
1835
|
+
/***/ "./src/services/timesheet-proxy-service.ts":
|
1836
|
+
/*!*************************************************!*\
|
1837
|
+
!*** ./src/services/timesheet-proxy-service.ts ***!
|
1838
|
+
\*************************************************/
|
1839
|
+
/*! no static exports found */
|
1840
|
+
/***/ (function(module, exports, __webpack_require__) {
|
1841
|
+
|
1842
|
+
"use strict";
|
1843
|
+
|
1844
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
1845
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
1846
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
1847
|
+
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;
|
1848
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
1849
|
+
};
|
1850
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
1851
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
1852
|
+
};
|
1853
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
1854
|
+
exports.TimesheetProxyService = void 0;
|
1855
|
+
const inversify_1 = __webpack_require__(/*! inversify */ "inversify");
|
1856
|
+
const core_1 = __webpack_require__(/*! @common-stack/core */ "@common-stack/core");
|
1857
|
+
let TimesheetProxyService = class TimesheetProxyService {
|
1858
|
+
constructor(broker, logger) {
|
1859
|
+
this.broker = broker;
|
1860
|
+
this.topic = "Timesheet" /* Timesheet */;
|
1861
|
+
this.logger = logger.child({ className: 'TimesheetProxyService' });
|
1862
|
+
}
|
1863
|
+
createTimesheet(userId, orgId, request) {
|
1864
|
+
return this.callAction("createTimesheet" /* createTimesheet */, { userId, orgId, request });
|
1865
|
+
}
|
1866
|
+
getDurationTimesheets(orgId, start, end) {
|
1867
|
+
return this.callAction("getDurationTimesheets" /* getDurationTimesheets */, { orgId, start, end });
|
1868
|
+
}
|
1869
|
+
getTimesheets(orgId) {
|
1870
|
+
return this.callAction("getTimesheets" /* getTimesheets */, { orgId });
|
1871
|
+
}
|
1872
|
+
getTimesheetsWithTotalHours(orgId, userId) {
|
1873
|
+
return this.callAction("getTimesheetsWithTotalHours" /* getTimesheetsWithTotalHours */, { orgId, userId });
|
1874
|
+
}
|
1875
|
+
removeTimesheet(userId, orgId, sheetId) {
|
1876
|
+
return this.callAction("removeTimesheet" /* removeTimesheet */, { userId, orgId, sheetId });
|
1877
|
+
}
|
1878
|
+
removeTimeRecordIdFromTimesheet(recordId, orgId) {
|
1879
|
+
return this.callAction("removeTimeRecordIdFromTimesheet" /* removeTimeRecordIdFromTimesheet */, { recordId, orgId });
|
1880
|
+
}
|
1881
|
+
updateTimesheet(userId, orgId, sheetId, request, userContext) {
|
1882
|
+
return this.callAction("updateTimesheet" /* updateTimesheet */, { userId, orgId, sheetId, request });
|
1883
|
+
}
|
1884
|
+
updateTimesheetStatus(orgId, sheetId, state) {
|
1885
|
+
return this.callAction("updateTimesheetStatus" /* updateTimesheetStatus */, { orgId, sheetId, state });
|
1886
|
+
}
|
1887
|
+
async callAction(command, params) {
|
1888
|
+
return this.broker.call(`${this.topic}.${command}`, params);
|
1889
|
+
}
|
1890
|
+
};
|
1891
|
+
TimesheetProxyService = __decorate([
|
1892
|
+
inversify_1.injectable(),
|
1893
|
+
__param(0, inversify_1.inject(core_1.CommonType.MOLECULER_BROKER)),
|
1894
|
+
__param(1, inversify_1.inject('Logger'))
|
1895
|
+
], TimesheetProxyService);
|
1896
|
+
exports.TimesheetProxyService = TimesheetProxyService;
|
1897
|
+
|
1898
|
+
|
1530
1899
|
/***/ }),
|
1531
1900
|
|
1532
1901
|
/***/ "./src/services/timesheet-service.ts":
|
@@ -1573,7 +1942,7 @@ let TimesheetService = class TimesheetService {
|
|
1573
1942
|
const timeRecords = await this.timeRecordRepository.getTimeRecords(orgId, userId);
|
1574
1943
|
return timesheets.map((timesheet) => {
|
1575
1944
|
const sheetTotalDuration = timeRecords
|
1576
|
-
.filter((tr) =>
|
1945
|
+
.filter((tr) => { var _a; return (_a = timesheet.timeRecordsId) === null || _a === void 0 ? void 0 : _a.includes(tr._id.toString()); })
|
1577
1946
|
.reduce((duration, tr) => duration + Math.floor((moment(tr.endTime).valueOf() - moment(tr.startTime).valueOf()) / 1000), 0);
|
1578
1947
|
return {
|
1579
1948
|
id: timesheet.id,
|
@@ -1587,6 +1956,7 @@ let TimesheetService = class TimesheetService {
|
|
1587
1956
|
submittedOn: timesheet.submittedOn,
|
1588
1957
|
updatedBy: timesheet.updatedBy,
|
1589
1958
|
updatedOn: timesheet.updatedOn,
|
1959
|
+
timeRecordsId: timesheet.timeRecordsId,
|
1590
1960
|
totalDuration: sheetTotalDuration,
|
1591
1961
|
};
|
1592
1962
|
});
|
@@ -1604,21 +1974,31 @@ let TimesheetService = class TimesheetService {
|
|
1604
1974
|
await this.timesheetRepository.updateTimesheet(orgId, sheetId, request);
|
1605
1975
|
if (request.state === "APPROVED" /* APPROVED */) {
|
1606
1976
|
// approve time records from startDate to endDate
|
1607
|
-
this.timeRecordService.approveTimeRecords(orgId, sheetId, request.
|
1977
|
+
this.timeRecordService.approveTimeRecords(orgId, sheetId, request.timeRecordsId);
|
1608
1978
|
}
|
1609
1979
|
else if (request.state === "DENYED" /* DENYED */) {
|
1610
1980
|
// approve time records from startDate to endDate
|
1611
1981
|
this.timeRecordService.disapproveTimeRecords(orgId, sheetId);
|
1612
1982
|
}
|
1613
1983
|
const resourceUri = core_1.generateOrgUri(orgId, "settings" /* settings */);
|
1614
|
-
const
|
1615
|
-
target:
|
1984
|
+
const settings = (await this.preferencesService.viewerSettings({
|
1985
|
+
target: 4 /* ORGANIZATION */,
|
1616
1986
|
settingsResource: resourceUri,
|
1987
|
+
}, {
|
1988
|
+
fragmentName: 'AccountBillingPreferences',
|
1989
|
+
fragmentDoc: `fragment AccountBillingPreferences on Preferences {
|
1990
|
+
account {
|
1991
|
+
notification {
|
1992
|
+
primaryEmail
|
1993
|
+
billing
|
1994
|
+
}
|
1995
|
+
}
|
1996
|
+
}`
|
1617
1997
|
}));
|
1618
1998
|
if (request.state === "APPROVED" /* APPROVED */ &&
|
1619
1999
|
settings.timetracker.notifications.approvalNotifications &&
|
1620
2000
|
settings.timetracker.notifications.enableTimetrackerNotifications) {
|
1621
|
-
const mailTopic = '
|
2001
|
+
const mailTopic = 'Timesheet approved';
|
1622
2002
|
const mailTo = userContext.emailId;
|
1623
2003
|
const mailFrom = config_1.config.MAIL_SEND_DEFAULT_EMAIL;
|
1624
2004
|
const templateId = constants_1.EmailTemplateCodes.TIMESHEET_APPROVAL;
|
@@ -1634,7 +2014,7 @@ let TimesheetService = class TimesheetService {
|
|
1634
2014
|
if (request.state === "SUBMITTED" /* SUBMITTED */ &&
|
1635
2015
|
settings.timetracker.notifications.submitNotifications &&
|
1636
2016
|
settings.timetracker.notifications.enableTimetrackerNotifications) {
|
1637
|
-
const mailTopic = '
|
2017
|
+
const mailTopic = 'Timesheet submitted';
|
1638
2018
|
const mailTo = userContext.emailId;
|
1639
2019
|
const mailFrom = config_1.config.MAIL_SEND_DEFAULT_EMAIL;
|
1640
2020
|
const templateId = constants_1.EmailTemplateCodes.SUBMIT_TIME;
|
@@ -1681,6 +2061,9 @@ let TimesheetService = class TimesheetService {
|
|
1681
2061
|
},
|
1682
2062
|
}, "MailService" /* MailService */);
|
1683
2063
|
}
|
2064
|
+
async removeTimeRecordIdFromTimesheet(recordId, orgId) {
|
2065
|
+
return await this.timesheetRepository.removeTimeRecordIdFromTimesheet(recordId, orgId);
|
2066
|
+
}
|
1684
2067
|
async callAction(command, params, topic, opts) {
|
1685
2068
|
return this.broker.call(`${topic}.${command}@${this.settings.adminApiNamespace}`, params, opts);
|
1686
2069
|
}
|
@@ -1699,6 +2082,108 @@ TimesheetService = __decorate([
|
|
1699
2082
|
exports.TimesheetService = TimesheetService;
|
1700
2083
|
|
1701
2084
|
|
2085
|
+
/***/ }),
|
2086
|
+
|
2087
|
+
/***/ "./src/store/models/timerecords-model.ts":
|
2088
|
+
/*!***********************************************!*\
|
2089
|
+
!*** ./src/store/models/timerecords-model.ts ***!
|
2090
|
+
\***********************************************/
|
2091
|
+
/*! no static exports found */
|
2092
|
+
/***/ (function(module, exports, __webpack_require__) {
|
2093
|
+
|
2094
|
+
"use strict";
|
2095
|
+
|
2096
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
2097
|
+
exports.TimeRecordsModelFunc = void 0;
|
2098
|
+
const mongoose_1 = __webpack_require__(/*! mongoose */ "mongoose");
|
2099
|
+
var PauseStatusDescription;
|
2100
|
+
(function (PauseStatusDescription) {
|
2101
|
+
PauseStatusDescription["BY_USER"] = "BY_USER";
|
2102
|
+
PauseStatusDescription["DUE_TO_INACTIVITY"] = "DUE_TO_INACTIVITY";
|
2103
|
+
})(PauseStatusDescription || (PauseStatusDescription = {}));
|
2104
|
+
const PauseStatusSchema = new mongoose_1.Schema({
|
2105
|
+
pausedTime: { type: Date },
|
2106
|
+
restartTime: { type: Date },
|
2107
|
+
status: { type: PauseStatusDescription },
|
2108
|
+
});
|
2109
|
+
// ===> TimeRecord
|
2110
|
+
const TimeRecordSchema = new mongoose_1.Schema({
|
2111
|
+
orgId: { type: String, index: true },
|
2112
|
+
userId: { type: String, index: true },
|
2113
|
+
startTime: { type: Date, index: true },
|
2114
|
+
endTime: { type: Date, default: null, index: true },
|
2115
|
+
taskName: { type: String },
|
2116
|
+
description: { type: String },
|
2117
|
+
taskId: { type: String },
|
2118
|
+
tags: { type: [String] },
|
2119
|
+
isBillable: { type: Boolean },
|
2120
|
+
projectId: { type: String },
|
2121
|
+
timesheetId: { type: String, index: true },
|
2122
|
+
isPause: { type: Boolean, default: false },
|
2123
|
+
isTimeout: { type: Boolean, default: false },
|
2124
|
+
pauseStatus: { type: [PauseStatusSchema] }
|
2125
|
+
});
|
2126
|
+
TimeRecordSchema.index({ endTime: 1, startTime: 1, userId: 1 });
|
2127
|
+
TimeRecordSchema.virtual('id').get(function () {
|
2128
|
+
return this._id.toHexString();
|
2129
|
+
});
|
2130
|
+
TimeRecordSchema.set('toJSON', {
|
2131
|
+
virtuals: true,
|
2132
|
+
});
|
2133
|
+
TimeRecordSchema.set('toObject', { virtuals: true });
|
2134
|
+
const TimeRecordsModelFunc = (db) => db.model('timerecords', TimeRecordSchema);
|
2135
|
+
exports.TimeRecordsModelFunc = TimeRecordsModelFunc;
|
2136
|
+
|
2137
|
+
|
2138
|
+
/***/ }),
|
2139
|
+
|
2140
|
+
/***/ "./src/store/models/timesheets-model.ts":
|
2141
|
+
/*!**********************************************!*\
|
2142
|
+
!*** ./src/store/models/timesheets-model.ts ***!
|
2143
|
+
\**********************************************/
|
2144
|
+
/*! no static exports found */
|
2145
|
+
/***/ (function(module, exports, __webpack_require__) {
|
2146
|
+
|
2147
|
+
"use strict";
|
2148
|
+
|
2149
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
2150
|
+
exports.TimesheetsModelFunc = void 0;
|
2151
|
+
const mongoose_1 = __webpack_require__(/*! mongoose */ "mongoose");
|
2152
|
+
var TimesheetState;
|
2153
|
+
(function (TimesheetState) {
|
2154
|
+
TimesheetState[TimesheetState["OPEN"] = 0] = "OPEN";
|
2155
|
+
TimesheetState[TimesheetState["APPROVED_PENDING"] = 1] = "APPROVED_PENDING";
|
2156
|
+
TimesheetState[TimesheetState["APPROVED"] = 2] = "APPROVED";
|
2157
|
+
TimesheetState[TimesheetState["APPROVED_FINALIZED"] = 3] = "APPROVED_FINALIZED";
|
2158
|
+
TimesheetState[TimesheetState["DENYED"] = 4] = "DENYED";
|
2159
|
+
TimesheetState[TimesheetState["SUBMITTED"] = 5] = "SUBMITTED";
|
2160
|
+
TimesheetState[TimesheetState["DENYED_FINALIZED"] = 6] = "DENYED_FINALIZED";
|
2161
|
+
})(TimesheetState || (TimesheetState = {}));
|
2162
|
+
// ===> Timesheet
|
2163
|
+
const TimesheetSchema = new mongoose_1.Schema({
|
2164
|
+
orgId: { type: String, index: true },
|
2165
|
+
userId: { type: String, index: true },
|
2166
|
+
startDate: { type: Date },
|
2167
|
+
endDate: { type: Date },
|
2168
|
+
state: { type: TimesheetState },
|
2169
|
+
submittedOn: { type: Date },
|
2170
|
+
approvedOn: { type: Date },
|
2171
|
+
approvedBy: { type: String },
|
2172
|
+
updatedBy: { type: String },
|
2173
|
+
updatedOn: { type: Date },
|
2174
|
+
timeRecordsId: { type: [String] },
|
2175
|
+
});
|
2176
|
+
TimesheetSchema.virtual('id').get(function () {
|
2177
|
+
return this._id.toHexString();
|
2178
|
+
});
|
2179
|
+
TimesheetSchema.set('toJSON', {
|
2180
|
+
virtuals: true,
|
2181
|
+
});
|
2182
|
+
TimesheetSchema.set('toObject', { virtuals: true });
|
2183
|
+
const TimesheetsModelFunc = (db) => db.model('timesheets', TimesheetSchema);
|
2184
|
+
exports.TimesheetsModelFunc = TimesheetsModelFunc;
|
2185
|
+
|
2186
|
+
|
1702
2187
|
/***/ }),
|
1703
2188
|
|
1704
2189
|
/***/ "./src/store/models/timetracker-model.ts":
|
@@ -1750,7 +2235,7 @@ const TimeRecordSchema = new mongoose_1.Schema({
|
|
1750
2235
|
activities: [TimeActivitySchema],
|
1751
2236
|
isPause: { type: Boolean, default: false },
|
1752
2237
|
isTimeout: { type: Boolean, default: false },
|
1753
|
-
pauseStatus: { type: [PauseStatusSchema] }
|
2238
|
+
pauseStatus: { type: [PauseStatusSchema] }
|
1754
2239
|
});
|
1755
2240
|
TimeRecordSchema.index({ endTime: 1, startTime: 1, userId: 1 });
|
1756
2241
|
// ===> Timesheet
|
@@ -1764,6 +2249,7 @@ const TimesheetSchema = new mongoose_1.Schema({
|
|
1764
2249
|
approvedBy: { type: String },
|
1765
2250
|
updatedBy: { type: String },
|
1766
2251
|
updatedOn: { type: Date },
|
2252
|
+
timeRecordsId: { type: [String] },
|
1767
2253
|
});
|
1768
2254
|
const TimeTrackerSchema = new mongoose_1.Schema({
|
1769
2255
|
orgId: { type: String, index: true },
|
@@ -1783,7 +2269,8 @@ TimeTrackerSchema.set('toJSON', {
|
|
1783
2269
|
virtuals: true,
|
1784
2270
|
});
|
1785
2271
|
TimeTrackerSchema.set('toObject', { virtuals: true });
|
1786
|
-
|
2272
|
+
const TimeTrackerModelFunc = (db) => db.model('timetracker', TimeTrackerSchema);
|
2273
|
+
exports.TimeTrackerModelFunc = TimeTrackerModelFunc;
|
1787
2274
|
|
1788
2275
|
|
1789
2276
|
/***/ }),
|
@@ -1805,7 +2292,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
1805
2292
|
o[k2] = m[k];
|
1806
2293
|
}));
|
1807
2294
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
1808
|
-
for (var p in m) if (p !== "default" && !
|
2295
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
1809
2296
|
};
|
1810
2297
|
Object.defineProperty(exports, "__esModule", { value: true });
|
1811
2298
|
__exportStar(__webpack_require__(/*! ./timerecord-repository */ "./src/store/repository/timerecord-repository.ts"), exports);
|
@@ -1835,82 +2322,60 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
1835
2322
|
Object.defineProperty(exports, "__esModule", { value: true });
|
1836
2323
|
exports.TimeRecordRepository = void 0;
|
1837
2324
|
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");
|
2325
|
+
const timerecords_model_1 = __webpack_require__(/*! ../models/timerecords-model */ "./src/store/models/timerecords-model.ts");
|
1840
2326
|
let TimeRecordRepository = class TimeRecordRepository {
|
1841
2327
|
constructor(db, logger) {
|
1842
2328
|
this.logger = logger.child({ className: 'TimeRecordRepository' });
|
1843
|
-
this.
|
2329
|
+
this.timeRecordsModel = timerecords_model_1.TimeRecordsModelFunc(db);
|
1844
2330
|
}
|
1845
2331
|
async getTimeRecords(orgId, userId, from, until) {
|
1846
2332
|
if (!userId) {
|
1847
2333
|
userId = /.*/;
|
1848
2334
|
}
|
1849
2335
|
let match = {
|
1850
|
-
'
|
2336
|
+
'userId': userId,
|
1851
2337
|
};
|
1852
2338
|
if (from) {
|
1853
|
-
match = Object.assign(Object.assign({}, match), { '
|
2339
|
+
match = Object.assign(Object.assign({}, match), { 'startTime': { $gte: from } });
|
1854
2340
|
}
|
1855
2341
|
if (until) {
|
1856
|
-
match = Object.assign(Object.assign({}, match), { '
|
2342
|
+
match = Object.assign(Object.assign({}, match), { 'endTime': { $lte: until } });
|
1857
2343
|
}
|
1858
|
-
const result = await this.
|
2344
|
+
const result = await this.timeRecordsModel.aggregate([
|
1859
2345
|
{
|
1860
2346
|
$match: {
|
1861
2347
|
orgId,
|
1862
2348
|
},
|
1863
2349
|
},
|
1864
|
-
{
|
1865
|
-
$unwind: '$timeRecords',
|
1866
|
-
},
|
1867
2350
|
{
|
1868
2351
|
$match: Object.assign({}, match),
|
1869
2352
|
},
|
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
2353
|
]);
|
1885
2354
|
if (result.length === 0) {
|
1886
2355
|
return [];
|
1887
2356
|
}
|
1888
|
-
return result
|
2357
|
+
return result;
|
1889
2358
|
}
|
1890
2359
|
async getOrganizationTimeRecords(orgId) {
|
1891
|
-
const trackDoc = await this.
|
1892
|
-
if (trackDoc
|
1893
|
-
return trackDoc
|
2360
|
+
const trackDoc = await this.timeRecordsModel.find({ orgId });
|
2361
|
+
if (trackDoc) {
|
2362
|
+
return trackDoc;
|
1894
2363
|
}
|
1895
2364
|
return [];
|
1896
2365
|
}
|
1897
2366
|
async getPlayingTimeRecord(userId, orgId) {
|
1898
|
-
const trackDoc = await this.
|
2367
|
+
const trackDoc = await this.timeRecordsModel.find({ orgId });
|
1899
2368
|
if (trackDoc) {
|
1900
2369
|
let res;
|
1901
|
-
if (trackDoc
|
1902
|
-
res = trackDoc.
|
2370
|
+
if (trackDoc)
|
2371
|
+
res = trackDoc.find((tr) => tr.userId === userId && tr.endTime === null);
|
1903
2372
|
return res;
|
1904
2373
|
}
|
1905
2374
|
return null;
|
1906
2375
|
}
|
1907
2376
|
async createTimeRecord(userId, orgId, request) {
|
1908
2377
|
try {
|
1909
|
-
const response = await this.
|
1910
|
-
upsert: true,
|
1911
|
-
new: true,
|
1912
|
-
projection: { userId, orgId, timeRecords: { $elemMatch: { startTime: request.startTime } } },
|
1913
|
-
});
|
2378
|
+
const response = await this.timeRecordsModel.create(Object.assign(Object.assign({}, request), { orgId, userId }));
|
1914
2379
|
return response.toObject();
|
1915
2380
|
}
|
1916
2381
|
catch (err) {
|
@@ -1921,21 +2386,12 @@ let TimeRecordRepository = class TimeRecordRepository {
|
|
1921
2386
|
try {
|
1922
2387
|
if (recordId === null || recordId === undefined)
|
1923
2388
|
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),
|
2389
|
+
const response = await this.timeRecordsModel.findOneAndUpdate({ orgId, _id: recordId }, {
|
2390
|
+
$set: Object.assign({}, request),
|
1930
2391
|
}, {
|
1931
2392
|
new: true,
|
1932
|
-
projection: {
|
1933
|
-
userId,
|
1934
|
-
orgId,
|
1935
|
-
timeRecords: { $elemMatch: { _id: recordId } },
|
1936
|
-
},
|
1937
2393
|
});
|
1938
|
-
return response.toObject();
|
2394
|
+
return response === null || response === void 0 ? void 0 : response.toObject();
|
1939
2395
|
}
|
1940
2396
|
catch (err) {
|
1941
2397
|
throw new Error(err.message);
|
@@ -1943,15 +2399,11 @@ let TimeRecordRepository = class TimeRecordRepository {
|
|
1943
2399
|
}
|
1944
2400
|
async removeTimeRecord(userId, orgId, recordId) {
|
1945
2401
|
try {
|
1946
|
-
const result = await this.
|
1947
|
-
|
1948
|
-
}, {
|
1949
|
-
$pull: { timeRecords: { _id: recordId } },
|
1950
|
-
});
|
1951
|
-
if (result.nModified !== 1) {
|
2402
|
+
const result = await this.timeRecordsModel.remove({ userId, orgId, _id: recordId });
|
2403
|
+
if (result.n !== 1) {
|
1952
2404
|
throw new Error('TimeRecord is not modified');
|
1953
2405
|
}
|
1954
|
-
return { userId, orgId,
|
2406
|
+
return { userId, orgId, _id: recordId };
|
1955
2407
|
}
|
1956
2408
|
catch (err) {
|
1957
2409
|
throw new Error(err.message);
|
@@ -1959,14 +2411,12 @@ let TimeRecordRepository = class TimeRecordRepository {
|
|
1959
2411
|
}
|
1960
2412
|
async removeDurationTimeRecords(userId, orgId, startTime, endTime, projectId) {
|
1961
2413
|
try {
|
1962
|
-
const trackerDoc = await this.
|
2414
|
+
const trackerDoc = await this.timeRecordsModel.find({ orgId });
|
1963
2415
|
if (trackerDoc && trackerDoc.length > 0) {
|
1964
|
-
const timeRecords = trackerDoc
|
1965
|
-
|
1966
|
-
|
1967
|
-
}
|
1968
|
-
timeRecords,
|
1969
|
-
});
|
2416
|
+
const timeRecords = trackerDoc.filter((tr) => tr.startTime > startTime && tr.startTime < endTime && tr.projectId === projectId);
|
2417
|
+
for (const record of timeRecords) {
|
2418
|
+
await this.timeRecordsModel.remove({ _id: record._id });
|
2419
|
+
}
|
1970
2420
|
return true;
|
1971
2421
|
}
|
1972
2422
|
return false;
|
@@ -1975,20 +2425,11 @@ let TimeRecordRepository = class TimeRecordRepository {
|
|
1975
2425
|
throw new Error(err.message);
|
1976
2426
|
}
|
1977
2427
|
}
|
1978
|
-
async approveTimeRecords(orgId, sheetId,
|
2428
|
+
async approveTimeRecords(orgId, sheetId, timeRecordsId) {
|
1979
2429
|
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
|
-
});
|
2430
|
+
for (const id of timeRecordsId) {
|
2431
|
+
const res = await this.timeRecordsModel.updateOne({ orgId, _id: id }, { $set: { 'timesheetId': sheetId } });
|
2432
|
+
}
|
1992
2433
|
}
|
1993
2434
|
catch (e) {
|
1994
2435
|
this.logger.debug('approveTimeRecords =>', e.message);
|
@@ -1997,15 +2438,11 @@ let TimeRecordRepository = class TimeRecordRepository {
|
|
1997
2438
|
}
|
1998
2439
|
async disapproveTimeRecords(orgId, sheetId) {
|
1999
2440
|
try {
|
2000
|
-
await this.
|
2441
|
+
const res = await this.timeRecordsModel.updateMany({
|
2001
2442
|
orgId,
|
2002
|
-
|
2443
|
+
timesheetId: sheetId
|
2444
|
+
}, { $set: { 'timesheetId': null } }, {
|
2003
2445
|
multi: true,
|
2004
|
-
arrayFilters: [
|
2005
|
-
{
|
2006
|
-
'el.timesheetId': sheetId,
|
2007
|
-
},
|
2008
|
-
],
|
2009
2446
|
});
|
2010
2447
|
}
|
2011
2448
|
catch (e) {
|
@@ -2046,17 +2483,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
2046
2483
|
exports.TimesheetRepository = void 0;
|
2047
2484
|
const inversify_1 = __webpack_require__(/*! inversify */ "inversify");
|
2048
2485
|
const core_1 = __webpack_require__(/*! @common-stack/core */ "@common-stack/core");
|
2049
|
-
const
|
2486
|
+
const timesheets_model_1 = __webpack_require__(/*! ../models/timesheets-model */ "./src/store/models/timesheets-model.ts");
|
2050
2487
|
let TimesheetRepository = class TimesheetRepository {
|
2051
2488
|
constructor(db, logger, broker) {
|
2052
2489
|
this.broker = broker;
|
2053
2490
|
this.logger = logger.child({ className: 'TimesheetRepository' });
|
2054
|
-
this.
|
2491
|
+
this.timesheetsModel = timesheets_model_1.TimesheetsModelFunc(db);
|
2055
2492
|
}
|
2056
2493
|
async getOrganizationTimesheets(orgId) {
|
2057
|
-
const trackDoc = await this.
|
2058
|
-
if (trackDoc && trackDoc
|
2059
|
-
return trackDoc
|
2494
|
+
const trackDoc = await this.timesheetsModel.find({ orgId });
|
2495
|
+
if (trackDoc && trackDoc) {
|
2496
|
+
return trackDoc;
|
2060
2497
|
}
|
2061
2498
|
return [];
|
2062
2499
|
}
|
@@ -2066,7 +2503,7 @@ let TimesheetRepository = class TimesheetRepository {
|
|
2066
2503
|
}
|
2067
2504
|
async createTimesheet(userId, orgId, request) {
|
2068
2505
|
try {
|
2069
|
-
const response = await this.
|
2506
|
+
const response = await this.timesheetsModel.create(Object.assign({ orgId }, request));
|
2070
2507
|
return true;
|
2071
2508
|
}
|
2072
2509
|
catch (err) {
|
@@ -2075,7 +2512,7 @@ let TimesheetRepository = class TimesheetRepository {
|
|
2075
2512
|
}
|
2076
2513
|
async updateTimesheet(orgId, sheetId, request) {
|
2077
2514
|
try {
|
2078
|
-
const response = await this.
|
2515
|
+
const response = await this.timesheetsModel.update({ orgId, _id: sheetId }, { $set: Object.assign({}, request) });
|
2079
2516
|
return response;
|
2080
2517
|
}
|
2081
2518
|
catch (err) {
|
@@ -2084,12 +2521,12 @@ let TimesheetRepository = class TimesheetRepository {
|
|
2084
2521
|
}
|
2085
2522
|
async updateTimesheetStatus(orgId, sheetId, state) {
|
2086
2523
|
try {
|
2087
|
-
const response = await this.
|
2524
|
+
const response = await this.timesheetsModel.update({
|
2088
2525
|
orgId,
|
2089
|
-
|
2526
|
+
_id: sheetId,
|
2090
2527
|
}, {
|
2091
2528
|
$set: {
|
2092
|
-
'
|
2529
|
+
'status': state,
|
2093
2530
|
},
|
2094
2531
|
});
|
2095
2532
|
return response;
|
@@ -2100,17 +2537,17 @@ let TimesheetRepository = class TimesheetRepository {
|
|
2100
2537
|
}
|
2101
2538
|
async removeTimesheet(userId, orgId, sheetId) {
|
2102
2539
|
try {
|
2103
|
-
await this.
|
2104
|
-
orgId,
|
2105
|
-
}, {
|
2106
|
-
$pull: { timesheets: { _id: sheetId } },
|
2107
|
-
});
|
2540
|
+
await this.timesheetsModel.remove({ orgId, _id: sheetId });
|
2108
2541
|
return true;
|
2109
2542
|
}
|
2110
2543
|
catch (err) {
|
2111
2544
|
throw new Error(err.message);
|
2112
2545
|
}
|
2113
2546
|
}
|
2547
|
+
async removeTimeRecordIdFromTimesheet(recordId, orgId) {
|
2548
|
+
const res = await this.timesheetsModel.updateMany({ orgId, timeRecordsId: recordId }, { $pullAll: { timeRecordsId: [recordId] } });
|
2549
|
+
return true;
|
2550
|
+
}
|
2114
2551
|
};
|
2115
2552
|
TimesheetRepository = __decorate([
|
2116
2553
|
inversify_1.injectable(),
|
@@ -2134,6 +2571,17 @@ module.exports = require("@adminide-stack/core");
|
|
2134
2571
|
|
2135
2572
|
/***/ }),
|
2136
2573
|
|
2574
|
+
/***/ "@adminide-stack/platform-server":
|
2575
|
+
/*!**************************************************!*\
|
2576
|
+
!*** external "@adminide-stack/platform-server" ***!
|
2577
|
+
\**************************************************/
|
2578
|
+
/*! no static exports found */
|
2579
|
+
/***/ (function(module, exports) {
|
2580
|
+
|
2581
|
+
module.exports = require("@adminide-stack/platform-server");
|
2582
|
+
|
2583
|
+
/***/ }),
|
2584
|
+
|
2137
2585
|
/***/ "@common-stack/core":
|
2138
2586
|
/*!*************************************!*\
|
2139
2587
|
!*** external "@common-stack/core" ***!
|
@@ -2211,14 +2659,14 @@ module.exports = require("inversify");
|
|
2211
2659
|
|
2212
2660
|
/***/ }),
|
2213
2661
|
|
2214
|
-
/***/ "
|
2215
|
-
|
2216
|
-
!*** external "
|
2217
|
-
|
2662
|
+
/***/ "moleculer":
|
2663
|
+
/*!****************************!*\
|
2664
|
+
!*** external "moleculer" ***!
|
2665
|
+
\****************************/
|
2218
2666
|
/*! no static exports found */
|
2219
2667
|
/***/ (function(module, exports) {
|
2220
2668
|
|
2221
|
-
module.exports = require("
|
2669
|
+
module.exports = require("moleculer");
|
2222
2670
|
|
2223
2671
|
/***/ }),
|
2224
2672
|
|