diff --git a/jam-ui/.env.development b/jam-ui/.env.development index 03d0588a9..cc7c8f542 100644 --- a/jam-ui/.env.development +++ b/jam-ui/.env.development @@ -1,2 +1,2 @@ -REACT_APP_LEGACY_BASE_URL=http://www.jamkazam.local:4000/ +REACT_APP_LEGACY_BASE_URL=http://www.jamkazam.local:4000 REACT_APP_API_BASE_URL=http://www.jamkazam.local:4000/api \ No newline at end of file diff --git a/jam-ui/.env.production b/jam-ui/.env.production new file mode 100644 index 000000000..64ac8589a --- /dev/null +++ b/jam-ui/.env.production @@ -0,0 +1,2 @@ +REACT_APP_LEGACY_BASE_URL=https://www.jamkazam.com +REACT_APP_API_BASE_URL=https://www.jamkazam.com/api \ No newline at end of file diff --git a/jam-ui/public/index.html b/jam-ui/public/index.html index 6729cfd40..3c65bdaa4 100644 --- a/jam-ui/public/index.html +++ b/jam-ui/public/index.html @@ -5,12 +5,11 @@ - + /> JamKazam diff --git a/jam-ui/src/App.js b/jam-ui/src/App.js index 74c430962..bb66a59cb 100644 --- a/jam-ui/src/App.js +++ b/jam-ui/src/App.js @@ -6,8 +6,12 @@ import 'react-toastify/dist/ReactToastify.min.css'; import 'react-datetime/css/react-datetime.css'; import 'react-image-lightbox/style.css'; +import useImportScript from "./hooks/useImportScript"; + const App = () => { + useImportScript(`${process.env.REACT_APP_LEGACY_BASE_URL}/client_scripts`) + return ( diff --git a/jam-ui/src/components/profile/JKMessageButton.js b/jam-ui/src/components/profile/JKMessageButton.js index 3b806a5b2..75ddb1249 100644 --- a/jam-ui/src/components/profile/JKMessageButton.js +++ b/jam-ui/src/components/profile/JKMessageButton.js @@ -24,7 +24,8 @@ const JKMessageButton = props => { className={`btn btn-primary ${cssClasses}`} title={buttonTitle()} data-testid="message" - disabled={!isFriend} + //disabled={!isFriend} + disabled={false} > {children} diff --git a/jam-ui/src/components/profile/JKMessageModal.js b/jam-ui/src/components/profile/JKMessageModal.js index 66746b85f..7a22acb26 100644 --- a/jam-ui/src/components/profile/JKMessageModal.js +++ b/jam-ui/src/components/profile/JKMessageModal.js @@ -46,6 +46,8 @@ const JKMessageModal = props => { } }, [show]); + + return ( <> diff --git a/jam-ui/src/hooks/useImportScript.js b/jam-ui/src/hooks/useImportScript.js new file mode 100644 index 000000000..783dfcc0c --- /dev/null +++ b/jam-ui/src/hooks/useImportScript.js @@ -0,0 +1,13 @@ +import { useEffect } from 'react'; +const useImportScript = resourceUrl=> { + useEffect(() => { + const script = document.createElement('script'); + script.src = resourceUrl; + script.defer = true; + document.body.appendChild(script); +return () => { + document.body.removeChild(script); + } + }, [resourceUrl]); +}; +export default useImportScript; \ No newline at end of file diff --git a/jam-ui/src/layouts/DashboardLayout.js b/jam-ui/src/layouts/DashboardLayout.js index 14628bbb6..83dc85090 100644 --- a/jam-ui/src/layouts/DashboardLayout.js +++ b/jam-ui/src/layouts/DashboardLayout.js @@ -20,6 +20,7 @@ import { getPageName } from '../helpers/utils'; import { useAuth } from '../context/AuthContext'; import { getCurrentUser } from '../helpers/rest'; + const AUTH_STAGES = { loading: 1, authenticated: 2, @@ -52,8 +53,11 @@ const DashboardLayout = ({ location }) => { }); }; + + useEffect(() => { fetchCurrentUser(); + //registerForChatMessages() }, []); useEffect(() => { @@ -76,8 +80,8 @@ const DashboardLayout = ({ location }) => { const DashboardLoadingIndicator = () => { return ( -
- Loading... +
+ Loading...
); }; @@ -108,8 +112,21 @@ const LoginRequestSection = () => { const DashboardSection = () => { const { isFluid, isVertical, navbarStyle } = useContext(AppContext); const isKanban = getPageName('kanban'); + + const registerForChatMessages = () => { + console.log('registering for chat messages'); + window.JK.JamServer.registerMessageCallback(window.JK.MessageType.CHAT_MESSAGE, function (header, payload) { + console.debug("Handling CHAT_MESSAGE msg " + JSON.stringify(payload)); + }) + } + + useEffect(() => { + //registerForChatMessages() + }, []); return ( + +
{isVertical && } @@ -126,6 +143,7 @@ const DashboardSection = () => { {/* */}
+ ); }; diff --git a/web/app/controllers/clients_controller.rb b/web/app/controllers/clients_controller.rb index 0e69dd440..54db426c4 100644 --- a/web/app/controllers/clients_controller.rb +++ b/web/app/controllers/clients_controller.rb @@ -6,29 +6,13 @@ class ClientsController < ApplicationController AUTHED = %W{friend} + def scripts + _index + render :layout => 'scripts', content_type: 'text/javascript' + end def index - - enable_olark - gon.olark_box_start_hidden = true - - # we want to enforce that /client is always the client view prefix - # this is a side effect of setting root path to '/'; soon we can remove this when we implement the new home page - if request.path == '/' - redirect_to client_url - return - end - - if current_user - @is_guitar_center = false #current_user.is_guitar_center? - gon.user_id = current_user.id - gon.user_email = current_user.email - gon.user_name = current_user.name - end - - @in_client_page = true - @minimal_curtain = Rails.application.config.minimal_curtain - gon.recurly_tax_estimate_jam_track_plan = Rails.application.config.recurly_tax_estimate_jam_track_plan + _index render :layout => 'client' end @@ -51,4 +35,28 @@ class ClientsController < ApplicationController end end + private + + def _index + enable_olark + gon.olark_box_start_hidden = true + + # we want to enforce that /client is always the client view prefix + # this is a side effect of setting root path to '/'; soon we can remove this when we implement the new home page + if request.path == '/' + redirect_to client_url + return + end + + if current_user + @is_guitar_center = false #current_user.is_guitar_center? + gon.user_id = current_user.id + gon.user_email = current_user.email + gon.user_name = current_user.name + end + + @in_client_page = true + @minimal_curtain = Rails.application.config.minimal_curtain + gon.recurly_tax_estimate_jam_track_plan = Rails.application.config.recurly_tax_estimate_jam_track_plan + end end diff --git a/web/config/application.rb b/web/config/application.rb index bfbfed764..b3361beea 100644 --- a/web/config/application.rb +++ b/web/config/application.rb @@ -96,6 +96,8 @@ if defined?(Bundler) config.assets.precompile += %w( support/support.js support/support.scss ) config.assets.precompile += %w( jk2021/jk2021.js jk2021/jk2021.css ) + config.assets.precompile += %w( modern/scripts.js ) + # where is rabbitmq? config.rabbitmq_host = "127.0.0.1" config.rabbitmq_port = 5672 diff --git a/web/config/routes.rb b/web/config/routes.rb index ac601cb3d..629b668c6 100644 --- a/web/config/routes.rb +++ b/web/config/routes.rb @@ -1,5 +1,7 @@ Rails.application.routes.draw do + + scope :as => 'jam_ruby' do resources :users resources :music_sessions @@ -110,7 +112,11 @@ Rails.application.routes.draw do get '/isp/ping.jar', :to => redirect('/ping.jar') get '/isp/ping:isp', :to => 'users#jnlp', :constraints => {:format => :jnlp}, :as => 'isp_ping' + get '/client', to: 'clients#index' + + get '/client_scripts', to: 'clients#scripts' #outputs javascript for external clients + get '/latency_tester', to: 'clients#latency_tester' get '/confirm/:signup_token', to: 'users#signup_confirm', as: 'signup_confirm'