Skip to content

Commit 4583a3a

Browse files
committed
Add copy to clipboard
Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
1 parent b34e828 commit 4583a3a

File tree

6 files changed

+33
-8
lines changed

6 files changed

+33
-8
lines changed

src/console/src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import { MatExpansionModule } from '@angular/material/expansion';
4343
import { MatCheckboxModule } from '@angular/material/checkbox';
4444
import { UserViewsComponent } from './components/dashboard/user/user-views/user-views.component';
4545
import { FileuploadComponent } from './components/widgets/fileupload.component';
46+
import { ClipboardModule } from '@angular/cdk/clipboard';
4647

4748
// Required during AOT compilation
4849
export function httpTranslateLoaderFactory(http: HttpClient) {
@@ -92,6 +93,7 @@ export function httpTranslateLoaderFactory(http: HttpClient) {
9293
MatProgressSpinnerModule,
9394
MatTabsModule,
9495
MatTooltipModule,
96+
ClipboardModule,
9597
TranslateModule.forRoot({
9698
loader: {
9799
provide: TranslateLoader,

src/console/src/app/components/dashboard/admin/admin-views/admin-views.component.html

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
<!-- GoTo Column -->
107107
<ng-container matColumnDef="GoTo">
108108
<th mat-header-cell *matHeaderCellDef></th>
109-
<td mat-cell *matCellDef="let element">
109+
<td mat-cell *matCellDef="let element" matTooltip="{{(element.Session?.length > 0 ? '' : 'GOTO_DISABLED') | translate}}">
110110
<button
111111
class="goto"
112112
[disabled]="deleting || element.Session?.length === 0"
@@ -118,6 +118,21 @@
118118
</td>
119119
</ng-container>
120120

121+
<!-- CopyToClipboard Column -->
122+
<ng-container matColumnDef="CopyToClipboard">
123+
<th mat-header-cell *matHeaderCellDef></th>
124+
<td mat-cell *matCellDef="let element" matTooltip="{{(element.Session?.length > 0 ? '' : 'GOTO_DISABLED') | translate}}">
125+
<button
126+
class="goto"
127+
[disabled]="deleting || element.Session?.length === 0"
128+
mat-mini-fab color="primary"
129+
matTooltip="{{(element.Session?.length > 0 ? 'COPY_TO_CLIP' : 'GOTO_DISABLED') | translate}}"
130+
[cdkCopyToClipboard]="getUrl(element)">
131+
<mat-icon>content_copy</mat-icon>
132+
</button>
133+
</td>
134+
</ng-container>
135+
121136
<!-- Delete Column -->
122137
<ng-container matColumnDef="Delete">
123138
<th mat-header-cell *matHeaderCellDef></th>

src/console/src/app/components/dashboard/admin/admin-views/admin-views.component.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class AdminViewsComponent implements OnInit, OnDestroy {
4242
dataSource: MatTableDataSource<Row> = new MatTableDataSource();
4343

4444
displayedColumns = ['Id', 'Name', 'Email', 'Phone', 'Status'];
45-
innerDisplayedColumns = ['Id', 'Path', 'VScodeSettings', 'GitAuth', 'Delete', 'GoTo'];
45+
innerDisplayedColumns = ['Id', 'Path', 'VScodeSettings', 'GitAuth', 'Delete', 'CopyToClipboard', 'GoTo'];
4646

4747
expandedElements: Record<string, boolean> = {};
4848
collapseDisabled = false;
@@ -171,6 +171,12 @@ export class AdminViewsComponent implements OnInit, OnDestroy {
171171
}
172172
}
173173

174+
public getUrl(element: View) {
175+
const url = `${environment.protocol}://${window.location.hostname}${element.Path}?${element.Query}`;
176+
177+
return url;
178+
}
179+
174180
public goToView(element: View) {
175181
this.cookieService.get('code-server-session');
176182
this.cookieService.put('code-server-session', element.Session, {
@@ -179,8 +185,6 @@ export class AdminViewsComponent implements OnInit, OnDestroy {
179185
storeUnencoded: true
180186
});
181187

182-
const url = `${environment.protocol}://${window.location.hostname}${element.Path}?${element.Query}`;
183-
184-
window.open(url, '_blank');
188+
window.open(this.getUrl(element), '_blank');
185189
}
186190
}

src/console/src/app/components/dashboard/user/user-views/user-views.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<!-- GoTo Column -->
3535
<ng-container matColumnDef="GoTo">
3636
<th mat-header-cell *matHeaderCellDef></th>
37-
<td mat-cell *matCellDef="let element">
37+
<td mat-cell *matCellDef="let element" matTooltip="{{(element.Session?.length > 0 ? '' : 'GOTO_DISABLED') | translate}}">
3838
<button
3939
class="goto"
4040
[disabled]="element.Session?.length === 0"

src/console/src/assets/i18n/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,7 @@
6161
"GOTO_DISABLED": "Unable to get View Session",
6262

6363
"FIELD_VIEW_SSH_KEY": "Git SSH Key",
64-
"COLUMN_GIT_AUTH": "Git Authentication"
64+
"COLUMN_GIT_AUTH": "Git Authentication",
65+
66+
"COPY_TO_CLIP": "Copy Url"
6567
}

src/console/src/assets/i18n/it.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,7 @@
6161
"GOTO_DISABLED": "Impossible accedere ai dati sessione",
6262

6363
"FIELD_VIEW_SSH_KEY": "Git Chiave SSH",
64-
"COLUMN_GIT_AUTH": "Git Auth"
64+
"COLUMN_GIT_AUTH": "Git Auth",
65+
66+
"COPY_TO_CLIP": "Copia Url"
6567
}

0 commit comments

Comments
 (0)