-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added option to import/export the scheduler config
- Loading branch information
Showing
9 changed files
with
144 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
.outlet { | ||
margin: 16px; | ||
} | ||
|
||
mat-toolbar { | ||
display: flex; | ||
justify-content: space-between; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,33 @@ | ||
import { Component } from '@angular/core'; | ||
import { MatToolbarModule } from '@angular/material/toolbar'; | ||
import { RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router'; | ||
import { Component, inject } from "@angular/core"; | ||
import { MatButtonModule } from "@angular/material/button"; | ||
import { MatDialog, MatDialogModule } from "@angular/material/dialog"; | ||
import { MatIconModule } from "@angular/material/icon"; | ||
import { MatToolbarModule } from "@angular/material/toolbar"; | ||
import { RouterLink, RouterLinkActive, RouterOutlet } from "@angular/router"; | ||
import { ImportExportDialogComponent } from './import-export-dialog/import-export-dialog.component'; | ||
|
||
@Component({ | ||
selector: 'app-root', | ||
templateUrl: './app.component.html', | ||
styleUrls: ['./app.component.css'], | ||
standalone: true, | ||
imports: [RouterLink, RouterLinkActive, RouterOutlet, MatToolbarModule] | ||
selector: "app-root", | ||
templateUrl: "./app.component.html", | ||
styleUrls: ["./app.component.css"], | ||
standalone: true, | ||
imports: [ | ||
RouterLink, | ||
RouterLinkActive, | ||
RouterOutlet, | ||
MatToolbarModule, | ||
MatIconModule, | ||
MatButtonModule, | ||
MatDialogModule, | ||
], | ||
}) | ||
export class AppComponent { | ||
|
||
private dialog = inject(MatDialog); | ||
|
||
openImportExport() { | ||
this.dialog.open(ImportExportDialogComponent, { | ||
width: "800px" | ||
}); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
src/app/import-export-dialog/import-export-dialog.component.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.full-width { | ||
width: 100%; | ||
} |
19 changes: 19 additions & 0 deletions
19
src/app/import-export-dialog/import-export-dialog.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<h2 mat-dialog-title>Import/Export</h2> | ||
<mat-dialog-content> | ||
|
||
<h3>Import</h3> | ||
<mat-form-field class="full-width"> | ||
<mat-label>Data</mat-label> | ||
<textarea [formControl]="importControl" rows="5" matInput placeholder="Paste JSON data"></textarea> | ||
</mat-form-field> | ||
<button mat-button (click)="importData()" [disabled]="importControl.invalid"> | ||
Import | ||
<mat-icon>upload</mat-icon> | ||
</button> | ||
|
||
<h3>Export</h3> | ||
<button mat-button (click)="copyConfigToClipboard()"> | ||
Export | ||
<mat-icon>content_paste_go</mat-icon> | ||
</button> | ||
</mat-dialog-content> |
43 changes: 43 additions & 0 deletions
43
src/app/import-export-dialog/import-export-dialog.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { CommonModule } from "@angular/common"; | ||
import { ChangeDetectionStrategy, Component, inject } from "@angular/core"; | ||
import { FormControl, ReactiveFormsModule } from '@angular/forms'; | ||
import { MatButtonModule } from "@angular/material/button"; | ||
import { MatDialogModule } from "@angular/material/dialog"; | ||
import { MatFormFieldModule } from '@angular/material/form-field'; | ||
import { MatIconModule } from "@angular/material/icon"; | ||
import { MatInputModule } from '@angular/material/input'; | ||
import { MatSnackBar } from '@angular/material/snack-bar'; | ||
import { ChoiceDataService } from "../shared/choice-data.service"; | ||
|
||
@Component({ | ||
selector: "app-import-export-dialog", | ||
standalone: true, | ||
imports: [ | ||
CommonModule, | ||
MatDialogModule, | ||
MatButtonModule, | ||
MatIconModule, | ||
MatFormFieldModule, | ||
MatInputModule, | ||
ReactiveFormsModule | ||
], | ||
templateUrl: `./import-export-dialog.component.html`, | ||
styleUrl: "./import-export-dialog.component.css", | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class ImportExportDialogComponent { | ||
private choiceDataService = inject(ChoiceDataService); | ||
private snackBar = inject(MatSnackBar); | ||
|
||
importControl = new FormControl(""); | ||
|
||
copyConfigToClipboard() { | ||
this.choiceDataService.copyToClipboard(); | ||
this.snackBar.open("Config copied to clipboard", null, { duration: 3000 }); | ||
} | ||
|
||
importData() { | ||
this.choiceDataService.import(this.importControl.value); | ||
this.snackBar.open("Config imported successfully", null, { duration: 3000 }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { ChoiceGroup } from './choice-group'; | ||
|
||
export interface Config { | ||
groups: ChoiceGroup[]; | ||
lastChoiceId: number; | ||
lastChoiceGroupId: number; | ||
} |