Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import JSON schema #2

Open
awdDev786 opened this issue Sep 9, 2017 · 50 comments
Open

Cannot import JSON schema #2

awdDev786 opened this issue Sep 9, 2017 · 50 comments

Comments

@awdDev786
Copy link

awdDev786 commented Sep 9, 2017

I exported JSON schema and then deleted all tables from database.then i tried importing same JSON schema ,it isn't giving any error but not importing schema too.
I tried following solutions before importing schema

  • deleted previous db and created new with same name and imported

  • deleted tables from existing db and imported

  • no change in existing db and tried importing

    etc
    But no solution worked.

Kindly guide me how to import the JSON schema or help me in identifying my mistake.

@Agontuk
Copy link
Owner

Agontuk commented Sep 9, 2017

Can you open the console and check if it's giving any errors after import? Also check the json file if it contains the tables you created.

@awdDev786
Copy link
Author

yes there is no error in console and even json file contains the tables i created.

@awdDev786
Copy link
Author

I tried importing on Official Demo site too but it didn't work.Kindly share example schema.json file which is working on mentioned link so that i can compare with my schema.json for identifying error.

@Agontuk
Copy link
Owner

Agontuk commented Sep 10, 2017

Works fine for me, here's a sample json file.

schema.json.zip

@awdDev786
Copy link
Author

it is neither showing any schema nor giving error.

@Agontuk
Copy link
Owner

Agontuk commented Sep 10, 2017

Then probably it's a browser issue, try clearing cache. It's working fine for me. Also if you can, give me a sample json file so that I can test it.

@awdDev786
Copy link
Author

Google version : 60.0.3112.113.
Windows:10 64bit
database name is same as in schema.json.tried with cache cleaning and the same schema.json file u sent.

@awdDev786
Copy link
Author

I have sent schema.json at mail.kindly have a look.

@awdDev786
Copy link
Author

awdDev786 commented Sep 11, 2017

Have you got sample schema which i've sent in email mentioned Here?

@Agontuk
Copy link
Owner

Agontuk commented Sep 11, 2017

Got the mail, seems like the one I sent. Again it works here. Can you import the json file again and after it is imported, go to console and use this command

JSON.parse(localStorage.getItem('schema'))

The output should match the json file, if not that's the issue you're facing IMO.

@awdDev786
Copy link
Author

ok thank u for lead.m checking it.

@awdDev786
Copy link
Author

its empty schema without any table while schema.json has tables.

@Agontuk
Copy link
Owner

Agontuk commented Sep 11, 2017

Another thing, when you're building a schema and then refresh the page, does it start from the beginning or it persists all the work you did until now ?

@awdDev786
Copy link
Author

it persists when i refreshed page

@Agontuk
Copy link
Owner

Agontuk commented Sep 11, 2017

Then it's certainly an importing issue, how are you importing it ? Just clicking import and select the json file, right ? Cause there's no other way as far as I remember.

@Agontuk
Copy link
Owner

Agontuk commented Sep 11, 2017

Can you try importing files with different extensions and see if it gives an alert like 'Please select the exported json file'

@awdDev786
Copy link
Author

yes it gave this error once.i changed the db name and kept them same.error vanished nw have no clue

@Agontuk
Copy link
Owner

Agontuk commented Sep 13, 2017

I've no clue as to what's happening on your side, I tried many times on my side and it works every time. So I haven't been able to reproduce it once. As a last resort, you can try with different browsers and see if it works.

@EagerDev
Copy link

I am also facing the same issue and one more observation is i am passing a value from header to schema component where it is updating the localstorage.but change in localstorage isn't updating component.I think both issues are same that change in localstorage after component is already rendered isnt re-rendering the component.

@Agontuk
Copy link
Owner

Agontuk commented Oct 13, 2017

localStorage change doesn't trigger re-rendering. It's only purpose is to read the saved state when you reload the page.

@awdDev786
Copy link
Author

@Agontuk kindly look at this video of issue.I made it for you.
ISSUE is described here.

My browser is:
Google Chrome | 61.0.3163.100

@Agontuk
Copy link
Owner

Agontuk commented Oct 20, 2017

Thanks for the video, it looks like your browser is not reloading itself after importing the json file. I'll take a look at it ASAP.

@Agontuk
Copy link
Owner

Agontuk commented Oct 21, 2017

I pushed a possible fix for this issue, let me know if it works for you.

@awdDev786
Copy link
Author

Have you updated in official site here?

@awdDev786 awdDev786 reopened this Oct 21, 2017
@awdDev786
Copy link
Author

Official Demo is still having the same issue.and also cloning new version didn't do the trick.(Sorry for accidentally closing it.)

@Agontuk
Copy link
Owner

Agontuk commented Oct 22, 2017

@awdDev786 can you check if this snippet works in your browser? I think FileReader API is somehow not triggering any event on your end.

@awdDev786
Copy link
Author

Through this code only .txt files can be read.schema.json file is not being read.

@Agontuk
Copy link
Owner

Agontuk commented Oct 22, 2017

So, it worked with .txt files ?

@awdDev786
Copy link
Author

yes.it read .txt file

@Agontuk
Copy link
Owner

Agontuk commented Oct 22, 2017

Thanks, I'll try another fix.

@awdDev786
Copy link
Author

Ok thank you for your concern.

@Agontuk
Copy link
Owner

Agontuk commented Oct 25, 2017

@awdDev786 can you clone this and try adding a console.log statement here. Then see if it logs to console when you import a file. I thought FileReader API is the culprit, but now I think file input change is not triggering on your end.

@awdDev786
Copy link
Author

@Agontuk not working.same behavior.

@Agontuk
Copy link
Owner

Agontuk commented Oct 26, 2017

So, handleFileUpload method is not getting called ?

@awdDev786
Copy link
Author

awdDev786 commented Oct 26, 2017

image

File is being uploaded and read here.handleFileUpload is also called.

@awdDev786
Copy link
Author

sorry for bothering you again,can u find some solution of this issue?

@Agontuk
Copy link
Owner

Agontuk commented Nov 1, 2017

I've pushed another possible fix, can you try it locally by cloning the repo? If it doesn't work, try putting a console.log here and here. See if they get logged in the console.

@awdDev786
Copy link
Author

@Agontuk empty console in both locations.

@Agontuk
Copy link
Owner

Agontuk commented Nov 3, 2017

@awdDev786 I'm out of ideas about why it's not working in your system. I'll try to investigate it more and see if I can reproduce it in my system. Please let me know if you have any ideas.

@awdDev786
Copy link
Author

@Agontuk Kindly update your online demo so that we can try there too.

@Agontuk
Copy link
Owner

Agontuk commented Nov 6, 2017

Done, please let me know if you figure out what's the issue.

@awdDev786
Copy link
Author

awdDev786 commented Nov 12, 2017

I have tried 5 different solutions described below:

  • I thought it can be an issue with my local deployment but same isn't working in official demo which means not an issue with deployment.

  • I also deployed it on a vps same issue means not an issue with my environment.

  • Additionally also tried with ms edge browser and mozilla so no issue with chrome.

  • Possibility is may be an issue with file import export.following are the steps i followed:

    1. I made a schema with 2 tables and exported it.
    2. Checked the schema.json file ,correct schema is exported.
    3. Deleted schema from designer.
    4. When i imported it in the same designer it firstly gave error as use exported schema and then it gave no error also empty schema in the response of
      JSON.parse(window.localStorage.getItem('schema'))
  • Possiblity of fileupload is also checked before that no file is being uploaded.

So @Agontuk Would you please share a youtube video where you are successfully exporting/importing schema so that I can understand the correct workflow?

Thankx for your time.

@Agontuk
Copy link
Owner

Agontuk commented Nov 12, 2017

What do you mean by "it firstly gave error"? That should never happen, unless you import files which don't have .json extension. Since the file you exported is a json file, it shouldn't occur. Can you explain this scenario in more detail?

@awdDev786
Copy link
Author

awdDev786 commented Nov 13, 2017

Yes file is with .json extension but as we have already checked by console that file is not being read here so it is not getting any file that's y it is giving such error.

@Agontuk
Copy link
Owner

Agontuk commented Nov 13, 2017

I'm checking the file type before reading it, so it shouldn't be giving this error. Anyway I just pushed a fix for an issue you mentioned on fourth point. Can you check locally if it changes anything on your end?

@awdDev786
Copy link
Author

awdDev786 commented Nov 18, 2017

It is giving same error of unexpected schema at first import.so seems no lead on issue locally.

@Agontuk
Copy link
Owner

Agontuk commented Nov 22, 2017

From your previous screenshot, I'm seeing file.type is empty. That's why it's giving the error. I'll check why it's being empty and make a fix asap.

@Agontuk
Copy link
Owner

Agontuk commented Nov 23, 2017

I'm thinking of exporting the file as a .txt instead of .json, will let you know when it's done.

@Agontuk
Copy link
Owner

Agontuk commented Nov 24, 2017

@awdDev786, I've changed the import & export feature to use .txt file. Can you rename your schema.json to schema.txt and see if it works locally?

@awdDev786
Copy link
Author

awdDev786 commented Jan 18, 2018

@Agontuk issue was resolved as your updated code. You have used this code to display imported schema.
window.location.reload();
I tried replacing it with some solution as i only want to reload/refresh component from schema.js despite of full window reload.Is it possible as i think its isn't good practice to reload window on schema changes.

@awdDev786 awdDev786 reopened this Jan 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants