Add Web UIs using templates.

* Added GUI to storage.
* Query submission and sorted results.


Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/fd1be925
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/fd1be925
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/fd1be925

Branch: refs/heads/master
Commit: fd1be925e6b8ef27b9ee86d11fb1942aac2d2558
Parents: 4847a31
Author: Sudheesh Katkam <[email protected]>
Authored: Fri May 30 15:56:55 2014 -0700
Committer: Jacques Nadeau <[email protected]>
Committed: Sun Jun 8 19:13:05 2014 -0700

----------------------------------------------------------------------
 .../drill/exec/server/DrillbitContext.java      |   4 +
 .../drill/exec/server/rest/DrillRoot.java       | 155 +++++++++++++++++--
 .../exec/server/rest/StorageResources.java      |   2 +-
 .../src/main/resources/rest/generic.ftl         |  72 +++++++++
 .../src/main/resources/rest/status/index.ftl    |  27 ++++
 .../src/main/resources/rest/status/list.ftl     |  43 ++++-
 .../src/main/resources/rest/status/profile.ftl  |  69 +++++++--
 .../src/main/resources/rest/status/query.ftl    |  54 +++++++
 .../src/main/resources/rest/status/result.ftl   |  40 +++++
 .../src/main/resources/rest/status/status.ftl   |  29 ++++
 .../src/main/resources/rest/storage/list.ftl    |  63 ++++++--
 .../src/main/resources/rest/storage/update.ftl  |  52 ++++---
 12 files changed, 540 insertions(+), 70 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fd1be925/exec/java-exec/src/main/java/org/apache/drill/exec/server/DrillbitContext.java
----------------------------------------------------------------------
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/server/DrillbitContext.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/DrillbitContext.java
index 7bf1e82..556724e 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/server/DrillbitContext.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/DrillbitContext.java
@@ -149,4 +149,8 @@ public class DrillbitContext {
     return storagePlugins.getSchemaFactory();
   }
 
+  public ClusterCoordinator getClusterCoordinator() {
+    return coord;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fd1be925/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRoot.java
----------------------------------------------------------------------
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRoot.java 
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRoot.java
index 1da5d79..6008aca 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRoot.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/DrillRoot.java
@@ -17,22 +17,39 @@
  */
 package org.apache.drill.exec.server.rest;
 
+import java.text.SimpleDateFormat;
+import java.util.AbstractMap;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import javax.inject.Inject;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.FormParam;
 import javax.ws.rs.GET;
+import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 
-import org.apache.drill.common.exceptions.ExecutionSetupException;
-import org.apache.drill.common.logical.StoragePluginConfig;
 import org.apache.drill.exec.cache.DistributedMap;
+import org.apache.drill.exec.client.DrillClient;
+import org.apache.drill.exec.exception.SchemaChangeException;
+import org.apache.drill.exec.proto.UserBitShared;
 import org.apache.drill.exec.proto.UserBitShared.QueryProfile;
-import org.apache.drill.exec.store.StoragePlugin;
-import org.apache.drill.exec.store.StoragePluginRegistry;
+import org.apache.drill.exec.record.RecordBatchLoader;
+import org.apache.drill.exec.record.VectorWrapper;
+import org.apache.drill.exec.rpc.RpcException;
+import org.apache.drill.exec.rpc.user.ConnectionThrottle;
+import org.apache.drill.exec.rpc.user.QueryResultBatch;
+import org.apache.drill.exec.rpc.user.UserResultsListener;
+import org.apache.drill.exec.vector.ValueVector;
 import org.apache.drill.exec.work.WorkManager;
 import org.apache.drill.exec.work.foreman.QueryStatus;
 import org.glassfish.jersey.server.mvc.Viewable;
@@ -41,30 +58,52 @@ import com.google.common.collect.Lists;
 
 @Path("/")
 public class DrillRoot {
-
   static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(DrillRoot.class);
 
   @Inject WorkManager work;
 
   @GET
-  @Path("status")
-  @Produces("text/plain")
-  public String getHello() {
-    return "running";
+  @Produces(MediaType.TEXT_HTML)
+  public Viewable getHello() {
+    String status = "Running!";
+    return new Viewable("/rest/status/index.ftl", status);
   }
 
   @GET
-  @Path("queries")
+  @Path("/status")
   @Produces(MediaType.TEXT_HTML)
-  public Viewable getQueries() {
-    DistributedMap<String, QueryProfile> profiles = 
work.getContext().getCache().getMap(QueryStatus.QUERY_PROFILE);
+  public Viewable getStatus() {
+    String status = "Running!";
+    return new Viewable("/rest/status/status.ftl", status);
+  }
 
-    List<String> ids = Lists.newArrayList();
-    for(Map.Entry<String, QueryProfile> entry : profiles.getLocalEntries()){
-      ids.add(entry.getKey());
+  @GET
+  @Path("/queries")
+  @Produces(MediaType.TEXT_HTML)
+  public Viewable getResults() {
+    DistributedMap<String, QueryProfile> cprofiles = 
work.getContext().getCache().getMap(QueryStatus.QUERY_PROFILE);
+
+    List<Map.Entry<String, Long>> ids = Lists.newArrayList();
+    for(Map.Entry<String, QueryProfile> entry : cprofiles.getLocalEntries()){
+      QueryProfile q = entry.getValue();
+      ids.add(new AbstractMap.SimpleEntry<>(entry.getKey(), 
q.getFragmentProfile(0).getMinorFragmentProfile(0).getStartTime()));
     }
 
-    return new Viewable("/rest/status/list.ftl", ids);
+    Collections.sort(ids, new Comparator<Map.Entry<String, Long>>() {
+      @Override
+      public int compare(Map.Entry<String, Long> o1, Map.Entry<String, Long> 
o2) {
+        return o2.getValue().compareTo(o1.getValue());
+      }
+    });
+
+    List<Map.Entry<String, String>> queries = Lists.newArrayList();
+    for(Map.Entry<String, Long> entry : ids){
+      queries.add(new AbstractMap.SimpleEntry<>(entry.getKey(), new 
SimpleDateFormat("MM/dd/yyyy HH:mm:ss").format(new Date(entry.getValue()))));
+    }
+
+    // add status (running, done)
+
+    return new Viewable("/rest/status/list.ftl", queries);
   }
 
 
@@ -80,5 +119,89 @@ public class DrillRoot {
 
   }
 
+  @GET
+  @Path("/query")
+  @Produces(MediaType.TEXT_HTML)
+  public Viewable getQuery() {
+    return new Viewable("/rest/status/query.ftl");
+  }
+
+  @POST
+  @Path("/query")
+  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
+  @Produces(MediaType.TEXT_HTML)
+  public Viewable submitQuery(@FormParam("query") String query, 
@FormParam("queryType") String queryType) throws Exception {
+    DrillClient client = new DrillClient(work.getContext().getConfig(), 
work.getContext().getClusterCoordinator());
+    client.connect();
+
+    UserBitShared.QueryType type = UserBitShared.QueryType.SQL;
+    switch (queryType){
+      case "SQL" : type = UserBitShared.QueryType.SQL; break;
+      case "LOGICAL" : type = UserBitShared.QueryType.LOGICAL; break;
+      case "PHYSICAL" : type = UserBitShared.QueryType.PHYSICAL; break;
+    }
+
+    Listener listener = new Listener(new 
RecordBatchLoader(work.getContext().getAllocator()));
+    client.runQuery(type, query, listener);
+    List<LinkedList<String>> result = listener.waitForCompletion();
+
+    return new Viewable("/rest/status/result.ftl", result);
+  }
+
+  private static class Listener implements UserResultsListener {
+    private volatile Exception exception;
+    private AtomicInteger count = new AtomicInteger();
+    private CountDownLatch latch = new CountDownLatch(1);
+    private LinkedList<LinkedList<String>> output = new LinkedList<>();
+    private RecordBatchLoader loader;
+
+    Listener(RecordBatchLoader loader) {
+      this.loader = loader;
+    }
 
+    @Override
+    public void submissionFailed(RpcException ex) {
+      exception = ex;
+      System.out.println("Query failed: " + ex.getMessage());
+      latch.countDown();
+    }
+
+    @Override
+    public void resultArrived(QueryResultBatch result, ConnectionThrottle 
throttle) {
+      int rows = result.getHeader().getRowCount();
+      if (result.getData() != null) {
+        count.addAndGet(rows);
+        try {
+          loader.load(result.getHeader().getDef(), result.getData());
+          output.add(new LinkedList<String>());
+          for (int i = 0; i < loader.getSchema().getFieldCount(); ++i) {
+            
output.getLast().add(loader.getSchema().getColumn(i).getPath().getAsUnescapedPath());
+          }
+        } catch (SchemaChangeException e) {
+          throw new RuntimeException(e);
+        }
+        for(int i = 0; i < rows; ++i) {
+          output.add(new LinkedList<String>());
+          for (VectorWrapper<?> vw : loader) {
+            ValueVector.Accessor accessor = vw.getValueVector().getAccessor();
+            output.getLast().add(accessor.getObject(i).toString());
+            }
+        }
+      }
+      result.release();
+      if (result.getHeader().getIsLastChunk()) {
+        latch.countDown();
+      }
+    }
+
+    @Override
+    public void queryIdArrived(UserBitShared.QueryId queryId) {}
+
+    public List<LinkedList<String>> waitForCompletion() throws Exception {
+      latch.await();
+      if(exception != null) throw exception;
+      System.out.println();
+      return output;
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fd1be925/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/StorageResources.java
----------------------------------------------------------------------
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/StorageResources.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/StorageResources.java
index 244d8a8..d67f06b 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/StorageResources.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/StorageResources.java
@@ -61,7 +61,7 @@ public class StorageResources {
 
     List<String> names = Lists.newArrayList();
     for (Map.Entry<String, StoragePluginConfig> config : storage.getStore()) {
-      names.add(config.getKey());
+      names.add(config.getKey().toUpperCase());
     }
 
     return new Viewable("/rest/storage/list.ftl", names);

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fd1be925/exec/java-exec/src/main/resources/rest/generic.ftl
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/resources/rest/generic.ftl 
b/exec/java-exec/src/main/resources/rest/generic.ftl
new file mode 100644
index 0000000..8ff83a0
--- /dev/null
+++ b/exec/java-exec/src/main/resources/rest/generic.ftl
@@ -0,0 +1,72 @@
+<#-- Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
+  license agreements. See the NOTICE file distributed with this work for 
additional
+  information regarding copyright ownership. The ASF licenses this file to
+  You under the Apache License, Version 2.0 (the "License"); you may not use
+  this file except in compliance with the License. You may obtain a copy of
+  the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+  by applicable law or agreed to in writing, software distributed under the
+  License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+  OF ANY KIND, either express or implied. See the License for the specific
+  language governing permissions and limitations under the License. -->
+
+<#macro page_head>
+</#macro>
+
+<#macro page_body>
+</#macro>
+
+<#macro page_html>
+  <!DOCTYPE html>
+  <html lang="en">
+    <head>
+      <meta charset="utf-8">
+      <meta http-equiv="X-UA-Compatible" content="IE=edge">
+
+      <title>Apache Drill</title>
+
+      <link 
href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"; 
rel="stylesheet">
+      <link 
href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css";
 rel="stylesheet">
+
+      <link href="theme.css" rel="stylesheet">
+
+      <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media 
queries -->
+      <!--[if lt IE 9]>
+        <script 
src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js";></script>
+        <script 
src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js";></script>
+      <![endif]-->
+
+      <@page_head/>
+    </head>
+
+    <body role="document">
+
+      <div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
+        <div class="container">
+          <div class="navbar-header">
+            <button type="button" class="navbar-toggle" data-toggle="collapse" 
data-target=".navbar-collapse">
+              <span class="sr-only">Toggle navigation</span>
+              <span class="icon-bar"></span>
+              <span class="icon-bar"></span>
+              <span class="icon-bar"></span>
+            </button>
+            <a class="navbar-brand" href="/">Apache Drill</a>
+          </div>
+          <div class="navbar-collapse collapse">
+            <ul class="nav navbar-nav">
+              <li><a href="/"><font color="red" 
id="statusFontColor">Status</font></a></li>
+              <li><a href="/query">Query</a></li>
+              <li><a href="/results">Results</a></li>
+              <li><a href="/storage">Storage</a></li>
+            </ul>
+          </div>
+        </div>
+      </div>
+
+      <div class="container theme-showcase" role="main">
+        <@page_body/>
+      </div>
+      <script 
src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js";></script>
+      <script 
src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js";></script>
+    </body>
+  </html>
+</#macro>

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fd1be925/exec/java-exec/src/main/resources/rest/status/index.ftl
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/resources/rest/status/index.ftl 
b/exec/java-exec/src/main/resources/rest/status/index.ftl
new file mode 100644
index 0000000..a6b3075
--- /dev/null
+++ b/exec/java-exec/src/main/resources/rest/status/index.ftl
@@ -0,0 +1,27 @@
+<#-- Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
+  license agreements. See the NOTICE file distributed with this work for 
additional
+  information regarding copyright ownership. The ASF licenses this file to
+  You under the Apache License, Version 2.0 (the "License"); you may not use
+  this file except in compliance with the License. You may obtain a copy of
+  the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+  by applicable law or agreed to in writing, software distributed under the
+  License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+  OF ANY KIND, either express or implied. See the License for the specific
+  language governing permissions and limitations under the License. -->
+
+<#include "*/generic.ftl">
+<#macro page_head>
+</#macro>
+
+<#macro page_body>
+  <a href="/queries">back</a><br/>
+  <div class="page-header">
+  </div>
+  <p class="lead"> Read about Apache Drill <a 
href="http://incubator.apache.org/drill/drill_overview.html"; 
rel="nofollow">here</a>.</p>
+  <script>
+      var elem = document.getElementById("statusFontColor");
+      elem.style.color = "green";
+  </script>
+</#macro>
+
+<@page_html/>

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fd1be925/exec/java-exec/src/main/resources/rest/status/list.ftl
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/resources/rest/status/list.ftl 
b/exec/java-exec/src/main/resources/rest/status/list.ftl
index ab1ca30..f40ca32 100644
--- a/exec/java-exec/src/main/resources/rest/status/list.ftl
+++ b/exec/java-exec/src/main/resources/rest/status/list.ftl
@@ -9,12 +9,41 @@
   OF ANY KIND, either express or implied. See the License for the specific
   language governing permissions and limitations under the License. -->
 
-<html>
-Welcome to Drill! 
-<br />
-<#list model as query>
+<#include "*/generic.ftl">
+<#macro page_head>
+</#macro>
 
-<a href="/query/${query}">${query}</a><br />
+<#macro page_body>
+  <a href="/queries">back</a><br/>
+  <div class="page-header">
+  </div>
+  <h3>List of Queries</h3>
+  <div class="table-responsive">
+    <table class="table table-hover">
+      <thead>
+         <td>Time</td>
+         <td>Query</td>
+      </thead>
+      <tbody>
+        <#list model as query>
+        <tr>
+          <td>${query.getValue()}</td>
+          <td>
+            <a href="/query/${query.getKey()}">
+              <div style="height:100%;width:100%">
+                ${query.getKey()}
+              </div>
+            </a>
+          </td>
+        </tr>
+        </#list>
+      </tbody>
+    </table>
+  </div>
+  <script>
+    var elem = document.getElementById("statusFontColor");
+    elem.style.color = "green";
+  </script>
+</#macro>
 
-</#list>
-</html>
\ No newline at end of file
+<@page_html/>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fd1be925/exec/java-exec/src/main/resources/rest/status/profile.ftl
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/resources/rest/status/profile.ftl 
b/exec/java-exec/src/main/resources/rest/status/profile.ftl
index 4989ae9..470f7ab 100644
--- a/exec/java-exec/src/main/resources/rest/status/profile.ftl
+++ b/exec/java-exec/src/main/resources/rest/status/profile.ftl
@@ -9,22 +9,57 @@
   OF ANY KIND, either express or implied. See the License for the specific
   language governing permissions and limitations under the License. -->
 
-<html>
-<a href="/queries">back</a><br />
+<#include "*/generic.ftl">
+<#macro page_head>
+</#macro>
 
-<pre>
-${model.query}
-</pre> 
-<br /><br />
-<pre>
-${model.plan}
-</pre>
+<#macro page_body>
+  <a href="/queries">back</a><br/>
+  <div class="page-header">
+  </div>
+  <h2>Query</h2>
+  <form role="form" action="/query" method="POST">
+    <div class="form-group">
+      <textarea class="form-control" id="query" 
name="query">${model.query}</textarea>
+    </div>
+    <div class="form-group">
+      <div class="radio-inline">
+        <label>
+          <input type="radio" name="queryType" id="sql" value="SQL" checked>
+          SQL
+        </label>
+      </div>
+      <div class="radio-inline">
+        <label>
+          <input type="radio" name="queryType" id="physical" value="PHYSICAL">
+          PHYSICAL
+        </label>
+      </div>
+      <div class="radio-inline">
+        <label>
+          <input type="radio" name="queryType" id="logical" value="LOGICAL">
+          LOGICAL
+        </label>
+      </div>
+    </div>
+    <button type="submit" class="btn btn-default">Re-run query</button>
+  </form>
+  <div class="page-header">
+    <h2>Physical plan</h2>
+  </div>
+  <div class="well">
+    <p><font face="courier">${model.plan}</font></p>
+  </div>
+  <div class="page-header">
+    <h2>Complete Profile</h2>
+  </div>
+  <div class="well">
+    <p><font face="courier">${model.toString()}</font></p>
+  </div>
+  <script>
+      var elem = document.getElementById("statusFontColor");
+      elem.style.color = "green";
+  </script>
+</#macro>
 
-
-<pre>
-${model.toString()}
-</pre>
-
-
-
-<html>
\ No newline at end of file
+<@page_html/>

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fd1be925/exec/java-exec/src/main/resources/rest/status/query.ftl
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/resources/rest/status/query.ftl 
b/exec/java-exec/src/main/resources/rest/status/query.ftl
new file mode 100644
index 0000000..a92696b
--- /dev/null
+++ b/exec/java-exec/src/main/resources/rest/status/query.ftl
@@ -0,0 +1,54 @@
+<#-- Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
+  license agreements. See the NOTICE file distributed with this work for 
additional
+  information regarding copyright ownership. The ASF licenses this file to
+  You under the Apache License, Version 2.0 (the "License"); you may not use
+  this file except in compliance with the License. You may obtain a copy of
+  the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+  by applicable law or agreed to in writing, software distributed under the
+  License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+  OF ANY KIND, either express or implied. See the License for the specific
+  language governing permissions and limitations under the License. -->
+
+<#include "*/generic.ftl">
+<#macro page_head>
+</#macro>
+
+<#macro page_body>
+  <a href="/queries">back</a><br/>
+  <div class="page-header">
+  </div>
+  <form role="form" action="/query" method="POST">
+    <div class="form-group">
+      <label for="queryType">Query Type</label>
+      <div class="radio">
+        <label>
+          <input type="radio" name="queryType" id="sql" value="SQL" checked>
+          SQL
+        </label>
+      </div>
+      <div class="radio">
+        <label>
+          <input type="radio" name="queryType" id="physical" value="PHYSICAL">
+          PHYSICAL
+        </label>
+      </div>
+      <div class="radio">
+        <label>
+          <input type="radio" name="queryType" id="logical" value="LOGICAL">
+          LOGICAL
+        </label>
+      </div>
+    </div>
+    <div class="form-group">
+      <label for="query">Query</label>
+      <textarea class="form-control" id="query" rows="5" 
name="query"></textarea>
+    </div>
+    <button type="submit" class="btn btn-default">Submit</button>
+  </form>
+  <script>
+      var elem = document.getElementById("statusFontColor");
+      elem.style.color = "green";
+  </script>
+</#macro>
+
+<@page_html/>

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fd1be925/exec/java-exec/src/main/resources/rest/status/result.ftl
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/resources/rest/status/result.ftl 
b/exec/java-exec/src/main/resources/rest/status/result.ftl
new file mode 100644
index 0000000..4c054f4
--- /dev/null
+++ b/exec/java-exec/src/main/resources/rest/status/result.ftl
@@ -0,0 +1,40 @@
+<#-- Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
+  license agreements. See the NOTICE file distributed with this work for 
additional
+  information regarding copyright ownership. The ASF licenses this file to
+  You under the Apache License, Version 2.0 (the "License"); you may not use
+  this file except in compliance with the License. You may obtain a copy of
+  the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+  by applicable law or agreed to in writing, software distributed under the
+  License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+  OF ANY KIND, either express or implied. See the License for the specific
+  language governing permissions and limitations under the License. -->
+
+<#include "*/generic.ftl">
+<#macro page_head>
+</#macro>
+
+<#macro page_body>
+  <a href="/queries">back</a><br/>
+  <div class="page-header">
+      <h2>Result</h2>
+  </div>
+  <div class="table-responsive">
+    <table class="table">
+      <tbody>
+        <#list model as rows>
+        <tr>
+          <#list rows as row>
+          <td>${row}</td>
+          </#list>
+        </tr>
+        </#list>
+      </tbody>
+    </table>
+  </div>
+  <script>
+      var elem = document.getElementById("statusFontColor");
+      elem.style.color = "green";
+  </script>
+</#macro>
+
+<@page_html/>

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fd1be925/exec/java-exec/src/main/resources/rest/status/status.ftl
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/resources/rest/status/status.ftl 
b/exec/java-exec/src/main/resources/rest/status/status.ftl
new file mode 100644
index 0000000..1d4e3d3
--- /dev/null
+++ b/exec/java-exec/src/main/resources/rest/status/status.ftl
@@ -0,0 +1,29 @@
+<#-- Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
+  license agreements. See the NOTICE file distributed with this work for 
additional
+  information regarding copyright ownership. The ASF licenses this file to
+  You under the Apache License, Version 2.0 (the "License"); you may not use
+  this file except in compliance with the License. You may obtain a copy of
+  the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
+  by applicable law or agreed to in writing, software distributed under the
+  License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+  OF ANY KIND, either express or implied. See the License for the specific
+  language governing permissions and limitations under the License. -->
+
+<#include "*/generic.ftl">
+<#macro page_head>
+</#macro>
+
+<#macro page_body>
+  <a href="/queries">back</a><br/>
+  <div class="page-header">
+    <div class="alert alert-success">
+      <strong>${model}</strong>
+    </div>
+  </div>
+  <script>
+      var elem = document.getElementById("statusFontColor");
+      elem.style.color = "green";
+  </script>
+</#macro>
+
+<@page_html/>

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fd1be925/exec/java-exec/src/main/resources/rest/storage/list.ftl
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/resources/rest/storage/list.ftl 
b/exec/java-exec/src/main/resources/rest/storage/list.ftl
index 380c3fc..6afe4b5 100644
--- a/exec/java-exec/src/main/resources/rest/storage/list.ftl
+++ b/exec/java-exec/src/main/resources/rest/storage/list.ftl
@@ -9,14 +9,59 @@
   OF ANY KIND, either express or implied. See the License for the specific
   language governing permissions and limitations under the License. -->
 
-<html>
-Registered Storage Plugins 
-<br />
-<#list model as plugin>
+<#include "*/generic.ftl">
+<#macro page_head>
+</#macro>
 
-${plugin} <a href="/storage/${plugin}/config">view</a> <a 
href="/storage/${plugin}/config/update">update</a><br />
+<#macro page_body>
+  <a href="/queries">back</a><br/>
+  <div class="page-header">
+  </div>
+  <h3>Registered Storage Plugins</h3>
+  <div class="table-responsive">
+    <table class="table">
+      <tbody>
+        <#list model as plugin>
+        <tr>
+          <td style="border:none;">
+            ${plugin}
+          </td>
+          <td style="border:none;">
+            <form action="/storage/${plugin}/config">
+              <button class="btn btn-default" type="submit">View</button>
+            </form>
+          </td>
+          <td style="border:none;">
+            <form action="/storage/${plugin}/config/update">
+              <button class="btn btn-primary" type="submit">Update</button>
+            </form>
+          </td>
+        </tr>
+        </#list>
+      </tbody>
+    </table>
+  </div>
+  <div>
+    <h4>Create new storage configuration</h4>
+    <form class="form-inline" id="newStorage" role="form" action="/" 
method="GET">
+      <div class="form-group">
+        <input type="text" class="form-control" id="storageName" 
placeholder="Storage Name">
+      </div>
+      <script>
+        function doSubmit() {
+          var name = document.getElementById("storageName");
+          var form = document.getElementById("newStorage");
+          form.action = "/storage/" + name.value + "/config/update?";
+          form.submit();
+        }
+      </script>
+      <button type="submit" class="btn btn-default" 
onclick="javascript:doSubmit();">Submit</button>
+    </form>
+  </div>
+  <script>
+      var elem = document.getElementById("statusFontColor");
+      elem.style.color = "green";
+  </script>
+</#macro>
 
-</#list>
-
-
-</html>
\ No newline at end of file
+<@page_html/>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/fd1be925/exec/java-exec/src/main/resources/rest/storage/update.ftl
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/resources/rest/storage/update.ftl 
b/exec/java-exec/src/main/resources/rest/storage/update.ftl
index 8c7588a..a76d750 100644
--- a/exec/java-exec/src/main/resources/rest/storage/update.ftl
+++ b/exec/java-exec/src/main/resources/rest/storage/update.ftl
@@ -9,25 +9,37 @@
   OF ANY KIND, either express or implied. See the License for the specific
   language governing permissions and limitations under the License. -->
 
-<html>
-Create/Update  
-<br />
+<#include "*/generic.ftl">
+<#macro page_head>
+</#macro>
 
-<form action="/storage/config/update" method="post">
-<input type="hidden" name="name" value="${model.name}" />
-<textarea rows="20" cols="50" name="config">
-${model.config}
-</textarea>
-<br />
-<input type="submit" value="<#if model.exists >update<#else>create</#if>"/>
-</form>
+<#macro page_body>
+  <a href="/queries">back</a><br/>
+  <div class="page-header">
+  </div>
+  <h3>Configuration</h3>
+  <form role="form" action="/storage/config/update" method="POST">
+   <input type="hidden" name="name" value="${model.name}" />
+   <div class="form-group">
+      <textarea class="form-control" id="config" rows="20" cols="50" 
name="config">${model.config}</textarea>
+   </div>
+   <button class="btn btn-default" type="submit">
+     <#if model.exists >Update<#else>Create</#if>
+   </button>
+  </form>
+  <br/>
+  <#if model.exists >
+    <form role="form" action="/storage/config/delete" method="POST">
+      <input type="hidden" name="name" value="${model.name}" />
+      <button type="submit" class="btn btn-default" onclick="return 
confirm('Are you sure?')">
+      Delete
+      </button>
+    </form>
+  </#if>
+  <script>
+      var elem = document.getElementById("statusFontColor");
+      elem.style.color = "green";
+  </script>
+</#macro>
 
-<#if model.exists >
-<form action="/storage/config/delete" method="post"><input type="hidden" 
name="name" value="${model.name}" />
-<input type="submit" value="delete" onclick="return confirm('Are you sure?')" 
/>
-</form>
-</#if>
-
-
-
-</html>
\ No newline at end of file
+<@page_html/>
\ No newline at end of file

Reply via email to