Bootstrap ui-router states programmatically - angular-ui-router

I'm working with angular 1.
I want to load some data from server before ui-router bootstrapping all the states.
Is it possible to do so?

I would say that in this Question: AngularJS - UI-router - How to configure dynamic views and mostly in this answer you can get the answer.
The point is to use a feature of UrlRouterProvider - deferIntercept()
The deferIntercept(defer)
Disables (or enables) deferring location change interception.
If you wish to customize the behavior of syncing the URL (for example,
if you wish to defer a transition but maintain the current URL), call
this method at configuration time. Then, at run time, call
$urlRouter.listen() after you have configured your own
$locationChangeSuccess event handler.
Full description including working example is here

Related

Vaadin UI between sessions

When I am creating a new session (or try to access from an other computer) in Vaadin Flow I get this error:
Can't move a node from one state tree to another
From this link, I read something about UI and getUIId().
However, I don't understand how I should change my application in order to fix the error.
As Denis mentioned in the forum post you linked, wrong scope sounds like the most likely culprit. In other words, you are trying to use the exact same component instance in two different UIs, when both UIs should have their own instance. It's not possible to use the same instance in two places at the same time.
You can find the documentation for Vaadin Spring scopes here: https://vaadin.com/docs/latest/flow/integrations/spring/scopes
One possible cause of errors such as that is that if you're storing a Component in a static variable. You shouldn't do that - a Component instance can only belong to a single UI. A single UI in turn (in practice) means a single browser tab.

How can I access a new window when test is running using cypress

I want to visit an url perform some operations then open different url in different tab/window and perform some action in new tab and come back to the previous tab/window and so on. Is this possible in cypress?
Please suggest some solution if possible.
Cypress does not and will not support handling more than one tab/browser, for further read and recipes see: https://docs.cypress.io/guides/references/trade-offs.html#Multiple-tabs
I see two solutions:
Use api request for the operations needed for the external url
Divide the test in different cases
2.1. In before/beforeEach section make preparations needed
2.2. It case for first part in your project
2.3. It case for the different url
2.4. It case for the second part needed in your project
If have some repetitive data that needs to be reused - you can declare it as a variable ouside of the "describe" scope with usual JS code.

How to change URL at runtime

We are trying to use Cobalt (20.stable) browser as the browser of our web SPA application.
My requirement is to be able to change URL at runtime, what I was able to find in the code:
Is:
starboard::shared::starboard::Application::Link(const char* link_data)
which ends up sending:
kSbEventTypeLink
Unfortunately this is not working, as code is ignoring the call; the handling reaches the point:
// TODO: Remove this when terminal application states are properly handled.
if (deep_link_event->IsH5vccLink()) {
browser_module_->Navigate(GURL(deep_link_event->link()));
}
In my case I m trying to change the URL to let say https://www.example.com.
There should be a way to do that as when navigating we can always have a link that will cause the browser to go to some URL?
Porting layer is not supposed to control navigation directly. Instead, your Starboard implementation may send a deep link event which could be intercepted by a web app which will perform a navigation. See h5vcc_runtime.idl for Web API.
That said, if you are building an SPA, why do you even need to change a URL? Initial URL of a web app is controlled by --url command line switch.
When you say runtime are you looking to change the initial URL when the app is first launched? If so, you could just use the --url parameter.
So you could do the following:
cobalt --url="https://www.example.com"
I did a patch to allow changing the URL.
I just need to call starboard::shared::starboard::Application::Link("https://www.example.com").
Inside this call a DeepLinkEvent is posted.
Patch : https://gofile.io/?c=9GvNHX
Cobalt does not navigate for you. The JavaScript receives the deeplink with the function it sets on h5vcc.runtime.onDeepLink and then does whatever it wants with that. As a SPA, it will parse the URL and load new content from its server in its own internal data format (e.g. protocol buffers, JSON, etc.) which it uses to update its own DOM to show new content.
Navigating is not the point of a SPA since that makes it not be a single page application. However, there may be cases such as a loader app that will want to make some initial decisions then load the actual SPA. That loader app would have to have the appropriate CSP rules in place, then set window.location to the URL of the page to navigate to.
Note: The code you found in Application::OnDeepLinkEvent() is a remnant that previously supported the H5vccURLHandler, which was removed in Cobalt 20. It's not meant to navigate to arbitrary deeplinks.

Nativescript - resumeEvent handling

In my app when the app is resumed from a sleep, I'd like to
reload the page - or ideally, just update specific UI elements.
How can this be done?
Preferably in a platform independent way.
You want to hook into the onResume method in the application module which exposes the event when an app resumes from the background.
https://docs.nativescript.org/api-reference/modules/application.html#onresume
So in your app.js (the entry point of your application), import the module and add the onResume event handler and it can run everytime the app resumes. Now reloading a page will require a little more work. You'd have to use the frame module and find out the current page and do your work, but I'm guessing it can be done with a little effort using the approach mentioned.
UPDATE: based off your comment, you need the reloadPage() method from the ui/frame module. https://docs.nativescript.org/api-reference/modules/_ui_frame_.html#reloadpage
The correct method is reloadPage() in the Frame module (as contributed by #Brad) but the problem is that it's NOT an exposed api.
No problem - just copy/paste it and it works.
The problem is that it basically does a navigateTo() to the currentPage and that effects the navigation history. You have 2 choices - setting clearHistory to true and you lose all history (don't want that) or set clearHistory to false which creates a a duplicate of the current-page (don't want that either). There's also a backstackVisible option but that doesn't help in this scenario.
#Brad tells me that there's api that allows access to the navigation stack - haven't looked into it.
For my app - the user will be at the root page most of the time, so I decided to reload the page only if on the root page and then set clearHistory to true and that works for me.

Kendo UI Grid/DataSource - Global Error Handling?

I've currently inherited an application which has numerous Kendo grids (and other controls) throughout, and I'm trying to fix an error which keeps cropping up now and again - specifically when the user is no longer authenticated.
I know what the solution is for a single instance of the control - return a flag to indicate authentication failed, and then detect this in the error handler and perform the authentication.
The problem is am I really going to have to handle this for every instance of a Kendo control I have? Is there not a global error handler I can hook into? Either for the data source itself (as I know this is used for all Kendo control data loading), or for the Grid specificially. I don't mind either way - just which one is a hook.
This would be a more straighforward short term solution than refactoring everything to specific error handlers, etc.
I assume you can attach a global error handler to $.ajax, which is used by the DataSource, you can check how to do it here:
http://api.jquery.com/category/ajax/global-ajax-event-handlers/
Or, you can take advanttage of that the configuration that is done in the DataSource is passed directly to the $.ajax:
http://docs.kendoui.com/api/framework/datasource#configuration-transport.read-ObjectStringFunction
For reference, someone from Telerik has provided a solution using just the DataSource. I haven't tested it, but I prefer the accepted answer above as it hooked into all Ajax on the site - not just ones that utilise the Kendo DataSource.
http://www.kendoui.com/forums/mvc/grid/global-error-handler-for-numerous-grids.aspx

Resources