---
# System prepended metadata

title: '<center>8^th^ July, 2019</center>'
tags: [Daily Internship Documentation]

---

# <center>8^th^ July, 2019</center>

###### tags: `Daily Internship Documentation`
---
## 4^th^ Day of Internship


## Summary
Today I improve the drop-down menu feature. I succeded to create a routing to go to the detailed-information page, and then integrate it with the button in the drop down-menu in dashboard page. I also tidy up the app folder, grouping some folder into pages folder. 

---
## Documentation

### 1. Dashboard Page
#### 1.1 dashboard.page.ts

1. Declare router variable in constructor. **(line 37)**
2. Create goToDetailedInformation() function, it is a router to go to detailed-information page. **(73-75)**

```htmlmixed=
import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http'
import { HostListener } from "@angular/core";
import { Router } from '@angular/router';

@Component({
  selector: 'app-dashboard',
  templateUrl: './dashboard.page.html',
  styleUrls: ['./dashboard.page.scss'],
})

export class DashboardPage implements OnInit {
  private device_id = 'T4_07_01';
  
  //variables for maintenance progress information
  private url_maintenance_progress = 'https://smartcampus.et.ntust.edu.tw:5425/Dispenser/Repair?Device_ID=' + this.device_id;
  private maintenance_status: any;
  private maintenance_data: any;
  private no_report_problem: boolean;

  //variables for dispenser picture
  public url_dispenser_picture = 'https://smartcampus.et.ntust.edu.tw:5425/Dispenser/Image?Device_ID=' + this.device_id;
  
  //variables for screen & item resolution
  public screenHeight: any;
  public screenWidth: any;

  public headerHeight: any;
  public contentHeight: any;

  public jellyfishIconTop: any;
  public jellyfishIconLeft: any;

  //Variable for tracking progress
  public trackIsActive: boolean;
  
  constructor(private http:HttpClient, private router: Router) {  }
  ngOnInit() {
    this.getScreenSize();
  }
  
    @HostListener('window:resize', ['$event'])
    getScreenSize(event?: any) {
      this.screenWidth = window.innerWidth;
      this.screenHeight = window.innerHeight;
      
      this.headerHeight = this.screenHeight * 0.7;
      this.contentHeight = this.screenHeight * 0.3;

      this.jellyfishIconTop = this.headerHeight - 60;
      this.jellyfishIconLeft = this.screenWidth/2 - 60;
  }

    maintenanceStatus(){
      this.http.get(this.url_maintenance_progress).subscribe(res => {
        this.maintenance_data = res["Data"];
        this.maintenance_status = this.maintenance_data["status"];
      })
      
      if(this.maintenance_status != 4){
        this.no_report_problem = true;
      }else{
        this.no_report_problem = false;
      }
  
      console.log('Report status: ' + this.no_report_problem);
    }
    
    getDispenserPictureUrl(){
      return this.url_dispenser_picture;
    }

    goToDetailedInformation(){
      this.router.navigate(['detailed-information']);
    }
}
```

#### 1.2 dashboard.page.html

1. Remove the href property in dropdown button. Add 'more-button' class to the button. **(line 14-15)**
2. Add (click) function in the 'Detailed information' button that will call goToDetailedInformation() function from typescript. **(line 15)**

```htmlmixed=
<ion-header no-border [style.height.px]="headerHeight" [style.width.px]="screenWidth">
  <div class="background-image" [ngStyle]="{'background-image': 'url(' + url_dispenser_picture + ')'}">

    <div class="overlay">
      <div class="logo">
        <img src="assets/dashboard/acuo_logo.png">
      </div>

      <!--More button for dropdown options-->
      <span class="dropdown" style="float: right;">
        <button class="ripple dropbtn">
          <ion-icon name="more" size="large"></ion-icon>
          <div class="dropdown-content">
            <button class="more-button">Maintenance records</button>
            <button class="more-button" (click)="goToDetailedInformation()">Detailed information</button>
          </div>
        </button>
      </span>

      <!--Star button for tracking feature-->
      <span>
        <button class="ripple header-button">
          <ion-icon name="star-outline" size="large"></ion-icon>
        </button>
      </span>

      <div class="jellyfish-icon" [style.top.px]="jellyfishIconTop" [style.left.px]="jellyfishIconLeft">
        <img alt="avatar" src="assets/dashboard/jellyfishIcon.png">
      </div>
    </div>

  </div>
</ion-header>

<ion-content [style.height.px]="contentHeight" [style.width.px]="screenWidth" position="absolute">

  <div class="content-button-space">

    <!--Report Dispenser button-->
    <span class="content-button">
      <button class="ripple full-button">
        <ion-icon name="warning" size="large"></ion-icon>
        <p>Report dispenser</p>
      </button>
    </span>

    <!--Nearby Dispenser button-->
    <span class="content-button ">
      <button class="ripple full-button">
        <ion-icon name="pin" size="large"></ion-icon>
        <p>Nearby dispenser</p>
      </button>
    </span>

  </div>

  <div class="report-status">
    No Report Problem
  </div>

</ion-content>
```

#### 1.1 dashboard.page.scss

1. In *.header-button* class, add background-color: transparent property. **(line 39)**
2. In *.full-button* class, add background-color: transparent property. **(line 76)**
3. Remove all the *.button* properties. Add outline: none property in it. **(line 114-117)**
4. Change the position of drop-down and *.button* class properties to the bottom. **(line 119-165)**
5. Define *.more-button* class to configure the display of the buttons in the drop-down content. **(line 145-161)**

```htmlmixed=
//=======================
// Header Part CSS 
//=======================
.ion-header {
    position: relative;
    width: 100%;
}

.background-image, .overlay{
    height: 100%;
    width: 100%;
}
.background-image{
    position: relative;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center center;
}

.overlay {
    z-index: 1;
    background-color: rgba($color: #000000, $alpha: 0.5);
}

.jellyfish-icon{
    position: absolute;
    height: 120px;
    width: 120px;
    border-radius: 50px;
}

.logo{
    position: absolute;
    top: 20px;
}

.header-button{
    position: relative;
    background-color: transparent;
    top: 20px;
    right: 20px;
    float: right;
    height:40px;
    width: 40px;
    color: white;
}

.logo {
    height: 50px;
    width: 90px;
    left: 33px;
}

//=======================
// Content Part CSS
//=======================
.content-button-space{
    position: relative;
    height:65%;
    width: 100%;
}

.content-button{
    position: relative;
    top: 0px;
    left: 0px;
    float: left;
    height:100%;
    width: 50%;
    text-align: center;
    color: black;
}

.full-button{
    position: relative;
    background-color: transparent;
    height: 100%;
    width: 100%;
}

.report-status{
    text-align: center;
    height: 35%;
    bottom: 0px;
    border-top: 1px solid #e9e9e9;
}

//=============================
// CSS properties Configuration
//=============================

/* Ripple effect */
.ripple {
    background-position: center;
    transition: background 0.8s;
}

.ripple:hover {
    background:transparent radial-gradient(circle,  transparent 1%, white 1%) center/15000%;
}

.ripple:active {
    color: #D3D3D3;
    size: 100%;
    transition: background 0s;
}

//Pressed effect

.pressed:active {
  transform: translateY(4px);
}

//button
button{
    outline: none;
}

//Dropdown button configuration
.dropbtn {
    background-color: transparent;
    border: none;
    color: white;
}
 
.dropdown {
    top: 20px;
    right: 20px;
    position: relative;
    display: inline-block;
}
    
.dropdown-content {
    position: absolute;
    display: none;
    right: 0;
    border: none;
    background-color: #f9f9f9;
    min-width: 180px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1;
    border-radius: 8px;
}
  
.dropdown-content .more-button {
    color: black;
    padding: 20px;
    top: 30%;
    height: 50px;
    text-decoration: none;
    display: block;
    border-bottom: black;
    text-align: center;
}

.more-button{
    border-radius: 8px;
    background-color: white;
    width: 100%;
}
.dropdown-content .more-button:hover {background-color: #f1f1f1;}

.dropdown:hover .dropdown-content {
    display: block;
}
```

---
### 2. App Folder
#### 2.1 app.module.ts

1. Import HttpClientModul from '@angular/common/http'. **(line 1)**
2. Insert HttpClientModul into @NgModule. **(line 20)**

```htmlmixed=
import { HttpClientModule } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';

import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';

import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';

@NgModule({
  declarations: [AppComponent],
  entryComponents: [],
  imports: [
    BrowserModule, 
    IonicModule.forRoot(), 
    AppRoutingModule,
    HttpClientModule
  ],
  providers: [
    StatusBar,
    SplashScreen,
    { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}

```

#### 2.2 app-routing.module.ts

1. Redirect the path from ' ' to 'dashboard' page. Remove 'home' page path. **(line 5)**

```htmlmixed=
import { NgModule } from '@angular/core';
import { PreloadAllModules, RouterModule, Routes } from '@angular/router';

const routes: Routes = [
  { path: '', redirectTo: 'dashboard', pathMatch: 'full' },
  { path: 'dashboard', loadChildren: './pages/dashboard/dashboard.module#DashboardPageModule' },
  { path: 'detailed-information', loadChildren: './pages/detailed-information/detailed-information.module#DetailedInformationPageModule' }
];

@NgModule({
  imports: [
    RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
  ],
  exports: [RouterModule]
})
export class AppRoutingModule { }

```

---
## Result

When the user click the 'Detailed information' button, it will go to detailed-information page.
### 1. Dashboard Page
![](https://i.imgur.com/scYE1I0.png)

### 2. Detailed-information Page
![](https://i.imgur.com/uWAaQN3.png)
