소스 검색

setup more information on s3 buckets

Chris Mague 7 년 전
부모
커밋
55ae7adf3c
4개의 변경된 파일32개의 추가작업 그리고 4개의 파일을 삭제
  1. 17 4
      lib/neoinfra/aws.rb
  2. 2 0
      models/s3.rb
  3. 1 0
      web/views/base_layout.html.erb
  4. 12 0
      web/views/view_buckets.html.erb

+ 17 - 4
lib/neoinfra/aws.rb

@@ -71,10 +71,14 @@ module NeoInfra
     def list_buckets
     def list_buckets
       buckets = []
       buckets = []
       Bucket.all.order('n.size DESC').each do |b|
       Bucket.all.order('n.size DESC').each do |b|
-        buckets <<  {'name' => b.name,
-                     'size' => b.size,
-                     'region' => b.region.region,
-                     'owner' => b.owner.name}
+        buckets <<  {
+          'name'       => b.name,
+          'size'       => b.size,
+          'versioning' => b.versioning,
+          'creation'   => b.creation,
+          'region'     => b.region.region,
+          'owner'      => b.owner.name
+        }
       end
       end
       return buckets
       return buckets
     end
     end
@@ -90,8 +94,17 @@ module NeoInfra
         s = Fog::Storage.new(base_conf)
         s = Fog::Storage.new(base_conf)
         s.directories.each do |bucket|
         s.directories.each do |bucket|
           next unless Bucket.where(name: bucket.key).empty?
           next unless Bucket.where(name: bucket.key).empty?
+          begin
+            vers = bucket.versioning?.to_s
+            crea =  bucket.creation_date.to_s
+          rescue
+            vers = "unknown"
+            crea = "unknown"
+          end
           b = Bucket.new(
           b = Bucket.new(
             name: bucket.key,
             name: bucket.key,
+            versioning: vers,
+            creation: crea,
             size: cw.get_bucket_size(account[:key], account[:secret], bucket.location, bucket.key)
             size: cw.get_bucket_size(account[:key], account[:secret], bucket.location, bucket.key)
           )
           )
           b.save
           b.save

+ 2 - 0
models/s3.rb

@@ -6,6 +6,8 @@ require 'neo4j'
 class Bucket
 class Bucket
   include Neo4j::ActiveNode
   include Neo4j::ActiveNode
   property :name, constraint: :unique
   property :name, constraint: :unique
+  property :versioning
+  property :creation
   property :size
   property :size
   has_one :out, :region, rel_class: :BucketRegion
   has_one :out, :region, rel_class: :BucketRegion
   has_one :out, :owner, rel_class: :BucketAccount
   has_one :out, :owner, rel_class: :BucketAccount

+ 1 - 0
web/views/base_layout.html.erb

@@ -5,6 +5,7 @@
     <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
     <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
     <meta name="description" content="">
     <meta name="description" content="">
     <meta name="author" content="">
     <meta name="author" content="">
+    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
     <link rel="icon" href="../../favicon.ico">
     <link rel="icon" href="../../favicon.ico">
     <script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
     <script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
 
 

+ 12 - 0
web/views/view_buckets.html.erb

@@ -8,6 +8,8 @@
         <th>Size</th>
         <th>Size</th>
         <th>Region</th>
         <th>Region</th>
         <th>Owner</th>
         <th>Owner</th>
+        <th>Versioning</th>
+        <th>Creation</th>
       </tr>
       </tr>
     </thead>
     </thead>
     <tbody>
     <tbody>
@@ -21,6 +23,16 @@
 <% end %>
 <% end %>
 <td><%= bucket['region']%></td>
 <td><%= bucket['region']%></td>
 <td><%= bucket['owner'] %></td>
 <td><%= bucket['owner'] %></td>
+<td>
+  <% if bucket['versioning'] == "true" %>
+    <i class="fa fa-check-circle" aria-hidden="true"></i>
+  <% elsif bucket['versioning'] == "false" %>
+    <i class="fa fa-times-circle" aria-hidden="true"></i>
+  <% else %>
+    <i class="fa fa-question-circle" aria-hidden="true"></i>
+  <% end %>
+</td>
+<td><%= bucket['creation'] %></td>
 </tr>
 </tr>
 <% end %>
 <% end %>
     </tbody>
     </tbody>