Archived
0

Рабочая балванка для менеджера серверов

This commit is contained in:
2017-03-18 17:35:10 +03:00
parent 6ec5431a4f
commit ad2baf2d9b
2 changed files with 17 additions and 14 deletions

View File

@@ -4,15 +4,15 @@
*/
package asys.mcsmanager;
import asys.webinterface.api.HttpReqResp;
import asys.webinterface.api.WebModule;
import com.sun.net.httpserver.HttpExchange;
import java.util.Collections;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class MCSM_WebModule implements WebModule {
public class MCSM_WebModule extends WebModule {
private final String MODULE_NAME = "mcsmanager";
@Override
@@ -21,24 +21,27 @@ public class MCSM_WebModule implements WebModule {
}
@Override
public List<String> getStylesheetsLinks() {
return Collections.emptyList();
}
@Override
public List<String> getJavaScriptLinks() {
return Collections.singletonList("/module/"+MODULE_NAME+"/module.js");
public String getReactJSModuleLink() {
return "/"+MODULE_NAME+"/module.js";
}
@Override
public Map<String, String> getMainMenuItems() {
return new HashMap<String, String>(){{
this.put("Серверы", "/module/"+MODULE_NAME);
this.put("Серверы", "/"+MODULE_NAME);
}};
}
@Override
public void handle(HttpReqResp httpReqResp) {
public boolean handle(HttpExchange httpExchange) throws IOException {
String urlPath = httpExchange.getRequestURI().getPath();
if (urlPath.equals("/"+MODULE_NAME+"/module.js")) {
InputStream stream = getClass().getResourceAsStream("/module.js");
httpExchange.getResponseHeaders().add("Content-Type", "text/javascript;charset=utf-8");
this.sendContent(httpExchange, 0, stream);
return true;
}
return false;
}
}