rush_job_mongoid 1.3.0 → 1.4.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
  SHA256:
3
- metadata.gz: 9515ce4b1fd90a74b0959c805981a82449cf3f28f00fe328a5e12753464e6355
4
- data.tar.gz: 2e27a3e9ff1076261c2b10eedf9d590f44c065527899bf45cc5c7e6b6f773c6b
3
+ metadata.gz: 3054de3624de32c8d3dfb815b7ae7f41cd3ec094309f057beb420943a1f05b9e
4
+ data.tar.gz: 8eb924984ce3ac7e84d6d62975c9c3e3e0020ee519ccf1cd50589f14f15759cb
5
5
  SHA512:
6
- metadata.gz: 950e7a850279f648e49458dd338d91734c86a08047a7df1a2ffae2de5ee10468872e4b48d35b63f3019b80bda70e032816fe45a1d800ff44f71bdba1de31a21a
7
- data.tar.gz: 3d4e87bd1e40fecc96cbef57558d3424b3051e1a806e0906825137449bf9015d7067592b7c467d43d7d809a98e7bf9ec1f61b4668e338010d404aac1211495cf
6
+ metadata.gz: 7cc9a9715ccb15e9ead71841abd4c250164a92d6411a5de53374378273a124132c7dacb50f8d5d3c979205dda19ca8d4d8e71e1473977ad14dbee192ab6ba57f
7
+ data.tar.gz: 499a2698a09fa5cd7f7e8c21509b93f7801777302f7f70eb1436e7caf1881d6fdf902f6d1353b93844651260f5629be8bca1956c3f94a3a4b73f4c51c90f57e9
data/README.md CHANGED
@@ -30,7 +30,7 @@ Queues on the dashboard are eager loaded. If there are lots of queues this can a
30
30
  Add this line to your Ruby on Rails application's Gemfile:
31
31
 
32
32
  ```ruby
33
- gem 'rush_job_mongoid', '~> 1.3.0'
33
+ gem 'rush_job_mongoid', '~> 1.4'
34
34
  ```
35
35
 
36
36
  And then execute:
@@ -3,7 +3,7 @@ import { RushJobMongoidTableUpdateController } from './rush_job_mongoid_table_up
3
3
  let intervalID;
4
4
 
5
5
  export default class RushJobMongoidPollingController extends RushJobMongoidTableUpdateController {
6
- static targets = ['pollingTime', 'pollingTimeLabel', 'pollingSlide'];
6
+ static targets = ['pollingTime', 'pollingTimeLabel', 'pollingSlide', 'progressBar', 'progressBarProgress'];
7
7
 
8
8
  connect() {
9
9
  this.pollingChange();
@@ -22,17 +22,36 @@ export default class RushJobMongoidPollingController extends RushJobMongoidTable
22
22
 
23
23
  if (pollingSlide.checked === true) {
24
24
  this.startPolling();
25
+ this.progressBarTarget.style = 'height: 7px;';
25
26
  } else {
26
27
  this.stopPolling();
28
+ this.progressBarTarget.style = 'display: none;';
27
29
  }
28
30
  }
29
31
 
30
32
  startPolling() {
33
+ this.stopPolling();
31
34
  this.updateJobs();
32
35
 
33
- intervalID = setTimeout(() => {
34
- this.startPolling();
35
- }, this.pollingTime() * 1000);
36
+ let progressInterval = 100;
37
+ let progressPrecent = 1;
38
+ let progressIntervalTime = this.pollingTime() * 10;
39
+
40
+ if (progressIntervalTime < 130) {
41
+ progressPrecent = 10;
42
+ progressIntervalTime = progressIntervalTime * 10;
43
+ }
44
+
45
+ intervalID = setInterval(() => {
46
+ this.progressBarProgressTarget.style = `width: ${progressInterval}%;`;
47
+ this.progressBarTarget.setAttribute('aria-valuenow', progressInterval);
48
+
49
+ progressInterval -= progressPrecent;
50
+
51
+ if (progressInterval < 0) {
52
+ this.startPolling();
53
+ }
54
+ }, progressIntervalTime);
36
55
  }
37
56
 
38
57
  stopPolling() {
@@ -1,15 +1,24 @@
1
1
  import { Controller } from '@hotwired/stimulus';
2
2
 
3
3
  export class RushJobMongoidTableUpdateController extends Controller {
4
- updateJobs() {
4
+ async updateJobs() {
5
5
  const headers = { 'Accept': 'text/vnd.turbo-stream.html' };
6
6
 
7
7
  this.blurTable();
8
8
  this.clearFlash();
9
9
 
10
- fetch(document.location.href, { headers: headers })
11
- .then(response => response.text())
12
- .then(html => Turbo.renderStreamMessage(html));
10
+ try {
11
+ const response = await fetch(document.location.href, { headers: headers })
12
+
13
+ if (!response.ok) {
14
+ throw new Error(`Failed to fetch job data. Status: ${response.status}`);
15
+ }
16
+
17
+ const response_text = await response.text();
18
+ Turbo.renderStreamMessage(response_text);
19
+ } catch (error) {
20
+ console.error(error.message);
21
+ }
13
22
  }
14
23
 
15
24
  blurTable() {
@@ -2,6 +2,7 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>Rush job mongoid</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
5
6
  <%= csrf_meta_tags %>
6
7
  <%= csp_meta_tag %>
7
8
 
@@ -13,6 +13,19 @@
13
13
  max="6"
14
14
  data-rush-job-mongoid-polling-target="pollingTime"
15
15
  data-action="input->rush-job-mongoid-polling#pollingChange">
16
+ <div id="rush-job-mongoid-polling-progress"
17
+ class="progress mb-2"
18
+ role="progressbar"
19
+ aria-label="polling progress"
20
+ aria-valuenow="100"
21
+ aria-valuemin="0"
22
+ aria-valuemax="100"
23
+ style="display: none;"
24
+ data-rush-job-mongoid-polling-target="progressBar">
25
+ <div class="progress-bar"
26
+ style="width: 100%;"
27
+ data-rush-job-mongoid-polling-target="progressBarProgress"></div>
28
+ </div>
16
29
  </div>
17
30
  <div class="col-3">
18
31
  <div class="form-check form-switch">
@@ -1,3 +1,3 @@
1
1
  module RushJobMongoid
2
- VERSION = '1.3.0'.freeze
2
+ VERSION = '1.4.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rush_job_mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JavaKoala
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-23 00:00:00.000000000 Z
11
+ date: 2024-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview