Skip to content

Commit

Permalink
update credential
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Werfling committed Jun 4, 2024
1 parent 3a64f8c commit 202ab67
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 24 deletions.
3 changes: 3 additions & 0 deletions backend/src/Routes/Main/Credential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import {DefaultRoute} from 'flyingfish_core';
import {List} from './Credential/List.js';
import {Provider} from './Credential/Provider.js';

/**
* Credential route
*/
export class Credential extends DefaultRoute {

/**
Expand Down
7 changes: 7 additions & 0 deletions backend/src/Routes/Main/Credential/Provider.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import {CredentialProviderResponse, StatusCodes} from 'flyingfish_schemas';
import {CredentialProviders} from '../../../inc/Provider/CredentialProvider/CredentialProviders.js';

/**
* Provider
*/
export class Provider {

/**
* Get providers
* @returns {CredentialProviderResponse}
*/
public static async getProviders(): Promise<CredentialProviderResponse> {
const cps = new CredentialProviders();
const providers = await cps.getProviders();
Expand Down
3 changes: 3 additions & 0 deletions core/src/inc/Provider/BaseProviders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import {AProviderOnLoadEvent} from './AProviderOnLoadEvent.js';
import {IProvider} from './IProvider.js';
import {ProviderType} from './ProviderType.js';

/**
* Base Provider
*/
export class BaseProviders {

/**
Expand Down
2 changes: 1 addition & 1 deletion core/src/inc/Provider/ProviderType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
export enum ProviderType {
sslcert = 'sslcert',
credential = 'credential'
};
}
9 changes: 9 additions & 0 deletions frontend/src/inc/Pages/Credential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ export class Credential extends BasePage {
this._credentialDialog.resetValues();
this._credentialDialog.setTitle('Credential Add');
this._credentialDialog.show();

const providers = await CredentialAPI.getProviderList();

this._credentialDialog.setProviders(providers.list);

return false;
}, 'btn btn-block btn-default btn-sm', IconFa.add);
}
Expand Down Expand Up @@ -129,6 +134,10 @@ export class Credential extends BasePage {
async(): Promise<void> => {
this._credentialDialog.resetValues();
this._credentialDialog.setTitle('Credential Edit');

const providers = await CredentialAPI.getProviderList();

this._credentialDialog.setProviders(providers.list);
},
IconFa.edit
);
Expand Down
24 changes: 23 additions & 1 deletion frontend/src/inc/Pages/Credential/CredentialEditModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Element,
SelectBottemBorderOnly2
} from 'bambooo';
import {CredentialSchemaTypes} from 'flyingfish_schemas/dist/src';
import {CredentialSchemaTypes, ProviderEntry} from 'flyingfish_schemas/dist/src';

/**
* Credential edit modal
Expand Down Expand Up @@ -73,4 +73,26 @@ export class CredentialEditModal extends ModalDialog {
return this._id;
}

/**
* setProviders
* @param providers
*/
public setProviders(providers: ProviderEntry[]): void {
this._selectProvider.clearValues();

this._selectProvider.addValue({
key: 'none',
value: 'Please select your provider'
});

for (const provider of providers) {
this._selectProvider.addValue({
key: provider.name,
value: provider.title
});
}

this._selectProvider.setSelectedValue('none');
}

}
6 changes: 3 additions & 3 deletions frontend/src/inc/Pages/DynDnsClient/DynDnsClientEditModal.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {DomainData, DynDnsClientDomain, DynDnsClientProvider} from 'flyingfish_schemas';
import {DomainData, DynDnsClientDomain, ProviderEntry} from 'flyingfish_schemas';
import {FormGroup, FormRow, InputBottemBorderOnly2, InputType, Multiple, SelectBottemBorderOnly2, Switch, Element,
ModalDialog, ModalDialogType} from 'bambooo';

Expand Down Expand Up @@ -112,9 +112,9 @@ export class DynDnsClientEditModal extends ModalDialog {

/**
* setProviders
* @param providers
* @param {ProviderEntry[]} providers
*/
public setProviders(providers: DynDnsClientProvider[]): void {
public setProviders(providers: ProviderEntry[]): void {
this._selectProvider.clearValues();

this._selectProvider.addValue({
Expand Down
5 changes: 2 additions & 3 deletions schemas/src/Backend/Routes/DynDnsClient/List.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {ExtractSchemaResultType, Vts} from 'vts';
import {SchemaDefaultReturn} from '../../../Core/Server/Routes/DefaultReturn.js';
import {SchemaDynDnsClientProvider} from './Providers.js';

import {SchemaProviderEntry} from '../../Provider/ProviderEntry.js';
/**
* DynDnsClientDomain
*/
Expand All @@ -21,7 +20,7 @@ export type DynDnsClientDomain = ExtractSchemaResultType<typeof SchemaDynDnsClie
export const SchemaDynDnsClientData = Vts.object({
id: Vts.number(),
domains: Vts.array(SchemaDynDnsClientDomain),
provider: SchemaDynDnsClientProvider,
provider: SchemaProviderEntry,
username: Vts.string(),
password: Vts.optional(Vts.string()),
update_domain: Vts.boolean(),
Expand Down
16 changes: 2 additions & 14 deletions schemas/src/Backend/Routes/DynDnsClient/Providers.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
import {ExtractSchemaResultType, Vts} from 'vts';
import {SchemaDefaultReturn} from '../../../Core/Server/Routes/DefaultReturn.js';

/**
* DynDnsClientProvider
*/
export const SchemaDynDnsClientProvider = Vts.object({
name: Vts.string(),
title: Vts.string()
});

/**
* DynDnsClientProvider
*/
export type DynDnsClientProvider = ExtractSchemaResultType<typeof SchemaDynDnsClientProvider>;
import {SchemaProviderEntry} from '../../Provider/ProviderEntry.js';

/**
* DynDnsClientProviderListResponse
*/
export const SchemaDynDnsClientProviderListResponse = SchemaDefaultReturn.extend({
list: Vts.array(SchemaDynDnsClientProvider)
list: Vts.array(SchemaProviderEntry)
});

/**
Expand Down
2 changes: 0 additions & 2 deletions schemas/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ export {
DynDnsClientDelete
} from './Backend/Routes/DynDnsClient/Delete.js';
export {
SchemaDynDnsClientProvider,
DynDnsClientProvider,
SchemaDynDnsClientProviderListResponse,
DynDnsClientProviderListResponse
} from './Backend/Routes/DynDnsClient/Providers.js';
Expand Down

0 comments on commit 202ab67

Please sign in to comment.