mobioffice-cli 0.0.1
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/.prettierrc +4 -0
- package/README.md +1 -0
- package/a.js +3 -0
- package/lib/index.js +87 -0
- package/package.json +50 -0
- package/scripts/1.ts +1300 -0
- package/scripts/GCloudPubSub/pub-sub-config.json +12 -0
- package/scripts/GCloudPubSub/visitorAutoRejection.ts +86 -0
- package/scripts/actions/assignUsersFromOneActionToOther.ts +64 -0
- package/scripts/actions/assignUsersListToAction.ts +81 -0
- package/scripts/actions/getActionsListOfUser.ts +42 -0
- package/scripts/actions/getCompanyUserDetails.ts +49 -0
- package/scripts/actions/giveActionToUser.ts +41 -0
- package/scripts/actions/giveUsersToActivitySelector.ts +56 -0
- package/scripts/actions/groupActionsInActivitySelector.ts +101 -0
- package/scripts/actions/modifySummaryReportDB.ts +42 -0
- package/scripts/actions/setUrlToActionStep.ts +18 -0
- package/scripts/actions/syncMySqlAttendanceDBWithFirebase.ts +93 -0
- package/scripts/actions/syncMySqlMeetingsDBWithFirebase.ts +103 -0
- package/scripts/actions/test.ts +29 -0
- package/scripts/actions/transferFeedsOldIdToNew.ts +40 -0
- package/scripts/actions/transformUserIntoManager.ts +89 -0
- package/scripts/argvConfig.js +9 -0
- package/scripts/backUpData/testCode.ts +131 -0
- package/scripts/benaraScripts/addWorkAreaMap.ts +46 -0
- package/scripts/benaraScripts/add_customers.ts +26 -0
- package/scripts/benaraScripts/add_customers_contact.ts +27 -0
- package/scripts/benaraScripts/add_empty_work_area.ts +17 -0
- package/scripts/benaraScripts/assignManagers.ts +35 -0
- package/scripts/benaraScripts/changeCheckInFlag.ts +45 -0
- package/scripts/benaraScripts/createCustomerContactsList.ts +170 -0
- package/scripts/benaraScripts/createUserByDeletingOldUser.ts +70 -0
- package/scripts/benaraScripts/createUsersAreaMapCollection.ts +23 -0
- package/scripts/benaraScripts/createWorkAreaMap.ts +24 -0
- package/scripts/benaraScripts/mapWorkAreasToUsers.ts +112 -0
- package/scripts/companies_data.json +2496 -0
- package/scripts/create_or_update_users.ts +31 -0
- package/scripts/csvToJson/csvToJson.ts +90 -0
- package/scripts/csvToJson/users.json +3896 -0
- package/scripts/db.js +27 -0
- package/scripts/db.json +13 -0
- package/scripts/dbMySql.ts +63 -0
- package/scripts/delete_action_steps.ts +11 -0
- package/scripts/delete_user.ts +71 -0
- package/scripts/dev_companies_data.json +613 -0
- package/scripts/enroll.xlsx +0 -0
- package/scripts/export_users.ts +72 -0
- package/scripts/files/visitorManagementFiles/displayScreen.json +70 -0
- package/scripts/files/visitorManagementFiles/init_report_visibility.ts +79 -0
- package/scripts/firebaseConfig.js +12 -0
- package/scripts/firebaseDocs/deleteIncommingCollection.ts +47 -0
- package/scripts/firebaseDocs/updateDoc.ts +43 -0
- package/scripts/getActionDataIntoJSON/getActionData.ts +68 -0
- package/scripts/get_attendance_by_any_date.ts +14 -0
- package/scripts/get_attendance_by_month.ts +12 -0
- package/scripts/get_attendance_monthly_by_team.ts +11 -0
- package/scripts/get_daily_report.ts +10 -0
- package/scripts/get_mangers.ts +13 -0
- package/scripts/grant_user_license.ts +18 -0
- package/scripts/init_CustomCollection.ts +16 -0
- package/scripts/init_action_steps.ts +28 -0
- package/scripts/init_actions.ts +31 -0
- package/scripts/init_company.ts +18 -0
- package/scripts/init_customer_mysql.ts +12 -0
- package/scripts/init_feed.ts +4 -0
- package/scripts/init_feed_details_screen.ts +14 -0
- package/scripts/init_geofence.ts +26 -0
- package/scripts/init_print_details_screen.ts +14 -0
- package/scripts/init_report_actions.ts +24 -0
- package/scripts/init_report_definition_detail.ts +26 -0
- package/scripts/init_report_definition_summary.ts +16 -0
- package/scripts/init_report_visibility.ts +46 -0
- package/scripts/init_user_customcollection.ts +16 -0
- package/scripts/json/action.json +21 -0
- package/scripts/json/company.json +24 -0
- package/scripts/json/report-action.json +13 -0
- package/scripts/json/report-def-deet.json +43 -0
- package/scripts/json/resp.json +784 -0
- package/scripts/json/steps.json +24 -0
- package/scripts/json/test.ts +49 -0
- package/scripts/mysqlConfig.ts +9 -0
- package/scripts/revoke_or_extend_license.ts +14 -0
- package/scripts/stream.js +4 -0
- package/scripts/testing1.ts +35 -0
- package/scripts/update/doc.json +20 -0
- package/scripts/update/getDocByPath.ts +34 -0
- package/scripts/update/updateDocByPath.ts +47 -0
- package/scripts/update/updateUsersOfCompanies.ts +58 -0
- package/scripts/update_actions.ts +19 -0
- package/scripts/update_actions_steps.ts +19 -0
- package/scripts/update_company.ts +19 -0
- package/scripts/update_geofence.ts +20 -0
- package/scripts/update_managers.ts +16 -0
- package/scripts/visitorMgmt/createArea.ts +68 -0
- package/scripts/visitorMgmt/createArea.txt +3 -0
- package/scripts/visitorMgmt/createVisitorPathInstructionDocs.ts +130 -0
- package/scripts/visitorMgmt/createVisitorPathInstructionDocs.txt +18 -0
- package/scripts/visitorMgmt/encryptDateString.ts +71 -0
- package/scripts/visitorMgmt/makeHostsManagersOfEachOther.ts +117 -0
- package/scripts/whatsapp_gupshup/sendMessage.ts +97 -0
- package/src/index.ts +87 -0
- package/src/models/Feed-Details-Screen.model.ts +29 -0
- package/src/models/action.model.ts +355 -0
- package/src/models/actions/doffing.ts +71 -0
- package/src/models/actions/folding.ts +39 -0
- package/src/models/attendance.model.ts +615 -0
- package/src/models/cicoPost.model.ts +20 -0
- package/src/models/company.model.ts +975 -0
- package/src/models/contact-us/resquest.model.ts +87 -0
- package/src/models/crud/crud.ts +30 -0
- package/src/models/customCollection.model.ts +47 -0
- package/src/models/customer/customer.model.ts +85 -0
- package/src/models/deviceChangeReq.ts +150 -0
- package/src/models/dispatch.model.ts +99 -0
- package/src/models/feed.models.ts +104 -0
- package/src/models/geofence.model.ts +61 -0
- package/src/models/leaveApplicationPost.model.ts +79 -0
- package/src/models/license.model.ts +215 -0
- package/src/models/log.model.ts +25 -0
- package/src/models/meeting.model.ts +80 -0
- package/src/models/meter.model.ts +62 -0
- package/src/models/missingPunchPost.model.ts +84 -0
- package/src/models/offline.model.ts +1133 -0
- package/src/models/post.model.ts +105 -0
- package/src/models/printDetailsScreen.model.ts +30 -0
- package/src/models/pushNotifications/pushNotification.model.ts +17 -0
- package/src/models/report-actions.model.ts +57 -0
- package/src/models/report-definition-details.model.ts +89 -0
- package/src/models/report-definition.model.ts +26 -0
- package/src/models/report-definitions-summary.model.ts +59 -0
- package/src/models/report-detail-data.model.ts +49 -0
- package/src/models/report-visibility.model.ts +44 -0
- package/src/models/report.model.ts +179 -0
- package/src/models/reportGenerator.model.ts +883 -0
- package/src/models/response.model.ts +31 -0
- package/src/models/steps.factory.model.ts +195 -0
- package/src/models/storeGupShupLog.model.ts +49 -0
- package/src/models/summary.model.ts +63 -0
- package/src/models/tasks/sub-task-group.model.ts +173 -0
- package/src/models/tasks/tags.model.ts +113 -0
- package/src/models/tasks/task-group.model.ts +172 -0
- package/src/models/tasks/task.model.ts +681 -0
- package/src/models/tempCollection.model.ts +398 -0
- package/src/models/user.model.ts +319 -0
- package/src/models/utility.model.ts +100 -0
- package/src/models/visitorManagement/acknowledgement.model.ts +71 -0
- package/src/models/visitorManagement/invite.model.ts +406 -0
- package/src/models/visitorManagement/newIn.model.ts +82 -0
- package/src/models/visitorManagement/selfServe.model.ts +58 -0
- package/src/models/worklogPost.model.ts +8 -0
- package/src/services/customer.ts +382 -0
- package/src/services/meeting.ts +123 -0
- package/test/1.ts +13 -0
- package/test/db.js +19 -0
- package/test/firebaseConfig.js +1 -0
- package/tsconfig.json +16 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
class HttpResponseAndErrorHandling {
|
2
|
+
private statusCode: number;
|
3
|
+
private message: string;
|
4
|
+
private data: any;
|
5
|
+
private error: any;
|
6
|
+
constructor(statusCode: number,
|
7
|
+
message: string,
|
8
|
+
data: any,
|
9
|
+
error: any) {
|
10
|
+
this.statusCode = statusCode;
|
11
|
+
this.message = message;
|
12
|
+
this.data = data;
|
13
|
+
this.error = error;
|
14
|
+
}
|
15
|
+
getSuccessResponse() {
|
16
|
+
return {
|
17
|
+
statusCode: this.statusCode,
|
18
|
+
message: this.message,
|
19
|
+
data: this.data
|
20
|
+
};
|
21
|
+
}
|
22
|
+
getErrorResponse() {
|
23
|
+
return {
|
24
|
+
statusCode: this.statusCode,
|
25
|
+
message: this.message,
|
26
|
+
error: this.error
|
27
|
+
};
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
export { HttpResponseAndErrorHandling };
|
@@ -0,0 +1,195 @@
|
|
1
|
+
class StepsFactory {
|
2
|
+
buttonActionText:string = "";
|
3
|
+
field:any = new Map();
|
4
|
+
fieldType:string = "";
|
5
|
+
id: string = "";
|
6
|
+
label:string = "";
|
7
|
+
nextCollection:string = "";
|
8
|
+
nextRole:string = "";
|
9
|
+
order:number = 0;
|
10
|
+
submitUrl:string = "";
|
11
|
+
type:string = "";
|
12
|
+
value:string = "";
|
13
|
+
|
14
|
+
initViaSnapshotDoc(doc:any) {
|
15
|
+
var _data = doc.data();
|
16
|
+
|
17
|
+
this.buttonActionText = _data.butttonActionText;
|
18
|
+
this.field = _data.field;
|
19
|
+
this.id = _data.id;
|
20
|
+
this.label = _data.label;
|
21
|
+
this.nextCollection = _data.nextCollection;
|
22
|
+
this.nextRole = _data.nextRole;
|
23
|
+
this.order = _data.order;
|
24
|
+
this.submitUrl = _data.submitUrl;
|
25
|
+
this.type = _data.type;
|
26
|
+
this.value = _data.value;
|
27
|
+
}
|
28
|
+
|
29
|
+
static inputFieldTemplate = {
|
30
|
+
buttonActionText: "Next",
|
31
|
+
field: {
|
32
|
+
hint: "",
|
33
|
+
icon: "",
|
34
|
+
id: "1",
|
35
|
+
url: "",
|
36
|
+
keys: [],
|
37
|
+
typeAheadRequired: false,
|
38
|
+
keyboardType: "",
|
39
|
+
keyForAPI: "",
|
40
|
+
isMultiline: false,
|
41
|
+
isRequired: true,
|
42
|
+
label: "Input",
|
43
|
+
value: "",
|
44
|
+
},
|
45
|
+
fieldType: "InputField",
|
46
|
+
label: "Input",
|
47
|
+
id: "",
|
48
|
+
nextCollection: "",
|
49
|
+
nextRole: "",
|
50
|
+
order: 0,
|
51
|
+
submitUrl: "",
|
52
|
+
type: "normal",
|
53
|
+
value: "",
|
54
|
+
};
|
55
|
+
|
56
|
+
static datePickerTemplate = {
|
57
|
+
buttonActionText: "Next",
|
58
|
+
field: {
|
59
|
+
hint: "",
|
60
|
+
icon: "",
|
61
|
+
id: "1",
|
62
|
+
keyForAPI: "",
|
63
|
+
isRequired: true,
|
64
|
+
label: "Date",
|
65
|
+
value: "",
|
66
|
+
},
|
67
|
+
fieldType: "datePicker",
|
68
|
+
id: "",
|
69
|
+
label: "Date",
|
70
|
+
nextCollection: "",
|
71
|
+
nextRole: "",
|
72
|
+
order: 0,
|
73
|
+
submitUrl: "",
|
74
|
+
type: "normal",
|
75
|
+
value: "",
|
76
|
+
};
|
77
|
+
|
78
|
+
static summaryStepTemplate = {
|
79
|
+
buttonActionText: "Done",
|
80
|
+
field: {
|
81
|
+
hint: "",
|
82
|
+
icon: "",
|
83
|
+
id: "1",
|
84
|
+
keyForAPI: "",
|
85
|
+
label: "Summary",
|
86
|
+
value: "",
|
87
|
+
},
|
88
|
+
fieldType: "Summary",
|
89
|
+
id: "",
|
90
|
+
label: "Summary",
|
91
|
+
nextCollection: "",
|
92
|
+
nextRole: "",
|
93
|
+
order: 4,
|
94
|
+
sumbitUrl: "",
|
95
|
+
type: "summary",
|
96
|
+
value: "",
|
97
|
+
};
|
98
|
+
|
99
|
+
static radioListItemsTemplate = {
|
100
|
+
id: "",
|
101
|
+
label: "",
|
102
|
+
hint: "",
|
103
|
+
icon: "",
|
104
|
+
};
|
105
|
+
|
106
|
+
static radioListTemplate = {
|
107
|
+
id: "",
|
108
|
+
buttonActionText: "Next",
|
109
|
+
field: {
|
110
|
+
autoChangePage: false,
|
111
|
+
hint: "",
|
112
|
+
icon: "",
|
113
|
+
id: "RLMP101",
|
114
|
+
isAPICalled: false,
|
115
|
+
keyForAPI: "",
|
116
|
+
isRequired: true,
|
117
|
+
itemList: [],
|
118
|
+
},
|
119
|
+
fieldType: "RadioList",
|
120
|
+
label: "label",
|
121
|
+
nextCollection: "",
|
122
|
+
nextRole: "",
|
123
|
+
order: 1,
|
124
|
+
submitUrl: "",
|
125
|
+
type: "normal",
|
126
|
+
value: "",
|
127
|
+
};
|
128
|
+
|
129
|
+
static qrCodeTemplate = {
|
130
|
+
id: "",
|
131
|
+
buttonActionText: "Next",
|
132
|
+
field: {
|
133
|
+
autoChangePage: false,
|
134
|
+
hint: "",
|
135
|
+
icon: "",
|
136
|
+
keyForAPI: "",
|
137
|
+
id: "RLMP101",
|
138
|
+
isAPICalled: false,
|
139
|
+
isRequired: true,
|
140
|
+
},
|
141
|
+
fieldType: "RadioList",
|
142
|
+
label: "label",
|
143
|
+
nextCollection: "",
|
144
|
+
nextRole: "",
|
145
|
+
order: 1,
|
146
|
+
submitUrl: "",
|
147
|
+
type: "normal",
|
148
|
+
value: "",
|
149
|
+
};
|
150
|
+
|
151
|
+
static timePickerTemplate = {
|
152
|
+
buttonActionText: "Next",
|
153
|
+
field: {
|
154
|
+
hint: "",
|
155
|
+
icon: "",
|
156
|
+
id: "1",
|
157
|
+
keyForAPI: "",
|
158
|
+
isRequired: true,
|
159
|
+
label: "Time",
|
160
|
+
value: "",
|
161
|
+
},
|
162
|
+
fieldType: "timePicker",
|
163
|
+
type: "normal",
|
164
|
+
id: "",
|
165
|
+
label: "Time",
|
166
|
+
nextCollection: "",
|
167
|
+
nextRole: "",
|
168
|
+
order: 2,
|
169
|
+
submitUrl: "",
|
170
|
+
value: "",
|
171
|
+
};
|
172
|
+
|
173
|
+
static selfieTemplate = {
|
174
|
+
buttonActionText: "Next",
|
175
|
+
field: {
|
176
|
+
id: "1",
|
177
|
+
label: "",
|
178
|
+
hint: "",
|
179
|
+
keyForAPI: "",
|
180
|
+
value: "",
|
181
|
+
isRequired: true,
|
182
|
+
},
|
183
|
+
fieldType: "Selfie",
|
184
|
+
type: "normal",
|
185
|
+
id: "",
|
186
|
+
label: "Time",
|
187
|
+
nextCollection: "",
|
188
|
+
nextRole: "",
|
189
|
+
order: 2,
|
190
|
+
submitUrl: "",
|
191
|
+
value: "",
|
192
|
+
};
|
193
|
+
}
|
194
|
+
|
195
|
+
export { StepsFactory };
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import { Pool } from "mysql2";
|
2
|
+
import CurdService from "./crud/crud";
|
3
|
+
|
4
|
+
export class GupShupLogs {
|
5
|
+
|
6
|
+
|
7
|
+
static async insertLog(connection: Pool, companyId: string, phoneNumber: string, msgId: string) {
|
8
|
+
const crudServicce = new CurdService(connection);
|
9
|
+
try {
|
10
|
+
const qryString = `INSERT INTO GupShup_Logs (companyId, phone_number, gupshup_msg_id, sent, delivered, \`read\`, deleted)
|
11
|
+
VALUES ('${companyId}', '${phoneNumber}', '${msgId}', NULL, NULL, NULL, NULL);`
|
12
|
+
console.log("query", qryString)
|
13
|
+
const result = await crudServicce.query(qryString);
|
14
|
+
return result
|
15
|
+
} catch (error: any) {
|
16
|
+
console.log(error.message);
|
17
|
+
return error
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
static async getLogs(connection: Pool, phoneNumber: string, msgId: string) {
|
22
|
+
const crudServicce = new CurdService(connection);
|
23
|
+
try {
|
24
|
+
const qryString = `SELECT * FROM GupShup_Logs
|
25
|
+
WHERE phone_number='${phoneNumber}' AND gupshup_msg_id = '${msgId}';`
|
26
|
+
console.log("query", qryString)
|
27
|
+
const result = await crudServicce.query(qryString);
|
28
|
+
return result;
|
29
|
+
} catch (error: any) {
|
30
|
+
console.log(error.message);
|
31
|
+
return error
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
static async updateLogs(connection: Pool, phoneNumber: string, msgId: string, action: string, data: string) {
|
36
|
+
const crudServicce = new CurdService(connection);
|
37
|
+
try {
|
38
|
+
const qryString = `UPDATE GupShup_Logs SET ${action} = '${data}' WHERE phone_number='${phoneNumber}' AND gupshup_msg_id = '${msgId}';`;
|
39
|
+
console.log("qryString",qryString)
|
40
|
+
const result = await crudServicce.query(qryString);
|
41
|
+
return result
|
42
|
+
} catch (error: any) {
|
43
|
+
console.log(error.message);
|
44
|
+
return error
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
|
49
|
+
}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
import { Post } from "./post.model";
|
2
|
+
import * as admin from "firebase-admin";
|
3
|
+
import { Utilities } from "./utility.model";
|
4
|
+
import { Pool } from "mysql2";
|
5
|
+
import CurdService from "./crud/crud";
|
6
|
+
class Summary extends Post {
|
7
|
+
actionName: string;
|
8
|
+
actionType: string;
|
9
|
+
|
10
|
+
constructor() {
|
11
|
+
super();
|
12
|
+
this.actionName = "summary";
|
13
|
+
this.actionType = "worklog";
|
14
|
+
}
|
15
|
+
|
16
|
+
async uploadSummaryToReportDB(info: any, connection: Pool, userPhone: string, eventId: string) {
|
17
|
+
const crudServicce = new CurdService(connection)
|
18
|
+
try {
|
19
|
+
const extraData = info.extraData;
|
20
|
+
const createdAt = await Utilities.epochToMySqlDateTime(info.createdAt);
|
21
|
+
let startTime = extraData.startTime;
|
22
|
+
if (typeof startTime !== "number") {
|
23
|
+
startTime = this.getEpochTimeFromTimeObj(startTime);
|
24
|
+
}
|
25
|
+
let endTime = extraData.endTime;
|
26
|
+
if (typeof endTime !== "number") {
|
27
|
+
endTime = this.getEpochTimeFromTimeObj(endTime);
|
28
|
+
}
|
29
|
+
const eventDetails = {
|
30
|
+
description: info.description,
|
31
|
+
boys: extraData.boys,
|
32
|
+
girls: extraData.girls,
|
33
|
+
date: extraData.date,
|
34
|
+
ground: extraData.ground,
|
35
|
+
groupImage: extraData.groupImage,
|
36
|
+
eventId: eventId,
|
37
|
+
level: extraData.level,
|
38
|
+
planImage: extraData.planImage,
|
39
|
+
startTime: await Utilities.epochToMySqlDateTime(startTime),
|
40
|
+
endTime: await Utilities.epochToMySqlDateTime(endTime)
|
41
|
+
}
|
42
|
+
let eventDate: any = new Date(eventDetails.date.split("/").reverse().join("-")).getTime();
|
43
|
+
eventDate = await Utilities.epochToMySqlDateTime(eventDate);
|
44
|
+
const qryString = `INSERT INTO summaryReports (companyId, userPhone,
|
45
|
+
createdAt, eventDetails,
|
46
|
+
eventDate)
|
47
|
+
VALUES ('${info.companyId}', '${userPhone}',
|
48
|
+
'${createdAt}', '${JSON.stringify(eventDetails)}',
|
49
|
+
'${eventDate}');`
|
50
|
+
console.log(qryString);
|
51
|
+
console.log("adding summary report entry to DB")
|
52
|
+
await crudServicce.query(qryString)
|
53
|
+
} catch (error: any) {
|
54
|
+
throw new Error(error.message)
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
getEpochTimeFromTimeObj(timeObj: any) {
|
59
|
+
return timeObj._seconds * 1000 + Math.floor(timeObj._nanoseconds / 1000000);
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
export { Summary }
|
@@ -0,0 +1,173 @@
|
|
1
|
+
import * as admin from "firebase-admin";
|
2
|
+
|
3
|
+
class SubTaskGroup {
|
4
|
+
private _id!: string | "";
|
5
|
+
public get id(): string | "" {
|
6
|
+
return this._id;
|
7
|
+
}
|
8
|
+
public set id(value: string | "") {
|
9
|
+
this._id = value;
|
10
|
+
}
|
11
|
+
|
12
|
+
private _groupId!: string | "";
|
13
|
+
public get groupId(): string | "" {
|
14
|
+
return this._groupId;
|
15
|
+
}
|
16
|
+
public set groupId(value: string | "") {
|
17
|
+
this._groupId = value;
|
18
|
+
}
|
19
|
+
|
20
|
+
private _title!: string | "";
|
21
|
+
public get title(): string | "" {
|
22
|
+
return this._title;
|
23
|
+
}
|
24
|
+
public set title(value: string | "") {
|
25
|
+
this._title = value;
|
26
|
+
}
|
27
|
+
|
28
|
+
private _userId!: string;
|
29
|
+
public get userId(): string {
|
30
|
+
return this._userId;
|
31
|
+
}
|
32
|
+
public set userId(value: string) {
|
33
|
+
this._userId = value;
|
34
|
+
}
|
35
|
+
|
36
|
+
private _companyId!: string;
|
37
|
+
public get companyId(): string {
|
38
|
+
return this._companyId;
|
39
|
+
}
|
40
|
+
public set companyId(value: string) {
|
41
|
+
this._companyId = value;
|
42
|
+
}
|
43
|
+
|
44
|
+
constructor() {}
|
45
|
+
|
46
|
+
argConstructor(
|
47
|
+
id: string,
|
48
|
+
groupId: string,
|
49
|
+
title: string,
|
50
|
+
userId: string,
|
51
|
+
companyId: string
|
52
|
+
) {
|
53
|
+
this.id = id;
|
54
|
+
this.groupId = groupId;
|
55
|
+
this.title = title;
|
56
|
+
this.userId = userId;
|
57
|
+
this.companyId = companyId;
|
58
|
+
}
|
59
|
+
|
60
|
+
fromJSON(subTaskGroup: string) {
|
61
|
+
let subTaskGroupJSON = JSON.parse(subTaskGroup);
|
62
|
+
this.groupId = subTaskGroupJSON["groupId"];
|
63
|
+
this.id = subTaskGroupJSON["id"];
|
64
|
+
this.title = subTaskGroupJSON["title"];
|
65
|
+
this.userId = subTaskGroupJSON["userId"];
|
66
|
+
this.companyId = subTaskGroupJSON["companyId"];
|
67
|
+
}
|
68
|
+
|
69
|
+
toJSON() {
|
70
|
+
return {
|
71
|
+
id: this.id,
|
72
|
+
title: this.title,
|
73
|
+
groupId: this.groupId,
|
74
|
+
userId: this.userId,
|
75
|
+
companyId: this.companyId,
|
76
|
+
};
|
77
|
+
}
|
78
|
+
|
79
|
+
getValue(key: string) {
|
80
|
+
switch (key) {
|
81
|
+
case "id":
|
82
|
+
return this.id;
|
83
|
+
case "title":
|
84
|
+
return this.title;
|
85
|
+
case "groupId":
|
86
|
+
return this.groupId;
|
87
|
+
case "userId":
|
88
|
+
return this.userId;
|
89
|
+
case "companyId":
|
90
|
+
return this.companyId;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
async save(firestore: admin.firestore.Firestore) {
|
95
|
+
if (this.id == null || this.id == "" || this.id == undefined) {
|
96
|
+
return {
|
97
|
+
status: "ERROR",
|
98
|
+
message: "Error Saving Task Group. ID Not Found",
|
99
|
+
};
|
100
|
+
} else {
|
101
|
+
let subGroupDoc: admin.firestore.DocumentReference = firestore
|
102
|
+
.collection("Companies")
|
103
|
+
.doc(this.companyId)
|
104
|
+
.collection("Task-Group")
|
105
|
+
.doc(this.groupId);
|
106
|
+
|
107
|
+
try {
|
108
|
+
let groupData: admin.firestore.DocumentSnapshot =
|
109
|
+
await subGroupDoc.get();
|
110
|
+
if (groupData.get("subGroups").length > 0) {
|
111
|
+
var allSGs = groupData.get("subGroups");
|
112
|
+
allSGs.push(this.toJSON());
|
113
|
+
console.log("allSGs", allSGs);
|
114
|
+
await subGroupDoc.update({
|
115
|
+
subGroups: allSGs,
|
116
|
+
});
|
117
|
+
} else {
|
118
|
+
await subGroupDoc.update({
|
119
|
+
subGroups: [this.toJSON()],
|
120
|
+
});
|
121
|
+
}
|
122
|
+
} catch (e) {
|
123
|
+
console.log("Error in updating sub group", e);
|
124
|
+
}
|
125
|
+
|
126
|
+
return { status: "OK", message: "Task Group Added Successfully" };
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
130
|
+
static async updateSubGroup(
|
131
|
+
firestore: admin.firestore.Firestore,
|
132
|
+
body: any
|
133
|
+
) {
|
134
|
+
try {
|
135
|
+
console.log("The BODY IS ", body);
|
136
|
+
let subGroupModel = body["extra"];
|
137
|
+
console.log("The Sub Group Model is ", subGroupModel);
|
138
|
+
let subGroup: SubTaskGroup = new SubTaskGroup();
|
139
|
+
subGroup.fromJSON(JSON.stringify(subGroupModel));
|
140
|
+
console.log("The subGroup model is ", subGroup.toJSON());
|
141
|
+
let response;
|
142
|
+
try {
|
143
|
+
response = await subGroup.save(firestore);
|
144
|
+
} catch (e) {
|
145
|
+
console.log("Error in sub group", e);
|
146
|
+
throw {
|
147
|
+
message: "Error in sub group",
|
148
|
+
status: 500
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
152
|
+
// Delete Incoming Ref
|
153
|
+
if (body["id"] != "") {
|
154
|
+
if (response?.["status"] == "OK") {
|
155
|
+
await firestore
|
156
|
+
.collection("Incoming")
|
157
|
+
.doc(body["id"])
|
158
|
+
.delete();
|
159
|
+
}
|
160
|
+
}
|
161
|
+
return {
|
162
|
+
...response
|
163
|
+
}
|
164
|
+
} catch(error: any) {
|
165
|
+
return {
|
166
|
+
error: error?.message ?? "Internal Server Error",
|
167
|
+
status: error?.status ?? 500
|
168
|
+
}
|
169
|
+
}
|
170
|
+
}
|
171
|
+
}
|
172
|
+
|
173
|
+
export { SubTaskGroup };
|
@@ -0,0 +1,113 @@
|
|
1
|
+
import * as admin from "firebase-admin";
|
2
|
+
|
3
|
+
class Tag {
|
4
|
+
private _id!: string | "";
|
5
|
+
public get id(): string | "" {
|
6
|
+
return this._id;
|
7
|
+
}
|
8
|
+
public set id(value: string | "") {
|
9
|
+
this._id = value;
|
10
|
+
}
|
11
|
+
|
12
|
+
private _value!: string | "";
|
13
|
+
public get value(): string | "" {
|
14
|
+
return this._value;
|
15
|
+
}
|
16
|
+
public set value(value: string | "") {
|
17
|
+
this._value = value;
|
18
|
+
}
|
19
|
+
|
20
|
+
private _userId!: string | "";
|
21
|
+
public get userId(): string | "" {
|
22
|
+
return this._userId;
|
23
|
+
}
|
24
|
+
public set userId(value: string | "") {
|
25
|
+
this._userId = value;
|
26
|
+
}
|
27
|
+
|
28
|
+
private _companyId!: string | "";
|
29
|
+
public get companyId(): string | "" {
|
30
|
+
return this._companyId;
|
31
|
+
}
|
32
|
+
public set companyId(value: string | "") {
|
33
|
+
this._companyId = value;
|
34
|
+
}
|
35
|
+
|
36
|
+
constructor() {}
|
37
|
+
|
38
|
+
argConstructor(id: string, value: string, userId: string, companyId: string) {
|
39
|
+
this.id = id;
|
40
|
+
this.value = value;
|
41
|
+
this.userId = userId;
|
42
|
+
this.companyId = companyId;
|
43
|
+
}
|
44
|
+
|
45
|
+
fromJSON(tag: string) {
|
46
|
+
let tagJSON = JSON.parse(tag);
|
47
|
+
this.id = tagJSON["id"] ?? "";
|
48
|
+
this.value = tagJSON["value"] ?? null;
|
49
|
+
this.userId = tagJSON["userId"] ?? null;
|
50
|
+
this.companyId = tagJSON["companyId"] ?? null;
|
51
|
+
}
|
52
|
+
|
53
|
+
toJSON() {
|
54
|
+
return {
|
55
|
+
id: this.id,
|
56
|
+
value: this.value,
|
57
|
+
userId: this.userId,
|
58
|
+
companyId: this.companyId,
|
59
|
+
};
|
60
|
+
}
|
61
|
+
|
62
|
+
async save(firestore: admin.firestore.Firestore) {
|
63
|
+
if (this.id == null || this.id == "" || this.id == undefined) {
|
64
|
+
return { status: "ERROR", message: "Error Saving Tag. ID Not Found" };
|
65
|
+
} else {
|
66
|
+
let tagDoc: admin.firestore.DocumentReference = firestore
|
67
|
+
.collection("Companies")
|
68
|
+
.doc(this.companyId)
|
69
|
+
.collection("Tags")
|
70
|
+
.doc(this.id);
|
71
|
+
|
72
|
+
await tagDoc.set(this.toJSON());
|
73
|
+
|
74
|
+
return { status: "OK", message: "Tag Added Successfully" };
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
// static async getOrCreateTag(
|
79
|
+
// tagsModel: any,
|
80
|
+
// firestore: admin.firestore.Firestore
|
81
|
+
// ) {
|
82
|
+
// if (tagsModel.get("id") != null || tagsModel.get("id") != "") {
|
83
|
+
// Tags.updateTag(tagsModel, firestore);
|
84
|
+
// } else {
|
85
|
+
// var docRef: admin.firestore.DocumentReference = firestore
|
86
|
+
// .collection("Companies")
|
87
|
+
// .doc(tagsModel.get("companyId"))
|
88
|
+
// .collection("Tags")
|
89
|
+
// .doc();
|
90
|
+
|
91
|
+
// tagsModel.set("id", docRef.id);
|
92
|
+
|
93
|
+
// await docRef.set(tagsModel);
|
94
|
+
// return "Successful Added";
|
95
|
+
// }
|
96
|
+
// }
|
97
|
+
|
98
|
+
// static async updateTag(
|
99
|
+
// tagsModel: Tags,
|
100
|
+
// firestore: admin.firestore.Firestore
|
101
|
+
// ) {
|
102
|
+
// await firestore
|
103
|
+
// .collection("Companies")
|
104
|
+
// .doc(tagsModel.get("companyId"))
|
105
|
+
// .collection("Tags")
|
106
|
+
// .doc(tagsModel.get("id"))
|
107
|
+
// .update(tagsModel);
|
108
|
+
|
109
|
+
// return "Successfully Updated";
|
110
|
+
// }
|
111
|
+
}
|
112
|
+
|
113
|
+
export { Tag };
|