Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/notifications.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2018-07-17 16:41:31 +0300
committerJoas Schilling <coding@schilljs.com>2018-07-17 16:41:31 +0300
commitb6a175bb0d47f7302094f71e2584ac5d1292e509 (patch)
treef1cced23410df1371158e2ca4762256fb99850c0
parent77aec817e6965cf170dac9e31d30172faacb7804 (diff)
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--package-lock.json74
-rw-r--r--package.json1
-rw-r--r--src/App.vue70
-rw-r--r--src/components/action.vue34
-rw-r--r--src/components/notification.vue17
5 files changed, 99 insertions, 97 deletions
diff --git a/package-lock.json b/package-lock.json
index 18c1a45..0865c60 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -522,6 +522,15 @@
"postcss-value-parser": "^3.2.3"
}
},
+ "axios": {
+ "version": "0.18.0",
+ "resolved": "https://registry.npmjs.org/axios/-/axios-0.18.0.tgz",
+ "integrity": "sha1-MtU+SFHv3AoRmTts0AB4nXDAUQI=",
+ "requires": {
+ "follow-redirects": "^1.3.0",
+ "is-buffer": "^1.1.5"
+ }
+ },
"babel-code-frame": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz",
@@ -2499,6 +2508,24 @@
"readable-stream": "^2.0.4"
}
},
+ "follow-redirects": {
+ "version": "1.5.1",
+ "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.1.tgz",
+ "integrity": "sha512-v9GI1hpaqq1ZZR6pBD1+kI7O24PhDvNGNodjS3MdcEqyrahCp8zbtpv+2B/krUnSmUH80lbAS7MrdeK5IylgKg==",
+ "requires": {
+ "debug": "^3.1.0"
+ },
+ "dependencies": {
+ "debug": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
+ "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
+ "requires": {
+ "ms": "2.0.0"
+ }
+ }
+ }
+ },
"for-in": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",
@@ -2562,8 +2589,7 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
- "dev": true,
- "optional": true
+ "dev": true
},
"aproba": {
"version": "1.2.0",
@@ -2584,14 +2610,12 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
- "dev": true,
- "optional": true
+ "dev": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
- "optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -2606,20 +2630,17 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
- "dev": true,
- "optional": true
+ "dev": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
- "dev": true,
- "optional": true
+ "dev": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
- "dev": true,
- "optional": true
+ "dev": true
},
"core-util-is": {
"version": "1.0.2",
@@ -2736,8 +2757,7 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
- "dev": true,
- "optional": true
+ "dev": true
},
"ini": {
"version": "1.3.5",
@@ -2749,7 +2769,6 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
- "optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@@ -2764,7 +2783,6 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
- "optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@@ -2772,14 +2790,12 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
- "dev": true,
- "optional": true
+ "dev": true
},
"minipass": {
"version": "2.2.4",
"bundled": true,
"dev": true,
- "optional": true,
"requires": {
"safe-buffer": "^5.1.1",
"yallist": "^3.0.0"
@@ -2798,7 +2814,6 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
- "optional": true,
"requires": {
"minimist": "0.0.8"
}
@@ -2879,8 +2894,7 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
- "dev": true,
- "optional": true
+ "dev": true
},
"object-assign": {
"version": "4.1.1",
@@ -2892,7 +2906,6 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
- "optional": true,
"requires": {
"wrappy": "1"
}
@@ -2978,8 +2991,7 @@
"safe-buffer": {
"version": "5.1.1",
"bundled": true,
- "dev": true,
- "optional": true
+ "dev": true
},
"safer-buffer": {
"version": "2.1.2",
@@ -3015,7 +3027,6 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
- "optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@@ -3035,7 +3046,6 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
- "optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@@ -3079,14 +3089,12 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
- "dev": true,
- "optional": true
+ "dev": true
},
"yallist": {
"version": "3.0.2",
"bundled": true,
- "dev": true,
- "optional": true
+ "dev": true
}
}
},
@@ -3554,8 +3562,7 @@
"is-buffer": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
- "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==",
- "dev": true
+ "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w=="
},
"is-data-descriptor": {
"version": "0.1.4",
@@ -4072,8 +4079,7 @@
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
- "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
- "dev": true
+ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"mute-stream": {
"version": "0.0.7",
diff --git a/package.json b/package.json
index b391491..ea6f4a4 100644
--- a/package.json
+++ b/package.json
@@ -11,6 +11,7 @@
"build": "webpack --progress --hide-modules --config src/webpack.prod.js"
},
"dependencies": {
+ "axios": "^0.18.0",
"vue": "^2.5.16"
},
"browserslist": [
diff --git a/src/App.vue b/src/App.vue
index 5b55cd8..1b890e7 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -19,7 +19,7 @@
<script>
import notification from './components/notification';
- // import axios from 'axios';
+ import axios from 'axios';
export default {
name: 'app',
@@ -62,16 +62,14 @@
methods: {
onDismissAll: function() {
- $.ajax({
- url: OC.linkToOCS('apps/notifications/api/v2', 2) + 'notifications',
- type: 'DELETE',
- success: function () {
+ axios
+ .delete(OC.linkToOCS('apps/notifications/api/v2', 2) + 'notifications', { headers: { requesttoken: OC.requestToken } })
+ .then(response => {
this.notifications = [];
- }.bind(this),
- error: function () {
+ })
+ .catch(err => {
OC.Notification.showTemporary(t('notifications', 'Failed to dismiss all notifications'));
- }
- });
+ });
},
onRemove: function(index) {
this.notifications.splice(index, 1);
@@ -81,37 +79,31 @@
* Performs the AJAX request to retrieve the notifications
*/
_fetch: function() {
- var request = $.ajax({
- url: OC.linkToOCS('apps/notifications/api/v2', 2) + 'notifications',
- type: 'GET',
- beforeSend: function (request) {
- request.setRequestHeader('Accept', 'application/json');
- }
- });
-
- request.done(function(data, statusText, xhr) {
- if (xhr.status === 204) {
- // 204 No Content - Intercept when no notifiers are there.
+ axios
+ .get(OC.linkToOCS('apps/notifications/api/v2', 2) + 'notifications', { headers: { requesttoken: OC.requestToken } })
+ .then(response => {
+ if (response.status === 204) {
+ // 204 No Content - Intercept when no notifiers are there.
+ this._shutDownNotifications();
+ } else if (!_.isUndefined(response.data) && !_.isUndefined(response.data.ocs) && !_.isUndefined(response.data.ocs.data) && _.isArray(response.data.ocs.data)) {
+ this.notifications = response.data.ocs.data;
+ } else {
+ console.debug("data.ocs.data is undefined or not an array");
+ }
+ })
+ .catch(err => {
+ if (err.response.status === 503) {
+ // 503 - Maintenance mode
+ console.debug('Shutting down notifications: instance is in maintenance mode.');
+ } else if (err.response.status === 404) {
+ // 404 - App disabled
+ console.debug('Shutting down notifications: app is disabled.');
+ } else {
+ console.error('Shutting down notifications: [' + err.response.status + '] ' + err.response.statusText);
+ }
+
this._shutDownNotifications();
- } else if (!_.isUndefined(data) && !_.isUndefined(data.ocs) && !_.isUndefined(data.ocs.data) && _.isArray(data.ocs.data)) {
- this.notifications = data.ocs.data;
- } else {
- console.debug("data.ocs.data is undefined or not an array");
- }
- }.bind(this));
- request.fail(function(xhr) {
- if (xhr.status === 503) {
- // 503 - Maintenance mode
- console.debug('Shutting down notifications: instance is in maintenance mode.');
- } else if (xhr.status === 404) {
- // 404 - App disabled
- console.debug('Shutting down notifications: app is disabled.');
- } else {
- console.error('Shutting down notifications: [' + xhr.status + '] ' + xhr.statusText);
- }
-
- this._shutDownNotifications();
- }.bind(this));
+ });
},
_backgroundFetch: function() {
diff --git a/src/components/action.vue b/src/components/action.vue
index c0df6ae..1c89c12 100644
--- a/src/components/action.vue
+++ b/src/components/action.vue
@@ -4,6 +4,7 @@
</template>
<script>
+ import axios from 'axios';
export default {
name: 'action',
@@ -16,23 +17,24 @@
methods: {
onClickActionButton: function () {
- $.ajax({
+ axios({
+ method: this.type || 'GET',
url: this.link,
- type: this.type || 'GET',
- success: function () {
- this.$parent._$el.fadeOut(OC.menuSpeed);
- this.$parent.$emit('remove');
- $('body').trigger(new $.Event('OCA.Notification.Action', {
- notification: this.$parent,
- action: {
- url: this.link,
- type: this.type || 'GET'
- }
- }));
- }.bind(this),
- error: function () {
- OC.Notification.showTemporary(t('notifications', 'Failed to perform action'));
- }
+ headers: { requesttoken: OC.requestToken }
+ })
+ .then(response => {
+ this.$parent._$el.fadeOut(OC.menuSpeed);
+ this.$parent.$emit('remove');
+ $('body').trigger(new $.Event('OCA.Notification.Action', {
+ notification: this.$parent,
+ action: {
+ url: this.link,
+ type: this.type || 'GET'
+ }
+ }));
+ })
+ .catch(err => {
+ OC.Notification.showTemporary(t('notifications', 'Failed to perform action'));
});
}
}
diff --git a/src/components/notification.vue b/src/components/notification.vue
index ebfbf77..1d904a5 100644
--- a/src/components/notification.vue
+++ b/src/components/notification.vue
@@ -23,6 +23,7 @@
</template>
<script>
+ import axios from 'axios';
import action from './action';
import parser from '../richObjectStringParser';
@@ -95,17 +96,17 @@
},
onDismissNotification: function() {
- $.ajax({
- url: OC.linkToOCS('apps/notifications/api/v2', 2) + 'notifications/' + this.notification_id,
- type: 'DELETE',
- success: function () {
+ axios
+ .delete(OC.linkToOCS('apps/notifications/api/v2', 2) + 'notifications/' + this.notification_id,
+ { headers: { requesttoken: OC.requestToken } }
+ )
+ .then(response => {
this._$el.fadeOut(OC.menuSpeed);
this.$emit('remove');
- }.bind(this),
- error: function () {
+ })
+ .catch(err => {
OC.Notification.showTemporary(t('notifications', 'Failed to dismiss notification'));
- }
- });
+ });
},
/**