]> source.dussan.org Git - nextcloud-server.git/commitdiff
Initial work on UI for mounting external storage
authorMichael Gapczynski <GapczynskiM@gmail.com>
Thu, 24 May 2012 15:06:03 +0000 (11:06 -0400)
committerMichael Gapczynski <GapczynskiM@gmail.com>
Thu, 24 May 2012 15:06:03 +0000 (11:06 -0400)
apps/files_external/appinfo/app.php
apps/files_external/appinfo/info.xml
apps/files_external/css/settings.css [new file with mode: 0644]
apps/files_external/js/settings.js [new file with mode: 0644]
apps/files_external/settings.php [new file with mode: 0644]
apps/files_external/templates/settings.php [new file with mode: 0644]

index 784ed032d475150134f8bf298424843db24a9680..2940a070258aec7f481c48e7382b13b1857f0dec 100644 (file)
@@ -10,3 +10,4 @@ OC::$CLASSPATH['OC_Filestorage_FTP']='apps/files_external/lib/ftp.php';
 OC::$CLASSPATH['OC_Filestorage_DAV']='apps/files_external/lib/webdav.php';
 OC::$CLASSPATH['OC_Filestorage_Google']='apps/files_external/lib/google.php';
 OC::$CLASSPATH['OC_Filestorage_SWIFT']='apps/files_external/lib/swift.php';
+OCP\App::registerAdmin('files_external', 'settings');
index c324730593f7f7349addb754c343bfac71c8f382..e0301365d16fb051b0d71681ab4f4d321b196ec1 100644 (file)
@@ -4,7 +4,7 @@
        <name>External storage support</name>
        <description>Mount external storage sources</description>
        <licence>AGPL</licence>
-       <author>Robin Appelman</author>
+       <author>Robin Appelman, Michael Gapczynski</author>
        <require>4</require>
        <shipped>true</shipped>
        <types>
diff --git a/apps/files_external/css/settings.css b/apps/files_external/css/settings.css
new file mode 100644 (file)
index 0000000..b11af75
--- /dev/null
@@ -0,0 +1,6 @@
+.error { color: #FF3B3B; }
+td.type { width:8em; }
+td.mount, td.options, td.applicable { width:10em; }
+#addStorage>td { border:none; }
+#addStorage>td:not(.selectStorage) { visibility:hidden; }
+#selectStorage { margin-left:-10px; }
\ No newline at end of file
diff --git a/apps/files_external/js/settings.js b/apps/files_external/js/settings.js
new file mode 100644 (file)
index 0000000..9a558ad
--- /dev/null
@@ -0,0 +1,59 @@
+$(document).ready(function(){
+
+       function applicableChange(applicable) {
+               if (applicable == 'Global') {
+                       
+               }
+               console.log(applicable);
+       }
+
+       $('#selectStorage').live('change', function() {
+               var tr = $(this).parent().parent();
+               $('#externalStorage tbody').last().append($(tr).clone());
+               var selected = $(this).val();
+               $(this).parent().text(selected);
+               var backends = $(this).data('configurations').split(';');
+               var configuration = [];
+               // Find selected backend configuration parameters
+               $.each(backends, function(index, backend) {
+                       if (backend.split(':')[0] == selected) {
+                               configuration = backend.split(':')[1].split(',');
+                               //                              break;
+                       }
+               });
+               var td = $(tr).find('td.configuration');
+               $.each(configuration, function(index, config) {
+                       if (config.indexOf('*') != -1) {
+                               td.append('<input type="password" placeholder="'+config.substring(1)+'" />');
+                       } else {
+                               td.append('<input type="text" placeholder="'+config+'" />');
+                       }
+               });
+               $(tr).find('td').last().attr('class', 'remove');
+               $(tr).removeAttr('id');
+               $(this).remove();
+       });
+
+       $('td.remove>img').live('click', function() {
+               $(this).parent().parent().remove();
+               // TODO remove storage
+       });
+
+       $('#externalStorage select[multiple]').each(function(index,element){
+               applyMultiplySelect($(element));
+       });
+
+       function applyMultiplySelect(element) {
+               var checkHandeler=false;
+               element.multiSelect({
+                       oncheck:applicableChange,
+                       onuncheck:applicableChange,
+                       minWidth: 120,
+               });
+       }
+
+       $('#allowUserMounting').bind('change', function() {
+               // TODO save setting
+       });
+
+});
\ No newline at end of file
diff --git a/apps/files_external/settings.php b/apps/files_external/settings.php
new file mode 100644 (file)
index 0000000..ce1b308
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+
+/**
+* ownCloud
+*
+* @author Michael Gapczynski
+* @copyright 2012 Michael Gapczynski mtgap@owncloud.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Affero General Public
+* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+OCP\Util::addscript('files_external', 'settings');
+OCP\Util::addstyle('files_external', 'settings');
+$tmpl = new OCP\Template('files_external', 'settings');
+$tmpl->assign('allowUserMounting', 'yes');
+$tmpl->assign('isAdminPage', true);
+$tmpl->assign('storage', array());
+$tmpl->assign('groups', OC_Group::getGroups());
+$tmpl->assign('backends', array('Amazon S3', 'FTP', 'Google Drive', 'SWIFT', 'WebDAV'));
+$tmpl->assign('configurations', '');
+$tmpl->assign('options', array('Encrypt', 'Version control', 'Allow sharing'));
+return $tmpl->fetchPage();
+
+?>
\ No newline at end of file
diff --git a/apps/files_external/templates/settings.php b/apps/files_external/templates/settings.php
new file mode 100644 (file)
index 0000000..e34c032
--- /dev/null
@@ -0,0 +1,74 @@
+<form id="files_external">
+       <fieldset class="personalblock">
+       <legend><strong><?php echo $l->t('External Storage'); ?></strong></legend>
+               <?php if (isset($_['storage'])): ?>
+               <table id="externalStorage">
+                       <thead>
+                               <tr>
+                                       <th><?php echo $l->t('Type'); ?></th>
+                                       <th><?php echo $l->t('Configuration'); ?></th>
+                                       <th><?php echo $l->t('Mount Location'); ?></th>
+                                       <th><?php echo $l->t('Options'); ?></th>
+                                       <?php if ($_['isAdminPage'] == true) echo '<th>'.$l->t('Applicable').'</th>'; ?>
+                                       <th>&nbsp;</th>
+                               </tr>
+                       </thead>
+                       <tbody>
+                       <?php $_['storage'] = array_merge($_['storage'], array(array('id' => 'addStorage', 'mount' => ''))); ?>
+                       <?php foreach($_['storage'] as $storage): ?>
+                               <tr <?php if ($storage['id'] == 'addStorage') echo 'id="addStorage"'; ?> data-storage-id="<?php echo $storage['id']; ?>">
+                                       <?php if ($storage['id'] == 'addStorage'): ?>
+                                               <td class="selectStorage">
+                                                       <select id="selectStorage" data-configurations="<?php echo $_['configurations']; ?>">
+                                                               <option value="" disabled selected style="display:none;"><?php echo $l->t('Add storage'); ?></option>
+                                                               <?php foreach($_['backends'] as $backend): ?>
+                                                                       <option value="<?php echo $backend; ?>"><?php echo $backend; ?></option>
+                                                               <?php endforeach; ?>
+                                                       </select>
+                                               </td>
+                                       <?php else: ?>
+                                               <td class="type" <?php if ($storage['status'] == 'error') echo 'class="error"'; ?>><?php echo $storage['type']; ?></td>
+                                       <?php endif; ?>
+                                       <td class ="configuration">
+                                       <?php if (isset($storage['configuration'])): ?>
+                                               <?php foreach($storage['configuration'] as $parameter => $value): ?>
+                                                       <?php if (strpos($parameter, '*') !== false): ?>
+                                                               <input type="password" value="<?php echo $value; ?>" placeholder="<?php echo $l->t(substr($parameter, 1)); ?>" />
+                                                       <?php else: ?>
+                                                               <input type="text" value="<?php echo $value; ?>" placeholder="<?php echo $l->t($parameter); ?>" />
+                                                       <?php endif; ?>
+                                               <?php endforeach; ?>
+                                       <?php endif; ?>
+                                       </td>
+                                       <td class="mount"><input type="text" name="storageMountLocation" value="<?php echo $storage['mount']; ?>" placeholder="<?php echo $l->t('Mount Location'); ?>" /></td>
+                                       <td class="options">
+                                               <select class="selectOptions" title="<?php echo $l->t('None set')?>" multiple="multiple">
+                                                       <?php if (OCP\App::isEnabled('files_encryption')) echo '<option value="Encrypt">Encrypt</option>'; ?>
+                                                       <?php if (OCP\App::isEnabled('files_versions')) echo '<option value="Version control">Version control</option>'; ?>
+                                                       <?php if (OCP\App::isEnabled('files_sharing')) echo '<option value="Allow sharing">Allow sharing</option>'; ?>
+                                               </select>
+                                       </td>
+                                       <?php if ($_['isAdminPage'] == true): ?>
+                                               <td class="applicable">
+                                                       <select class="selectApplicable" data-storage-applicable="<?php echo $storage['applicable']; ?>" title="<?php echo $l->t('None set'); ?>" multiple="multiple">
+                                                               <option value="Global"><?php echo $l->t('Global'); ?></option>
+                                                               <?php foreach($_['groups'] as $group): ?>
+                                                                       <option value="<?php echo $group; ?>"><?php echo $group; ?></option>
+                                                               <?php endforeach; ?>
+                                                       </select>
+                                               </td>
+                                       <?php endif; ?>
+                                       <td <?php if ($storage['id'] != 'addStorage') echo 'class="remove"'; ?>><img alt="<?php echo $l->t('Delete'); ?>" title="<?php echo $l->t('Delete'); ?>" class="svg action" src="<?php echo image_path('core', 'actions/delete.svg'); ?>" /></td>
+                               </tr>
+                       <?php endforeach; ?>
+                       </tbody>
+               </table>
+               <?php endif; ?>
+               <?php if ($_['isAdminPage'] == true): ?>
+                       <br />
+                       <input type="checkbox" name="allowUserMounting" id="allowUserMounting" value="1" <?php if ($_['allowUserMounting'] == 'yes') echo ' checked="checked"'; ?> />
+                       <label for="allowUserMounting"><?php echo $l->t('Enable User External Storage'); ?></label><br/>
+                       <em><?php echo $l->t('Allow users to mount their own external storage'); ?></em>
+               <?php endif; ?>
+       </fieldset>
+</form>
\ No newline at end of file