Skip to content

Commit

Permalink
editor save refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
dafik committed Nov 21, 2023
1 parent f933baf commit d1bf53b
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ build/
/app/src/main/resources/tiny.prop.json
/config/config-sbc2ha-new/.gitignore
/config/config-typescript/*
/config/editor/*
/docs/*
/docker/ha/sbc2ha.jar
/config/editor/node/*
42 changes: 42 additions & 0 deletions config/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store

/example-configs/*

/converter/src/main/resources/tools/*
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<h1 mat-dialog-title>Save editor content</h1>
<div mat-dialog-content>
<form [formGroup]="platform" class="form1">

<mat-label>Reload</mat-label>
<mat-checkbox [formControl]="reloadCtrl"></mat-checkbox>

<mat-label>Show logs</mat-label>
<mat-checkbox [formControl]="showLogsCtrl"></mat-checkbox>

</form>
</div>
<div mat-dialog-actions>
<button mat-raised-button color="warn" (click)="uploadCache()">in cache</button>
<button mat-raised-button color="primary" (click)="uploadConfig()">in config</button>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { SaveDialogComponent } from './save-dialog.component';

describe('SaveDialogComponent', () => {
let component: SaveDialogComponent;
let fixture: ComponentFixture<SaveDialogComponent>;

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [SaveDialogComponent]
});
fixture = TestBed.createComponent(SaveDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import {Component, Inject} from '@angular/core';
import {FormBuilder, FormControl, Validators} from "@angular/forms";
import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from "@angular/material/dialog";
import {CoverConfig} from "../../../../definition/actuator/CoverConfig";
import {ExtensionsService} from "../../extensions.service";

@Component({
selector: 'app-save-dialog',
templateUrl: './save-dialog.component.html',
styleUrls: ['./save-dialog.component.scss']
})
export class SaveDialogComponent {


reloadCtrl = new FormControl(true, Validators.required);
showLogsCtrl = new FormControl(true, Validators.required);


platform = this._formBuilder.group({
reload: this.reloadCtrl,
showLogs: this.showLogsCtrl,
});

constructor(private _formBuilder: FormBuilder,
public dialogRef: MatDialogRef<SaveDialogComponent, SaveCommand>,
@Inject(MAT_DIALOG_DATA) public data: { config: CoverConfig },
public es: ExtensionsService,
public dialog: MatDialog
) {
}


uploadCache() {
let rawValue = this.platform.getRawValue();
this.dialogRef.close({
target: "cache",
reload: (rawValue.reload) as boolean,
showLogs: (rawValue.showLogs) as boolean
})
}

uploadConfig() {
let rawValue = this.platform.getRawValue();
this.dialogRef.close({
target: "config",
reload: (rawValue.reload) as boolean,
showLogs: (rawValue.showLogs) as boolean
})
}
}

export interface SaveCommand {
target: string;
reload: boolean;
showLogs: boolean
}

0 comments on commit d1bf53b

Please sign in to comment.