[update] Project infos
This commit is contained in:
@@ -8,8 +8,10 @@ class Files
|
||||
{
|
||||
constructor( _options )
|
||||
{
|
||||
this.items = {}
|
||||
this.socket = _options.socket
|
||||
this.items = {}
|
||||
this.count = 0
|
||||
this.socket = _options.socket
|
||||
this.last_version_date = new Date()
|
||||
}
|
||||
|
||||
create( _path, _content )
|
||||
@@ -35,6 +37,8 @@ class Files
|
||||
|
||||
// Save
|
||||
this.items[ normalized_path ] = file
|
||||
this.count++
|
||||
this.last_version_date = new Date()
|
||||
|
||||
// Emit
|
||||
this.socket.emit( 'create_file', file.describe() )
|
||||
@@ -82,6 +86,9 @@ class Files
|
||||
// Create version
|
||||
file.create_version( _content )
|
||||
|
||||
// Save
|
||||
this.last_version_date = new Date()
|
||||
|
||||
return file
|
||||
}
|
||||
|
||||
@@ -99,6 +106,10 @@ class Files
|
||||
// Delete file
|
||||
file.destructor()
|
||||
delete this.items[ normalized_path ]
|
||||
this.count--
|
||||
|
||||
// Save
|
||||
this.last_version_date = new Date()
|
||||
|
||||
// Emit
|
||||
this.socket.emit( 'delete_file', file.describe() )
|
||||
@@ -112,14 +123,16 @@ class Files
|
||||
describe()
|
||||
{
|
||||
// Set up
|
||||
let result = {}
|
||||
let result = {}
|
||||
result.count = this.count
|
||||
result.items = {}
|
||||
|
||||
// Each file
|
||||
for( let _file_path in this.items )
|
||||
{
|
||||
let _file = this.items[ _file_path ]
|
||||
|
||||
result[ _file_path ] = _file.describe()
|
||||
result.items[ _file_path ] = _file.describe()
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
@@ -12,6 +12,7 @@ class Project
|
||||
this.set_socket( options.socket )
|
||||
|
||||
this.files = new Files( { socket: this.socket } )
|
||||
this.date = new Date()
|
||||
}
|
||||
|
||||
set_name( _name )
|
||||
@@ -41,6 +42,7 @@ class Project
|
||||
let result = {}
|
||||
result.name = this.name
|
||||
result.files = this.files.describe()
|
||||
result.date = this.date
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -103,8 +103,11 @@ class Projects
|
||||
let _project = this.all[ _slug ]
|
||||
|
||||
result.all[ _slug ] = {
|
||||
slug: _project.slug,
|
||||
name: _project.name
|
||||
slug : _project.slug,
|
||||
name : _project.name,
|
||||
files_count : _project.files.count,
|
||||
date : _project.date,
|
||||
last_update_date: _project.files.last_version_date,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user