Skip to content

Commit

Permalink
Allow sending SSH Key from console
Browse files Browse the repository at this point in the history
Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
  • Loading branch information
torchiaf committed May 22, 2024
1 parent 7681e11 commit ad80c78
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@
<td mat-cell *matCellDef="let element"> {{element.Path}}?{{element.Repo}} </td>
</ng-container>

<!-- Auth Column -->
<ng-container matColumnDef="GitAuth">
<th mat-header-cell *matHeaderCellDef> {{ 'COLUMN_GIT_AUTH' | translate }} </th>
<td mat-cell *matCellDef="let element"> {{element.GitAuth ? 'Enabled' : 'None'}} </td>
</ng-container>

<!-- VScodeSettings Column -->
<ng-container matColumnDef="VScodeSettings">
<th mat-header-cell *matHeaderCellDef> {{ 'COLUMN_VSCODE_SETTINGS' | translate }} </th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class AdminViewsComponent implements OnInit, OnDestroy {
dataSource: MatTableDataSource<Row> = new MatTableDataSource();

displayedColumns = ['Id', 'Name', 'Email', 'Phone', 'Status'];
innerDisplayedColumns = ['Id', 'Path', 'VScodeSettings', 'Delete', 'GoTo'];
innerDisplayedColumns = ['Id', 'Path', 'VScodeSettings', 'GitAuth', 'Delete', 'GoTo'];

expandedElements: Record<string, boolean> = {};
collapseDisabled = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
<td mat-cell *matCellDef="let element"> {{element.VScodeSettings}} </td>
</ng-container>

<!-- Auth Column -->
<ng-container matColumnDef="GitAuth">
<th mat-header-cell *matHeaderCellDef> {{ 'COLUMN_GIT_AUTH' | translate }} </th>
<td mat-cell *matCellDef="let element"> {{element.GitAuth ? 'Enabled' : 'None'}} </td>
</ng-container>

<!-- GoTo Column -->
<ng-container matColumnDef="GoTo">
<th mat-header-cell *matHeaderCellDef></th>
Expand All @@ -51,4 +57,4 @@
</span>
</ng-template>
</mat-tab>
</mat-tab-group>
</mat-tab-group>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class UserViewsComponent implements OnInit, OnDestroy {

readonly tableRefresh$: Subject<void> = new Subject<void>();

displayedColumns = ['Id', 'Path', 'VScodeSettings', 'GoTo'];
displayedColumns = ['Id', 'Path', 'VScodeSettings', 'GitAuth', 'GoTo'];
dataSource: MatTableDataSource<Row> = new MatTableDataSource();

constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ <h4 mat-title>{{'CREATE_VIEW_TITLE' | translate}}</h4>
</mat-form-field>
</p>

<p fxLayout="column" fxLayoutAlign="start start" fxLayoutGap="15px" class="ssh-file-upload">
<vo-mat-fileUpload
[chooseLabel]="'FIELD_VIEW_SSH_KEY' | translate"
[disabled]="view.general.sshKey !== ''"
(done)="sshFileUpload($event)">
</vo-mat-fileUpload>
</p>

<mat-checkbox class="repository-info" name="repositoryInfo" [(ngModel)]="repositoryInfo">{{ (repositoryInfo ? 'FIELD_VIEW_ADVANCED_ENABLED' : 'FIELD_VIEW_ADVANCED_DISABLED') | translate}}</mat-checkbox>

<p *ngIf="repositoryInfo" fxLayout="row" fxLayoutAlign="space-around center">
Expand Down Expand Up @@ -57,14 +65,6 @@ <h4 mat-title>{{'CREATE_VIEW_TITLE' | translate}}</h4>
</mat-form-field>
</p>

<p *ngIf="repositoryInfo" fxLayout="column" fxLayoutAlign="start start" fxLayoutGap="15px" class="ssh-file-upload">
<vo-mat-fileUpload
[chooseLabel]="'FIELD_VIEW_SSH_KEY' | translate"
[disabled]="sshKey !== null"
(done)="sshFileUpload($event)">
</vo-mat-fileUpload>
</p>

<p class="form-btn" fxLayout="row" fxLayoutAlign="end end">
<button
mat-stroked-button color="primary"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Extension, ViewCreate } from 'src/app/models/view';

@Component({
Expand All @@ -13,8 +13,6 @@ export class ViewCreateFormComponent {

repositoryInfo = true;

sshKey: string | null = null;

// TODO hardcoded
extensions: Extension[] = [{
id: 'hoovercj.vscode-power-mode',
Expand All @@ -38,6 +36,7 @@ export class ViewCreateFormComponent {
},
extensions: [],
vscodeSettings: '',
sshKey: '',
},
repo: {
git: {
Expand All @@ -48,20 +47,20 @@ export class ViewCreateFormComponent {
commit: ''
}
}
}

constructor() {}
};

public async sshFileUpload(files: File[]) {
let sshKey = '';

if (files?.length > 0) {
const text = await files[0]?.text();

this.sshKey = btoa(text);
sshKey = btoa(text);
} else {
this.sshKey = null;
sshKey = '';
}

console.log(this.sshKey);
this.view.general.sshKey = sshKey;
}

public save() {
Expand Down
1 change: 1 addition & 0 deletions src/console/src/app/models/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface View {
Path: string;
Status: string;
VScodeSettings: string;
GitAuth: boolean;
Session: string;
RepoType: string;
Repo: string;
Expand Down
3 changes: 2 additions & 1 deletion src/console/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@
"DELETE_VIEW_CONFIRM_MSG": "Are you sure?",
"GOTO_DISABLED": "Unable to get View Session",

"FIELD_VIEW_SSH_KEY": "Git SSH Key"
"FIELD_VIEW_SSH_KEY": "Git SSH Key",
"COLUMN_GIT_AUTH": "Git Authentication"
}
3 changes: 2 additions & 1 deletion src/console/src/assets/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@
"DELETE_VIEW_CONFIRM_MSG": "Sei sicuro/a?",
"GOTO_DISABLED": "Impossible accedere ai dati sessione",

"FIELD_VIEW_SSH_KEY": "Git Chiave SSH"
"FIELD_VIEW_SSH_KEY": "Git Chiave SSH",
"COLUMN_GIT_AUTH": "Git Auth"
}

0 comments on commit ad80c78

Please sign in to comment.