jigarius / toggl2redmine

Import time from Toggl 2 Redmine.
GNU General Public License v3.0
26 stars 6 forks source link

Error: Could not fetch Toggl Workspaces. Please refresh the page to try again. #42

Closed akawoj closed 5 years ago

akawoj commented 5 years ago

Hi,

thanks for great work!

I'm trying to use this plugin, but after providing API key I got: "Could not fetch Toggl Workspaces. Please refresh the page to try again." error on Toggl tab in Redmine. The timelog table below is empty. How can I fix this or find the reason of such behaviour?

jigarius commented 5 years ago

I have a theory, however, I need to know on what domain you are using the plugin.

akawoj commented 5 years ago

I have a theory, however, I need to know on what domain you are using the plugin.

redmine.something.pl

jigarius commented 5 years ago

I think you'll have to contact Toggl to whitelist your domain. I had to do it for my own setup as well. I'm trying to figure out a work around for this.

akawoj commented 5 years ago

What should I say to them? What do you mean by whitelist my domain? I was using toggl API for another plugin for redmine, from the same domain and it was working fine.

jigarius commented 5 years ago

Since some of the requests in my plugin are being made from client-side JS, Toggl needs to whitelist your domain. Just send them a link to my plugin and tell them that the requests are failing and that you want them to allow requests from your domain. Don't forget to send them the domain though :)

akawoj commented 5 years ago

thx, working on it

akawoj commented 5 years ago

My domain has been whitelisted and workspaces are loading properly.

Now I got another problem - I can't see any hours from toggl - there is only endless loader on "Time logged on Toggl" section. I also have "Invalid Date" in "Last imported on" section.

jigarius commented 5 years ago

Can you tell me the version of Redmine you're using? Also, can you check the developer console to see if there are any JavaScript errors?

jigarius commented 5 years ago

BTW, just curious. Have you followed the installation instructions correctly? Especially the step where you run the migrations?

akawoj commented 5 years ago

We are using Redmine 3.4.9.stable

The errors from javascript console:

[Error] RangeError: Invalid Date
    toISOString (t2r.js:720)
    _getRawTogglTimeEntries (t2r.js:720)
    getTogglTimeEntries (t2r.js:765)
    updateTogglReport (t2r.js:842)
    (anonimowa funkcja) (t2r.js:413)
> T2RConsole.setVerboseMode(1)
< undefined
> T2RConsole.setVerboseMode()
< undefined
> T2RConsole.setVerboseMode
< function (status) {
  T2R.browserStorage('t2r.debug', status == true);
}
[Error] RangeError: Invalid Date
    toISOString (t2r.js:720)
    _getRawTogglTimeEntries (t2r.js:720)
    getTogglTimeEntries (t2r.js:765)
    updateTogglReport (t2r.js:842)
    (anonimowa funkcja) (t2r.js:413)
akawoj commented 5 years ago

And yes, we've done the migrations

jigarius commented 5 years ago

I think you're a victim of issue #43 as well. The migrations probably didn't run well. Try running the migrations again with the latest code on the master branch.

RAILS_ENV=production bundle exec rake redmine:plugins:migrate

After this, try the plugin again. While you're on the plugin page, try doing a hard refresh and let me know how it goes.

If the problem persists, we can probably setup a screen sharing session so that I can see what's going and find the right fix.

akawoj commented 5 years ago

Hi,

I used the lastest code and did the migrations. No it works on macOS Chrome, still doesn't work on Safari (I did "hard refresh"). I will check it with other people on Safari and let you know.

jigarius commented 5 years ago

Aha! That might explain it. I've never tested it on Safari because it's a browser that not many people use. It's like Apple's Internet Explorer 😅 I'll do some tests on Safari.

jigarius commented 5 years ago

@akawoj I think it should work for you now. I tested it on Safari and found it to be working. There were three problems:

The fixes are in the 3.x branch. Let me know if you can use the plugin now.

akawoj commented 5 years ago

I've installed the latest version, did the hard refresh and still no luck on Safari ("invalid date" errors in javascript console)

jigarius commented 5 years ago

That is highly strange. So, you did:

If the above steps don't work for you, would you be able to do a screen-sharing session so that I can help you further?

As for me, it now works correctly on Safari as well as Chrome.

akawoj commented 5 years ago

It work, I had to manually clean Safari cache. Thanks for your help and very good work with plugin.