Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return display name on /gateways #1123

Merged
merged 5 commits into from
Aug 14, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/controllers/v3/GatewayController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,25 @@ export class NamespaceController extends Controller {
}

/**
* @summary List of Gateway IDs
* @summary List of Gateways available to the user
* @param request
* @returns
*/
@Get()
@OperationId('gateway-list')
public async list(@Request() request: any): Promise<string[]> {
public async list(@Request() request: any): Promise<{ gatewayId: string, displayName: string }[]> {
rustyjux marked this conversation as resolved.
Show resolved Hide resolved
const result = await this.keystone.executeGraphQL({
context: this.keystone.createContext(request),
query: list,
});
logger.debug('Result %j', result);
return result.data.allNamespaces.map((ns: Namespace) => ns.name).sort();
}
type NamespaceInfo = { gatewayId: string, displayName: string };
return result.data.allNamespaces
.map((ns: Namespace) => ({ gatewayId: ns.name, displayName: ns.displayName }))
.sort((a: NamespaceInfo, b: NamespaceInfo) => {
const displayNameComparison = a.displayName.localeCompare(b.displayName);
return displayNameComparison !== 0 ? displayNameComparison : a.gatewayId.localeCompare(b.gatewayId);
}); }

/**
* Get details about the gateway, such as permissions for what the gateway is setup with.
Expand Down Expand Up @@ -281,6 +286,7 @@ const list = gql`
query Namespaces {
allNamespaces {
name
displayName
}
}
`;
Expand Down
Loading