# 17th July Report ## Progress Time: **08:55** Event: Entering the lab --- ### Continuing to finalize code on Maintenance Progress page Time: **10:17** - There is changes on API where getting the dispenser repair condition return value. - From json object: ```json { "code": 200, "msg": "success", "success": "true", "result": "ok", "Data": [ { "Device_ID": "EE_06_01", "UploadTime": "2019-03-08 16:32:00", "Status": 4, "ErrorType": 5, "Description": "Coldd water button is broken" } ] } ``` - To json array: ```json { "code": 200, "msg": "success", "success": "true", "result": "ok", "Data": [ { "Device_ID": "MA_05_01", "Email": "ntust.smartcampus@gmail.com", "ErrorType": 5, "Description": "Broken", "Status": 4, "UploadTime": "2019-01-02 09:36:00", "NotifyTime": "2019-01-02 09:36:00", "Maintainer": "Mr.Pang", "Result": "Someone push powersaving button", "CompleteTime": "2019-01-02 24:00:00", "Index": 0, "Source": null, "Source2": null, "Source3": null }, ... ] } ``` - Not only changes the format but also value inside each of JSON object, now it has three types of time: - **Upload time**, when the report has been sent. - **Notify time**, when the report has been received by the company and forwarded to repairman. - **Complete time**, when the problem has been repaired and confirmed by the repairman. - This also change the code both in back end (Typescript) and front end (HTML). - The result will be like this: <center> <img src="https://raw.githubusercontent.com/aru1702/images/master/ntust-documentation/28-01.JPG" /> </center> --- ### Discuss with Mr. Johnny about changes for database Time: **11:20** - In about to get the different time for every steps in dispenser repair condition, some attributes should be added. - Status for maintenance will be increased to 7: - 1 = user report the problem. - 2 = client receive the problem (by Ms. Fang). - 3 = company receive the problem (by Mr. Pang). - 4 = company assign to repairman to do repairment. - 5 = repairment done - 6 = company receive report with pictures - 7 = client receive notify and repairment complete. - Current time attributes (3): upload time, notify time, and complete time, it should has 7 different time attributes. - Will be added time attributes (add 4 more): - Time when the company person in charge get the problem from the client. - Time when the company confirm and assign the problem to repairman - Time when the repairman has done fix the problem and report back to company. - Time when company receive report from repairman and about to notify to client. - My suggestion: - Should be add `boolean` identification for if repairman has to delay the repair progress because need to request spareparts/components. - When the problem status is 4, means that problem has been set to be repaired, server has to add an attribute about time to notify in Repairman App when it must be done. - Along with above, server will calculate that time (`deadlineTime`) with the current server time (`currentTime`) by the date of month. - `deadlineTime` < `currentTime`, means problem in yesterday timeline, high priority to be done. - `deadlineTime` = `currentTime`, means problem in today timeline, in Repairman App set as Today Mission. - `deadlineTime` > `currentTime`, means problem for tomorrow/future timeline, set as Next Mission. - Changes should be followed Ms. Annie design and confirm if there any disposal component. - Repairmen App logic: **step 4 to 5** when repairment has done <center> <img src="https://raw.githubusercontent.com/aru1702/images/master/ntust-documentation/28-02.JPG" style="max-height: 350px" /> </center> <br> - Company Dashboard logic: **step 3 to 4** when company receive report from client, and **step 5 to 6** when company send repairment report back to client <center> <img src="https://raw.githubusercontent.com/aru1702/images/master/ntust-documentation/28-03.JPG" /> </center> --- ### Integrate the Maintenance Progress page in Dashboard Page Time: **15:37** - From Dashboard Page, maintenance progress can be accessed when the user has logged in and has report the problem before. - If user hasn't report anything it will display the same "No report problem" text as when user hasn't logged in. - If user has logged in and has done report before it will display link to Maintenance Progress page with text "View maintenance report". - Dashboard Page also responsible with handling the `device_id` and `session_id`, which is user's email address, that got from Preference and passed to Maintenance Progress page. - It will be display like this, left is before log in and log in but no report has been sent, and right is after log in and has report has been sent. <center> <img src="https://raw.githubusercontent.com/aru1702/images/master/ntust-documentation/28-04.JPG" style="max-height: 350px" /> </center> #### In dashboard.page.html ```htmlmixed= <div class="report-status transparent" *ngIf="!hasReportSubmitted"> No Report Problem </div> <div class="report-status" *ngIf="hasReportSubmitted" (click)="goToMaintenanceProgress()"> View maintenance progress > </div> ``` #### In dashboard.page.scss ```css= .report-status{ text-align: center; height: 35%; bottom: 0px; border-top: 1px solid #e9e9e9; padding: 30px; } .transparent { color: rgba($color: #000000, $alpha: 0.5) } ``` #### Add into dashboard.page.ts ```typescript= public hasReportSubmitted: boolean = false; async main () { let email = await this.pref.getData(StaticVariable.KEY__SESSION_ID); if (email !== "" || email !== null || email !== undefined) { this.hasReportSubmitted = await this.api.checkAnyReportSubmitted(email, this.device_id); } } ``` - If variable `hasReportSubmitted` is false considered that user hasn't logged in and/or never submit a problem report before, true if user has logged in and has ever submit a report before. - On **typescript** code above, added one function in `dispenser-api.service` to check if user has ever submit a report with boolean return value. ```typescript= async checkAnyReportSubmitted (email: string, device_id: string) { let data = await this.getDispenserRepairCondition(device_id); let hasCorrectEmail = false; // check if dispenser has problem reported if (data.length > 0) { for (let i = 0 ; i < data.length ; i++) { // check if any problem submitted by the user if (data[i]['Email'] === email) { hasCorrectEmail = true; break; } } } return hasCorrectEmail; } ``` --- ## Conclusion - Maintenance progress has steps to display with different time for each of them. - Because of more than 4 steps from Ms. Annie design, only 3 steps from time stored in database, we should add more time attributes to database. - There should be at least 7 steps of maintenance progress: **(start)** initial report, client receive, company confirm, repairman fix, repair done, company re-confirm, and client receive report **(complete)**. - Further changes will be later discuss between my teams, Mr.Johnny, and Ms. Annie, this also discussing about Repairman App and testing Company Dashboard. - Integrate the Dashboard Page to Maintenance Progress with condition if already log in and has report been submitted before. --- Time: **18:00** Event: Leaving the lab ###### tags: `on-intern`