# 21st August Report
## Progress
Time: **08:50**
Event: Entering the lab
---
### 6th Weekly Presentation
Start time: **09:25**
End time: **11:40**
Professor in-charge: **Prof. Ray**
Result: https://hackmd.io/@muhamadaldy/HkBOj8c4H
---
### Arrived system for Repairman App
Time: **13:58**
- The main target of arrived system is to perform confirm mission for the repairman to the missions been assigned.
- The workflow:
- The repairman should click "ARRIVED" button first in order to write the report.
- Once he's been arrived, he can either do "DONE" or "UNDONE" the mission.
- "DONE" mission means that he clear the mission and send report with image, on the other hand "UNDONE" mission is the opposite but he still need to report why he can't clear it with reason.
- Based on our discussion there are three conditions for Repairman about how missions can be done.
- Repairman clear the mission and send a report with/without attachs pictures.
- Repairman can't clear the mission and send a report with reason.
- Repairman can't clear and not reporting, also repairman not click ARRIVED button on a mission means he was skipping this.
Time: **17:46**
- In **detail.page.html** we add button with two conditions: one is for before ARRIVED button clicked, and the other one when after.
```htmlmixed=
<ion-footer *ngIf="!doneMission">
<section class="full-width">
<ion-button expand="full" *ngIf="!Arrived" (click)="arrived()">Arrived</ion-button>
<ion-grid *ngIf="Arrived">
<ion-row>
<ion-col size="6">
<div>
<ion-button expand="full" (click)="wantToClearMission(false)">Cannot complete<br>by now</ion-button>
</div>
</ion-col>
<ion-col size="6">
<div>
<ion-button expand="full" (click)="wantToClearMission(true)">Complete repair</ion-button>
</div>
</ion-col>
</ion-row>
</ion-grid>
</section>
</ion-footer>
```
- To put the button always on the bottom of Modal page, which is Detail page is pop up in front of Home page, use `ion-footer`.
- In **line 4** is the first condition.
- In **line 6-20** is the second condition, it has two options for want to DONE or NOT DONE the mission.
- For both DONE and NOT DONE will run `wantToClearMission()` function, it also send boolean parameter which **true** is for wants to DONE and **false** for the opposite.
- In **detail.page.ts** we add more functions to handle ARRIVED and DONE/UNDONE button.
```typescript=
export class DetailPage implements OnInit {
Arrived: boolean = false;
data: any;
doneMission: boolean;
inputCamera = false;
image: any = [];
reader: any = [];
// loadCtrl var
makeLoading: any;
constructor(
public navParams: NavParams,
private navCtrl: NavController,
private modalController: ModalController,
private loadCtrl: LoadingController,
private toastCtrl: ToastController,
private api: DispenserAPIService,
private pref: PreferenceManagerService
) {
this.data = navParams.get('Data');
this.doneMission = navParams.get('DoneMission');
}
ngOnInit () {
console.log(this.data);
console.log(this.doneMission);
}
ionViewDidEnter () {
if (this.data['ArriveTime'] !== "") {
this.Arrived = true;
} else {
this.Arrived = false;
}
console.log(this.Arrived);
}
/**
* Create the loading controller
*/
async createLoadCtrl () {
// insert component of loading controller
this.makeLoading = await this.loadCtrl.create({
message: 'Loading data ...',
spinner: 'crescent',
duration: 10000
});
// display the loading controller
await this.makeLoading.present();
}
/**
* Dismiss the loading controller
*/
async dismissLoadCtrl () {
this.makeLoading.dismiss();
}
dismiss () {
this.modalController.dismiss();
}
async arrived () {
// create loading screen
await this.createLoadCtrl();
let myToast: any;
let toastMessage: string;
let missionNum = this.data['MissionNumber'];
let result = await this.api.repairmanHasArrived(missionNum);
if (result === 1) {
this.Arrived = true;
toastMessage = "You have successfully arrived on this mission!"
} else {
toastMessage = "Failed to arrived on this mission, please try again!"
}
// create Toast with myToastMessage as message display
myToast = await this.toastCtrl.create({
message: toastMessage,
duration: 2000,
position: 'top',
showCloseButton: true,
closeButtonText: 'Close'
});
// display the Toast
await myToast.present();
// dismiss the loading screen
this.dismissLoadCtrl();
}
async wantToClearMission (isMissionDone: boolean) {
await this.dismiss();
await this.pref.setData(StaticVariables.KEY__MISSION_DONE_UNDONE__BOOLEAN, isMissionDone);
this.navCtrl.navigateForward(['report-repair']);
}
}
```
- We also use **Loading Controller** to make loading screen, import the code from previous back end code like in Auth pages.
- In **line 68-99** this function will turn `Arrived` boolean variable to true after it ARRIVED button clicked and success performed, then back to front end code (HTML) it will turn ARRIVED button into DONE/UNDONE button.
- In **line 101-105** this function need boolean parameter to set into preference so Report Repair page will has parameter to choose which is the repairman wants to DONE the mission, or to UNDONE the mission.
- DONE the mission means the repairman has clear the mission, write the report with attaching pictures, and send it to company.
- UNDONE the mission means the repairman cannot finish the mission, write the report to tell what the reason, and send it to company.
- Result in Detail page as modal page over the Home page:
- Mission in Today Mission list is clicked
<center>
<img src="https://raw.githubusercontent.com/aru1702/images/master/ntust-documentation/48-01.JPG" style="max-width: 250px" />
</center>
<br>
- After the ARRIVED button has clicked
<center>
<img src="https://raw.githubusercontent.com/aru1702/images/master/ntust-documentation/48-02.JPG" style="max-width: 250px" />
</center>
<br>
- After this, repairman can choose either to DONE (Complete repair) or UNDONE (Cannot complete by now) and routed to Report Repair page by certain condition.
---
## Conclusion
- From today weekly meeting, me and Ian should finish the remaining task before final presentation, also on Friday we should deploy the Repairman App to Johnny domain so it can has online access.
- Arrived function has been created with using Post Repairman Arrived API, this will update ArriveTime attribute in database also update UI in Repairman App.
---
Time: **18:05**
Event: Leaving the lab
###### tags: `on-intern`