summaryrefslogtreecommitdiffstats
path: root/settings/js
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2019-02-11 11:13:55 +0100
committerGitHub <noreply@github.com>2019-02-11 11:13:55 +0100
commit34dc165132a06211e2ba10dcb9826cf6ed5096f6 (patch)
tree51bd0513064597ba6ea9af402381d91bce85db50 /settings/js
parent2e7eb344c8a65ab02a8704405d929fd60356a0ea (diff)
parent587a140c8a75e9a3a0a98ccd37675f785d37f5ab (diff)
downloadnextcloud-server-34dc165132a06211e2ba10dcb9826cf6ed5096f6.tar.gz
nextcloud-server-34dc165132a06211e2ba10dcb9826cf6ed5096f6.zip
Merge pull request #13097 from nextcloud/feature/11319/where-is-your-data
Where is your data?
Diffstat (limited to 'settings/js')
-rw-r--r--settings/js/admin.js103
1 files changed, 103 insertions, 0 deletions
diff --git a/settings/js/admin.js b/settings/js/admin.js
index b93c55a8a9c..1c9b5460eab 100644
--- a/settings/js/admin.js
+++ b/settings/js/admin.js
@@ -313,4 +313,107 @@ $(document).ready(function(){
if (document.getElementById('security-warning') !== null) {
setupChecks();
}
+
+ // server info
+
+ var serverInfoForm = $('#server-info-form');
+ var serverInfoWorkingTimeoutHandle;
+ var serverInfoSubmitButton = $('#server-info-submit-button');
+
+ /**
+ * Sets the server info submit button state to default.
+ */
+ function setServerInfoButtonDefault() {
+ serverInfoSubmitButton.removeClass('button-success');
+ serverInfoSubmitButton.removeClass('button-error');
+ serverInfoSubmitButton.removeClass('button-working');
+ }
+
+ /**
+ * Sets the server info submit button state to working.
+ */
+ function setServerInfoButtonWorking() {
+ serverInfoSubmitButton.removeClass('button-success');
+ serverInfoSubmitButton.removeClass('button-error');
+ serverInfoSubmitButton.addClass('button-working');
+ }
+
+ /**
+ * Sets the server info submit button state to success.
+ */
+ function setServerInfoButtonSuccess() {
+ serverInfoSubmitButton.removeClass('button-error');
+ serverInfoSubmitButton.removeClass('button-working');
+ serverInfoSubmitButton.addClass('button-success');
+ }
+
+ /**
+ * Sets the server info submit button state to error.
+ */
+ function setServerInfoButtonError() {
+ serverInfoSubmitButton.removeClass('button-success');
+ serverInfoSubmitButton.removeClass('button-working');
+ serverInfoSubmitButton.addClass('button-error');
+ }
+
+ /**
+ * Clears the server info working timeout, if present.
+ */
+ function clearServerInfoWorkingTimeout() {
+ if (serverInfoWorkingTimeoutHandle) {
+ clearTimeout(serverInfoWorkingTimeoutHandle);
+ serverInfoWorkingTimeoutHandle = undefined;
+ }
+ }
+
+ /**
+ * Unlocks the server info form, e.g. removing readonly from inputs.
+ */
+ function unlockForm() {
+ serverInfoForm.find('input, select').prop('readonly', false);
+ serverInfoSubmitButton.prop('disabled', false);
+ }
+
+ /**
+ * Resets the submit button state one of the form elements is changed.
+ */
+ serverInfoForm.find('input, select').on('keyup change', function() {
+ setServerInfoButtonDefault();
+ });
+
+ /**
+ * Handles the server info form submit.
+ */
+ serverInfoForm.on('submit', function(event) {
+ event.stopImmediatePropagation();
+ event.preventDefault();
+
+ serverInfoForm.find('input, select').prop('readonly', true);
+ serverInfoSubmitButton.prop('disabled', true);
+
+ clearServerInfoWorkingTimeout();
+
+ // start show spinner only if request takes longer than one second
+ serverInfoWorkingTimeoutHandle = setTimeout(function() {
+ setServerInfoButtonWorking();
+ }, 1000);
+
+ $.ajax({
+ url: OC.generateUrl('/settings/serverinfo'),
+ type: 'POST',
+ data: serverInfoForm.serialize(),
+ success: function() {
+ clearServerInfoWorkingTimeout();
+ setServerInfoButtonSuccess();
+ unlockForm();
+ serverInfoSubmitButton.blur();
+ },
+ error: function() {
+ clearServerInfoWorkingTimeout();
+ setServerInfoButtonError();
+ unlockForm();
+ serverInfoSubmitButton.blur();
+ }
+ });
+ });
});