Load applications from api.
This commit is contained in:
@@ -9,6 +9,7 @@ import { HeaderComponent } from './header/header.component';
|
|||||||
import { StatusComponent } from './applications/status/status.component';
|
import { StatusComponent } from './applications/status/status.component';
|
||||||
import { ApplicationCardComponent } from './core/components/application-card/application-card.component';
|
import { ApplicationCardComponent } from './core/components/application-card/application-card.component';
|
||||||
import {MatTooltipModule} from '@angular/material/tooltip';
|
import {MatTooltipModule} from '@angular/material/tooltip';
|
||||||
|
import { AddApplicationButtonComponent } from './core/components/add-application-button/add-application-button.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@@ -17,7 +18,8 @@ import {MatTooltipModule} from '@angular/material/tooltip';
|
|||||||
CreateApplicationComponent,
|
CreateApplicationComponent,
|
||||||
UiKitComponent,
|
UiKitComponent,
|
||||||
StatusComponent,
|
StatusComponent,
|
||||||
ApplicationCardComponent
|
ApplicationCardComponent,
|
||||||
|
AddApplicationButtonComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
RouterModule,
|
RouterModule,
|
||||||
|
|||||||
@@ -1,3 +1,13 @@
|
|||||||
<div class="application-list">
|
<div class="application-list" *ngIf="applications?.length; else noAnyApp">
|
||||||
<app-application-card *ngFor="let application of applications" [application]="application"></app-application-card>
|
<app-application-card *ngFor="let application of applications" [application]="application"></app-application-card>
|
||||||
</div>
|
</div>
|
||||||
|
<ng-template #noAnyApp>
|
||||||
|
<div class="no-any-app">
|
||||||
|
<p>
|
||||||
|
There is no any application.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Add one by clicking here: <app-add-application-button></app-add-application-button>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</ng-template>
|
||||||
@@ -1,6 +1,22 @@
|
|||||||
|
@import '../../../colors.scss';
|
||||||
|
|
||||||
.application-list {
|
.application-list {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.no-any-app {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
color: $gray-icon-secondary;
|
||||||
|
|
||||||
|
p {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,5 +28,8 @@ export class StatusComponent implements OnInit {
|
|||||||
image: 'https://gitea.takiguchi.ovh/avatars/6c339db7805f158c21b4eed47758dbb1',
|
image: 'https://gitea.takiguchi.ovh/avatars/6c339db7805f158c21b4eed47758dbb1',
|
||||||
status: 'started'
|
status: 'started'
|
||||||
} as Application);
|
} as Application);
|
||||||
|
|
||||||
|
this._applicationService.getAll()
|
||||||
|
.then(applications => this.applications = applications);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-add-application-button',
|
||||||
|
template: `
|
||||||
|
<button class="secondaryy" type="button" matTooltip="Add a new application to monitor">
|
||||||
|
<mat-icon>add</mat-icon>
|
||||||
|
Add
|
||||||
|
</button>
|
||||||
|
`
|
||||||
|
})
|
||||||
|
export class AddApplicationButtonComponent {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -11,6 +11,10 @@ export class ApplicationService {
|
|||||||
private _httpClient: HttpClient
|
private _httpClient: HttpClient
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
getAll(): Promise<Application[]> {
|
||||||
|
return this._httpClient.get<Application[]>('/api/applications').toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
add(application: Application): Promise<Application> {
|
add(application: Application): Promise<Application> {
|
||||||
return this._httpClient.post<Application>('/api/applications', application).toPromise();
|
return this._httpClient.post<Application>('/api/applications', application).toPromise();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
<header>
|
<header>
|
||||||
<img src="assets/images/logo.png" alt="Cerberus" matTooltip="Cerberus"/>
|
<img src="assets/images/logo.png" alt="Cerberus" matTooltip="Cerberus"/>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<button class="secondaryy" type="button">
|
<app-add-application-button></app-add-application-button>
|
||||||
<mat-icon>add</mat-icon>
|
|
||||||
Add
|
|
||||||
</button>
|
|
||||||
<div class="iconed-input">
|
<div class="iconed-input">
|
||||||
<mat-icon>search</mat-icon>
|
<mat-icon>search</mat-icon>
|
||||||
<input placeholder="Search"/>
|
<input placeholder="Search"/>
|
||||||
|
|||||||
@@ -24,7 +24,3 @@ header {
|
|||||||
right: 1rem;
|
right: 1rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mat-icon {
|
|
||||||
font-size: 18px;
|
|
||||||
}
|
|
||||||
@@ -14,9 +14,11 @@ body {
|
|||||||
|
|
||||||
::selection {
|
::selection {
|
||||||
background: $blue;
|
background: $blue;
|
||||||
|
color: white;
|
||||||
}
|
}
|
||||||
::-moz-selection {
|
::-moz-selection {
|
||||||
background: $blue;
|
background: $blue;
|
||||||
|
color: white;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,3 +187,7 @@ mat-icon.mat-icon {
|
|||||||
left: 1rem;
|
left: 1rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mat-icon.mat-icon {
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user