Initial commit
This commit is contained in:
1
src/app/app.component.html
Normal file
1
src/app/app.component.html
Normal file
@@ -0,0 +1 @@
|
||||
<app-layout></app-layout>
|
||||
0
src/app/app.component.scss
Normal file
0
src/app/app.component.scss
Normal file
23
src/app/app.component.spec.ts
Normal file
23
src/app/app.component.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { AppComponent } from './app.component';
|
||||
|
||||
describe('AppComponent', () => {
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [AppComponent],
|
||||
}).compileComponents();
|
||||
});
|
||||
|
||||
it('should create the app', () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.componentInstance;
|
||||
expect(app).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should render title', () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
fixture.detectChanges();
|
||||
const compiled = fixture.nativeElement as HTMLElement;
|
||||
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, DevDisciples.Json.Tools.App');
|
||||
});
|
||||
});
|
||||
13
src/app/app.component.ts
Normal file
13
src/app/app.component.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { RouterOutlet } from '@angular/router';
|
||||
import {LayoutComponent} from "./layout/layout.component";
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
standalone: true,
|
||||
imports: [RouterOutlet, LayoutComponent],
|
||||
templateUrl: './app.component.html',
|
||||
styleUrl: './app.component.scss'
|
||||
})
|
||||
export class AppComponent {
|
||||
}
|
||||
16
src/app/app.config.ts
Normal file
16
src/app/app.config.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import {ApplicationConfig, importProvidersFrom, provideZoneChangeDetection} from '@angular/core';
|
||||
import { provideRouter } from '@angular/router';
|
||||
|
||||
import { routes } from './app.routes';
|
||||
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
|
||||
import {MonacoEditorModule} from "ngx-monaco-editor-v2";
|
||||
import {HttpClientModule, provideHttpClient} from "@angular/common/http";
|
||||
|
||||
export const appConfig: ApplicationConfig = {
|
||||
providers: [
|
||||
provideZoneChangeDetection({ eventCoalescing: true }),
|
||||
provideRouter(routes), provideAnimationsAsync(),
|
||||
importProvidersFrom(MonacoEditorModule.forRoot()),
|
||||
provideHttpClient(),
|
||||
]
|
||||
};
|
||||
14
src/app/app.routes.ts
Normal file
14
src/app/app.routes.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Routes } from '@angular/router';
|
||||
import {HomeComponent} from "./home/home.component";
|
||||
import {BeautifyComponent} from "./beautify/beautify.component";
|
||||
import {UglifyComponent} from "./uglify/uglify.component";
|
||||
import {Json2CsharpComponent} from "./json2csharp/json2-csharp.component";
|
||||
import {JsonPathComponent} from "./json-path/json-path.component";
|
||||
|
||||
export const routes: Routes = [
|
||||
{ path: 'home', component: HomeComponent },
|
||||
{ path: 'beautify', component: BeautifyComponent },
|
||||
{ path: 'uglify', component: UglifyComponent },
|
||||
{ path: 'json2csharp', component: Json2CsharpComponent },
|
||||
{ path: 'jsonpath', component: JsonPathComponent },
|
||||
];
|
||||
8
src/app/beautify/beautify.component.html
Normal file
8
src/app/beautify/beautify.component.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<h1>JSON Beautify</h1>
|
||||
|
||||
<app-input-output [input]="$input.value"
|
||||
[inputOptions]="inputOptions"
|
||||
(onInputChange)="handleInputChange($event)"
|
||||
[output]="output"
|
||||
[outputOptions]="outputOptions">
|
||||
</app-input-output>
|
||||
0
src/app/beautify/beautify.component.scss
Normal file
0
src/app/beautify/beautify.component.scss
Normal file
23
src/app/beautify/beautify.component.spec.ts
Normal file
23
src/app/beautify/beautify.component.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { BeautifyComponent } from './beautify.component';
|
||||
|
||||
describe('BeautifyComponent', () => {
|
||||
let component: BeautifyComponent;
|
||||
let fixture: ComponentFixture<BeautifyComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [BeautifyComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(BeautifyComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
66
src/app/beautify/beautify.component.ts
Normal file
66
src/app/beautify/beautify.component.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {EditorComponent} from "ngx-monaco-editor-v2";
|
||||
import {FormsModule} from "@angular/forms";
|
||||
import {InputOutputComponent} from "../input-output/input-output.component";
|
||||
import {JsonTransformService} from "../json-transform.service";
|
||||
import {
|
||||
DebounceTime,
|
||||
GenerateDefaultJsonObjectString,
|
||||
MonacoJsonConfig,
|
||||
ReadOnlyMonacoJsonConfig
|
||||
} from "../defaults";
|
||||
import {BehaviorSubject, debounceTime} from "rxjs";
|
||||
|
||||
@Component({
|
||||
selector: 'app-beautify',
|
||||
standalone: true,
|
||||
imports: [
|
||||
EditorComponent,
|
||||
FormsModule,
|
||||
InputOutputComponent
|
||||
],
|
||||
templateUrl: './beautify.component.html',
|
||||
styleUrl: './beautify.component.scss'
|
||||
})
|
||||
export class BeautifyComponent implements OnInit {
|
||||
// input: string = ;
|
||||
$input: BehaviorSubject<string> = new BehaviorSubject<string>(GenerateDefaultJsonObjectString());
|
||||
inputOptions = MonacoJsonConfig;
|
||||
output: string = GenerateDefaultJsonObjectString(2);
|
||||
outputOptions = ReadOnlyMonacoJsonConfig;
|
||||
// error: string = "";
|
||||
|
||||
constructor(private service: JsonTransformService) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.$input
|
||||
.pipe(debounceTime(DebounceTime))
|
||||
.subscribe(input => {
|
||||
this.update(input)
|
||||
});
|
||||
}
|
||||
|
||||
update(input: string): void {
|
||||
this.service
|
||||
.beautify(input)
|
||||
.subscribe({
|
||||
next: response => {
|
||||
console.log(response);
|
||||
this.output = response.body.result;
|
||||
},
|
||||
error: response => {
|
||||
console.log(response)
|
||||
if (response.status === 499) {
|
||||
this.output = response.error.detail;
|
||||
console.log(response.error.detail);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
handleInputChange($event: any): void {
|
||||
console.log($event);
|
||||
this.$input.next($event);
|
||||
}
|
||||
}
|
||||
26
src/app/defaults.ts
Normal file
26
src/app/defaults.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
export const MonacoJsonConfig = {
|
||||
theme: 'vs-dark',
|
||||
language: 'json',
|
||||
readOnly: false,
|
||||
automaticLayout: true
|
||||
};
|
||||
|
||||
export const ReadOnlyMonacoJsonConfig = {
|
||||
theme: 'vs-dark',
|
||||
language: 'json',
|
||||
readOnly: true,
|
||||
automaticLayout: true
|
||||
};
|
||||
|
||||
export const ReadOnlyMonacoCSharpConfig = {
|
||||
theme: 'vs-dark',
|
||||
language: 'csharp',
|
||||
readOnly: false,
|
||||
automaticLayout: true
|
||||
};
|
||||
|
||||
export const GenerateDefaultJsonObjectString = (space: number = 0): string => {
|
||||
return JSON.stringify({first_name: "John", last_name: "Doe"}, null, space);
|
||||
}
|
||||
|
||||
export const DebounceTime: number = 750;
|
||||
1
src/app/home/home.component.html
Normal file
1
src/app/home/home.component.html
Normal file
@@ -0,0 +1 @@
|
||||
<p>home works!</p>
|
||||
0
src/app/home/home.component.scss
Normal file
0
src/app/home/home.component.scss
Normal file
23
src/app/home/home.component.spec.ts
Normal file
23
src/app/home/home.component.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { HomeComponent } from './home.component';
|
||||
|
||||
describe('HomeComponent', () => {
|
||||
let component: HomeComponent;
|
||||
let fixture: ComponentFixture<HomeComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [HomeComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(HomeComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
12
src/app/home/home.component.ts
Normal file
12
src/app/home/home.component.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
standalone: true,
|
||||
imports: [],
|
||||
templateUrl: './home.component.html',
|
||||
styleUrl: './home.component.scss'
|
||||
})
|
||||
export class HomeComponent {
|
||||
|
||||
}
|
||||
15
src/app/input-output/input-output.component.html
Normal file
15
src/app/input-output/input-output.component.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<main>
|
||||
<section id="left">
|
||||
<h3>Input</h3>
|
||||
<ngx-monaco-editor (ngModelChange)="handleInputChange($event)"
|
||||
[options]="inputOptions"
|
||||
[(ngModel)]="input">
|
||||
</ngx-monaco-editor>
|
||||
</section>
|
||||
<section id="right">
|
||||
<h3>Output</h3>
|
||||
<ngx-monaco-editor [options]="outputOptions"
|
||||
[(ngModel)]="output">
|
||||
</ngx-monaco-editor>
|
||||
</section>
|
||||
</main>
|
||||
19
src/app/input-output/input-output.component.scss
Normal file
19
src/app/input-output/input-output.component.scss
Normal file
@@ -0,0 +1,19 @@
|
||||
main {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
|
||||
#left {
|
||||
flex: 0.5;
|
||||
}
|
||||
|
||||
#right {
|
||||
flex: 0.5;
|
||||
}
|
||||
|
||||
ngx-monaco-editor {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
23
src/app/input-output/input-output.component.spec.ts
Normal file
23
src/app/input-output/input-output.component.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { InputOutputComponent } from './input-output.component';
|
||||
|
||||
describe('InputOutputComponent', () => {
|
||||
let component: InputOutputComponent;
|
||||
let fixture: ComponentFixture<InputOutputComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [InputOutputComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(InputOutputComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
25
src/app/input-output/input-output.component.ts
Normal file
25
src/app/input-output/input-output.component.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import {Component, EventEmitter, Input, Output} from '@angular/core';
|
||||
import {EditorComponent} from "ngx-monaco-editor-v2";
|
||||
import {FormsModule} from "@angular/forms";
|
||||
|
||||
@Component({
|
||||
selector: 'app-input-output',
|
||||
standalone: true,
|
||||
imports: [
|
||||
EditorComponent,
|
||||
FormsModule
|
||||
],
|
||||
templateUrl: './input-output.component.html',
|
||||
styleUrl: './input-output.component.scss'
|
||||
})
|
||||
export class InputOutputComponent {
|
||||
@Input() input!: string;
|
||||
@Input() inputOptions!: any;
|
||||
@Output() onInputChange = new EventEmitter();
|
||||
@Input() output!: string;
|
||||
@Input() outputOptions!: any;
|
||||
|
||||
handleInputChange($event: string) {
|
||||
this.onInputChange.emit($event);
|
||||
}
|
||||
}
|
||||
13
src/app/json-path/json-path.component.html
Normal file
13
src/app/json-path/json-path.component.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<h1>JSON to C#</h1>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>Path</mat-label>
|
||||
<input matInput placeholder="$.*" [value]="$path.value" (input)="handlePathChange($event)">
|
||||
</mat-form-field>
|
||||
|
||||
<app-input-output [input]="$input.value"
|
||||
[inputOptions]="inputOptions"
|
||||
(onInputChange)="handleInputChange($event)"
|
||||
[output]="output"
|
||||
[outputOptions]="outputOptions">
|
||||
</app-input-output>
|
||||
3
src/app/json-path/json-path.component.scss
Normal file
3
src/app/json-path/json-path.component.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
mat-form-field {
|
||||
width: 100%;
|
||||
}
|
||||
23
src/app/json-path/json-path.component.spec.ts
Normal file
23
src/app/json-path/json-path.component.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { JsonPathComponent } from './json-path.component';
|
||||
|
||||
describe('JsonPathComponent', () => {
|
||||
let component: JsonPathComponent;
|
||||
let fixture: ComponentFixture<JsonPathComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [JsonPathComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(JsonPathComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
69
src/app/json-path/json-path.component.ts
Normal file
69
src/app/json-path/json-path.component.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {InputOutputComponent} from "../input-output/input-output.component";
|
||||
import {DebounceTime, GenerateDefaultJsonObjectString, MonacoJsonConfig, ReadOnlyMonacoCSharpConfig} from "../defaults";
|
||||
import {BehaviorSubject, debounceTime} from "rxjs";
|
||||
import {JsonTransformService} from "../json-transform.service";
|
||||
import {MatFormField} from "@angular/material/form-field";
|
||||
import {MatInputModule} from "@angular/material/input";
|
||||
|
||||
@Component({
|
||||
selector: 'app-json-path',
|
||||
standalone: true,
|
||||
imports: [
|
||||
InputOutputComponent,
|
||||
MatFormField,
|
||||
MatInputModule
|
||||
],
|
||||
templateUrl: './json-path.component.html',
|
||||
styleUrl: './json-path.component.scss'
|
||||
})
|
||||
export class JsonPathComponent implements OnInit {
|
||||
$path: BehaviorSubject<string> = new BehaviorSubject<string>("$.*");
|
||||
$input: BehaviorSubject<string> = new BehaviorSubject<string>(GenerateDefaultJsonObjectString(2));
|
||||
inputOptions = MonacoJsonConfig;
|
||||
output: string = "";
|
||||
outputOptions = ReadOnlyMonacoCSharpConfig;
|
||||
|
||||
constructor(private service: JsonTransformService) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.$input
|
||||
.pipe(debounceTime(DebounceTime))
|
||||
.subscribe(input => this.update(input, this.$path.value));
|
||||
|
||||
this.$path
|
||||
.pipe(debounceTime(DebounceTime))
|
||||
.subscribe(path => this.update(this.$input.value, path));
|
||||
|
||||
this.update(this.$input.value, this.$path.value);
|
||||
}
|
||||
|
||||
update(input: string, path: string): void {
|
||||
this.service
|
||||
.jsonPath(input, path)
|
||||
.subscribe({
|
||||
next: response => {
|
||||
console.log(response);
|
||||
this.output = response.body.result;
|
||||
},
|
||||
error: response => {
|
||||
console.log(response)
|
||||
if (response.status === 499) {
|
||||
this.output = response.error.detail;
|
||||
console.log(response.error.detail);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
handlePathChange($event: any): void {
|
||||
console.log($event);
|
||||
this.$path.next($event.target.value);
|
||||
}
|
||||
|
||||
handleInputChange($event: any): void {
|
||||
console.log($event);
|
||||
this.$input.next($event);
|
||||
}
|
||||
}
|
||||
16
src/app/json-transform.service.spec.ts
Normal file
16
src/app/json-transform.service.spec.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { JsonTransformService } from './json-transform.service';
|
||||
|
||||
describe('JsonTransformService', () => {
|
||||
let service: JsonTransformService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(JsonTransformService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
29
src/app/json-transform.service.ts
Normal file
29
src/app/json-transform.service.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {HttpClient, HttpResponse} from "@angular/common/http";
|
||||
import {Observable} from "rxjs";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class JsonTransformService {
|
||||
private url: string = "https://localhost:5001";
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
}
|
||||
|
||||
public beautify(source: string): Observable<HttpResponse<any>> {
|
||||
return this.http.post(`${this.url}/api/transform/beautify`, {Source: source}, {observe: "response"});
|
||||
}
|
||||
|
||||
public uglify(source: string): Observable<HttpResponse<any>> {
|
||||
return this.http.post(`${this.url}/api/transform/uglify`, {Source: source}, {observe: "response"});
|
||||
}
|
||||
|
||||
public json2csharp(source: string): Observable<HttpResponse<any>> {
|
||||
return this.http.post(`${this.url}/api/transform/json2csharp`, {Source: source}, {observe: "response"});
|
||||
}
|
||||
|
||||
public jsonPath(source: string, path: string): Observable<HttpResponse<any>> {
|
||||
return this.http.post(`${this.url}/api/transform/jsonpath`, {source: source, path: path}, {observe: "response"});
|
||||
}
|
||||
}
|
||||
8
src/app/json2csharp/json2-csharp.component.html
Normal file
8
src/app/json2csharp/json2-csharp.component.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<h1>JSON to C#</h1>
|
||||
|
||||
<app-input-output [input]="$input.value"
|
||||
[inputOptions]="inputOptions"
|
||||
(onInputChange)="handleInputChange($event)"
|
||||
[output]="output"
|
||||
[outputOptions]="outputOptions">
|
||||
</app-input-output>
|
||||
0
src/app/json2csharp/json2-csharp.component.scss
Normal file
0
src/app/json2csharp/json2-csharp.component.scss
Normal file
23
src/app/json2csharp/json2-csharp.component.spec.ts
Normal file
23
src/app/json2csharp/json2-csharp.component.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { Json2CsharpComponent } from './json2-csharp.component';
|
||||
|
||||
describe('Json2csharpComponent', () => {
|
||||
let component: Json2CsharpComponent;
|
||||
let fixture: ComponentFixture<Json2CsharpComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [Json2CsharpComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(Json2CsharpComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
60
src/app/json2csharp/json2-csharp.component.ts
Normal file
60
src/app/json2csharp/json2-csharp.component.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {InputOutputComponent} from "../input-output/input-output.component";
|
||||
import {JsonTransformService} from "../json-transform.service";
|
||||
import {
|
||||
DebounceTime,
|
||||
GenerateDefaultJsonObjectString,
|
||||
MonacoJsonConfig,
|
||||
ReadOnlyMonacoCSharpConfig
|
||||
} from "../defaults";
|
||||
import {BehaviorSubject, debounceTime} from "rxjs";
|
||||
|
||||
@Component({
|
||||
selector: 'app-json2csharp',
|
||||
standalone: true,
|
||||
imports: [
|
||||
InputOutputComponent
|
||||
],
|
||||
templateUrl: './json2-csharp.component.html',
|
||||
styleUrl: './json2-csharp.component.scss'
|
||||
})
|
||||
export class Json2CsharpComponent implements OnInit {
|
||||
$input: BehaviorSubject<string> = new BehaviorSubject<string>(GenerateDefaultJsonObjectString(2));
|
||||
inputOptions = MonacoJsonConfig;
|
||||
output: string = "";
|
||||
outputOptions = ReadOnlyMonacoCSharpConfig;
|
||||
|
||||
constructor(private service: JsonTransformService) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.$input
|
||||
.pipe(debounceTime(DebounceTime))
|
||||
.subscribe(input => this.update(input));
|
||||
|
||||
this.update(this.$input.value);
|
||||
}
|
||||
|
||||
update(input: string): void {
|
||||
this.service
|
||||
.json2csharp(input)
|
||||
.subscribe({
|
||||
next: response => {
|
||||
console.log(response);
|
||||
this.output = response.body.result;
|
||||
},
|
||||
error: response => {
|
||||
console.log(response)
|
||||
if (response.status === 499) {
|
||||
this.output = response.error.detail;
|
||||
console.log(response.error.detail);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
handleInputChange($event: any): void {
|
||||
console.log($event);
|
||||
this.$input.next($event);
|
||||
}
|
||||
}
|
||||
26
src/app/layout/layout.component.html
Normal file
26
src/app/layout/layout.component.html
Normal file
@@ -0,0 +1,26 @@
|
||||
<mat-sidenav-container class="sidenav-container">
|
||||
<mat-sidenav #drawer class="sidenav" mode="side" opened>
|
||||
<mat-toolbar>Menu</mat-toolbar>
|
||||
<mat-nav-list>
|
||||
<mat-list-item routerLink="/home">Home</mat-list-item>
|
||||
<mat-list-item routerLink="/beautify">Beautify</mat-list-item>
|
||||
<mat-list-item routerLink="/uglify">Uglify</mat-list-item>
|
||||
<mat-list-item routerLink="/json2csharp">JSON to C#</mat-list-item>
|
||||
<mat-list-item routerLink="/jsonpath">JSON Path</mat-list-item>
|
||||
</mat-nav-list>
|
||||
</mat-sidenav>
|
||||
|
||||
<mat-sidenav-content>
|
||||
<mat-toolbar color="primary">
|
||||
<button mat-icon-button (click)="drawer.toggle()">
|
||||
<mat-icon>menu</mat-icon>
|
||||
</button>
|
||||
<span>JSON Transform</span>
|
||||
</mat-toolbar>
|
||||
|
||||
<main>
|
||||
<!-- Add your dashboard content here -->
|
||||
<router-outlet></router-outlet>
|
||||
</main>
|
||||
</mat-sidenav-content>
|
||||
</mat-sidenav-container>
|
||||
16
src/app/layout/layout.component.scss
Normal file
16
src/app/layout/layout.component.scss
Normal file
@@ -0,0 +1,16 @@
|
||||
mat-sidenav-container {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
mat-sidenav-content {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
mat-sidenav {
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
main {
|
||||
height: 100%;
|
||||
padding: 20px;
|
||||
}
|
||||
23
src/app/layout/layout.component.spec.ts
Normal file
23
src/app/layout/layout.component.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { LayoutComponent } from './layout.component';
|
||||
|
||||
describe('LayoutComponent', () => {
|
||||
let component: LayoutComponent;
|
||||
let fixture: ComponentFixture<LayoutComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [LayoutComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(LayoutComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
27
src/app/layout/layout.component.ts
Normal file
27
src/app/layout/layout.component.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Component } from '@angular/core';
|
||||
import {MatSidenavContainer, MatSidenavModule} from "@angular/material/sidenav";
|
||||
import {MatToolbarModule} from "@angular/material/toolbar";
|
||||
import {MatListItem, MatNavList} from "@angular/material/list";
|
||||
import {RouterLink, RouterOutlet} from "@angular/router";
|
||||
import {MatIconButton} from "@angular/material/button";
|
||||
import {MatIconModule} from "@angular/material/icon";
|
||||
|
||||
@Component({
|
||||
selector: 'app-layout',
|
||||
standalone: true,
|
||||
imports: [
|
||||
MatSidenavContainer,
|
||||
MatToolbarModule,
|
||||
MatNavList,
|
||||
MatListItem,
|
||||
MatSidenavModule,
|
||||
RouterLink,
|
||||
MatIconButton,
|
||||
MatIconModule,
|
||||
RouterOutlet
|
||||
],
|
||||
templateUrl: './layout.component.html',
|
||||
styleUrl: './layout.component.scss'
|
||||
})
|
||||
export class LayoutComponent {
|
||||
}
|
||||
8
src/app/uglify/uglify.component.html
Normal file
8
src/app/uglify/uglify.component.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<h1>JSON Uglify</h1>
|
||||
|
||||
<app-input-output [input]="$input.value"
|
||||
[inputOptions]="inputOptions"
|
||||
(onInputChange)="handleInputChange($event)"
|
||||
[output]="output"
|
||||
[outputOptions]="outputOptions">
|
||||
</app-input-output>
|
||||
0
src/app/uglify/uglify.component.scss
Normal file
0
src/app/uglify/uglify.component.scss
Normal file
23
src/app/uglify/uglify.component.spec.ts
Normal file
23
src/app/uglify/uglify.component.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UglifyComponent } from './uglify.component';
|
||||
|
||||
describe('UglifyComponent', () => {
|
||||
let component: UglifyComponent;
|
||||
let fixture: ComponentFixture<UglifyComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [UglifyComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(UglifyComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
61
src/app/uglify/uglify.component.ts
Normal file
61
src/app/uglify/uglify.component.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {JsonTransformService} from "../json-transform.service";
|
||||
import {InputOutputComponent} from "../input-output/input-output.component";
|
||||
import {
|
||||
DebounceTime,
|
||||
GenerateDefaultJsonObjectString,
|
||||
MonacoJsonConfig,
|
||||
ReadOnlyMonacoJsonConfig
|
||||
} from "../defaults";
|
||||
import {debounceTime, BehaviorSubject} from "rxjs";
|
||||
|
||||
@Component({
|
||||
selector: 'app-uglify',
|
||||
standalone: true,
|
||||
imports: [
|
||||
InputOutputComponent
|
||||
],
|
||||
templateUrl: './uglify.component.html',
|
||||
styleUrl: './uglify.component.scss'
|
||||
})
|
||||
export class UglifyComponent implements OnInit {
|
||||
// input: string = ;
|
||||
$input: BehaviorSubject<string> = new BehaviorSubject<string>(GenerateDefaultJsonObjectString(2));
|
||||
inputOptions = MonacoJsonConfig;
|
||||
output: string = GenerateDefaultJsonObjectString();
|
||||
outputOptions = ReadOnlyMonacoJsonConfig;
|
||||
|
||||
constructor(private service: JsonTransformService) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.$input
|
||||
.pipe(debounceTime(DebounceTime))
|
||||
.subscribe(input => {
|
||||
this.update(input)
|
||||
});
|
||||
}
|
||||
|
||||
update(input: string): void {
|
||||
this.service
|
||||
.uglify(input)
|
||||
.subscribe({
|
||||
next: response => {
|
||||
console.log(response);
|
||||
this.output = response.body.result;
|
||||
},
|
||||
error: response => {
|
||||
console.log(response)
|
||||
if (response.status === 499) {
|
||||
this.output = response.error.detail;
|
||||
console.log(response.error.detail);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
handleInputChange($event: any): void {
|
||||
console.log($event);
|
||||
this.$input.next($event);
|
||||
}
|
||||
}
|
||||
15
src/index.html
Normal file
15
src/index.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>DevDisciplesJsonToolsApp</title>
|
||||
<base href="/">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
</head>
|
||||
<body class="mat-typography">
|
||||
<app-root></app-root>
|
||||
</body>
|
||||
</html>
|
||||
6
src/main.ts
Normal file
6
src/main.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { bootstrapApplication } from '@angular/platform-browser';
|
||||
import { appConfig } from './app/app.config';
|
||||
import { AppComponent } from './app/app.component';
|
||||
|
||||
bootstrapApplication(AppComponent, appConfig)
|
||||
.catch((err) => console.error(err));
|
||||
40
src/styles.scss
Normal file
40
src/styles.scss
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
// Custom Theming for Angular Material
|
||||
// For more information: https://material.angular.io/guide/theming
|
||||
@use '@angular/material' as mat;
|
||||
// Plus imports for other components in your app.
|
||||
|
||||
// Include the common styles for Angular Material. We include this here so that you only
|
||||
// have to load a single css file for Angular Material in your app.
|
||||
// Be sure that you only ever include this mixin once!
|
||||
@include mat.core();
|
||||
|
||||
// Define the theme object.
|
||||
$DevDisciples-Json-Tools-App-theme: mat.define-theme((
|
||||
color: (
|
||||
theme-type: light,
|
||||
primary: mat.$azure-palette,
|
||||
tertiary: mat.$blue-palette,
|
||||
),
|
||||
density: (
|
||||
scale: 0,
|
||||
)
|
||||
));
|
||||
|
||||
// Include theme styles for core and each component used in your app.
|
||||
// Alternatively, you can import and @include the theme mixins for each component
|
||||
// that you are using.
|
||||
:root {
|
||||
@include mat.all-component-themes($DevDisciples-Json-Tools-App-theme);
|
||||
}
|
||||
|
||||
// Comment out the line below if you want to use the pre-defined typography utility classes.
|
||||
// For more information: https://material.angular.io/guide/typography#using-typography-styles-in-your-application.
|
||||
// @include mat.typography-hierarchy($DevDisciples.Json.Tools.App-theme);
|
||||
|
||||
// Comment out the line below if you want to use the deprecated `color` inputs.
|
||||
// @include mat.color-variants-backwards-compatibility($DevDisciples.Json.Tools.App-theme);
|
||||
/* You can add global styles to this file, and also import other style files */
|
||||
|
||||
html, body { height: 100%; }
|
||||
body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }
|
||||
Reference in New Issue
Block a user