diff --git a/package.json b/package.json index 21264d08..f54b867e 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,12 @@ "private": true, "scripts": { "serve": "vue-cli-service serve --mode production", - "dev": "vue-cli-service serve --mode staging", + "watch":"watchify src/serviceWorker.js -o public/service-worker.js -v [ babelify --presets [es2015] ]", + "start:dev": " vue-cli-service serve --mode staging ", + "dev":"npm run watch & npm run start:dev", "setEnv": "cp env.staging .env", - "build": "vue-cli-service build", + "serviceworker":"browserify src/serviceWorker.js -o public/service-worker.js -v [ babelify --presets [es2015] ]", + "build": " npm run serviceworker & vue-cli-service build ", "build-stage": "vue-cli-service build --mode staging", "lint": "vue-cli-service lint", "test:unit": "vue-cli-service test:unit", @@ -18,7 +21,9 @@ "auth0-js": "^9.16.2", "axios": "^0.21.1", "bootstrap-vue": "^2.0.0-rc.11", + "browserify": "^17.0.0", "dayjs": "^1.10.6", + "dotenv": "^16.0.0", "js-file-download": "^0.4.12", "marked": "^3.0.8", "node-fetch": "^2.6.0", @@ -40,20 +45,34 @@ "vuejs-datepicker": "^1.6.2", "vuejs-datetimepicker": "^1.1.13", "vuejs-paginate": "^2.1.0", + "watchify": "^4.0.0", "web3": "^1.6.0" }, "devDependencies": { + "babelify": "^7.2.0", "@vue/cli-plugin-babel": "^3.0.0-rc.10", "@vue/cli-plugin-eslint": "^3.0.0-rc.10", "@vue/cli-plugin-unit-mocha": "^3.0.0-rc.10", "@vue/cli-service": "^3.0.0-rc.10", "@vue/test-utils": "^1.0.0-beta.20", + "babel-preset-es2015": "^6.24.1", "chai": "^4.1.2", "eslint": "^5.16.0", "eslint-loader": "^3.0.2", "eslint-plugin-vue": "^5.2.3", "prettier": "^2.4.1", "vue-template-compiler": "^2.5.16" + }, "browserify": { + "transform": [ + [ + "babelify", + { + "presets": [ + "es2015" + ] + } + ] + ] }, "eslintConfig": { "root": true, diff --git a/public/service-worker.js b/public/service-worker.js new file mode 100644 index 00000000..effa4030 --- /dev/null +++ b/public/service-worker.js @@ -0,0 +1,46 @@ +(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i + + diff --git a/src/config.js b/src/config.js index 26cec117..e27b61a0 100644 --- a/src/config.js +++ b/src/config.js @@ -16,6 +16,7 @@ const config = { auth0ClinetId: process.env.VUE_APP_AUTH0_CLIENT_ID, telegramBotId: process.env.VUE_APP_TELEGRAM_BOT_ID, kommunicateAppId:process.env.VUE_APP_KOMMINICATE_APP_ID, + webpush_public_key:process.env.VUE_APP_WEBPUSH_VAPID_PUBLIC_KEY, eventActionType: { INPUT_TEXT: "INPUT_TEXT", INPUT_NUMBER :"INPUT_NUMBER", diff --git a/src/main.js b/src/main.js index 94853494..726e3417 100644 --- a/src/main.js +++ b/src/main.js @@ -64,3 +64,5 @@ new Vue({ router, render: (h) => h(App), }).$mount("#app"); + + diff --git a/src/serviceWorker.js b/src/serviceWorker.js new file mode 100644 index 00000000..46a87023 --- /dev/null +++ b/src/serviceWorker.js @@ -0,0 +1,53 @@ + + + + + + + +self.addEventListener("install", () => { + + console.log("Service worker installing..."); + // Add a call to skipWaiting here +}); + + +self.addEventListener("activate",()=>{ + console.log("Service Worker actives"); +}) + +self.addEventListener('notificationclick',(e)=>{ + clients.openWindow(e.action) + +}) + +self.addEventListener("push", function (e) { + + + + + // var options = { + // body: body, + // icon: "/mstile-150x150.png", + // image: "", + // vibrate: [100, 50, 100], + // sound: "clip", + // data: { + // dateOfArrival: Date.now(), + // primaryKey: 1, + // }, + // actions: [ + // { + // action: "explore", + // title: "Explore this new world", + + // }, + // { + // action: "close", + // title: "I don't want any of this", + + // }, + // ], + // }; + e.waitUntil(self.registration.showNotification("Push Notification", e.data.json())); +}); diff --git a/src/views/admin/Events.vue b/src/views/admin/Events.vue index ea9baa7e..2afeff19 100644 --- a/src/views/admin/Events.vue +++ b/src/views/admin/Events.vue @@ -736,7 +736,7 @@ export default { let eventActionValue= this.eventActionList; eventActionValue= eventActionValue.filter((x) => (x.type!=="INPUT_TEXT") && (x.type!=="INPUT_NUMBER") && (x.type!=="INPUT_DATE") && (x.type!=="INPUT_HYPERLINK") && (x.type!=="BLOCKCHAIN_ETH") &&(x.type!=="BLOCKCHAIN_MATIC")&&(x.type!=="BLOCKCHAIN_BSC") &&(x.type!=="BLOCKCHAIN_ONE") &&(x.type!=="BLOCKCHAIN_AVAX") - &&(x.type!=="BLOCKCHAIN_REEF") &&(x.type!=="BLOCKCHAIN_TEZ") &&(x.type!=="PRIZE_CARD")) + &&(x.type!=="BLOCKCHAIN_REEF") &&(x.type!=="BLOCKCHAIN_TEZ") &&(x.type!=="PRIZE_CARD")&&(x.type!=="PUSH_NOTIFICATION")) const filteredValueList=checkValue(eventActionValue, 'value'); if(filteredValueList.includes(false)){ return (Messages.EVENTS.CHECK_ALL_VALUE_EMPTY);