[Groonga-commit] groonga/groonga-admin at 740b547 [master] Show table list on top page

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Oct 27 15:20:39 JST 2014


Kouhei Sutou	2014-10-27 15:20:39 +0900 (Mon, 27 Oct 2014)

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

  Message:
    Show table list on top page

  Added files:
    app/scripts/controllers/top-controller.js
    app/scripts/groonga-response/table-list.js
    app/views/top.html
  Removed files:
    app/scripts/controllers/main.js
    app/views/main.html
  Modified files:
    app/index.html
    app/scripts/app.js

  Modified: app/index.html (+2 -4)
===================================================================
--- app/index.html    2014-10-23 13:28:54 +0900 (70ba68f)
+++ app/index.html    2014-10-27 15:20:39 +0900 (db89083)
@@ -24,8 +24,6 @@
       <div class="header">
         <ul class="nav nav-pills pull-right">
           <li class="active"><a ng-href="#">Home</a></li>
-          <li><a ng-href="#/about">About</a></li>
-          <li><a ng-href="#">Contact</a></li>
         </ul>
         <h3 class="text-muted">Groonga Admin</h3>
       </div>
@@ -33,7 +31,6 @@
       <div ng-view=""></div>
 
       <div class="footer">
-        <p><span class="glyphicon glyphicon-heart"></span> from the Yeoman team</p>
       </div>
     </div>
 
@@ -73,8 +70,9 @@
         <!-- build:js({.tmp,app}) scripts/scripts.js -->
         <script src="scripts/groonga-response.js"></script>
         <script src="scripts/groonga-response/select.js"></script>
+        <script src="scripts/groonga-response/table-list.js"></script>
         <script src="scripts/app.js"></script>
-        <script src="scripts/controllers/main.js"></script>
+        <script src="scripts/controllers/top-controller.js"></script>
         <script src="scripts/controllers/table-search-controller.js"></script>
         <!-- endbuild -->
 </body>

  Modified: app/scripts/app.js (+2 -2)
===================================================================
--- app/scripts/app.js    2014-10-23 13:28:54 +0900 (c025efb)
+++ app/scripts/app.js    2014-10-27 15:20:39 +0900 (bd93af9)
@@ -20,8 +20,8 @@ angular
   .config(function ($routeProvider) {
     $routeProvider
       .when('/', {
-        templateUrl: 'views/main.html',
-        controller: 'MainCtrl'
+        templateUrl: 'views/top.html',
+        controller: 'TopController'
       })
       .when('/tables/:table/search', {
         templateUrl: 'views/tables/search.html',

  Deleted: app/scripts/controllers/main.js (+0 -17) 100644
===================================================================
--- app/scripts/controllers/main.js    2014-10-23 13:28:54 +0900 (830bbe5)
+++ /dev/null
@@ -1,17 +0,0 @@
-'use strict';
-
-/**
- * @ngdoc function
- * @name groongaAdminApp.controller:MainCtrl
- * @description
- * # MainCtrl
- * Controller of the groongaAdminApp
- */
-angular.module('groongaAdminApp')
-  .controller('MainCtrl', function ($scope) {
-    $scope.awesomeThings = [
-      'HTML5 Boilerplate',
-      'AngularJS',
-      'Karma'
-    ];
-  });

  Added: app/scripts/controllers/top-controller.js (+19 -0) 100644
===================================================================
--- /dev/null
+++ app/scripts/controllers/top-controller.js    2014-10-27 15:20:39 +0900 (ff3b6e8)
@@ -0,0 +1,19 @@
+'use strict';
+
+/**
+ * @ngdoc function
+ * @name groongaAdminApp.controller:TopController
+ * @description
+ * # TopController
+ * Controller of the groongaAdminApp
+ */
+angular.module('groongaAdminApp')
+  .controller('TopController', function ($scope, $http) {
+    $scope.tables = [];
+    $http.jsonp('/d/table_list', {params: {callback: 'JSON_CALLBACK'}})
+      .success(function(data) {
+        var response = new GroongaResponse.TableList(data);
+        $scope.tables = response.tables();
+        console.log($scope.tables);
+      });
+  });

  Added: app/scripts/groonga-response/table-list.js (+61 -0) 100644
===================================================================
--- /dev/null
+++ app/scripts/groonga-response/table-list.js    2014-10-27 15:20:39 +0900 (b08e592)
@@ -0,0 +1,61 @@
+'use strict';
+
+(function() {
+  function TableList(rawData) {
+    this._rawData = rawData;
+  }
+  GroongaResponse.TableList = TableList;
+
+  TableList.prototype.header = function() {
+    return this._rawData[0];
+  };
+
+  TableList.prototype.status = function() {
+    return this.header()[0];
+  };
+
+  TableList.prototype.isSuccess = function() {
+    return this.status() === 0;
+  };
+
+  TableList.prototype.startTime = function() {
+    var startTime = new Date();
+    startTime.setTime(this.header()[1]);
+    return startTime;
+  };
+
+  TableList.prototype.elapsedTime = function() {
+    return this.header()[2];
+  };
+
+  TableList.prototype.errorMessage = function() {
+    return this.header()[3];
+  };
+
+  TableList.prototype.body = function() {
+    return this._rawData[1];
+  };
+
+  TableList.prototype.parameters = function() {
+    return this.body()[0].map(function(parameter) {
+      return {
+        name: parameter[0],
+        type: parameter[1]
+      };
+    });
+  };
+
+  TableList.prototype.tables = function() {
+    var parameters = this.parameters();
+    console.log(this.body());
+    console.log(this.body()[1]);
+    console.log(this.body().slice(1));
+    return this.body().slice(1).map(function(tableProperties) {
+      var table = {};
+      parameters.forEach(function(parameter, index) {
+        table[parameter.name] = tableProperties[index];
+      });
+      return table;
+    });
+  };
+})();

  Deleted: app/views/main.html (+0 -23) 100644
===================================================================
--- app/views/main.html    2014-10-23 13:28:54 +0900 (7addb36)
+++ /dev/null
@@ -1,23 +0,0 @@
-<div class="jumbotron">
-  <h1>'Allo, 'Allo!</h1>
-  <p class="lead">
-    <img src="images/yeoman.png" alt="I'm Yeoman"><br>
-    Always a pleasure scaffolding your apps.
-  </p>
-  <p><a class="btn btn-lg btn-success" ng-href="#">Splendid!<span class="glyphicon glyphicon-ok"></span></a></p>
-</div>
-
-<div class="row marketing">
-  <h4>HTML5 Boilerplate</h4>
-  <p>
-    HTML5 Boilerplate is a professional front-end template for building fast, robust, and adaptable web apps or sites.
-  </p>
-
-  <h4>Angular</h4>
-  <p>
-    AngularJS is a toolset for building the framework most suited to your application development.
-  </p>
-
-  <h4>Karma</h4>
-  <p>Spectacular Test Runner for JavaScript.</p>
-</div>

  Added: app/views/top.html (+8 -0) 100644
===================================================================
--- /dev/null
+++ app/views/top.html    2014-10-27 15:20:39 +0900 (9d2dab1)
@@ -0,0 +1,8 @@
+<div class="container">
+  <h2>Tables</h2>
+  <div class="list-group">
+    <a ng-repeat="table in tables track by $index"
+       class="list-group-item"
+       href="#/tables/{{table.name}}/search">{{table.name}}</a>
+  </div>
+</div>
-------------- next part --------------
HTML����������������������������...
Descargar 



More information about the Groonga-commit mailing list
Back to archive index