I got a little Problem at the Moment:
Im building a new WebApp with different States. For this im using UI-Router.
Different States mean different URLs.
The Problem is the WebApp has to open a connection via Websocket to a server. If the connection is opened and the user navigate through the page there is no Problem. The Problem for me is the first "State" the user enters the WebApp.
Example URLs:
".../" -> open Connection -> State Home
".../#/Overview" -> open Connection -> State Overview
".../#/User/12" -> open Connection -> State User with resolve for User-Id 12
I hope you understand what I mean.
First i thought I do this with a resolve but then I thought okay i want the user to show the information"open Connection" during the process.
If I use mutiple resolves (my 3rd Example) it would also Display open Connection
So I need some "State" in the middle which Jumps in and then navigate to the state the user opened
Nobody has a answer?
Or is there maybe a way to initialize the page/App before UI-Router starts to work?
So before any States would Start the WebApp should open the connection and if it fails go to State "X" if not UI-Router should just do his normal job
Related
In my ReactJS project a link will be opened with some unique id .../connect/123456 By opening this user can have video call with someone. This is working but the problem is if copy the link and open in a new tab or new browser it still works. What I need is an error message says "Connection already made". How to achieve this?
You can solve this server side. Simply have a flag on your database that the call is already in progress. On the front-end side, simply fetch this flag from the database, if call is already in progress: then display the error message and redirect as necessary.
I am new to mobx-persist. I am not able to figure out how rehydration works in mobx-persist. I tried asking about it in github but got no reply so far. I am wondering if anyone here is able to point me the right direction.
The problem that I am trying to solve is to prevent losing the react states on the page refresh. I want to keep the stats in the session storage and load them back when the page is refreshed. (Note: I managed to do it by accessing the session storage directly from the react store but I thought that mobx-persist might do the better job.)
I created a sample here. https://github.com/michaelsync/js-lab/tree/master/mobx-persist-sample.
You can use the following command to run the sample.
yarn install
yarn start
It has two components called "entry" page and "result". User can enter something in "entry" page and show that data in the "result" page. There is one store called userDataStore that has only one property called data.
When you click on "Click Me" in the entry page, the data that you typed on text box will be saved in user data store. and it retrieves the data back from the result page.
The issue is that when I refresh the page, I still lost the react states. I guess it's because I don't understand how rehydration works in mobx-persist.
The steps to replicate the issue ~
run the program by using yarn start
enter something in textbox and click on "Click me" (It will redirect to the result page)
you will see what you entered in the result page.
Refresh the page (press F5) - the data will be lost.
Can someone please help me with the steps that I need to do in hydration and rehydration?
Note: I don't want to use any server-side code or isomorphic rendering to sync the states for now. using the session storage might be anti-pattern but I see it fit in my tiny project.
I am using angular
Lets say i have login screen(model,controller,view) and few other screens (model,controller,view) that perform some secret manipulation that available only to logged in user.
Is this possible to load to browser only login files(That those files won't be shown in F12/sources) ,then when user successfully logged in load all the secret files.
In short i don't want that user can see those files before he logged in.
That is one of the problems within client-side applications like angular SPAs. Since you want to load the content from your server, IF something happens on the client, the client already has to know, where it can get the content.
One solution could be to us ui-router. (Documentation). There, you can set a state for logged in users. Every state can have an own html template, which gets loaded, when you enter the state.
The problem ist, that the path of said html template is already on the client. That means, you have to set some kind of cookie from your server, so that you know, that the client is logged in. And only then, the requested template can be recieved. That way everybody can know where the template is on your server but cannot access it.
I am really new in webprogramming and using angularJs and ionic to create an app.
Here is my problem, morelikeley my issue that I want to deal with the right way:
I have got a button which will exchange some data with my server and then link to an other website.
I am now wondering if it is the correct way to add an ng-clicked on my button which then runs a script that talks to my server and after that calls the next website by $location.path()?
Problem with this is, that it always throws an error saying:
Error: $location is not defined $scope.click#http://localhost:8100/scripts/controllers.js:17:9 $parseFunctionCall#http://localhost:8100/lib/angular/angular.js:12237:15 #http://localhost:8100>/lib/ionic/release/js/ionic-angular.js:7788:9 $RootScopeProvider/this.$get</Scope.prototype.$eval#http://localhost:8100/lib/angular/angular.js:14291:16 $RootScopeProvider/this.$get</Scope.prototype.$apply#http://localhost:8100/lib/angular/angular.js:14389:18 #http://localhost:8100/lib/ionic/release/js/ionic-angular.js:7787:7 jQuery.event.dispatch#http://localhost:8100/lib/jquery/dist/jquery.js:4408:15 jQuery.event.add/elemData.handle#http://localhost:8100/lib/jquery/dist/jquery.js:4095:6 triggerMouseEvent#http://localhost:8100/lib/ionic/release/js/ionic.js:2641:3 tapClick#http://localhost:8100/lib/ionic/release/js/ionic.js:2630:3 tapMouseUp#http://localhost:8100/lib/ionic/release/js/ionic.js:2700:5
My other idea is to set an href on the button which links to the next website, but then i cannot ensure that my script was executed successfully before redirecting, or is there a way to handle this?
Thanks!
I have a page with a button and a form. Initially only the button will be visible, form is hidden using ng-hide condition (link to third party website) , on clicking that button you will be redirected to another page for log-in. After log-in my API redirects to my original page but instead of ,
localhost:8443/mypage/mypage.html (where i set a variable as true once log-in is success to display the form)
callback is for
john-1234:8443/mypage/mypage.html (the variable is not set true)
Is there any difference between calling as localhost:8443 and john-1234:8443. Does it have any impact on variables evaluated by controller.
Please help me. Sorry if this is a silly doubt. But i am new to this.
localhost means this computer and resolved as 127.0.0.1 as you may already know.
john-1234 will not be resolved then as it does not mean this computer for your system.
So your controller will not receive the variables. Possibly you have a test environment. If you proceed with production environment, then you would be able to redirect to an exact URL which will perfectly work.