diff --git a/build.gradle b/build.gradle index 03e60097..dc489edc 100644 --- a/build.gradle +++ b/build.gradle @@ -243,7 +243,7 @@ dependencies { compile "org.jdom:jdom2:2.0.6" compile "org.springframework:spring-websocket:5.0.7.RELEASE" compile "org.springframework.security:spring-security-messaging:5.0.7.RELEASE" - // compile "io.hawt:hawtio-springboot:2.4.0" + compile "io.hawt:hawtio-springboot:2.4.0" // end custom dependencies diff --git a/src/main/java/org/assimbly/gateway/event/FailureListener.java b/src/main/java/org/assimbly/gateway/event/FailureListener.java index 17cef0d5..0214ed82 100644 --- a/src/main/java/org/assimbly/gateway/event/FailureListener.java +++ b/src/main/java/org/assimbly/gateway/event/FailureListener.java @@ -10,7 +10,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.messaging.simp.SimpMessageSendingOperations; import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; // This class listens to failure events in camel exchanges (routes) and send them to the websocket topic: topic/alert // Check the following page for all EventObject instances of Camel: http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/management/event/package-summary.html @@ -22,27 +21,29 @@ public class FailureListener extends EventNotifierSupport { @Autowired private SimpMessageSendingOperations messagingTemplate; + +private String flowId; public void notify(EventObject eventObject) throws Exception { if (eventObject instanceof ExchangeFailureHandledEvent) { ExchangeFailureHandledEvent exchangeFailedEvent = (ExchangeFailureHandledEvent) eventObject; - String flowId = exchangeFailedEvent.getExchange().getFromRouteId(); + flowId = exchangeFailedEvent.getExchange().getFromRouteId(); if(this.messagingTemplate!=null) { - this.messagingTemplate.convertAndSend("/topic/" + flowId + "/alert", flowId); + this.messagingTemplate.convertAndSend("/topic/" + flowId + "/alert","alert:" + flowId); }else { log.warn("Can't send alert to websocket. messagingTemplate=null"); } - }if (eventObject instanceof ExchangeFailedEvent) { + }else if (eventObject instanceof ExchangeFailedEvent) { ExchangeFailedEvent exchangeFailedEvent = (ExchangeFailedEvent) eventObject; - String flowId = exchangeFailedEvent.getExchange().getFromRouteId(); + flowId = exchangeFailedEvent.getExchange().getFromRouteId(); if(this.messagingTemplate!=null) { - this.messagingTemplate.convertAndSend("/topic/" + flowId + "/alert", flowId); + this.messagingTemplate.convertAndSend("/topic/" + flowId + "/alert","alert:" + flowId); }else { log.warn("Can't send alert to websocket. messagingTemplate=null"); } diff --git a/src/main/java/org/assimbly/gateway/service/EnvironmentVariablesService.java b/src/main/java/org/assimbly/gateway/service/EnvironmentVariablesService.java index 8521bc8b..daa2947c 100644 --- a/src/main/java/org/assimbly/gateway/service/EnvironmentVariablesService.java +++ b/src/main/java/org/assimbly/gateway/service/EnvironmentVariablesService.java @@ -1,6 +1,10 @@ package org.assimbly.gateway.service; import org.assimbly.gateway.service.dto.EnvironmentVariablesDTO; +import org.assimbly.gateway.service.dto.FlowDTO; +import org.assimbly.gateway.service.dto.HeaderDTO; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import java.util.List; import java.util.Optional; @@ -23,8 +27,7 @@ public interface EnvironmentVariablesService { * * @return the list of entities */ - List findAll(); - + Page findAll(Pageable pageable); /** * Get the "id" environmentVariables. diff --git a/src/main/java/org/assimbly/gateway/service/HeaderService.java b/src/main/java/org/assimbly/gateway/service/HeaderService.java index 900b20cf..4ba628f0 100644 --- a/src/main/java/org/assimbly/gateway/service/HeaderService.java +++ b/src/main/java/org/assimbly/gateway/service/HeaderService.java @@ -1,6 +1,9 @@ package org.assimbly.gateway.service; +import org.assimbly.gateway.service.dto.FlowDTO; import org.assimbly.gateway.service.dto.HeaderDTO; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import java.util.List; import java.util.Optional; @@ -23,7 +26,8 @@ public interface HeaderService { * * @return the list of entities */ - List findAll(); + Page findAll(Pageable pageable); + /** diff --git a/src/main/java/org/assimbly/gateway/service/ServiceService.java b/src/main/java/org/assimbly/gateway/service/ServiceService.java index 020e64f3..d2b4bda8 100644 --- a/src/main/java/org/assimbly/gateway/service/ServiceService.java +++ b/src/main/java/org/assimbly/gateway/service/ServiceService.java @@ -1,6 +1,9 @@ package org.assimbly.gateway.service; +import org.assimbly.gateway.service.dto.FlowDTO; import org.assimbly.gateway.service.dto.ServiceDTO; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import java.util.List; import java.util.Optional; @@ -23,7 +26,7 @@ public interface ServiceService { * * @return the list of entities */ - List findAll(); + Page findAll(Pageable pageable); /** diff --git a/src/main/java/org/assimbly/gateway/service/impl/EnvironmentVariablesServiceImpl.java b/src/main/java/org/assimbly/gateway/service/impl/EnvironmentVariablesServiceImpl.java index 5a7afcf6..4aa7d642 100644 --- a/src/main/java/org/assimbly/gateway/service/impl/EnvironmentVariablesServiceImpl.java +++ b/src/main/java/org/assimbly/gateway/service/impl/EnvironmentVariablesServiceImpl.java @@ -7,14 +7,12 @@ import org.assimbly.gateway.service.mapper.EnvironmentVariablesMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.LinkedList; -import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; /** * Service Implementation for managing EnvironmentVariables. @@ -54,16 +52,16 @@ public EnvironmentVariablesDTO save(EnvironmentVariablesDTO environmentVariables * * @return the list of entities */ + @Override @Transactional(readOnly = true) - public List findAll() { - log.debug("Request to get all EnvironmentVariables"); - return environmentVariablesRepository.findAll().stream() - .map(environmentVariablesMapper::toDto) - .collect(Collectors.toCollection(LinkedList::new)); + public Page findAll(Pageable pageable) { + log.debug("Request to get all Environment variables"); + return environmentVariablesRepository.findAll(pageable) + .map(environmentVariablesMapper::toDto); } - + /** * Get one environmentVariables by id. * diff --git a/src/main/java/org/assimbly/gateway/service/impl/HeaderServiceImpl.java b/src/main/java/org/assimbly/gateway/service/impl/HeaderServiceImpl.java index dc735441..0bbbd54c 100644 --- a/src/main/java/org/assimbly/gateway/service/impl/HeaderServiceImpl.java +++ b/src/main/java/org/assimbly/gateway/service/impl/HeaderServiceImpl.java @@ -3,11 +3,13 @@ import org.assimbly.gateway.service.HeaderService; import org.assimbly.gateway.domain.Header; import org.assimbly.gateway.repository.HeaderRepository; +import org.assimbly.gateway.service.dto.EnvironmentVariablesDTO; import org.assimbly.gateway.service.dto.HeaderDTO; import org.assimbly.gateway.service.mapper.HeaderMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -48,22 +50,15 @@ public HeaderDTO save(HeaderDTO headerDTO) { header = headerRepository.save(header); return headerMapper.toDto(header); } - - /** - * Get all the headers. - * - * @return the list of entities - */ + @Override @Transactional(readOnly = true) - public List findAll() { + public Page findAll(Pageable pageable) { log.debug("Request to get all Headers"); - return headerRepository.findAll().stream() - .map(headerMapper::toDto) - .collect(Collectors.toCollection(LinkedList::new)); + return headerRepository.findAll(pageable) + .map(headerMapper::toDto); } - /** * Get one header by id. * diff --git a/src/main/java/org/assimbly/gateway/service/impl/ServiceServiceImpl.java b/src/main/java/org/assimbly/gateway/service/impl/ServiceServiceImpl.java index 96fec825..df10a4d8 100644 --- a/src/main/java/org/assimbly/gateway/service/impl/ServiceServiceImpl.java +++ b/src/main/java/org/assimbly/gateway/service/impl/ServiceServiceImpl.java @@ -2,11 +2,13 @@ import org.assimbly.gateway.service.ServiceService; import org.assimbly.gateway.repository.ServiceRepository; +import org.assimbly.gateway.service.dto.HeaderDTO; import org.assimbly.gateway.service.dto.ServiceDTO; import org.assimbly.gateway.service.mapper.ServiceMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -47,22 +49,15 @@ public ServiceDTO save(ServiceDTO serviceDTO) { service = serviceRepository.save(service); return serviceMapper.toDto(service); } - - /** - * Get all the services. - * - * @return the list of entities - */ + @Override @Transactional(readOnly = true) - public List findAll() { - log.debug("Request to get all Services"); - return serviceRepository.findAll().stream() - .map(serviceMapper::toDto) - .collect(Collectors.toCollection(LinkedList::new)); + public Page findAll(Pageable pageable) { + log.debug("Request to get all Headers"); + return serviceRepository.findAll(pageable) + .map(serviceMapper::toDto); } - /** * Get one service by id. * diff --git a/src/main/java/org/assimbly/gateway/web/rest/ConnectorResource.java b/src/main/java/org/assimbly/gateway/web/rest/ConnectorResource.java index a636844e..65b3b8e7 100644 --- a/src/main/java/org/assimbly/gateway/web/rest/ConnectorResource.java +++ b/src/main/java/org/assimbly/gateway/web/rest/ConnectorResource.java @@ -8,6 +8,7 @@ import org.assimbly.gateway.web.rest.util.ResponseUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; +import org.springframework.messaging.simp.SimpMessageSendingOperations; import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.NativeWebRequest; @@ -44,7 +45,10 @@ public class ConnectorResource { @Autowired FailureListener failureListener; - + + @Autowired + private SimpMessageSendingOperations messagingTemplate; + public ConnectorResource() {} //configure connector (by gatewayid) @@ -224,16 +228,30 @@ public ResponseEntity setMaintenance(@ApiParam(hidden = true) @RequestHe try { + //pass spring variable into new Thread (outside of Spring context) + final SimpMessageSendingOperations messagingTemplate2 = messagingTemplate; + Thread thread = new Thread(new Runnable() - { - public void run() + { + + SimpMessageSendingOperations messagingTemplate = messagingTemplate2; + + public void run() { + try { for(Long id : ids) { flowId = id.toString(); status = connector.getFlowStatus(flowId); if(status.equals("started")) { - connector.pauseFlow(flowId); + status = connector.pauseFlow(flowId); + if(status.equals("suspended") || status.equals("stopped")) { + if(this.messagingTemplate!=null) { + this.messagingTemplate.convertAndSend("/topic/" + flowId + "/event","event:suspended"); + } + }else { + throw new Exception(status); + } } } @@ -244,7 +262,11 @@ public void run() flowId = id.toString(); status = connector.getFlowStatus(flowId); if(status.equals("suspended")) { - connector.resumeFlow(flowId); + if(status.equals("started")) { + if(this.messagingTemplate!=null) { + this.messagingTemplate.convertAndSend("/topic/" + flowId + "/event","event:resumed"); + } + } } } @@ -340,6 +362,9 @@ public ResponseEntity startflow(@ApiParam(hidden = true) @RequestHeader( flowId = id.toString(); status = connector.startFlow(flowId); if(status.equals("started")) { + if(this.messagingTemplate!=null) { + this.messagingTemplate.convertAndSend("/topic/" + flowId + "/event","event:started"); + } return ResponseUtil.createSuccessResponseWithHeaders(connectorId, mediaType,"/connector/{connectorId}/flow/start/{id}","started flow " + flowId,"started flow " + flowId,flowId); }else { throw new Exception(status); @@ -360,6 +385,9 @@ public ResponseEntity stopflow(@ApiParam(hidden = true) @RequestHeader( flowId = id.toString(); status = connector.stopFlow(flowId); if(status.equals("stopped")) { + if(this.messagingTemplate!=null) { + this.messagingTemplate.convertAndSend("/topic/" + flowId + "/event","event:stopped"); + } return ResponseUtil.createSuccessResponseWithHeaders(connectorId, mediaType,"/connector/{connectorId}/flow/stop/{id}","stopped flow " + flowId,"stopped flow " + flowId,flowId); }else { throw new Exception(status); @@ -380,6 +408,9 @@ public ResponseEntity restartflow(@ApiParam(hidden = true) @RequestHead flowId = id.toString(); status = connector.restartFlow(flowId); if(status.equals("started")) { + if(this.messagingTemplate!=null) { + this.messagingTemplate.convertAndSend("/topic/" + flowId + "/event","event:restarted"); + } return ResponseUtil.createSuccessResponseWithHeaders(connectorId, mediaType,"/connector/{connectorId}/flow/restart/{id}","restarted","restarted flow " + flowId,flowId); }else { throw new Exception(status); @@ -400,6 +431,9 @@ public ResponseEntity pauseflow(@ApiParam(hidden = true) @RequestHeader flowId = id.toString(); status = connector.pauseFlow(flowId); if(status.equals("suspended") || status.equals("stopped")) { + if(this.messagingTemplate!=null) { + this.messagingTemplate.convertAndSend("/topic/" + flowId + "/event","event:suspended"); + } return ResponseUtil.createSuccessResponseWithHeaders(connectorId, mediaType,"/connector/{connectorId}/flow/pause/{id}","paused","paused flow " + flowId,flowId); }else { throw new Exception(status); @@ -420,6 +454,9 @@ public ResponseEntity resumeflow(@ApiParam(hidden = true) @RequestHeader flowId = id.toString(); status = connector.resumeFlow(flowId); if(status.equals("started")) { + if(this.messagingTemplate!=null) { + this.messagingTemplate.convertAndSend("/topic/" + flowId + "/event","event:resumed"); + } return ResponseUtil.createSuccessResponseWithHeaders(connectorId, mediaType,"/connector/{connectorId}/flow/resume/{id}","resumed","resumed flow " + flowId,flowId); }else { throw new Exception(status); diff --git a/src/main/java/org/assimbly/gateway/web/rest/EnvironmentResource.java b/src/main/java/org/assimbly/gateway/web/rest/EnvironmentResource.java index 2e123c81..2935f40a 100644 --- a/src/main/java/org/assimbly/gateway/web/rest/EnvironmentResource.java +++ b/src/main/java/org/assimbly/gateway/web/rest/EnvironmentResource.java @@ -39,10 +39,10 @@ public class EnvironmentResource { */ @PostMapping(path = "/environment/{gatewayid}", consumes = {"text/plain","application/xml", "application/json"}, produces = {"text/plain","application/xml", "application/json"}) @Timed - public ResponseEntity setGatewayConfiguration(@ApiParam(hidden = true) @RequestHeader("Accept") String mediaType, @PathVariable Long gatewayid, @RequestBody String configuration) throws Exception { + public ResponseEntity setGatewayConfiguration(@ApiParam(hidden = true) @RequestHeader("Accept") String mediaType,@ApiParam(hidden = true) @RequestHeader("Content-Type") String contentType, @PathVariable Long gatewayid, @RequestBody String configuration) throws Exception { try { - DBConfiguration.convertConfigurationToDB(gatewayid, mediaType, configuration); + DBConfiguration.convertConfigurationToDB(gatewayid, contentType, configuration); return ResponseUtil.createSuccessResponse(gatewayid, mediaType, "setConfiguration", "Connector configuration set"); } catch (Exception e) { return ResponseUtil.createFailureResponse(gatewayid, mediaType, "setConfiguration", e.getMessage()); diff --git a/src/main/java/org/assimbly/gateway/web/rest/EnvironmentVariablesResource.java b/src/main/java/org/assimbly/gateway/web/rest/EnvironmentVariablesResource.java index 3895bf4c..2aa8e894 100644 --- a/src/main/java/org/assimbly/gateway/web/rest/EnvironmentVariablesResource.java +++ b/src/main/java/org/assimbly/gateway/web/rest/EnvironmentVariablesResource.java @@ -4,10 +4,15 @@ import org.assimbly.gateway.service.EnvironmentVariablesService; import org.assimbly.gateway.web.rest.errors.BadRequestAlertException; import org.assimbly.gateway.web.rest.util.HeaderUtil; +import org.assimbly.gateway.web.rest.util.PaginationUtil; import org.assimbly.gateway.service.dto.EnvironmentVariablesDTO; + import io.github.jhipster.web.util.ResponseUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -83,11 +88,15 @@ public ResponseEntity updateEnvironmentVariables(@Reque */ @GetMapping("/environment-variables") @Timed - public List getAllEnvironmentVariables() { + public ResponseEntity> getAllEnvironmentVariables(Pageable pageable) { log.debug("REST request to get all EnvironmentVariables"); - return environmentVariablesService.findAll(); - } + Page page = environmentVariablesService.findAll(pageable); + HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/environment-variables"); + return ResponseEntity.ok().headers(headers).body(page.getContent()); + } + + /** * GET /environment-variables/:id : get the "id" environmentVariables. * diff --git a/src/main/java/org/assimbly/gateway/web/rest/FlowResource.java b/src/main/java/org/assimbly/gateway/web/rest/FlowResource.java index f84eae16..213aae63 100644 --- a/src/main/java/org/assimbly/gateway/web/rest/FlowResource.java +++ b/src/main/java/org/assimbly/gateway/web/rest/FlowResource.java @@ -14,18 +14,13 @@ import org.springframework.data.domain.Sort; import org.springframework.data.web.SortDefault; import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.net.URI; import java.net.URISyntaxException; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; import java.util.List; import java.util.Optional; -import java.util.Set; /** * REST controller for managing flow. diff --git a/src/main/java/org/assimbly/gateway/web/rest/HeaderResource.java b/src/main/java/org/assimbly/gateway/web/rest/HeaderResource.java index 5a3110ec..16885efa 100644 --- a/src/main/java/org/assimbly/gateway/web/rest/HeaderResource.java +++ b/src/main/java/org/assimbly/gateway/web/rest/HeaderResource.java @@ -4,10 +4,16 @@ import org.assimbly.gateway.service.HeaderService; import org.assimbly.gateway.web.rest.errors.BadRequestAlertException; import org.assimbly.gateway.web.rest.util.HeaderUtil; +import org.assimbly.gateway.web.rest.util.PaginationUtil; import org.assimbly.gateway.service.dto.HeaderDTO; +import org.assimbly.gateway.service.dto.ServiceDTO; + import io.github.jhipster.web.util.ResponseUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -83,9 +89,12 @@ public ResponseEntity updateHeader(@RequestBody HeaderDTO headerDTO) */ @GetMapping("/headers") @Timed - public List getAllHeaders() { + public ResponseEntity> getAllHeaders(Pageable pageable) { log.debug("REST request to get all Headers"); - return headerService.findAll(); + Page page = headerService.findAll(pageable); + HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/headers"); + return ResponseEntity.ok().headers(headers).body(page.getContent()); + } /** diff --git a/src/main/java/org/assimbly/gateway/web/rest/ServiceResource.java b/src/main/java/org/assimbly/gateway/web/rest/ServiceResource.java index 3849be63..09f2de25 100644 --- a/src/main/java/org/assimbly/gateway/web/rest/ServiceResource.java +++ b/src/main/java/org/assimbly/gateway/web/rest/ServiceResource.java @@ -4,10 +4,15 @@ import org.assimbly.gateway.service.ServiceService; import org.assimbly.gateway.web.rest.errors.BadRequestAlertException; import org.assimbly.gateway.web.rest.util.HeaderUtil; +import org.assimbly.gateway.web.rest.util.PaginationUtil; +import org.assimbly.gateway.service.dto.FlowDTO; import org.assimbly.gateway.service.dto.ServiceDTO; import io.github.jhipster.web.util.ResponseUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -83,9 +88,11 @@ public ResponseEntity updateService(@RequestBody ServiceDTO serviceD */ @GetMapping("/services") @Timed - public List getAllServices() { + public ResponseEntity> getAllServices(Pageable pageable) { log.debug("REST request to get all Services"); - return serviceService.findAll(); + Page page = serviceService.findAll(pageable); + HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/services"); + return ResponseEntity.ok().headers(headers).body(page.getContent()); } /** diff --git a/src/main/webapp/app/entities/environment-variables/environment-variables.component.html b/src/main/webapp/app/entities/environment-variables/environment-variables.component.html index e962b9c8..6f008910 100644 --- a/src/main/webapp/app/entities/environment-variables/environment-variables.component.html +++ b/src/main/webapp/app/entities/environment-variables/environment-variables.component.html @@ -12,12 +12,15 @@

- - - - - - + + + + + + diff --git a/src/main/webapp/app/entities/environment-variables/environment-variables.component.ts b/src/main/webapp/app/entities/environment-variables/environment-variables.component.ts index a997b24e..bf24ef97 100644 --- a/src/main/webapp/app/entities/environment-variables/environment-variables.component.ts +++ b/src/main/webapp/app/entities/environment-variables/environment-variables.component.ts @@ -12,19 +12,32 @@ import { EnvironmentVariablesService } from './environment-variables.service'; templateUrl: './environment-variables.component.html' }) export class EnvironmentVariablesComponent implements OnInit, OnDestroy { + environmentVariables: IEnvironmentVariables[]; currentAccount: any; eventSubscriber: Subscription; + //sorting + predicate: any; + reverse: any; + page: any; + constructor( protected environmentVariablesService: EnvironmentVariablesService, protected jhiAlertService: JhiAlertService, protected eventManager: JhiEventManager, protected accountService: AccountService - ) {} + ) { + this.page = 0; + this.predicate = 'key'; + this.reverse = true; + } loadAll() { - this.environmentVariablesService.query().subscribe( + this.environmentVariablesService.query({ + page: this.page, + sort: this.sort() + }).subscribe( (res: HttpResponse) => { this.environmentVariables = res.body; }, @@ -33,10 +46,10 @@ export class EnvironmentVariablesComponent implements OnInit, OnDestroy { } ngOnInit() { - this.loadAll(); this.accountService.identity().then(account => { this.currentAccount = account; }); + this.loadAll(); this.registerChangeInEnvironmentVariables(); } @@ -55,4 +68,19 @@ export class EnvironmentVariablesComponent implements OnInit, OnDestroy { protected onError(errorMessage: string) { this.jhiAlertService.error(errorMessage, null, null); } + + sort() { + const result = [this.predicate + ',' + (this.reverse ? 'asc' : 'desc')]; + if (this.predicate !== 'key') { + result.push('key'); + } + return result; + } + + reset() { + this.page = 0; + this.environmentVariables = []; + this.loadAll(); + } + } diff --git a/src/main/webapp/app/entities/flow/flow-row.component.ts b/src/main/webapp/app/entities/flow/flow-row.component.ts index 6e41d20a..031e31d8 100644 --- a/src/main/webapp/app/entities/flow/flow-row.component.ts +++ b/src/main/webapp/app/entities/flow/flow-row.component.ts @@ -103,17 +103,18 @@ export class FlowRowComponent implements OnInit, OnDestroy { this.registerTriggeredAction(); this.connection = this.flowService.connectionStomp(); this.stompClient = this.flowService.client(); - this.subscribe(); + this.subscribe('alert'); + this.subscribe('event'); this.receive().subscribe(data => { - console.log('data'); - console.log(data); - console.log(this.flow.id); - if (this.flow.id === data) { - this.getFlowNumberOfAlerts(data); + const data2 = data.split(':'); + if(data2[0]==='event'){ + this.setFlowStatus(data2[1]) + }else if(data2[0]==='alert'){ + if (this.flow.id === data2[1]) { + this.getFlowNumberOfAlerts(data[1]); + } } - }); - } ngOnDestroy() { @@ -427,7 +428,7 @@ export class FlowRowComponent implements OnInit, OnDestroy { this.flowService.setConfiguration(this.flow.id, data.body).subscribe(data2 => { this.flowService.start(this.flow.id).subscribe(response => { if (response.status === 200) { - this.setFlowStatus('started'); + //this.setFlowStatus('started'); } this.disableActionBtns = false; }, (err) => { @@ -435,7 +436,7 @@ export class FlowRowComponent implements OnInit, OnDestroy { this.isFlowStatusOK = false; this.flowStatusError = `Flow with id=${this.flow.id} is not started.`; this.disableActionBtns = false; - }); + }); }) }, (err) => { this.flowConfigurationNotObtained(this.flow.id); @@ -450,7 +451,7 @@ export class FlowRowComponent implements OnInit, OnDestroy { this.disableActionBtns = true; this.flowService.pause(this.flow.id).subscribe((response) => { if (response.status === 200) { - this.setFlowStatus('suspended'); + // this.setFlowStatus('suspended'); } this.disableActionBtns = false; }, (err) => { @@ -470,7 +471,7 @@ export class FlowRowComponent implements OnInit, OnDestroy { this.flowService.setConfiguration(this.flow.id, data.body).subscribe(data2 => { this.flowService.resume(this.flow.id).subscribe(response => { if (response.status === 200) { - this.setFlowStatus('resumed'); + // this.setFlowStatus('resumed'); } this.disableActionBtns = false; }, (err) => { @@ -496,7 +497,7 @@ export class FlowRowComponent implements OnInit, OnDestroy { this.flowService.setConfiguration(this.flow.id, data.body).subscribe(data2 => { this.flowService.restart(this.flow.id).subscribe(response => { if (response.status === 200) { - this.setFlowStatus('restarted'); + // this.setFlowStatus('restarted'); } this.disableActionBtns = false; }, (err) => { @@ -519,7 +520,7 @@ export class FlowRowComponent implements OnInit, OnDestroy { this.flowService.stop(this.flow.id).subscribe((response) => { if (response.status === 200) { - this.setFlowStatus('stopped'); + // this.setFlowStatus('stopped'); } this.disableActionBtns = false; }, (err) => { @@ -534,15 +535,15 @@ export class FlowRowComponent implements OnInit, OnDestroy { return this.listener; } - subscribe() { - const topic = '/topic/' + this.flow.id + '/alert'; + subscribe(type) { + const topic = '/topic/' + this.flow.id + '/' + type; this.connection.then(() => { this.subscriber = this.stompClient.subscribe(topic, data => { if(!this.listenerObserver){ this.listener = this.createListener(); } - this.listenerObserver.next(JSON.parse(data.body)); + this.listenerObserver.next(data.body); }); }); } diff --git a/src/main/webapp/app/entities/gateway/gateway-import-dialog.component.ts b/src/main/webapp/app/entities/gateway/gateway-import-dialog.component.ts index f4279108..f8b3525c 100644 --- a/src/main/webapp/app/entities/gateway/gateway-import-dialog.component.ts +++ b/src/main/webapp/app/entities/gateway/gateway-import-dialog.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit, OnDestroy, AfterContentInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; - +import { JhiEventManager, JhiAlertService } from 'ng-jhipster'; import { GatewayService } from './gateway.service'; import { IGateway } from 'app/shared/model/gateway.model'; import { GatewayPopupService } from "app/entities/gateway"; @@ -20,6 +20,7 @@ export class GatewayImportDialogComponent implements AfterContentInit { importError = false; constructor( + private eventManager: JhiEventManager, private gatewayService: GatewayService, public activeModal: NgbActiveModal ) { @@ -48,6 +49,8 @@ export class GatewayImportDialogComponent implements AfterContentInit { importConfiguration() { this.gatewayService.setGatewayConfiguration(this.gatewayId, this.xmlConfiguration).subscribe( r => { + this.importError = false; + this.eventManager.broadcast({ name: 'gatewayListModification', content: 'OK' }); this.activeModal.dismiss(true); }, err => { diff --git a/src/main/webapp/app/entities/gateway/gateway.component.html b/src/main/webapp/app/entities/gateway/gateway.component.html index 850dad0a..f190e03a 100644 --- a/src/main/webapp/app/entities/gateway/gateway.component.html +++ b/src/main/webapp/app/entities/gateway/gateway.component.html @@ -15,7 +15,7 @@


-

IDKeyValueGateway
ID + Key + + ValueGateway
- - + - - + + - - + - - +
+
Flow name + Flow + + Time
+
{{flow.name}} + {{flow.name}}
{{messageFlow}} {{maintenanceTimers[i]}}
diff --git a/src/main/webapp/app/entities/maintenance/maintenance.component.ts b/src/main/webapp/app/entities/maintenance/maintenance.component.ts index 98c66cb8..32ba0088 100644 --- a/src/main/webapp/app/entities/maintenance/maintenance.component.ts +++ b/src/main/webapp/app/entities/maintenance/maintenance.component.ts @@ -29,17 +29,29 @@ export class MaintenanceComponent implements OnInit, OnDestroy { maintenanceTimers: Array = []; timeLeft: Array = []; disableFlows: Array = []; - + + //sorting + page: any; + predicate: any; + reverse: any; + constructor( protected maintenanceService: MaintenanceService, protected flowService: FlowService, protected jhiAlertService: JhiAlertService, protected eventManager: JhiEventManager, protected accountService: AccountService - ) {} + ) { + this.page = 0; + this.predicate = 'name'; + this.reverse = true; + } loadAll() { - this.flowService.query().subscribe( + this.flowService.query({ + page: this.page, + sort: this.sort() + }).subscribe( (res: HttpResponse) => { this.flows = res.body }, @@ -130,4 +142,18 @@ export class MaintenanceComponent implements OnInit, OnDestroy { e.currentTarget.checked ? this.selectedFlows[i] = flow : this.selectedFlows[i] = null; this.allSelected = JSON.stringify(this.selectedFlows) === JSON.stringify(this.flows); } + + sort() { + const result = [this.predicate + ',' + (this.reverse ? 'asc' : 'desc')]; + if (this.predicate !== 'name') { + result.push('name'); + } + return result; + } + + reset() { + this.page = 0; + this.flows = []; + this.loadAll(); + } } diff --git a/src/main/webapp/app/entities/service/service-all.component.ts b/src/main/webapp/app/entities/service/service-all.component.ts index e9a5926b..e5a9cc17 100644 --- a/src/main/webapp/app/entities/service/service-all.component.ts +++ b/src/main/webapp/app/entities/service/service-all.component.ts @@ -21,11 +21,14 @@ export class ServiceAllComponent implements OnInit, OnDestroy { reverse: any; constructor( - protected serviceService: ServiceService, + protected serviceService: ServiceService, protected jhiAlertService: JhiAlertService, protected eventManager: JhiEventManager, protected accountService: AccountService ) { + this.page = 0; + this.predicate = 'name'; + this.reverse = true; } ngOnInit() { @@ -33,12 +36,6 @@ export class ServiceAllComponent implements OnInit, OnDestroy { this.registerChangeInServices(); } - reset() { - this.page = 0; - this.services = []; - this.loadAllServices(); - } - ngOnDestroy() { this.eventManager.destroy(this.eventSubscriber); } @@ -52,7 +49,10 @@ export class ServiceAllComponent implements OnInit, OnDestroy { this.currentAccount = account; }); this.isAdmin = this.accountService.isAdmin(); - this.serviceService.query().subscribe( + this.serviceService.query({ + page: this.page, + sort: this.sort() + }).subscribe( (res) => { this.services = res.body; }, @@ -63,4 +63,20 @@ export class ServiceAllComponent implements OnInit, OnDestroy { private onError(error) { this.jhiAlertService.error(error.message, null, null); } + + sort() { + const result = [this.predicate + ',' + (this.reverse ? 'asc' : 'desc')]; + if (this.predicate !== 'name') { + result.push('name'); + } + return result; + } + + reset() { + this.page = 0; + this.services = []; + this.loadAllServices(); + } + + } diff --git a/src/main/webapp/app/entities/service/service.service.ts b/src/main/webapp/app/entities/service/service.service.ts index 59ee42c3..ea12bb01 100644 --- a/src/main/webapp/app/entities/service/service.service.ts +++ b/src/main/webapp/app/entities/service/service.service.ts @@ -26,11 +26,12 @@ export class ServiceService { find(id: number): Observable { return this.http.get(`${this.resourceUrl}/${id}`, { observe: 'response' }); } - + query(req?: any): Observable { const options = createRequestOption(req); return this.http.get(this.resourceUrl, { params: options, observe: 'response' }); } + delete(id: number): Observable> { return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' });