From 85a8296278e6ea268656e6f3c7929fa3aa4c3eed Mon Sep 17 00:00:00 2001 From: konrad Date: Sat, 8 Sep 2018 21:43:16 +0200 Subject: [PATCH] Added better notification handling --- package-lock.json | 21 ++------------------- package.json | 4 ++-- src/App.vue | 14 ++++++++------ src/main.js | 4 ++++ src/message/index.js | 16 ++++++++++++++++ 5 files changed, 32 insertions(+), 27 deletions(-) create mode 100644 src/message/index.js diff --git a/package-lock.json b/package-lock.json index 9421c2244..2fd46b14c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1205,18 +1205,6 @@ "long": "^3.2.0" } }, - "@websanova/vue-dot": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/@websanova/vue-dot/-/vue-dot-0.1.1.tgz", - "integrity": "sha512-xOroPXFJPs8HpGWHgX4yAk7y7Fce+w7omnGUrzowMI9P5JWTFftE1uBXA5Pm+wdp8nK9E1vgV7gWWrh8llohNA==", - "dev": true - }, - "@websanova/vue-env": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/@websanova/vue-env/-/vue-env-0.6.2.tgz", - "integrity": "sha512-ExigiAGJlr7C+U0Y2Y3MmCQ7lJIeMvAjnkzJ1b7X9xBTTUyJQ7M8ReLVZJREZcZx2+NGurpLJE/wJQgBpmn2XQ==", - "dev": true - }, "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -4031,12 +4019,6 @@ "is-obj": "^1.0.0" } }, - "dotenv": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-6.0.0.tgz", - "integrity": "sha512-FlWbnhgjtwD+uNLUGHbMykMOYQaTivdHEmYwAKFjn6GKe/CqY0fNae93ZHTd20snh9ZLr8mTzIL9m0APQ1pjQg==", - "dev": true - }, "duplexer": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", @@ -12491,7 +12473,8 @@ "vue-notification": { "version": "1.3.13", "resolved": "https://registry.npmjs.org/vue-notification/-/vue-notification-1.3.13.tgz", - "integrity": "sha512-GBCpsd+usRF2EhLWl2/rzNWErYnlo+HoKV7G0LL6c/Iy2eo2ikpwVXlDAUepOQaeq0hJoDu0oyUfhKBRL1AosA==" + "integrity": "sha512-GBCpsd+usRF2EhLWl2/rzNWErYnlo+HoKV7G0LL6c/Iy2eo2ikpwVXlDAUepOQaeq0hJoDu0oyUfhKBRL1AosA==", + "dev": true }, "vue-router": { "version": "3.0.1", diff --git a/package.json b/package.json index a20a66b58..b2cad8244 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,7 @@ }, "dependencies": { "bulma": "^0.7.1", - "vue": "^2.5.17", - "vue-notification": "^1.3.13" + "vue": "^2.5.17" }, "devDependencies": { "@vue/cli-plugin-babel": "^3.0.1", @@ -19,6 +18,7 @@ "axios": "^0.18.0", "node-sass": "^4.9.3", "sass-loader": "^7.1.0", + "vue-notification": "^1.3.13", "vue-router": "^3.0.1", "vue-template-compiler": "^2.5.17" }, diff --git a/src/App.vue b/src/App.vue index d5180afb3..0f729a051 100644 --- a/src/App.vue +++ b/src/App.vue @@ -33,12 +33,14 @@ + diff --git a/src/main.js b/src/main.js index 5e315dacb..6e5821343 100644 --- a/src/main.js +++ b/src/main.js @@ -7,6 +7,10 @@ import '../node_modules/bulma/bulma.sass' Vue.config.productionTip = false +// Notifications +import Notifications from 'vue-notification' +Vue.use(Notifications) + // Check the user's auth status when the app starts auth.checkAuth() diff --git a/src/message/index.js b/src/message/index.js new file mode 100644 index 000000000..561242748 --- /dev/null +++ b/src/message/index.js @@ -0,0 +1,16 @@ +export default { + error(e, context) { + // Build the notification text from error response + let err = e.message + if (e.response && e.response.data && e.response.data.message) { + err += '
' + e.response.data.message + } + + // Fire a notification + context.$notify({ + type: 'error', + title: 'Error', + text: err + }) + } +} \ No newline at end of file