Skip to content

Commit

Permalink
fixed issues #1, #2, #3
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Fischer committed Oct 18, 2017
1 parent 70e89c7 commit e3e384f
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 20 deletions.
2 changes: 1 addition & 1 deletion webserver/controllers/EntitiesController.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ module.exports = function(connection, app, passport, io){
;

evallog.log('Merge entities ' + sourceId + ' to ' + targetId);

console.log('Merge entities ' + sourceId + ' to ' + targetId);
Entity.merge(targetId, sourceId, userId, (err, result) => {
if(err){
console.log(err);
Expand Down
12 changes: 7 additions & 5 deletions webserver/controllers/UsersController.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ module.exports = function(connection, app, passport){
return;
}

User.exists(req.body.username, (err, exists) => {
User.exists(req.body.username, (err, userexists) => {
if(err){
console.log(err);
return setImmediate(() => {
res.sendStatus(500);
});
}

if(exists)
if(userexists)
return setImmediate(() => {
res.send({
success: false,
message: 'An account for the given Email address exists already!'
});
});
console.log(exists);
console.log("User exists? "+userexists);

User.create(req.body, (err, user) => {
if(err){
Expand Down Expand Up @@ -114,8 +114,10 @@ module.exports = function(connection, app, passport){
/*
Login
*/
app.post('/login', passport.authenticate('local', { successRedirect: (process.env.PATH_PREFIX || '/') + 'Users/status', failureRedirect: (process.env.PATH_PREFIX || '/') + 'login' }));


app.post('/login',
passport.authenticate('local', { successRedirect: (process.env.PATH_PREFIX || '/') + 'Users/status', failureRedirect: (process.env.PATH_PREFIX || '/') + 'asdfghjklöä' }));

/*
Return login status
*/
Expand Down
8 changes: 5 additions & 3 deletions webserver/models/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,18 @@ module.exports = function(db){
this.create = create;

function exists(username, callback){
db.query('SELECT count(*) `cnt` FROM `users` WHERE username="?" LIMIT 1', [
db.query('SELECT count(*) `cnt` FROM `users` WHERE username=? LIMIT 1', [
username
], function(err, res){
], function(err, res2){
if(err)
return setImmediate(() => {
callback(err);
});

console.log('User exists?' + res2[0]['cnt']);

setImmediate(() => {
callback(null, res[0]['cnt']?true:false);
callback(null, res2[0]['cnt']?true:false);
});
});
}
Expand Down
23 changes: 17 additions & 6 deletions webserver/public/js/storyfinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ exports.receiveCreateRelation = receiveCreateRelation;

var _ActionTypes = require('../constants/ActionTypes');

var CHROME_PLUGIN_ID = "pebdjeaapfkjiceloeecpoedbliefnap";

var types = _interopRequireWildcard(_ActionTypes);

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
Expand Down Expand Up @@ -298,7 +300,7 @@ function receiveCreateRelation(data) {
}

/*export function selectLayer(path, layerId) {
return function(dispatch){
return function(dispatch){asdf
path = path.push(layerId);

dispatch(requestLayers(path));
Expand Down Expand Up @@ -1086,7 +1088,7 @@ module.exports = function (store) {
console.log(event);

// TODO FIXME: check if origin is available somehow
if (origin !== "chrome-extension://mhgfcmndpjapfadjkcfnhpfkdiekgimd") {
if (origin !== "chrome-extension://"+CHROME_PLUGIN_ID) {
console.log('Origin mismatch:', origin);
return;
}
Expand Down Expand Up @@ -1591,6 +1593,9 @@ module.exports = function (store) {
Nur die #topNodes Top Knoten und davon jeweils die #leafs wichtigsten Nachbarn werden gerendert
*/
var pageRankByNode = _.map(nodes, function (node) {
if(_.isUndefined(node))
return 0;

if (addFocus) {
if (!_.isUndefined(node.focused) && node.focused) {
//console.log('calc', node.tfidf);
Expand Down Expand Up @@ -54155,6 +54160,8 @@ module.exports = function Vis(store) {
if (!bKeepInViewport) return d.x;

/*if(d.x > width - 100 && d.y > height - 100)
/*if(d.x > width - 100 && d.y > height - 100)
d.x = width - 100;
d.x = width - 100;

if(d.x < 100 && d.y < 100)
Expand Down Expand Up @@ -54287,7 +54294,7 @@ module.exports = function Vis(store) {
//closeNode(el);

//var id = d3.select(el).datum().id;
//console.log('Merging ' + src + ' -> ' + tgt);
console.log('Merging ' + src + ' -> ' + tgt);
gG.mergeNodes(tgt, src);

fetch('/Entities/' + tgt + '/' + src, {
Expand All @@ -54303,7 +54310,7 @@ module.exports = function Vis(store) {
});

//Knoten nicht neu Ranken, ansonsten werden ggf. weitere Knoten ausgeblendet!
gG.rankNodes();
//gG.rankNodes();
gG.buildRenderGraph(maxFocus, maxNeighbours, null);
renderGraph = gG.getRenderGraph();

Expand Down Expand Up @@ -54681,20 +54688,24 @@ module.exports = function Vis(store) {
});

drag.on('dragend', function (d, e) {
console.log('dragend');

d3.select(this).attr('class', d3.select(this).attr('class').replace(/\sdragging/g, '').replace(/^dragging/, ''));

hideDelete();

if (!_.isNull(labelDragged) && !_.isNull(dragOverDelete)) {
deleteNode(this, function () {});
} else if (!_.isNull(labelHover) && !_.isNull(labelDragged) && labelHover != labelDragged.id) {
//console.log('Merging ' + labelHover + ' / ' + labelDragged.id);
console.log('Merging ' + labelHover + ' / ' + labelDragged.id);
merge(labelHover, labelDragged.id);
labelDragged = null;
}

labelDragged = null;
labelHover = null;

hideDelete();

});
}

Expand Down
10 changes: 6 additions & 4 deletions webserver/public/js/vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ module.exports = function Vis(store){
this.toggleLinkMode = toggleLinkMode;

function merge(tgt, src, callback){
console.log("Merge!");
setData();

removeSelection();
Expand Down Expand Up @@ -527,7 +528,8 @@ module.exports = function Vis(store){
return ret;
});

d3cola = cola.d3adaptor()
d3cola = cola.d3adaptor();
console.log("d3cola merge");
elNew = { nodes: null, nodeIds: {}, labels: null, links: null, linkIds: {}};
elExisting = { nodes: null, nodeIds: {}, labels: null, links: null, linkIds: {}};

Expand Down Expand Up @@ -606,7 +608,7 @@ module.exports = function Vis(store){
return ret;
});

d3cola = cola.d3adaptor()
d3cola = cola.d3adaptor();
elNew = { nodes: null, nodeIds: {}, labels: null, links: null, linkIds: {}};
elExisting = { nodes: null, nodeIds: {}, labels: null, links: null, linkIds: {}};

Expand Down Expand Up @@ -1045,13 +1047,13 @@ module.exports = function Vis(store){

drag.on('dragend', function(d, e){
d3.select(this).attr('class', d3.select(this).attr('class').replace(/\sdragging/g, '').replace(/^dragging/,''));

if(!_.isNull(labelDragged) && !_.isNull(dragOverDelete)){
deleteNode(this, function(){

});
}else if(!_.isNull(labelHover) && !_.isNull(labelDragged) && labelHover != labelDragged.id){
//console.log('Merging ' + labelHover + ' / ' + labelDragged.id);
console.log('Merging ' + labelHover + ' / ' + labelDragged.id);
merge(labelHover, labelDragged.id);
labelDragged = null;
}
Expand Down
7 changes: 6 additions & 1 deletion webserver/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,15 @@ passport.use(new BasicStrategy(
passport.use(new LocalStrategy(
function(username, password, done){
User.verify(username, password, function(err, isValid, user){
if (err) { return done(err); }
if (err) {
console.log('Passport ERROR');
return done(err);
}
if (!isValid) {
console.log('Passport Incorrect username or password');
return done(null, false, { message: 'Incorrect username or password.' });
}
console.log('Passport success!');
return done(null, user);
});
}
Expand Down

0 comments on commit e3e384f

Please sign in to comment.