Skip to content

Commit

Permalink
fixed git-ls, fixed modify user bug, added javascript support
Browse files Browse the repository at this point in the history
  • Loading branch information
dmolchanenko committed Sep 23, 2013
1 parent d66d350 commit 42f7699
Show file tree
Hide file tree
Showing 14 changed files with 115 additions and 6 deletions.
7 changes: 4 additions & 3 deletions agent/routes/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ function startLauncher(executionID,threadID,callback){
if (msg.command == "action finished"){
delete actionCache[portNumber];
if(msg.screenshot){
sendScreenShotToServer(baseExecutionDir+"/"+executionID + "/bin/" + msg.screenshot,msg.screenshot,common.Config.AppServerIPHost,common.Config.AppServerPort,function(){
sendFileToServer(baseExecutionDir+"/"+executionID + "/bin/" + msg.screenshot,msg.screenshot,"/screenshots",common.Config.AppServerIPHost,common.Config.AppServerPort,function(){
sendActionResult(msg,common.Config.AppServerIPHost,common.Config.AppServerPort);
})
}
Expand Down Expand Up @@ -466,7 +466,7 @@ function getExecutionStatus(host,port,executionID,callback){
req.end();
}

function sendScreenShotToServer(file,id,host,port,callback){
function sendFileToServer(file,id,url,host,port,callback){
if(fs.existsSync(file) == false) {
if (callback) callback();
return;
Expand All @@ -492,7 +492,8 @@ function sendScreenShotToServer(file,id,host,port,callback){
var options = {
hostname: host,
port: port,
path: '/screenshots',
path: url,
//path: '/screenshots',
method: 'POST',
headers: {
//'Content-Type': 'text/plain'//,
Expand Down
5 changes: 5 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var express = require('express')
, methodFinder = require('./routes/methodFinder')
, aggregate = require('./routes/aggregate')
, executionstatus = require('./routes/executionstatus')
, emailsettings = require('./routes/emailsettings')
, license = require('./routes/license');


Expand Down Expand Up @@ -75,6 +76,10 @@ app.get('/login',auth.loginPage);
app.post('/license',auth.auth,license.licensePost);
app.get('/license',auth.auth,license.licenseGet);

//emailsettings
app.post('/emailsettings',auth.auth,emailsettings.Post);
app.get('/emailsettings',auth.auth,emailsettings.Get);

//aggregate
app.post('/aggregate',auth.auth,aggregate.aggregatePost);

Expand Down
2 changes: 2 additions & 0 deletions gitinterface/gitcommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ exports.commitsSinceDate = function(workdir,date,callback){

exports.lsFiles = function(workdir,query,callback){
var params = query;
params.unshift("-o");
params.unshift("-c");
params.unshift("ls-files");
var git = spawn(path.resolve(__dirname,'../vendor/Git/bin/git.exe'),params,{cwd: workdir,timeout:300000});
var cliData = "";
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
, "optimist" : "0.5.2"
, "forever-monitor" : "1.1.0"
, "xml-writer" : "1.4.0"
, "nodemailer" : "0.5.2"
}
}
4 changes: 4 additions & 0 deletions public/controller/Scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ Ext.define("Redwood.controller.Scripts", {
icon = "images/fileTypeGroovy.png";
}else if (fileName.slice(-4) == "java"){
icon = "images/fileTypeJava.png";
}else if (fileName.slice(-2) == "js"){
icon = "images/fileTypeJavascript.png";
}
return icon;
},
Expand Down Expand Up @@ -747,6 +749,8 @@ Ext.define("Redwood.controller.Scripts", {
editorType = "text/x-java";
}else if (record.get("fullpath").slice(-3) == "xml"){
editorType = "application/xml";
}else if (record.get("fullpath").slice(-2) == "js"){
editorType = "text/javascript";
}

var tab;
Expand Down
Binary file added public/images/e-mail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/fileTypeJavascript.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<script src="codemirror/lib/codemirror.js"></script>
<script src="ux/codeeditor/search.js"></script>
<script src="codemirror/mode/groovy/groovy.js"></script>
<script src="codemirror/mode/clike/clike.js"></script>
<script src="codemirror/mode/javascript/javascript.js"></script>
<script src="codemirror/mode/xml/xml.js"></script>
<script src="ux/BoxReorderer.js"></script>
<script src="ux/TabCloseMenu.js"></script>
Expand Down
5 changes: 4 additions & 1 deletion public/ux/codeeditor/codeeditorfield.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Ext.define('Redwood.ux.CodeEditorField', {
hideLabel: true,
anchor: '100%',
allowBlank: true,
editorType: "text/x-groovy",

isFullScreen: function(){
return /\bCodeMirror-fullscreen\b/.test(this.editor.getWrapperElement().className);
Expand Down Expand Up @@ -76,7 +77,7 @@ Ext.define('Redwood.ux.CodeEditorField', {
}
*/
},
mode: "text/x-groovy",
mode: me.editorType,//"text/x-groovy",
onResize: function(){
var showing = document.body.getElementsByClassName("CodeMirror-fullscreen")[0];
if (!showing) return;
Expand Down Expand Up @@ -140,6 +141,7 @@ Ext.define('Redwood.ux.EditorPanel', {
layout: 'fit',
preventHeader: true,
plain: true,
editorType: "text/x-groovy",
//autoScroll:false,

title:"",
Expand All @@ -152,6 +154,7 @@ Ext.define('Redwood.ux.EditorPanel', {

{
xtype: 'codeeditorfield',
editorType:me.editorType,
margin: '0 0 -100 0',
onChange: function(cm,changeOpt){
if (me.dirty == false){
Expand Down
1 change: 0 additions & 1 deletion public/view/LicenseEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Ext.define('Redwood.view.LicenseEditor', {
xtype: 'fieldset',
title: 'License Information',
defaultType: 'textfield',
itemId:"testcaseDetails",
flex: 1,
collapsible: false,
defaults: {
Expand Down
1 change: 1 addition & 0 deletions public/view/UserEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Ext.define('Redwood.view.UserEdit', {
form.updateRecord();
Ext.data.StoreManager.lookup('UserTags').sync();
Ext.data.StoreManager.lookup('Users').sync();
window.close();
}else{
Ext.Ajax.request({
url:"/canadduser",
Expand Down
43 changes: 43 additions & 0 deletions routes/emailsettings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
exports.Get = function(req, res){
var app = require('../common');
var db = app.getDB();

db.collection('emailsettings', function(err, collection) {
collection.findOne({}, {}, function(err, settings) {
if(settings == null){
res.contentType('json');
res.json({});
}
else{
if (settings.password) settings.password = "**********************";
res.contentType('json');
res.json(settings);
}
})
})

};

exports.Post = function(req, res){
var app = require('../common');
var db = app.getDB();
var data = req.body;
db.collection('emailsettings', function(err, collection) {
collection.findOne({}, {}, function(err, settings) {
if(settings == null){
collection.insert(data,{safe:true},function(err,returnData){
res.contentType('json');
res.json({success:true});
})
}
else{
data._id = settings._id;
if (data.password == "**********************") data.password = settings.password;
collection.save(data,{safe:true},function(err){
res.contentType('json');
res.json({success:true});
});
}
});
});
};
48 changes: 48 additions & 0 deletions routes/resultfiles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
var fs = require('fs');
Grid = require('mongodb').Grid;
MongoDB = require('mongodb');

exports.Post = function(req, res){
var db = require('../common').getDB();
var tmp_path = req.files.file.path;
var id = req.files.file.name;
var gridStore = new Grid(db, id, 'w');

gridStore.writeFile(tmp_path,function(err, doc){
fs.unlink(tmp_path);
res.contentType('json');
res.json({
success: true
});
});

};

exports.Get = function(req, res){
var db = require('../common').getDB();

Grid.read(db, id, function(err, data) {
if(data){
res.contentType("application/octet-stream");
res.end(data, "binary");
}
else{
res.end("Error: file not found.", "utf8");
}

});
db.collection('screenshots', function(err, collection) {
collection.findOne({_id:req.params.id}, {},function(err,file){
if(file != null){
res.contentType("image/png");
res.end(file.file.buffer, "binary");
}
else{
res.end("Error: file not found.", "utf8");
}
//fs.writeFile("c:/tmp/image.png",file.file.buffer,{encoding:"binary"},function(){
// console.log("all done")
//})
})
});
};
2 changes: 2 additions & 0 deletions routes/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,8 @@ var walkDir = function(dir,filesInConflict,filesNotPushed, done) {
result.icon = "images/fileTypeGroovy.png";
}else if (file.slice(-4) == "java"){
result.icon = "images/fileTypeJava.png";
}else if (file.slice(-2) == "js"){
result.icon = "images/fileTypeJavascript.png";
}
result.leaf= true;
results.push(result);
Expand Down

0 comments on commit 42f7699

Please sign in to comment.