Sunday, June 5, 2011

AJAXify phpMyAdmin Interface - GSOC 2011 - Second week

After successfully completing my first task which is Ajaxify the "Create Table" option in the navigation panel last week, I moved to the second task of the schedule. It is applying ajax behavior to the "Add a new User" option in the db->privileges tab. Initially I went through the implementation of "Add a new User" option in host->privileges which is a similar situation as db->privileges. I went through the code in the server_privileges.php and server_privileges.js files to find out what are the available logics and the code which can be reused for my implementation. I found that $("#fieldset_add_user a.ajax").live("click") event code is the logic and the code which I can reuse for my implementation. After that I started modifying it according to my task.

First I added the class="ajax" attribute to the "Add a new user link" when the Ajax in enabled. Then It became supporting to the same logic in $("#fieldset_add_user a.ajax").live("click") event.

At that point when we click on the "Add a new User" link, it successfully popups the dialog box which is carrying the "Add user" form and after we submit it correctly create that user. But still its not done. Because I had to reload the "db specific user rights" table at the db->privileges tab.

After discussing with Marc I decided to use a post command to get the updated "db specific user rights" table in db->privileges and replace it with the current table. So in oder to do so I had to remove the echoes of the "db specific user rights" form in server_privileges.php file and use the PMA_ajaxResponse() to pass the string of the table object as a json string.

Then I had to face a problem of not parsing the json string correctly and outputs error. So I used the $.parseJSON() function to parse the json string at the server_privileges.js file. Then it worked fine and reloaded the "db specific user rights" table with newly added user.

Then Marc directed me to a new scenario in host->databases->check_privileges->"Add a new user" which gave some errors because of my modification. Finally I have modified the logic which corrects the error and now the feature is working correctly.

Add user dialog

Now the "Add a new user" in db->privileges option works fine with the ajax behavior and I think it will help to improve the usability of PMA.

Next week I'm going to work with modifying the "Insert for a table" option in db->structure, which will apply the ajax behavior to it.

No comments:

Post a Comment