ui(admin): show alias in allocation dropdown; fixes #3434
This commit is contained in:
parent
9b7cea5d04
commit
34da772db7
|
@ -12,19 +12,29 @@ export interface Allocation {
|
||||||
relations: {
|
relations: {
|
||||||
server?: Server;
|
server?: Server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getDisplayText (): string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const rawDataToAllocation = ({ attributes }: FractalResponseData): Allocation => ({
|
export const rawDataToAllocation = ({ attributes }: FractalResponseData): Allocation => ({
|
||||||
id: attributes.id,
|
id: attributes.id,
|
||||||
ip: attributes.ip,
|
ip: attributes.ip,
|
||||||
port: attributes.port,
|
port: attributes.port,
|
||||||
alias: attributes.ip_alias || null,
|
alias: attributes.alias || null,
|
||||||
serverId: attributes.server_id,
|
serverId: attributes.server_id,
|
||||||
assigned: attributes.assigned,
|
assigned: attributes.assigned,
|
||||||
|
|
||||||
relations: {
|
relations: {
|
||||||
server: attributes.relationships?.server?.object === 'server' ? rawDataToServer(attributes.relationships.server as FractalResponseData) : undefined,
|
server: attributes.relationships?.server?.object === 'server' ? rawDataToServer(attributes.relationships.server as FractalResponseData) : undefined,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// TODO: If IP is an IPv6, wrap IP in [].
|
||||||
|
getDisplayText (): string {
|
||||||
|
if (attributes.alias !== null) {
|
||||||
|
return `${attributes.ip}:${attributes.port} (${attributes.alias})`;
|
||||||
|
}
|
||||||
|
return `${attributes.ip}:${attributes.port}`;
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export interface Filters {
|
export interface Filters {
|
||||||
|
|
|
@ -99,7 +99,7 @@ export function ServerAllocationsContainer ({ server }: { server: Server }) {
|
||||||
const loadOptions = async (inputValue: string, callback: (options: Option[]) => void) => {
|
const loadOptions = async (inputValue: string, callback: (options: Option[]) => void) => {
|
||||||
const allocations = await getAllocations(server.nodeId, { ip: inputValue, server_id: '0' });
|
const allocations = await getAllocations(server.nodeId, { ip: inputValue, server_id: '0' });
|
||||||
callback(allocations.map(a => {
|
callback(allocations.map(a => {
|
||||||
return { value: a.id.toString(), label: a.ip + ':' + a.port };
|
return { value: a.id.toString(), label: a.getDisplayText() };
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ export function ServerAllocationsContainer ({ server }: { server: Server }) {
|
||||||
name={'allocationId'}
|
name={'allocationId'}
|
||||||
>
|
>
|
||||||
{server.relations?.allocations?.map(a => (
|
{server.relations?.allocations?.map(a => (
|
||||||
<option key={a.id} value={a.id}>{a.ip}:{a.port}</option>
|
<option key={a.id} value={a.id}>{a.getDisplayText()}</option>
|
||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
|
@ -133,7 +133,7 @@ export function ServerAllocationsContainer ({ server }: { server: Server }) {
|
||||||
name={'removeAllocations'}
|
name={'removeAllocations'}
|
||||||
label={'Remove Allocations'}
|
label={'Remove Allocations'}
|
||||||
options={server.relations?.allocations?.map(a => {
|
options={server.relations?.allocations?.map(a => {
|
||||||
return { value: a.id.toString(), label: a.ip + ':' + a.port };
|
return { value: a.id.toString(), label: a.getDisplayText() };
|
||||||
}) || []}
|
}) || []}
|
||||||
isMulti
|
isMulti
|
||||||
isSearchable
|
isSearchable
|
||||||
|
|
Loading…
Reference in New Issue