Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add menu for copying adb connect command that uses cvdr #611

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions frontend/src/operator/webui/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import {MatButtonModule} from '@angular/material/button';
import {MatCardModule} from '@angular/material/card';
import {MatCheckboxModule} from '@angular/material/checkbox';
import {MatIconModule} from '@angular/material/icon';
import {MatMenuModule} from '@angular/material/menu';
import {MatSidenavModule} from '@angular/material/sidenav';
import {MatSlideToggleModule} from '@angular/material/slide-toggle';
import {MatSnackBarModule} from '@angular/material/snack-bar';
import {MatToolbarModule} from '@angular/material/toolbar';
import {ViewPaneComponent} from './view-pane/view-pane.component';
import {SafeDeviceUrlPipe} from './safe-device-url.pipe';
Expand All @@ -32,8 +34,10 @@ import {RouterModule} from '@angular/router';
MatCardModule,
MatCheckboxModule,
MatIconModule,
MatMenuModule,
MatSidenavModule,
MatSlideToggleModule,
MatSnackBarModule,
MatToolbarModule,
FormsModule,
HttpClientModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
(change)="displaysService.toggleVisibility(device.device_id)"
>{{ device.device_id }}</mat-slide-toggle
>
<button mat-icon-button class="menu" title="menu">
<button
mat-icon-button class="menu" title="menu"
[matMenuTriggerFor]="deviceMenu"
[matMenuTriggerData]="{device_id: device.device_id}"
>
<mat-icon>more_vert</mat-icon>
</button>
</li>
Expand All @@ -29,3 +33,9 @@
Show All
</button>
</div>

<mat-menu #deviceMenu="matMenu">
<ng-template matMenuContent let-device_id="device_id">
<button mat-menu-item (click)="copyAdbCommand(device_id)">Copy ADB connect command</button>
</ng-template>
</mat-menu>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {DisplaysService} from '../displays.service';
import {filter, first, mergeMap} from 'rxjs/operators';
import {GroupService} from '../group.service';
import {ActivatedRoute, NavigationEnd, Router} from '@angular/router';
import {MatSnackBar} from '@angular/material/snack-bar'

@Component({
selector: 'app-device-pane',
Expand All @@ -19,7 +20,8 @@ export class DevicePaneComponent {
public displaysService: DisplaysService,
private groupService: GroupService,
private activatedRoute: ActivatedRoute,
private router: Router
private router: Router,
private snackBar: MatSnackBar
) {}

ngOnInit(): void {
Expand Down Expand Up @@ -50,4 +52,14 @@ export class DevicePaneComponent {
});
});
}

copyAdbCommand(deviceId: string) {
var currentUrl = window.location.href
var command = 'cvdr connect --connect_agent=websocket_agent ' +
`--service_url=${currentUrl} --host=websocket ${deviceId}`
navigator.clipboard.writeText(command)
this.snackBar.open('ADB connect command copied to the Clipboard', 'OK', {
duration: 3000,
});
}
}
Loading