openvidu-server: generic frontend resource handler (usable for CE and PRO)

pull/447/head
pabloFuente 2020-04-20 14:25:59 +02:00
parent 7ba1b2bb12
commit 7f1fd28438
4 changed files with 19 additions and 7 deletions

View File

@ -43,7 +43,7 @@
"private": true, "private": true,
"scripts": { "scripts": {
"build": "./node_modules/@angular/cli/bin/ng build --base-href /dashboard/ --output-path ../main/resources/static/dashboard", "build": "./node_modules/@angular/cli/bin/ng build --base-href /dashboard/ --output-path ../main/resources/static/dashboard",
"build-prod": "./node_modules/@angular/cli/bin/ng build --base-href /dashboard/ --prod --output-path ../main/resources/static/dashboard", "build-prod": "./node_modules/@angular/cli/bin/ng build --prod --base-href /dashboard/ --output-path ../main/resources/static/dashboard",
"e2e": "ng e2e", "e2e": "ng e2e",
"lint": "ng lint", "lint": "ng lint",
"ng": "ng", "ng": "ng",

View File

@ -352,7 +352,7 @@ public class OpenviduConfig {
return !"/opt/openvidu/custom-layout".equals(path); return !"/opt/openvidu/custom-layout".equals(path);
} }
public String getOpenViduRecordingDefaultLayoutsPath() { public String getOpenViduFrontendDefaultPath() {
return "dashboard"; return "dashboard";
} }

View File

@ -539,7 +539,7 @@ public class ComposedRecordingService extends RecordingService {
log.error(e.getMessage()); log.error(e.getMessage());
} }
String defaultPathForDefaultLayout = recordingComposedUrlDefined ? "" String defaultPathForDefaultLayout = recordingComposedUrlDefined ? ""
: ("/" + openviduConfig.getOpenViduRecordingDefaultLayoutsPath()); : ("/" + openviduConfig.getOpenViduFrontendDefaultPath());
finalUrl = (startsWithHttp ? "http" : "https") + "://OPENVIDUAPP:" + secret + "@" + recordingUrl finalUrl = (startsWithHttp ? "http" : "https") + "://OPENVIDUAPP:" + secret + "@" + recordingUrl
+ defaultPathForDefaultLayout + "/#/layout-" + layout + "/" + recording.getSessionId() + "/" + defaultPathForDefaultLayout + "/#/layout-" + layout + "/" + recording.getSessionId() + "/"
+ secret + "/" + port + "/" + !recording.hasAudio(); + secret + "/" + port + "/" + !recording.hasAudio();

View File

@ -17,23 +17,35 @@
package io.openvidu.server.resources; package io.openvidu.server.resources;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import io.openvidu.server.config.OpenviduConfig;
/** /**
* This class changes the path where static files are served from / to * This class changes the path where static files are served from / to
* /dashboard. Entrypoint file index.html must have tag <base href="/dashboard/"> * /NEW_FRONTEND_PATH. Entrypoint file index.html must have tag
* <base href="/NEW_FRONTEND_PATH/">
*
* By default in OpenVidu CE this path is /dashbaord and in OpenVidu PRO is
* /inspector
* *
* @author Pablo Fuente (pablofuenteperez@gmail.com) * @author Pablo Fuente (pablofuenteperez@gmail.com)
*/ */
@Configuration @Configuration
public class DashboardResourceHandler extends WebMvcConfigurerAdapter { public class FrontendResourceHandler extends WebMvcConfigurerAdapter {
@Autowired
OpenviduConfig openviduConfig;
@Override @Override
public void addViewControllers(ViewControllerRegistry registry) { public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/dashboard").setViewName("redirect:/dashboard/"); registry.addViewController("/" + openviduConfig.getOpenViduFrontendDefaultPath())
registry.addViewController("/dashboard/").setViewName("forward:/dashboard/index.html"); .setViewName("redirect:/" + openviduConfig.getOpenViduFrontendDefaultPath() + "/");
registry.addViewController("/" + openviduConfig.getOpenViduFrontendDefaultPath() + "/")
.setViewName("forward:/" + openviduConfig.getOpenViduFrontendDefaultPath() + "/index.html");
super.addViewControllers(registry); super.addViewControllers(registry);
} }