1
+ import { Clipboard } from '@angular/cdk/clipboard' ;
1
2
import { CdkDragDrop , moveItemInArray } from '@angular/cdk/drag-drop' ;
2
3
import { Component } from '@angular/core' ;
4
+ import { MatDialog } from '@angular/material/dialog' ;
3
5
import { MatSnackBar } from '@angular/material/snack-bar' ;
4
6
import { MIDIPatch , NetworkPatch } from '@showbridge/types' ;
5
7
import { combineLatest , filter , take } from 'rxjs' ;
6
8
import { MIDIDeviceInfo } from 'src/app/models/events.model' ;
7
9
import { EventService } from 'src/app/services/event.service' ;
8
10
import { SettingsService } from 'src/app/services/settings.service' ;
9
11
import { VarsService } from 'src/app/services/vars.service' ;
12
+ import { ImportJSONComponent } from '../import-json/import-json.component' ;
10
13
11
14
@Component ( {
12
15
selector : 'app-patch-editor' ,
@@ -24,7 +27,9 @@ export class PatchEditorComponent {
24
27
public varsService : VarsService ,
25
28
private eventService : EventService ,
26
29
private snackbar : MatSnackBar ,
27
- public settingsService : SettingsService
30
+ public settingsService : SettingsService ,
31
+ private clipboard : Clipboard ,
32
+ private dialog : MatDialog
28
33
) {
29
34
eventService . protocolStatus$
30
35
. pipe (
@@ -65,6 +70,28 @@ export class PatchEditorComponent {
65
70
this . midiPatches . push ( { name : '' , port : '' } ) ;
66
71
}
67
72
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
+
68
95
savePatches ( ) {
69
96
this . midiPatches = this . midiPatches . filter ( ( patch ) => patch . port !== undefined ) ;
70
97
this . networkPatches = this . networkPatches . filter ( ( patch ) => patch . host !== '' ) ;
0 commit comments