Skip to content

Commit 70c4230

Browse files
committed
add copy and import buttons to patch-editor
1 parent 7844151 commit 70c4230

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

webui/src/app/components/patch-editor/patch-editor.component.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@
77
(click)="addMIDIPatch()">
88
Add MIDI Patch
99
</button>
10+
<button
11+
class="px-8 py-1 my-2 ml-2 text-sm text-gray-300 bg-gray-800 border border-gray-500 border-solid rounded-lg"
12+
(click)="copyMIDIDevices()">
13+
Copy Device List
14+
</button>
15+
16+
<button
17+
*ngIf="settingsService.isDummySite"
18+
class="px-8 py-1 my-2 ml-2 text-sm text-gray-300 bg-gray-800 border border-gray-500 border-solid rounded-lg"
19+
(click)="importMIDIDevices()">
20+
Import Device List
21+
</button>
1022
</div>
1123
<table class="w-full">
1224
<thead>

webui/src/app/components/patch-editor/patch-editor.component.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
import { Clipboard } from '@angular/cdk/clipboard';
12
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
23
import { Component } from '@angular/core';
4+
import { MatDialog } from '@angular/material/dialog';
35
import { MatSnackBar } from '@angular/material/snack-bar';
46
import { MIDIPatch, NetworkPatch } from '@showbridge/types';
57
import { combineLatest, filter, take } from 'rxjs';
68
import { MIDIDeviceInfo } from 'src/app/models/events.model';
79
import { EventService } from 'src/app/services/event.service';
810
import { SettingsService } from 'src/app/services/settings.service';
911
import { VarsService } from 'src/app/services/vars.service';
12+
import { ImportJSONComponent } from '../import-json/import-json.component';
1013

1114
@Component({
1215
selector: 'app-patch-editor',
@@ -24,7 +27,9 @@ export class PatchEditorComponent {
2427
public varsService: VarsService,
2528
private eventService: EventService,
2629
private snackbar: MatSnackBar,
27-
public settingsService: SettingsService
30+
public settingsService: SettingsService,
31+
private clipboard: Clipboard,
32+
private dialog: MatDialog
2833
) {
2934
eventService.protocolStatus$
3035
.pipe(
@@ -65,6 +70,28 @@ export class PatchEditorComponent {
6570
this.midiPatches.push({ name: '', port: '' });
6671
}
6772

73+
copyMIDIDevices() {
74+
this.clipboard.copy(JSON.stringify(this.midiPorts));
75+
this.snackbar.open('Device list copied....', undefined, { duration: 3000 });
76+
}
77+
78+
importMIDIDevices() {
79+
const dialogRef = this.dialog.open(ImportJSONComponent, {
80+
width: '400px',
81+
height: '400px',
82+
data: {
83+
title: 'Import Device List',
84+
},
85+
});
86+
87+
dialogRef
88+
.afterClosed()
89+
.pipe(filter((result) => !!result && result !== ''))
90+
.subscribe((result) => {
91+
this.midiPorts = result;
92+
});
93+
}
94+
6895
savePatches() {
6996
this.midiPatches = this.midiPatches.filter((patch) => patch.port !== undefined);
7097
this.networkPatches = this.networkPatches.filter((patch) => patch.host !== '');

0 commit comments

Comments
 (0)