Project slug + Update projects sockets structure + Express to angular structure

This commit is contained in:
brunosimon
2016-06-06 21:52:58 +02:00
parent b2c68a7b73
commit e4ccca4fb6
13 changed files with 172 additions and 180 deletions
+6 -11
View File
@@ -5,16 +5,6 @@ angular_module.controller(
'project',
function( $scope, project )
{
update_callback = null;
// Result
var result = {};
result.data = {};
result.on_update = function( callback )
{
update_callback = callback;
};
$scope.folder_click = function( folder )
{
console.log( folder );
@@ -25,6 +15,11 @@ angular_module.controller(
console.log( file );
};
$scope.init = function( project_slug )
{
project.connect( project_slug );
};
project.on_update( function( data )
{
$scope.$apply( function()
@@ -33,7 +28,7 @@ angular_module.controller(
} );
} );
this.project = project.data;
$scope.project = project.data;
}
]
);
@@ -10,7 +10,6 @@ angular_module.controller(
$scope.$apply( function()
{
$scope.projects = Object.keys( data.all ).length ? data.all : null;
console.log($scope.projects);
} );
} );
+17 -15
View File
@@ -2,8 +2,7 @@ angular_module.factory(
'project',
[
'$timeout',
'$rootScope',
function( $timeout, $rootScope )
function( $timeout )
{
update_callback = null;
@@ -13,23 +12,26 @@ angular_module.factory(
{
update_callback = callback;
};
var socket = io( 'http://192.168.1.4:3000/site' );
socket.on( 'connect', function()
result.connect = function( project_name )
{
console.log('connected');
} );
var socket = io( 'http://192.168.1.4:3000/project/' + project_name );
socket.on( 'update_project', function( data )
{
result.data = data;
socket.on( 'connect', function()
{
console.log('connected');
} );
if( typeof update_callback === 'function' )
update_callback.apply( this, [ data ] );
} );
socket.on( 'update_project', function( data )
{
result.data = data;
result.data = {"name":"pwet","folders":{".":{"name":".","files":{"test-1.txt":{"name":"test-1.txt","versions":[{"date":"2016-06-04T23:26:45.759Z","content":"dsfsdf\n\naaaa\n\ndsfsdf\n\nbbbbiuhsdfiuhsdfdsf\n\n\ndsfsdf\nsodifja\n","diff":false}]}},"folders":{"folder-2":{"name":"folder-2","files":{"hey.txt":{"name":"hey.txt","versions":[{"date":"2016-06-04T23:26:41.642Z","content":"qdsqsdsq\n","diff":false}]}},"folders":{}},"folder-1":{"name":"folder-1","files":{"test-4.txt":{"name":"test-4.txt","versions":[{"date":"2016-06-04T23:26:46.571Z","content":"sdnufoisdf\n","diff":false}]}},"folders":{}}}}}};
if( typeof update_callback === 'function' )
update_callback.apply( this, [ data ] );
} );
};
result.data = {"name":"","folders":{}};
return result;
}
+1 -3
View File
@@ -1,9 +1,7 @@
angular_module.factory(
'projects',
[
'$timeout',
'$rootScope',
function( $timeout, $rootScope )
function()
{
update_callback = null;