Show status icons for mount points in external storage UI
This commit is contained in:
parent
5fb4ed2d92
commit
0dbf1d0260
|
@ -10,9 +10,10 @@ if ($_POST['isPersonal'] == 'true') {
|
|||
OCP\JSON::checkAdminUser();
|
||||
$isPersonal = false;
|
||||
}
|
||||
OC_Mount_Config::addMountPoint($_POST['mountPoint'],
|
||||
$status = OC_Mount_Config::addMountPoint($_POST['mountPoint'],
|
||||
$_POST['class'],
|
||||
$_POST['classOptions'],
|
||||
$_POST['mountType'],
|
||||
$_POST['applicable'],
|
||||
$isPersonal);
|
||||
$isPersonal);
|
||||
OCP\JSON::success(array('data' => array('message' => $status)));
|
|
@ -1,4 +1,7 @@
|
|||
.error { color: #FF3B3B; }
|
||||
td.status>span { display:inline-block; height:16px; width:16px; }
|
||||
span.success { background-image: url('../img/success.png'); background-repeat:no-repeat; }
|
||||
span.error { background-image: url('../img/error.png'); background-repeat:no-repeat; }
|
||||
span.waiting { background-image: url('../img/waiting.png'); background-repeat:no-repeat; }
|
||||
td.mountPoint, td.backend { width:10em; }
|
||||
td.remove>img { visibility:hidden; padding-top:0.8em; }
|
||||
tr:hover>td.remove>img { visibility:visible; cursor:pointer; }
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 533 B |
Binary file not shown.
After Width: | Height: | Size: 545 B |
Binary file not shown.
After Width: | Height: | Size: 512 B |
|
@ -4,6 +4,7 @@ OC.MountConfig={
|
|||
if (mountPoint == '') {
|
||||
return false;
|
||||
}
|
||||
var statusSpan = $(tr).find('.status span');
|
||||
var backendClass = $(tr).find('.backend').data('class');
|
||||
var configuration = $(tr).find('.configuration input');
|
||||
var addMountPoint = true;
|
||||
|
@ -27,6 +28,7 @@ OC.MountConfig={
|
|||
}
|
||||
});
|
||||
if (addMountPoint) {
|
||||
var status = false;
|
||||
if ($('#externalStorage').data('admin') === true) {
|
||||
var isPersonal = false;
|
||||
var multiselect = $(tr).find('.chzn-select').val();
|
||||
|
@ -47,7 +49,14 @@ OC.MountConfig={
|
|||
oldUsers.splice($.inArray(applicable, oldUsers), 1);
|
||||
}
|
||||
}
|
||||
$.post(OC.filePath('files_external', 'ajax', 'addMountPoint.php'), { mountPoint: mountPoint, class: backendClass, classOptions: classOptions, mountType: mountType, applicable: applicable, isPersonal: isPersonal });
|
||||
$.post(OC.filePath('files_external', 'ajax', 'addMountPoint.php'), { mountPoint: mountPoint, class: backendClass, classOptions: classOptions, mountType: mountType, applicable: applicable, isPersonal: isPersonal }, function(result) {
|
||||
statusSpan.removeClass();
|
||||
if (result && result.status == 'success' && result.data.message) {
|
||||
statusSpan.addClass('success');
|
||||
} else {
|
||||
statusSpan.addClass('error');
|
||||
}
|
||||
});
|
||||
});
|
||||
var mountType = 'group';
|
||||
$.each(oldGroups, function(index, applicable) {
|
||||
|
@ -61,7 +70,14 @@ OC.MountConfig={
|
|||
var isPersonal = true;
|
||||
var mountType = 'user';
|
||||
var applicable = OC.currentUser;
|
||||
$.post(OC.filePath('files_external', 'ajax', 'addMountPoint.php'), { mountPoint: mountPoint, class: backendClass, classOptions: classOptions, mountType: mountType, applicable: applicable, isPersonal: isPersonal });
|
||||
$.post(OC.filePath('files_external', 'ajax', 'addMountPoint.php'), { mountPoint: mountPoint, class: backendClass, classOptions: classOptions, mountType: mountType, applicable: applicable, isPersonal: isPersonal }, function(result) {
|
||||
statusSpan.removeClass();
|
||||
if (result && result.status == 'success' && result.data.message) {
|
||||
statusSpan.addClass('success');
|
||||
} else {
|
||||
statusSpan.addClass('error');
|
||||
}
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -82,6 +98,7 @@ $(document).ready(function() {
|
|||
$(tr).find('.mountPoint input').val(suggestMountPoint(selected.replace(/\s+/g, '')));
|
||||
}
|
||||
$(tr).addClass(backendClass);
|
||||
$(tr).find('.status').append('<span class="waiting"></span>');
|
||||
$(tr).find('.backend').data('class', backendClass);
|
||||
var configurations = $(this).data('configurations');
|
||||
var td = $(tr).find('td.configuration');
|
||||
|
|
|
@ -30,11 +30,19 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common {
|
|||
|
||||
private static $tempFiles = array();
|
||||
|
||||
// TODO options: storage class, encryption server side, encrypt before upload?
|
||||
// TODO Update to new AWS SDK
|
||||
|
||||
public function __construct($params) {
|
||||
$this->s3 = new AmazonS3(array('key' => $params['key'], 'secret' => $params['secret']));
|
||||
$this->bucket = $params['bucket'];
|
||||
if (isset($params['key']) && isset($params['secret']) && isset($params['bucket'])) {
|
||||
$this->s3 = new AmazonS3(array('key' => $params['key'], 'secret' => $params['secret']));
|
||||
$this->bucket = $params['bucket'];
|
||||
$test = $this->s3->get_canonical_user_id();
|
||||
if (!isset($test['id']) || $test['id'] == '') {
|
||||
throw new Exception();
|
||||
}
|
||||
} else {
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
|
||||
private function getObject($path) {
|
||||
|
|
|
@ -131,7 +131,9 @@ class OC_Mount_Config {
|
|||
'class' => $mount['class'],
|
||||
'backend' => $backends[$mount['class']]['backend'],
|
||||
'configuration' => $mount['options'],
|
||||
'applicable' => array('groups' => array($group), 'users' => array()));
|
||||
'applicable' => array('groups' => array($group), 'users' => array()),
|
||||
'status' => self::getBackendStatus($mount['class'], $mount['options'])
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -146,10 +148,13 @@ class OC_Mount_Config {
|
|||
$system[$mountPoint]['applicable']['users']
|
||||
= array_merge($system[$mountPoint]['applicable']['users'], array($user));
|
||||
} else {
|
||||
$system[$mountPoint] = array('class' => $mount['class'],
|
||||
$system[$mountPoint] = array(
|
||||
'class' => $mount['class'],
|
||||
'backend' => $backends[$mount['class']]['backend'],
|
||||
'configuration' => $mount['options'],
|
||||
'applicable' => array('groups' => array(), 'users' => array($user)));
|
||||
'applicable' => array('groups' => array(), 'users' => array($user)),
|
||||
'status' => self::getBackendStatus($mount['class'], $mount['options'])
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -170,14 +175,32 @@ class OC_Mount_Config {
|
|||
if (isset($mountPoints[self::MOUNT_TYPE_USER][$uid])) {
|
||||
foreach ($mountPoints[self::MOUNT_TYPE_USER][$uid] as $mountPoint => $mount) {
|
||||
// Remove '/uid/files/' from mount point
|
||||
$personal[substr($mountPoint, strlen($uid) + 8)] = array('class' => $mount['class'],
|
||||
'backend' => $backends[$mount['class']]['backend'],
|
||||
'configuration' => $mount['options']);
|
||||
$personal[substr($mountPoint, strlen($uid) + 8)] = array(
|
||||
'class' => $mount['class'],
|
||||
'backend' => $backends[$mount['class']]['backend'],
|
||||
'configuration' => $mount['options'],
|
||||
'status' => self::getBackendStatus($mount['class'], $mount['options'])
|
||||
);
|
||||
}
|
||||
}
|
||||
return $personal;
|
||||
}
|
||||
|
||||
private static function getBackendStatus($class, $options) {
|
||||
foreach ($options as &$option) {
|
||||
$option = str_replace('$user', OCP\User::getUser(), $option);
|
||||
}
|
||||
if (class_exists($class)) {
|
||||
try {
|
||||
new $class($options);
|
||||
return true;
|
||||
} catch (Exception $exception) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add directory for mount point to the filesystem
|
||||
* @param OC_Fileview instance $view
|
||||
|
@ -259,7 +282,7 @@ class OC_Mount_Config {
|
|||
$mountPoints[$mountType] = $mount;
|
||||
}
|
||||
self::writeData($isPersonal, $mountPoints);
|
||||
return true;
|
||||
return self::getBackendStatus($class, $classOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -41,7 +41,10 @@ class OC_Filestorage_Dropbox extends OC_Filestorage_Common {
|
|||
$oauth = new Dropbox_OAuth_Curl($params['app_key'], $params['app_secret']);
|
||||
$oauth->setToken($params['token'], $params['token_secret']);
|
||||
$this->dropbox = new Dropbox_API($oauth, 'dropbox');
|
||||
$this->mkdir('');
|
||||
$test = $this->stat('');
|
||||
if (!$test) {
|
||||
throw new Exception('Creating OC_Filestorage_Dropbox storage failed');
|
||||
}
|
||||
} else {
|
||||
throw new Exception('Creating OC_Filestorage_Dropbox storage failed');
|
||||
}
|
||||
|
|
|
@ -16,26 +16,35 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{
|
|||
private static $tempFiles=array();
|
||||
|
||||
public function __construct($params) {
|
||||
$this->host=$params['host'];
|
||||
$this->user=$params['user'];
|
||||
$this->password=$params['password'];
|
||||
if (isset($params['secure'])) {
|
||||
if (is_string($params['secure'])) {
|
||||
$this->secure = ($params['secure'] === 'true');
|
||||
if (isset($params['host']) && isset($params['user']) && isset($params['password'])) {
|
||||
$this->host=$params['host'];
|
||||
$this->user=$params['user'];
|
||||
$this->password=$params['password'];
|
||||
if (isset($params['secure'])) {
|
||||
if (is_string($params['secure'])) {
|
||||
$this->secure = ($params['secure'] === 'true');
|
||||
} else {
|
||||
$this->secure = (bool)$params['secure'];
|
||||
}
|
||||
} else {
|
||||
$this->secure = (bool)$params['secure'];
|
||||
$this->secure = false;
|
||||
}
|
||||
$this->root=isset($params['root'])?$params['root']:'/';
|
||||
if ( ! $this->root || $this->root[0]!='/') {
|
||||
$this->root='/'.$this->root;
|
||||
}
|
||||
$test = $this->stat('');
|
||||
if (!$test) {
|
||||
throw new Exception();
|
||||
}
|
||||
//create the root folder if necesary
|
||||
if ( ! $this->is_dir('')) {
|
||||
$this->mkdir('');
|
||||
}
|
||||
} else {
|
||||
$this->secure = false;
|
||||
}
|
||||
$this->root=isset($params['root'])?$params['root']:'/';
|
||||
if ( ! $this->root || $this->root[0]!='/') {
|
||||
$this->root='/'.$this->root;
|
||||
}
|
||||
//create the root folder if necesary
|
||||
if ( ! $this->is_dir('')) {
|
||||
$this->mkdir('');
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,6 +42,10 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
|
|||
$this->oauth_token = new OAuthToken($params['token'], $params['token_secret']);
|
||||
$this->sig_method = new OAuthSignatureMethod_HMAC_SHA1();
|
||||
$this->entries = array();
|
||||
$test = $this->free_space('');
|
||||
if (!$test) {
|
||||
throw new Exception();
|
||||
}
|
||||
} else {
|
||||
throw new Exception('Creating OC_Filestorage_Google storage failed');
|
||||
}
|
||||
|
|
|
@ -16,28 +16,36 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{
|
|||
private $share;
|
||||
|
||||
public function __construct($params) {
|
||||
$this->host=$params['host'];
|
||||
$this->user=$params['user'];
|
||||
$this->password=$params['password'];
|
||||
$this->share=$params['share'];
|
||||
$this->root=isset($params['root'])?$params['root']:'/';
|
||||
if ( ! $this->root || $this->root[0]!='/') {
|
||||
$this->root='/'.$this->root;
|
||||
}
|
||||
if (substr($this->root, -1, 1)!='/') {
|
||||
$this->root.='/';
|
||||
}
|
||||
if ( ! $this->share || $this->share[0]!='/') {
|
||||
$this->share='/'.$this->share;
|
||||
}
|
||||
if (substr($this->share, -1, 1)=='/') {
|
||||
$this->share=substr($this->share, 0, -1);
|
||||
}
|
||||
|
||||
//create the root folder if necesary
|
||||
if ( ! $this->is_dir('')) {
|
||||
$this->mkdir('');
|
||||
if (isset($params['host']) && isset($params['user']) && isset($params['password']) && isset($params['share'])) {
|
||||
$this->host=$params['host'];
|
||||
$this->user=$params['user'];
|
||||
$this->password=$params['password'];
|
||||
$this->share=$params['share'];
|
||||
$this->root=isset($params['root'])?$params['root']:'/';
|
||||
if ( ! $this->root || $this->root[0]!='/') {
|
||||
$this->root='/'.$this->root;
|
||||
}
|
||||
if (substr($this->root, -1, 1)!='/') {
|
||||
$this->root.='/';
|
||||
}
|
||||
if ( ! $this->share || $this->share[0]!='/') {
|
||||
$this->share='/'.$this->share;
|
||||
}
|
||||
if (substr($this->share, -1, 1)=='/') {
|
||||
$this->share=substr($this->share, 0, -1);
|
||||
}
|
||||
$test = $this->stat('');
|
||||
if (!$test) {
|
||||
throw new Exception();
|
||||
}
|
||||
//create the root folder if necesary
|
||||
if ( ! $this->is_dir('')) {
|
||||
$this->mkdir('');
|
||||
}
|
||||
} else {
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function constructUrl($path) {
|
||||
|
|
|
@ -267,32 +267,37 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
|
|||
}
|
||||
|
||||
public function __construct($params) {
|
||||
$this->token=$params['token'];
|
||||
$this->host=$params['host'];
|
||||
$this->user=$params['user'];
|
||||
$this->root=isset($params['root'])?$params['root']:'/';
|
||||
if (isset($params['secure'])) {
|
||||
if (is_string($params['secure'])) {
|
||||
$this->secure = ($params['secure'] === 'true');
|
||||
if (isset($params['token']) && isset($params['host']) && isset($params['user'])) {
|
||||
$this->token=$params['token'];
|
||||
$this->host=$params['host'];
|
||||
$this->user=$params['user'];
|
||||
$this->root=isset($params['root'])?$params['root']:'/';
|
||||
if (isset($params['secure'])) {
|
||||
if (is_string($params['secure'])) {
|
||||
$this->secure = ($params['secure'] === 'true');
|
||||
} else {
|
||||
$this->secure = (bool)$params['secure'];
|
||||
}
|
||||
} else {
|
||||
$this->secure = (bool)$params['secure'];
|
||||
$this->secure = false;
|
||||
}
|
||||
if ( ! $this->root || $this->root[0]!='/') {
|
||||
$this->root='/'.$this->root;
|
||||
}
|
||||
$this->auth = new CF_Authentication($this->user, $this->token, null, $this->host);
|
||||
$this->auth->authenticate();
|
||||
|
||||
$this->conn = new CF_Connection($this->auth);
|
||||
|
||||
if ( ! $this->containerExists('/')) {
|
||||
$this->rootContainer=$this->createContainer('/');
|
||||
} else {
|
||||
$this->rootContainer=$this->getContainer('/');
|
||||
}
|
||||
} else {
|
||||
$this->secure = false;
|
||||
}
|
||||
if ( ! $this->root || $this->root[0]!='/') {
|
||||
$this->root='/'.$this->root;
|
||||
}
|
||||
$this->auth = new CF_Authentication($this->user, $this->token, null, $this->host);
|
||||
$this->auth->authenticate();
|
||||
|
||||
$this->conn = new CF_Connection($this->auth);
|
||||
|
||||
if ( ! $this->containerExists('/')) {
|
||||
$this->rootContainer=$this->createContainer('/');
|
||||
} else {
|
||||
$this->rootContainer=$this->getContainer('/');
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,47 +20,56 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
|
|||
private static $tempFiles=array();
|
||||
|
||||
public function __construct($params) {
|
||||
$host = $params['host'];
|
||||
//remove leading http[s], will be generated in createBaseUri()
|
||||
if (substr($host, 0, 8) == "https://") $host = substr($host, 8);
|
||||
else if (substr($host, 0, 7) == "http://") $host = substr($host, 7);
|
||||
$this->host=$host;
|
||||
$this->user=$params['user'];
|
||||
$this->password=$params['password'];
|
||||
if (isset($params['secure'])) {
|
||||
if (is_string($params['secure'])) {
|
||||
$this->secure = ($params['secure'] === 'true');
|
||||
if (isset($params['host']) && isset($params['user']) && isset($params['password'])) {
|
||||
$host = $params['host'];
|
||||
//remove leading http[s], will be generated in createBaseUri()
|
||||
if (substr($host, 0, 8) == "https://") $host = substr($host, 8);
|
||||
else if (substr($host, 0, 7) == "http://") $host = substr($host, 7);
|
||||
$this->host=$host;
|
||||
$this->user=$params['user'];
|
||||
$this->password=$params['password'];
|
||||
if (isset($params['secure'])) {
|
||||
if (is_string($params['secure'])) {
|
||||
$this->secure = ($params['secure'] === 'true');
|
||||
} else {
|
||||
$this->secure = (bool)$params['secure'];
|
||||
}
|
||||
} else {
|
||||
$this->secure = (bool)$params['secure'];
|
||||
$this->secure = false;
|
||||
}
|
||||
$this->root=isset($params['root'])?$params['root']:'/';
|
||||
if ( ! $this->root || $this->root[0]!='/') {
|
||||
$this->root='/'.$this->root;
|
||||
}
|
||||
if (substr($this->root, -1, 1)!='/') {
|
||||
$this->root.='/';
|
||||
}
|
||||
|
||||
$settings = array(
|
||||
'baseUri' => $this->createBaseUri(),
|
||||
'userName' => $this->user,
|
||||
'password' => $this->password,
|
||||
);
|
||||
|
||||
$this->client = new OC_Connector_Sabre_Client($settings);
|
||||
|
||||
$caview = \OCP\Files::getStorage('files_external');
|
||||
if ($caview) {
|
||||
$certPath=\OCP\Config::getSystemValue('datadirectory').$caview->getAbsolutePath("").'rootcerts.crt';
|
||||
if (file_exists($certPath)) {
|
||||
$this->client->addTrustedCertificates($certPath);
|
||||
}
|
||||
}
|
||||
$test = $this->stat('');
|
||||
if (!$test) {
|
||||
throw new Exception();
|
||||
}
|
||||
//create the root folder if necesary
|
||||
$this->mkdir('');
|
||||
} else {
|
||||
$this->secure = false;
|
||||
throw new Exception();
|
||||
}
|
||||
$this->root=isset($params['root'])?$params['root']:'/';
|
||||
if ( ! $this->root || $this->root[0]!='/') {
|
||||
$this->root='/'.$this->root;
|
||||
}
|
||||
if (substr($this->root, -1, 1)!='/') {
|
||||
$this->root.='/';
|
||||
}
|
||||
|
||||
$settings = array(
|
||||
'baseUri' => $this->createBaseUri(),
|
||||
'userName' => $this->user,
|
||||
'password' => $this->password,
|
||||
);
|
||||
|
||||
$this->client = new OC_Connector_Sabre_Client($settings);
|
||||
|
||||
$caview = \OCP\Files::getStorage('files_external');
|
||||
if ($caview) {
|
||||
$certPath=\OCP\Config::getSystemValue('datadirectory').$caview->getAbsolutePath("").'rootcerts.crt';
|
||||
if (file_exists($certPath)) {
|
||||
$this->client->addTrustedCertificates($certPath);
|
||||
}
|
||||
}
|
||||
//create the root folder if necesary
|
||||
$this->mkdir('');
|
||||
|
||||
}
|
||||
|
||||
private function createBaseUri() {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
<table id="externalStorage" data-admin='<?php echo json_encode($_['isAdminPage']); ?>'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th><?php echo $l->t('Mount point'); ?></th>
|
||||
<th><?php echo $l->t('Backend'); ?></th>
|
||||
<th><?php echo $l->t('Configuration'); ?></th>
|
||||
|
@ -17,6 +18,11 @@
|
|||
<?php $_['mounts'] = array_merge($_['mounts'], array('' => array())); ?>
|
||||
<?php foreach ($_['mounts'] as $mountPoint => $mount): ?>
|
||||
<tr <?php echo ($mountPoint != '') ? 'class="'.$mount['class'].'"' : 'id="addMountPoint"'; ?>>
|
||||
<td class="status">
|
||||
<?php if (isset($mount['status'])): ?>
|
||||
<span class="<?php echo ($mount['status']) ? 'success' : 'error'; ?>"></span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="mountPoint"><input type="text" name="mountPoint"
|
||||
value="<?php echo $mountPoint; ?>"
|
||||
placeholder="<?php echo $l->t('Mount point'); ?>" /></td>
|
||||
|
|
Loading…
Reference in New Issue