show rendered image
added loading icon image is scaled to available space
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
package org.lucares.pdbui;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.lucares.pdbui.domain.PlotRequest;
|
||||
import org.lucares.pdbui.domain.PlotResponse;
|
||||
import org.lucares.recommind.logs.InternalPlottingException;
|
||||
import org.lucares.recommind.logs.Plotter;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@@ -12,12 +17,12 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
@Controller
|
||||
@EnableAutoConfiguration
|
||||
public class PdbController {
|
||||
public class PdbController implements HardcodedValues {
|
||||
|
||||
private final PdbRepository pdbRepository;
|
||||
private final Plotter plotter;
|
||||
|
||||
public PdbController(final PdbRepository pdbRepository) {
|
||||
this.pdbRepository = pdbRepository;
|
||||
public PdbController(final Plotter plotter) {
|
||||
this.plotter = plotter;
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/plots", //
|
||||
@@ -27,8 +32,17 @@ public class PdbController {
|
||||
)
|
||||
@ResponseBody
|
||||
PlotResponse createPlot(@RequestBody final PlotRequest request) {
|
||||
System.out.println(request.getQuery());
|
||||
return new PlotResponse("img/abc.png");
|
||||
|
||||
try {
|
||||
System.out.println(request.getQuery());
|
||||
final File image = plotter.plot(request.getQuery(), request.getHeight(), request.getWidth());
|
||||
|
||||
final Path relativeImagePath = plotter.getOutputDir().relativize(image.toPath());
|
||||
return new PlotResponse(WEB_IMAGE_OUTPUT_PATH + "/" + relativeImagePath.toString());
|
||||
|
||||
} catch (final InternalPlottingException e) {
|
||||
throw new InternalServerError(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user