rest-ftp-daemon 0.212.0 → 0.213.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53e2cba7fe2218d3f261566678feba235343ca4a
4
- data.tar.gz: 75c4001a985741740c66165c6b1d73a893d0e43a
3
+ metadata.gz: 8cdf3cbfd6993183cfe6410fc11ce2743f0d3ca2
4
+ data.tar.gz: 07938cd1ed765a2939e8bdc2589069e9379dcd7b
5
5
  SHA512:
6
- metadata.gz: 695516939d86fe5e962458758dfe2ce3aa34b5c80ca8eec9bd3ccc4f893c303f9fac4489eec4368cc0ab469d53c584654573e938ad6b90a37c42795f3c1d85ce
7
- data.tar.gz: 72cdbba9f002f17faa9e6c0d203c089b89e5eb9a57cc32e892287ebe620e4e4c96f1234fc54ca0087e1cfe733ba7da3290c247c93f1f07cf1d1ec269f7ee6361
6
+ metadata.gz: 22536522c3a2cc04c73876305ce7f9217f9f8a12ec141c0d8ea8113c7908c94aa7569477051d179316afffb2efd2c836fb940418aa2d00acd74485b95e45238a
7
+ data.tar.gz: 4835fa78f98b4ab22b57be1456e438c65687756ec919435e5dd6cbf5880c7795724ee336fb334ca71df0667b9a8aa681e4a199b12b45bdfc5f696f81378c96f2
@@ -23,6 +23,7 @@ require 'rest-ftp-daemon/constants'
23
23
  require 'rest-ftp-daemon/settings'
24
24
  require 'rest-ftp-daemon/exceptions'
25
25
  require 'rest-ftp-daemon/helpers'
26
+ require 'rest-ftp-daemon/paginate'
26
27
  require 'rest-ftp-daemon/uri'
27
28
  require 'rest-ftp-daemon/job_queue'
28
29
  # require 'rest-ftp-daemon/worker'
@@ -19,20 +19,25 @@ module RestFtpDaemon
19
19
  Facter.loadfacts
20
20
 
21
21
  # Detect QS filters
22
- only = params["only"].to_s
22
+ @only = params["only"].to_s
23
23
 
24
24
  # Get jobs for this view, order jobs by their weights
25
- current = $queue.filter_jobs only
25
+ result = $queue.filter_jobs @only
26
26
 
27
27
  # Provide queue only if no filtering set
28
- queue = []
29
- queue = $queue.queue if only.empty?
28
+ @queue = []
29
+ @queue = $queue.queue if @only.empty?
30
30
 
31
31
  # Get workers status
32
32
  @worker_variables = $pool.worker_variables
33
33
 
34
+ # Build paginator
35
+ @paginate = Paginate.new result.reverse
36
+ @paginate.only = params["only"]
37
+ @paginate.page = params["page"]
38
+
34
39
  # Compile haml template
35
- output = render :dashboard, {queue: queue, current: current, only: only}
40
+ output = render :dashboard
36
41
 
37
42
  # Send response
38
43
  env['api.format'] = :html
@@ -1,7 +1,7 @@
1
1
  # Terrific constants
2
2
  APP_NAME = "rest-ftp-daemon"
3
3
  APP_NICK = "rftpd"
4
- APP_VER = "0.212.0"
4
+ APP_VER = "0.213.0"
5
5
 
6
6
 
7
7
  # Jobs and workers
@@ -44,7 +44,7 @@ WORKER_STYLES = {
44
44
  :done => :success,
45
45
  :dead => :danger
46
46
  }
47
-
47
+ PAGINATE_MAX = 30
48
48
 
49
49
  # Configuration defaults
50
50
  DEFAULT_WORKER_TIMEOUT = 3600
@@ -0,0 +1,60 @@
1
+ module RestFtpDaemon
2
+ class Paginate
3
+
4
+ def initialize data
5
+ # Defaults
6
+ @pages = 0
7
+ @total = 0
8
+ @data = []
9
+ @only = nil
10
+ @page = 1
11
+ @pages = 1
12
+
13
+ # Ensure data set is countable
14
+ return unless data.is_a? Enumerable
15
+ @data = data
16
+
17
+ # Count elements
18
+ @total = @data.count
19
+
20
+ # Count pages
21
+ @pages = (@total.to_f / PAGINATE_MAX).ceil
22
+ @pages = 1 if @pages < 1
23
+ end
24
+
25
+ def only= raw_only
26
+ @only = raw_only
27
+ end
28
+
29
+ def page= raw_page
30
+ @page = [1, raw_page.to_i, @pages].sort[1]
31
+ end
32
+
33
+ def browser
34
+ out = []
35
+ 1.upto(@pages) do |p|
36
+ out << link(p)
37
+ end
38
+ out.join()
39
+ end
40
+
41
+ def subset
42
+ size = PAGINATE_MAX.to_i
43
+ offset = (@page-1) * size
44
+ @data[offset, size]
45
+ end
46
+
47
+ private
48
+
49
+ def link p
50
+ klass = (p == @page)? ' btn-info' : ''
51
+ return "<a class='page btn btn-default%s' href='?only=%s&page=%d'>%p</a>" % [
52
+ klass,
53
+ @only,
54
+ p,
55
+ p,
56
+ ]
57
+ end
58
+
59
+ end
60
+ end
@@ -63,3 +63,16 @@ h2 {
63
63
  /*min-width: 60px;*/
64
64
  }
65
65
 
66
+ a.class {
67
+ text-decoration: underline;
68
+ }
69
+
70
+
71
+ a.page.btn {
72
+ /*font-weight: bold;*/
73
+ /*font-size: 1.5em;*/
74
+ }
75
+
76
+ .debug {
77
+ border: 1px solid orange;
78
+ }
@@ -24,9 +24,11 @@
24
24
 
25
25
  = render :dashboard_headers
26
26
 
27
- .row
28
- #box-jobs.col-md-12
29
- = render :dashboard_jobs, {current: current, queue: queue, only: only}
27
+ %br
28
+ %br
29
+ %br
30
+
31
+ = render :dashboard_jobs
30
32
 
31
33
  .row
32
34
  #box-tokens.col-md-6
@@ -32,8 +32,10 @@
32
32
 
33
33
  .btn-group.btn-group-sm
34
34
  .btn.btn-default.btn-info Processed
35
- .btn.btn-default= Helpers.format_bytes(info_processed)
35
+ .btn.btn-default= info_processed
36
36
 
37
37
  .btn-group.btn-group-sm
38
38
  .btn.btn-default.btn-info Transferred
39
39
  .btn.btn-default= Helpers.format_bytes(trans, "B")
40
+
41
+
@@ -1,47 +1,54 @@
1
- - count_all = $queue.jobs_count
2
1
  - counts_by_status = $queue.counts_by_status
3
- -# jobs_without_queue = jobs
4
-
5
-
6
- %h2
7
- Jobs table &nbsp;
8
-
9
- .btn-group.btn-group-md
10
- - klass = only.empty? ? "btn-info" : ""
11
- %a.btn.btn-default{href: "?only=", class: klass}
12
- ALL (#{count_all})
13
- .btn-group.btn-group-md
14
- - counts_by_status.each do |status, count|
15
- - klass = (status.to_s == only) ? "btn-info" : ""
16
- %a.btn.btn-default{href: "?only=#{status}", class: klass}
17
- #{status} (#{count})
18
-
19
- %table.table.table-striped.table-hover.table-condensed#jobs
20
-
21
- %thead
22
- %tr
23
- %th ID
24
- %th label
25
- %th source
26
- %th <=>
27
- %th target
28
- %th queued
29
- %th{width: 150} status
30
- %th{"min-width" => 120} error
31
- %th.text-right size
32
- %th.text-right bitrate
33
- %th info
34
-
35
-
36
- - unless queue.empty?
37
- %tbody.jobs
38
- = render :dashboard_table, {jobs: queue.reverse}
39
-
40
- %thead
41
- %tr
42
- %td{colspan: 13}
43
- %br
44
-
45
- - unless current.empty?
46
- %tbody.jobs
47
- = render :dashboard_table, {jobs: current.reverse}
2
+ - counts_all = $queue.jobs_count
3
+ - jobs = @paginate.subset
4
+
5
+
6
+ .row
7
+
8
+ .col-md-5
9
+ .btn-group.btn-group-md
10
+ - klass = @only.empty? ? "btn-info" : ""
11
+ %a.btn.btn-default{href: "?only=", class: klass}
12
+ ALL (#{counts_all})
13
+ .btn-group.btn-group-md
14
+ - counts_by_status.each do |status, count|
15
+ - klass = (status.to_s == @only) ? "btn-info" : ""
16
+ %a.btn.btn-default{href: "?only=#{status}", class: klass}
17
+ #{status} (#{count})
18
+
19
+ .col-md-7
20
+ = @paginate.browser
21
+
22
+
23
+
24
+ .row
25
+ #box-jobs.col-md-12
26
+
27
+ %table.table.table-striped.table-hover.table-condensed#jobs
28
+
29
+ %thead
30
+ %tr
31
+ %th ID
32
+ %th label
33
+ %th source
34
+ %th <=>
35
+ %th target
36
+ %th queued
37
+ %th{width: 150} status
38
+ %th{"min-width" => 120} error
39
+ %th.text-right size
40
+ %th.text-right bitrate
41
+ %th info
42
+
43
+ - unless @queue.empty?
44
+ %tbody.jobs
45
+ = render :dashboard_table, {jobs: @queue.reverse}
46
+
47
+ %thead
48
+ %tr
49
+ %td{colspan: 13}
50
+ %br
51
+
52
+ - unless jobs.empty?
53
+ %tbody.jobs
54
+ = render :dashboard_table, {jobs: jobs.reverse}
@@ -84,19 +84,19 @@ module RestFtpDaemon
84
84
  job = $queue.pop
85
85
 
86
86
  # Prepare the job for processing
87
- worker_status :processing
87
+ worker_status :working
88
88
  worker_jid job.id
89
- info "processing"
89
+ info "working"
90
90
  job.wid = Thread.current.thread_variable_get :wid
91
91
 
92
92
  # Processs this job protected by a timeout
93
- status = Timeout::timeout(@timeout, RestFtpDaemon::JobTimeout) do
93
+ Timeout::timeout(@timeout, RestFtpDaemon::JobTimeout) do
94
94
  job.process
95
95
  end
96
96
 
97
97
  # Processing done
98
- worker_status :done
99
- info "done"
98
+ worker_status :finished
99
+ info "finished"
100
100
  worker_jid nil
101
101
  job.wid = nil
102
102
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest-ftp-daemon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.212.0
4
+ version: 0.213.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruno MEDICI
@@ -239,6 +239,7 @@ files:
239
239
  - lib/rest-ftp-daemon/logger.rb
240
240
  - lib/rest-ftp-daemon/logger_pool.rb
241
241
  - lib/rest-ftp-daemon/notification.rb
242
+ - lib/rest-ftp-daemon/paginate.rb
242
243
  - lib/rest-ftp-daemon/settings.rb
243
244
  - lib/rest-ftp-daemon/static/css/bootstrap.css
244
245
  - lib/rest-ftp-daemon/static/css/main.css