summaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-02-03 12:48:17 +0100
committerVincent Petry <pvince81@owncloud.com>2014-09-23 11:16:14 +0200
commite65ceb08fc4a56d0fb9e4be5d51ba04168cbb59a (patch)
tree72f9a407f9f0a653ad534a1aec4df76837d15ef8 /core/js
parentfc42a64e6c848adc21bb069da01398f7d39fcc4a (diff)
downloadnextcloud-server-e65ceb08fc4a56d0fb9e4be5d51ba04168cbb59a.tar.gz
nextcloud-server-e65ceb08fc4a56d0fb9e4be5d51ba04168cbb59a.zip
Moved WebDAV and internet checks to client side JS
- Added setup checks in JavaScript - Moved isWebDAVWorking to JS using SetupChecks - Moved internet connection checks to an ajax call that goes through the server
Diffstat (limited to 'core/js')
-rw-r--r--core/js/js.js1
-rw-r--r--core/js/setupchecks.js71
2 files changed, 72 insertions, 0 deletions
diff --git a/core/js/js.js b/core/js/js.js
index d49001ee387..dde8ffa3211 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -256,6 +256,7 @@ var OC={
* @param {string} type the type of the file to link to (e.g. css,img,ajax.template)
* @param {string} file the filename
* @return {string} Absolute URL for a file in an app
+ * @deprecated use OC.generateUrl() instead
*/
filePath:function(app,type,file){
var isCore=OC.coreApps.indexOf(app)!==-1,
diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js
new file mode 100644
index 00000000000..f351c1b451a
--- /dev/null
+++ b/core/js/setupchecks.js
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2014
+ *
+ * This file is licensed under the Affero General Public License version 3
+ * or later.
+ *
+ * See the COPYING-README file.
+ *
+ */
+
+(function() {
+ OC.SetupChecks = {
+ /**
+ * Check whether the WebDAV connection works.
+ *
+ * @return $.Deferred object resolved with an array of error messages
+ */
+ checkWebDAV: function() {
+ var deferred = $.Deferred();
+ var afterCall = function(xhr) {
+ var messages = [];
+ if (xhr.status !== 207 && xhr.status !== 401) {
+ messages.push(
+ t('core', 'Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken.')
+ );
+ }
+ deferred.resolve(messages);
+ };
+
+ $.ajax({
+ type: 'PROPFIND',
+ url: OC.linkToRemoteBase('webdav'),
+ data: '<?xml version="1.0"?>' +
+ '<d:propfind xmlns:d="DAV:">' +
+ '<d:prop><d:resourcetype/></d:prop>' +
+ '</d:propfind>',
+ complete: afterCall
+ });
+ return deferred.promise();
+ },
+
+ /**
+ * Runs setup checks on the server side
+ *
+ * @return $.Deferred object resolved with an array of error messages
+ */
+ checkSetup: function() {
+ var deferred = $.Deferred();
+ var afterCall = function(data, statusText, xhr) {
+ var messages = [];
+ if (xhr.status === 200 && data) {
+ if (!data.serverhasinternetconnection) {
+ messages.push(
+ t('core', 'This server has no working internet connection. This means that some of the features like mounting of external storage, notifications about updates or installation of 3rd party apps donĀ“t work. Accessing files from remote and sending of notification emails might also not work. We suggest to enable internet connection for this server if you want to have all features.')
+ );
+ }
+ } else {
+ messages.push(t('core', 'Error occurred while checking server setup'));
+ }
+ deferred.resolve(messages);
+ };
+
+ $.ajax({
+ type: 'GET',
+ url: OC.generateUrl('settings/ajax/checksetup')
+ }).then(afterCall, afterCall);
+ return deferred.promise();
+ }
+ };
+})();
+