Skip to content

Commit

Permalink
Merge pull request #563 from juliensadaoui/disable-jhcc-support
Browse files Browse the repository at this point in the history
Disable JHipster Control Center Support
  • Loading branch information
juliensadaoui authored Oct 28, 2023
2 parents 623c99b + c3a41d0 commit 4505b53
Show file tree
Hide file tree
Showing 57 changed files with 2,280 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .yo-rc.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@
"testFrameworks": [],
"useSass": true,
"websocket": false,
"withAdminUi": false
"withAdminUi": true
}
}
4 changes: 2 additions & 2 deletions src/main/resources/config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ eureka:
enabled: true
healthcheck:
enabled: true
fetch-registry: true
register-with-eureka: true
fetch-registry: false
register-with-eureka: false
instance-info-replication-interval-seconds: 10
registry-fetch-interval-seconds: 10
service-url:
Expand Down
16 changes: 16 additions & 0 deletions src/main/webapp/app/admin/admin-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ import { RouterModule } from '@angular/router';
path: 'docs',
loadChildren: () => import('./docs/docs.module').then(m => m.DocsModule),
},
{
path: 'configuration',
loadChildren: () => import('./configuration/configuration.module').then(m => m.ConfigurationModule),
},
{
path: 'health',
loadChildren: () => import('./health/health.module').then(m => m.HealthModule),
},
{
path: 'logs',
loadChildren: () => import('./logs/logs.module').then(m => m.LogsModule),
},
{
path: 'metrics',
loadChildren: () => import('./metrics/metrics.module').then(m => m.MetricsModule),
},
/* jhipster-needle-add-admin-route - JHipster will add admin routes here */
]),
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<div *ngIf="allBeans">
<h2 id="configuration-page-heading" data-cy="configurationPageHeading">Configuration</h2>

<span>Filter (by prefix)</span>
<input type="text" [(ngModel)]="beansFilter" (ngModelChange)="filterAndSortBeans()" class="form-control" />

<h3 id="spring-configuration">Spring configuration</h3>

<table class="table table-striped table-bordered table-responsive d-table" aria-describedby="spring-configuration">
<thead>
<tr jhiSort predicate="prefix" [(ascending)]="beansAscending" (sortChange)="filterAndSortBeans()">
<th jhiSortBy="prefix" scope="col" class="w-40"><span>Prefix</span> <fa-icon icon="sort"></fa-icon></th>
<th scope="col" class="w-60"><span>Properties</span></th>
</tr>
</thead>
<tbody>
<tr *ngFor="let bean of beans">
<td>
<span>{{ bean.prefix }}</span>
</td>
<td>
<div class="row" *ngFor="let property of bean.properties | keyvalue">
<div class="col-md-4">{{ property.key }}</div>
<div class="col-md-8">
<span class="float-end bg-secondary break">{{ property.value | json }}</span>
</div>
</div>
</td>
</tr>
</tbody>
</table>

<div *ngFor="let propertySource of propertySources; let i = index">
<h4 [id]="'property-source-' + i">
<span>{{ propertySource.name }}</span>
</h4>

<table class="table table-sm table-striped table-bordered table-responsive d-table" [attr.aria-describedby]="'property-source-' + i">
<thead>
<tr>
<th scope="col" class="w-40">Property</th>
<th scope="col" class="w-60">Value</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let property of propertySource.properties | keyvalue">
<td class="break">{{ property.key }}</td>
<td class="break">
<span class="float-end bg-secondary break">{{ property.value.value }}</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { of } from 'rxjs';

import { ConfigurationComponent } from './configuration.component';
import { ConfigurationService } from './configuration.service';
import { Bean, PropertySource } from './configuration.model';

describe('ConfigurationComponent', () => {
let comp: ConfigurationComponent;
let fixture: ComponentFixture<ConfigurationComponent>;
let service: ConfigurationService;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
declarations: [ConfigurationComponent],
providers: [ConfigurationService],
})
.overrideTemplate(ConfigurationComponent, '')
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(ConfigurationComponent);
comp = fixture.componentInstance;
service = TestBed.inject(ConfigurationService);
});

describe('OnInit', () => {
it('Should call load all on init', () => {
// GIVEN
const beans: Bean[] = [
{
prefix: 'jhipster',
properties: {
clientApp: {
name: 'jhipsterApp',
},
},
},
];
const propertySources: PropertySource[] = [
{
name: 'server.ports',
properties: {
'local.server.port': {
value: '8080',
},
},
},
];
jest.spyOn(service, 'getBeans').mockReturnValue(of(beans));
jest.spyOn(service, 'getPropertySources').mockReturnValue(of(propertySources));

// WHEN
comp.ngOnInit();

// THEN
expect(service.getBeans).toHaveBeenCalled();
expect(service.getPropertySources).toHaveBeenCalled();
expect(comp.allBeans).toEqual(beans);
expect(comp.beans).toEqual(beans);
expect(comp.propertySources).toEqual(propertySources);
});
});
});
35 changes: 35 additions & 0 deletions src/main/webapp/app/admin/configuration/configuration.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Component, OnInit } from '@angular/core';

import { ConfigurationService } from './configuration.service';
import { Bean, PropertySource } from './configuration.model';

@Component({
selector: 'jhi-configuration',
templateUrl: './configuration.component.html',
})
export class ConfigurationComponent implements OnInit {
allBeans!: Bean[];
beans: Bean[] = [];
beansFilter = '';
beansAscending = true;
propertySources: PropertySource[] = [];

constructor(private configurationService: ConfigurationService) {}

ngOnInit(): void {
this.configurationService.getBeans().subscribe(beans => {
this.allBeans = beans;
this.filterAndSortBeans();
});

this.configurationService.getPropertySources().subscribe(propertySources => (this.propertySources = propertySources));
}

filterAndSortBeans(): void {
const beansAscendingValue = this.beansAscending ? -1 : 1;
const beansAscendingValueReverse = this.beansAscending ? 1 : -1;
this.beans = this.allBeans
.filter(bean => !this.beansFilter || bean.prefix.toLowerCase().includes(this.beansFilter.toLowerCase()))
.sort((a, b) => (a.prefix < b.prefix ? beansAscendingValue : beansAscendingValueReverse));
}
}
40 changes: 40 additions & 0 deletions src/main/webapp/app/admin/configuration/configuration.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
export interface ConfigProps {
contexts: Contexts;
}

export interface Contexts {
[key: string]: Context;
}

export interface Context {
beans: Beans;
parentId?: any;
}

export interface Beans {
[key: string]: Bean;
}

export interface Bean {
prefix: string;
properties: any;
}

export interface Env {
activeProfiles?: string[];
propertySources: PropertySource[];
}

export interface PropertySource {
name: string;
properties: Properties;
}

export interface Properties {
[key: string]: Property;
}

export interface Property {
value: string;
origin?: string;
}
12 changes: 12 additions & 0 deletions src/main/webapp/app/admin/configuration/configuration.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { SharedModule } from 'app/shared/shared.module';

import { ConfigurationComponent } from './configuration.component';
import { configurationRoute } from './configuration.route';

@NgModule({
imports: [SharedModule, RouterModule.forChild([configurationRoute])],
declarations: [ConfigurationComponent],
})
export class ConfigurationModule {}
11 changes: 11 additions & 0 deletions src/main/webapp/app/admin/configuration/configuration.route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Route } from '@angular/router';

import { ConfigurationComponent } from './configuration.component';

export const configurationRoute: Route = {
path: '',
component: ConfigurationComponent,
data: {
pageTitle: 'Configuration',
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { TestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';

import { ConfigurationService } from './configuration.service';
import { Bean, ConfigProps, Env, PropertySource } from './configuration.model';

describe('Logs Service', () => {
let service: ConfigurationService;
let httpMock: HttpTestingController;
let expectedResult: Bean[] | PropertySource[] | null;

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
});

expectedResult = null;
service = TestBed.inject(ConfigurationService);
httpMock = TestBed.inject(HttpTestingController);
});

afterEach(() => {
httpMock.verify();
});

describe('Service methods', () => {
it('should get the config', () => {
const bean: Bean = {
prefix: 'jhipster',
properties: {
clientApp: {
name: 'jhipsterApp',
},
},
};
const configProps: ConfigProps = {
contexts: {
jhipster: {
beans: {
'tech.jhipster.config.JHipsterProperties': bean,
},
},
},
};
service.getBeans().subscribe(received => (expectedResult = received));

const req = httpMock.expectOne({ method: 'GET' });
req.flush(configProps);
expect(expectedResult).toEqual([bean]);
});

it('should get the env', () => {
const propertySources: PropertySource[] = [
{
name: 'server.ports',
properties: {
'local.server.port': {
value: '8080',
},
},
},
];
const env: Env = { propertySources };
service.getPropertySources().subscribe(received => (expectedResult = received));

const req = httpMock.expectOne({ method: 'GET' });
req.flush(env);
expect(expectedResult).toEqual(propertySources);
});
});
});
28 changes: 28 additions & 0 deletions src/main/webapp/app/admin/configuration/configuration.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

import { ApplicationConfigService } from 'app/core/config/application-config.service';
import { Bean, Beans, ConfigProps, Env, PropertySource } from './configuration.model';

@Injectable({ providedIn: 'root' })
export class ConfigurationService {
constructor(private http: HttpClient, private applicationConfigService: ApplicationConfigService) {}

getBeans(): Observable<Bean[]> {
return this.http.get<ConfigProps>(this.applicationConfigService.getEndpointFor('management/configprops')).pipe(
map(configProps =>
Object.values(
Object.values(configProps.contexts)
.map(context => context.beans)
.reduce((allBeans: Beans, contextBeans: Beans) => ({ ...allBeans, ...contextBeans }))
)
)
);
}

getPropertySources(): Observable<PropertySource[]> {
return this.http.get<Env>(this.applicationConfigService.getEndpointFor('management/env')).pipe(map(env => env.propertySources));
}
}
Loading

0 comments on commit 4505b53

Please sign in to comment.