Skip to content

Commit

Permalink
Merge pull request #3 from yast/notify-changes
Browse files Browse the repository at this point in the history
Implement changes notification in  the UI
  • Loading branch information
imobachgs authored Dec 24, 2021
2 parents 55aa5a8 + 2ccba1b commit 130e50e
Show file tree
Hide file tree
Showing 60 changed files with 273 additions and 838 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ build-iPhoneSimulator/

# Used by RuboCop. Remote config files pulled in from inherit_from directive.
# .rubocop-https?--*

# Web interface logs directory
.log
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ The current UI is a small web application built with [React](https://reactjs.org
$ npm install
$ npm start

Point your browser to http://localhost:3001 and enjoy!
Point your browser to http://localhost:3000 and enjoy!

# References

Expand Down
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"web-vitals": "^0.2.2"
},
"scripts": {
"start": "HOST=localhost PORT=3001 react-scripts start",
"start": "HOST=localhost PORT=3000 react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
Expand Down
4 changes: 2 additions & 2 deletions web/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ function App() {
console.log("WebSocket Event", event);
const { data } = event;
const changedKeys = Object.keys(JSON.parse(data));
if (changedKeys.includes("disk")) {
if (changedKeys.includes("Disk")) {
loadStorage(dispatch);
}

if (changedKeys.includes("status")) {
if (changedKeys.includes("Status")) {
loadInstallation(dispatch);
}
});
Expand Down
4 changes: 3 additions & 1 deletion web/src/context/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ let _installerClient;
const installerClient = () => {
if (_installerClient) return _installerClient;

_installerClient = new InstallerClient('http://localhost:3000');
_installerClient = new InstallerClient({
url: 'http://localhost:3001', ws: 'ws://localhost:3002'
});
return _installerClient;
};

Expand Down
19 changes: 9 additions & 10 deletions web/src/lib/InstallerClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@
import axios from 'axios';

export default class InstallerClient {
constructor(url) {
constructor({ url, ws }) {
this.url = url;
// const wsUrl = url.replace("http", "ws") + "/ws";
// this.socket = new WebSocket(`${wsUrl}`);
// this.socket.onclose = () => console.log("The socket was closed");
this.socket = new WebSocket(`${ws}`);
this.socket.onclose = () => console.log("The socket was closed");
}

onMessage(handler) {
// this.socket.addEventListener("message", handler);
this.socket.addEventListener("message", handler);
}

async getInstallation() {
Expand All @@ -39,14 +38,14 @@ export default class InstallerClient {

async getProducts() {
const { data } = await axios.post(
`${this.url}/calls.json`, { meth: "GetProducts" }
`${this.url}/calls`, { meth: "GetProducts" }
);
return data;
}

async getLanguages() {
const { data } = await axios.post(
`${this.url}/calls.json`, { meth: "GetLanguages" }
`${this.url}/calls`, { meth: "GetLanguages" }
);
return Object.keys(data).map(key => {
return { id: key, name: data[key][1] }
Expand All @@ -55,20 +54,20 @@ export default class InstallerClient {

async getStorage() {
const { data } = await axios.post(
`${this.url}/calls.json`, { meth: "GetStorage" }
`${this.url}/calls`, { meth: "GetStorage" }
);
return data;
}

async getDisks() {
const { data } = await axios.post(
`${this.url}/calls.json`, { meth: "GetDisks" }
`${this.url}/calls`, { meth: "GetDisks" }
);
return data;
}

async getOptions() {
const { data } = await axios.get(`${this.url}/properties.json`);
const { data } = await axios.get(`${this.url}/properties`);
return Object.fromEntries(
Object.entries(data[0]).map(([k, v]) => [k.toLowerCase(), v])
)
Expand Down
5 changes: 0 additions & 5 deletions yastd-proxy/.gitattributes

This file was deleted.

70 changes: 50 additions & 20 deletions yastd-proxy/.gitignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,56 @@
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'
*.gem
*.rbc
/.config
/coverage/
/InstalledFiles
/pkg/
/spec/reports/
/spec/examples.txt
/test/tmp/
/test/version_tmp/
/tmp/

# Used by dotenv library to load environment variables.
# .env

# Ignore Byebug command history file.
.byebug_history

# Ignore bundler config.
/.bundle
## Specific to RubyMotion:
.dat*
.repl_history
build/
*.bridgesupport
build-iPhoneOS/
build-iPhoneSimulator/

## Specific to RubyMotion (use of CocoaPods):
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# vendor/Pods/

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep
## Documentation cache and generated files:
/.yardoc/
/_yardoc/
/doc/
/rdoc/

# Ignore pidfiles, but keep the directory.
/tmp/pids/*
!/tmp/pids/
!/tmp/pids/.keep
## Environment normalization:
/.bundle/
/vendor/bundle
/lib/bundler/man/

# for a library or gem, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# Gemfile.lock
# .ruby-version
# .ruby-gemset

# Ignore master key for decrypting credentials and more.
/config/master.key
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc

# Ignore vendor/bundle, where gems are installed
vendor/bundle
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
# .rubocop-https?--*
1 change: 0 additions & 1 deletion yastd-proxy/.ruby-version

This file was deleted.

55 changes: 10 additions & 45 deletions yastd-proxy/Gemfile
Original file line number Diff line number Diff line change
@@ -1,47 +1,12 @@
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby "2.7.5"

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.0.0"

# Use the Puma web server [https://github.com/puma/puma]
gem "puma", "~> 5.0"

# Build JSON APIs with ease [https://github.com/rails/jbuilder]
# gem "jbuilder"

# Use Redis adapter to run Action Cable in production
# gem "redis", "~> 4.0"

# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
# gem "kredis"
# frozen_string_literal: true

# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
# gem "bcrypt", "~> 3.1.7"

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]

# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false

# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
# gem "rack-cors"

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri mingw x64_mingw ]
end

group :development do
# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
# gem "spring"
end

# Add CORS support
gem "rack-cors"
source "https://rubygems.org"

# Run commands
gem "cheetah"
gem "eventmachine"
gem "em-websocket"
gem "rack-contrib", require: "rack/contrib"
gem "rake"
gem "sinatra"
gem "sinatra-cors"
gem "ruby-dbus", require: "dbus"
gem "thin"
Loading

0 comments on commit 130e50e

Please sign in to comment.