Initial commit
This commit is contained in:
commit
376c42c3e6
16
.editorconfig
Normal file
16
.editorconfig
Normal 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
42
.gitignore
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-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
|
27
README.md
Normal file
27
README.md
Normal file
@ -0,0 +1,27 @@
|
||||
# DevDisciplesJsonToolsApp
|
||||
|
||||
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 18.2.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.dev/tools/cli) page.
|
110
angular.json
Normal file
110
angular.json
Normal file
@ -0,0 +1,110 @@
|
||||
{
|
||||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||
"version": 1,
|
||||
"newProjectRoot": "projects",
|
||||
"projects": {
|
||||
"DevDisciples.Json.Tools.App": {
|
||||
"projectType": "application",
|
||||
"schematics": {
|
||||
"@schematics/angular:component": {
|
||||
"style": "scss"
|
||||
}
|
||||
},
|
||||
"root": "",
|
||||
"sourceRoot": "src",
|
||||
"prefix": "app",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-angular:application",
|
||||
"options": {
|
||||
"outputPath": "dist/dev-disciples.json.tools.app",
|
||||
"index": "src/index.html",
|
||||
"browser": "src/main.ts",
|
||||
"polyfills": [
|
||||
"zone.js"
|
||||
],
|
||||
"tsConfig": "tsconfig.app.json",
|
||||
"inlineStyleLanguage": "scss",
|
||||
"assets": [
|
||||
{
|
||||
"glob": "**/*",
|
||||
"input": "public"
|
||||
},
|
||||
{ "glob": "**/*",
|
||||
"input": "node_modules/monaco-editor",
|
||||
"output": "/assets/monaco/"
|
||||
}
|
||||
],
|
||||
"styles": [
|
||||
"src/styles.scss"
|
||||
],
|
||||
"scripts": []
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"budgets": [
|
||||
{
|
||||
"type": "initial",
|
||||
"maximumWarning": "500kB",
|
||||
"maximumError": "1MB"
|
||||
},
|
||||
{
|
||||
"type": "anyComponentStyle",
|
||||
"maximumWarning": "2kB",
|
||||
"maximumError": "4kB"
|
||||
}
|
||||
],
|
||||
"outputHashing": "all"
|
||||
},
|
||||
"development": {
|
||||
"optimization": false,
|
||||
"extractLicenses": false,
|
||||
"sourceMap": true
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "production"
|
||||
},
|
||||
"serve": {
|
||||
"builder": "@angular-devkit/build-angular:dev-server",
|
||||
"configurations": {
|
||||
"production": {
|
||||
"buildTarget": "DevDisciples.Json.Tools.App:build:production"
|
||||
},
|
||||
"development": {
|
||||
"buildTarget": "DevDisciples.Json.Tools.App:build:development"
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "development"
|
||||
},
|
||||
"extract-i18n": {
|
||||
"builder": "@angular-devkit/build-angular:extract-i18n"
|
||||
},
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"options": {
|
||||
"polyfills": [
|
||||
"zone.js",
|
||||
"zone.js/testing"
|
||||
],
|
||||
"tsConfig": "tsconfig.spec.json",
|
||||
"inlineStyleLanguage": "scss",
|
||||
"assets": [
|
||||
{
|
||||
"glob": "**/*",
|
||||
"input": "public"
|
||||
},
|
||||
{ "glob": "**/*",
|
||||
"input": "node_modules/monaco-editor",
|
||||
"output": "/assets/monaco/"
|
||||
}
|
||||
],
|
||||
"styles": [
|
||||
"src/styles.scss"
|
||||
],
|
||||
"scripts": []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
14458
package-lock.json
generated
Normal file
14458
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
42
package.json
Normal file
42
package.json
Normal file
@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "dev-disciples.json.tools.app",
|
||||
"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": "^18.2.0",
|
||||
"@angular/cdk": "^18.2.4",
|
||||
"@angular/common": "^18.2.0",
|
||||
"@angular/compiler": "^18.2.0",
|
||||
"@angular/core": "^18.2.0",
|
||||
"@angular/forms": "^18.2.0",
|
||||
"@angular/material": "^18.2.4",
|
||||
"@angular/platform-browser": "^18.2.0",
|
||||
"@angular/platform-browser-dynamic": "^18.2.0",
|
||||
"@angular/router": "^18.2.0",
|
||||
"monaco-editor": "^0.50.0",
|
||||
"ngx-monaco-editor-v2": "^18.1.0",
|
||||
"rxjs": "~7.8.0",
|
||||
"tslib": "^2.3.0",
|
||||
"zone.js": "~0.14.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "^18.2.4",
|
||||
"@angular/cli": "^18.2.4",
|
||||
"@angular/compiler-cli": "^18.2.0",
|
||||
"@types/jasmine": "~5.1.0",
|
||||
"jasmine-core": "~5.2.0",
|
||||
"karma": "~6.4.0",
|
||||
"karma-chrome-launcher": "~3.2.0",
|
||||
"karma-coverage": "~2.2.0",
|
||||
"karma-jasmine": "~5.1.0",
|
||||
"karma-jasmine-html-reporter": "~2.1.0",
|
||||
"typescript": "~5.5.2"
|
||||
}
|
||||
}
|
BIN
public/favicon.ico
Normal file
BIN
public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
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; }
|
15
tsconfig.app.json
Normal file
15
tsconfig.app.json
Normal file
@ -0,0 +1,15 @@
|
||||
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
||||
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./out-tsc/app",
|
||||
"types": []
|
||||
},
|
||||
"files": [
|
||||
"src/main.ts"
|
||||
],
|
||||
"include": [
|
||||
"src/**/*.d.ts"
|
||||
]
|
||||
}
|
33
tsconfig.json
Normal file
33
tsconfig.json
Normal file
@ -0,0 +1,33 @@
|
||||
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
||||
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
||||
{
|
||||
"compileOnSave": false,
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist/out-tsc",
|
||||
"strict": true,
|
||||
"noImplicitOverride": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"skipLibCheck": true,
|
||||
"isolatedModules": true,
|
||||
"esModuleInterop": true,
|
||||
"sourceMap": true,
|
||||
"declaration": false,
|
||||
"experimentalDecorators": true,
|
||||
"moduleResolution": "bundler",
|
||||
"importHelpers": true,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"lib": [
|
||||
"ES2022",
|
||||
"dom"
|
||||
]
|
||||
},
|
||||
"angularCompilerOptions": {
|
||||
"enableI18nLegacyMessageIdFormat": false,
|
||||
"strictInjectionParameters": true,
|
||||
"strictInputAccessModifiers": true,
|
||||
"strictTemplates": true
|
||||
}
|
||||
}
|
15
tsconfig.spec.json
Normal file
15
tsconfig.spec.json
Normal file
@ -0,0 +1,15 @@
|
||||
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
||||
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./out-tsc/spec",
|
||||
"types": [
|
||||
"jasmine"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.spec.ts",
|
||||
"src/**/*.d.ts"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user