logman 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. data/.gitignore +18 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +45 -0
  5. data/Rakefile +1 -0
  6. data/config.ru +9 -0
  7. data/lib/console/auth.rb +39 -0
  8. data/lib/console/base.rb +22 -0
  9. data/lib/console/bucket_api.rb +50 -0
  10. data/lib/console/log_api.rb +38 -0
  11. data/lib/console/static/app/api_guide/index.html +57 -0
  12. data/lib/console/static/app/bucket/add_edit.html +40 -0
  13. data/lib/console/static/app/bucket/bucket.js +149 -0
  14. data/lib/console/static/app/bucket/log-details.html +37 -0
  15. data/lib/console/static/app/bucket/logs.html +23 -0
  16. data/lib/console/static/app/logman.js +25 -0
  17. data/lib/console/static/app/user/list.html +33 -0
  18. data/lib/console/static/app/user/user-modal.html +34 -0
  19. data/lib/console/static/app/user/user.js +69 -0
  20. data/lib/console/static/css/bootstrap.css +7118 -0
  21. data/lib/console/static/css/bootstrap.min.css +7 -0
  22. data/lib/console/static/css/jsontree.css +64 -0
  23. data/lib/console/static/css/logman.css +59 -0
  24. data/lib/console/static/css/plugins/dataTables/dataTables.bootstrap.css +233 -0
  25. data/lib/console/static/css/plugins/morris/morris-0.4.3.min.css +2 -0
  26. data/lib/console/static/css/plugins/social-buttons/social-buttons.css +68 -0
  27. data/lib/console/static/css/plugins/timeline/timeline.css +144 -0
  28. data/lib/console/static/css/sb-admin.css +317 -0
  29. data/lib/console/static/font-awesome/css/font-awesome.css +1338 -0
  30. data/lib/console/static/font-awesome/css/font-awesome.min.css +4 -0
  31. data/lib/console/static/font-awesome/fonts/FontAwesome.otf +0 -0
  32. data/lib/console/static/font-awesome/fonts/fontawesome-webfont.eot +0 -0
  33. data/lib/console/static/font-awesome/fonts/fontawesome-webfont.svg +414 -0
  34. data/lib/console/static/font-awesome/fonts/fontawesome-webfont.ttf +0 -0
  35. data/lib/console/static/font-awesome/fonts/fontawesome-webfont.woff +0 -0
  36. data/lib/console/static/font-awesome/less/bordered-pulled.less +16 -0
  37. data/lib/console/static/font-awesome/less/core.less +12 -0
  38. data/lib/console/static/font-awesome/less/fixed-width.less +6 -0
  39. data/lib/console/static/font-awesome/less/font-awesome.less +17 -0
  40. data/lib/console/static/font-awesome/less/icons.less +412 -0
  41. data/lib/console/static/font-awesome/less/larger.less +13 -0
  42. data/lib/console/static/font-awesome/less/list.less +19 -0
  43. data/lib/console/static/font-awesome/less/mixins.less +20 -0
  44. data/lib/console/static/font-awesome/less/path.less +14 -0
  45. data/lib/console/static/font-awesome/less/rotated-flipped.less +9 -0
  46. data/lib/console/static/font-awesome/less/spinning.less +30 -0
  47. data/lib/console/static/font-awesome/less/stacked.less +20 -0
  48. data/lib/console/static/font-awesome/less/variables.less +381 -0
  49. data/lib/console/static/font-awesome/scss/_bordered-pulled.scss +16 -0
  50. data/lib/console/static/font-awesome/scss/_core.scss +12 -0
  51. data/lib/console/static/font-awesome/scss/_fixed-width.scss +6 -0
  52. data/lib/console/static/font-awesome/scss/_icons.scss +412 -0
  53. data/lib/console/static/font-awesome/scss/_larger.scss +13 -0
  54. data/lib/console/static/font-awesome/scss/_list.scss +19 -0
  55. data/lib/console/static/font-awesome/scss/_mixins.scss +20 -0
  56. data/lib/console/static/font-awesome/scss/_path.scss +14 -0
  57. data/lib/console/static/font-awesome/scss/_rotated-flipped.scss +9 -0
  58. data/lib/console/static/font-awesome/scss/_spinning.scss +30 -0
  59. data/lib/console/static/font-awesome/scss/_stacked.scss +20 -0
  60. data/lib/console/static/font-awesome/scss/_variables.scss +381 -0
  61. data/lib/console/static/font-awesome/scss/font-awesome.scss +17 -0
  62. data/lib/console/static/fonts/glyphicons-halflings-regular.eot +0 -0
  63. data/lib/console/static/fonts/glyphicons-halflings-regular.svg +229 -0
  64. data/lib/console/static/fonts/glyphicons-halflings-regular.ttf +0 -0
  65. data/lib/console/static/fonts/glyphicons-halflings-regular.woff +0 -0
  66. data/lib/console/static/js/angular-resource.min.js +13 -0
  67. data/lib/console/static/js/angular-route.min.js +14 -0
  68. data/lib/console/static/js/angular.min.js +202 -0
  69. data/lib/console/static/js/bootstrap.js +2006 -0
  70. data/lib/console/static/js/bootstrap.min.js +7 -0
  71. data/lib/console/static/js/demo/dashboard-demo.js +117 -0
  72. data/lib/console/static/js/demo/flot-demo.js +1242 -0
  73. data/lib/console/static/js/demo/morris-demo.js +155 -0
  74. data/lib/console/static/js/jquery-1.10.2.js +6 -0
  75. data/lib/console/static/js/jsontree.js +77 -0
  76. data/lib/console/static/js/plugins/dataTables/dataTables.bootstrap.js +245 -0
  77. data/lib/console/static/js/plugins/dataTables/jquery.dataTables.js +14013 -0
  78. data/lib/console/static/js/plugins/flot/excanvas.min.js +1 -0
  79. data/lib/console/static/js/plugins/flot/jquery.flot.js +2599 -0
  80. data/lib/console/static/js/plugins/flot/jquery.flot.pie.js +750 -0
  81. data/lib/console/static/js/plugins/flot/jquery.flot.resize.js +60 -0
  82. data/lib/console/static/js/plugins/flot/jquery.flot.tooltip.min.js +12 -0
  83. data/lib/console/static/js/plugins/metisMenu/jquery.metisMenu.js +45 -0
  84. data/lib/console/static/js/plugins/morris/morris.js +1888 -0
  85. data/lib/console/static/js/plugins/morris/raphael-2.1.0.min.js +10 -0
  86. data/lib/console/static/js/sb-admin.js +31 -0
  87. data/lib/console/static/js/ui-bootstrap-tpls-0.10.0.min.js +9 -0
  88. data/lib/console/user_api.rb +51 -0
  89. data/lib/console/views/app.erb +144 -0
  90. data/lib/console/views/dashboard.erb +30 -0
  91. data/lib/console/views/login.erb +89 -0
  92. data/lib/console/web_console.rb +24 -0
  93. data/lib/logman.rb +3 -0
  94. data/lib/logman/server.rb +9 -0
  95. data/lib/logman/system.rb +53 -0
  96. data/lib/logman/version.rb +3 -0
  97. data/lib/models/bucket.rb +38 -0
  98. data/lib/models/log.rb +41 -0
  99. data/lib/models/user.rb +33 -0
  100. data/lib/modules/log_writer.rb +27 -0
  101. data/lib/modules/secure_password.rb +122 -0
  102. data/logman.gemspec +30 -0
  103. metadata +261 -0
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .project
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in logman.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Branko Krstic
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,45 @@
1
+ # Logman
2
+
3
+ Logman is Web Console/API for gathering logs from various sources and analyzing them. Logs are saved to mongo database.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'logman'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install logman
18
+
19
+ ## Usage
20
+
21
+ Create rackup file `config.ru` with content:
22
+
23
+ ```ruby
24
+ require 'logman'
25
+
26
+ Logman.configure do |config|
27
+ config.database_uri = 'mongodb://localhost/logman'
28
+
29
+ config.log_writer = Logman::LogWriter
30
+ config.web_console = Logman::WebConsole
31
+ end
32
+
33
+ run Logman::Server
34
+
35
+ ```
36
+
37
+ Execute `rackup -p 3000`
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,9 @@
1
+ require 'logman'
2
+
3
+ Logman.configure do |config|
4
+ config.database_uri = 'mongodb://localhost/logman'
5
+ config.log_writer = Logman::LogWriter
6
+ config.web_console = Logman::WebConsole
7
+ end
8
+
9
+ run Logman::Server
@@ -0,0 +1,39 @@
1
+
2
+ module Logman
3
+ class Auth < ConsoleBase
4
+ get '/login' do
5
+ erb :login, locals:{ :invalid=> false, :register=> (User.count==0) }
6
+ end
7
+
8
+ post '/login' do
9
+ #register for the first time
10
+ if User.count == 0
11
+ user = User.new(params)
12
+ user.admin = true
13
+
14
+ if user.save
15
+ session[:user_id] = user.id.to_s
16
+ return redirect '/'
17
+ else
18
+ return erb :login, locals:{ :invalid=> true, :register=>true }
19
+ end
20
+ end
21
+
22
+ #login routine
23
+ user = User.find_by_email(params[:email])
24
+
25
+ if user.nil? || user.authenticate(params[:password]).blank?
26
+ erb :login, locals:{ :invalid=> true, :register=>false }
27
+ else
28
+ session[:user_id] = user.id.to_s
29
+ redirect '/'
30
+ end
31
+ end
32
+
33
+ get '/logout' do
34
+ session[:user_id] = nil
35
+ redirect '/'
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,22 @@
1
+ module Logman
2
+ class ConsoleBase < Sinatra::Base
3
+ before do
4
+ # session[:user_id] = '52e7ffa1adf1744071000001'
5
+ @user = User.find(session[:user_id])
6
+ end
7
+
8
+ register do
9
+ def auth (type)
10
+ condition do
11
+ if @user.nil?
12
+ redirect "/login"
13
+ else
14
+ ut = (@user.admin)? :admin : :user
15
+ halt 401, 'No Access' if ut == :user && type == :admin
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,50 @@
1
+ module Logman
2
+ class BucketAPI < ConsoleBase
3
+
4
+ get '/api/buckets',:auth=>:user do
5
+ json @user.buckets
6
+ end
7
+
8
+ get '/api/buckets/:id',:auth=>:user do
9
+ json @user.buckets.find(params[:id])
10
+ end
11
+
12
+ post '/api/buckets', :auth=> :admin do
13
+ json = JSON.parse(request.body.read)
14
+ bucket = Bucket.new(json)
15
+
16
+ if bucket.save
17
+ json bucket
18
+ else
19
+ status 422
20
+ bucket.errors.to_json
21
+ end
22
+ end
23
+
24
+ put '/api/buckets/:id', :auth=> :admin do
25
+ if params[:generateToken].blank? == false
26
+ bucket = Bucket.find(params[:id])
27
+ bucket.new_token if bucket
28
+ bucket.save
29
+ return json bucket
30
+ end
31
+
32
+ json = JSON.parse(request.body.read)
33
+ bucket = Bucket.find(params[:id])
34
+
35
+ if bucket.update_attributes(json)
36
+ json bucket
37
+ else
38
+ status 422
39
+ bucket.errors.to_json
40
+ end
41
+ end
42
+
43
+ delete '/api/buckets/:id', :auth=>:admin do
44
+ bucket = Bucket.find(params[:id])
45
+ bucket.destroy if bucket
46
+ status 200
47
+ end
48
+
49
+ end
50
+ end
@@ -0,0 +1,38 @@
1
+ module Logman
2
+ class LogAPI < ConsoleBase
3
+
4
+ get '/api/buckets/:id/logs',:auth=>:user do
5
+ bucket = Bucket.find(params[:id])
6
+
7
+ if bucket.nil?
8
+ status 404
9
+ else
10
+ page = params[:page] || 1
11
+
12
+ pagination={
13
+ :order => :created_at.desc,
14
+ :per_page => params[:per_page] || 10,
15
+ :page => page
16
+ }
17
+
18
+
19
+ data = bucket.logs.paginate(pagination)
20
+
21
+ res ={
22
+ :page => page,
23
+ :items => data,
24
+ :total_items => bucket.logs.count,
25
+ }
26
+
27
+ json res
28
+
29
+ end
30
+ end
31
+
32
+ get '/app/dashboard-view',:auth=>:user do
33
+ graph_data = (7.days.ago.to_date..Date.today).map {|t| {date: t, count: Log.count_on_date(t)} }
34
+ erb :dashboard, :locals=>{:graph_data=> graph_data}
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,57 @@
1
+ <div class="col-lg-12" ng-controller="LocationCtl">
2
+ <h1 class="page-header">API Guide</h1>
3
+ <div ng-controller="BucketListCtl">
4
+ <p>Select Bucket: <select ng-options="b.name for b in buckets" ng-model="sbucket"></select>
5
+
6
+ <p>To save a single log to logman bucket, make <strong>POST</strong> request to url:</p>
7
+ <code>{{protocol}}//{{host}}/api/write?key={{ (sbucket)? sbucket.write_token : 'bucket_write_key' }}</code>
8
+ </div>
9
+
10
+ <br>
11
+ <p>With data in JSON format:</p>
12
+
13
+
14
+ <pre >
15
+ <span style='color:#806030; '>{</span>
16
+
17
+ log_type<span style='color:#806030; '>:</span> <span style='color:#c00000; '>1</span><span style='color:#806030; '>,</span> <span style='color:#c34e00; '>//type of log: 1-error, 2-success, 3-warning,4-info</span>
18
+ message<span style='color:#806030; '>:</span> <span style='color:#e60000; '>'Err...'</span><span style='color:#806030; '>,</span> <span style='color:#c34e00; '>//log message</span>
19
+
20
+ <span style='color:#c34e00; '>//Optional parameters</span>
21
+ data<span style='color:#806030; '>:</span> <span style='color:#806030; '>{</span> <span style='color:#c34e00; '>//aditional data</span>
22
+ innerException<span style='color:#806030; '>:</span> <span style='color:#806030; '>{</span>message<span style='color:#806030; '>:</span><span style='color:#e60000; '>'...'</span><span style='color:#806030; '>}</span>
23
+ <span style='color:#806030; '>}</span><span style='color:#806030; '>,</span>
24
+ datetime<span style='color:#806030; '>:</span> <span style='color:#e60000; '>'1-1-2013 10:00'</span><span style='color:#806030; '>,</span> <span style='color:#c34e00; '>//time when error occurred on server</span>
25
+ data_type<span style='color:#806030; '>:</span> <span style='color:#e60000; '>'.net exception'</span><span style='color:#806030; '>,</span> <span style='color:#c34e00; '>//not used for now, but indicates 'data' field format</span>
26
+
27
+ sources<span style='color:#806030; '>:</span> <span style='color:#806030; '>[</span><span style='color:#806030; '>{</span> <span style='color:#c34e00; '>//Name and IP of machine that generated an error, </span>
28
+ name<span style='color:#806030; '>:</span> <span style='color:#e60000; '>'my server'</span><span style='color:#806030; '>,</span> <span style='color:#c34e00; '>//if logman Proxy is used, it will append his hostname and ip</span>
29
+ ip_address<span style='color:#806030; '>:</span> <span style='color:#e60000; '>'234.124.156.123'</span>
30
+ <span style='color:#806030; '>}</span><span style='color:#806030; '>]</span>
31
+ <span style='color:#806030; '>}</span>
32
+ </pre>
33
+
34
+ </div>
35
+
36
+ <!--
37
+
38
+ {
39
+
40
+ log_type: 1, //type of log: 1-error, 2-success, 3-warning,4-info
41
+ message: 'Err...', //log message
42
+
43
+ //Optional parameters
44
+ data: { //aditional data
45
+ innerException: {message:'...'}
46
+ },
47
+ datetime: '1-1-2013 10:00', //time when error occurred - if it's blank, current time is set
48
+ data_type: '.net exception', //not used for now, but indicates 'data' field format
49
+
50
+ sources: [{ //Name and IP of machine that generated an error, if logman Proxy is used, it will append his hostname and ip
51
+ name: 'my server',
52
+ ip_address: '234.124.156.123'
53
+ }]
54
+ }
55
+
56
+
57
+ -->
@@ -0,0 +1,40 @@
1
+
2
+ <div class="col-lg-12" ng-controller="BucketAddEditCtl">
3
+ <h1 class="page-header"> <i class="fa fa-bitbucket"></i> {{bucket.name || 'New bucket'}}</h1>
4
+
5
+ <div class="row">
6
+ <div class="col-lg-6">
7
+ <form role="form" ng-submit="saveCreate()">
8
+ <div class="form-group">
9
+ <label for="exampleInputEmail1">Bucket Name</label>
10
+ <input type="text" required ng-model="bucket.name" class="form-control" placeholder="Bucket name">
11
+ </div>
12
+
13
+ <div class="form-group">
14
+ <label for="exampleInputPassword1">Access Permisions</label>
15
+
16
+ <div ng-repeat="u in users" class="checkbox">
17
+ <label>
18
+ <input type="checkbox" ng-checked="haveAccess(u)" ng-click="invertAccess(u)">
19
+ {{u.name}} <span class="small" ng-if="u.admin">[Admin]</span>
20
+ </label>
21
+ </div>
22
+
23
+ </div>
24
+
25
+ <div class="form-group" ng-if="bucket.id">
26
+ <label for="exampleInputPassword1">Write Token</label>
27
+ <p class="form-control-static">
28
+ <code>{{bucket.write_token}}</code>
29
+ &nbsp;
30
+ <button type="button" class="btn btn-xs btn-danger" ng-click="generateToken()">Regenerate</button>
31
+ </p>
32
+ </div>
33
+
34
+ <button type="submit" class="btn btn-default">Save</button>
35
+ <button type="button" ng-click="destroyBucket()" class="btn btn-danger">Destroy</button>
36
+ </form>
37
+ </div>
38
+ </div>
39
+
40
+ </div>
@@ -0,0 +1,149 @@
1
+
2
+ logman.factory('$bucket',['$resource',function($resource){
3
+ var Bucket = $resource('/api/buckets/:id',{id: '@id'},{
4
+ save: {method: 'PUT'},
5
+ create: {method: 'POST'},
6
+ generateToken: {method: 'PUT', params:{generateToken:true}}
7
+ });
8
+
9
+ var collection = Bucket.query();
10
+
11
+ return {
12
+ Bucket: Bucket,
13
+ collection: collection,
14
+ reload: function(){
15
+ Bucket.query({},function(ls){
16
+ collection.length = 0;
17
+ for (var i=0; i < ls.length; i++)collection.push(ls[i]);
18
+ });
19
+ }
20
+ }
21
+ }]);
22
+
23
+ var BucketListCtl = function($scope, $bucket, $location){
24
+ $scope.buckets = $bucket.collection;
25
+ $scope.is_admin = user.admin;
26
+
27
+ $scope.toLogs = function(b){
28
+ $location.path('/buckets/'+b.id+'/logs');
29
+ }
30
+
31
+ $scope.toDetails = function(b){
32
+ $location.path('/buckets/'+b.id+'/details');
33
+ }
34
+ }
35
+
36
+ var BucketAddEditCtl = function($scope, $bucket, $routeParams, $user,$location){
37
+ $scope.users = $user.collection;
38
+
39
+ if($routeParams.id)$scope.bucket= $bucket.Bucket.get({id: $routeParams.id})
40
+ else $scope.bucket = new $bucket.Bucket({user_ids:[]});
41
+
42
+ $scope.haveAccess = function(user){
43
+ if(!$scope.bucket.user_ids)return;
44
+ for (var i=0; i < $scope.bucket.user_ids.length; i++)
45
+ if($scope.bucket.user_ids[i]==user.id)return true;
46
+
47
+ return false;
48
+ }
49
+
50
+ $scope.invertAccess = function(user){
51
+ if(!$scope.bucket.user_ids)return;
52
+ var have = $scope.haveAccess(user);
53
+
54
+ if(!have) $scope.bucket.user_ids.push(user.id);
55
+ else $scope.bucket.user_ids.splice($scope.bucket.user_ids.indexOf(user.id),1);
56
+ }
57
+
58
+ $scope.saveCreate = function(){
59
+ function success(){
60
+ $bucket.reload();
61
+ }
62
+
63
+ if($scope.bucket.id)$scope.bucket.$save(success);
64
+ else $scope.bucket.$create(success);
65
+ }
66
+
67
+ $scope.generateToken = function(){
68
+ message = "Warning!!!\n\nGenerating new token will cause all apps that use old token to stop! Continue?";
69
+ if(confirm(message)){
70
+ $scope.bucket.$generateToken($bucket.reload);
71
+ }
72
+ }
73
+
74
+ $scope.destroyBucket = function(){
75
+ if(confirm('Are you sure?')){
76
+ $scope.bucket.$delete(function(){
77
+ $bucket.reload();
78
+ $location.path('/');
79
+ });
80
+ }
81
+ }
82
+ }
83
+
84
+
85
+ var LogsCtl = function($scope, $resource, $routeParams,$bucket,$modal){
86
+ $scope.bucket = $bucket.Bucket.get({id: $routeParams.id});
87
+
88
+ $scope.loadLogs = function(page){
89
+ // var page = ($scope.logs)? $scope.logs.page : 1;
90
+ $scope.logs = $resource('/api/buckets/:bucket_id/logs').get({bucket_id: $routeParams.id, page: page});
91
+ }
92
+
93
+
94
+ $scope.show = function(log){
95
+ $scope.active = log;
96
+ var modalInstance = $modal.open({
97
+ templateUrl: '/app/bucket/log-details.html',
98
+ controller: LogDetails,
99
+ resolve: {log: function(){return log; }},
100
+ windowClass: 'full-modal'
101
+ });
102
+ }
103
+
104
+ $scope.loadLogs(1);
105
+ }
106
+
107
+
108
+ var LogDetails = function($scope, $modalInstance,log){
109
+ $scope.log = log;
110
+
111
+ $scope.cancel = function () {
112
+ $modalInstance.dismiss('cancel');
113
+ };
114
+
115
+ $scope.log_type = function(log,for_class_name){
116
+ if(!for_class_name) return ['Error','Success','Warning', 'Info'][log.log_type-1]
117
+ else{
118
+ var klass = $scope.log_type(log).toLocaleLowerCase();
119
+ if(klass=='error')klass='danger';
120
+ return klass;
121
+ }
122
+ }
123
+
124
+ $scope.formatData = function(root){
125
+ return JSON.stringify(root);
126
+ }
127
+ }
128
+
129
+ logman.directive('jsonTree',function(){
130
+ function link(scope, element){
131
+ $(element).jsontree(scope.json_data);
132
+ }
133
+
134
+ return {
135
+ link: link,
136
+ scope: {json_data:'=jsonData'}
137
+ }
138
+ });
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+