Futuro Prometedor: La Cantera Turca
Turquía no solo cuenta con estrellas consolidadas, sino también con una nueva generación lista para brillar. Explora el talento emergente que promete revolucionar el fútbol turco:
<|repo_name|>qianyongzhi/MicroProfile-Frontend<|file_sep|>/src/app/services/crud.service.ts
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class CrudService {
constructor(private http: HttpClient) { }
get(endpoint: string): Observable {
return this.http.get(endpoint);
}
getById(endpoint: string, id: number): Observable {
return this.http.get(`${endpoint}/${id}`);
}
post(endpoint: string, body: any): Observable {
return this.http.post(endpoint, body);
}
put(endpoint: string, body: any): Observable {
return this.http.put(endpoint, body);
}
delete(endpoint: string): Observable {
return this.http.delete(endpoint);
}
}
<|repo_name|>qianyongzhi/MicroProfile-Frontend<|file_sep|>/src/app/components/health-check/health-check.component.ts
import { Component } from '@angular/core';
import { CrudService } from '../../services/crud.service';
@Component({
selector: 'app-health-check',
templateUrl: './health-check.component.html',
styleUrls: ['./health-check.component.scss']
})
export class HealthCheckComponent {
public healthInfo = null;
constructor(private crudService: CrudService) {
this.loadHealthInfo();
}
private loadHealthInfo() {
this.crudService.get('/health').subscribe(data => {
this.healthInfo = data[0];
console.log('Health check status is ', this.healthInfo.status);
});
}
}
<|file_sep|># MicroProfile-Frontend
## Prerequisites
- [Node.js](https://nodejs.org/en/download/)
- [Angular CLI](https://cli.angular.io/)
- [MicroProfile-Health](https://github.com/qianyongzhi/MicroProfile-Health) (Backend API)
## Setup
1. Install Angular CLI.
bash
npm install -g @angular/cli
1. Clone the repository.
bash
git clone https://github.com/qianyongzhi/MicroProfile-Frontend.git
1. Install the dependencies.
bash
npm install
## Run
Start the frontend.
bash
ng serve --open
Visit [http://localhost:4200/](http://localhost:4200/) to see the app running.<|repo_name|>qianyongzhi/MicroProfile-Frontend<|file_sep|>/src/app/components/home/home.component.ts
import { Component } from '@angular/core';
import { CrudService } from '../../services/crud.service';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.scss']
})
export class HomeComponent {
public info = null;
constructor(private crudService: CrudService) {
this.loadInfo();
}
private loadInfo() {
this.crudService.get('/info').subscribe(data => {
this.info = data[0];
console.log('App info is ', this.info.app);
});
}
}
<|repo_name|>qianyongzhi/MicroProfile-Frontend<|file_sep|>/src/app/components/info/info.component.ts
import { Component } from '@angular/core';
import { CrudService } from '../../services/crud.service';
@Component({
selector: 'app-info',
templateUrl: './info.component.html',
styleUrls: ['./info.component.scss']
})
export class InfoComponent {
public info = null;
constructor(private crudService: CrudService) {
this.loadInfo();
}
private loadInfo() {
this.crudService.get('/info').subscribe(data => {
this.info = data[0];
console.log('App info is ', this.info.app);
console.log('Java version is ', this.info.javaVersion);
console.log('Java vendor is ', this.info.javaVendor);
console.log('Java home is ', this.info.javaHome);
console.log('OS name is ', this.info.osName);
console.log('OS version is ', this.info.osVersion);
console.log('OS architecture is ', this.info.osArch);
console.log('OS family is ', this.info.osFamily);
console.log('Server port is ', this.info.serverPort);
console.log('Server context path is ', this.info.serverContextPath);
console.log('Server servlet context path is ', this.info.serverServletContextPath);
console.log('Server name is ', this.info.serverName);
console.log('Server host name is ', this.info.serverHostName);
console.log('Server address is ', this.info.serverAddress);
console.log('Server local address is ', this.info.serverLocalAddress);
console.log('Server local host name is ', this.info.serverLocalHostName);
console.log('Server local port is ', this.info.serverLocalPort);
console.log('Server application name is ', this.info.serverApplicationName);
const buildTimestamp = new Date(this.info.buildTimestamp * 1000).toLocaleString();
const gitCommit = `git rev-parse HEAD`.replace(/n$/, '').split('n')[0];
const gitCommitShort = `git rev-parse --short HEAD`.replace(/n$/, '').split('n')[0];
const gitBranch = `git branch | grep \* | cut -d' ' -f2`.replace(/n$/, '').split('n')[0];
const gitChanges = `git status --porcelain`.replace(/n$/, '').split('n');
if (this.info.buildTimestamp && gitCommit && gitBranch) {
if (gitChanges.length > 0) {
this.info.buildStatus = 'Modified';
} else if (this.info.buildTimestamp === parseInt(gitCommit.substring(0, gitCommit.length - gitCommitShort.length), null)) {
this.info.buildStatus = 'Clean';
} else {
this.info.buildStatus = 'Unknown';
}
this.info.buildTimestampReadable = buildTimestamp;
this.info.gitCommit = gitCommit;
this.info.gitBranch = gitBranch;
this.info.gitChangesCount = gitChanges.length;
if (this.info.gitChangesCount > MAX_GIT_CHANGES_COUNT) {
this.gitChanges = [...gitChanges.slice(0, MAX_GIT_CHANGES_COUNT), `${this.info.gitChangesCount - MAX_GIT_CHANGES_COUNT} more...`];
} else {
this.gitChanges = [...gitChanges];
}
const configFilePaths = [
process.env['HOME'] + '/.config/maven/settings.xml',
process.env['HOME'] + '/etc/maven/settings.xml',
process.env['HOME'] + '/maven/settings.xml',
process.env['HOME'] + '/settings.xml',
process.env['HOME'] + '/settings-maven.xml'
];
for (const configFilePath of configFilePaths) {
if (fs.existsSync(configFilePath)) {
fs.readFile(configFilePath, function(err, data) {
if (!err) {
const settingsXml = new xmlParser().parseFromString(data.toString());
const profilesNodeList = settingsXml.getElementsByTagName('profiles');
if (profilesNodeList.length > 0) {
const profilesNode = profilesNodeList[0];
if (profilesNode.hasChildNodes()) {
const profileNodeList = profilesNode.childNodes;
for (const profileNode of profileNodeList) {
if (profileNode.nodeType === Node.ELEMENT_NODE && profileNode.nodeName === 'profile') {
const activeProfilesList = profileNode.getElementsByTagName('activeByDefault');
if (activeProfilesList.length > 0 && activeProfilesList[0].textContent === 'true') {
let id;
let properties;
let propertyList;
let propertyNodeList;
let propertyValue;
const idNodeList = profileNode.getElementsByTagName('id');
if (idNodeList.length > 0) {
id = idNodeList[0].textContent;
}
const propertiesNodeList = profileNode.getElementsByTagName('properties');
if (propertiesNodeList.length > 0 && propertiesNodeList[0].hasChildNodes()) {
properties = {};
propertyList = propertiesNodeList[0].childNodes;
for (const property of propertyList) {
if (property.nodeType === Node.ELEMENT_NODE && property.nodeName === 'property') {
propertyValue = property.textContent;
const nameAttributeNodes = property.attributes;
for (const nameAttribute of nameAttributeNodes) {
if (nameAttribute.nodeName === 'name') {
properties[nameAttribute.nodeValue] = propertyValue;
}
}
}
}
}
if (id !== undefined && properties !== undefined) {
let mavenBuildTimestampString;
let mavenBuildTimestampReadable;
try {
mavenBuildTimestampString = properties['build.timestamp'];
mavenBuildTimestampReadable =
new Date(parseInt(mavenBuildTimestampString.substring(0, mavenBuildTimestampString.length - mavenBuildTimestampShort.length), null) * 1000)
.toLocaleString();
mavenBuildTimestampShort =
mavenBuildTimestampString.substring(mavenBuildTimestampString.length - mavenBuildTimestampShort.length);
if (mavenBuildTimestampString !== undefined &&
mavenBuildTimestampReadable !== undefined &&
mavenBuildTimestampShort !== undefined &&
mavenBuildTimestampString === mavenBuildTimestampShort.substring(0,
mavenBuildTimestampShort.length)) {
this.mvnGitCompare =
new Date(parseInt(mvnGitCompare.substring(0,
mvnGitCompare.length - mvnGitCompareShort.length), null) * 1000)
.toLocaleString();
this.mvnGitCompareShort =
mvnGitCompare.substring(mvnGitCompare.length - mvnGitCompareShort.length);
if (
gitCommit.substring(0,
gitCommit.length - gitCommitShort.length)
.toLowerCase() ===
mvnGitCompare.substring(0,
mvnGitCompare.length - mvnGitCompareShort.length).toLowerCase()
) {
if (
gitCommit.substring(gitCommit.length - gitCommitShort.length)
.toLowerCase() === mvnGitCompare.substring(mvnGitCompare.length -
mvnGitCompareShort.length).toLowerCase()
) {
if (
mvnBuildTimestampString.toLowerCase() === mavenBuildTimestampString.toLowerCase()
) {
this.mvnStatus =
buildStatus === 'Clean' ? 'Clean' : buildStatus;
} else {
this.mvnStatus =
buildStatus === 'Clean' ? 'Rebuild Required' : buildStatus;