App-Inventor-Gallery
App-Inventor-Gallery copied to clipboard
Flag-it backend
for the moment, send email to administrators
also it should increment a database count (along with email to admins if total count now exceeds some configured value, initially 1). should also store who flagged it. there is an existing database object for flags (needs review). Derrell will need to work with person who takes this issue to get them started.
To send email, use the App Engine Java API from JavaScript.
Chris -- please plan to talk with Derrell to unpack this one. One part of the story is doing unit testing on the backend code w/o having to build a front end.
The global boolean flag rpcjs.sim.remote.MRpc.SIMULATE specifies whether you are in simulation mode or real (App Inventor) mode.
You may find this useful: http://code.google.com/appengine/docs/java/overview.html
What I will have to do to fix this issue is:
in Constants.js add: maxFlagged flaggedType
in ObjComments.js add status and numCurrFlags
in ObjAppData.js add numCurrFlags
create MFlags.js and build an rpc
the rpc flagIt(flagType, visitor, explanation, appId, commentId,)
this rpc will: instanciate and put an ObjFlags object on the database in a similar way to assignment 8.
increment the numCurrFlags variable in the app or comment
if numCurrFlags >= maxFlagged, set status to pending and send an email to the administrators
Chris, I think you hit on the major points we discussed. A few details:
in Constants.js add:
maxFlagged flaggedType
Note naming policy. what you're calling maxFlagged will be an integer constant. It should be named in all upper case: MAX_FLAGGED
flaggedType is a constant map. It should begin with a capital letter, so FlaggedType. On the other hand, the parameter to your RPC is called flagType which I think makes more sense. Maybe this constant map should be called FlagType?
Looking good. Go forth and implement!
Derrell
Sorry the status update is so late. I have made the initial code for the app flagging, however I have had some trouble getting the testing tab to function correctly. I need to set up github properly anyway (I do not have a clean directory at this point) so if I stopped by Derrels office after class tomorrow I believe I could get to a point where I could have the issue closed within a couple hours if everything goes the way I would expect it to.
Chris, I'd suggest that in your case, where you must update to swedev right away, that you make a copy of the files which contain your changes for flagging, then follow my swedev instructions of last night, and after you have confirmed that your swedev environment is working, then create a new branch for your flagging changes, copy/paste your changes (only the changes, not whole files) from the saved files into the just-checked-out files, and go from there.
As for the testing tab, it seems that unzipping the template.zip file creates the files in a template directory. Move the files up into the same directory as the template.zip file is, and remove the template directory that was created by the unzip operation.
I have got the flagging code for apps working, and the code for flagging comments in development. Currently the code is having trouble identifying an already created comment, and sending an email is yet to be implemented.
finish the work up to but NOT INCLUDING email, and commit this. email will be a separate issue.
The comment flagging has been implemented in addition to the app flagging and is in the flagIt branch on my github. I currently have the return value set to the status of the app or comment, however there may be some more important value that could be returned instead(for example the number of flags on the app or comment).
Thanks, Chris! Here are a few things to fix before I can pull it in:
- Constants.js: MAX_FLAGGED needs a documentation comment (with /** )
- MFlags.js is not likely copyright by Reed. That should have your copyright.
- There is no need for an empty statics section in MFlags
- Correct the documentation for the flagIt function
- The entire flagIt function is nearly devoid of comments. Please comment it as you see done in the rest of this application. Every functional block of code should be commented as to what it will do, and then small sets of lines should provide the detail documentation of what they are doing.
- if(commentDataObj.status == statusVals.Pending) {} else should instead be if(commentDataObj.status != statusVals.Pending)
Once you get these issues corrected, I should be able to pull it into swedev.
Thanks!
Derrell
I implemented the changes and sent a pull request, however it appears that in the time between fetching upstream and merging flagIt and swedev derrell has made some changes to his swedev. Let me know if I should re merge and resend the pull request
No need for a re-merge. The other changes did not affect your code, and #166 has been pulled.
I got the code functional to ensure a user only flags an app or comment once. I implemented the flag it button to use the flagIt rpc call, however the handler only outputs the rpc return value to the console. These changes can be found on my flagIt branch.
Chris, this is great. A couple of issues:
- We can't use alert() in backend code. When it runs on App Engine, there will be no such function. You can surround it in code that ensure that it exists only in the source version, which is probably appropriate:
if (qx.core.Environment.get("qx.debug")) { alert(...); }
- The indentation and locations of braces in MFlags is quite inconsistent, and not in line with the coding standards. Would you please fix those.
- I corrected the merge conflict for your appinfo.Gui file and some minor issues in Fsm. I pushed it to my FlagIt branch from where you can pull it.
in order to implement the emails where should the java includes be placed? Alternatively what other files could I use as an example of implementing java code.
On Tue, Nov 15, 2011 at 20:39, cadler1 < [email protected]
wrote:
in order to implement the emails where should the java includes be placed? Alternatively what other files could I use as an example of implementing java code.
For this application, you can put the Java code in the else clause of if (qx.core.Environment.get("qx.debug")) inside of the RPC implementation.
The documentation for the Java classes you'll need to send email are documented here: http://code.google.com/appengine/docs/java/mail/
You can access a Java class from JavaScript with Packages.
does Package have access to the javax library, because when the code is executed it throws a server error saying
Async(undefined) exception: Server error -1: Method threw an error: TypeError: Packages.javax.mail is undefined
on the first execution of the javax library.
On Wed, Nov 16, 2011 at 16:53, cadler1 < [email protected]
wrote:
does Package have access to the javax library, because when the code is executed it throws a server error saying
Async(undefined) exception: Server error -1: Method threw an error: TypeError: Packages.javax.mail is undefined
on the first execution of the javax library.
Are you running this in the App Engine emulator, or in the simulator running in the browser? There is no access to any java class in the browser. The java classes are only available in App Engine or its emulator.
I suspect you're running in the simulator since we haven't discussed setting up the emulator. Here's the process:
- Edit backend-js/jsserver/Makefile.paths with the correct paths for your environment. Here is what's in my file:
qxroot := ../../../../qx/qooxdoo/framework/source/class/ app := ../../frontendfsm/aiagallery/source/class rpcjs := ../../../../qx/contrib/trunk/qooxdoo-contrib/RpcJs/trunk/source/class
- In frontend/aiagallery, run "generate.py build" which will create a build version of the app and copy it into the appropriate place in backend-js/jsserver/war
- Change directory into backend-js/jsserver and type "make". It should compile lots and lots of files.
- Run "run.sh war" from that same directory. The emulator is now running. It will print it's port, but should probably be available on http://localhost:8080
I think that's all there is too it. Let me know if you have problems.
Derrell
I pulled from upstream swedev and now whenever I try to run the make file for the app emulator it gives me the error
*** No rule to make target qxoo_classes/qx/util/OOUtil.class', needed by
all'. Stop.
On Sun, Nov 27, 2011 at 18:29, cadler1 < [email protected]
wrote:
I pulled from upstream swedev and now whenever I try to run the make file for the app emulator it gives me the error *** No rule to make target
qxoo_classes/qx/util/OOUtil.class', needed by
all'. Stop.
Uggh. My mistake. I had to update our backend stuff for latest qooxdoo, which broke it for you. Ok, you have two choices:
- You can update to latest qooxdoo, by removing the old svn-based qooxdoo and cloning the qooxdoo project on github, or
- you can delete that line from both the Makefile and the pair of lines related to it from backend-js/jsserver/src/main/Loader.js
#1 is a clone of https://[email protected]/qooxdoo/qooxdoo.git
Sorry about that.
Derrell
currently the database seems to be executing the java mailing code correctly, however I have it being sent to my gmail account and it does not seem to be showing up there (even in the spam folder) .
It appears the code stops executing after the newFlag.put() line is executed and returns the error: Server error -1: Method threw an error: JavaException: java.lang.NumberFormatException: For input string: "undefined"
I have pushed the current code to my flagIt branch, most of the updates in mFlags is debugging code.
On Sun, Nov 27, 2011 at 21:24, cadler1 < [email protected]
wrote:
It appears the code stops executing after the newFlag.put() line is executed and returns the error: Server error -1: Method threw an error: JavaException: java.lang.NumberFormatException: For input string: "undefined"
You are overriding the defaults in the ObjFlags object. You are doing:
newFlag = new aiagallery.dbif.ObjFlags();
The above line creates default data for this new object.
var data =
{
type : flagType,
app : appNum,
comment : "0000",
visitor : visitorId,
explanation : explanationInput
}
newFlag.setData(data);
Here, you just overrode all of the default data with your new data.
What you want to do instead is:
newFlag = new aiagallery.dbif.ObjFlags();
var data = newFlag.getData();
data.type = flagType;
data.app = appNum;
data.comment = "0000";
data.visitor = visitorId;
data.explanation = explanationInput;
(and then the newFlag.setData(data) call is superfluous because data contains a reference to the map that's already in the newFlag object and you are modifying the data referenced by that variable)
I suspect that's your problem.
Derrell
yep, that fixed the flag creation problem, now I just have to deal with the java email bit.
where should I be looking to find if the app inventor emulator can send email?
On Mon, Nov 28, 2011 at 14:36, cadler1 < [email protected]
wrote:
where should I be looking to find if the app inventor emulator can send email?
The page http://code.google.com/appengine/docs/java/mail/overview.html says:
Mail and the Development Server When an application running in the development server calls the Mail service to send an email message, the message is printed to the log. The Java development server does not send the email message.
So if things are working, you should, I think, see the message printed on the "console" which is the shell from which you started the emulator (development server).
Derrell
It is not outputting anything to the console at this point I have been staring at it for over an hour with no progress. I have updated my flagIt branch and I think a second pair of eyes would do some good.