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:21:44 +0300
committerJoas Schilling <coding@schilljs.com>2018-07-17 16:21:44 +0300
commit77aec817e6965cf170dac9e31d30172faacb7804 (patch)
tree400da7a543409e8d800ce9c9a3884610f9b3a83e
parent8a698911cf29cba031672098c89462e202b84b9b (diff)
Move to src/ and import
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--js-src/app.js111
-rw-r--r--package-lock.json13
-rw-r--r--package.json6
-rw-r--r--src/App.vue (renamed from js-src/components/root.vue)76
-rw-r--r--src/components/action.vue (renamed from js-src/components/action.vue)2
-rw-r--r--src/components/notification.vue (renamed from js-src/components/notification.vue)7
-rw-r--r--src/init.js (renamed from js-src/init.js)17
-rw-r--r--src/richObjectStringParser.js (renamed from js-src/richObjectStringParser.js)0
-rw-r--r--src/webpack.common.js (renamed from js-src/webpack.common.js)0
-rw-r--r--src/webpack.dev.js (renamed from js-src/webpack.dev.js)0
-rw-r--r--src/webpack.prod.js (renamed from js-src/webpack.prod.js)0
11 files changed, 98 insertions, 134 deletions
diff --git a/js-src/app.js b/js-src/app.js
deleted file mode 100644
index 879c161..0000000
--- a/js-src/app.js
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * @copyright (c) 2016 Joas Schilling <coding@schilljs.com>
- * @copyright (c) 2015 Tom Needham <tom@owncloud.com>
- *
- * @author Tom Needham <tom@owncloud.com>
- * @author Joas Schilling <coding@schilljs.com>
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- */
-
-/* global OC, OCA, $, _, t, oc_config, define, console */
-
-define(function (require) {
- "use strict";
-
- return {
-
- /** @type {number} */
- pollInterval: 30000, // milliseconds
-
- /** @type {number|null} */
- interval: null,
-
- /** @type {Vue|null} */
- vm: null,
-
- /**
- * Initialise the app
- */
- initialise: function() {
-
- // Add to the UI
- $('form.searchbox').after($('<div>').attr('id', 'notifications'));
-
- // Setup Vue
- var Vue = require('vue');
- Vue.mixin({
- methods: {
- t: function(app, text, vars, count, options) {
- return OC.L10N.translate(app, text, vars, count, options);
- },
- n: function(app, textSingular, textPlural, count, vars, options) {
- return OC.L10N.translatePlural(app, textSingular, textPlural, count, vars, options);
- }
- }
- });
-
- this.vm = new Vue(require('./components/root.vue'));
-
- // Initial call to the notification endpoint
- this._fetch();
-
- // Setup the background checker
- if (oc_config.session_keepalive) {
- this.interval = setInterval(this._backgroundFetch.bind(this), this.pollInterval);
- }
- },
-
- /**
- * 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.
- this._shutDownNotifications();
- } else if (!_.isUndefined(data) && !_.isUndefined(data.ocs) && !_.isUndefined(data.ocs.data) && _.isArray(data.ocs.data)) {
- this.vm.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() {
- this.vm.backgroundFetching = true;
- this._fetch();
- },
-
- /**
- * The app was disabled or has no notifiers, so we can stop polling
- * And hide the UI as well
- */
- _shutDownNotifications: function() {
- window.clearInterval(this.interval);
- this.vm.shutdown = true;
- }
- };
-});
diff --git a/package-lock.json b/package-lock.json
index 49af7ef..18c1a45 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -2562,7 +2562,8 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"aproba": {
"version": "1.2.0",
@@ -2977,7 +2978,8 @@
"safe-buffer": {
"version": "5.1.1",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"safer-buffer": {
"version": "2.1.2",
@@ -3033,6 +3035,7 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
+ "optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@@ -3076,12 +3079,14 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"yallist": {
"version": "3.0.2",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
}
}
},
diff --git a/package.json b/package.json
index ae80e29..b391491 100644
--- a/package.json
+++ b/package.json
@@ -6,9 +6,9 @@
"license": "agpl",
"private": true,
"scripts": {
- "dev": "webpack --config js-src/webpack.dev.js",
- "watch": "webpack --progress --watch --config js-src/webpack.dev.js",
- "build": "webpack --progress --hide-modules --config js-src/webpack.prod.js"
+ "dev": "webpack --config src/webpack.dev.js",
+ "watch": "webpack --progress --watch --config src/webpack.dev.js",
+ "build": "webpack --progress --hide-modules --config src/webpack.prod.js"
},
"dependencies": {
"vue": "^2.5.16"
diff --git a/js-src/components/root.vue b/src/App.vue
index 2e3bb8c..5b55cd8 100644
--- a/js-src/components/root.vue
+++ b/src/App.vue
@@ -18,17 +18,24 @@
</template>
<script>
- export default {
- name: "root",
+ import notification from './components/notification';
+ // import axios from 'axios';
- el: '#notifications',
+ export default {
+ name: 'app',
data: function () {
return {
hadNotifications: false,
backgroundFetching: false,
shutdown: false,
- notifications: []
+ notifications: [],
+
+ /** @type {number} */
+ pollInterval: 30000, // milliseconds
+
+ /** @type {number|null} */
+ interval: null,
};
},
@@ -68,11 +75,62 @@
},
onRemove: function(index) {
this.notifications.splice(index, 1);
+ },
+
+ /**
+ * 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.
+ 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() {
+ this.backgroundFetching = true;
+ this._fetch();
+ },
+
+ /**
+ * The app was disabled or has no notifiers, so we can stop polling
+ * And hide the UI as well
+ */
+ _shutDownNotifications: function() {
+ window.clearInterval(this.interval);
+ this.shutdown = true;
}
},
components: {
- 'notification': require('./notification.vue')
+ notification
},
mounted: function () {
@@ -80,6 +138,14 @@
// Bind the button click event
OC.registerMenu($(this.$refs.button), $(this.$refs.container), undefined, true);
+
+ // Initial call to the notification endpoint
+ this._fetch();
+
+ // Setup the background checker
+ if (oc_config.session_keepalive) {
+ this.interval = setInterval(this._backgroundFetch.bind(this), this.pollInterval);
+ }
},
updated: function() {
diff --git a/js-src/components/action.vue b/src/components/action.vue
index 56607c0..c0df6ae 100644
--- a/js-src/components/action.vue
+++ b/src/components/action.vue
@@ -5,7 +5,7 @@
<script>
export default {
- name: "action",
+ name: 'action',
props: [
'label',
diff --git a/js-src/components/notification.vue b/src/components/notification.vue
index 4be15e6..ebfbf77 100644
--- a/js-src/components/notification.vue
+++ b/src/components/notification.vue
@@ -23,10 +23,11 @@
</template>
<script>
- var parser = require('../richObjectStringParser');
+ import action from './action';
+ import parser from '../richObjectStringParser';
export default {
- name: "notification",
+ name: 'notification',
props: [
'notification_id',
@@ -185,7 +186,7 @@
},
components: {
- 'action': require('./action.vue')
+ action
}
}
</script>
diff --git a/js-src/init.js b/src/init.js
index 7730aff..5d77ca7 100644
--- a/js-src/init.js
+++ b/src/init.js
@@ -18,14 +18,17 @@
*
*/
-/* global define, $ */
+import Vue from 'vue';
+import App from './App';
-define(function(require) {
- 'use strict';
+Vue.prototype.t = t;
+Vue.prototype.n = n;
+Vue.prototype.OC = OC;
+Vue.prototype.OCA = OCA;
- var App = require('./app');
+$('form.searchbox').after($('<div>').attr('id', 'notifications'));
- $(function() {
- App.initialise();
- });
+new Vue({
+ el: '#notifications',
+ render: h => h(App)
});
diff --git a/js-src/richObjectStringParser.js b/src/richObjectStringParser.js
index 8cfaa5b..8cfaa5b 100644
--- a/js-src/richObjectStringParser.js
+++ b/src/richObjectStringParser.js
diff --git a/js-src/webpack.common.js b/src/webpack.common.js
index c81f24e..c81f24e 100644
--- a/js-src/webpack.common.js
+++ b/src/webpack.common.js
diff --git a/js-src/webpack.dev.js b/src/webpack.dev.js
index c4d7cf1..c4d7cf1 100644
--- a/js-src/webpack.dev.js
+++ b/src/webpack.dev.js
diff --git a/js-src/webpack.prod.js b/src/webpack.prod.js
index 672b9c6..672b9c6 100644
--- a/js-src/webpack.prod.js
+++ b/src/webpack.prod.js