]> git.immae.eu Git - perso/Immae/Projets/Nodejs/Surfer.git/blobdiff - frontend/js/app.js
Make folder listing a global setting
[perso/Immae/Projets/Nodejs/Surfer.git] / frontend / js / app.js
index 1500457e0a3993c402a18860ac47a7ce2d69acbc..e9d469be99d400656e7107259265c8f2503ece1d 100644 (file)
@@ -124,10 +124,6 @@ function open(row, event, column) {
     window.open(encode(path));
 }
 
-function up() {
-    window.location.hash = sanitize(app.path.split('/').slice(0, -1).filter(function (p) { return !!p; }).join('/'));
-}
-
 function uploadFiles(files) {
     if (!files || !files.length) return;
 
@@ -215,7 +211,9 @@ var app = new Vue({
         },
         onOptionsMenu: function (command) {
             if (command === 'folderListing') {
-                console.log('Not implemented');
+                superagent.put('/api/settings').send({ folderListingEnabled: this.folderListingEnabled }).query({ access_token: localStorage.accessToken }).end(function (error) {
+                    if (error) console.error(error);
+                });
             } else if (command === 'about') {
                 this.$msgbox({
                     title: 'About Surfer',
@@ -328,7 +326,9 @@ var app = new Vue({
             return filesize(cellValue);
         },
         loadDirectory: loadDirectory,
-        up: up,
+        onUp: function () {
+            window.location.hash = sanitize(app.path.split('/').slice(0, -1).filter(function (p) { return !!p; }).join('/'));
+        },
         open: open,
         drop: drop,
         dragOver: dragOver
@@ -339,6 +339,12 @@ getProfile(localStorage.accessToken, function (error) {
     if (error) return console.error(error);
 
     loadDirectory(window.location.hash.slice(1));
+
+    superagent.get('/api/settings').query({ access_token: localStorage.accessToken }).end(function (error, result) {
+        if (error) console.error(error);
+
+        app.folderListingEnabled = !!result.body.folderListingEnabled;
+    });
 });
 
 $(window).on('hashchange', function () {