vitalidze / traccar-web

Traccar Web UI mod
http://traccar.litvak.su/
151 stars 145 forks source link

Help with the "Logout Button" #992

Open leo0880 opened 7 years ago

leo0880 commented 7 years ago

Hi Vitaly, First that all, thanks for all this great platform that you have developed, it is really nice. I have a question, due that I am not a good programmer, the thing is that I am trying to redirect to different website address once I click on the "Logout Button". For this what I did was on the file /traccar-web/src/main/java/org/traccar/web/src/main/java/org/traccar/web/client/view/NavView.java I modified the following:

@UiHandler("logoutButton") public void onLogoutClicked(SelectEvent event) { Application.getDataService().logout(new BaseAsyncCallback(i18n) { @Override public void onSuccess(Boolean result) { Window.Location.replace("http://example.com"); //or Window.Location.assign("http://example.com"); } }); }

But when I click on "logout Button" the page stay in blank on Chrome and internet explorer say something about frame instead to go to the specific address. Again I am not a good programmer but any help from you will be appreciate. Thanks

vitalidze commented 7 years ago

I think you are on the right way. This should work with either Window.Location.replace or with Window.Location.assign methods. According to the docs, assign runs the javascript with window.location= code, which is the most convenient way to do the redirect from javascript. You need to read web browser console error messages to figure out why it does not work for you.