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
@@ -1,87 +0,0 @@
|
|
1
|
-
import * as admin from "firebase-admin";
|
2
|
-
class Request {
|
3
|
-
id!: string;
|
4
|
-
message!: string;
|
5
|
-
phone!: string;
|
6
|
-
firstName!: string;
|
7
|
-
lastName!: string;
|
8
|
-
email!: string;
|
9
|
-
private _sendUpdates!: boolean;
|
10
|
-
|
11
|
-
public get sendUpdates(): boolean {
|
12
|
-
return this._sendUpdates;
|
13
|
-
}
|
14
|
-
public set sendUpdates(value: boolean) {
|
15
|
-
this._sendUpdates = value;
|
16
|
-
}
|
17
|
-
|
18
|
-
constructor() {}
|
19
|
-
|
20
|
-
argConstructor(
|
21
|
-
id: string,
|
22
|
-
message: string,
|
23
|
-
phone: string,
|
24
|
-
firstName: string,
|
25
|
-
lastName: string,
|
26
|
-
email: string,
|
27
|
-
_sendUpdates: boolean
|
28
|
-
) {
|
29
|
-
this.id = id;
|
30
|
-
this.message = message;
|
31
|
-
this.phone = phone;
|
32
|
-
this.firstName = firstName;
|
33
|
-
this.lastName = lastName;
|
34
|
-
this.email = email;
|
35
|
-
this._sendUpdates = _sendUpdates
|
36
|
-
}
|
37
|
-
|
38
|
-
fromJSON(request: string) {
|
39
|
-
let requestJSON = JSON.parse(request);
|
40
|
-
|
41
|
-
this.id = requestJSON["phone"];
|
42
|
-
this.message = requestJSON["message"];
|
43
|
-
this.phone = requestJSON["phone"];
|
44
|
-
this.firstName = requestJSON["firstName"];
|
45
|
-
this.lastName = requestJSON["lastName"];
|
46
|
-
this.email = requestJSON["email"];
|
47
|
-
this._sendUpdates = requestJSON["sendUpdates"]
|
48
|
-
}
|
49
|
-
|
50
|
-
toJSON() {
|
51
|
-
return {
|
52
|
-
id: this.phone,
|
53
|
-
message: this.message,
|
54
|
-
phone: this.phone,
|
55
|
-
firstName: this.firstName,
|
56
|
-
lastName: this.lastName,
|
57
|
-
email: this.email,
|
58
|
-
sendUpdates: this._sendUpdates
|
59
|
-
};
|
60
|
-
}
|
61
|
-
|
62
|
-
async save(firestore: admin.firestore.Firestore) {
|
63
|
-
let requestDoc: admin.firestore.DocumentReference = firestore
|
64
|
-
.collection("Requests")
|
65
|
-
.doc(this.phone.toString());
|
66
|
-
|
67
|
-
const requestDocInfo = await requestDoc.get();
|
68
|
-
const reqsInfo = requestDocInfo.data();
|
69
|
-
if (reqsInfo) {
|
70
|
-
reqsInfo.requests.push(this.toJSON());
|
71
|
-
await requestDoc.set(reqsInfo)
|
72
|
-
} else {
|
73
|
-
const newRequest = {
|
74
|
-
id: this.phone,
|
75
|
-
requests: [this.toJSON()]
|
76
|
-
}
|
77
|
-
await requestDoc.set(newRequest);
|
78
|
-
}
|
79
|
-
return {
|
80
|
-
status: "OK",
|
81
|
-
message: "Request Added Successfully",
|
82
|
-
path: requestDoc.path,
|
83
|
-
};
|
84
|
-
}
|
85
|
-
}
|
86
|
-
|
87
|
-
export { Request };
|
package/src/models/crud/crud.ts
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
import { Pool, PoolConnection, RowDataPacket, ResultSetHeader, OkPacket } from 'mysql2';
|
2
|
-
|
3
|
-
class CurdService {
|
4
|
-
private pool: Pool;
|
5
|
-
|
6
|
-
constructor(pool: Pool) {
|
7
|
-
this.pool = pool;
|
8
|
-
}
|
9
|
-
|
10
|
-
public async query(queryString: string): Promise<RowDataPacket[] | ResultSetHeader | OkPacket> {
|
11
|
-
return new Promise((resolve, reject) => {
|
12
|
-
this.pool.getConnection((err, connection: PoolConnection) => {
|
13
|
-
if (err) {
|
14
|
-
reject(err);
|
15
|
-
return;
|
16
|
-
}
|
17
|
-
connection.query(queryString, (err, result:any) => {
|
18
|
-
connection.release();
|
19
|
-
if (err) {
|
20
|
-
reject(err);
|
21
|
-
return;
|
22
|
-
}
|
23
|
-
resolve(result);
|
24
|
-
});
|
25
|
-
});
|
26
|
-
});
|
27
|
-
}
|
28
|
-
}
|
29
|
-
|
30
|
-
export default CurdService;
|
@@ -1,47 +0,0 @@
|
|
1
|
-
import * as admin from "firebase-admin"
|
2
|
-
import { User } from "./user.model";
|
3
|
-
|
4
|
-
class CustomCollection {
|
5
|
-
id: string = "";
|
6
|
-
|
7
|
-
static async createCustomCollection(
|
8
|
-
firestore: admin.firestore.Firestore,
|
9
|
-
collectionDetails: any
|
10
|
-
) {
|
11
|
-
try {
|
12
|
-
let collection_snapshot = await firestore.collection("customCollection")
|
13
|
-
.get();
|
14
|
-
if (collection_snapshot.empty) {
|
15
|
-
console.log("no collection found: creating one...");
|
16
|
-
await CustomCollection.createNewCollection(firestore, collectionDetails);
|
17
|
-
} else {
|
18
|
-
throw new Error("there is already a collection with this name.");
|
19
|
-
}
|
20
|
-
} catch (error) {
|
21
|
-
console.log(error);
|
22
|
-
}
|
23
|
-
}
|
24
|
-
|
25
|
-
static async createNewCollection(firestore: admin.firestore.Firestore,
|
26
|
-
collectionDetails: any) {
|
27
|
-
let restructuredDetails: any = await CustomCollection.restructureDetails(collectionDetails);
|
28
|
-
let docRef = firestore.collection("CustomCollections").doc();
|
29
|
-
restructuredDetails.id = docRef.id;
|
30
|
-
await docRef.set(restructuredDetails);
|
31
|
-
return restructuredDetails;
|
32
|
-
}
|
33
|
-
|
34
|
-
static async restructureDetails(collectionDetails: any) {
|
35
|
-
// for now collectionDetails remain unaltered
|
36
|
-
return collectionDetails;
|
37
|
-
}
|
38
|
-
|
39
|
-
static async getUserWorkAreaList(firestore:admin.firestore.Firestore,companyId:string,phone:string){
|
40
|
-
let userId = await User.getUserIdByPhone(firestore,phone)
|
41
|
-
let workAreaSnapShot = await firestore.collection("CustomCollections").doc(companyId).collection("Users").doc(userId).get()
|
42
|
-
return workAreaSnapShot.data()
|
43
|
-
}
|
44
|
-
|
45
|
-
}
|
46
|
-
|
47
|
-
export { CustomCollection };
|
@@ -1,85 +0,0 @@
|
|
1
|
-
import { Firestore } from "@google-cloud/firestore";
|
2
|
-
import * as admin from "firebase-admin";
|
3
|
-
|
4
|
-
class Customer {
|
5
|
-
customerName: string;
|
6
|
-
address: string;
|
7
|
-
zipcode: string;
|
8
|
-
city: string;
|
9
|
-
state: string;
|
10
|
-
GSTNo: string;
|
11
|
-
contactName: string;
|
12
|
-
contactNo: string;
|
13
|
-
|
14
|
-
constructor(customerName: string,
|
15
|
-
address: string,
|
16
|
-
zipcode: string,
|
17
|
-
city: string,
|
18
|
-
state: string,
|
19
|
-
GSTNo: string,
|
20
|
-
contactName: string,
|
21
|
-
contactNo: string) {
|
22
|
-
this.customerName = customerName;
|
23
|
-
this.address = address;
|
24
|
-
this.zipcode = zipcode;
|
25
|
-
this.city = city;
|
26
|
-
this.state = state;
|
27
|
-
this.GSTNo = GSTNo;
|
28
|
-
this.contactName = contactName;
|
29
|
-
this.contactNo = contactNo;
|
30
|
-
}
|
31
|
-
}
|
32
|
-
|
33
|
-
class CustomerContact {
|
34
|
-
customerId: number;
|
35
|
-
contactName: string;
|
36
|
-
contactNo: string;
|
37
|
-
alternateContactNo: string;
|
38
|
-
designation: string;
|
39
|
-
constructor(
|
40
|
-
customerId: number,
|
41
|
-
contactName: string,
|
42
|
-
contactNo: string,
|
43
|
-
alternateContactNo: string,
|
44
|
-
designation: string
|
45
|
-
) {
|
46
|
-
this.customerId = customerId;
|
47
|
-
this.contactName = contactName;
|
48
|
-
this.contactNo = contactNo;
|
49
|
-
this.alternateContactNo = alternateContactNo;
|
50
|
-
this.designation = designation;
|
51
|
-
}
|
52
|
-
}
|
53
|
-
|
54
|
-
class CustomerCard {
|
55
|
-
companyId: string;
|
56
|
-
userId: string;
|
57
|
-
createdAt: string;
|
58
|
-
actionName: string;
|
59
|
-
actionType: string;
|
60
|
-
actionId: string;
|
61
|
-
actionEvent: string;
|
62
|
-
extraData: any;
|
63
|
-
id: string;
|
64
|
-
constructor(companyId: string,
|
65
|
-
userId: string,
|
66
|
-
createdAt: string,
|
67
|
-
actionName: string,
|
68
|
-
actionType: string,
|
69
|
-
actionId: string,
|
70
|
-
actionEvent: string,
|
71
|
-
extraData: any,
|
72
|
-
id: string) {
|
73
|
-
this.companyId = companyId;
|
74
|
-
this.userId = userId;
|
75
|
-
this.createdAt = createdAt;
|
76
|
-
this.actionName = actionName;
|
77
|
-
this.actionType = actionType;
|
78
|
-
this.actionId = actionId;
|
79
|
-
this.actionEvent = actionEvent;
|
80
|
-
this.extraData = extraData;
|
81
|
-
this.id = id;
|
82
|
-
}
|
83
|
-
}
|
84
|
-
|
85
|
-
export { Customer, CustomerContact, CustomerCard };
|
@@ -1,150 +0,0 @@
|
|
1
|
-
import * as admin from "firebase-admin";
|
2
|
-
import { Action } from "./action.model";
|
3
|
-
import { Company } from "./company.model";
|
4
|
-
import { Offline } from "./offline.model";
|
5
|
-
class DeviceChangeReq {
|
6
|
-
static async checkIsReqPending(firestore: admin.firestore.Firestore,
|
7
|
-
deviceChangeInfo: any, company: string) {
|
8
|
-
const newDeviceId = deviceChangeInfo.extra.extraData.deviceId;
|
9
|
-
const nickName = "mobiOffice";
|
10
|
-
const requestCompanyId = await Company.getCompanyIdByNickName(firestore, company);
|
11
|
-
console.log("requestCompanyId", requestCompanyId);
|
12
|
-
const companyId = await Company.getCompanyIdByNickName(firestore, nickName);
|
13
|
-
const actionName = deviceChangeInfo.actionName;
|
14
|
-
let isReqPending = false;
|
15
|
-
console.log("companyId", companyId, "actionName", actionName);
|
16
|
-
const actionId = await Action.getActionId(firestore, companyId, actionName);
|
17
|
-
console.log(companyId, requestCompanyId);
|
18
|
-
const deviceChangeReqs = await firestore.collection("Companies")
|
19
|
-
.doc(companyId)
|
20
|
-
.collection("Actions")
|
21
|
-
.doc(actionId)
|
22
|
-
.collection(actionName)
|
23
|
-
.where("reqCompanyId", "==", requestCompanyId)
|
24
|
-
.get()
|
25
|
-
deviceChangeReqs.forEach((doc: any) => {
|
26
|
-
console.log("compare", doc.data().extraData.deviceId, newDeviceId, doc.data().isProcessed);
|
27
|
-
if (doc.data().extraData.deviceId === newDeviceId
|
28
|
-
&& doc.data().isProcessed === false) {
|
29
|
-
isReqPending = true;
|
30
|
-
}
|
31
|
-
})
|
32
|
-
return isReqPending;
|
33
|
-
}
|
34
|
-
|
35
|
-
static async fetchOpenReqs(firestore: admin.firestore.Firestore,
|
36
|
-
companyId: string) {
|
37
|
-
const nickName = "mobiOffice";
|
38
|
-
const supportCompanyId = await Company.getCompanyIdByNickName(firestore, nickName);
|
39
|
-
const actionName = "requestForm";
|
40
|
-
const actionId = await Action.getActionId(firestore, supportCompanyId, actionName);
|
41
|
-
const allRequestsDocs = await firestore.collection("Companies")
|
42
|
-
.doc(supportCompanyId)
|
43
|
-
.collection("Actions")
|
44
|
-
.doc(actionId)
|
45
|
-
.collection(actionName)
|
46
|
-
.get();
|
47
|
-
let allRequestsData = allRequestsDocs.docs.map((doc) => {
|
48
|
-
return doc.data();
|
49
|
-
})
|
50
|
-
let openRequests = allRequestsData.filter((doc) => {
|
51
|
-
return doc.reqCompanyId === companyId && !doc.isProcessed;
|
52
|
-
})
|
53
|
-
return openRequests;
|
54
|
-
}
|
55
|
-
|
56
|
-
static async approve(firestore: admin.firestore.Firestore,
|
57
|
-
approvalDetails: any) {
|
58
|
-
const extraData = approvalDetails.extra.extraData;
|
59
|
-
const companyId = extraData.companyNameId;
|
60
|
-
const requestId = extraData.requestId;
|
61
|
-
const requestStatus = extraData.approval;
|
62
|
-
const openRequests = await this.fetchOpenReqs(firestore, companyId);
|
63
|
-
const objToProcess: any = [];
|
64
|
-
openRequests.forEach(async (doc) => {
|
65
|
-
if( doc.eventId === requestId) {
|
66
|
-
objToProcess.push(doc);
|
67
|
-
}
|
68
|
-
})
|
69
|
-
if (objToProcess.length !== 0) {
|
70
|
-
const licenseDoc = await firestore.collection("Licenses")
|
71
|
-
.where("company", "==", objToProcess[0].company)
|
72
|
-
.where("user", "==", `+${objToProcess[0].extraData.phone}`)
|
73
|
-
.get();
|
74
|
-
let license = licenseDoc.docs.map((doc) => {
|
75
|
-
return doc.data();
|
76
|
-
})[0];
|
77
|
-
const updatedLicense = await this.replaceOldDeviceWithNew(license, objToProcess[0]);
|
78
|
-
console.log(updatedLicense);
|
79
|
-
if (updatedLicense) {
|
80
|
-
licenseDoc.forEach(doc => {
|
81
|
-
doc.ref.set(updatedLicense);
|
82
|
-
})
|
83
|
-
}
|
84
|
-
await this.updateCompanyActionDoc(firestore, requestId, requestStatus);
|
85
|
-
} else {
|
86
|
-
throw new Error("no documents to process");
|
87
|
-
}
|
88
|
-
}
|
89
|
-
|
90
|
-
static async replaceOldDeviceWithNew(license: any, objToProcess: any) {
|
91
|
-
const extraDevices = license.extraDevices;
|
92
|
-
const newDeviceObj = {
|
93
|
-
fromDate: Date.now(),
|
94
|
-
modelName: objToProcess.extraData.model,
|
95
|
-
brandName: objToProcess.extraData.brand,
|
96
|
-
deviceId: objToProcess.extraData.deviceId
|
97
|
-
}
|
98
|
-
const indexToReplace = await this.getIndexToReplace(extraDevices, objToProcess.extraData.oldDeviceId);
|
99
|
-
if (indexToReplace === "not found") {
|
100
|
-
return null;
|
101
|
-
}
|
102
|
-
extraDevices.splice(indexToReplace, 1, newDeviceObj);
|
103
|
-
license.extraDevices = extraDevices;
|
104
|
-
return license;
|
105
|
-
}
|
106
|
-
|
107
|
-
static async getIndexToReplace(extraDevices: any, deviceId: string) {
|
108
|
-
for (let i = 0; i < extraDevices.length; i++) {
|
109
|
-
if (extraDevices[i].deviceId === deviceId) {
|
110
|
-
return i;
|
111
|
-
}
|
112
|
-
}
|
113
|
-
return "not found";
|
114
|
-
}
|
115
|
-
|
116
|
-
static async updateCompanyActionDoc(firestore: admin.firestore.Firestore,
|
117
|
-
requestId: string,
|
118
|
-
requestStatus: string) {
|
119
|
-
const companyId = await Company.getCompanyIdByNickName(firestore, "mobiOffice");
|
120
|
-
const actionName = "requestForm";
|
121
|
-
const actionId = await Action.getActionId(firestore, companyId, actionName);
|
122
|
-
const doc = await firestore.collection("Companies")
|
123
|
-
.doc(companyId)
|
124
|
-
.collection("Actions")
|
125
|
-
.doc(actionId)
|
126
|
-
.collection(actionName)
|
127
|
-
.doc(requestId)
|
128
|
-
.get();
|
129
|
-
await doc.ref.update({
|
130
|
-
isProcessed: true,
|
131
|
-
approval: requestStatus
|
132
|
-
})
|
133
|
-
|
134
|
-
const supportUsers = await Company.getUsersListbyCompany(firestore, "mobiOffice");
|
135
|
-
|
136
|
-
for(let user of supportUsers) {
|
137
|
-
const docRef = await firestore.collection("Feeds").doc(user.id).collection(companyId).doc(requestId).get();
|
138
|
-
const docData = docRef.data();
|
139
|
-
const extraData = docData?.extraData;
|
140
|
-
extraData["approval"] = requestStatus
|
141
|
-
await firestore.collection("Feeds").doc(user.id).collection(companyId).doc(requestId).update({
|
142
|
-
isProcessed: true,
|
143
|
-
extraData: extraData
|
144
|
-
})
|
145
|
-
}
|
146
|
-
|
147
|
-
}
|
148
|
-
}
|
149
|
-
|
150
|
-
export { DeviceChangeReq };
|
@@ -1,99 +0,0 @@
|
|
1
|
-
import { Post } from "./post.model"
|
2
|
-
import * as admin from "firebase-admin";
|
3
|
-
import { Offline } from "./offline.model";
|
4
|
-
import { TempCollection } from "./tempCollection.model";
|
5
|
-
import { User } from "./user.model";
|
6
|
-
|
7
|
-
class Dispatch extends Post {
|
8
|
-
actionEvent: string = "";
|
9
|
-
actionType: string = "worklog";
|
10
|
-
actionName: string = "dispatch";
|
11
|
-
customerName:string = ""
|
12
|
-
|
13
|
-
static async createPostforDispatch(firestore: admin.firestore.Firestore,postInfo: any,uniqueId:string){
|
14
|
-
let post = new Dispatch();
|
15
|
-
post = await Dispatch.setIncomingInfoToDispatch(postInfo, post);
|
16
|
-
console.log(post)
|
17
|
-
let eventId = await Post.createNewPost(firestore,post)
|
18
|
-
await TempCollection.deleteTempCollection(firestore,uniqueId)
|
19
|
-
return eventId
|
20
|
-
}
|
21
|
-
|
22
|
-
static async createPostForSODispatch(firestore: admin.firestore.Firestore, postInfo: any, status: string) {
|
23
|
-
console.log("in create post for dispatch");
|
24
|
-
const userInfo: any = await User.getUserInfoById(firestore, postInfo.userId, postInfo.companyId);
|
25
|
-
const extraData = postInfo.extra.extraData;
|
26
|
-
extraData.status = status;
|
27
|
-
extraData.time = postInfo.createdAt;
|
28
|
-
extraData.date = new Date(postInfo.createdAt).toLocaleDateString("en-GB");
|
29
|
-
extraData.userName = userInfo.name;
|
30
|
-
console.log(extraData);
|
31
|
-
let post = {
|
32
|
-
...postInfo,
|
33
|
-
extraData: extraData,
|
34
|
-
actionId: postInfo.extra.actionId,
|
35
|
-
description: postInfo.extra.extraData.customerName,
|
36
|
-
actionType: "worklog"
|
37
|
-
};
|
38
|
-
delete post.extra;
|
39
|
-
console.log(post);
|
40
|
-
console.log("creating post for dispatch");
|
41
|
-
let eventId = await Post.createNewPost(firestore, post);
|
42
|
-
return eventId;
|
43
|
-
}
|
44
|
-
|
45
|
-
static async setIncomingInfoToDispatch(info:any, post:Dispatch){
|
46
|
-
post.actionEvent = info.extra.actionEvent;
|
47
|
-
post.id = info.id
|
48
|
-
post.customerName = info.customerName
|
49
|
-
post.actionId = info.extra.actionId;
|
50
|
-
post.companyId = info.extra.companyId;
|
51
|
-
post.createdAt = info.extra.createdAt;
|
52
|
-
post.description = info.description;
|
53
|
-
post.eventId = info.extra.eventId;
|
54
|
-
post.isGeofence = info.extra.isGeofence;
|
55
|
-
post.userId = info.userId;
|
56
|
-
const newExtraData = await this.modifyExtraDataForDispatch(info);
|
57
|
-
post.extraData = newExtraData;
|
58
|
-
post.seen = info.extra.seen;
|
59
|
-
post.startAt = "";
|
60
|
-
post.startLat = info.extra.startLat;
|
61
|
-
post.startLong = info.extra.startLong;
|
62
|
-
post.endAt = "";
|
63
|
-
post.endLat = info.extra.endLat;
|
64
|
-
post.endLong = info.extra.endLong;
|
65
|
-
post.stepValues = info.extra.stepValues;
|
66
|
-
post.time = info.extra.time;
|
67
|
-
post.checkInternet = info.extra.checkInternet;
|
68
|
-
return post;
|
69
|
-
}
|
70
|
-
|
71
|
-
static async modifyExtraDataForDispatch(info: any) {
|
72
|
-
const time = info.createdAt;
|
73
|
-
const date = new Date(time).toLocaleDateString("en-GB");
|
74
|
-
const newExtraData = {
|
75
|
-
...info.extra.extraData,
|
76
|
-
status: "Pending",
|
77
|
-
customerName: info.description.split("--")[0],
|
78
|
-
date: date,
|
79
|
-
time: time
|
80
|
-
}
|
81
|
-
return newExtraData;
|
82
|
-
}
|
83
|
-
|
84
|
-
static async getSODesignsByDocId(firestore: admin.firestore.Firestore,
|
85
|
-
uniqueId: string) {
|
86
|
-
try {
|
87
|
-
const storedInfoDoc = await firestore.collection("TempCollection")
|
88
|
-
.doc(uniqueId)
|
89
|
-
.get();
|
90
|
-
const info: any = storedInfoDoc.data();
|
91
|
-
console.log(info.scannedTakas);
|
92
|
-
return info.scannedTakas;
|
93
|
-
} catch(error: any) {
|
94
|
-
throw new Error(error.message)
|
95
|
-
}
|
96
|
-
}
|
97
|
-
}
|
98
|
-
|
99
|
-
export { Dispatch };
|
@@ -1,104 +0,0 @@
|
|
1
|
-
import * as admin from 'firebase-admin';
|
2
|
-
import { Attendance } from './attendance.model';
|
3
|
-
import { Offline } from './offline.model';
|
4
|
-
|
5
|
-
class Feeds {
|
6
|
-
|
7
|
-
static async initFeed(firestore: admin.firestore.Firestore) {
|
8
|
-
let document = firestore.collection('Feeds').doc();
|
9
|
-
await document.set({
|
10
|
-
id: document.id,
|
11
|
-
})
|
12
|
-
return "success"
|
13
|
-
}
|
14
|
-
|
15
|
-
static async updateFeed(firestore: admin.firestore.Firestore, userId: string, companyId: string, eventId: string, data: any, isError: boolean, lotNo: string) {
|
16
|
-
console.log("going to update cards");
|
17
|
-
await Feeds.updateFeedForUser(firestore, userId, companyId, eventId, data, isError, lotNo);
|
18
|
-
let managersList = await Offline.getUserManagersList(firestore, companyId, userId);
|
19
|
-
for (let manager of managersList) {
|
20
|
-
await Feeds.updateFeedForUser(firestore, manager, companyId, eventId, data, isError, lotNo);
|
21
|
-
}
|
22
|
-
return "success"
|
23
|
-
}
|
24
|
-
|
25
|
-
static async updateFeedForUser(firestore: admin.firestore.Firestore, userId: string, companyId: string, eventId: string, data: any, isError: boolean, lotNo: string) {
|
26
|
-
console.log("received info");
|
27
|
-
let userFeedDoc = await firestore.collection("Feeds").doc(userId).collection(companyId).where("eventId", "==", eventId).get()
|
28
|
-
let description = userFeedDoc.docs[0].data().description || "";
|
29
|
-
let extraData = userFeedDoc.docs[0].data().extraData
|
30
|
-
const oldUserFeedDoc = userFeedDoc.docs[0].data();
|
31
|
-
delete oldUserFeedDoc.extraData;
|
32
|
-
console.log("deleted extraData from oldUserFeedDoc");
|
33
|
-
extraData = {
|
34
|
-
...extraData,
|
35
|
-
lotNo,
|
36
|
-
status: data
|
37
|
-
}
|
38
|
-
let newUserFeedDoc: any = {};
|
39
|
-
if (isError) {
|
40
|
-
console.log("api sent error response");
|
41
|
-
newUserFeedDoc.cardColor = "#FFF44336";
|
42
|
-
} else {
|
43
|
-
console.log("api send success response");
|
44
|
-
if (extraData.toBePrinted) {
|
45
|
-
extraData.print = extraData.toBePrinted;
|
46
|
-
extraData.print["lot_no"] = lotNo
|
47
|
-
delete extraData.toBePrinted;
|
48
|
-
}
|
49
|
-
}
|
50
|
-
|
51
|
-
description = `${description}--${data.split(" ").slice(0, 3).join(" ")}`;
|
52
|
-
|
53
|
-
console.log("updated the description");
|
54
|
-
newUserFeedDoc = {
|
55
|
-
...oldUserFeedDoc,
|
56
|
-
...newUserFeedDoc,
|
57
|
-
description: description,
|
58
|
-
extraData: extraData
|
59
|
-
}
|
60
|
-
console.log("going to set the newUserFeedDoc");
|
61
|
-
userFeedDoc.forEach((doc) => {
|
62
|
-
doc.ref.set(newUserFeedDoc)
|
63
|
-
})
|
64
|
-
console.log("done");
|
65
|
-
// userFeedDoc.forEach((doc)=>{
|
66
|
-
// doc.ref.update({
|
67
|
-
// description:description,
|
68
|
-
// extraData:extraData
|
69
|
-
// })
|
70
|
-
// if (doc.data().tobePrinted) {
|
71
|
-
// doc.ref.update({
|
72
|
-
// print: doc.data().tobePrinted
|
73
|
-
// })
|
74
|
-
// }
|
75
|
-
// if (isError) {
|
76
|
-
// doc.ref.update({
|
77
|
-
// cardColor: "#FFF44336"
|
78
|
-
// })
|
79
|
-
// }
|
80
|
-
// })
|
81
|
-
return "success"
|
82
|
-
}
|
83
|
-
|
84
|
-
static async updateEndMeetingsTimeInFeeds(firestore: admin.firestore.Firestore, userId: string, companyId: string, eventId: string, endTime: number) {
|
85
|
-
let userFeedDoc = await firestore.collection("Feeds").doc(userId).collection(companyId).where("eventId", "==", eventId).get()
|
86
|
-
if (userFeedDoc.docs.length) {
|
87
|
-
let extraData = userFeedDoc.docs[0].data().extraData
|
88
|
-
extraData = {
|
89
|
-
...extraData,
|
90
|
-
"End Time": endTime
|
91
|
-
}
|
92
|
-
console.log(extraData)
|
93
|
-
userFeedDoc.forEach((doc) => {
|
94
|
-
doc.ref.update({
|
95
|
-
extraData: extraData
|
96
|
-
})
|
97
|
-
})
|
98
|
-
return "success"
|
99
|
-
}
|
100
|
-
}
|
101
|
-
|
102
|
-
|
103
|
-
}
|
104
|
-
export { Feeds };
|
@@ -1,61 +0,0 @@
|
|
1
|
-
import * as admin from "firebase-admin";
|
2
|
-
import { Company } from "./company.model";
|
3
|
-
|
4
|
-
class Geofence{
|
5
|
-
|
6
|
-
static async getOrCreateGeoFence(firestore:admin.firestore.Firestore,geofenceDoc:any){
|
7
|
-
let snapshot = await firestore.collection('Geofence').where('companyNickName','==',geofenceDoc.companyNickName).get()
|
8
|
-
if(snapshot.empty){
|
9
|
-
if(!geofenceDoc.companyId){
|
10
|
-
let companynickname = await Company.getCompanyIdbyNickname(firestore,geofenceDoc.companyNickName)
|
11
|
-
geofenceDoc.companyId = companynickname
|
12
|
-
}
|
13
|
-
geofenceDoc = await Geofence.convertGeofenceDataType(geofenceDoc)
|
14
|
-
let geofence_snapshot = firestore.collection("Geofence").doc()
|
15
|
-
let docId = geofence_snapshot.id
|
16
|
-
geofenceDoc.id = docId
|
17
|
-
geofence_snapshot.set(geofenceDoc)
|
18
|
-
return geofenceDoc
|
19
|
-
}
|
20
|
-
return snapshot.docs[0].data()
|
21
|
-
}
|
22
|
-
|
23
|
-
static async convertGeofenceDataType(geoFenceDoc:any){
|
24
|
-
if(geoFenceDoc.geoFenceIds){
|
25
|
-
geoFenceDoc.geoFenceIds = geoFenceDoc.geoFenceIds.split('&').map(Number)
|
26
|
-
}else{
|
27
|
-
geoFenceDoc.geoFenceIds = []
|
28
|
-
}
|
29
|
-
for(let value of geoFenceDoc.geoFence){
|
30
|
-
if(value.area){
|
31
|
-
value.area = Number(value.area)
|
32
|
-
}
|
33
|
-
value.attributes = {}
|
34
|
-
if(value.calendarId){
|
35
|
-
value.calendarId = Number(value.calendarId)
|
36
|
-
}
|
37
|
-
if(value.id){
|
38
|
-
value.id = Number(value.id)
|
39
|
-
}
|
40
|
-
}
|
41
|
-
return geoFenceDoc
|
42
|
-
}
|
43
|
-
|
44
|
-
static async updateGeofence(firestore:admin.firestore.Firestore,arrayUnion:any,geofenceDoc:any){
|
45
|
-
let snapshot = await firestore.collection('Geofence').where('companyNickName','==',geofenceDoc.companyNickName).get()
|
46
|
-
if(snapshot.empty){
|
47
|
-
return `create geofence for this company ${geofenceDoc.nickName}`
|
48
|
-
}else{
|
49
|
-
for(let geofenceDetail of geofenceDoc.geoFence){
|
50
|
-
snapshot.forEach((doc)=>{
|
51
|
-
doc.ref.update({
|
52
|
-
geoFence: arrayUnion(geofenceDetail),
|
53
|
-
geoFenceIds:arrayUnion(geofenceDetail.id)
|
54
|
-
})
|
55
|
-
})
|
56
|
-
}
|
57
|
-
return "updated successfully"
|
58
|
-
}
|
59
|
-
}
|
60
|
-
}
|
61
|
-
export { Geofence }
|