[Groonga-commit] groonga/groonga-admin at faeb7ca [master] table show: support removing a table

Zurück zum Archiv-Index

Kouhei Sutou null+****@clear*****
Wed Dec 31 23:51:17 JST 2014


Kouhei Sutou	2014-12-31 23:51:17 +0900 (Wed, 31 Dec 2014)

  New Revision: faeb7ca30f97c766851bfab5fdb280f596fd9096
  https://github.com/groonga/groonga-admin/commit/faeb7ca30f97c766851bfab5fdb280f596fd9096

  Message:
    table show: support removing a table

  Modified files:
    app/scripts/controllers/table-show-controller.js
    app/views/tables/show.html

  Modified: app/scripts/controllers/table-show-controller.js (+22 -2)
===================================================================
--- app/scripts/controllers/table-show-controller.js    2014-12-31 23:50:44 +0900 (5a1f6ed)
+++ app/scripts/controllers/table-show-controller.js    2014-12-31 23:51:17 +0900 (bba66be)
@@ -9,15 +9,35 @@
  */
 angular.module('groongaAdminApp')
   .controller('TableShowController', [
-    '$scope', '$routeParams', '$filter', 'schemaLoader',
-    function ($scope, $routeParams, $filter, schemaLoader) {
+    '$scope', '$routeParams', '$http', '$location', 'schemaLoader',
+    function ($scope, $routeParams, $http, $location, schemaLoader) {
       var schema;
+      var client = new GroongaClient($http);
 
       function initialize() {
         $scope.table = {
           name: $routeParams.table,
           columns: []
         };
+        $scope.remove = remove;
+      }
+
+      function remove() {
+        if (!window.confirm('Really remove the table?')) {
+          return;
+        }
+
+        var request = client.execute('table_remove', {name: $scope.table.name});
+        request.success(function(response) {
+          console.log(response);
+          if (response.isRemoved()) {
+            schemaLoader().reload();
+            $location.url('/tables/');
+          } else {
+            var errorMessage = response.errorMessage();
+            $scope.message = 'Failed to remove the table: ' + errorMessage;
+          }
+        });
       }
 
       initialize();

  Modified: app/views/tables/show.html (+26 -9)
===================================================================
--- app/views/tables/show.html    2014-12-31 23:50:44 +0900 (0138238)
+++ app/views/tables/show.html    2014-12-31 23:51:17 +0900 (7be3464)
@@ -5,19 +5,36 @@
     <li class="active"><a href="#/tables/{{table.name}}">{{table.name}}</a></li>
   </ol>
 
-  <div class="content">
+  <div class="sidebar">
+    <div class="panel panel-default">
+      <div class="panel-heading">
+        <h2 class="panel-title">Actions</h2>
+      </div>
+      <div class="panel-body">
+        <ul class="list-group">
+          <li class="list-group-item">
+            <a href="#/tables/{{table.name}}/search">
+              <span class="glyphicon glyphicon-search"></span>
+              Search
+            </a>
+          </li>
+          <li class="list-group-item">
+            <button type="button" ng-click="remove()">
+              <span class="glyphicon glyphicon-remove"></span>
+              Remove
+            </button>
+          </li>
+        </ul>
+      </div>
+    </div>
+  </div>
+
+  <div class="main-content">
     <div class="alert alert-warning" ng-show="message.length &gt; 0">
       <p>{{message}}</p>
     </div>
 
-    <h2>
-      Table: {{table.name}}
-      <a href="#/tables/{{table.name}}/search">
-        <span class="badge">
-          <span class="glyphicon glyphicon-search"></span>
-        </span>
-      </a>
-    </h2>
+    <h2>Table: {{table.name}}</h2>
     <div class="table-properties">
       <table>
         <tr>
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Zurück zum Archiv-Index