mobioffice-cli 1.0.0 → 1.0.2
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/{src/index.ts → lib/index.d.ts} +1 -45
- package/lib/models/Feed-Details-Screen.model.d.ts +6 -0
- package/lib/models/Feed-Details-Screen.model.js +27 -0
- package/lib/models/action.model.d.ts +58 -0
- package/lib/models/action.model.js +315 -0
- package/lib/models/actions/doffing.d.ts +6 -0
- package/lib/models/actions/doffing.js +64 -0
- package/lib/models/actions/folding.d.ts +7 -0
- package/lib/models/actions/folding.js +37 -0
- package/lib/models/attendance.model.d.ts +44 -0
- package/lib/models/attendance.model.js +446 -0
- package/lib/models/cicoPost.model.d.ts +9 -0
- package/lib/models/cicoPost.model.js +19 -0
- package/lib/models/company.model.d.ts +67 -0
- package/lib/models/company.model.js +725 -0
- package/lib/models/contact-us/resquest.model.d.ts +30 -0
- package/lib/models/contact-us/resquest.model.js +73 -0
- package/lib/models/crud/crud.d.ts +7 -0
- package/lib/models/crud/crud.js +27 -0
- package/lib/models/customCollection.model.d.ts +9 -0
- package/lib/models/customCollection.model.js +40 -0
- package/lib/models/customer/customer.model.d.ts +32 -0
- package/lib/models/customer/customer.model.js +62 -0
- package/lib/models/deviceChangeReq.d.ts +10 -0
- package/lib/models/deviceChangeReq.js +138 -0
- package/lib/models/dispatch.model.d.ts +14 -0
- package/lib/models/dispatch.model.js +93 -0
- package/lib/models/feed.models.d.ts +8 -0
- package/lib/models/feed.models.js +97 -0
- package/lib/models/geofence.model.d.ts +7 -0
- package/lib/models/geofence.model.js +61 -0
- package/lib/models/leaveApplicationPost.model.d.ts +12 -0
- package/lib/models/leaveApplicationPost.model.js +72 -0
- package/lib/models/license.model.d.ts +25 -0
- package/lib/models/license.model.js +198 -0
- package/lib/models/log.model.d.ts +6 -0
- package/{src/models/log.model.ts → lib/models/log.model.js} +11 -11
- package/lib/models/meeting.model.d.ts +11 -0
- package/lib/models/meeting.model.js +79 -0
- package/lib/models/meter.model.d.ts +18 -0
- package/lib/models/meter.model.js +54 -0
- package/lib/models/missingPunchPost.model.d.ts +15 -0
- package/lib/models/missingPunchPost.model.js +69 -0
- package/lib/models/offline.model.d.ts +70 -0
- package/lib/models/offline.model.js +831 -0
- package/lib/models/post.model.d.ts +38 -0
- package/lib/models/post.model.js +94 -0
- package/lib/models/printDetailsScreen.model.d.ts +6 -0
- package/lib/models/printDetailsScreen.model.js +27 -0
- package/lib/models/pushNotifications/pushNotification.model.d.ts +4 -0
- package/lib/models/pushNotifications/pushNotification.model.js +17 -0
- package/lib/models/report-actions.model.d.ts +26 -0
- package/lib/models/report-actions.model.js +56 -0
- package/lib/models/report-definition-details.model.d.ts +13 -0
- package/lib/models/report-definition-details.model.js +85 -0
- package/lib/models/report-definition.model.d.ts +23 -0
- package/lib/models/report-definition.model.js +26 -0
- package/lib/models/report-definitions-summary.model.d.ts +8 -0
- package/lib/models/report-definitions-summary.model.js +59 -0
- package/lib/models/report-detail-data.model.d.ts +46 -0
- package/lib/models/report-detail-data.model.js +49 -0
- package/lib/models/report-visibility.model.d.ts +7 -0
- package/lib/models/report-visibility.model.js +42 -0
- package/lib/models/report.model.d.ts +19 -0
- package/lib/models/report.model.js +138 -0
- package/lib/models/reportGenerator.model.d.ts +164 -0
- package/lib/models/reportGenerator.model.js +642 -0
- package/lib/models/response.model.d.ts +18 -0
- package/lib/models/response.model.js +30 -0
- package/lib/models/steps.factory.model.d.ts +172 -0
- package/lib/models/steps.factory.model.js +187 -0
- package/lib/models/storeGupShupLog.model.d.ts +6 -0
- package/lib/models/storeGupShupLog.model.js +51 -0
- package/lib/models/summary.model.d.ts +10 -0
- package/{src/models/summary.model.ts → lib/models/summary.model.js} +28 -27
- package/lib/models/tasks/sub-task-group.model.d.ts +42 -0
- package/lib/models/tasks/sub-task-group.model.js +154 -0
- package/lib/models/tasks/tags.model.d.ts +29 -0
- package/lib/models/tasks/tags.model.js +70 -0
- package/lib/models/tasks/task-group.model.d.ts +53 -0
- package/lib/models/tasks/task-group.model.js +156 -0
- package/lib/models/tasks/task.model.d.ts +163 -0
- package/lib/models/tasks/task.model.js +603 -0
- package/lib/models/tempCollection.model.d.ts +40 -0
- package/{src/models/tempCollection.model.ts → lib/models/tempCollection.model.js} +114 -130
- package/lib/models/user.model.d.ts +42 -0
- package/lib/models/user.model.js +272 -0
- package/lib/models/utility.model.d.ts +13 -0
- package/lib/models/utility.model.js +93 -0
- package/lib/models/visitorManagement/acknowledgement.model.d.ts +9 -0
- package/lib/models/visitorManagement/acknowledgement.model.js +55 -0
- package/lib/models/visitorManagement/invite.model.d.ts +32 -0
- package/lib/models/visitorManagement/invite.model.js +326 -0
- package/lib/models/visitorManagement/newIn.model.d.ts +19 -0
- package/lib/models/visitorManagement/newIn.model.js +67 -0
- package/lib/models/visitorManagement/selfServe.model.d.ts +13 -0
- package/lib/models/visitorManagement/selfServe.model.js +46 -0
- package/lib/models/worklogPost.model.d.ts +6 -0
- package/lib/models/worklogPost.model.js +9 -0
- package/lib/services/customer.d.ts +30 -0
- package/lib/services/customer.js +354 -0
- package/lib/services/meeting.d.ts +19 -0
- package/lib/services/meeting.js +109 -0
- package/package.json +4 -1
- package/.prettierrc +0 -4
- package/a.js +0 -3
- package/scripts/1.ts +0 -1300
- package/scripts/GCloudPubSub/pub-sub-config.json +0 -12
- package/scripts/GCloudPubSub/visitorAutoRejection.ts +0 -86
- package/scripts/actions/assignUsersFromOneActionToOther.ts +0 -64
- package/scripts/actions/assignUsersListToAction.ts +0 -81
- package/scripts/actions/getActionsListOfUser.ts +0 -42
- package/scripts/actions/getCompanyUserDetails.ts +0 -49
- package/scripts/actions/giveActionToUser.ts +0 -41
- package/scripts/actions/giveUsersToActivitySelector.ts +0 -56
- package/scripts/actions/groupActionsInActivitySelector.ts +0 -101
- package/scripts/actions/modifySummaryReportDB.ts +0 -42
- package/scripts/actions/setUrlToActionStep.ts +0 -18
- package/scripts/actions/syncMySqlAttendanceDBWithFirebase.ts +0 -93
- package/scripts/actions/syncMySqlMeetingsDBWithFirebase.ts +0 -103
- package/scripts/actions/test.ts +0 -29
- package/scripts/actions/transferFeedsOldIdToNew.ts +0 -40
- package/scripts/actions/transformUserIntoManager.ts +0 -89
- package/scripts/argvConfig.js +0 -9
- package/scripts/backUpData/testCode.ts +0 -131
- package/scripts/benaraScripts/addWorkAreaMap.ts +0 -46
- package/scripts/benaraScripts/add_customers.ts +0 -26
- package/scripts/benaraScripts/add_customers_contact.ts +0 -27
- package/scripts/benaraScripts/add_empty_work_area.ts +0 -17
- package/scripts/benaraScripts/assignManagers.ts +0 -35
- package/scripts/benaraScripts/changeCheckInFlag.ts +0 -45
- package/scripts/benaraScripts/createCustomerContactsList.ts +0 -170
- package/scripts/benaraScripts/createUserByDeletingOldUser.ts +0 -70
- package/scripts/benaraScripts/createUsersAreaMapCollection.ts +0 -23
- package/scripts/benaraScripts/createWorkAreaMap.ts +0 -24
- package/scripts/benaraScripts/mapWorkAreasToUsers.ts +0 -112
- package/scripts/companies_data.json +0 -2496
- package/scripts/create_or_update_users.ts +0 -31
- package/scripts/csvToJson/csvToJson.ts +0 -90
- package/scripts/csvToJson/users.json +0 -3896
- package/scripts/db.js +0 -27
- package/scripts/db.json +0 -13
- package/scripts/dbMySql.ts +0 -63
- package/scripts/delete_action_steps.ts +0 -11
- package/scripts/delete_user.ts +0 -71
- package/scripts/dev_companies_data.json +0 -613
- package/scripts/enroll.xlsx +0 -0
- package/scripts/export_users.ts +0 -72
- package/scripts/files/visitorManagementFiles/displayScreen.json +0 -70
- package/scripts/files/visitorManagementFiles/init_report_visibility.ts +0 -79
- package/scripts/firebaseConfig.js +0 -12
- package/scripts/firebaseDocs/deleteIncommingCollection.ts +0 -47
- package/scripts/firebaseDocs/updateDoc.ts +0 -43
- package/scripts/getActionDataIntoJSON/getActionData.ts +0 -68
- package/scripts/get_attendance_by_any_date.ts +0 -14
- package/scripts/get_attendance_by_month.ts +0 -12
- package/scripts/get_attendance_monthly_by_team.ts +0 -11
- package/scripts/get_daily_report.ts +0 -10
- package/scripts/get_mangers.ts +0 -13
- package/scripts/grant_user_license.ts +0 -18
- package/scripts/init_CustomCollection.ts +0 -16
- package/scripts/init_action_steps.ts +0 -28
- package/scripts/init_actions.ts +0 -31
- package/scripts/init_company.ts +0 -18
- package/scripts/init_customer_mysql.ts +0 -12
- package/scripts/init_feed.ts +0 -4
- package/scripts/init_feed_details_screen.ts +0 -14
- package/scripts/init_geofence.ts +0 -26
- package/scripts/init_print_details_screen.ts +0 -14
- package/scripts/init_report_actions.ts +0 -24
- package/scripts/init_report_definition_detail.ts +0 -26
- package/scripts/init_report_definition_summary.ts +0 -16
- package/scripts/init_report_visibility.ts +0 -46
- package/scripts/init_user_customcollection.ts +0 -16
- package/scripts/json/action.json +0 -21
- package/scripts/json/company.json +0 -24
- package/scripts/json/report-action.json +0 -13
- package/scripts/json/report-def-deet.json +0 -43
- package/scripts/json/resp.json +0 -784
- package/scripts/json/steps.json +0 -24
- package/scripts/json/test.ts +0 -49
- package/scripts/mysqlConfig.ts +0 -9
- package/scripts/revoke_or_extend_license.ts +0 -14
- package/scripts/stream.js +0 -4
- package/scripts/testing1.ts +0 -35
- package/scripts/update/doc.json +0 -20
- package/scripts/update/getDocByPath.ts +0 -34
- package/scripts/update/updateDocByPath.ts +0 -47
- package/scripts/update/updateUsersOfCompanies.ts +0 -58
- package/scripts/update_actions.ts +0 -19
- package/scripts/update_actions_steps.ts +0 -19
- package/scripts/update_company.ts +0 -19
- package/scripts/update_geofence.ts +0 -20
- package/scripts/update_managers.ts +0 -16
- package/scripts/visitorMgmt/createArea.ts +0 -68
- package/scripts/visitorMgmt/createArea.txt +0 -3
- package/scripts/visitorMgmt/createVisitorPathInstructionDocs.ts +0 -130
- package/scripts/visitorMgmt/createVisitorPathInstructionDocs.txt +0 -18
- package/scripts/visitorMgmt/encryptDateString.ts +0 -71
- package/scripts/visitorMgmt/makeHostsManagersOfEachOther.ts +0 -117
- package/scripts/whatsapp_gupshup/sendMessage.ts +0 -97
- package/src/models/Feed-Details-Screen.model.ts +0 -29
- package/src/models/action.model.ts +0 -355
- package/src/models/actions/doffing.ts +0 -71
- package/src/models/actions/folding.ts +0 -39
- package/src/models/attendance.model.ts +0 -615
- package/src/models/cicoPost.model.ts +0 -20
- package/src/models/company.model.ts +0 -975
- package/src/models/contact-us/resquest.model.ts +0 -87
- package/src/models/crud/crud.ts +0 -30
- package/src/models/customCollection.model.ts +0 -47
- package/src/models/customer/customer.model.ts +0 -85
- package/src/models/deviceChangeReq.ts +0 -150
- package/src/models/dispatch.model.ts +0 -99
- package/src/models/feed.models.ts +0 -104
- package/src/models/geofence.model.ts +0 -61
- package/src/models/leaveApplicationPost.model.ts +0 -79
- package/src/models/license.model.ts +0 -215
- package/src/models/meeting.model.ts +0 -80
- package/src/models/meter.model.ts +0 -62
- package/src/models/missingPunchPost.model.ts +0 -84
- package/src/models/offline.model.ts +0 -1133
- package/src/models/post.model.ts +0 -105
- package/src/models/printDetailsScreen.model.ts +0 -30
- package/src/models/pushNotifications/pushNotification.model.ts +0 -17
- package/src/models/report-actions.model.ts +0 -57
- package/src/models/report-definition-details.model.ts +0 -89
- package/src/models/report-definition.model.ts +0 -26
- package/src/models/report-definitions-summary.model.ts +0 -59
- package/src/models/report-detail-data.model.ts +0 -49
- package/src/models/report-visibility.model.ts +0 -44
- package/src/models/report.model.ts +0 -179
- package/src/models/reportGenerator.model.ts +0 -883
- package/src/models/response.model.ts +0 -31
- package/src/models/steps.factory.model.ts +0 -195
- package/src/models/storeGupShupLog.model.ts +0 -49
- package/src/models/tasks/sub-task-group.model.ts +0 -173
- package/src/models/tasks/tags.model.ts +0 -113
- package/src/models/tasks/task-group.model.ts +0 -172
- package/src/models/tasks/task.model.ts +0 -681
- package/src/models/user.model.ts +0 -319
- package/src/models/utility.model.ts +0 -100
- package/src/models/visitorManagement/acknowledgement.model.ts +0 -71
- package/src/models/visitorManagement/invite.model.ts +0 -406
- package/src/models/visitorManagement/newIn.model.ts +0 -82
- package/src/models/visitorManagement/selfServe.model.ts +0 -58
- package/src/models/worklogPost.model.ts +0 -8
- package/src/services/customer.ts +0 -382
- package/src/services/meeting.ts +0 -123
- package/test/1.ts +0 -13
- package/test/db.js +0 -19
- package/test/firebaseConfig.js +0 -1
- package/tsconfig.json +0 -16
package/src/models/post.model.ts
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
import { Offline } from "./offline.model";
|
2
|
-
import * as admin from "firebase-admin";
|
3
|
-
import { Dispatch } from "./dispatch.model";
|
4
|
-
import { Company } from "./company.model";
|
5
|
-
import { User } from "./user.model";
|
6
|
-
import { Action } from "./action.model";
|
7
|
-
class Post {
|
8
|
-
actionEvent: string = "";
|
9
|
-
actionId : string = "";
|
10
|
-
actionName: string = "";
|
11
|
-
actionType: string = "";
|
12
|
-
companyId: string = "";
|
13
|
-
createdAt: string = "";
|
14
|
-
refId: string = "";
|
15
|
-
description: string = "";
|
16
|
-
eventId : string = "";
|
17
|
-
isGeofence: boolean = false;
|
18
|
-
userId: string = "";
|
19
|
-
id: string = "";
|
20
|
-
forApproval: boolean = false;
|
21
|
-
forApprovalText: string = "";
|
22
|
-
object: any = null;
|
23
|
-
origin: any = null;
|
24
|
-
seen: boolean = false;
|
25
|
-
startAt: string = "";
|
26
|
-
startLat: string = "";
|
27
|
-
startLong: string = "";
|
28
|
-
endAt: string = "";
|
29
|
-
endLat: string = "";
|
30
|
-
endLong: string = "";
|
31
|
-
stepValues: any[] = [];
|
32
|
-
target: string = "";
|
33
|
-
time: string = "";
|
34
|
-
extraData: any = {};
|
35
|
-
checkInternet: boolean = false;
|
36
|
-
image: string = "";
|
37
|
-
eventDetails: string = "";
|
38
|
-
isProcessed: boolean = false;
|
39
|
-
missedEvent: string = "";
|
40
|
-
|
41
|
-
static async createNewPost(firestore:admin.firestore.Firestore,postInfo: any){
|
42
|
-
let incomingDocId = postInfo.id
|
43
|
-
try{
|
44
|
-
let userRef = await Offline.createRefForUser(firestore, postInfo.companyId, postInfo.userId);
|
45
|
-
postInfo.id = userRef.id;
|
46
|
-
const postToSave = JSON.parse(JSON.stringify(postInfo));
|
47
|
-
console.log("------before saving in company")
|
48
|
-
let postEventId = await Offline.addDetailsToCompanyActions(firestore,
|
49
|
-
postInfo.companyId,
|
50
|
-
postInfo.actionId,
|
51
|
-
postToSave,
|
52
|
-
postInfo.actionName);
|
53
|
-
postToSave.eventId = postEventId;
|
54
|
-
await userRef.set(postToSave);
|
55
|
-
console.log("post sent to user feed");
|
56
|
-
await Offline.sendFeedToManagers(firestore,
|
57
|
-
postInfo.companyId,
|
58
|
-
postInfo.userId,
|
59
|
-
postToSave);
|
60
|
-
console.log("post sent to managers' feed",postToSave.startAt)
|
61
|
-
await Offline.deleteInfoFromIncoming(firestore, incomingDocId);
|
62
|
-
console.log("document deleted from incoming");
|
63
|
-
return postEventId
|
64
|
-
}
|
65
|
-
catch(error){
|
66
|
-
await firestore.collection("Incoming").doc(incomingDocId).update({
|
67
|
-
message: "Error",
|
68
|
-
errorDetail: error,
|
69
|
-
errorId: "err101",
|
70
|
-
})
|
71
|
-
console.log(error)
|
72
|
-
return error
|
73
|
-
}
|
74
|
-
}
|
75
|
-
|
76
|
-
static async sendDCRPost(firestore: admin.firestore.Firestore,
|
77
|
-
postToSave: any) {
|
78
|
-
const nickName = "mobiOffice";
|
79
|
-
const companyId = await Company.getCompanyIdByNickName(firestore, nickName);
|
80
|
-
const actionId = await Action.getActionId(firestore, companyId, postToSave.actionName)
|
81
|
-
const supportUsers = await Company.getUsersListbyCompany(firestore, nickName);
|
82
|
-
console.log(actionId, companyId);
|
83
|
-
const postEventDocRef = firestore.collection("Companies")
|
84
|
-
.doc(companyId)
|
85
|
-
.collection("Actions")
|
86
|
-
.doc(actionId)
|
87
|
-
.collection(postToSave.actionName)
|
88
|
-
.doc(postToSave.id)
|
89
|
-
postToSave.eventId = postToSave.id;
|
90
|
-
await postEventDocRef.set(postToSave)
|
91
|
-
const feedIdObj: any = {}
|
92
|
-
for (let user of supportUsers) {
|
93
|
-
let userRef = firestore.collection("Feeds")
|
94
|
-
.doc(user.id)
|
95
|
-
.collection(companyId)
|
96
|
-
.doc(postToSave.id)
|
97
|
-
// postToSave.id = userRef.id;
|
98
|
-
await userRef.set(postToSave);
|
99
|
-
// feedIdObj[user.id] = userRef.id;
|
100
|
-
}
|
101
|
-
// return feedIdObj;
|
102
|
-
}
|
103
|
-
}
|
104
|
-
|
105
|
-
export { Post };
|
@@ -1,30 +0,0 @@
|
|
1
|
-
import * as admin from 'firebase-admin';
|
2
|
-
import { Company } from './company.model';
|
3
|
-
|
4
|
-
class PrintDetailsScreen {
|
5
|
-
|
6
|
-
static async createPrintDetailsScreen(firestore:admin.firestore.Firestore,nickName:string,data:any){
|
7
|
-
let companyId = await Company.getCompanyIdbyNickname(firestore,nickName);
|
8
|
-
let snapshot = firestore
|
9
|
-
.collection("Companies")
|
10
|
-
.doc(companyId)
|
11
|
-
.collection("Print-Details-Screen").doc()
|
12
|
-
data.id = snapshot.id
|
13
|
-
await snapshot.set(data)
|
14
|
-
return data
|
15
|
-
}
|
16
|
-
|
17
|
-
|
18
|
-
static async updatePrintDetailsScreen(firestore:admin.firestore.Firestore,nickName:string,data:any){
|
19
|
-
let companyId = await Company.getCompanyIdbyNickname(firestore,nickName);
|
20
|
-
let snapshot = await firestore
|
21
|
-
.collection("Companies")
|
22
|
-
.doc(companyId)
|
23
|
-
.collection("Print-Details-Screen").where("actionName","==",data.actionName).get()
|
24
|
-
snapshot.forEach((doc)=>{
|
25
|
-
doc.ref.update(data)
|
26
|
-
})
|
27
|
-
}
|
28
|
-
|
29
|
-
}
|
30
|
-
export { PrintDetailsScreen };
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import { firestore } from "firebase-admin";
|
2
|
-
|
3
|
-
class PushNotifications {
|
4
|
-
static async sendPushNotification(admin: any,
|
5
|
-
fcmTokens: string[], message: any) {
|
6
|
-
try {
|
7
|
-
const response = await admin.messaging().sendToDevice(fcmTokens, message);
|
8
|
-
console.log(response.results);
|
9
|
-
// console.log(response[0].error)
|
10
|
-
return "Notification Sent Successfully"
|
11
|
-
} catch (error: any) {
|
12
|
-
throw new Error(error.message)
|
13
|
-
}
|
14
|
-
}
|
15
|
-
}
|
16
|
-
|
17
|
-
export { PushNotifications };
|
@@ -1,57 +0,0 @@
|
|
1
|
-
import * as admin from 'firebase-admin';
|
2
|
-
import { Action } from './action.model';
|
3
|
-
import { Company } from './company.model';
|
4
|
-
class ReportActions {
|
5
|
-
darkColor: string = "";
|
6
|
-
lightColor: string = "";
|
7
|
-
description: string = "";
|
8
|
-
icon: string = "";
|
9
|
-
title: string = "";
|
10
|
-
url: string = "";
|
11
|
-
id:string = "";
|
12
|
-
order: string = "";
|
13
|
-
keys: string = "";
|
14
|
-
|
15
|
-
static async getOrCreateReportActions(firestore:admin.firestore.Firestore,nickName:string,reportAction:any){
|
16
|
-
if(!reportAction.title){
|
17
|
-
return "Please provide title"
|
18
|
-
}
|
19
|
-
let companyId = await Company.getCompanyIdbyNickname(firestore,nickName)
|
20
|
-
let snapshot = firestore.collection('Companies').doc(companyId).collection('Report-Actions')
|
21
|
-
let reportAction_data = await snapshot.where('title','==',reportAction.title).get()
|
22
|
-
if(reportAction_data.empty){
|
23
|
-
let actionId = await Action.getActionIdByDisplayName(firestore,companyId,reportAction.title);
|
24
|
-
//reportAction = await ReportActions.convertReportActionsDataType(reportAction)
|
25
|
-
reportAction.id = actionId
|
26
|
-
let reportaction_snapshot_newData = snapshot.doc(actionId)
|
27
|
-
await reportaction_snapshot_newData.set(reportAction)
|
28
|
-
return (await reportaction_snapshot_newData.get()).data()
|
29
|
-
}else{
|
30
|
-
return reportAction_data.docs[0].data()
|
31
|
-
}
|
32
|
-
}
|
33
|
-
|
34
|
-
static async convertReportActionsDataType(data:any){
|
35
|
-
if(data.keys){
|
36
|
-
data.keys = data.keys.split('&')
|
37
|
-
}
|
38
|
-
if(data.order){
|
39
|
-
data.order = Number(data.order)
|
40
|
-
}
|
41
|
-
return data
|
42
|
-
}
|
43
|
-
|
44
|
-
static reportActionsTemplate = {
|
45
|
-
darkColor: null,
|
46
|
-
lightColor: null,
|
47
|
-
description: null,
|
48
|
-
icon: null,
|
49
|
-
title: null,
|
50
|
-
url: null,
|
51
|
-
id: null,
|
52
|
-
order: null,
|
53
|
-
keys: null,
|
54
|
-
};
|
55
|
-
}
|
56
|
-
|
57
|
-
export { ReportActions };
|
@@ -1,89 +0,0 @@
|
|
1
|
-
import * as admin from 'firebase-admin';
|
2
|
-
import { Action } from './action.model';
|
3
|
-
import { Company } from './company.model';
|
4
|
-
import { ReportDefinitionSummary } from './report-definitions-summary.model';
|
5
|
-
|
6
|
-
|
7
|
-
class ReportDefinitionDetail {
|
8
|
-
color:string = "";
|
9
|
-
data:any[] = [];
|
10
|
-
detailOf:string = "";
|
11
|
-
name:string = "";
|
12
|
-
toHome:boolean = false;
|
13
|
-
id:string = ""
|
14
|
-
nickname?:string = ""
|
15
|
-
|
16
|
-
|
17
|
-
static async getOrCreateReportDefinitionDetail(firestore:admin.firestore.Firestore,nickName:string,reportDefinitionDetail:ReportDefinitionDetail){
|
18
|
-
let companyId = await Company.getCompanyIdbyNickname(firestore,nickName);
|
19
|
-
let snapshot = firestore
|
20
|
-
.collection("Companies")
|
21
|
-
.doc(companyId)
|
22
|
-
.collection("Report-Definition-Detail")
|
23
|
-
let reportDefinitionDetials_snapshot = await snapshot.where('name','==',reportDefinitionDetail.name).get()
|
24
|
-
if(reportDefinitionDetials_snapshot.empty){
|
25
|
-
//reportDefinitionDetail = await ReportDefinitionDetail.convertReportDefinitionDetail(reportDefinitionDetail)
|
26
|
-
let docRef = snapshot.doc()
|
27
|
-
let id = await ReportDefinitionSummary.getReportDefinitionSummaryId(firestore,nickName,reportDefinitionDetail.name)
|
28
|
-
if(!id.length){
|
29
|
-
id = await Action.getActionIdByDisplayName(firestore,companyId,reportDefinitionDetail.name)
|
30
|
-
}
|
31
|
-
reportDefinitionDetail.detailOf = id
|
32
|
-
reportDefinitionDetail.id = docRef.id
|
33
|
-
await docRef.set(reportDefinitionDetail);
|
34
|
-
return (await docRef.get()).data()
|
35
|
-
}else{
|
36
|
-
return reportDefinitionDetials_snapshot.docs[0].data()
|
37
|
-
}
|
38
|
-
}
|
39
|
-
|
40
|
-
static async convertReportDefinitionDetail(data:any){
|
41
|
-
if(data.toHome){
|
42
|
-
data.toHome = await Action.booleanConvertion(data.toHome.toLowerCase());
|
43
|
-
}
|
44
|
-
if(data.share){
|
45
|
-
data.share = await Action.booleanConvertion(data.share.toLowerCase());
|
46
|
-
}
|
47
|
-
if(data.keys){
|
48
|
-
data.keys = await data.keys.split("&")
|
49
|
-
}
|
50
|
-
if(data.data){
|
51
|
-
for(let subData of data.data){
|
52
|
-
if(subData.autoAPICalled){
|
53
|
-
subData.autoAPICalled = await Action.booleanConvertion(subData.autoAPICalled);
|
54
|
-
}
|
55
|
-
if(subData.isSSL){
|
56
|
-
subData.isSSL = await Action.booleanConvertion(subData.isSSL);
|
57
|
-
}
|
58
|
-
if(subData.halfPage){
|
59
|
-
subData.halfPage = await Action.booleanConvertion(subData.halfPage);
|
60
|
-
}
|
61
|
-
if(subData.fullPage){
|
62
|
-
subData.fullPage = await Action.booleanConvertion(subData.fullPage);
|
63
|
-
}
|
64
|
-
if(subData.keys){
|
65
|
-
subData.keys = subData.keys.split('&')
|
66
|
-
}
|
67
|
-
if(subData.nextPage){
|
68
|
-
subData.nextPage = Number(subData.nextPage)
|
69
|
-
}
|
70
|
-
if(subData.pageSize){
|
71
|
-
subData.pageSize = Number(subData.pageSize)
|
72
|
-
}
|
73
|
-
if(subData.rowHeight){
|
74
|
-
subData.rowHeight = Number(subData.rowHeight)
|
75
|
-
}
|
76
|
-
if(subData.order){
|
77
|
-
subData.order = Number(subData.order)
|
78
|
-
}
|
79
|
-
if(subData.totalItems){
|
80
|
-
subData.totalItems = Number(subData.totalItems)
|
81
|
-
}
|
82
|
-
}
|
83
|
-
}
|
84
|
-
|
85
|
-
return data
|
86
|
-
}
|
87
|
-
}
|
88
|
-
|
89
|
-
export { ReportDefinitionDetail }
|
@@ -1,26 +0,0 @@
|
|
1
|
-
class ReportDefinition {
|
2
|
-
|
3
|
-
id:string = "";
|
4
|
-
name:string = "";
|
5
|
-
detailOf: string = "";
|
6
|
-
toHome: boolean = true;
|
7
|
-
share:boolean = false;
|
8
|
-
keys:[] = [];
|
9
|
-
color:string = "";
|
10
|
-
downloadUrl:string = "";
|
11
|
-
data:[] = [];
|
12
|
-
|
13
|
-
static reportDefTemplate = {
|
14
|
-
id: "",
|
15
|
-
name: "",
|
16
|
-
detailOf: "",
|
17
|
-
toHome: true,
|
18
|
-
share: false,
|
19
|
-
keys: [],
|
20
|
-
color: "",
|
21
|
-
downloadUrl: "",
|
22
|
-
data: [],
|
23
|
-
};
|
24
|
-
}
|
25
|
-
|
26
|
-
export { ReportDefinition };
|
@@ -1,59 +0,0 @@
|
|
1
|
-
import * as admin from 'firebase-admin';
|
2
|
-
import { Action } from './action.model';
|
3
|
-
import { Company } from './company.model';
|
4
|
-
class ReportDefinitionSummary {
|
5
|
-
static async getOrCreateReportDefinitionSummary(firestore:admin.firestore.Firestore,nickName:string,reportSummary:any){
|
6
|
-
let companyId = await Company.getCompanyIdbyNickname(firestore,nickName)
|
7
|
-
let snapshot = await firestore
|
8
|
-
.collection("Companies")
|
9
|
-
.doc(companyId)
|
10
|
-
.collection("Report-Definition-Summary");
|
11
|
-
let ReportDefinitionSummary_data = await snapshot.where("name", "==", reportSummary.name).get();
|
12
|
-
if(ReportDefinitionSummary_data.empty){
|
13
|
-
reportSummary = await ReportDefinitionSummary.convertReportDefinitionSummary(reportSummary)
|
14
|
-
let docRef = snapshot.doc()
|
15
|
-
reportSummary.id = docRef.id
|
16
|
-
await docRef.set(reportSummary);
|
17
|
-
return (await docRef.get()).data()
|
18
|
-
}else{
|
19
|
-
return ReportDefinitionSummary_data.docs[0].data()
|
20
|
-
}
|
21
|
-
}
|
22
|
-
|
23
|
-
static async convertReportDefinitionSummary(data:any){
|
24
|
-
if(data.autoAPICall){
|
25
|
-
data.autoAPICall = await Action.booleanConvertion(data.autoAPICall.toLowerCase())
|
26
|
-
}
|
27
|
-
return data
|
28
|
-
}
|
29
|
-
|
30
|
-
static async getReportDefinitionSummaryId(firestore:admin.firestore.Firestore,nickName:string,reportDefinitionSummaryName:string){
|
31
|
-
let companyId = await Company.getCompanyIdbyNickname(firestore,nickName)
|
32
|
-
let docRef = await firestore
|
33
|
-
.collection("Companies")
|
34
|
-
.doc(companyId)
|
35
|
-
.collection("Report-Definition-Summary")
|
36
|
-
.where('name','==',reportDefinitionSummaryName)
|
37
|
-
.get()
|
38
|
-
let id = ""
|
39
|
-
docRef.forEach((doc)=>{
|
40
|
-
id = doc.data().id
|
41
|
-
})
|
42
|
-
return id
|
43
|
-
}
|
44
|
-
|
45
|
-
static async getReportDefinitionSummaryDocById(firestore:admin.firestore.Firestore,companyId:string,docId:string){
|
46
|
-
try{
|
47
|
-
let snapshot = await firestore.collection("Companies")
|
48
|
-
.doc(companyId)
|
49
|
-
.collection("Report-Definition-Summary")
|
50
|
-
.doc(docId)
|
51
|
-
.get()
|
52
|
-
return snapshot.data()
|
53
|
-
}
|
54
|
-
catch(error:any){
|
55
|
-
throw new Error(error.message)
|
56
|
-
}
|
57
|
-
}
|
58
|
-
}
|
59
|
-
export { ReportDefinitionSummary };
|
@@ -1,49 +0,0 @@
|
|
1
|
-
class ReportDetailData {
|
2
|
-
id:string = "";
|
3
|
-
url:string ="";
|
4
|
-
reportType:string = "";
|
5
|
-
halfPage:boolean = true;
|
6
|
-
fullPage:boolean = false ;
|
7
|
-
pageSize:number = 10;
|
8
|
-
nextPage:number = 1;
|
9
|
-
totalItems:number = 30;
|
10
|
-
data: []= [];
|
11
|
-
autoAPICalled:boolean = false;
|
12
|
-
showPrint:boolean = false;
|
13
|
-
showBarcode:boolean = false;
|
14
|
-
isSSL :boolean = true;
|
15
|
-
saveInPublicStorage:boolean = true;
|
16
|
-
keys:[] = [];
|
17
|
-
order:number = 0;
|
18
|
-
type:string = "";
|
19
|
-
|
20
|
-
static reportDataType = {
|
21
|
-
TILE: "tile",
|
22
|
-
TABLE: "table",
|
23
|
-
PDF: "pdf",
|
24
|
-
TEXT: "text",
|
25
|
-
};
|
26
|
-
|
27
|
-
static reportDetailDataTemplate = {
|
28
|
-
id: "",
|
29
|
-
url: "",
|
30
|
-
loadingText: "",
|
31
|
-
reportType: "",
|
32
|
-
halfPage: true,
|
33
|
-
fullPage: false,
|
34
|
-
pageSize: 10,
|
35
|
-
nextPage: 1,
|
36
|
-
totalItems: 30,
|
37
|
-
data: [],
|
38
|
-
type: "tile",
|
39
|
-
autoAPICalled: false,
|
40
|
-
showPrint: false,
|
41
|
-
showBarcode: false,
|
42
|
-
isSSL: true,
|
43
|
-
saveInPublicStorage: true,
|
44
|
-
keys: [],
|
45
|
-
order: 0,
|
46
|
-
};
|
47
|
-
}
|
48
|
-
|
49
|
-
export { ReportDetailData };
|
@@ -1,44 +0,0 @@
|
|
1
|
-
import * as admin from 'firebase-admin';
|
2
|
-
import { Company } from './company.model';
|
3
|
-
|
4
|
-
class ReportVisibility{
|
5
|
-
|
6
|
-
static async setReportVisibility(firestore:admin.firestore.Firestore,nickName:string,reportVisibilityData:any){
|
7
|
-
let companyId = await Company.getCompanyIdbyNickname(firestore,nickName);
|
8
|
-
let docRef = firestore
|
9
|
-
.collection("Companies")
|
10
|
-
.doc(companyId)
|
11
|
-
.collection("Report-Visibility")
|
12
|
-
.doc(reportVisibilityData.id);
|
13
|
-
docRef.set(reportVisibilityData);
|
14
|
-
return docRef.id;
|
15
|
-
}
|
16
|
-
|
17
|
-
static async updateReportVisibility(firestore:admin.firestore.Firestore,arrayUnion:any,nickName:string,userId:string,reportVisibilityData:any){
|
18
|
-
let companyId = await Company.getCompanyIdbyNickname(firestore,nickName);
|
19
|
-
let docRef = await firestore.collection("Companies")
|
20
|
-
.doc(companyId)
|
21
|
-
.collection("Report-Visibility")
|
22
|
-
.doc(userId).get();
|
23
|
-
await docRef.ref.update({
|
24
|
-
"report-sections": arrayUnion(reportVisibilityData)
|
25
|
-
})
|
26
|
-
return docRef.data()?.id
|
27
|
-
}
|
28
|
-
|
29
|
-
static async getUserReportList(firestore:admin.firestore.Firestore,companyId:string,userId:string){
|
30
|
-
try{
|
31
|
-
let userReportSnapshot = await firestore.collection("Companies")
|
32
|
-
.doc(companyId)
|
33
|
-
.collection("Report-Visibility")
|
34
|
-
.doc(userId)
|
35
|
-
.get()
|
36
|
-
let userReportsList = userReportSnapshot.data()
|
37
|
-
return userReportsList;
|
38
|
-
}
|
39
|
-
catch(error:any){
|
40
|
-
throw new Error(error.message)
|
41
|
-
}
|
42
|
-
}
|
43
|
-
}
|
44
|
-
export { ReportVisibility };
|
@@ -1,179 +0,0 @@
|
|
1
|
-
import { ReportDefinition } from "./report-definition.model";
|
2
|
-
import * as admin from "firebase-admin";
|
3
|
-
import { ReportActions } from "./report-actions.model";
|
4
|
-
import { Action } from "./action.model";
|
5
|
-
import { Utilities } from "./utility.model";
|
6
|
-
import { ReportGenerator } from "./reportGenerator.model";
|
7
|
-
import { Pool } from "mysql2";
|
8
|
-
|
9
|
-
class Report {
|
10
|
-
static async addReport(
|
11
|
-
firebase: admin.firestore.Firestore,
|
12
|
-
companyId: string,
|
13
|
-
report: ReportDefinition
|
14
|
-
) {
|
15
|
-
let reportRef = firebase
|
16
|
-
.collection("Companies")
|
17
|
-
.doc(companyId)
|
18
|
-
.collection("Report-Definition-Detail")
|
19
|
-
.doc();
|
20
|
-
report.id = reportRef.id;
|
21
|
-
try {
|
22
|
-
await reportRef.set({ ...report });
|
23
|
-
return report;
|
24
|
-
} catch (e) {
|
25
|
-
throw e;
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
29
|
-
static async addReportAction(
|
30
|
-
firestore: admin.firestore.Firestore,
|
31
|
-
companyId: string,
|
32
|
-
reportActionMap: ReportActions
|
33
|
-
) {
|
34
|
-
var raRef = firestore
|
35
|
-
.collection("Companies")
|
36
|
-
.doc(companyId)
|
37
|
-
.collection("Report-Actions")
|
38
|
-
.doc(reportActionMap.id);
|
39
|
-
raRef.set({ ...reportActionMap });
|
40
|
-
|
41
|
-
return reportActionMap;
|
42
|
-
}
|
43
|
-
|
44
|
-
static async getReport(
|
45
|
-
firestore: admin.firestore.Firestore,
|
46
|
-
actionDBMap: Record<string, { connection: Pool, tableName: string }>,
|
47
|
-
nickName: string,
|
48
|
-
action: string,
|
49
|
-
timeStamps: any,
|
50
|
-
phone: string
|
51
|
-
) {
|
52
|
-
try {
|
53
|
-
console.log("Inside getReport");
|
54
|
-
const startTime = await Utilities.epochToMySqlDateTime(timeStamps.fromDate);
|
55
|
-
const endTime = await Utilities.epochToMySqlDateTime(timeStamps.toDate);
|
56
|
-
const timeInterval = {
|
57
|
-
startTime,
|
58
|
-
endTime,
|
59
|
-
};
|
60
|
-
console.log(timeInterval);
|
61
|
-
const reportGenerator = new ReportGenerator();
|
62
|
-
const reportInfo = await reportGenerator.generateReport(
|
63
|
-
firestore,
|
64
|
-
actionDBMap,
|
65
|
-
nickName,
|
66
|
-
action,
|
67
|
-
timeInterval,
|
68
|
-
phone
|
69
|
-
);
|
70
|
-
return reportInfo;
|
71
|
-
} catch (error) {
|
72
|
-
throw error;
|
73
|
-
}
|
74
|
-
}
|
75
|
-
|
76
|
-
static async getCicoInfoForDay(
|
77
|
-
firestore: admin.firestore.Firestore,
|
78
|
-
userId: string,
|
79
|
-
companyId: string,
|
80
|
-
startTime: number
|
81
|
-
) {
|
82
|
-
const cicoActionName = "check_in_out";
|
83
|
-
const cicoInfo = {
|
84
|
-
checkIn: "",
|
85
|
-
checkOut: "",
|
86
|
-
};
|
87
|
-
const cicoActionId = await Action.getActionId(
|
88
|
-
firestore,
|
89
|
-
companyId,
|
90
|
-
cicoActionName
|
91
|
-
);
|
92
|
-
const cicoInfo_snapshot = await firestore
|
93
|
-
.collection("Companies")
|
94
|
-
.doc(companyId)
|
95
|
-
.collection("Actions")
|
96
|
-
.doc(cicoActionId)
|
97
|
-
.collection(cicoActionName)
|
98
|
-
.where("userId", "==", userId)
|
99
|
-
.where("createdAt", ">=", startTime)
|
100
|
-
.where("createdAt", "<=", startTime + 86400000)
|
101
|
-
.orderBy("createdAt", "desc")
|
102
|
-
.get();
|
103
|
-
let checkInTime: number = 0;
|
104
|
-
let checkOutTime: number = 0;
|
105
|
-
cicoInfo_snapshot.forEach((doc: any) => {
|
106
|
-
if (doc.data().startAt) {
|
107
|
-
checkInTime = doc.data().startAt;
|
108
|
-
}
|
109
|
-
if (doc.data().endAt) {
|
110
|
-
checkOutTime = doc.data().endAt;
|
111
|
-
}
|
112
|
-
});
|
113
|
-
if (checkInTime === 0) {
|
114
|
-
cicoInfo.checkIn = "Not Found";
|
115
|
-
} else {
|
116
|
-
cicoInfo.checkIn = new Date(checkInTime).toLocaleTimeString("en-GB", {
|
117
|
-
timeZone: "asia/kolkata",
|
118
|
-
});
|
119
|
-
}
|
120
|
-
if (checkOutTime === 0) {
|
121
|
-
cicoInfo.checkOut = "Not Found";
|
122
|
-
} else {
|
123
|
-
cicoInfo.checkOut = new Date(checkOutTime).toLocaleTimeString("en-GB", {
|
124
|
-
timeZone: "asia/kolkata",
|
125
|
-
});
|
126
|
-
}
|
127
|
-
return cicoInfo;
|
128
|
-
}
|
129
|
-
|
130
|
-
static async getReportObjForUser(
|
131
|
-
firestore: admin.firestore.Firestore,
|
132
|
-
userId: any,
|
133
|
-
companyId: string,
|
134
|
-
action: string,
|
135
|
-
timeStamps: any
|
136
|
-
) {
|
137
|
-
try {
|
138
|
-
let reportDocs: any = [];
|
139
|
-
const actionId = await Action.getActionId(firestore, companyId, action);
|
140
|
-
const userInfo_snapshot = await firestore
|
141
|
-
.collection("Companies")
|
142
|
-
.doc(companyId)
|
143
|
-
.collection("Actions")
|
144
|
-
.doc(actionId)
|
145
|
-
.collection(action)
|
146
|
-
.where("userId", "==", userId)
|
147
|
-
.get();
|
148
|
-
userInfo_snapshot.forEach((doc) => {
|
149
|
-
if (
|
150
|
-
doc.data().createdAt >= timeStamps.fromDate &&
|
151
|
-
doc.data().createdAt <= timeStamps.toDate
|
152
|
-
) {
|
153
|
-
reportDocs.push(doc.data());
|
154
|
-
}
|
155
|
-
});
|
156
|
-
return reportDocs;
|
157
|
-
} catch (error) {
|
158
|
-
throw error;
|
159
|
-
}
|
160
|
-
}
|
161
|
-
|
162
|
-
static async getReportObjForDay(reportObjects: any, startTime: number) {
|
163
|
-
try {
|
164
|
-
const milliSecondsInADay = 24 * 60 * 60 * 1000;
|
165
|
-
let reportObjectsForDay = reportObjects.filter((obj: any) => {
|
166
|
-
if (obj.createdAt < startTime + milliSecondsInADay) {
|
167
|
-
return true;
|
168
|
-
} else {
|
169
|
-
return false;
|
170
|
-
}
|
171
|
-
});
|
172
|
-
return reportObjectsForDay;
|
173
|
-
} catch (error) {
|
174
|
-
throw error;
|
175
|
-
}
|
176
|
-
}
|
177
|
-
}
|
178
|
-
|
179
|
-
export { Report };
|