-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(PublicKey):own components for modals
- Loading branch information
Showing
11 changed files
with
332 additions
and
275 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
...red_modules/public-key/generate-public-key-modal/generate-public-key-modal.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
|
||
<div class="modal-dialog" role="document"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h4 class="modal-title">Generate public key</h4> | ||
<button | ||
type="button" | ||
class="btn-close" | ||
style="cursor: pointer" | ||
(click)="hide()" | ||
data-dismiss="modal" | ||
aria-label="Close" | ||
></button> | ||
</div> | ||
<div class="modal-body"> | ||
<alert type="danger"> | ||
Hereby a new keypair is generated, the public key will be set automatically. A download window for the | ||
private key will also open. | ||
<strong | ||
>In order to use the new key, the permissions of the key may have to be adjusted. For this purpose call<br /> | ||
<code style="color: #777777">chmod 0600 nameOfTheKey</code>.</strong | ||
> | ||
<alert type="warning"> | ||
We do not store the private key anywhere!<br /> | ||
|
||
In case you lose your private key, it is lost permanently! | ||
</alert> | ||
<div class="form-check"> | ||
<input | ||
class="form-check-input" | ||
name="public_key_acknowledgement_checkbox" | ||
type="checkbox" | ||
id="public_key_acknowledgement_checkbox" | ||
[(ngModel)]="acknowledgement_given" | ||
data-test-id="public_key_acknowledgement_checkbox" | ||
/> | ||
<label class="form-check-label" for="public_key_acknowledgement_checkbox"> | ||
I hereby confirm that I am aware of the effects of generating a new SSH-key. | ||
</label> | ||
</div> | ||
</alert> | ||
</div> | ||
|
||
<div class="modal-footer"> | ||
<button | ||
[disabled]="!acknowledgement_given" | ||
class="btn btn-success col-md4" | ||
type="button" | ||
id="set_new_ssh_key_button" | ||
data-test-id="set_new_ssh_key_button" | ||
(click)="generateKey(); hide()" | ||
> | ||
Set | ||
</button> | ||
<button class="btn btn-primary col-md-4" type="reset" (click)="hide()">Cancel</button> | ||
</div> | ||
</div> | ||
<!-- /.modal-content --> | ||
</div> | ||
<!-- /.modal-dialog --> | ||
|
Empty file.
23 changes: 23 additions & 0 deletions
23
..._modules/public-key/generate-public-key-modal/generate-public-key-modal.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { GeneratePublicKeyModalComponent } from './generate-public-key-modal.component'; | ||
|
||
describe('GeneratePublicKeyModalComponent', () => { | ||
let component: GeneratePublicKeyModalComponent; | ||
let fixture: ComponentFixture<GeneratePublicKeyModalComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [GeneratePublicKeyModalComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(GeneratePublicKeyModalComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
48 changes: 48 additions & 0 deletions
48
...hared_modules/public-key/generate-public-key-modal/generate-public-key-modal.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Component, EventEmitter, Injectable, Output } from '@angular/core'; | ||
Check failure on line 1 in src/app/shared/shared_modules/public-key/generate-public-key-modal/generate-public-key-modal.component.ts GitHub Actions / tslinting-check
|
||
import { KeyService } from 'app/api-connector/key.service'; | ||
import { AbstractBaseModalComponent } from 'app/shared/modal/abstract-base-modal/abstract-base-modal.component'; | ||
import { BsModalService } from 'ngx-bootstrap/modal'; | ||
import { saveAs } from 'file-saver' | ||
|
||
@Injectable({ providedIn: 'root' }) | ||
@Component({ | ||
selector: 'app-generate-public-key-modal', | ||
templateUrl: './generate-public-key-modal.component.html', | ||
styleUrl: './generate-public-key-modal.component.scss' | ||
}) | ||
export class GeneratePublicKeyModalComponent extends AbstractBaseModalComponent { | ||
userlogin:string; | ||
acknowledgement_given:boolean=false | ||
|
||
constructor( | ||
protected modalService: BsModalService, | ||
private keyService:KeyService | ||
) { | ||
super(modalService) | ||
|
||
} | ||
showGeneratePublicKeyModal( | ||
userlogin:string | ||
|
||
): EventEmitter<void> { | ||
const initialState = { | ||
userlogin | ||
} | ||
|
||
return this.showBaseModal(GeneratePublicKeyModalComponent, initialState) | ||
} | ||
|
||
downloadPem(data: string): void { | ||
const blob: Blob = new Blob([data], { type: 'pem' }) | ||
const url: string = window.URL.createObjectURL(blob) | ||
saveAs(url, `${this.userlogin}_ecdsa`) | ||
} | ||
|
||
|
||
generateKey(): void { | ||
this.keyService.generateKey().subscribe((res: any): void => { | ||
this.event.emit() | ||
this.downloadPem(res['private_key']) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.