-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
58ad5f4
commit e47aff0
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
//модуль для показа прогресс-бара создания отчетов | ||
|
||
app.modules.progressBar = (function(self) { | ||
|
||
function _requestError(data) { | ||
var payload = data.payload; | ||
|
||
if (app.config.progressBar.documentLocationError) { | ||
alert('Ошибка'); | ||
location.href = app.config.progressBar.documentLocationError; | ||
} | ||
|
||
if (payload && payload.error_messages) { | ||
$('.js-pberrors').html(payload.error_messages.join('<br>')); | ||
} | ||
} | ||
|
||
function _requestSuccess(data) { | ||
var | ||
progress = data.progress; | ||
|
||
if (progress && progress.message) { | ||
$('.js-pbstat').text(progress.num + ' из ' + progress.total + ' (' + Math.round(progress.percent) + '%)'); | ||
} | ||
} | ||
|
||
function _init() { | ||
$('.js-progressbar').progressBar({ | ||
url: app.config.progressBar.url, | ||
pid: app.config.progressBar.pid, | ||
onSuccess: function() { | ||
location.href = app.config.progressBar.documentLocation; | ||
}, | ||
onError: function(data) { | ||
_requestError(data); | ||
}, | ||
onRequestSuccess: function(data) { | ||
_requestSuccess(data); | ||
} | ||
}); | ||
} | ||
|
||
self.load = function() { | ||
_init(); | ||
}; | ||
return self; | ||
}(app.modules.progressBar || {})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
- content_for :javascripts_bottom do | ||
= javascript_include_tag 'standalone/progress_bar', :defer => true | ||
|
||
#progress | ||
.progressbar.js-progressbar | ||
#pbstat.js-pbstat | ||
#pberrors.pberrors.js-pberrors | ||
- if @back_url.present? | ||
= link_to 'Закрыть', @back_url | ||
|
||
:javascript | ||
app.config.progressBar = { | ||
url: #{job_status_path(domain: :current).to_json}, | ||
pid: #{@job_id.to_json}, | ||
documentLocation: #{@success_url_js || @success_url.to_json}, | ||
documentLocationError: #{@error_url ? @error_url.to_json : nil.to_json} | ||
}; |