thecore_tcp_debug 3.0.4 → 3.0.5

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: b9740bf418284b7fb2ac3af38852e441d11386d3827a4478a54f620ba30427cd
4
- data.tar.gz: 00fe0a835179e301e651e27974e99a9c463cd2b9ef283f538077326b6c409f23
3
+ metadata.gz: 2b8a39ea1c4c564c1674f4cf2875797d9080e58f821f1bf625447c8bc0ba6b59
4
+ data.tar.gz: 675fb4e845b17ef8399a46acc968d640e01daf9f1e391e713a322041423b6e95
5
5
  SHA512:
6
- metadata.gz: 84f1b6fe14db21c19a78527194bd25cf6794f24016d2aaa3d51a017bfebf857569b2f585a589294bdcd992b07353d420b6b93a6ca80284935b9fe6280fd9ac18
7
- data.tar.gz: 3ca8770e8b1ebb7ad79096346b2879f762b5b6d5a643534ee892b68186b24d3fc5092644b34a1bb4bcc9f6483d5c145876444656b4539cff3754643fc5053183
6
+ metadata.gz: a423f91a4d5699f3c0ee2945c9cc933bdd2b05c1234d33296604e6a3f5ada3114dae45c15d0028060afd0ef1d718b92af24522e867ae2771bb5cd9f3ee11f8d1
7
+ data.tar.gz: 5feaa6841b651d60f839c28d88a275191661979c4461a4c0a6f28a85964a52efb21bc47c37a3d8d96b0dfa24cfe8403ec2be95830dac69fbe172c3cfa98754dc
@@ -0,0 +1,56 @@
1
+
2
+ $(document).on('turbo:load', function (event) {
3
+ hideLoader();
4
+
5
+ console.log("Into TCP Debug");
6
+ // Action cable Websocket
7
+ App.cable.subscriptions.create("ActivityLogChannel", {
8
+ connected() {
9
+ console.log("Connected to the channel:", this);
10
+ this.send({ message: 'TCP Debug Client is connected', topic: "tcp_debug", namespace: "subscriptions" });
11
+ },
12
+ disconnected() {
13
+ console.log("TCP Debug Client Disconnected");
14
+ },
15
+ received(data) {
16
+ if(data["topic"] == "tcp_debug")
17
+ console.log("TCP DEBUG", data);
18
+ }
19
+ });
20
+
21
+ $("#ping-host").keypress(function(event){if(event.keyCode == 13){$('#ping').click();}});
22
+ $("#telnet-host").keypress(function(event){if(event.keyCode == 13){$('#telnet').click();}});
23
+ $("#telnet-port").keypress(function(event){if(event.keyCode == 13){$('#telnet').click();}});
24
+ });
25
+
26
+ function hideLoader() {
27
+ $(".loader").hide();
28
+ $(".tcp-debug-response").show();
29
+ }
30
+
31
+ function showLoader() {
32
+ $(".loader").show();
33
+ $(".tcp-debug-response").hide();
34
+ }
35
+
36
+ function startTest(element) {
37
+ $("#response").empty();
38
+ typeOfTest = $(element).attr("id");
39
+ host = $(`#${typeOfTest}-host`).val();
40
+ port = $(`#${typeOfTest}-port`).val();
41
+ // console.log(typeOfTest)
42
+ // console.log(host)
43
+ // console.log(port)
44
+ showLoader();
45
+ $.get("#{rails_admin.send('tcp_debug_path')}", {
46
+ test: typeOfTest,
47
+ host: host,
48
+ port: port
49
+ }).then(function (params) {
50
+ // console.log("OK", params)
51
+ $("#response").html(params["debug_status"]).removeClass("text-danger").addClass("text-success");
52
+ }).catch(function (params) {
53
+ // console.log("KO", params)
54
+ $("#response").html(params["responseJSON"]["debug_status"]).removeClass("text-success").addClass("text-danger");
55
+ }).always(hideLoader);
56
+ }
@@ -1,7 +1,4 @@
1
- @import 'thecore_ui_commons/variables';
2
-
3
1
  // Spinner
4
-
5
2
  .loader {
6
3
  width: 40px;
7
4
  height: 40px;
@@ -65,7 +62,6 @@ div.row.tcp-debug {
65
62
  .tcp-debug-response {
66
63
  width: 100%;
67
64
  margin-left: 0.1em;
68
- height: 4em;
69
65
  }
70
66
 
71
67
  #response {
@@ -1,33 +1,40 @@
1
- <div class="row tcp-debug">
2
- <div class="input-group">
3
- <div class="input-group-prepend">
4
- <span class="input-group-text"><%=t :tcp_address_and_port%></span>
1
+
2
+ <div class="card mb-3">
3
+ <div class="card-body">
4
+ <div class="row tcp-debug">
5
+ <div class="input-group">
6
+ <div class="input-group-prepend">
7
+ <span class="input-group-text"><%=t :tcp_address_and_port%></span>
8
+ </div>
9
+ <input type="text" class="form-control" id="telnet-host" placeholder="Host" aria-label="Host">
10
+ <input type="text" class="form-control" id="telnet-port" placeholder="Port" aria-label="Port">
11
+ <div class="input-group-append">
12
+ <button class="btn btn-outline-secondary" type="button" id="telnet" onclick="startTest(this)"><%=t :test_it %></button>
13
+ </div>
14
+ </div>
5
15
  </div>
6
- <input type="text" class="form-control" id="telnet-host" placeholder="Host" aria-label="Host">
7
- <input type="text" class="form-control" id="telnet-port" placeholder="Port" aria-label="Port">
8
- <div class="input-group-append">
9
- <button class="btn btn-outline-secondary" type="button" id="telnet" onclick="startTest(this)"><%=t :test_it %></button>
16
+ <div class="row tcp-debug">
17
+ <div class="input-group">
18
+ <div class="input-group-prepend">
19
+ <span class="input-group-text"><%=t :ping_address %></span>
20
+ </div>
21
+ <input type="text" class="form-control" id="ping-host" placeholder="Host" aria-label="Host">
22
+ <div class="input-group-append">
23
+ <button class="btn btn-outline-secondary" type="button" id="ping" onclick="startTest(this)"><%=t :test_it%></button>
24
+ </div>
25
+ </div>
10
26
  </div>
11
27
  </div>
12
28
  </div>
13
- <div class="row tcp-debug">
14
- <div class="input-group">
15
- <div class="input-group-prepend">
16
- <span class="input-group-text"><%=t :ping_address %></span>
29
+
30
+ <div class="card mb-3">
31
+ <div class="card-body">
32
+ <div class="response tcp-debug-response" id="response">
17
33
  </div>
18
- <input type="text" class="form-control" id="ping-host" placeholder="Host" aria-label="Host">
19
- <div class="input-group-append">
20
- <button class="btn btn-outline-secondary" type="button" id="ping" onclick="startTest(this)"><%=t :test_it%></button>
34
+
35
+ <div class="loader">
36
+ <div class="double-bounce1"></div>
37
+ <div class="double-bounce2"></div>
21
38
  </div>
22
39
  </div>
23
40
  </div>
24
-
25
- <div class="row tcp-debug-response">
26
- <p id="response" class="response">
27
- </p>
28
- </div>
29
-
30
- <div class="loader">
31
- <div class="double-bounce1"></div>
32
- <div class="double-bounce2"></div>
33
- </div>
@@ -1,44 +1,5 @@
1
1
  Rails.application.configure do
2
2
  config.after_initialize do
3
- RailsAdmin::Config::Actions.add_action "tcp_debug", :base, :root do
4
- show_in_sidebar true
5
- show_in_navigation false
6
- breadcrumb_parent [nil]
7
- # This ensures the action only shows up for Users
8
- # visible? authorized?
9
- # Not a member action
10
- member false
11
- # Not a colleciton action
12
- collection false
13
-
14
- link_icon 'fas fa-heartbeat'
15
-
16
- # You may or may not want pjax for your action
17
- # pjax? true
18
-
19
- http_methods [:get]
20
- # Adding the controller which is needed to compute calls from the ui
21
- controller do
22
- proc do # This is needed because we need that this code is re-evaluated each time is called
23
- if request.xhr?
24
- case params["test"]
25
- when "telnet"
26
- port_is_open = Socket.tcp(params["host"], params["port"], connect_timeout: 5) { true } rescue false
27
- message, status = { debug_status: I18n.t("tcp_debug_telnet_ko", host: params["host"].presence || "-", port: params["port"].presence || "-") }, 503
28
- message, status = { debug_status: I18n.t("tcp_debug_telnet_ok", host: params["host"].presence || "-", port: params["port"].presence || "-") }, 200 if port_is_open
29
- when "ping"
30
- check = Net::Ping::External.new(params["host"])
31
- message, status = { debug_status: I18n.t("tcp_debug_ping_ko", host: params["host"].presence || "-") }, 503
32
- message, status = { debug_status: I18n.t("tcp_debug_ping_ok", host: params["host"].presence || "-") }, 200 if check.ping?
33
- else
34
- message, status = { debug_status: I18n.t("invalid_test", host: params["host"]) }, 400
35
- end
36
-
37
- ActionCable.server.broadcast("messages", { topic: :tcp_debug, status: status, message: message})
38
- render json: message.to_json, status: status
39
- end
40
- end
41
- end
42
- end
3
+ require 'root_actions/tcp_debug'
43
4
  end
44
5
  end
@@ -1,4 +1,4 @@
1
1
  Rails.application.config.assets.precompile += %w(
2
- rails_admin/custom/thecore/tcp_debug.js
3
- rails_admin/custom/thecore/tcp_debug.css
2
+ main_tcp_debug.js
3
+ main_tcp_debug.css
4
4
  )
@@ -0,0 +1,37 @@
1
+ RailsAdmin::Config::Actions.add_action "tcp_debug", :base, :root do
2
+ show_in_sidebar true
3
+ show_in_navigation false
4
+ breadcrumb_parent [nil]
5
+ # This ensures the action only shows up for Users
6
+ # visible? authorized?
7
+ # Not a member action
8
+ member false
9
+ # Not a colleciton action
10
+ collection false
11
+
12
+ link_icon 'fas fa-heartbeat'
13
+
14
+ http_methods [:get]
15
+ # Adding the controller which is needed to compute calls from the ui
16
+ controller do
17
+ proc do # This is needed because we need that this code is re-evaluated each time is called
18
+ if request.xhr?
19
+ case params["test"]
20
+ when "telnet"
21
+ port_is_open = Socket.tcp(params["host"], params["port"], connect_timeout: 5) { true } rescue false
22
+ message, status = { debug_status: I18n.t("tcp_debug_telnet_ko", host: params["host"].presence || "-", port: params["port"].presence || "-") }, 503
23
+ message, status = { debug_status: I18n.t("tcp_debug_telnet_ok", host: params["host"].presence || "-", port: params["port"].presence || "-") }, 200 if port_is_open
24
+ when "ping"
25
+ check = Net::Ping::External.new(params["host"])
26
+ message, status = { debug_status: I18n.t("tcp_debug_ping_ko", host: params["host"].presence || "-") }, 503
27
+ message, status = { debug_status: I18n.t("tcp_debug_ping_ok", host: params["host"].presence || "-") }, 200 if check.ping?
28
+ else
29
+ message, status = { debug_status: I18n.t("invalid_test", host: params["host"]) }, 400
30
+ end
31
+
32
+ ActionCable.server.broadcast("messages", { topic: :tcp_debug, status: status, message: message})
33
+ render json: message.to_json, status: status
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,3 +1,4 @@
1
1
  module ThecoreTcpDebug
2
- VERSION = "#{`git describe --tags $(git rev-list --tags --max-count=1)`}"
2
+ VERSION = "3.0.5".freeze
3
+ # "#{`git describe --tags $(git rev-list --tags --max-count=1)`}"
3
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thecore_tcp_debug
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.4
4
+ version: 3.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-05 00:00:00.000000000 Z
11
+ date: 2023-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ping
@@ -48,8 +48,8 @@ files:
48
48
  - MIT-LICENSE
49
49
  - README.md
50
50
  - Rakefile
51
- - app/assets/javascripts/rails_admin/custom/thecore/tcp_debug.js
52
- - app/assets/stylesheets/rails_admin/custom/thecore/tcp_debug.scss
51
+ - app/assets/javascripts/main_tcp_debug.js
52
+ - app/assets/stylesheets/main_tcp_debug.scss
53
53
  - app/views/rails_admin/main/tcp_debug.html.erb
54
54
  - config/initializers/add_to_db_migration.rb
55
55
  - config/initializers/after_initialize.rb
@@ -57,6 +57,7 @@ files:
57
57
  - config/locales/en.thecore_tcp_debug.yml
58
58
  - config/locales/it.thecore_tcp_debug.yml
59
59
  - db/seeds.rb
60
+ - lib/root_actions/tcp_debug.rb
60
61
  - lib/thecore_tcp_debug.rb
61
62
  - lib/thecore_tcp_debug/engine.rb
62
63
  - lib/thecore_tcp_debug/version.rb
@@ -1,59 +0,0 @@
1
-
2
- $(document).on('turbo:load', function (event) {
3
- // Event
4
- currentURL = new URL(event.originalEvent.detail.url);
5
- if(currentURL.pathname.endsWith("tcp_debug")){
6
- hideLoader();
7
-
8
- // Action cable Websocket
9
- App.cable.subscriptions.create("ActivityLogChannel", {
10
- connected() {
11
- console.log("Connected to the channel:", this);
12
- this.send({ message: 'TCP Debug Client is connected', topic: "tcp_debug", namespace: "subscriptions" });
13
- },
14
- disconnected() {
15
- console.log("Disconnected");
16
- },
17
- received(data) {
18
- if(data["topic"] == "tcp_debug")
19
- console.log("TCP DEBUG", data);
20
- }
21
- });
22
-
23
- $("#ping-host").keypress(function(event){if(event.keyCode == 13){$('#ping').click();}});
24
- $("#telnet-host").keypress(function(event){if(event.keyCode == 13){$('#telnet').click();}});
25
- $("#telnet-port").keypress(function(event){if(event.keyCode == 13){$('#telnet').click();}});
26
- }
27
- });
28
-
29
- function hideLoader() {
30
- $(".loader").hide();
31
- $(".tcp-debug-response").show();
32
- }
33
-
34
- function showLoader() {
35
- $(".loader").show();
36
- $(".tcp-debug-response").hide();
37
- }
38
-
39
- function startTest(element) {
40
- $("#response").empty();
41
- typeOfTest = $(element).attr("id");
42
- host = $(`#${typeOfTest}-host`).val();
43
- port = $(`#${typeOfTest}-port`).val();
44
- // console.log(typeOfTest)
45
- // console.log(host)
46
- // console.log(port)
47
- showLoader();
48
- $.get("#{rails_admin.send('tcp_debug_path')}", {
49
- test: typeOfTest,
50
- host: host,
51
- port: port
52
- }).then(function (params) {
53
- // console.log("OK", params)
54
- $("#response").html(params["debug_status"]).removeClass("bg-danger").addClass("bg-success");
55
- }).catch(function (params) {
56
- // console.log("KO", params)
57
- $("#response").html(params["responseJSON"]["debug_status"]).removeClass("bg-success").addClass("bg-danger");
58
- }).always(hideLoader);
59
- }