Initial Commit

This commit is contained in:
RakVhalate 2022-12-28 23:08:26 +05:00
commit a1f4abca0f
37 changed files with 11872 additions and 0 deletions

16
.editorconfig Normal file
View File

@ -0,0 +1,16 @@
# Editor configuration, see https://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.ts]
quote_type = single
[*.md]
max_line_length = off
trim_trailing_whitespace = false

42
.gitignore vendored Normal file
View File

@ -0,0 +1,42 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# Compiled output
/dist
/tmp
/out-tsc
/bazel-out
# Node
/node_modules
npm-debug.log
yarn-error.log
# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*
# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings
# System files
.DS_Store
Thumbs.db

4
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,4 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
"recommendations": ["angular.ng-template"]
}

20
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,20 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "ng serve",
"type": "pwa-chrome",
"request": "launch",
"preLaunchTask": "npm: start",
"url": "http://localhost:4200/"
},
{
"name": "ng test",
"type": "chrome",
"request": "launch",
"preLaunchTask": "npm: test",
"url": "http://localhost:9876/debug.html"
}
]
}

42
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,42 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "start",
"isBackground": true,
"problemMatcher": {
"owner": "typescript",
"pattern": "$tsc",
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "(.*?)"
},
"endsPattern": {
"regexp": "bundle generation complete"
}
}
}
},
{
"type": "npm",
"script": "test",
"isBackground": true,
"problemMatcher": {
"owner": "typescript",
"pattern": "$tsc",
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "(.*?)"
},
"endsPattern": {
"regexp": "bundle generation complete"
}
}
}
}
]
}

27
README.md Normal file
View File

@ -0,0 +1,27 @@
# ConsulParser
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 15.0.4.
## Development server
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files.
## Code scaffolding
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
## Build
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
## Running unit tests
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
## Running end-to-end tests
Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.

104
angular.json Normal file
View File

@ -0,0 +1,104 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"ConsulParser": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/consul-parser",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": [
"zone.js"
],
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "ConsulParser:build:production"
},
"development": {
"browserTarget": "ConsulParser:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "ConsulParser:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": [
"zone.js",
"zone.js/testing"
],
"tsConfig": "tsconfig.spec.json",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"scripts": []
}
}
}
}
}
}

11230
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

38
package.json Normal file
View File

@ -0,0 +1,38 @@
{
"name": "consul-parser",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"private": true,
"dependencies": {
"@angular/animations": "^15.0.0",
"@angular/common": "^15.0.0",
"@angular/compiler": "^15.0.0",
"@angular/core": "^15.0.0",
"@angular/forms": "^15.0.0",
"@angular/platform-browser": "^15.0.0",
"@angular/platform-browser-dynamic": "^15.0.0",
"@angular/router": "^15.0.0",
"rxjs": "~7.5.0",
"tslib": "^2.3.0",
"zone.js": "~0.12.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^15.0.4",
"@angular/cli": "~15.0.4",
"@angular/compiler-cli": "^15.0.0",
"@types/jasmine": "~4.3.0",
"jasmine-core": "~4.5.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.0.0",
"typescript": "~4.8.2"
}
}

View File

@ -0,0 +1 @@
<p>consul works!</p>

View File

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ConsulComponent } from './consul.component';
describe('ConsulComponent', () => {
let component: ConsulComponent;
let fixture: ComponentFixture<ConsulComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ConsulComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(ConsulComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,10 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-consul',
templateUrl: './consul.component.html',
styleUrls: ['./consul.component.scss']
})
export class ConsulComponent {
}

View File

@ -0,0 +1,3 @@
import { IConsulObject } from "./JsonObject"
export var SampleResponse = '{"consul-server":{"ID":"Wfrning!","Service":"Dummy-Response ","Tags":["infra","vdk2ch","consul-server","ssl"],"Meta":{},"Port":8500,"Address":"consul.vdk2ch.ru","Weights":{"Passing":1,"Warning":1},"EnableTagOverride":false,"Datacenter":"vdk2ch"},"drone-server":{"ID":"drone-server","Service":"drone-server","Tags":["infra","vdk2ch","drone-server","ssl"],"Meta":{},"Port":38080,"Address":"drone.vdk2ch.ru","Weights":{"Passing":1,"Warning":1},"EnableTagOverride":false,"Datacenter":"vdk2ch"},"dvach-back-api":{"ID":"dvach-back-api","Service":"dvach-back-api","Tags":["board","vdk2ch","back-api","api","ssl"],"Meta":{},"Port":5000,"Address":"api.vdk2ch.ru","Weights":{"Passing":1,"Warning":1},"EnableTagOverride":false,"Datacenter":"vdk2ch"},"dvach-front-angular":{"ID":"dvach-front-angular","Service":"dvach-front-angular","Tags":["board","vdk2ch","angular","front","ssl"],"Meta":{},"Port":4200,"Address":"board.vdk2ch.ru","Weights":{"Passing":1,"Warning":1},"EnableTagOverride":false,"Datacenter":"vdk2ch"},"gitea":{"ID":"gitea","Service":"gitea","Tags":["infra","vdk2ch","git","ssl"],"Meta":{},"Port":3000,"Address":"git.vdk2ch.ru","Weights":{"Passing":1,"Warning":1},"EnableTagOverride":false,"Datacenter":"vdk2ch"},"graylog":{"ID":"graylog","Service":"graylog","Tags":["infra","vdk2ch","graylog","ssl"],"Meta":{},"Port":9000,"Address":"graylog.vdk2ch.ru","Weights":{"Passing":1,"Warning":1},"EnableTagOverride":false,"Datacenter":"vdk2ch"},"minio-api":{"ID":"minio-api","Service":"minio-api","Tags":["infra","vdk2ch","minio-api","static","ssl"],"Meta":{},"Port":15555,"Address":"static.vdk2ch.ru","Weights":{"Passing":1,"Warning":1},"EnableTagOverride":false,"Datacenter":"vdk2ch"},"minio-consule":{"ID":"minio-consule","Service":"minio-console","Tags":["infra","vdk2ch","minio-consol","ssl"],"Meta":{},"Port":15556,"Address":"minio.vdk2ch.ru","Weights":{"Passing":1,"Warning":1},"EnableTagOverride":false,"Datacenter":"vdk2ch"}}'

View File

@ -0,0 +1,17 @@
export interface IConsulObject
{
ID: string,
Service: string,
Tags: string[],
Meta: {
},
Port: number,
Address: string,
Weights: {
Passing: number,
Warning: number
},
EnableTagOverride: boolean,
Datacenter: string
}

View File

@ -0,0 +1,6 @@
<button (click)="list()">Листануть</button>
<ul>
<li *ngFor="let element of responseArray">
<app-single-objcet [object]="element"></app-single-objcet>
</li>
</ul>

View File

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MainPageComponent } from './main-page.component';
describe('MainPageComponent', () => {
let component: MainPageComponent;
let fixture: ComponentFixture<MainPageComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ MainPageComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(MainPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,42 @@
import { Component } from '@angular/core';
import { IConsulObject } from 'src/app/Models/JsonObject';
import { HttpClient } from '@angular/common/http'
import * as DummyResponse from '../../Models/DummyResponse';
@Component({
selector: 'app-main-page',
templateUrl: './main-page.component.html',
styleUrls: ['./main-page.component.scss']
})
export class MainPageComponent {
constructor(private http: HttpClient) {}
response: any = JSON.parse(DummyResponse.SampleResponse);
keys: string[] = [];
responseArray: IConsulObject[] = [];
list(){
this.responseArray = []
this.getList().subscribe(response => {
this.response = response
this.keys= Object.keys(this.response);
this.keys.forEach(element => {
var toPush = this.response[element];
this.responseArray.push(toPush);
});
})
}
getList(){
var response = this.http.get<any>("https://consul.vdk2ch.ru/v1/agent/services")
console.log(response)
return response;
}
ngOnInit(): void {
}
}

View File

@ -0,0 +1,14 @@
<details>
<summary>{{object.ID}}</summary>
<div>
<h4>Service: {{object.Service}},</h4>
<h4>Tags: {{object.Tags}},</h4>
<h4>Port: {{object.Port}},</h4>
<h4>Address: {{object.Address}},</h4>
<h4>Weights: </h4>
<h6>Passing: {{object.Weights.Passing}},</h6>
<h6>Warning: {{object.Weights.Warning}}</h6>
<h4>EnableTagOverride: {{object.EnableTagOverride}}</h4>
<h4>Datacenter: {{object.Datacenter}}</h4>
</div>
</details>

View File

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SingleObjcetComponent } from './single-objcet.component';
describe('SingleObjcetComponent', () => {
let component: SingleObjcetComponent;
let fixture: ComponentFixture<SingleObjcetComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ SingleObjcetComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(SingleObjcetComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,16 @@
import { Component, Input, OnInit } from '@angular/core';
import { IConsulObject } from 'src/app/Models/JsonObject';
@Component({
selector: 'app-single-objcet',
templateUrl: './single-objcet.component.html',
styleUrls: ['./single-objcet.component.scss']
})
export class SingleObjcetComponent implements OnInit {
@Input() object: IConsulObject;
ngOnInit(): void {
}
}

View File

@ -0,0 +1,13 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { MainPageComponent } from './Pages/main-page/main-page.component';
const routes: Routes = [
{ path: 'benis', component: MainPageComponent },
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }

View File

@ -0,0 +1,6 @@
<nav>
<ul>
<li><a routerLink="/benis" routerLinkActive="active" ariaCurrentWhenActive="page">Отобразить жсон</a></li>
</ul>
</nav>
<router-outlet></router-outlet>

View File

View File

@ -0,0 +1,35 @@
import { TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [
RouterTestingModule
],
declarations: [
AppComponent
],
}).compileComponents();
});
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app).toBeTruthy();
});
it(`should have as title 'ConsulParser'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app.title).toEqual('ConsulParser');
});
it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('.content span')?.textContent).toContain('ConsulParser app is running!');
});
});

10
src/app/app.component.ts Normal file
View File

@ -0,0 +1,10 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
title = 'ConsulParser';
}

24
src/app/app.module.ts Normal file
View File

@ -0,0 +1,24 @@
import { HttpClientModule } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { MainPageComponent } from './Pages/main-page/main-page.component';
import { SingleObjcetComponent } from './Pages/single-object/single-objcet.component';
@NgModule({
declarations: [
AppComponent,
MainPageComponent,
SingleObjcetComponent
],
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

0
src/assets/.gitkeep Normal file
View File

BIN
src/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 948 B

13
src/index.html Normal file
View File

@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>ConsulParser</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root></app-root>
</body>
</html>

7
src/main.ts Normal file
View File

@ -0,0 +1,7 @@
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.error(err));

1
src/styles.scss Normal file
View File

@ -0,0 +1 @@
/* You can add global styles to this file, and also import other style files */

14
tsconfig.app.json Normal file
View File

@ -0,0 +1,14 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
},
"files": [
"src/main.ts"
],
"include": [
"src/**/*.d.ts"
]
}

34
tsconfig.json Normal file
View File

@ -0,0 +1,34 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "ES2022",
"module": "ES2022",
"strictPropertyInitialization": false,
"useDefineForClassFields": false,
"lib": [
"ES2022",
"dom"
]
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}

14
tsconfig.spec.json Normal file
View File

@ -0,0 +1,14 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/spec",
"types": [
"jasmine"
]
},
"include": [
"src/**/*.spec.ts",
"src/**/*.d.ts"
]
}