Merge pull request #19100 from owncloud/ext-tooltip-unavailable
Display external storage status as tooltip
This commit is contained in:
commit
911613f711
4 changed files with 66 additions and 13 deletions
|
@ -237,9 +237,21 @@ abstract class StoragesController extends Controller {
|
|||
)
|
||||
);
|
||||
} catch (InsufficientDataForMeaningfulAnswerException $e) {
|
||||
$storage->setStatus(\OC_Mount_Config::STATUS_INDETERMINATE);
|
||||
$storage->setStatus(
|
||||
\OC_Mount_Config::STATUS_INDETERMINATE,
|
||||
$this->l10n->t('Insufficient data: %s', [$e->getMessage()])
|
||||
);
|
||||
} catch (StorageNotAvailableException $e) {
|
||||
$storage->setStatus(\OC_Mount_Config::STATUS_ERROR);
|
||||
$storage->setStatus(
|
||||
\OC_Mount_Config::STATUS_ERROR,
|
||||
$e->getMessage()
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
// FIXME: convert storage exceptions to StorageNotAvailableException
|
||||
$storage->setStatus(
|
||||
\OC_Mount_Config::STATUS_ERROR,
|
||||
get_class($e).': '.$e->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -643,6 +643,10 @@ MountConfigListView.prototype = _.extend({
|
|||
});
|
||||
|
||||
addSelect2(this.$el.find('tr:not(#addMountPoint) .applicableUsers'), this._userListLimit);
|
||||
this.$el.tooltip({
|
||||
selector: '.status span',
|
||||
container: 'body'
|
||||
});
|
||||
|
||||
this._initEvents();
|
||||
|
||||
|
@ -709,11 +713,12 @@ MountConfigListView.prototype = _.extend({
|
|||
}
|
||||
highlightInput($target);
|
||||
var $tr = $target.closest('tr');
|
||||
this.updateStatus($tr, null);
|
||||
|
||||
var timer = $tr.data('save-timer');
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(function() {
|
||||
self.saveStorageConfig($tr);
|
||||
self.saveStorageConfig($tr, null, timer);
|
||||
}, 2000);
|
||||
$tr.data('save-timer', timer);
|
||||
},
|
||||
|
@ -931,8 +936,9 @@ MountConfigListView.prototype = _.extend({
|
|||
*
|
||||
* @param $tr storage row
|
||||
* @param Function callback callback to call after save
|
||||
* @param concurrentTimer only update if the timer matches this
|
||||
*/
|
||||
saveStorageConfig:function($tr, callback) {
|
||||
saveStorageConfig:function($tr, callback, concurrentTimer) {
|
||||
var self = this;
|
||||
var storage = this.getStorageConfig($tr);
|
||||
if (!storage.validate()) {
|
||||
|
@ -942,15 +948,23 @@ MountConfigListView.prototype = _.extend({
|
|||
this.updateStatus($tr, StorageConfig.Status.IN_PROGRESS);
|
||||
storage.save({
|
||||
success: function(result) {
|
||||
self.updateStatus($tr, result.status);
|
||||
$tr.attr('data-id', result.id);
|
||||
if (concurrentTimer === undefined
|
||||
|| $tr.data('save-timer') === concurrentTimer
|
||||
) {
|
||||
self.updateStatus($tr, result.status, result.statusMessage);
|
||||
$tr.attr('data-id', result.id);
|
||||
|
||||
if (_.isFunction(callback)) {
|
||||
callback(storage);
|
||||
if (_.isFunction(callback)) {
|
||||
callback(storage);
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
self.updateStatus($tr, StorageConfig.Status.ERROR);
|
||||
if (concurrentTimer === undefined
|
||||
|| $tr.data('save-timer') === concurrentTimer
|
||||
) {
|
||||
self.updateStatus($tr, StorageConfig.Status.ERROR);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -971,7 +985,7 @@ MountConfigListView.prototype = _.extend({
|
|||
this.updateStatus($tr, StorageConfig.Status.IN_PROGRESS);
|
||||
storage.recheck({
|
||||
success: function(result) {
|
||||
self.updateStatus($tr, result.status);
|
||||
self.updateStatus($tr, result.status, result.statusMessage);
|
||||
},
|
||||
error: function() {
|
||||
self.updateStatus($tr, StorageConfig.Status.ERROR);
|
||||
|
@ -984,11 +998,15 @@ MountConfigListView.prototype = _.extend({
|
|||
*
|
||||
* @param {jQuery} $tr
|
||||
* @param {int} status
|
||||
* @param {string} message
|
||||
*/
|
||||
updateStatus: function($tr, status) {
|
||||
updateStatus: function($tr, status, message) {
|
||||
var $statusSpan = $tr.find('.status span');
|
||||
$statusSpan.removeClass('loading-small success indeterminate error');
|
||||
switch (status) {
|
||||
case null:
|
||||
// remove status
|
||||
break;
|
||||
case StorageConfig.Status.IN_PROGRESS:
|
||||
$statusSpan.addClass('loading-small');
|
||||
break;
|
||||
|
@ -1001,6 +1019,7 @@ MountConfigListView.prototype = _.extend({
|
|||
default:
|
||||
$statusSpan.addClass('error');
|
||||
}
|
||||
$statusSpan.attr('data-original-title', (typeof message === 'string') ? message : '');
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -269,6 +269,7 @@ class OC_Mount_Config {
|
|||
}
|
||||
} catch (Exception $exception) {
|
||||
\OCP\Util::logException('files_external', $exception);
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
return self::STATUS_ERROR;
|
||||
|
|
|
@ -72,6 +72,13 @@ class StorageConfig implements \JsonSerializable {
|
|||
*/
|
||||
private $status;
|
||||
|
||||
/**
|
||||
* Status message
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $statusMessage;
|
||||
|
||||
/**
|
||||
* Priority
|
||||
*
|
||||
|
@ -295,7 +302,7 @@ class StorageConfig implements \JsonSerializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the storage status, whether the config worked last time
|
||||
* Gets the storage status, whether the config worked last time
|
||||
*
|
||||
* @return int $status status
|
||||
*/
|
||||
|
@ -303,13 +310,24 @@ class StorageConfig implements \JsonSerializable {
|
|||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the message describing the storage status
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getStatusMessage() {
|
||||
return $this->statusMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the storage status, whether the config worked last time
|
||||
*
|
||||
* @param int $status status
|
||||
* @param string|null $message optional message
|
||||
*/
|
||||
public function setStatus($status) {
|
||||
public function setStatus($status, $message = null) {
|
||||
$this->status = $status;
|
||||
$this->statusMessage = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -341,6 +359,9 @@ class StorageConfig implements \JsonSerializable {
|
|||
if (!is_null($this->status)) {
|
||||
$result['status'] = $this->status;
|
||||
}
|
||||
if (!is_null($this->statusMessage)) {
|
||||
$result['statusMessage'] = $this->statusMessage;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue