From b9bd42e1387637977067c59bf824de40f2d8a5d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eudes=20In=C3=A1cio?= Date: Mon, 26 Jun 2023 11:12:57 +0100 Subject: [PATCH] Firebase web notifications added --- package-lock.json | 343 +--------------------- package.json | 4 +- src/app/app.component.ts | 25 +- src/app/app.module.ts | 5 + src/app/modals/profile/profile.page.ts | 127 ++++---- src/app/services/contacts.service.ts | 8 +- src/app/services/notifications.service.ts | 183 ++++++------ src/app/shared/header/header.page.html | 14 +- src/app/shared/header/header.page.ts | 23 +- src/firebase-config.ts | 10 + version/git-version.ts | 14 +- 11 files changed, 253 insertions(+), 503 deletions(-) create mode 100644 src/firebase-config.ts diff --git a/package-lock.json b/package-lock.json index 8aed6fff6..d1f59dcfc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "@angular/cdk": "^11.2.13", "@angular/common": "^12.1.2", "@angular/core": "^12.1.2", - "@angular/fire": "6.1.5", + "@angular/fire": "^6.1.5", "@angular/forms": "~12.1.2", "@angular/localize": "^12.1.2", "@angular/material": "^11.2.13", @@ -126,7 +126,7 @@ "duration": "^0.2.2", "faker": "^5.5.3", "fifo-process-queue": "^1.2.0", - "firebase": "^7.0 || ^8.0", + "firebase": "^8.10.1", "g": "^2.0.1", "global": "^4.4.0", "hammerjs": "^2.0.8", @@ -157,7 +157,6 @@ "pdfjs": "^2.4.6", "pdfjs-dist": "^2.9.359", "puppeteer": "^19.7.1", - "react-redux": "^8.0.7", "rocket.chat.realtime.api.rxjs": "^2.1.1", "rxjs": "~6.6.3", "rxjs-compat": "^6.6.7", @@ -213,7 +212,6 @@ "karma-jasmine": "~4.0.0", "karma-jasmine-html-reporter": "^1.5.0", "protractor": "~7.0.0", - "redux-devtools": "^3.7.0", "ts-node": "~8.3.0", "tslint": "^6.1.3", "typescript": "^4.3.5", @@ -3362,6 +3360,7 @@ }, "node_modules/@babel/runtime": { "version": "7.14.8", + "dev": true, "license": "MIT", "dependencies": { "regenerator-runtime": "^0.13.4" @@ -7833,15 +7832,6 @@ "version": "2.0.40", "license": "MIT" }, - "node_modules/@types/hoist-non-react-statics": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz", - "integrity": "sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA==", - "dependencies": { - "@types/react": "*", - "hoist-non-react-statics": "^3.3.0" - } - }, "node_modules/@types/istanbul-lib-coverage": { "version": "2.0.3", "license": "MIT" @@ -7940,11 +7930,6 @@ "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.2.tgz", "integrity": "sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg==" }, - "node_modules/@types/prop-types": { - "version": "15.7.5", - "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz", - "integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==" - }, "node_modules/@types/puppeteer": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/@types/puppeteer/-/puppeteer-7.0.4.tgz", @@ -7959,21 +7944,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@types/react": { - "version": "18.2.11", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.11.tgz", - "integrity": "sha512-+hsJr9hmwyDecSMQAmX7drgbDpyE+EgSF6t7+5QEBAn1tQK7kl1vWZ4iRf6SjQ8lk7dyEULxUmZOIpN0W5baZA==", - "dependencies": { - "@types/prop-types": "*", - "@types/scheduler": "*", - "csstype": "^3.0.2" - } - }, - "node_modules/@types/scheduler": { - "version": "0.16.3", - "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.3.tgz", - "integrity": "sha512-5cJ8CB4yAx7BH1oMvdU0Jh9lrEXyPkar6F9G/ERswkCuvP4KQZfZkSjcMbAICCpQTN4OuZn8tz0HiKv9TGZgrQ==" - }, "node_modules/@types/selenium-webdriver": { "version": "3.0.19", "dev": true, @@ -8006,11 +7976,6 @@ "version": "2.0.1", "license": "MIT" }, - "node_modules/@types/use-sync-external-store": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/@types/use-sync-external-store/-/use-sync-external-store-0.0.3.tgz", - "integrity": "sha512-EwmlvuaxPNej9+T4v5AuBPJa2x2UOJVdjCtDHgcDqitUeOtjnJKJ+apYjVcAoBEMjKW1VVFGZLUb5+qqa09XFA==" - }, "node_modules/@types/uuid": { "version": "8.3.1", "license": "MIT" @@ -12866,11 +12831,6 @@ "version": "0.3.8", "license": "MIT" }, - "node_modules/csstype": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", - "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==" - }, "node_modules/currently-unhandled": { "version": "0.4.1", "license": "MIT", @@ -15953,19 +15913,6 @@ "minimalistic-crypto-utils": "^1.0.1" } }, - "node_modules/hoist-non-react-statics": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", - "integrity": "sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==", - "dependencies": { - "react-is": "^16.7.0" - } - }, - "node_modules/hoist-non-react-statics/node_modules/react-is": { - "version": "16.13.1", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", - "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" - }, "node_modules/homedir-polyfill": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", @@ -28244,21 +28191,6 @@ "read": "1" } }, - "node_modules/prop-types": { - "version": "15.8.1", - "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", - "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", - "dependencies": { - "loose-envify": "^1.4.0", - "object-assign": "^4.1.1", - "react-is": "^16.13.1" - } - }, - "node_modules/prop-types/node_modules/react-is": { - "version": "16.13.1", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", - "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" - }, "node_modules/properties-parser": { "version": "0.3.1", "dev": true, @@ -29012,71 +28944,10 @@ "rc": "cli.js" } }, - "node_modules/react": { - "version": "16.14.0", - "resolved": "https://registry.npmjs.org/react/-/react-16.14.0.tgz", - "integrity": "sha512-0X2CImDkJGApiAlcf0ODKIneSwBPhqJawOa5wCtKbu7ZECrmS26NvtSILynQ66cgkT/RJ4LidJOc3bUESwmU8g==", - "peer": true, - "dependencies": { - "loose-envify": "^1.1.0", - "object-assign": "^4.1.1", - "prop-types": "^15.6.2" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/react-is": { "version": "17.0.2", "license": "MIT" }, - "node_modules/react-redux": { - "version": "8.0.7", - "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-8.0.7.tgz", - "integrity": "sha512-1vRQuCQI5Y2uNmrMXg81RXKiBHY3jBzvCvNmZF437O/Z9/pZ+ba2uYHbemYXb3g8rjsacBGo+/wmfrQKzMhJsg==", - "dependencies": { - "@babel/runtime": "^7.12.1", - "@types/hoist-non-react-statics": "^3.3.1", - "@types/use-sync-external-store": "^0.0.3", - "hoist-non-react-statics": "^3.3.2", - "react-is": "^18.0.0", - "use-sync-external-store": "^1.0.0" - }, - "peerDependencies": { - "@reduxjs/toolkit": "^1 || ^2.0.0-beta.0", - "@types/react": "^16.8 || ^17.0 || ^18.0", - "@types/react-dom": "^16.8 || ^17.0 || ^18.0", - "react": "^16.8 || ^17.0 || ^18.0", - "react-dom": "^16.8 || ^17.0 || ^18.0", - "react-native": ">=0.59", - "redux": "^4 || ^5.0.0-beta.0" - }, - "peerDependenciesMeta": { - "@reduxjs/toolkit": { - "optional": true - }, - "@types/react": { - "optional": true - }, - "@types/react-dom": { - "optional": true - }, - "react-dom": { - "optional": true - }, - "react-native": { - "optional": true - }, - "redux": { - "optional": true - } - } - }, - "node_modules/react-redux/node_modules/react-is": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", - "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==" - }, "node_modules/read": { "version": "1.0.7", "license": "ISC", @@ -29261,57 +29132,6 @@ "node": "*" } }, - "node_modules/redux": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/redux/-/redux-4.2.1.tgz", - "integrity": "sha512-LAUYz4lc+Do8/g7aeRa8JkyDErK6ekstQaqWQrNRW//MY1TvCEpMtpTWvlQ+FPbWCx+Xixu/6SHt5N0HR+SB4w==", - "devOptional": true, - "peer": true, - "dependencies": { - "@babel/runtime": "^7.9.2" - } - }, - "node_modules/redux-devtools": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/redux-devtools/-/redux-devtools-3.7.0.tgz", - "integrity": "sha512-Lnx3UX7mnJij2Xs+RicPK1GyKkbuodrCKtfYmJsN603wC0mc99W//xCAskGVNmRhIXg4e57m2k1CyX0kVzCsBg==", - "deprecated": "Package moved to @redux-devtools/core.", - "dev": true, - "dependencies": { - "@types/prop-types": "^15.7.3", - "lodash": "^4.17.19", - "prop-types": "^15.7.2", - "redux-devtools-instrument": "^1.10.0" - }, - "peerDependencies": { - "react": "^0.14.9 || ^15.3.0 || ^16.0.0", - "react-redux": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0", - "redux": "^3.5.2 || ^4.0.0" - } - }, - "node_modules/redux-devtools-instrument": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/redux-devtools-instrument/-/redux-devtools-instrument-1.10.0.tgz", - "integrity": "sha512-X8JRBCzX2ADSMp+iiV7YQ8uoTNyEm0VPFPd4T854coz6lvRiBrFSqAr9YAS2n8Kzxx8CJQotR0QF9wsMM+3DvA==", - "deprecated": "Package moved to @redux-devtools/instrument.", - "dev": true, - "dependencies": { - "lodash": "^4.17.19", - "symbol-observable": "^1.2.0" - }, - "peerDependencies": { - "redux": "^3.4.0 || ^4.0.0" - } - }, - "node_modules/redux-devtools-instrument/node_modules/symbol-observable": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz", - "integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/reflect-metadata": { "version": "0.1.13", "license": "Apache-2.0" @@ -39031,14 +38851,6 @@ "node": ">=0.10.0" } }, - "node_modules/use-sync-external-store": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz", - "integrity": "sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==", - "peerDependencies": { - "react": "^16.8.0 || ^17.0.0 || ^18.0.0" - } - }, "node_modules/util": { "version": "0.11.1", "license": "MIT", @@ -42881,6 +42693,7 @@ }, "@babel/runtime": { "version": "7.14.8", + "dev": true, "requires": { "regenerator-runtime": "^0.13.4" } @@ -46260,15 +46073,6 @@ "@types/hammerjs": { "version": "2.0.40" }, - "@types/hoist-non-react-statics": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz", - "integrity": "sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA==", - "requires": { - "@types/react": "*", - "hoist-non-react-statics": "^3.3.0" - } - }, "@types/istanbul-lib-coverage": { "version": "2.0.3" }, @@ -46356,11 +46160,6 @@ "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.2.tgz", "integrity": "sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg==" }, - "@types/prop-types": { - "version": "15.7.5", - "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz", - "integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==" - }, "@types/puppeteer": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/@types/puppeteer/-/puppeteer-7.0.4.tgz", @@ -46373,21 +46172,6 @@ "version": "0.0.32", "dev": true }, - "@types/react": { - "version": "18.2.11", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.11.tgz", - "integrity": "sha512-+hsJr9hmwyDecSMQAmX7drgbDpyE+EgSF6t7+5QEBAn1tQK7kl1vWZ4iRf6SjQ8lk7dyEULxUmZOIpN0W5baZA==", - "requires": { - "@types/prop-types": "*", - "@types/scheduler": "*", - "csstype": "^3.0.2" - } - }, - "@types/scheduler": { - "version": "0.16.3", - "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.3.tgz", - "integrity": "sha512-5cJ8CB4yAx7BH1oMvdU0Jh9lrEXyPkar6F9G/ERswkCuvP4KQZfZkSjcMbAICCpQTN4OuZn8tz0HiKv9TGZgrQ==" - }, "@types/selenium-webdriver": { "version": "3.0.19", "dev": true @@ -46417,11 +46201,6 @@ "@types/stack-utils": { "version": "2.0.1" }, - "@types/use-sync-external-store": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/@types/use-sync-external-store/-/use-sync-external-store-0.0.3.tgz", - "integrity": "sha512-EwmlvuaxPNej9+T4v5AuBPJa2x2UOJVdjCtDHgcDqitUeOtjnJKJ+apYjVcAoBEMjKW1VVFGZLUb5+qqa09XFA==" - }, "@types/uuid": { "version": "8.3.1" }, @@ -49569,11 +49348,6 @@ } } }, - "csstype": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", - "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==" - }, "currently-unhandled": { "version": "0.4.1", "requires": { @@ -51666,21 +51440,6 @@ "minimalistic-crypto-utils": "^1.0.1" } }, - "hoist-non-react-statics": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", - "integrity": "sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==", - "requires": { - "react-is": "^16.7.0" - }, - "dependencies": { - "react-is": { - "version": "16.13.1", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", - "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" - } - } - }, "homedir-polyfill": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", @@ -60167,23 +59926,6 @@ "read": "1" } }, - "prop-types": { - "version": "15.8.1", - "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", - "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", - "requires": { - "loose-envify": "^1.4.0", - "object-assign": "^4.1.1", - "react-is": "^16.13.1" - }, - "dependencies": { - "react-is": { - "version": "16.13.1", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", - "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" - } - } - }, "properties-parser": { "version": "0.3.1", "dev": true, @@ -60679,40 +60421,9 @@ "strip-json-comments": "~2.0.1" } }, - "react": { - "version": "16.14.0", - "resolved": "https://registry.npmjs.org/react/-/react-16.14.0.tgz", - "integrity": "sha512-0X2CImDkJGApiAlcf0ODKIneSwBPhqJawOa5wCtKbu7ZECrmS26NvtSILynQ66cgkT/RJ4LidJOc3bUESwmU8g==", - "peer": true, - "requires": { - "loose-envify": "^1.1.0", - "object-assign": "^4.1.1", - "prop-types": "^15.6.2" - } - }, "react-is": { "version": "17.0.2" }, - "react-redux": { - "version": "8.0.7", - "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-8.0.7.tgz", - "integrity": "sha512-1vRQuCQI5Y2uNmrMXg81RXKiBHY3jBzvCvNmZF437O/Z9/pZ+ba2uYHbemYXb3g8rjsacBGo+/wmfrQKzMhJsg==", - "requires": { - "@babel/runtime": "^7.12.1", - "@types/hoist-non-react-statics": "^3.3.1", - "@types/use-sync-external-store": "^0.0.3", - "hoist-non-react-statics": "^3.3.2", - "react-is": "^18.0.0", - "use-sync-external-store": "^1.0.0" - }, - "dependencies": { - "react-is": { - "version": "18.2.0", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", - "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==" - } - } - }, "read": { "version": "1.0.7", "requires": { @@ -60843,46 +60554,6 @@ } } }, - "redux": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/redux/-/redux-4.2.1.tgz", - "integrity": "sha512-LAUYz4lc+Do8/g7aeRa8JkyDErK6ekstQaqWQrNRW//MY1TvCEpMtpTWvlQ+FPbWCx+Xixu/6SHt5N0HR+SB4w==", - "devOptional": true, - "peer": true, - "requires": { - "@babel/runtime": "^7.9.2" - } - }, - "redux-devtools": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/redux-devtools/-/redux-devtools-3.7.0.tgz", - "integrity": "sha512-Lnx3UX7mnJij2Xs+RicPK1GyKkbuodrCKtfYmJsN603wC0mc99W//xCAskGVNmRhIXg4e57m2k1CyX0kVzCsBg==", - "dev": true, - "requires": { - "@types/prop-types": "^15.7.3", - "lodash": "^4.17.19", - "prop-types": "^15.7.2", - "redux-devtools-instrument": "^1.10.0" - } - }, - "redux-devtools-instrument": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/redux-devtools-instrument/-/redux-devtools-instrument-1.10.0.tgz", - "integrity": "sha512-X8JRBCzX2ADSMp+iiV7YQ8uoTNyEm0VPFPd4T854coz6lvRiBrFSqAr9YAS2n8Kzxx8CJQotR0QF9wsMM+3DvA==", - "dev": true, - "requires": { - "lodash": "^4.17.19", - "symbol-observable": "^1.2.0" - }, - "dependencies": { - "symbol-observable": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz", - "integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==", - "dev": true - } - } - }, "reflect-metadata": { "version": "0.1.13" }, @@ -67417,12 +67088,6 @@ "use": { "version": "3.1.1" }, - "use-sync-external-store": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz", - "integrity": "sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==", - "requires": {} - }, "util": { "version": "0.11.1", "peer": true, diff --git a/package.json b/package.json index ad6c161be..a16107b2c 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@angular/cdk": "^11.2.13", "@angular/common": "^12.1.2", "@angular/core": "^12.1.2", - "@angular/fire": "6.1.5", + "@angular/fire": "^6.1.5", "@angular/forms": "~12.1.2", "@angular/localize": "^12.1.2", "@angular/material": "^11.2.13", @@ -140,7 +140,7 @@ "duration": "^0.2.2", "faker": "^5.5.3", "fifo-process-queue": "^1.2.0", - "firebase": "^7.0 || ^8.0", + "firebase": "^8.10.1", "g": "^2.0.1", "global": "^4.4.0", "hammerjs": "^2.0.8", diff --git a/src/app/app.component.ts b/src/app/app.component.ts index e0f1fcae5..c3bcd745e 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -9,6 +9,7 @@ import { InativityService } from "src/app/services/inativity.service"; import { ThemeService } from 'src/app/services/theme.service'; import { environment } from 'src/environments/environment'; import { Storage } from '@ionic/storage'; +import { AngularFireMessaging } from '@angular/fire/messaging'; const CUSTOM_DATE_FORMATS: NgxMatDateFormats = { parse: { @@ -38,12 +39,34 @@ export class AppComponent { private sqliteservice: SqliteService, private InativityService: InativityService, public ThemeService: ThemeService, - private storage: Storage + private storage: Storage, + /* private afMessaging: AngularFireMessaging, */ ) { this.initializeApp(); this.storage.set('version', environment.version).then(() => {}) + /* this.requestPermission(); + this.receiveMessages(); */ } +/* requestPermission() { + this.afMessaging.requestToken.subscribe( + (token) => { + // Save the token to your server for sending notifications + console.log('Permission granted! Token:', token); + }, + (error) => { + console.error('Permission denied:', error); + } + ); + } + + receiveMessages() { + this.afMessaging.messages.subscribe((message) => { + console.log('Received message:', message); + // Handle the received message, e.g., show a notification + }); + } */ + initializeApp() { this.platform.ready().then(() => { this.statusBar.styleDefault(); diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 0651a6997..50bd6b1bd 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -77,6 +77,9 @@ import * as Sentry from '@sentry/capacitor'; // For automatic instrumentation (highly recommended) import { Integration } from '@sentry/types'; import { BrowserTracing } from '@sentry/tracing'; +import { AngularFireModule } from '@angular/fire'; +import { AngularFireMessagingModule } from '@angular/fire/messaging'; +import { firebaseConfig } from '../firebase-config'; // import { ServiceWorkerModule } from '@angular/service-worker'; // import { AngularFireModule } from '@angular/fire'; @@ -156,6 +159,8 @@ import { FirebaseX } from '@ionic-native/firebase-x/ngx'; */ NgxMatMomentModule, MatSelectModule, MatButtonModule, + AngularFireModule.initializeApp(firebaseConfig), + AngularFireMessagingModule, ], providers: [ diff --git a/src/app/modals/profile/profile.page.ts b/src/app/modals/profile/profile.page.ts index 717e68f48..04f03993b 100644 --- a/src/app/modals/profile/profile.page.ts +++ b/src/app/modals/profile/profile.page.ts @@ -45,31 +45,36 @@ export class ProfilePage implements OnInit { private platform: Platform, private eventTriger: EventTrigger, public ThemeService: ThemeService, + private notificationService: NotificationsService ) { - + router.events.subscribe((val) => { this.isProfileOpen = false this.logoutOut = true }); this.eventTriger.getObservable().subscribe((event) => { - if(event.notification == "recive") { + if (event.notification == "recive") { + this.getNotificationData(); + } else if(event.notification == "deleted") { + console.log('header', event.notification) this.getNotificationData(); } }); + this.notificationService.notificationReceived.subscribe(() => { + this.getNotificationData(); + }); + setTimeout(() => { this.hideImage = true }, 2000) } ngOnInit() { - if (this.platform.is('desktop') || this.platform.is('mobileweb')) { - this.getNotificationData(); - } else { - this.getNotificationData(); - } + + this.getNotificationData(); } @@ -83,32 +88,52 @@ export class ProfilePage implements OnInit { asyncNotification() { } async getNotificationData() { - - //const keyExist = await this.storageservice.keyExist("Notifications") - - //if(keyExist) { - this.storageservice.get("Notifications").then((value) => { - this.DataArray = [] - value.forEach((element, i) => { - let notificationObject; - if (element.data) { - notificationObject = { - index: i, - title: element.title, - Service: element.data.Service, - Object: element.data.Object, - IdObject: element.data.IdObject, - FolderId: element.data.FolderId, - body: element.body, - dateInit: this.getFormatedTime(element.data.dateInit), - dateEnd: this.getFormatedTime(element.data.dateEnd), - Location: element.data.Location, - TypeAgenda: element.data.TypeAgenda, - Role: element.data.Role, - Status: element.data.Status - } - } else { + //const keyExist = await this.storageservice.keyExist("Notifications") + + //if(keyExist) { + await this.storageservice.get("Notifications").then((value) => { + + this.DataArray = [] + value.forEach((element, i) => { + let notificationObject; + if (element.notification) { + + notificationObject = { + index: i, + title: element.notification.title, + Service: element.data.Service, + Object: element.data.Object, + IdObject: element.data.IdObject, + FolderId: element.data.FolderId, + body: element.notification.body, + dateInit: this.getFormatedTime(element.data.dateInit), + dateEnd: this.getFormatedTime(element.data.dateEnd), + Location: element.data.Location, + TypeAgenda: element.data.TypeAgenda, + Role: element.data.Role, + Status: element.data.Status + } + + } else if (element.data) { + notificationObject = { + index: i, + title: element.title, + Service: element.data.Service, + Object: element.data.Object, + IdObject: element.data.IdObject, + FolderId: element.data.FolderId, + body: element.body, + dateInit: this.getFormatedTime(element.data.dateInit), + dateEnd: this.getFormatedTime(element.data.dateEnd), + Location: element.data.Location, + TypeAgenda: element.data.TypeAgenda, + Role: element.data.Role, + Status: element.data.Status + } + + } else { + { notificationObject = { FolderId: element.FolderId, IdObject: element.IdObject, @@ -125,14 +150,15 @@ export class ProfilePage implements OnInit { title: element.title } } - - this.DataArray.push(notificationObject) - }); - this.notificationdata = this.DataArray - }).catch((error) => { - console.error('storage getnotification: ',error) - }) - // } + } + + this.DataArray.push(notificationObject) + }); + this.notificationdata = this.DataArray + }).catch((error) => { + console.error('storage getnotification: ', error) + }) + // } } @@ -198,9 +224,6 @@ export class ProfilePage implements OnInit { // this.notificationservice.tempClearArray(); this.deleteNotification(index); - this.eventTriger.publishSomeData({ - notification: "deleted" - }) @@ -213,8 +236,12 @@ export class ProfilePage implements OnInit { this.storageservice.get("Notifications").then((value) => { + this.eventTriger.publishSomeData({ + notification: "deleted" + }) + }).catch((error) => { - console.error('storage delete notification: ',error) + console.error('storage delete notification: ', error) }) }); @@ -225,14 +252,14 @@ export class ProfilePage implements OnInit { SessionStore.setUrlBeforeInactivity(this.router.url); this.logoutOut == false - if(environment.production) { + if (environment.production) { window.location.pathname = '/auth' } else { const pathBeforeGoOut = window.location.pathname this.router.navigateByUrl('/auth', { replaceUrl: true }); - + setTimeout(() => { - if(this.logoutOut == false || pathBeforeGoOut == window.location.pathname) { + if (this.logoutOut == false || pathBeforeGoOut == window.location.pathname) { window.location.pathname = '/auth' } else { @@ -268,7 +295,7 @@ export class ProfilePage implements OnInit { } - if(this.isProfileOpen == false) { + if (this.isProfileOpen == false) { this.isProfileOpen = true; const modal = await this.modalController.create({ @@ -278,11 +305,11 @@ export class ProfilePage implements OnInit { } }); await modal.present(); - + modal.onDidDismiss().then(() => { this.isProfileOpen = false; }) - + } } diff --git a/src/app/services/contacts.service.ts b/src/app/services/contacts.service.ts index f555d9605..dfee9314c 100644 --- a/src/app/services/contacts.service.ts +++ b/src/app/services/contacts.service.ts @@ -35,11 +35,15 @@ export class ContactsService { } getContacts(namefilter:string): Observable{ - const geturl = environment.apiURL + 'contacts/get'; + /* const geturl = environment.apiURL + 'contacts/get' */; + const geturl = environment.apiURL + 'userauthentication/list' let params = new HttpParams(); + /* params = params.set("namefilter", namefilter); + params = params.set("domain", environment.domain); */ + params = params.set("namefilter", namefilter); - params = params.set("domain", environment.domain); + params = params.set("domain", ""); let options = { headers: this.headers, diff --git a/src/app/services/notifications.service.ts b/src/app/services/notifications.service.ts index 60bbec2e0..698c5f41a 100644 --- a/src/app/services/notifications.service.ts +++ b/src/app/services/notifications.service.ts @@ -1,6 +1,6 @@ /* eslint-disable */ /* tslint:disable */ -import { Injectable, NgZone } from '@angular/core'; +import { EventEmitter, Injectable, NgZone } from '@angular/core'; import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; import { environment } from 'src/environments/environment'; import { StorageService } from 'src/app/services/storage.service'; @@ -14,6 +14,8 @@ import { ActionPerformed, PushNotificationSchema, PushNotifications, Token, } fr import { notificationObject } from '../models/notifications'; import { v4 as uuidv4 } from 'uuid' import { Capacitor } from '@capacitor/core'; +import { AngularFireMessaging } from '@angular/fire/messaging'; +import { Subject } from 'rxjs'; @Injectable({ providedIn: 'root' }) @@ -34,6 +36,7 @@ export class NotificationsService { active = false isPushNotificationsAvailable = Capacitor.isPluginAvailable('PushNotifications'); + notificationReceived: EventEmitter = new EventEmitter(); constructor( private http: HttpClient, @@ -42,44 +45,11 @@ export class NotificationsService { private platform: Platform, private router: Router, private zone: NgZone, - private eventtrigger: EventTrigger,) { + private eventtrigger: EventTrigger, + private afMessaging: AngularFireMessaging,) { } - - // registerCallback({type, funx, id = uuidv4()} : { - // type: notificationObject, - // funx: Function - // id?: string - // }) { - // this.callbacks[id] = { funx, id, type} - // return id; - // } - - - // private async runNotificationCallback(notification) { - - // for (const [key, value] of Object.entries(this.callbacks)) { - // if(value.type == notification.data.Object) { - - // const dontRepeat = await value.funx(notification) - - // if(dontRepeat) { - // delete this.callbacks[key] - // } - - // } else if (value.type == '*') { - // const dontRepeat = await value.funx(notification) - - // if(dontRepeat) { - // delete this.callbacks[key] - // } - // } - - // } - - // } - getTokenByUserIdAndId(user, userID) { // const geturl = environment.apiURL + 'notifications/user/' + userID; @@ -87,46 +57,63 @@ export class NotificationsService { } requestPermissions() { - if (!this.isPushNotificationsAvailable) { - return false - } - PushNotifications.requestPermissions().then(result => { - if (result.receive === 'granted') { - // Register with Apple / Google to receive push via APNS/FCM - PushNotifications.register(); - } else { - // Show some error + if (this.platform.is('mobile')) { + if (!this.isPushNotificationsAvailable) { + return false } - }); + PushNotifications.requestPermissions().then(result => { + if (result.receive === 'granted') { + // Register with Apple / Google to receive push via APNS/FCM + PushNotifications.register(); + } else { + // Show some error + } + }); + } else { + } } getAndpostToken(username) { - if (!this.isPushNotificationsAvailable) { - return false + const geturl = environment.apiURL + 'notifications/token'; + if (this.platform.is('mobile')) { + if (!this.isPushNotificationsAvailable) { + return false + } + + PushNotifications.addListener('registration', + (token: Token) => { + this.postToken(token.value, geturl) + } + ); + } else { + this.afMessaging.requestToken.subscribe( + (token) => { + // Save the token to your server for sending notifications + console.log('Permission granted! Token:', token); + this.postToken(token, geturl) + }, + (error) => { + console.error('Permission denied:', error); + } + ); } - const geturl = environment.apiURL + 'notifications/token'; - PushNotifications.addListener('registration', - (token: Token) => { - const headers = { 'Authorization': SessionStore.user.BasicAuthKey }; - const body = { - UserId: SessionStore.user.UserId, - TokenId: token.value, - Status: 1, - Service: 1 - }; - - this.http.post(`${geturl}`, body, { headers }).subscribe(data => { - this.active = true - - }, (error) => { - - }) - } - ); + } + postToken(token, geturl) { + const headers = { 'Authorization': SessionStore.user.BasicAuthKey }; + const body = { + UserId: SessionStore.user.UserId, + TokenId: token, + Status: 1, + Service: 1 + }; + this.http.post(`${geturl}`, body, { headers }).subscribe(data => { + this.active = true + }, (error) => { + }) } registrationError() { @@ -142,33 +129,47 @@ export class NotificationsService { } onReciveForeground() { - if (!this.isPushNotificationsAvailable) { - return false - } + if(this.platform.is('mobile')) { - PushNotifications.addListener('pushNotificationReceived', - (notification: PushNotificationSchema) => { - this.active = true - - console.log(notification) - this.storageService.get("Notifications").then((store) => { - - store.push(notification) - this.storageService.store("Notifications", store) - }).catch((error) => { - if (!error) { - this.storageService.store("Notifications", [notification]) - } - }) - - // this.runNotificationCallback(notification) - /* this.eventTriger.publish('notificatioRecive') */ - this.eventtrigger.publishSomeData({ - notification: "recive" - }) + if (!this.isPushNotificationsAvailable) { + return false } - ); + PushNotifications.addListener('pushNotificationReceived', + (notification: PushNotificationSchema) => { + this.active = true + + this.storenotification(notification) + this.eventtrigger.publishSomeData({ + notification: "recive" + }) + } + ); + + } else { + this.afMessaging.messages.subscribe((notification) => { + this.storenotification(notification) + this.storenotification(notification) + this.notificationReceived.emit(); + this.eventtrigger.publishSomeData({ + notification: "recive" + }) + // Handle the received message, e.g., show a notification + }); + } + } + + storenotification(notification) { + console.log(notification) + this.storageService.get("Notifications").then((store) => { + + store.push(notification) + this.storageService.store("Notifications", store) + }).catch((error) => { + if (!error) { + this.storageService.store("Notifications", [notification]) + } + }) } onReciveBackground() { diff --git a/src/app/shared/header/header.page.html b/src/app/shared/header/header.page.html index cc8bf0f7f..d588e30b3 100644 --- a/src/app/shared/header/header.page.html +++ b/src/app/shared/header/header.page.html @@ -35,10 +35,16 @@
-
{{notificationLength}}
+ + +
+
+ {{notificationLength}}
+
@@ -156,9 +162,9 @@
-
- {{notificationLength}}
+
+ {{notificationLength}}
diff --git a/src/app/shared/header/header.page.ts b/src/app/shared/header/header.page.ts index daa935228..3c22affb6 100644 --- a/src/app/shared/header/header.page.ts +++ b/src/app/shared/header/header.page.ts @@ -13,6 +13,7 @@ import { PermissionList } from 'src/app/models/permission/permissionList'; import { PermissionService } from 'src/app/services/permission.service'; import { EventTrigger } from 'src/app/services/eventTrigger.service' import { ActiveTabService } from 'src/app/services/active-tab.service'; +import { NotificationsService } from 'src/app/services/notifications.service'; @Component({ selector: 'app-header', @@ -27,7 +28,7 @@ export class HeaderPage implements OnInit { hideSearchBtn: boolean = false; notificationdata: any[] = []; DataArray: Array = []; - notificationLength: 0; + notificationLength: number = 0; SessionStore = SessionStore check: boolean; @@ -36,6 +37,7 @@ export class HeaderPage implements OnInit { canOpenSearch = false showProfileModal = false permissionList = new PermissionList(); + notificationCount: number = 0; constructor( @@ -48,7 +50,8 @@ export class HeaderPage implements OnInit { public RouteService: RouteService, public p: PermissionService, private eventTriger: EventTrigger, - public ActiveTabService: ActiveTabService + public ActiveTabService: ActiveTabService, + private notificationService: NotificationsService ) { this.loggeduser = SessionStore.user; router.events.subscribe((val) => { @@ -60,22 +63,28 @@ export class HeaderPage implements OnInit { this.eventTriger.getObservable().subscribe((event) => { if(event.notification == "recive") { - this.notificationLengthData() + console.log('header', event.notification) + this.notificationLength++ + } else if(event.notification == "deleted") { + console.log('header', event.notification) + this.notificationLength-- } }); + /* this.notificationService.notificationReceived.subscribe(() => { + console.log('header', 'event.notification') + this.notificationLengthData() + }); */ + } async ngOnInit() { this.hideSearch(); - this.update(); + this.notificationLengthData(); } - update() { - - } async notificationLengthData() { await this.storageservice.get("Notifications").then((value) => { diff --git a/src/firebase-config.ts b/src/firebase-config.ts new file mode 100644 index 000000000..7942ce0f0 --- /dev/null +++ b/src/firebase-config.ts @@ -0,0 +1,10 @@ +export const firebaseConfig = { + apiKey: "AIzaSyAAdHmTFznCMerdT99nrewJgISRvtxPqoY", + authDomain: "gabinete-digital-2020.firebaseapp.com", + databaseURL: "https://gabinete-digital-2020.firebaseio.com", + projectId: "gabinete-digital-2020", + storageBucket: "gabinete-digital-2020.appspot.com", + messagingSenderId: "800733765231", + appId: "1:800733765231:web:28e7792ab150006513779a", + measurementId: "G-8QN4BLZ8XK" +}; \ No newline at end of file diff --git a/version/git-version.ts b/version/git-version.ts index 69d0cd7dd..d9cd0f219 100644 --- a/version/git-version.ts +++ b/version/git-version.ts @@ -1,12 +1,12 @@ export let versionData = { - "shortSHA": "20cf57fb0", - "SHA": "20cf57fb0761b5e49652f47cb54ce99962825fb9", - "branch": "feature/gabinete-search", + "shortSHA": "2178ad88c", + "SHA": "2178ad88c25de008983a3e3b39d9c002ec5a5a3e", + "branch": "webNotifications", "lastCommitAuthor": "'Eudes InĂ¡cio'", - "lastCommitTime": "'Tue Jun 13 14:46:33 2023 +0100'", - "lastCommitMessage": "rollback da task", - "lastCommitNumber": "5021", + "lastCommitTime": "'Mon Jun 19 05:36:24 2023 +0100'", + "lastCommitMessage": "Last pull made", + "lastCommitNumber": "5023", "change": "", - "changeStatus": "On branch feature/gabinete-search\nYour branch and 'origin/feature/gabinete-search' have diverged,\nand have 9 and 1 different commits each, respectively.\n (use \"git pull\" to merge the remote branch into yours)\n\nAll conflicts fixed but you are still merging.\n (use \"git commit\" to conclude merge)\n\nChanges to be committed:\n\tmodified: src/app/pages/gabinete-digital/diplomas/diploma/diploma.page.html\n\tmodified: src/app/pages/gabinete-digital/event-list/event-list.page.html\n\tmodified: src/app/pages/gabinete-digital/event-list/event-list.page.ts\n\tmodified: src/app/pages/gabinete-digital/gabinete-digital.page.ts\n\tmodified: src/app/shared/agenda/event-list/event-list.page.html\n\tmodified: src/app/shared/agenda/event-list/event-list.page.ts\n\tmodified: src/app/shared/gabinete-digital/all-processes/all-processes.page.ts\n\tmodified: src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.html\n\tmodified: src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.ts\n\tmodified: src/global.scss", + "changeStatus": "On branch webNotifications\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: package-lock.json\n\tmodified: package.json\n\tmodified: src/app/app.component.ts\n\tmodified: src/app/app.module.ts\n\tmodified: src/app/modals/profile/profile.page.ts\n\tmodified: src/app/services/contacts.service.ts\n\tmodified: src/app/services/notifications.service.ts\n\tmodified: src/app/shared/header/header.page.html\n\tmodified: src/app/shared/header/header.page.ts\n\tnew file: src/firebase-config.ts", "changeAuthor": "eudes.inacio" } \ No newline at end of file