Agontuk / schema-designer

Database schema designer for Laravel & Lumen
https://agontuk.github.io/schema-designer/
MIT License
124 stars 53 forks source link

Cannot import JSON schema #2

Open awdDev786 opened 7 years ago

awdDev786 commented 7 years ago

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

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

Agontuk commented 7 years ago

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 commented 7 years ago

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

awdDev786 commented 7 years ago

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 commented 7 years ago

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

schema.json.zip

awdDev786 commented 7 years ago

it is neither showing any schema nor giving error.

Agontuk commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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

awdDev786 commented 7 years ago

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

Agontuk commented 7 years ago

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 commented 7 years ago

ok thank u for lead.m checking it.

awdDev786 commented 7 years ago

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

Agontuk commented 7 years ago

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 commented 7 years ago

it persists when i refreshed page

Agontuk commented 7 years ago

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 commented 7 years ago

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

awdDev786 commented 7 years ago

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

Agontuk commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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

awdDev786 commented 7 years ago

@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 commented 7 years ago

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 commented 7 years ago

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

awdDev786 commented 7 years ago

Have you updated in official site here?

awdDev786 commented 7 years ago

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

Agontuk commented 7 years ago

@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 commented 7 years ago

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

Agontuk commented 7 years ago

So, it worked with .txt files ?

awdDev786 commented 7 years ago

yes.it read .txt file

Agontuk commented 7 years ago

Thanks, I'll try another fix.

awdDev786 commented 7 years ago

Ok thank you for your concern.

Agontuk commented 7 years ago

@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 commented 7 years ago

@Agontuk not working.same behavior.

Agontuk commented 7 years ago

So, handleFileUpload method is not getting called ?

awdDev786 commented 7 years ago

image

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

awdDev786 commented 7 years ago

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

Agontuk commented 7 years ago

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 commented 7 years ago

@Agontuk empty console in both locations.

Agontuk commented 7 years ago

@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 commented 7 years ago

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

Agontuk commented 7 years ago

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

awdDev786 commented 7 years ago

I have tried 5 different solutions described below:

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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

Agontuk commented 7 years ago

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 commented 7 years ago

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

Agontuk commented 7 years ago

@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 commented 6 years ago

@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.