Skip to content

Commit

Permalink
[FIX] fix some doris web page dispaly error (apache#3544)
Browse files Browse the repository at this point in the history
  • Loading branch information
yangzhg authored May 14, 2020
1 parent 47bce08 commit d9e4551
Show file tree
Hide file tree
Showing 16 changed files with 948 additions and 57 deletions.
11 changes: 8 additions & 3 deletions fe/src/main/java/org/apache/doris/http/action/HelpAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,14 @@ private void appendHelpInfo(StringBuilder buffer) {

private void appendSearchButton(StringBuilder buffer) {
buffer.append("<form class=\"form-search\">"
+ "<input name=\"query\" type=\"text\" class=\"input-medium search-query\" "
+ " placeholder=\"input here...\">"
+ "<button type=\"submit\" class=\"btn\">Search</button>"
+ "<div class=\"col-lg-3\" style=\"padding-left: 0px;\">"
+ " <div class=\"input-group\">"
+ " <input name = \"query\" type=\"text\" class=\"form-control\" placeholder=\"input here...\">"
+ " <span class=\"input-group-btn\">"
+ " <button class=\"btn btn-default\" type=\"submit\">Search</button>"
+ " </span>"
+ " </div>"
+ "</div>"
+ "<a href=\"/help\" class=\"btn btn-primary\">Back To Home</a>"
+ "</form>");
}
Expand Down
16 changes: 11 additions & 5 deletions fe/src/main/java/org/apache/doris/http/action/LogAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,21 @@ private void appendUpdateVerboseButton(StringBuilder buffer, String type) {
return;
}

buffer.append("<form class=\"form-search\">"
+ "<input name=\"" + type + "\" type=\"text\" class=\"input-medium search-query\" "
+ " placeholder=\"" + placeHolder + "\">"
+ "<button type=\"submit\" class=\"btn\">" + buttonName + "</button>"
buffer.append("<form>"
+ "<div class=\"col-lg-3\" style=\"padding-left: 0px;\">"
+ " <div class=\"input-group\">"
+ " <input name = \"" + type + "\" type=\"text\" class=\"form-control\" placeholder=\""
+ placeHolder + "\">"
+ " <span class=\"input-group-btn\" style=\"padding-left: 0px;\">"
+ " <button class=\"btn btn-default\" type=\"submit\">" + buttonName + "</button>"
+ " </span>\n"
+ " </div>\n"
+ "</div>"
+ "</form>");
}

private void appendLogInfo(StringBuilder buffer) {
buffer.append("<h2>Log Contents</h2>");
buffer.append("<br/><h2>Log Contents</h2>");

final String logPath = Config.sys_log_dir + "/fe.warn.log";
buffer.append("Log path is: " + logPath + "<br/>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ public static void registerAction(ActionController controller) throws IllegalArg
controller.registerHandler(HttpMethod.GET, "/static/css", action);
controller.registerHandler(HttpMethod.GET, "/static", action);
controller.registerHandler(HttpMethod.GET, "/static/resource", action);
controller.registerHandler(HttpMethod.GET, "/static/images", action);
controller.registerHandler(HttpMethod.GET, "/static/fonts", action);

StaticResourceAction action2 = new StaticResourceAction(controller, "webroot");
controller.registerHandler(HttpMethod.GET, "/static_test", action2);
Expand Down
12 changes: 3 additions & 9 deletions fe/src/main/java/org/apache/doris/http/action/SystemAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ public void executeGet(BaseRequest request, BaseResponse response) {
private void appendSystemInfo(StringBuilder buffer, String procPath, String path) {
buffer.append("<h2>System Info</h2>");
buffer.append("<p>This page lists the system info, like /proc in Linux.</p>");
buffer.append("<p class=\"text-info\"> Current path: " + path + "</p>");
buffer.append("<p class=\"text-info\"> Current path: " + path + "<a href=\"?path=" + getParentPath(path)
+ "\" class=\"btn btn-primary\" style=\"float: right;\">"
+ "Parent Dir</a></p><br/>");

ProcNodeInterface procNode = getProcNode(procPath);
if (procNode == null) {
Expand Down Expand Up @@ -124,19 +126,11 @@ private void appendSystemInfo(StringBuilder buffer, String procPath, String path
Preconditions.checkNotNull(columnNames);
Preconditions.checkNotNull(rows);

appendBackButton(buffer, path);
appendTableHeader(buffer, columnNames);
appendSystemTableBody(buffer, rows, isDir, path);
appendTableFooter(buffer);
}

private void appendBackButton(StringBuilder buffer, String path) {
String parentDir = getParentPath(path);
buffer.append("<a href=\"?path=" + parentDir
+ "\" class=\"btn btn-primary\">"
+ "parent dir</a>");
}

private void appendSystemTableBody(StringBuilder buffer, List<List<String>> rows, boolean isDir, String path) {
for ( List<String> strList : rows) {
buffer.append("<tr>");
Expand Down
74 changes: 42 additions & 32 deletions fe/src/main/java/org/apache/doris/http/action/WebBaseAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,33 +54,42 @@
public class WebBaseAction extends BaseAction {
private static final Logger LOG = LogManager.getLogger(WebBaseAction.class);

protected static final String LINE_SEP = System.getProperty("line.separator");

protected static final String PALO_SESSION_ID = "PALO_SESSION_ID";
private static final long PALO_SESSION_EXPIRED_TIME = 3600 * 24; // one day

protected static final String PAGE_HEADER = "<!DOCTYPE html>"
+ "<html>"
+ "<head>"
+ " <title>Baidu Palo</title>"
+ " <title>Apache Doris(Incubating)</title>"
+ " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" >"

+ " <link href=\"static/css?res=bootstrap.css\" "
+ " <link rel=\"shortcut icon\" href=\"/static/images?res=favicon.ico\">"
+ " <link href=\"/static/css?res=bootstrap.css\" "
+ " rel=\"stylesheet\" media=\"screen\"/>"
+ " <link href=\"/static/css?res=bootstrap-theme.css\" "
+ " rel=\"stylesheet\" media=\"screen\"/>"
+ " <link href=\"static/css?res=datatables_bootstrap.css\" "
+ " <link href=\"/static/css?res=datatables_bootstrap.css\" "
+ " rel=\"stylesheet\" media=\"screen\"/>"

+ " <script type=\"text/javascript\" src=\"static?res=jquery.js\"></script>"
+ " <script type=\"text/javascript\" src=\"static?res=jquery.dataTables.js\"></script>"
+ " <script type=\"text/javascript\" src=\"static?res=datatables_bootstrap.js\"></script>" + LINE_SEP

+ " <script type=\"text/javascript\"> " + LINE_SEP
+ " $(document).ready(function() { " + LINE_SEP
+ " $('#table_id').dataTable({ " + LINE_SEP
+ " \"aaSorting\": []," + LINE_SEP
+ " });" + LINE_SEP
+ " }); " + LINE_SEP
+ " </script> " + LINE_SEP
+ " <script type=\"text/javascript\" src=\"/static?res=jquery.js\"></script>"
+ " <script type=\"text/javascript\" src=\"/static?res=jquery.dataTables.js\"></script>"
+ " <script type=\"text/javascript\" src=\"/static?res=datatables_bootstrap.js\"></script>"

+ " <script type=\"text/javascript\"> "
+ " $(document).ready(function() { "
+ " $('#table_id').dataTable({ "
+ " \"aaSorting\": [],"
+ " \"lengthMenu\": [[10, 25, 50, 100,-1], [10, 25, 50, 100, \"All\"]],"
+ " \"iDisplayLength\": 50,"
+ " });"
+ " }); "
+ " $(document).ready(function () {"
+ " var location = window.location.pathname;"
+ " var id = location.substring(location.lastIndexOf('/') + 1);"
+ " if (id != null || $.trim(id) != \"\") {"
+ " $(\"#nav_\" + id).addClass(\"active\");"
+ " }"
+ " });"
+ " </script> "

+ " <style>"
+ " body {"
Expand All @@ -91,10 +100,15 @@ public class WebBaseAction extends BaseAction {
+ "<body>";
protected static final String PAGE_FOOTER = "</div></body></html>";
protected static final String NAVIGATION_BAR_PREFIX =
" <nav class=\"navbar navbar-inverse navbar-fixed-top\" role=\"navigation\" style=\"text-align: center;\">"
" <nav class=\"navbar navbar-default navbar-fixed-top\" role=\"navigation\">"
+ " <div class=\"container-fluid\">"
+ " <div class=\"navbar-header\">"
+ " <a class=\"navbar-brand\" href=\"/\" style=\"padding: unset;\">"
+ " <img alt=\"Doris\" style=\"height: inherit;\" src=\"/static/images?res=doris-logo.png\">"
+ " </a>"
+ " </div>"
+ " <div>"
+ " <ul class=\"nav nav-pills\" role=\"tablist\" style=\"display: inline-block;float: none; \">";
+ " <ul class=\"nav navbar-nav\" role=\"tablist\">";
protected static final String NAVIGATION_BAR_SUFFIX =
" </ul>"
+ " </div>"
Expand Down Expand Up @@ -233,40 +247,36 @@ protected void addSession(BaseRequest request, BaseResponse response, SessionVal

protected void getPageHeader(BaseRequest request, StringBuilder sb) {
String newPageHeaderString = PAGE_HEADER;
newPageHeaderString = newPageHeaderString.replaceAll("<title>Baidu Palo</title>",
newPageHeaderString = newPageHeaderString.replaceAll("<title>Apache Doris</title>",
"<title>" + Config.cluster_name + "</title>");

sb.append(newPageHeaderString);
sb.append(NAVIGATION_BAR_PREFIX);

// TODO(lingbin): maybe should change to register the menu item?
sb.append("<li class=\"active\"><a href=\"/\">")
.append("Doris")
.append("</a></li>");
if (request.isAuthorized()) {
sb.append("<li><a href=\"/system\">")
sb.append("<li id=\"nav_system\"><a href=\"/system\">")
.append("system")
.append("</a></li>");
sb.append("<li><a href=\"/backend\">")
sb.append("<li id=\"nav_backend\"><a href=\"/backend\">")
.append("backends")
.append("</a></li>");
sb.append("<li><a href=\"/log\">")
sb.append("<li id=\"nav_log\"><a href=\"/log\">")
.append("logs")
.append("</a></li>");
sb.append("<li><a href=\"/query\">")
sb.append("<li id=\"nav_query\"><a href=\"/query\">")
.append("queries")
.append("</a></li>");
sb.append("<li><a href=\"/session\">")
sb.append("<li id=\"nav_session\"><a href=\"/session\">")
.append("sessions")
.append("</a></li>");
sb.append("<li><a href=\"/variable\">")
sb.append("<li id=\"nav_variable\"><a href=\"/variable\">")
.append("variables")
.append("</a></li>");
sb.append("<li><a href=\"/ha\">")
sb.append("<li id=\"nav_ha\"><a href=\"/ha\">")
.append("ha")
.append("</a></li>");
}
sb.append("<li><a href=\"/help\">")
sb.append("<li id=\"nav_help\"><a href=\"/help\">")
.append("help")
.append("</a></li></tr>");

Expand Down
Loading

0 comments on commit d9e4551

Please sign in to comment.