Handle file delation + Handle file activation file + Activate last version on file activation

This commit is contained in:
brunosimon
2016-08-12 01:29:23 +02:00
parent a73a484d2a
commit 9ce3261a96
4 changed files with 65 additions and 42 deletions
+29 -18
View File
@@ -37,8 +37,8 @@ class App
*/
set_dummy()
{
// // Default project
// let project = this.projects.create_project( 'dummy' )
// Default project
let project = this.projects.create_project( 'dummy' )
// // Same name projects
// let project_2 = this.projects.create_project( 'dummy' )
@@ -46,27 +46,38 @@ class App
// let project_4 = this.projects.create_project( 'dummy' )
// let project_5 = this.projects.create_project( 'dummy' )
// // Some file
// project.files.create( './coucou/coco.txt', '1234' )
// project.files.create( './test-1.txt', 'content 1' )
// project.files.create_version( './test-1.txt', 'content 2' )
// project.files.create_version( './test-1.txt', 'content 31298' )
// project.files.create_version( './toto/tata/lorem.txt', '123456789' )
// project.files.create_version( './toto/tata/lorem.txt', '1aze' )
// project.files.create_version( './toto/tata/ipsum.txt', 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Mollitia asperiores iure, animi voluptatibus ut officiis. Molestias, quod perferendis hic totam doloremque, porro aperiam enim tenetur, maxime inventore consequuntur nisi in?' )
// project.files.create_version( './toto/tata/ipsum.txt' )
// Some file
project.files.create( './coucou/coco.txt', '1234' )
project.files.create( './test-1.txt', 'content 1' )
project.files.create( './toto/tata/ipsum.txt' )
project.files.create_version( './test-1.txt', 'content 2' )
project.files.create_version( './test-1.txt', 'content 31298' )
project.files.create_version( './toto/tata/lorem.txt', '123456789' )
project.files.create_version( './toto/tata/lorem.txt', '1aze' )
project.files.create_version( './toto/tata/ipsum.txt', 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Mollitia asperiores iure, animi voluptatibus ut officiis. Molestias, quod perferendis hic totam doloremque, porro aperiam enim tenetur, maxime inventore consequuntur nisi in?' )
// // Adding file versions
// let counting = 0
// setInterval( function()
// {
// project.files.create_version( './coucou/coco.txt', 'test: ' + counting++ )
// }, 2000 )
// Adding file versions
let counting = 0
setInterval( function()
{
project.files.create_version( './coucou/coco.txt', 'test: ' + counting++ )
}, 2000 )
// Creating and deleting file
let toggle = true
setInterval( function()
{
if( toggle )
project.files.create( './toto/toggle.txt', 'content' )
else
project.files.delete( './toto/toggle.txt', 'content' )
toggle = !toggle
}, 3000 )
// Log
// console.log( util.inspect( project.files.describe(), { depth: null, colors: true } ) )
console.log( util.inspect( project.files.describe(), { depth: null, colors: true } ) )
}
/**
@@ -25,14 +25,12 @@ application.controller(
$scope.file_click = function( file )
{
console.log('file click');
// project.each_file( function( file )
// {
// file.active = false;
// } );
file = file.data;
file.notif = 0;
// file.active = true;
// $scope.file = file;
$scope.file = file;
$scope.version = file.versions[ file.versions.length - 1 ];
};
$scope.version_click = function( version )
+31 -17
View File
@@ -33,22 +33,22 @@ application.factory(
socket.on( 'create_file', function( data )
{
console.log('create_file');
console.log(data);
// console.log('create_file');
// console.log(data);
var existing_file = result.files[ data.path.full ];
var file = result.files[ data.path.full ];
// Doesn't exist yet
if( typeof existing_file === 'undefined' )
if( typeof file === 'undefined' )
{
existing_file = Object.assign( {}, data );
existing_file.notif = 0;
result.files[ data.path.full ] = existing_file;
file = Object.assign( {}, data );
file.notif = 0;
result.files[ data.path.full ] = file;
result.tree.add_file( data.path.full, existing_file )
result.tree.add_file( data.path.full, file )
}
existing_file.notif++;
file.notif++;
// Apply callback
if( typeof update_callback === 'function' )
@@ -57,17 +57,17 @@ application.factory(
socket.on( 'create_version', function( data )
{
console.log('create_version');
console.log(data);
// console.log('create_version');
// console.log(data);
var existing_file = result.files[ data.file ];
var file = result.files[ data.file ];
// Doesn't exist yet
if( typeof existing_file !== 'undefined' )
if( typeof file !== 'undefined' )
{
existing_file.versions.push( data.version );
file.versions.push( data.version );
existing_file.notif++;
file.notif++;
// Apply callback
if( typeof update_callback === 'function' )
@@ -77,8 +77,22 @@ application.factory(
socket.on( 'delete_file', function( data )
{
console.log('delete_file');
console.log(data);
// console.log('delete_file');
// console.log(data);
var file = result.files[ data.path.full ];
// Doesn't exist yet
if( typeof file !== 'undefined' )
{
result.tree.remove_file( file.path.full )
delete result.files[ data.path.full ]
// Apply callback
if( typeof update_callback === 'function' )
update_callback.apply( this, [ data ] );
}
} );
// Update project event
+1 -1
View File
@@ -26,7 +26,7 @@ section.page-project(ng-controller="ProjectController as controller",ng-init="in
nav.versions-nav
a.version(href="#",ng-repeat="_version in file.versions",ng-click="version_click(_version)")
div.date
| {{_version.date_formated}}
| {{_version.date}}
sup.time-from-now
| ({{_version.time_from_now}})
div.differences