Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Volker Theile <votdev@gmx.de>
- Loading branch information
Showing
8 changed files
with
125 additions
and
1 deletion.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
...components/limn-ui/form/components/form-sshcert-select/form-sshcert-select.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,20 @@ | ||
<mat-form-field fxFlex | ||
[formGroup]="formGroup"> | ||
<mat-label>{{ config.label }}</mat-label> | ||
<mat-select [formControlName]="config.name" | ||
[placeholder]="config.placeholder" | ||
[required]="config.validators?.required"> | ||
<mat-option *ngFor="let option of config.store.data" | ||
[value]="option[config.valueField]"> | ||
{{ option[config.textField] }} | ||
</mat-option> | ||
</mat-select> | ||
<mat-error *ngIf="formGroup.invalid"> | ||
<span *ngIf="formGroup.hasError('required', config.name)"> | ||
This field is required. | ||
</span> | ||
</mat-error> | ||
<mat-hint *ngIf="config.hint?.length > 0" | ||
[innerHTML]="config.hint | sanitizeHtml"> | ||
</mat-hint> | ||
</mat-form-field> |
3 changes: 3 additions & 0 deletions
3
...components/limn-ui/form/components/form-sshcert-select/form-sshcert-select.component.scss
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,3 @@ | ||
mat-hint { | ||
margin-bottom: 5px; | ||
} |
37 changes: 37 additions & 0 deletions
37
...ponents/limn-ui/form/components/form-sshcert-select/form-sshcert-select.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,37 @@ | ||
/* eslint-disable max-len */ | ||
import { HttpClientTestingModule } from '@angular/common/http/testing'; | ||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; | ||
import { FormBuilder } from '@angular/forms'; | ||
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; | ||
|
||
import { FormSshcertSelectComponent } from '~/app/core/components/limn-ui/form/components/form-sshcert-select/form-sshcert-select.component'; | ||
import { LimnUiModule } from '~/app/core/components/limn-ui/limn-ui.module'; | ||
|
||
describe('FormSshcertSelectComponent', () => { | ||
let component: FormSshcertSelectComponent; | ||
let fixture: ComponentFixture<FormSshcertSelectComponent>; | ||
|
||
beforeEach( | ||
waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [HttpClientTestingModule, LimnUiModule, NoopAnimationsModule] | ||
}).compileComponents(); | ||
}) | ||
); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(FormSshcertSelectComponent); | ||
component = fixture.componentInstance; | ||
component.config = { | ||
type: 'sslCertSelect', | ||
name: 'foo' | ||
}; | ||
const formBuilder = TestBed.inject(FormBuilder); | ||
component.formGroup = formBuilder.group({ foo: [null] }); | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
55 changes: 55 additions & 0 deletions
55
...e/components/limn-ui/form/components/form-sshcert-select/form-sshcert-select.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,55 @@ | ||
/** | ||
* This file is part of OpenMediaVault. | ||
* | ||
* @license http://www.gnu.org/licenses/gpl.html GPL Version 3 | ||
* @author Volker Theile <volker.theile@openmediavault.org> | ||
* @copyright Copyright (c) 2009-2021 Volker Theile | ||
* | ||
* OpenMediaVault is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* any later version. | ||
* | ||
* OpenMediaVault is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
import { Component } from '@angular/core'; | ||
import * as _ from 'lodash'; | ||
|
||
import { FormSelectComponent } from '~/app/core/components/limn-ui/form/components/form-select/form-select.component'; | ||
|
||
@Component({ | ||
selector: 'omv-form-sshcert-select', | ||
templateUrl: './form-sshcert-select.component.html', | ||
styleUrls: ['./form-sshcert-select.component.scss'] | ||
}) | ||
export class FormSshcertSelectComponent extends FormSelectComponent { | ||
protected sanitizeConfig() { | ||
super.sanitizeConfig(); | ||
_.merge(this.config, { | ||
valueField: 'uuid', | ||
textField: 'comment', | ||
placeholder: 'Select a SSH certificate ...', | ||
store: { | ||
proxy: { | ||
service: 'CertificateMgmt', | ||
get: { | ||
method: 'getSshList', | ||
params: { | ||
start: 0, | ||
limit: -1 | ||
} | ||
} | ||
}, | ||
sorters: [ | ||
{ | ||
dir: 'asc', | ||
field: 'name' | ||
} | ||
] | ||
} | ||
}); | ||
} | ||
} |
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
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
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
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