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 +4 -4
- data/lib/rest-ftp-daemon.rb +1 -0
- data/lib/rest-ftp-daemon/api/dashboard.rb +10 -5
- data/lib/rest-ftp-daemon/constants.rb +2 -2
- data/lib/rest-ftp-daemon/paginate.rb +60 -0
- data/lib/rest-ftp-daemon/static/css/main.css +13 -0
- data/lib/rest-ftp-daemon/views/dashboard.haml +5 -3
- data/lib/rest-ftp-daemon/views/dashboard_headers.haml +3 -1
- data/lib/rest-ftp-daemon/views/dashboard_jobs.haml +53 -46
- data/lib/rest-ftp-daemon/worker_pool.rb +5 -5
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cdf3cbfd6993183cfe6410fc11ce2743f0d3ca2
|
4
|
+
data.tar.gz: 07938cd1ed765a2939e8bdc2589069e9379dcd7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22536522c3a2cc04c73876305ce7f9217f9f8a12ec141c0d8ea8113c7908c94aa7569477051d179316afffb2efd2c836fb940418aa2d00acd74485b95e45238a
|
7
|
+
data.tar.gz: 4835fa78f98b4ab22b57be1456e438c65687756ec919435e5dd6cbf5880c7795724ee336fb334ca71df0667b9a8aa681e4a199b12b45bdfc5f696f81378c96f2
|
data/lib/rest-ftp-daemon.rb
CHANGED
@@ -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
|
-
|
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
|
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.
|
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
|
@@ -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=
|
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
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
.
|
10
|
-
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
-
|
15
|
-
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
%
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
%
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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 :
|
87
|
+
worker_status :working
|
88
88
|
worker_jid job.id
|
89
|
-
info "
|
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
|
-
|
93
|
+
Timeout::timeout(@timeout, RestFtpDaemon::JobTimeout) do
|
94
94
|
job.process
|
95
95
|
end
|
96
96
|
|
97
97
|
# Processing done
|
98
|
-
worker_status :
|
99
|
-
info "
|
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.
|
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
|