diff options
author | Jongmok Hong <jongmok@google.com> | 2018-09-19 11:43:03 +0900 |
---|---|---|
committer | Jongmok Hong <jongmok@google.com> | 2018-10-02 08:06:23 +0900 |
commit | b76820eae0c12db5ef5a3eeb828e98e2af6ddae7 (patch) | |
tree | 069c4c6a3ae2c851d943c5f69830e8a098486d8a | |
parent | a2a6d84b2826f919d2751bb693582bc307dbed69 (diff) | |
download | test_serving-b76820eae0c12db5ef5a3eeb828e98e2af6ddae7.tar.gz |
Display the latest build and schedule update time.
Test: go/vtslab-schedule-dev
Bug: 116284491
Change-Id: Ib1cf40aeb521a20db6be7736459c24d0329ab3d2
-rw-r--r-- | gae/frontend/src/app/app.module.ts | 3 | ||||
-rw-r--r-- | gae/frontend/src/app/menu/dashboard/dashboard.component.html | 17 | ||||
-rw-r--r-- | gae/frontend/src/app/menu/dashboard/dashboard.component.scss | 17 | ||||
-rw-r--r-- | gae/frontend/src/app/menu/dashboard/dashboard.component.ts | 51 | ||||
-rw-r--r-- | gae/frontend/src/app/menu/menu_base.ts | 2 | ||||
-rw-r--r-- | gae/frontend/src/app/model/build.ts | 1 | ||||
-rw-r--r-- | gae/frontend/src/styles.scss | 4 | ||||
-rw-r--r-- | gae/webapp/src/proto/model.py | 1 |
8 files changed, 90 insertions, 6 deletions
diff --git a/gae/frontend/src/app/app.module.ts b/gae/frontend/src/app/app.module.ts index 8eb7026..c70fd52 100644 --- a/gae/frontend/src/app/app.module.ts +++ b/gae/frontend/src/app/app.module.ts @@ -23,6 +23,7 @@ import { RouterModule, Routes } from '@angular/router'; // Angular Material modules import { MatButtonModule } from '@angular/material/button'; +import { MatCardModule } from '@angular/material/card'; import { MatChipsModule } from '@angular/material/chips'; import { MatExpansionModule } from '@angular/material/expansion'; import { MatFormFieldModule } from '@angular/material/form-field'; @@ -70,6 +71,7 @@ const appRoutes: Routes = [ @NgModule({ imports: [ MatButtonModule, + MatCardModule, MatChipsModule, MatExpansionModule, MatFormFieldModule, @@ -85,6 +87,7 @@ const appRoutes: Routes = [ ], exports: [ MatButtonModule, + MatCardModule, MatChipsModule, MatExpansionModule, MatFormFieldModule, diff --git a/gae/frontend/src/app/menu/dashboard/dashboard.component.html b/gae/frontend/src/app/menu/dashboard/dashboard.component.html index 0ddc6ef..b91e80c 100644 --- a/gae/frontend/src/app/menu/dashboard/dashboard.component.html +++ b/gae/frontend/src/app/menu/dashboard/dashboard.component.html @@ -12,4 +12,19 @@ See the License for the specific language governing permissions and limitations under the License. --> -VTS Scheduler Dashboard +<div fxLayout="row"> + <mat-card> + <mat-card-title>Build</mat-card-title> + <mat-card-subtitle>Last updated: {{getRelativeTime(lastBuildUpdateTime)}}</mat-card-subtitle> + <button mat-raised-button (click)="getLatestBuild()"> + <mat-icon>refresh</mat-icon> + </button> + </mat-card> + <mat-card> + <mat-card-title>Schedule</mat-card-title> + <mat-card-subtitle>Last updated: {{getRelativeTime(lastScheduleUpdateTime)}}</mat-card-subtitle> + <button mat-raised-button (click)="getLastestSchedule()"> + <mat-icon>refresh</mat-icon> + </button> + </mat-card> +</div> diff --git a/gae/frontend/src/app/menu/dashboard/dashboard.component.scss b/gae/frontend/src/app/menu/dashboard/dashboard.component.scss index e69de29..a17cb36 100644 --- a/gae/frontend/src/app/menu/dashboard/dashboard.component.scss +++ b/gae/frontend/src/app/menu/dashboard/dashboard.component.scss @@ -0,0 +1,17 @@ +.mat-card { + width: 50%; + + .mat-raised-button { + position: absolute; + top: 10px; + right: 10px; + min-width: 28px; + width: 28px; + height: 28px; + padding: 0; + .mat-icon { + width: 24px; + height: 24px; + } + } +} diff --git a/gae/frontend/src/app/menu/dashboard/dashboard.component.ts b/gae/frontend/src/app/menu/dashboard/dashboard.component.ts index 57ea988..79d85a0 100644 --- a/gae/frontend/src/app/menu/dashboard/dashboard.component.ts +++ b/gae/frontend/src/app/menu/dashboard/dashboard.component.ts @@ -13,17 +13,60 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Component } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { MatSnackBar } from '@angular/material'; +import { BuildService } from "../build/build.service"; +import { MenuBaseClass } from "../menu_base"; +import { ScheduleService } from "../schedule/schedule.service"; + /** Component that handles dashboard. */ @Component({ selector: 'app-dashboard', templateUrl: './dashboard.component.html', + providers: [ BuildService, ScheduleService ], styleUrls: ['./dashboard.component.scss'] }) -export class DashboardComponent { - constructor(public snackBar: MatSnackBar) { - this.snackBar.dismiss(); +export class DashboardComponent extends MenuBaseClass implements OnInit { + lastBuildUpdateTime: any = '---'; + lastScheduleUpdateTime: any = '---'; + + constructor(private buildService: BuildService, + private scheduleService: ScheduleService, + public snackBar: MatSnackBar) { + super(snackBar); + } + + ngOnInit(): void { + this.getLatestBuild(); + this.getLastestSchedule(); + } + + /** Fetches the most recently updated build and gets timestamp from it. */ + getLatestBuild() { + this.lastBuildUpdateTime = '---'; + this.buildService.getBuilds(1, 0, '', 'timestamp', 'desc') + .subscribe( + (response) => { + if (response.builds) { + this.lastBuildUpdateTime = response.builds[0].timestamp; + } + }, + (error) => this.showSnackbar(`[${error.status}] ${error.name}`) + ); + } + + /** Fetches the most recently updated schedule and gets timestamp from it. */ + getLastestSchedule() { + this.lastScheduleUpdateTime = '---'; + this.scheduleService.getSchedules(1, 0, '', 'timestamp', 'desc') + .subscribe( + (response) => { + if (response.schedules) { + this.lastScheduleUpdateTime = response.schedules[0].timestamp; + } + }, + (error) => this.showSnackbar(`[${error.status}] ${error.name}`) + ); } } diff --git a/gae/frontend/src/app/menu/menu_base.ts b/gae/frontend/src/app/menu/menu_base.ts index 8d568b0..316923e 100644 --- a/gae/frontend/src/app/menu/menu_base.ts +++ b/gae/frontend/src/app/menu/menu_base.ts @@ -50,7 +50,7 @@ export abstract class MenuBaseClass { getRelativeTime(timeString) { return (moment.tz(timeString, 'YYYY-MM-DDThh:mm:ss', 'UTC').isValid() ? - moment.tz(timeString, 'YYYY-MM-DDThh:mm:ss', 'UTC').fromNow() : timeString); + moment.tz(timeString, 'YYYY-MM-DDThh:mm:ss', 'UTC').fromNow() : '---'); } /** Displays a snackbar notification. */ diff --git a/gae/frontend/src/app/model/build.ts b/gae/frontend/src/app/model/build.ts index 9e946d1..bf32a4a 100644 --- a/gae/frontend/src/app/model/build.ts +++ b/gae/frontend/src/app/model/build.ts @@ -21,4 +21,5 @@ export class Build { artifact_type: string = void 0; artifacts: string[] = void 0; signed: boolean = void 0; + timestamp: any = void 0; } diff --git a/gae/frontend/src/styles.scss b/gae/frontend/src/styles.scss index 0c95e64..7505757 100644 --- a/gae/frontend/src/styles.scss +++ b/gae/frontend/src/styles.scss @@ -22,6 +22,10 @@ body { } } +.mat-card { + margin: 20px; +} + .entity-table { margin: 10px 20px 20px 20px; diff --git a/gae/webapp/src/proto/model.py b/gae/webapp/src/proto/model.py index b29ad6b..d24db1e 100644 --- a/gae/webapp/src/proto/model.py +++ b/gae/webapp/src/proto/model.py @@ -42,6 +42,7 @@ class BuildInfoMessage(messages.Message): artifact_type = messages.StringField(5) artifacts = messages.StringField(6, repeated=True) signed = messages.BooleanField(7) + timestamp = message_types.DateTimeField(8) class ScheduleControlModel(ndb.Model): |