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 a copy button in the visor list #406

Merged
merged 1 commit into from
Jun 15, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@
{{ node.local_pk }}
</td>
<td (click)="$event.stopPropagation()" class="actions">
<button
[clipboard]="node.local_pk"
(copyEvent)="onCopyToClipboardClicked()"
mat-icon-button
[matTooltip]="'nodes.copy-key' | translate"
class="grey-button-background"
>
<mat-icon class="small-icon">filter_none</mat-icon>
</button>
<button
(click)="showEditLabelDialog(node)"
mat-icon-button
Expand Down Expand Up @@ -132,12 +141,12 @@
<div class="margin-part"></div>
<div class="right-part">
<button
(click)="$event.stopPropagation(); node.online ? showEditLabelDialog(node) : showOptionsDialog(node)"
(click)="$event.stopPropagation(); showOptionsDialog(node)"
mat-icon-button
[matTooltip]="(node.online ? 'edit-label.title' : 'common.options') | translate"
[matTooltip]="'common.options' | translate"
class="grey-button-background"
>
<mat-icon>{{ node.online ? 'short_text' : 'add' }}</mat-icon>
<mat-icon>{{ 'add' }}</mat-icon>
</button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@

.actions {
text-align: right;
width: 110px;
width: 150px;

button {
width: 32px;
height: 32px;
line-height: 24px;

&:last-child {
margin-left: 15px;
margin-left: 5px;

.small-icon {
font-size: 15px;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { SelectColumnComponent, SelectedColumn } from '../../layout/select-colum
import GeneralUtils from 'src/app/utils/generalUtils';
import { SelectOptionComponent, SelectableOption } from '../../layout/select-option/select-option.component';
import { processServiceError } from 'src/app/utils/errors';
import { ClipboardService } from 'src/app/services/clipboard.service';

/**
* List of the columns that can be used to sort the data.
Expand Down Expand Up @@ -71,6 +72,7 @@ export class NodeListComponent implements OnInit, OnDestroy {
private ngZone: NgZone,
private snackbarService: SnackbarService,
private sidenavService: SidenavService,
private clipboardService: ClipboardService
) {
// Data for populating the tab bar.
this.tabsData = [
Expand Down Expand Up @@ -306,24 +308,42 @@ export class NodeListComponent implements OnInit, OnDestroy {
showOptionsDialog(node: Node) {
const options: SelectableOption[] = [
{
icon: 'short_text',
label: 'edit-label.title',
icon: 'filter_none',
label: 'nodes.copy-key',
},
{
icon: 'close',
label: 'nodes.delete-node',
icon: 'short_text',
label: 'edit-label.title',
}
];

if (!node.online) {
options.push({
icon: 'close',
label: 'nodes.delete-node',
});
}

SelectOptionComponent.openDialog(this.dialog, options).afterClosed().subscribe((selectedOption: number) => {
if (selectedOption === 1) {
this.showEditLabelDialog(node);
if (this.clipboardService.copy(node.local_pk)) {
this.onCopyToClipboardClicked();
}
} else if (selectedOption === 2) {
this.showEditLabelDialog(node);
} else if (selectedOption === 3) {
this.deleteNode(node);
}
});
}

/**
* Called after copying the public key of a node.
*/
onCopyToClipboardClicked() {
this.snackbarService.showDone('copy.copied');
}

/**
* Opens the modal window for changing the label of a node.
*/
Expand Down
1 change: 1 addition & 0 deletions static/skywire-manager-src/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
"state-tooltip": "Current state",
"label": "Label",
"key": "Key",
"copy-key": "Copy key",
"view-node": "View visor",
"delete-node": "Remove visor",
"error-load": "An error occurred while refreshing the list. Retrying...",
Expand Down