feat: Add API to get template filters (#12969)
Adds a new API to get available filters for application templates from Appsmith cloud services. It acts as a proxy to the API.
This commit is contained in:
parent
d14d8d356e
commit
15394207a5
|
|
@ -40,6 +40,12 @@ public class ApplicationTemplateControllerCE {
|
|||
.map(templates -> new ResponseDTO<>(HttpStatus.OK.value(), templates, null));
|
||||
}
|
||||
|
||||
@GetMapping("filters")
|
||||
public Mono<ResponseDTO<ApplicationTemplate>> getFilters() {
|
||||
return applicationTemplateService.getFilters()
|
||||
.map(filters -> new ResponseDTO<>(HttpStatus.OK.value(), filters, null));
|
||||
}
|
||||
|
||||
@PostMapping("{templateId}/import/{organizationId}")
|
||||
public Mono<ResponseDTO<Application>> importApplicationFromTemplate(@PathVariable String templateId,
|
||||
@PathVariable String organizationId) {
|
||||
|
|
|
|||
|
|
@ -10,4 +10,5 @@ public interface ApplicationTemplateServiceCE {
|
|||
Flux<ApplicationTemplate> getSimilarTemplates(String templateId);
|
||||
Mono<ApplicationTemplate> getTemplateDetails(String templateId);
|
||||
Mono<Application> importApplicationFromTemplate(String templateId, String organizationId);
|
||||
Mono<ApplicationTemplate> getFilters();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,6 +137,24 @@ public class ApplicationTemplateServiceCEImpl implements ApplicationTemplateServ
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<ApplicationTemplate> getFilters() {
|
||||
final String baseUrl = cloudServicesConfig.getBaseUrl();
|
||||
|
||||
return WebClient
|
||||
.create(baseUrl + "/api/v1/app-templates/filters")
|
||||
.get()
|
||||
.exchangeToMono(clientResponse -> {
|
||||
if (clientResponse.statusCode().equals(HttpStatus.OK)) {
|
||||
return clientResponse.bodyToMono(ApplicationTemplate.class);
|
||||
} else if (clientResponse.statusCode().isError()) {
|
||||
return Mono.error(new AppsmithException(AppsmithError.CLOUD_SERVICES_ERROR, clientResponse.statusCode()));
|
||||
} else {
|
||||
return clientResponse.createException().flatMap(Mono::error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static class NoEncodingUriBuilderFactory extends DefaultUriBuilderFactory {
|
||||
public NoEncodingUriBuilderFactory(String baseUriTemplate) {
|
||||
super(UriComponentsBuilder.fromHttpUrl(baseUriTemplate));
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user