Fix modal displaying and add image to application entity.
This commit is contained in:
@@ -2,3 +2,4 @@
|
|||||||
<div class="content">
|
<div class="content">
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
</div>
|
</div>
|
||||||
|
<app-modal></app-modal>
|
||||||
@@ -10,6 +10,7 @@ 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';
|
import { AddApplicationButtonComponent } from './core/components/add-application-button/add-application-button.component';
|
||||||
|
import { ModalComponent } from './core/components/modal/modal.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@@ -19,7 +20,8 @@ import { AddApplicationButtonComponent } from './core/components/add-application
|
|||||||
UiKitComponent,
|
UiKitComponent,
|
||||||
StatusComponent,
|
StatusComponent,
|
||||||
ApplicationCardComponent,
|
ApplicationCardComponent,
|
||||||
AddApplicationButtonComponent
|
AddApplicationButtonComponent,
|
||||||
|
ModalComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
RouterModule,
|
RouterModule,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<div class="card">
|
<div class="content">
|
||||||
<h1>Add a new application</h1>
|
<h1>Add a new application</h1>
|
||||||
<form [formGroup]="form" (ngSubmit)="onSubmit()" ngNativeValidate>
|
<form [formGroup]="form" (ngSubmit)="onSubmit()" ngNativeValidate>
|
||||||
<div class="form-control">
|
<div class="form-control">
|
||||||
@@ -10,15 +10,19 @@
|
|||||||
<input id="service-name" formControlName="serviceName" placeholder="Enter service name" required/>
|
<input id="service-name" formControlName="serviceName" placeholder="Enter service name" required/>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-control">
|
<div class="form-control">
|
||||||
<label for="service-type">Type:</label>
|
<label for="service-type">Type</label>
|
||||||
<select id="service-type" formControlName="serviceType" placeholder="Enter service type">
|
<select id="service-type" formControlName="serviceType" placeholder="Enter service type">
|
||||||
<option *ngFor="let type of serviceTypes" [value]="type.value">
|
<option *ngFor="let type of serviceTypes" [value]="type.value">
|
||||||
{{type.label}}
|
{{type.label}}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-control">
|
||||||
|
<label for="image">Image</label>
|
||||||
|
<input id="image" formControlName="image" placeholder="Enter image url" required/>
|
||||||
|
</div>
|
||||||
<div class="row action">
|
<div class="row action">
|
||||||
<button type="button" class="secondary">Cancel</button>
|
<button type="button" class="secondary" (click)="onCancel()">Cancel</button>
|
||||||
<button type="submit">Save</button>
|
<button type="submit">Save</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -1,3 +1,17 @@
|
|||||||
.card {
|
.content {
|
||||||
|
width: 300px;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
|
||||||
|
form {
|
||||||
|
.action {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
|
button {
|
||||||
|
margin: 0;
|
||||||
|
width: 100px;
|
||||||
|
flex: 0 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
|||||||
import { Application } from 'src/app/core/entities/Application';
|
import { Application } from 'src/app/core/entities/Application';
|
||||||
import { ReferentialData } from 'src/app/core/entities/ReferentialData';
|
import { ReferentialData } from 'src/app/core/entities/ReferentialData';
|
||||||
import { ApplicationService } from 'src/app/core/services/application.service';
|
import { ApplicationService } from 'src/app/core/services/application.service';
|
||||||
|
import { ModalService } from 'src/app/core/services/modal.service';
|
||||||
import { ReferentialDataService } from 'src/app/core/services/referential-data.service';
|
import { ReferentialDataService } from 'src/app/core/services/referential-data.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -14,14 +15,16 @@ export class CreateApplicationComponent implements OnInit {
|
|||||||
form: FormGroup = this._formBuilder.group({
|
form: FormGroup = this._formBuilder.group({
|
||||||
name: [undefined, Validators.required],
|
name: [undefined, Validators.required],
|
||||||
serviceName: [undefined, Validators.required],
|
serviceName: [undefined, Validators.required],
|
||||||
serviceType: [undefined, Validators.required]
|
serviceType: [undefined, Validators.required],
|
||||||
|
image: [undefined, Validators.required]
|
||||||
});
|
});
|
||||||
serviceTypes: ReferentialData[] = [];
|
serviceTypes: ReferentialData[] = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _formBuilder: FormBuilder,
|
private _formBuilder: FormBuilder,
|
||||||
private _referentialDataService: ReferentialDataService,
|
private _referentialDataService: ReferentialDataService,
|
||||||
private _applicationService: ApplicationService
|
private _applicationService: ApplicationService,
|
||||||
|
private _modalService: ModalService
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
@@ -40,4 +43,8 @@ export class CreateApplicationComponent implements OnInit {
|
|||||||
console.error('Form is invalid');
|
console.error('Form is invalid');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onCancel(): void {
|
||||||
|
this._modalService.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { Application } from 'src/app/core/entities/Application';
|
import { Application } from 'src/app/core/entities/Application';
|
||||||
import { ApplicationService } from 'src/app/core/services/application.service';
|
import { ApplicationService } from 'src/app/core/services/application.service';
|
||||||
|
import { ModalService } from 'src/app/core/services/modal.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-status',
|
selector: 'app-status',
|
||||||
@@ -11,7 +12,8 @@ export class StatusComponent implements OnInit {
|
|||||||
applications: Application[] = [];
|
applications: Application[] = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _applicationService: ApplicationService
|
private _applicationService: ApplicationService,
|
||||||
|
private _modalService: ModalService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|||||||
@@ -1,15 +1,23 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { CreateApplicationComponent } from 'src/app/applications/create-application/create-application.component';
|
||||||
|
import { ModalService } from '../../services/modal.service';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-add-application-button',
|
selector: 'app-add-application-button',
|
||||||
template: `
|
template: `
|
||||||
<button class="secondaryy" type="button" matTooltip="Add a new application to monitor">
|
<button type="button" (click)="onClick()" matTooltip="Add a new application to monitor">
|
||||||
<mat-icon>add</mat-icon>
|
<mat-icon>add</mat-icon>
|
||||||
Add
|
Add
|
||||||
</button>
|
</button>
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
export class AddApplicationButtonComponent {
|
export class AddApplicationButtonComponent {
|
||||||
|
constructor(
|
||||||
|
private _modalService: ModalService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
onClick(): void {
|
||||||
|
this._modalService.open(CreateApplicationComponent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<div id="modal-container" [class]="this.displayed ? 'displayed' : 'hidden'">
|
||||||
|
<div id="overlay"></div>
|
||||||
|
<div id="modal-frame" #modalFrame>
|
||||||
|
<div id="modal-window">
|
||||||
|
<div #modalContent></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
63
cerberus/src/app/core/components/modal/modal.component.scss
Normal file
63
cerberus/src/app/core/components/modal/modal.component.scss
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
#modal-container {
|
||||||
|
&.hidden {
|
||||||
|
#overlay {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#modal-frame {
|
||||||
|
height: 0;
|
||||||
|
|
||||||
|
#modal-window {
|
||||||
|
top: -500px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.displayed {
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
#overlay {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
#modal-frame {
|
||||||
|
#modal-window {
|
||||||
|
top: 58px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#overlay {
|
||||||
|
position: fixed;
|
||||||
|
top: 56px;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
z-index: 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
#modal-frame {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
z-index: 101;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
transition: height 1s ease;
|
||||||
|
|
||||||
|
#modal-window {
|
||||||
|
position: absolute;
|
||||||
|
background-color: #f6f6f6;
|
||||||
|
z-index: 102;
|
||||||
|
padding: 1rem;
|
||||||
|
border: 1px solid #bfbfbf;
|
||||||
|
border-top: none;
|
||||||
|
min-width: 600px;
|
||||||
|
max-height: 500px;
|
||||||
|
box-shadow: inset 0px 5px 5px -3px rgba(0,0,0,.2), 0px 5px 10px 1px rgba(0,0,0,.2);
|
||||||
|
transition: top 1s ease;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
35
cerberus/src/app/core/components/modal/modal.component.ts
Normal file
35
cerberus/src/app/core/components/modal/modal.component.ts
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import { Component, ComponentFactoryResolver, ElementRef, OnInit, Type, ViewChild, ViewContainerRef } from "@angular/core";
|
||||||
|
import { ModalService } from "../../services/modal.service";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-modal',
|
||||||
|
templateUrl: './modal.component.html',
|
||||||
|
styleUrls: ['./modal.component.scss']
|
||||||
|
})
|
||||||
|
export class ModalComponent implements OnInit {
|
||||||
|
displayed: boolean = false;
|
||||||
|
modalContentClass: Type<unknown> | undefined;
|
||||||
|
@ViewChild('modalFrame', { static: true }) modalFrame: ElementRef<HTMLDivElement> | undefined;
|
||||||
|
@ViewChild('modalContent', { read: ViewContainerRef }) modalContent: ViewContainerRef | undefined;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private _componentFactoryResolver: ComponentFactoryResolver,
|
||||||
|
private _modalService: ModalService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this._modalService.modalContent.subscribe(modalContentClass => {
|
||||||
|
if (!modalContentClass) {
|
||||||
|
this.displayed = false;
|
||||||
|
window.setTimeout(() => {
|
||||||
|
this.modalContent?.detach();
|
||||||
|
}, 1000);
|
||||||
|
} else {
|
||||||
|
this.displayed = true;
|
||||||
|
this.modalContent?.detach();
|
||||||
|
const componentFactory = this._componentFactoryResolver.resolveComponentFactory(modalContentClass);
|
||||||
|
this.modalContent?.createComponent<unknown>(componentFactory);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
21
cerberus/src/app/core/services/modal.service.ts
Normal file
21
cerberus/src/app/core/services/modal.service.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { Injectable, Type } from "@angular/core";
|
||||||
|
import { BehaviorSubject, Observable } from "rxjs";
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class ModalService {
|
||||||
|
_modalContent: BehaviorSubject<Type<unknown> | undefined> = new BehaviorSubject<Type<unknown> | undefined>(undefined);
|
||||||
|
|
||||||
|
open(componentClass: Type<unknown>): void {
|
||||||
|
this._modalContent.next(componentClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
close(): void {
|
||||||
|
this._modalContent.next(undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
get modalContent(): Observable<Type<unknown> | undefined> {
|
||||||
|
return this._modalContent.asObservable();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,8 @@ header {
|
|||||||
height: 56px;
|
height: 56px;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
border: 1px solid #bfbfbf;
|
||||||
|
z-index: 102;
|
||||||
|
|
||||||
img {
|
img {
|
||||||
width: 42px;
|
width: 42px;
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import { Component } from "@angular/core";
|
import { Component } from "@angular/core";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-header',
|
selector: 'app-header',
|
||||||
templateUrl: './header.component.html',
|
templateUrl: './header.component.html',
|
||||||
styleUrls: ['./header.component.scss']
|
styleUrls: ['./header.component.scss']
|
||||||
})
|
})
|
||||||
export class HeaderComponent {
|
export class HeaderComponent {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@ package org.takiguchi.cerberus.cerberusapp.controller;
|
|||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.takiguchi.cerberus.cerberusapp.model.Application;
|
import org.takiguchi.cerberus.cerberusapp.model.Application;
|
||||||
|
import org.takiguchi.cerberus.cerberusapp.model.ApplicationStatus;
|
||||||
import org.takiguchi.cerberus.cerberusapp.model.ServiceStatus;
|
import org.takiguchi.cerberus.cerberusapp.model.ServiceStatus;
|
||||||
import org.takiguchi.cerberus.cerberusapp.service.ApplicationService;
|
import org.takiguchi.cerberus.cerberusapp.service.ApplicationService;
|
||||||
|
|
||||||
@@ -37,6 +38,7 @@ public class ApplicationController {
|
|||||||
.withName(application.getName())
|
.withName(application.getName())
|
||||||
.withServiceName(application.getServiceName())
|
.withServiceName(application.getServiceName())
|
||||||
.withServiceType(application.getServiceType())
|
.withServiceType(application.getServiceType())
|
||||||
|
.withImage(application.getImage())
|
||||||
.build();
|
.build();
|
||||||
return service.add(applicationToAdd);
|
return service.add(applicationToAdd);
|
||||||
}
|
}
|
||||||
@@ -80,4 +82,9 @@ public class ApplicationController {
|
|||||||
public void restart(@PathVariable("applicationId") UUID applicationId) {
|
public void restart(@PathVariable("applicationId") UUID applicationId) {
|
||||||
service.restart(applicationId);
|
service.restart(applicationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/status")
|
||||||
|
public List<ApplicationStatus> getAllApplicationStatus() {
|
||||||
|
return service.checkAllStatus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,16 +9,18 @@ public class Application {
|
|||||||
/** The technical service name, like a docker container name or a system V service name. */
|
/** The technical service name, like a docker container name or a system V service name. */
|
||||||
private final String serviceName;
|
private final String serviceName;
|
||||||
private final ServiceType serviceType;
|
private final ServiceType serviceType;
|
||||||
|
private final String image;
|
||||||
|
|
||||||
public static Builder anApplication() {
|
public static Builder anApplication() {
|
||||||
return new Builder();
|
return new Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Application(UUID id, String name, String serviceName, ServiceType serviceType) {
|
private Application(UUID id, String name, String serviceName, ServiceType serviceType, String image) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.serviceName = serviceName;
|
this.serviceName = serviceName;
|
||||||
this.serviceType = serviceType;
|
this.serviceType = serviceType;
|
||||||
|
this.image = image;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
@@ -37,11 +39,16 @@ public class Application {
|
|||||||
return serviceType;
|
return serviceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getImage() {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
private UUID id;
|
private UUID id;
|
||||||
private String name;
|
private String name;
|
||||||
private String serviceName;
|
private String serviceName;
|
||||||
private ServiceType serviceType;
|
private ServiceType serviceType;
|
||||||
|
private String image;
|
||||||
|
|
||||||
private Builder() {
|
private Builder() {
|
||||||
}
|
}
|
||||||
@@ -66,8 +73,13 @@ public class Application {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder withImage(String image) {
|
||||||
|
this.image = image;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Application build() {
|
public Application build() {
|
||||||
return new Application(id, name, serviceName, serviceType);
|
return new Application(id, name, serviceName, serviceType, image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package org.takiguchi.cerberus.cerberusapp.model;
|
||||||
|
|
||||||
|
public class ApplicationStatus {
|
||||||
|
private final Application application;
|
||||||
|
private final ServiceStatus status;
|
||||||
|
|
||||||
|
public static Builder anApplicationStatus() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicationStatus(Application application, ServiceStatus status) {
|
||||||
|
this.application = application;
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Application getApplication() {
|
||||||
|
return application;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServiceStatus getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
private Application application;
|
||||||
|
private ServiceStatus status;
|
||||||
|
|
||||||
|
private Builder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder withApplication(Application application) {
|
||||||
|
this.application = application;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder withStatus(ServiceStatus status) {
|
||||||
|
this.status = status;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicationStatus build() {
|
||||||
|
return new ApplicationStatus(application, status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ public class ApplicationEntityMapper {
|
|||||||
.withName(entity.getName())
|
.withName(entity.getName())
|
||||||
.withServiceName(entity.getServiceName())
|
.withServiceName(entity.getServiceName())
|
||||||
.withServiceType(entity.getServiceType())
|
.withServiceType(entity.getServiceType())
|
||||||
|
.withImage(entity.getImage())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,7 +24,8 @@ public class ApplicationEntityMapper {
|
|||||||
application.getId(),
|
application.getId(),
|
||||||
application.getName(),
|
application.getName(),
|
||||||
application.getServiceName(),
|
application.getServiceName(),
|
||||||
application.getServiceType()
|
application.getServiceType(),
|
||||||
|
application.getImage()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
package org.takiguchi.cerberus.cerberusapp.persistence.model;
|
package org.takiguchi.cerberus.cerberusapp.persistence.model;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonView;
|
|
||||||
import org.takiguchi.cerberus.cerberusapp.model.ServiceType;
|
import org.takiguchi.cerberus.cerberusapp.model.ServiceType;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static javax.persistence.EnumType.ORDINAL;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "application")
|
@Table(name = "application")
|
||||||
public class ApplicationEntity {
|
public class ApplicationEntity {
|
||||||
@@ -18,15 +15,17 @@ public class ApplicationEntity {
|
|||||||
private String serviceName;
|
private String serviceName;
|
||||||
@Enumerated
|
@Enumerated
|
||||||
private ServiceType serviceType;
|
private ServiceType serviceType;
|
||||||
|
private String image;
|
||||||
|
|
||||||
public ApplicationEntity() {
|
public ApplicationEntity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationEntity(UUID id, String name, String serviceName, ServiceType serviceType) {
|
public ApplicationEntity(UUID id, String name, String serviceName, ServiceType serviceType, String image) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.serviceName = serviceName;
|
this.serviceName = serviceName;
|
||||||
this.serviceType = serviceType;
|
this.serviceType = serviceType;
|
||||||
|
this.image = image;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
@@ -57,6 +56,14 @@ public class ApplicationEntity {
|
|||||||
return serviceType;
|
return serviceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getImage() {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImage(String image) {
|
||||||
|
this.image = image;
|
||||||
|
}
|
||||||
|
|
||||||
public void setServiceType(ServiceType serviceType) {
|
public void setServiceType(ServiceType serviceType) {
|
||||||
this.serviceType = serviceType;
|
this.serviceType = serviceType;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package org.takiguchi.cerberus.cerberusapp.service;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.takiguchi.cerberus.cerberusapp.exception.NotFoundException;
|
import org.takiguchi.cerberus.cerberusapp.exception.NotFoundException;
|
||||||
import org.takiguchi.cerberus.cerberusapp.model.Application;
|
import org.takiguchi.cerberus.cerberusapp.model.Application;
|
||||||
|
import org.takiguchi.cerberus.cerberusapp.model.ApplicationStatus;
|
||||||
import org.takiguchi.cerberus.cerberusapp.model.ServiceStatus;
|
import org.takiguchi.cerberus.cerberusapp.model.ServiceStatus;
|
||||||
import org.takiguchi.cerberus.cerberusapp.service.servicemanager.ServiceManagerProvider;
|
import org.takiguchi.cerberus.cerberusapp.service.servicemanager.ServiceManagerProvider;
|
||||||
import org.takiguchi.cerberus.cerberusapp.service.validator.ApplicationValidator;
|
import org.takiguchi.cerberus.cerberusapp.service.validator.ApplicationValidator;
|
||||||
@@ -10,8 +11,10 @@ import org.takiguchi.cerberus.cerberusapp.service.validator.ApplicationValidator
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.takiguchi.cerberus.cerberusapp.model.Application.anApplication;
|
import static org.takiguchi.cerberus.cerberusapp.model.Application.anApplication;
|
||||||
|
import static org.takiguchi.cerberus.cerberusapp.model.ApplicationStatus.anApplicationStatus;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ApplicationService {
|
public class ApplicationService {
|
||||||
@@ -94,4 +97,16 @@ public class ApplicationService {
|
|||||||
NotFoundException::new
|
NotFoundException::new
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ApplicationStatus> checkAllStatus() {
|
||||||
|
return getAll().stream()
|
||||||
|
.map(application -> {
|
||||||
|
ServiceStatus status = checkStatus(application.getId());
|
||||||
|
return anApplicationStatus()
|
||||||
|
.withApplication(application)
|
||||||
|
.withStatus(status)
|
||||||
|
.build();
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,5 +5,6 @@ CREATE TABLE IF NOT EXISTS application (
|
|||||||
name VARCHAR NOT NULL,
|
name VARCHAR NOT NULL,
|
||||||
service_name VARCHAR NOT NULL,
|
service_name VARCHAR NOT NULL,
|
||||||
service_type SMALLINT NOT NULL,
|
service_type SMALLINT NOT NULL,
|
||||||
|
image VARCHAR NOT NULL,
|
||||||
CONSTRAINT application_pk PRIMARY KEY (id)
|
CONSTRAINT application_pk PRIMARY KEY (id)
|
||||||
);
|
);
|
||||||
Reference in New Issue
Block a user