Commit 35a12823 authored by Nikhil Rane's avatar Nikhil Rane
Browse files

Added Export Script functionality, fixed some parser errors and some UIs.

parent c2c30940
......@@ -106,7 +106,7 @@ function createHash(string){
//
// Possible errors: the passwords are not the same, and a user
// with that username already exists.
function createUser(fullName, username, password, password_confirmation, callback){
function createUser(fullName, emailAdd, username, password, password_confirmation, callback){
var coll = mongo.collection('users');
if (password !== password_confirmation) {
......@@ -118,6 +118,7 @@ function createUser(fullName, username, password, password_confirmation, callbac
var hashedPassword = createHash(password + salt);
var userObject = {
fullName: fullName,
email: emailAdd,
username: username,
salt: salt,
hashedPassword: hashedPassword
......@@ -140,13 +141,19 @@ function createUser(fullName, username, password, password_confirmation, callbac
app.post('/signup', function(req, res){
//check if this is actually a login call.
if(req.body.submit === "Login") {
res.redirect('/login');
}
var fullName = req.body.fullName;
var emailAdd = req.body.emailID;
var username = req.body.username;
var password = req.body.password;
var confirm_password = req.body.confirm_password;
createUser(fullName, username, password, confirm_password, function(err, user){
createUser(fullName, emailAdd, username, password, confirm_password, function(err, user){
if (err) {
res.render('signup', {error: err});
} else {
......
......@@ -165,7 +165,7 @@ module.exports = function(app, mongo, io, cookie, transporter) {
}
// Send an email notification to registered email ID if email_notification flag is set
if(documentData.email_notification == "true") {
if(documentData !== null && documentData.email_notification == "true") {
var emailText = 'The execution of <b>' + fileName + '</b> is complete. The executed script and execution log is attached to this email.<br /><br />';
emailText = emailText + "\n The output files are available under <i>";
......@@ -787,16 +787,13 @@ module.exports = function(app, mongo, io, cookie, transporter) {
var fileName = req.body.toGenerate.name;
var user = req.body.toGenerate.username;
sendSocketMessage(fileName, user, false, sessionID, eventName, {output: "Generating script....................STARTED", type: "message"});
var generatedScript = generateScript(parsedData);
//FIXME Remove these hardcoded tags, let's handle on client side
sendSocketMessage(fileName, user, false, sessionID, eventName, {output: "Script generation....................COMPLETE\n\nScript:\n<font color='#008C8C'>" + generatedScript + "</font>", type: "message"});
saveScriptToDB(generatedScript, fileName, user, sessionID, eventName);
if(fileName !== undefined && fileName !== null && fileName.length <= 0) {
saveScriptToDB(generatedScript, fileName, user, sessionID, eventName);
}
res.end(JSON.stringify({ result: true }));
res.end(JSON.stringify({ result: generatedScript }));
});
......@@ -831,7 +828,11 @@ module.exports = function(app, mongo, io, cookie, transporter) {
var user = req.body.toGenerate.username;
var files = req.body.toGenerate.files;
if(files === undefined) {
if( fileName === undefined || fileName === null || (fileName !== null && fileName !== undefined && fileName.length <= 0) ) {
fileName = "noname.pflow";
}
if(files === undefined || files === null) {
files = [];
}
......
......@@ -462,6 +462,7 @@
<script src="./public/src/templates/DownloadFiles.js"></script>
<script src="./public/src/templates/DocumentsList.js"></script>
<script src="./public/src/templates/HelpModal.js"></script>
<script src="./public/src/templates/ScriptText.js"></script>
<script src="./public/src/templates/AggProps.js"></script>
......
......@@ -2,62 +2,38 @@
<html>
<head>
<!--META-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Signup!</title>
<!--STYLESHEETS-->
<link href="./public/css/login_page_style.css" rel="stylesheet" type="text/css" />
<style type='text/css'>
.user-icon {
top:200px; /* Positioning fix for slide-in, got lazy to think up of simpler method. */
background: rgba(65,72,72,0.75) url(./public/images/user-icon.png) no-repeat center;
}
.pass-icon {
top:273px;
background: rgba(65,72,72,0.75) url(./public/images/pass-icon.png) no-repeat center;
}
</style>
<!--SCRIPTS-->
<script src="./public/js/jquery-1.11.1.js"></script>
<!--Slider-in icons-->
<script type="text/javascript">
$(document).ready(function() {
$(".username").focus(function() {
$(".user-icon").css("left","-48px");
});
$(".username").blur(function() {
$(".user-icon").css("left","0px");
});
<!--META-->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="nikhilrane">
<link rel="icon" href="./public/images/favicon.png">
<title>Signup!</title>
<!-- Bootstrap core CSS -->
<link href="./public/css/bootstrap.css" rel="stylesheet">
<link href="./public/css/application.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="./public/css/starter-template.css" rel="stylesheet">
<!--STYLESHEETS-->
<link href="./public/css/login_page_style.css" rel="stylesheet" type="text/css" />
<!--SCRIPTS-->
<script src="./public/js/jquery-1.11.1.js"></script>
<script src="./public/js/bootstrap.js"></script>
<!--Slider-in icons-->
<script type="text/javascript">
$(".password").focus(function() {
$(".pass-icon").css("left","-48px");
});
$(".password").blur(function() {
$(".pass-icon").css("left","0px");
});
$(".confirm-password").focus(function() {
$(".pass-icon").css("left","-48px");
});
$(".confirm-password").blur(function() {
$(".pass-icon").css("left","0px");
});
});
</script>
</script>
</head>
<body>
<!--WRAPPER-->
<div id="wrapper">
<!--SLIDE-IN ICONS-->
<div class="user-icon"></div>
<div class="pass-icon"></div>
<!--END SLIDE-IN ICONS-->
<div id="wrapper" style="top:40%">
<!--SIGNUP FORM-->
<form name="signup-form" class="login-form" action="/signup" method="post">
......@@ -71,16 +47,49 @@ $(document).ready(function() {
<!--CONTENT-->
<div class="content">
<!--FULL NAME--><input name="fullName" type="text" class="input" value="First &amp; Last name" onfocus="this.value=''" /><!--END FULL NAME-->
<!--USERNAME--><input name="username" type="text" class="input username" value="Username" onfocus="this.value=''" /><!--END USERNAME-->
<!--PASSWORD--><input name="password" type="password" class="input password" value="Password" onfocus="this.value=''" /><!--END PASSWORD-->
<!--PASSWORD--><input name="confirm_password" type="password" class="input confirm-password" value="Confirm Password" onfocus="this.value=''" /><!--END CONFIRM-PASSWORD-->
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><span class="glyphicon glyphicon-font"></span></div>
<input class="form-control" name="fullName" type="text" placeholder="First &amp; Last name">
</div>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></div>
<input class="form-control" name="emailID" type="email" placeholder="Email ID">
</div>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><span class="glyphicon glyphicon-user"></span></div>
<input class="form-control" name="username" type="text" placeholder="Username">
</div>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></div>
<input class="form-control" name="password" type="password" placeholder="Password">
</div>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></div>
<input class="form-control" name="confirm_password" type="password" placeholder="Confirm Password">
</div>
</div>
</div>
<!--END CONTENT-->
<!--FOOTER-->
<div class="footer">
<!--SIGNUP BUTTON--><input type="submit" name="submit" value="Signup" class="button" /><!--END SIGNUP BUTTON-->
<!--LOGIN BUTTON--><input style="float:left;" type="submit" name="submit" value="Login" class="register" /><!--END LOGIN BUTTON-->
<!--SIGNUP BUTTON--><input type="submit" name="submit" value="Signup" class="button" /><!--END SIGNUP BUTTON-->
</div>
<!--END FOOTER-->
......
......@@ -200,11 +200,52 @@ autostudio.Toolbar = Class.extend({
mainUL.append(li);
li = $('<li></li>');
this.exportScriptButton = $('<a href="#">Export script...</a>');
buttonGroup.append(li);
this.exportScriptButton.click($.proxy(function() {
var writer = new draw2d.io.json.Writer();
writer.marshal(this.view, $.proxy(function(jsonData) {
var documentObject = {
"documentData" : jsonData,
"name": app.loadedDefinitionId,
"username" : sessionStorage.getItem('username')
};
$.ajax({
url: '/pipestudio/generateScript',
data: { "toGenerate" : documentObject },
type: 'POST',
success: function(scriptText) {
var dataString = JSON.parse(scriptText).result;
var blob = new Blob([dataString], {type: "text/plain;charset=utf-8"});
var name = "script" + pstudioJSON.fileExtension;
if(app.loadedDefinitionId !== undefined && app.loadedDefinitionId !== null && app.loadedDefinitionId.length > 0) {
name = app.loadedDefinitionId;
}
saveAs(blob, name);
},
error: function(err) {
console.log("Failure in parse" + JSON.stringify(err));
},
});
},this));
},this)).attr("disabled", false);
li.append(this.exportScriptButton);
mainUL.append(li);
mainUL.append('<li class="divider"></li>');
li = $('<li></li>');
this.generateScriptButton = $('<a href="#">Generate Script</a>');
this.generateScriptButton = $('<a href="#">Show Script</a>');
buttonGroup.append(li);
this.generateScriptButton.click($.proxy(function() {
......@@ -214,9 +255,7 @@ autostudio.Toolbar = Class.extend({
var writer = new draw2d.io.json.Writer();
// alert("calling parse...");
writer.marshal(this.view, $.proxy(function(jsonData) {
// alert("Inside marshal, cookie: " + document.cookie);
var documentObject = {
"documentData" : jsonData,
......@@ -224,15 +263,16 @@ autostudio.Toolbar = Class.extend({
"username" : sessionStorage.getItem('username')
};
// alert("sending: " + JSON.stringify(documentObject));
$.ajax({
url: '/pipestudio/generateScript',
// dataType: "jsonp",
data: { "toGenerate" : documentObject },
type: 'POST',
success: function(script) {
console.log("Success in parse! \n" + JSON.stringify(script));
success: function(scriptText) {
var compiled = templates["ScriptText"];
var script = JSON.parse(scriptText).result;
$("#modalDiv").html("");
$("#modalDiv").append(compiled.render({"name": app.loadedDefinitionId, "script": script}));
$("#scriptTextDiv").modal();
},
error: function(err) {
console.log("Failure in parse" + JSON.stringify(err));
......
<div id="helpTextDiv" class='modal fade'>
<div class='modal-dialog'>
<div class='modal-content'>
<div class='modal-header'>
<button type='button' class='close' data-dismiss='modal'><span aria-hidden='true'>&times;</span>
<span class='sr-only'></span>
</button>
<h4 class='modal-title'>{{name}}</h4>
</div>
<div id='modal-body' class='modal-body'>
{{{helpHTML}}}
</div>
<div class='modal-footer'>
<button type='button' class='btn btn-primary' data-dismiss='modal'>Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
if (!!!templates) var templates = {};
templates["HelpModal"] = new Hogan.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("<div id=\"helpTextDiv\" class='modal fade'>");t.b("\n" + i);t.b(" <div class='modal-dialog'>");t.b("\n" + i);t.b(" <div class='modal-content'>");t.b("\n" + i);t.b(" <div class='modal-header'>");t.b("\n" + i);t.b(" <button type='button' class='close' data-dismiss='modal'><span aria-hidden='true'>&times;</span>");t.b("\n" + i);t.b(" <span class='sr-only'></span>");t.b("\n" + i);t.b(" </button>");t.b("\n" + i);t.b(" <h4 class='modal-title'>");t.b(t.v(t.f("name",c,p,0)));t.b("</h4>");t.b("\n" + i);t.b(" </div>");t.b("\n" + i);t.b(" <div id='modal-body' class='modal-body'>");t.b("\n" + i);t.b(" ");t.b(t.t(t.f("helpHTML",c,p,0)));t.b("\n" + i);t.b(" </div>");t.b("\n" + i);t.b(" <div class='modal-footer'>");t.b("\n" + i);t.b(" <button type='button' class='btn btn-primary' data-dismiss='modal'>Close</button>");t.b("\n" + i);t.b(" </div>");t.b("\n" + i);t.b(" </div><!-- /.modal-content -->");t.b("\n" + i);t.b(" </div><!-- /.modal-dialog -->");t.b("\n" + i);t.b("</div><!-- /.modal -->");return t.fl(); },partials: {}, subs: { }});
<div id="scriptTextDiv" class='modal fade'>
<div class='modal-lg'>
<div class='modal-content'>
<div class='modal-header'>
<button type='button' class='close' data-dismiss='modal'><span aria-hidden='true'>&times;</span>
<span class='sr-only'></span>
</button>
<h4 class='modal-title'>{{name}} Script</h4>
</div>
<div id='modal-body' class='modal-body'>
<pre><code style="color:blue;"> {{script}} </pre></code>
</div>
<div class='modal-footer'>
<button type='button' class='btn btn-primary' data-dismiss='modal'>Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
if (!!!templates) var templates = {};
templates["ScriptText"] = new Hogan.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("<div id=\"scriptTextDiv\" class='modal fade'>");t.b("\n" + i);t.b(" <div class='modal-lg'>");t.b("\n" + i);t.b(" <div class='modal-content'>");t.b("\n" + i);t.b(" <div class='modal-header'>");t.b("\n" + i);t.b(" <button type='button' class='close' data-dismiss='modal'><span aria-hidden='true'>&times;</span>");t.b("\n" + i);t.b(" <span class='sr-only'></span>");t.b("\n" + i);t.b(" </button>");t.b("\n" + i);t.b(" <h4 class='modal-title'>");t.b(t.v(t.f("name",c,p,0)));t.b(" Script</h4>");t.b("\n" + i);t.b(" </div>");t.b("\n" + i);t.b(" <div id='modal-body' class='modal-body'>");t.b("\n" + i);t.b(" <pre><code style=\"color:blue;\"> ");t.b(t.v(t.f("script",c,p,0)));t.b(" </pre></code>");t.b("\n" + i);t.b(" </div>");t.b("\n" + i);t.b(" <div class='modal-footer'>");t.b("\n" + i);t.b(" <button type='button' class='btn btn-primary' data-dismiss='modal'>Close</button>");t.b("\n" + i);t.b(" </div>");t.b("\n" + i);t.b(" </div><!-- /.modal-content -->");t.b("\n" + i);t.b(" </div><!-- /.modal-dialog -->");t.b("\n" + i);t.b("</div><!-- /.modal -->");return t.fl(); },partials: {}, subs: { }});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment