Permalink
Browse files

revisions folder anzeigen

  • Loading branch information...
1 parent ddd3c6c commit 8bec06da1d8c2a7637a8c153e25e7ba04cc19986 Stephan committed Dec 13, 2012
Showing with 156 additions and 21 deletions.
  1. +63 −0 app/modules/localeEdit/localeEdit.js
  2. +5 −0 app/modules/localeEdit/views.js
  3. +27 −10 app/router.js
  4. +10 −0 app/templates/localeedit/revisions.html
  5. +1 −11 edit.html
  6. +47 −0 localeEditFileManager.js
  7. +1 −0 main.html
  8. +2 −0 server.js
@@ -130,7 +130,70 @@ function(app, jquery, Views ) {
})
};
+ Localeedit.InitRevisionListUi = function(){
+ $('.revisons-list-wrapper').html('');
+ var $fileListWrapper = $('.revisons-list-wrapper')
+ return $.ajax({
+ url: '/api/getCurrentRevisions'
+ }).success(function(data) {
+ $.each(data,function(index, value){
+ var $fileWrapper = $('<div>',{
+ 'class': ' well well-large file'
+ }).appendTo($fileListWrapper);
+
+ var $text = $('<span>', {
+ 'class' : "label label-info pull-left"
+ }).appendTo($fileWrapper);
+ $text.html('Name: ' + value.name);
+
+ var $text = $('<span>', {
+ 'class' : "label label-info pull-left"
+ }).appendTo($fileWrapper);
+ $text.html('Änderungsdatum: ' + value.lastChange);
+
+ var $text = $('<span>', {
+ 'class' : "label label-info pull-left"
+ }).appendTo($fileWrapper);
+ $text.html('Größe: ' + value.size);
+
+ var $btnDownlaod = $('<button>', {
+ type : "button",
+ 'class' : "pull-right btn btn-primary",
+ 'data-loading-text' : "downloading"
+ }).appendTo($fileWrapper);
+ $btnDownlaod.html('Download');
+ $btnDownlaod.click(function(){
+ window.open(value.url, 'Download ' + value.name);
+ });
+
+ var $btnDelete = $('<button>', {
+ type : "button",
+ 'class' : "pull-right btn btn-primary",
+ 'data-loading-text' : "deleteing"
+ }).appendTo($fileWrapper);
+ $btnDelete.html('Löschen');
+ $btnDelete.click(function(){
+ $.ajax({ url: '/api/deleteUserFile/',
+ type: 'POST',
+ data: {
+ Filename: value.name
+ }
+ }).success(function(data){
+ Localeedit.InitFileListUi();
+ });
+ });
+
+ })
+ })
+ .fail(function () {
+ $('<span class="alert alert-error"/>')
+ .text('file manager currently unavaiable - ' +
+ new Date())
+ .appendTo('.revisons-list-wrapper');
+ });
+
+ };
Localeedit.InitFileListUi = function() {
$('.file-list-wrapper').html('');
var $fileListWrapper = $('.file-list-wrapper')
@@ -21,6 +21,11 @@ function(app, LocaleEdit, Backbone) {
manage: true
});
+ Views.Revisions = Backbone.View.extend({
+ template: 'app/templates/localeedit/revisions',
+ manage: true
+ });
+
Views.EditFilter = Backbone.View.extend({
events: {
"keyup #keySearchTask" : "KeySearch",
View
@@ -14,9 +14,23 @@ function(app,LocaleEdit,jquery) {
"": "index",
"index": "index",
"edit": "edit",
- "overview": "overview"
+ "overview": "overview",
+ "revisions" : "revisions"
},
- overview: function() {
+ index: function() {
+ jquery('#loadIndicator').show();
+ app.useLayout('main').setViews({
+ '#stage': new LocaleEdit.Views.Upload()
+ }).render()
+ .done(function(){
+ jquery.when(LocaleEdit.InitUi())
+ .done(function(){
+ jquery('ul.nav li').removeClass('active');
+ jquery('ul.nav a[href="#index"]').parent().addClass('active');
+ jquery('#loadIndicator').fadeOut('slow');
+ });
+ });
+ }, overview: function() {
jquery('#loadIndicator').show();
app.useLayout('main').setViews({
@@ -32,20 +46,23 @@ function(app,LocaleEdit,jquery) {
});
});
},
- index: function() {
+ revisions: function() {
jquery('#loadIndicator').show();
app.useLayout('main').setViews({
- '#stage': new LocaleEdit.Views.Upload()
+
+ '#stage': new LocaleEdit.Views.Revisions()
}).render()
- .done(function(){
- jquery.when(LocaleEdit.InitUi())
- .done(function(){
+ .done(function() {
+ jquery.when(LocaleEdit.InitRevisionListUi())
+ .done(function(){
+
jquery('ul.nav li').removeClass('active');
- jquery('ul.nav a[href="#index"]').parent().addClass('active');
+ jquery('ul.nav a[href="#revisions"]').parent().addClass('active');
jquery('#loadIndicator').fadeOut('slow');
- });
- });
+ });
+ });
},
+
edit: function() {
jquery('#loadIndicator').show();
var collection = new LocaleEdit.Collection();
@@ -0,0 +1,10 @@
+<div class="container">
+ <div class="page-header">
+ <h1>Revision-list</h1>
+ </div>
+ <blockquote>
+ <p>This overview shows your backup folder. You can delete these folders or switch to the content of a folder.
+ </p>
+ </blockquote>
+ <br>
+ <div class="revisons-list-wrapper"></div>
View
@@ -3,18 +3,8 @@
<li class="active"><a href="#index">Upload</a></li>
<li><a href="#overview">Übersicht</a></li>
<li><a href="#edit">Editieren</a></li>
+ <li><a href="#revisions">REVISIONEN</a></li>
<li class="pull-right" style="margin: 0 60px 0 0;"><a href="logout" data-bypass>LogOut</a></li>
-<!-- <li class="dropdown">
- <a class="dropdown-toggle" data-toggle="dropdown" href="#">FrontEnd<b class="caret"></b></a>
- <ul class="dropdown-menu">
- <li><a href="#">Twitter Bootstrap</a></li>
- <li><a href="#">Google Plus API</a></li>
- <li><a href="#">HTML5</a></li>
- <li class="divider"></li>
- <li><a href="#">Examples</a></li>
- </ul>
- </li> -->
-
</ul>
</li>
</ul>
@@ -90,6 +90,53 @@ exports.GetUserFiles = function(req, res) {
});
};
+exports.GetCurrentRevisions = function(req, res) {
+ var dirName = getUserFolder(req);
+ console.log('Retrieving UserFiles: ');
+ fs.readdir(dirName, function(err, files){
+
+
+
+ var dirs = [];
+ var dirsWithMetaInfo = [];
+
+ var doResponse = function() {
+ res.writeHead(200, { 'Content-Type': 'application/json' });
+ res.write(JSON.stringify(
+ dirsWithMetaInfo.map(function (file)
+ {
+ return { url: '/files/user_' + req.session.passport.user + '/' + file.Name,
+ name: file.Name,
+ lastChange: file.mtime,
+ size: file.size,
+ deleteUrl: req.originalUrl + file }; })
+ ));
+ res.end();
+ };
+
+ // nur die js Dateien ohne Ordner
+ for (var i in files) {
+ var file = files[i];
+ if(file.indexOf('js') === -1 ){
+ dirs.push(file);
+ }
+ }
+
+ // anreichern mit meta infos
+ for (var i in dirs) {
+ var dir = dirs[i];
+ var statsDone = 0;
+
+ var stats = fs.statSync(dirName+'/' + dir);
+ dirsWithMetaInfo.push({
+ Name: dir,
+ mtime: stats.mtime,
+ size: stats.size
+ });
+ }
+ doResponse();
+ });
+};
exports.SaveLocales = function(req, res) {
View
@@ -3,6 +3,7 @@
<li class="active"><a href="#index">UPLOAD</a></li>
<li><a href="#overview">OVERVIEW</a></li>
<li><a href="#edit">EDIT</a></li>
+ <li><a href="#revisions">REVISIONEN</a></li>
<li class="pull-right" style="margin: 0 60px 0 0;"><a href="logout" data-bypass>LOGOUT</a></li>
<!-- <li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">FrontEnd<b class="caret"></b></a>
View
@@ -125,6 +125,7 @@ app.get('/', ensureAuthenticated, indexRequest);
app.get('/index', ensureAuthenticated, indexRequest);
app.get('/edit', ensureAuthenticated, indexRequest);
app.get('/overview', ensureAuthenticated, indexRequest);
+app.get('/revisions', ensureAuthenticated, indexRequest);
app.get('/upload', function indexRequest (req, res){
res.writeHead(200, {'Content-Type': 'text/html'});
@@ -177,6 +178,7 @@ app.get('/files/*', function(req, res){
//get a array of uploaded js files which represent the basis for our future work
app.get('/api/currentfiles', filemanager.GetUserFiles);
+app.get('/api/getCurrentRevisions', filemanager.GetCurrentRevisions);
//get the locales as json array of locale objects
app.get('/api/getworkinglocales', filemanager.GetCurrentWorkingLocales);
app.post('/api/deleteUserFile',express.bodyParser(), filemanager.DeleteUserFile);

0 comments on commit 8bec06d

Please sign in to comment.