Skip to content

Commit

Permalink
fix: links and add sorting for runtimes (#811)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephGit authored Dec 19, 2024
1 parent 6c60664 commit 12a93d1
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
5 changes: 4 additions & 1 deletion AMW_angular/io/src/app/servers/servers.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ export class ServersService extends BaseService {

servers: Signal<Server[]> = toSignal(this.reloadedServers, { initialValue: [] as Server[] });

private runtimes$ = this.http.get<Resource[]>(`${this.serversUrl}/runtimes`).pipe(catchError(this.handleError));
private runtimes$ = this.http
.get<Resource[]>(`${this.serversUrl}/runtimes`)
.pipe(catchError(this.handleError))
.pipe(map((data) => data.sort((a, b) => (a.name < b.name ? -1 : 1))));
runtimes: Signal<Resource[]> = toSignal(this.runtimes$);

private appServersSuggestions$ = this.http
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package ch.mobi.itc.mobiliar.rest.dtos;


import ch.puzzle.itc.mobiliar.business.server.entity.ServerTuple;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "appAppServer")
@XmlAccessorType(XmlAccessType.FIELD)
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ServerDTO {

private String host;
private String appServer;
private String appServerRelease;
private String runtime;
private String node;
private String nodeRelease;
private String environment;
private Integer appServerId;
private Integer nodeId;
private Integer environmentId;
private String domain;
private boolean definedOnNode;

public ServerDTO(ServerTuple serverTuple) {
this.host = serverTuple.getHost();
this.appServer = serverTuple.getAppServer();
this.appServerRelease = serverTuple.getAppServerRelease();
this.runtime = serverTuple.getRuntime();
this.node = serverTuple.getNode();
this.nodeRelease = serverTuple.getNodeRelease();
this.environment = serverTuple.getEnvironment();
this.appServerId = serverTuple.getAppServerId();
this.nodeId = serverTuple.getNodeId();
this.environmentId = serverTuple.getEnvironmentId();
this.domain = serverTuple.getDomain();
this.definedOnNode = serverTuple.isDefinedOnNode();
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package ch.mobi.itc.mobiliar.rest.servers;

import ch.mobi.itc.mobiliar.rest.dtos.ResourceGroupDTO;
import ch.mobi.itc.mobiliar.rest.dtos.ResourceTypeDTO;
import ch.mobi.itc.mobiliar.rest.dtos.ServerDTO;
import ch.puzzle.itc.mobiliar.business.resourcegroup.boundary.ResourceGroupLocator;
import ch.puzzle.itc.mobiliar.business.resourcegroup.control.ResourceGroupPersistenceService;
import ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ResourceGroupEntity;
import ch.puzzle.itc.mobiliar.business.server.boundary.GetServersUseCase;
import ch.puzzle.itc.mobiliar.business.server.boundary.ServerView;
import ch.puzzle.itc.mobiliar.business.server.entity.ServerTuple;
import ch.puzzle.itc.mobiliar.common.util.DefaultResourceTypeDefinition;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
Expand Down Expand Up @@ -76,6 +79,9 @@ public Response getServers(@QueryParam("environment") String environment,
@QueryParam("appServer") String appServer,
@QueryParam("host") String host,
@QueryParam("node") String node) {
return Response.status(OK).entity(serverView.getServers(host,appServer,runtime, node, environment,true)).build();

List<ServerDTO> servers = serverView.getServers(host,appServer,runtime, node, environment,true).stream().map(ServerDTO::new).collect(Collectors.toList());

return Response.status(OK).entity(servers).build();
}
}

0 comments on commit 12a93d1

Please sign in to comment.