-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#70 add new table, change credential request, add frontend page
- Loading branch information
Stefan Werfling
committed
Apr 29, 2024
1 parent
bfd8195
commit 24ecf9b
Showing
22 changed files
with
467 additions
and
37 deletions.
There are no files selected for viewing
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,26 @@ | ||
import {Router} from 'express'; | ||
import {DefaultRoute} from 'flyingfish_core'; | ||
import {List} from './Credential/List.js'; | ||
|
||
export class Credential extends DefaultRoute { | ||
|
||
/** | ||
* getExpressRouter | ||
*/ | ||
public getExpressRouter(): Router { | ||
this._get( | ||
'/json/credential/list', | ||
async( | ||
req, | ||
res | ||
) => { | ||
if (this.isUserLogin(req, res)) { | ||
res.status(200).json(List.getCredentials()); | ||
} | ||
} | ||
); | ||
|
||
return super.getExpressRouter(); | ||
} | ||
|
||
} |
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,26 @@ | ||
import {CredentialServiceDB} from 'flyingfish_core'; | ||
import {Credential, CredentialResponse, StatusCodes} from 'flyingfish_schemas'; | ||
|
||
export class List { | ||
|
||
public static async getCredentials(): Promise<CredentialResponse> { | ||
const credentials = await CredentialServiceDB.getInstance().findAll(); | ||
const list: Credential[] = []; | ||
|
||
for (const credential of credentials) { | ||
list.push({ | ||
id: credential.id, | ||
name: credential.name, | ||
provider: credential.provider, | ||
authSchemaType: credential.scheme, | ||
settings: credential.settings | ||
}); | ||
} | ||
|
||
return { | ||
statusCode: StatusCodes.OK, | ||
list: list | ||
}; | ||
} | ||
|
||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import {Column, Entity, Index} from 'typeorm'; | ||
import {DBBaseEntityId} from '../DBBaseEntityId.js'; | ||
|
||
/** | ||
* Credential location a N to N | ||
*/ | ||
@Entity({name: 'credential_location'}) | ||
export class CredentialLocation extends DBBaseEntityId { | ||
|
||
/** | ||
* Id from credential | ||
*/ | ||
@Index() | ||
@Column() | ||
public credential_id!: number; | ||
|
||
/** | ||
* Id from location | ||
*/ | ||
@Index() | ||
@Column() | ||
public location_id!: number; | ||
|
||
/** | ||
* Position for fallback | ||
*/ | ||
@Column() | ||
public position!: number; | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
core/src/inc/Db/MariaDb/Service/CredentialLocationService.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,38 @@ | ||
import {DBService} from '../DBService.js'; | ||
import {CredentialLocation} from '../Entity/CredentialLocation.js'; | ||
|
||
export class CredentialLocationService extends DBService<CredentialLocation> { | ||
|
||
/** | ||
* register name | ||
*/ | ||
public static REGISTER_NAME = 'credential_location'; | ||
|
||
/** | ||
* getInstance | ||
*/ | ||
public static getInstance(): CredentialLocationService { | ||
return DBService.getSingleInstance( | ||
CredentialLocationService, | ||
CredentialLocation, | ||
CredentialLocationService.REGISTER_NAME | ||
); | ||
} | ||
|
||
/** | ||
* getListByLocation | ||
* @param {number} locationId | ||
* @returns {CredentialLocation[]} | ||
*/ | ||
public async getListByLocation(locationId: number): Promise<CredentialLocation[]> { | ||
return this._repository.find({ | ||
where: { | ||
location_id: locationId | ||
}, | ||
order: { | ||
position: 'ASC' | ||
} | ||
}); | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {CredentialResponse, SchemaCredentialResponse} from 'flyingfish_schemas/dist/src'; | ||
import {NetFetch} from '../Net/NetFetch'; | ||
|
||
export class Credential { | ||
|
||
public static async getList(): Promise<CredentialResponse> { | ||
return NetFetch.getData('/json/credential/list', SchemaCredentialResponse); | ||
} | ||
|
||
} |
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 |
---|---|---|
|
@@ -42,4 +42,5 @@ export class Dashboard { | |
|
||
return true; | ||
} | ||
|
||
} |
Oops, something went wrong.