diff --git a/angular.json b/angular.json index ff682adde..042364a39 100644 --- a/angular.json +++ b/angular.json @@ -84,7 +84,8 @@ "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { - "browserTarget": "app:build" + "browserTarget": "app:build", + "proxyConfig": "src/proxy.conf.json" }, "configurations": { "production": { diff --git a/ionic.config.json b/ionic.config.json index 2bb709ac7..aab0ef21f 100644 --- a/ionic.config.json +++ b/ionic.config.json @@ -3,5 +3,15 @@ "integrations": { "cordova": {} }, - "type": "angular" + "type": "angular", + "proxies":[ + { + "path": "/mfp/api/imfpush/", + "proxyUrl": "http://gpr-dev-10.gabinetedigital.local:9080/mfp/api/imfpush/" + }, + { + "path": "/mfp/api", + "proxyUrl": "http://gpr-dev-10.gabinetedigital.local:9080/mfp/api" + } + ] } diff --git a/package-lock.json b/package-lock.json index 144fbd3af..624789780 100644 --- a/package-lock.json +++ b/package-lock.json @@ -765,9 +765,9 @@ } }, "make-fetch-happen": { - "version": "9.0.4", - "resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-9.0.4.tgz", - "integrity": "sha512-sQWNKMYqSmbAGXqJg2jZ+PmHh5JAybvwu0xM8mZR/bsTjGiTASj3ldXJV7KFHy1k/IJIBkjxQFoWIVsv9+PQMg==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-9.1.0.tgz", + "integrity": "sha512-+zopwDy7DNknmwPQplem5lAZX/eCOzSvSNNcSKm5eVwTkOBzoktEfXsa9L23J/GIRhxRsaxzkPEhrJEpE2F4Gg==", "dev": true, "requires": { "agentkeepalive": "^4.1.3", @@ -784,16 +784,17 @@ "minipass-pipeline": "^1.2.4", "negotiator": "^0.6.2", "promise-retry": "^2.0.1", - "socks-proxy-agent": "^5.0.0", + "socks-proxy-agent": "^6.0.0", "ssri": "^8.0.0" }, "dependencies": { "cacache": { - "version": "15.2.0", - "resolved": "https://registry.npmjs.org/cacache/-/cacache-15.2.0.tgz", - "integrity": "sha512-uKoJSHmnrqXgthDFx/IU6ED/5xd+NNGe+Bb+kLZy7Ku4P+BaiWEUflAKPZ7eAzsYGcsAGASJZsybXp+quEcHTw==", + "version": "15.3.0", + "resolved": "https://registry.npmjs.org/cacache/-/cacache-15.3.0.tgz", + "integrity": "sha512-VVdYzXEn+cnbXpFgWs5hTT7OScegHVmLhJIR8Ufqk3iFD6A6j5iSX1KuBTfNEv4tdJWE2PzA6IVFtcLC7fN9wQ==", "dev": true, "requires": { + "@npmcli/fs": "^1.0.0", "@npmcli/move-file": "^1.0.1", "chownr": "^2.0.0", "fs-minipass": "^2.0.0", @@ -901,9 +902,9 @@ } }, "read-package-json-fast": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/read-package-json-fast/-/read-package-json-fast-2.0.2.tgz", - "integrity": "sha512-5fyFUyO9B799foVk4n6ylcoAktG/FbE3jwRKxvwaeSrIunaoMc0u81dzXxjeAFKOce7O5KncdfwpGvvs6r5PsQ==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/read-package-json-fast/-/read-package-json-fast-2.0.3.tgz", + "integrity": "sha512-W/BKtbL+dUjTuRL2vziuYhp76s5HZ9qQhd/dKfWIZveD0O40453QNyZhC0e63lqZrAQ4jiOapVoeJ7JrszenQQ==", "dev": true, "requires": { "json-parse-even-better-errors": "^2.3.0", @@ -919,6 +920,27 @@ "lru-cache": "^6.0.0" } }, + "socks": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.6.1.tgz", + "integrity": "sha512-kLQ9N5ucj8uIcxrDwjm0Jsqk06xdpBjGNQtpXy4Q8/QY2k+fY7nZH8CARy+hkbG+SGAovmzzuauCpBlb8FrnBA==", + "dev": true, + "requires": { + "ip": "^1.1.5", + "smart-buffer": "^4.1.0" + } + }, + "socks-proxy-agent": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-6.0.0.tgz", + "integrity": "sha512-FIgZbQWlnjVEQvMkylz64/rUggGtrKstPnx8OZyYFG0tAFR8CSBtpXxSwbFLHyeXFn/cunFL7MpuSOvDSOPo9g==", + "dev": true, + "requires": { + "agent-base": "^6.0.2", + "debug": "^4.3.1", + "socks": "^2.6.1" + } + }, "uuid": { "version": "8.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", @@ -4509,6 +4531,12 @@ } } }, + "@gar/promisify": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.2.tgz", + "integrity": "sha512-82cpyJyKRoQoRi+14ibCeGPu0CwypgtBAdBhq1WfvagpCZNKqwXbKwXllYSMG91DhmG4jt9gN8eP6lGOtozuaw==", + "dev": true + }, "@hapi/hoek": { "version": "9.2.0", "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.2.0.tgz", @@ -4546,11 +4574,18 @@ } }, "@ionic-native/file": { - "version": "5.31.1", - "resolved": "https://registry.npmjs.org/@ionic-native/file/-/file-5.31.1.tgz", - "integrity": "sha512-VWLpI6T/VeqbqIoiGg4Gr380fmEf1RXe0yzq7t9DDwXhpvsyG8uT+T4/BYSxhGalNE0lH2I0nvhKx/YfVuWIOA==", + "version": "5.36.0", + "resolved": "https://registry.npmjs.org/@ionic-native/file/-/file-5.36.0.tgz", + "integrity": "sha512-x7yZ4VdC8n8FNlpRmUFtohNlOZnExvoxZ/6oCvGsV+ec8TJXUsDK/BYi1g+lkPTCUY3EmQIeBOe4PLO6fRJ7qg==", "requires": { "@types/cordova": "^0.0.34" + }, + "dependencies": { + "@types/cordova": { + "version": "0.0.34", + "resolved": "https://registry.npmjs.org/@types/cordova/-/cordova-0.0.34.tgz", + "integrity": "sha1-6nrd907Ow9dimCegw54smt3HPQQ=" + } } }, "@ionic-native/file-path": { @@ -4602,6 +4637,21 @@ "resolved": "https://registry.npmjs.org/@ionic-native/local-notifications/-/local-notifications-4.20.0.tgz", "integrity": "sha512-Ht/0zau8/2+G/bH/okXXhhWB6YrkCNL2QxVJHQ2dophXFGxQPOZAN3CKWhuQSjfbr76fa2nvQXF6jsXLpIR/ng==" }, + "@ionic-native/media": { + "version": "5.36.0", + "resolved": "https://registry.npmjs.org/@ionic-native/media/-/media-5.36.0.tgz", + "integrity": "sha512-WIDCeUlX7bCbse/x2Rr7mAIQJnLo18ZWcmsVgSTTBVS7ObU2DBl4ieqRx6y9PAAV+3tNZqMV4JAWDfMiFokpJg==", + "requires": { + "@types/cordova": "^0.0.34" + }, + "dependencies": { + "@types/cordova": { + "version": "0.0.34", + "resolved": "https://registry.npmjs.org/@types/cordova/-/cordova-0.0.34.tgz", + "integrity": "sha1-6nrd907Ow9dimCegw54smt3HPQQ=" + } + } + }, "@ionic-native/network": { "version": "5.35.0", "resolved": "https://registry.npmjs.org/@ionic-native/network/-/network-5.35.0.tgz", @@ -4641,11 +4691,18 @@ } }, "@ionic-native/sqlite": { - "version": "5.31.1", - "resolved": "https://registry.npmjs.org/@ionic-native/sqlite/-/sqlite-5.31.1.tgz", - "integrity": "sha512-X26n+6mvqyv94ADG67lHOmDj/Ha+ZVbHztwsWzbvBqmnmgck9y+mo8ndC47UKIXRA/8lwoGMyAtJAfE81eT3mg==", + "version": "5.36.0", + "resolved": "https://registry.npmjs.org/@ionic-native/sqlite/-/sqlite-5.36.0.tgz", + "integrity": "sha512-+1nXUqBucwG6MYoEvqKlZecvI3xVGWeKIzdZf8Nc4vQx4JFDUYdluiEw3mfzptCC1S/4l6skBsL8eZLFfpzUKA==", "requires": { "@types/cordova": "^0.0.34" + }, + "dependencies": { + "@types/cordova": { + "version": "0.0.34", + "resolved": "https://registry.npmjs.org/@types/cordova/-/cordova-0.0.34.tgz", + "integrity": "sha1-6nrd907Ow9dimCegw54smt3HPQQ=" + } } }, "@ionic-native/sqlite-porter": { @@ -4673,11 +4730,11 @@ } }, "@ionic/angular": { - "version": "5.5.4", - "resolved": "https://registry.npmjs.org/@ionic/angular/-/angular-5.5.4.tgz", - "integrity": "sha512-Iavv1rvOXNgVpYjy/HVKiPMO0SRx4a8Dwpn9/HHVsxrIbBX+Jr1Fo0UvCTyXOeWBCd6rkKTW1ro5zcWonuv8nw==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ionic/angular/-/angular-5.7.0.tgz", + "integrity": "sha512-oJLpHYRevSmih7IuBVm/VoCHkl8H5V24ZFaPT2XdqixyxcnwmoeQ10ew/Ha0UjgUv8q6T8t5I5c/LUqgwGypjQ==", "requires": { - "@ionic/core": "5.5.4", + "@ionic/core": "5.7.0", "tslib": "^1.9.3" }, "dependencies": { @@ -4689,12 +4746,12 @@ } }, "@ionic/angular-toolkit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@ionic/angular-toolkit/-/angular-toolkit-3.1.0.tgz", - "integrity": "sha512-qaNSFouUVM4TaGwiZMQNft13dFUkZpg2m/rKGVdBoajvTowXSM2sHUNoyzerDqjKZZdeD7mSn8J8bL40mUtyFQ==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@ionic/angular-toolkit/-/angular-toolkit-4.0.0.tgz", + "integrity": "sha512-HGRAGUtc1YSwNZ/Q7X7c2QRyYM2AfsSm++OasPrMo3LnPRVr8OIsUih2ithEU7f3CXrViUR7j/Anu90zGsRgzg==", "dev": true, "requires": { - "@schematics/angular": "^11.1.0", + "@schematics/angular": "^12.0.0", "cheerio": "1.0.0-rc.3", "colorette": "1.1.0", "copy-webpack-plugin": "^6.2.1", @@ -4703,40 +4760,11 @@ "ws": "^7.0.1" }, "dependencies": { - "@angular-devkit/core": { - "version": "11.2.1", - "resolved": "https://registry.npmjs.org/@angular-devkit/core/-/core-11.2.1.tgz", - "integrity": "sha512-CPFQn+NNC4x28X/STwmwmWge127iY9dsKuXeIV8OCSTOQiY4odOTYigP19AglXyK4e9DG/0JKxej/3CeUYx6Tg==", - "dev": true, - "requires": { - "ajv": "6.12.6", - "fast-json-stable-stringify": "2.1.0", - "magic-string": "0.25.7", - "rxjs": "6.6.3", - "source-map": "0.7.3" - } - }, - "@angular-devkit/schematics": { - "version": "11.2.1", - "resolved": "https://registry.npmjs.org/@angular-devkit/schematics/-/schematics-11.2.1.tgz", - "integrity": "sha512-y2tzJq+MMwLdQ6Li+AxjozI51miN5CjK9x9jtFHi+njqJr595WTNQi39RjyHxAue1VFMr8gu1VBnKGKJ1J3vNA==", - "dev": true, - "requires": { - "@angular-devkit/core": "11.2.1", - "ora": "5.3.0", - "rxjs": "6.6.3" - } - }, - "@schematics/angular": { - "version": "11.2.1", - "resolved": "https://registry.npmjs.org/@schematics/angular/-/angular-11.2.1.tgz", - "integrity": "sha512-CnN4bkRwhCp7jc4HGJ9qp/xqLwmnkn/zRf/EEb5tHFC0Bz2WvoNuAoqPRSkgIis3L+Ozahmeb8JxTIdazK1Hog==", - "dev": true, - "requires": { - "@angular-devkit/core": "11.2.1", - "@angular-devkit/schematics": "11.2.1", - "jsonc-parser": "3.0.0" - } + "@types/json-schema": { + "version": "7.0.9", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz", + "integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==", + "dev": true }, "ajv": { "version": "6.12.6", @@ -4750,92 +4778,6 @@ "uri-js": "^4.2.2" } }, - "ansi-regex": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", - "dev": true - }, - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "cacache": { - "version": "15.0.5", - "resolved": "https://registry.npmjs.org/cacache/-/cacache-15.0.5.tgz", - "integrity": "sha512-lloiL22n7sOjEEXdL8NAjTgv9a1u43xICE9/203qonkZUCj5X1UEWIdf2/Y0d6QcCtMzbKQyhrcDbdvlZTs/+A==", - "dev": true, - "requires": { - "@npmcli/move-file": "^1.0.1", - "chownr": "^2.0.0", - "fs-minipass": "^2.0.0", - "glob": "^7.1.4", - "infer-owner": "^1.0.4", - "lru-cache": "^6.0.0", - "minipass": "^3.1.1", - "minipass-collect": "^1.0.2", - "minipass-flush": "^1.0.5", - "minipass-pipeline": "^1.2.2", - "mkdirp": "^1.0.3", - "p-map": "^4.0.0", - "promise-inflight": "^1.0.1", - "rimraf": "^3.0.2", - "ssri": "^8.0.0", - "tar": "^6.0.2", - "unique-filename": "^1.1.1" - } - }, - "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "chownr": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", - "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", - "dev": true - }, - "cli-cursor": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", - "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", - "dev": true, - "requires": { - "restore-cursor": "^3.1.0" - } - }, - "cli-spinners": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.5.0.tgz", - "integrity": "sha512-PC+AmIuK04E6aeSs/pUccSujsTzBhu4HzC2dL+CfJB/Jcc2qTRbEwZQDfIUpt2Xl8BodYBEq8w4fc0kU2I9DjQ==", - "dev": true - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, "colorette": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/colorette/-/colorette-1.1.0.tgz", @@ -4859,63 +4801,6 @@ "schema-utils": "^3.0.0", "serialize-javascript": "^5.0.1", "webpack-sources": "^1.4.3" - }, - "dependencies": { - "glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "requires": { - "is-glob": "^4.0.1" - } - } - } - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "log-symbols": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.0.0.tgz", - "integrity": "sha512-FN8JBzLx6CzeMrB0tg6pqlGU1wCrXW+ZXGH481kfsBqer0hToTIiHdjH4Mq8xJUbvATujKCvaREGWpGUionraA==", - "dev": true, - "requires": { - "chalk": "^4.0.0" - } - }, - "mimic-fn": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", - "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", - "dev": true - }, - "onetime": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", - "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", - "dev": true, - "requires": { - "mimic-fn": "^2.1.0" - } - }, - "ora": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/ora/-/ora-5.3.0.tgz", - "integrity": "sha512-zAKMgGXUim0Jyd6CXK9lraBnD3H5yPGBPPOkC23a2BG6hsm4Zu6OQSjQuEtV0BHDf4aKHcUFvJiGRrFuW3MG8g==", - "dev": true, - "requires": { - "bl": "^4.0.3", - "chalk": "^4.1.0", - "cli-cursor": "^3.1.0", - "cli-spinners": "^2.5.0", - "is-interactive": "^1.0.0", - "log-symbols": "^4.0.0", - "strip-ansi": "^6.0.0", - "wcwidth": "^1.0.1" } }, "p-limit": { @@ -4927,91 +4812,16 @@ "yocto-queue": "^0.1.0" } }, - "p-map": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/p-map/-/p-map-4.0.0.tgz", - "integrity": "sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==", - "dev": true, - "requires": { - "aggregate-error": "^3.0.0" - } - }, - "restore-cursor": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", - "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", - "dev": true, - "requires": { - "onetime": "^5.1.0", - "signal-exit": "^3.0.2" - } - }, - "rxjs": { - "version": "6.6.3", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.3.tgz", - "integrity": "sha512-trsQc+xYYXZ3urjOiJOuCOa5N3jAZ3eiSpQB5hIT8zGlL2QfnHLJ2r7GMkBGuIausdJN1OneaI6gQlsqNHHmZQ==", - "dev": true, - "requires": { - "tslib": "^1.9.0" - }, - "dependencies": { - "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true - } - } - }, "schema-utils": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.0.0.tgz", - "integrity": "sha512-6D82/xSzO094ajanoOSbe4YvXWMfn2A//8Y1+MUqFAJul5Bs+yn36xbK9OtNDcRVSBJ9jjeoXftM6CfztsjOAA==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.1.1.tgz", + "integrity": "sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw==", "dev": true, "requires": { - "@types/json-schema": "^7.0.6", + "@types/json-schema": "^7.0.8", "ajv": "^6.12.5", "ajv-keywords": "^3.5.2" } - }, - "serialize-javascript": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-5.0.1.tgz", - "integrity": "sha512-SaaNal9imEO737H2c05Og0/8LUXG7EnsZyMa8MzkmuHoELfT6txuj0cMqRj6zfPKnmQ1yasR4PCJc8x+M4JSPA==", - "dev": true, - "requires": { - "randombytes": "^2.1.0" - } - }, - "strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.0" - } - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - }, - "tapable": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.0.tgz", - "integrity": "sha512-FBk4IesMV1rBxX2tfiK8RAmogtWn53puLOQlvO8XuwlgxcYbP4mVPS9Ph4aeamSyyVjOl24aYWAuc8U5kCVwMw==", - "dev": true - }, - "tslib": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz", - "integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==", - "dev": true } } }, @@ -5210,19 +5020,13 @@ } }, "@ionic/core": { - "version": "5.5.4", - "resolved": "https://registry.npmjs.org/@ionic/core/-/core-5.5.4.tgz", - "integrity": "sha512-IjbGN8vh3XuJ2ulo3BMlMflcWlUhvEGEexr29JKFvb+O4bWKP5sC2fkqSrswrIstOmv7axm7CeIi2MNRkwYwVA==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ionic/core/-/core-5.7.0.tgz", + "integrity": "sha512-5GunAeZWDhjbo4/gFCYjA4vXP3V+8PEoGa9C+ZEojurpk7IBuAtI36KalCukrHLPoIbfUCywTXoZubfC1S6lHQ==", "requires": { - "ionicons": "^5.1.2", - "tslib": "^1.10.0" - }, - "dependencies": { - "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - } + "@stencil/core": "^2.4.0", + "ionicons": "^5.5.3", + "tslib": "^2.1.0" } }, "@ionic/lab": { @@ -6634,6 +6438,27 @@ "resolved": "https://registry.npmjs.org/@npmcli/ci-detect/-/ci-detect-1.3.0.tgz", "integrity": "sha512-oN3y7FAROHhrAt7Rr7PnTSwrHrZVRTS2ZbyxeQwSSYD0ifwM3YNgQqbaRmjcWoPyq77MjchusjJDspbzMmip1Q==" }, + "@npmcli/fs": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@npmcli/fs/-/fs-1.0.0.tgz", + "integrity": "sha512-8ltnOpRR/oJbOp8vaGUnipOi3bqkcW+sLHFlyXIr08OGHmVJLB1Hn7QtGXbYcpVtH1gAYZTlmDXtE4YV0+AMMQ==", + "dev": true, + "requires": { + "@gar/promisify": "^1.0.1", + "semver": "^7.3.5" + }, + "dependencies": { + "semver": { + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + } + } + }, "@npmcli/git": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/@npmcli/git/-/git-2.0.6.tgz", @@ -6796,9 +6621,9 @@ } }, "@stencil/core": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/@stencil/core/-/core-2.4.0.tgz", - "integrity": "sha512-gU6+Yyd6O0KrCSS/O6j8KKqmRo+/Dcs2fI0+APCpbAWK+nqhwDISpdnSEfGDCLMoAC08XOZCycBRk2K1VGnEcg==" + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/@stencil/core/-/core-2.8.0.tgz", + "integrity": "sha512-WazFGUMnbumg8ePNvej8cIOEcxvuZ0ugKQkkE1xFbDYcl7DgJd62MiG+bIqCcQlIdLEfhjAdoixxlFdJgrgjyA==" }, "@szmarczak/http-timer": { "version": "1.1.2", @@ -6943,6 +6768,14 @@ "resolved": "https://registry.npmjs.org/@types/hammerjs/-/hammerjs-2.0.39.tgz", "integrity": "sha512-lYR2Y/tV2ujpk/WyUc7S0VLI0a9hrtVIN9EwnrNo5oSEJI2cK2/XrgwOQmXLL3eTulOESvh9qP6si9+DWM9cOA==" }, + "@types/http-proxy": { + "version": "1.17.7", + "resolved": "https://registry.npmjs.org/@types/http-proxy/-/http-proxy-1.17.7.tgz", + "integrity": "sha512-9hdj6iXH64tHSLTY+Vt2eYOGzSogC+JQ2H7bdPWkuh7KXP5qLllWx++t+K9Wk556c3dkDdPws/SpMRi0sdCT1w==", + "requires": { + "@types/node": "*" + } + }, "@types/istanbul-lib-coverage": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.3.tgz", @@ -9146,26 +8979,6 @@ "integrity": "sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg==", "dev": true }, - "dom-serializer": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.1.tgz", - "integrity": "sha512-l0IU0pPzLWSHBcieZbpOKgkIn3ts3vAh7ZuFyXNwJxJXk/c4Gwj9xaTJwIDVQCXawWD0qb3IzMGH5rglQaO0XA==", - "dev": true, - "requires": { - "domelementtype": "^1.3.0", - "entities": "^1.1.1" - } - }, - "domutils": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", - "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=", - "dev": true, - "requires": { - "dom-serializer": "0", - "domelementtype": "1" - } - }, "entities": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", @@ -10655,6 +10468,12 @@ "integrity": "sha512-Wq0kCanxubK/JroTW4Mp5soayScnRyiY1eCkbwiz1Dyt1xHOiOW/v+1miqtBHtnZhcXw25TulCKAVJzkNBdmyg==", "dev": true }, + "cordova-plugin-media": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/cordova-plugin-media/-/cordova-plugin-media-5.0.3.tgz", + "integrity": "sha512-UQPFlpk1zL4BY44zGi8RVmYCvcKBCN4Dyf8ovxqGYCC8zR1yhbTRWYDdO9vJdERwbfgWV7+z7FMWiSUfqWm9bQ==", + "dev": true + }, "cordova-plugin-mfp": { "version": "8.0.2021031007", "resolved": "https://registry.npmjs.org/cordova-plugin-mfp/-/cordova-plugin-mfp-8.0.2021031007.tgz", @@ -13796,19 +13615,19 @@ } }, "dom-serializer": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.2.2.tgz", - "integrity": "sha512-2/xPb3ORsQ42nHYiSunXkDjPLBaEj/xTwUO4B7XCZQTRk7EBtTOPaygh10YAAh2OI1Qrp6NWfpAhzswj0ydt9g==", + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.1.tgz", + "integrity": "sha512-l0IU0pPzLWSHBcieZbpOKgkIn3ts3vAh7ZuFyXNwJxJXk/c4Gwj9xaTJwIDVQCXawWD0qb3IzMGH5rglQaO0XA==", "dev": true, "requires": { - "domelementtype": "^2.0.1", - "entities": "^2.0.0" + "domelementtype": "^1.3.0", + "entities": "^1.1.1" }, "dependencies": { - "domelementtype": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.1.0.tgz", - "integrity": "sha512-LsTgx/L5VpD+Q8lmsXSHW2WpA+eBlZ9HPf3erD1IoPF00/3JKHZ3BknUVA2QGDNu69ZNmyFmCWBSO45XjYKC5w==", + "entities": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", + "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==", "dev": true } } @@ -13851,9 +13670,9 @@ } }, "domutils": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.7.0.tgz", - "integrity": "sha512-Lgd2XcJ/NjEw+7tFvfKxOzCYKZsdct5lczQ2ZaQY8Djz7pfAD3Gbp8ySJWtreII/vDlMVmxwa6pHmdxIYgttDg==", + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", + "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=", "dev": true, "requires": { "dom-serializer": "0", @@ -15768,120 +15587,15 @@ } }, "http-proxy-middleware": { - "version": "0.19.1", - "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-0.19.1.tgz", - "integrity": "sha512-yHYTgWMQO8VvwNS22eLLloAkvungsKdKTLO8AJlftYIKNfJr3GK3zK0ZCfzDDGUBttdGc8xFy1mCitvNKQtC3Q==", - "dev": true, + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.1.tgz", + "integrity": "sha512-cfaXRVoZxSed/BmkA7SwBVNI9Kj7HFltaE5rqYOub5kWzWZ+gofV2koVN1j2rMW7pEfSSlCHGJ31xmuyFyfLOg==", "requires": { - "http-proxy": "^1.17.0", - "is-glob": "^4.0.0", - "lodash": "^4.17.11", - "micromatch": "^3.1.10" - }, - "dependencies": { - "braces": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", - "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", - "dev": true, - "requires": { - "arr-flatten": "^1.1.0", - "array-unique": "^0.3.2", - "extend-shallow": "^2.0.1", - "fill-range": "^4.0.0", - "isobject": "^3.0.1", - "repeat-element": "^1.1.2", - "snapdragon": "^0.8.1", - "snapdragon-node": "^2.0.1", - "split-string": "^3.0.2", - "to-regex": "^3.0.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "fill-range": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", - "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", - "dev": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-number": "^3.0.0", - "repeat-string": "^1.6.1", - "to-regex-range": "^2.1.0" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "micromatch": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", - "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", - "dev": true, - "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "braces": "^2.3.1", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "extglob": "^2.0.4", - "fragment-cache": "^0.2.1", - "kind-of": "^6.0.2", - "nanomatch": "^1.2.9", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.2" - } - }, - "to-regex-range": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", - "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", - "dev": true, - "requires": { - "is-number": "^3.0.0", - "repeat-string": "^1.6.1" - } - } + "@types/http-proxy": "^1.17.5", + "http-proxy": "^1.18.1", + "is-glob": "^4.0.1", + "is-plain-obj": "^3.0.0", + "micromatch": "^4.0.2" } }, "http-server": { @@ -16404,11 +16118,11 @@ "integrity": "sha512-ytlaVoz8Olq4k04Vaf/xuhDeoWEbdeCB/9kqTMnZgWfTkA+M87X72V4pyDtKEm1G+nDwxSboBRlYLDj9wtXdIA==" }, "ionicons": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/ionicons/-/ionicons-5.5.0.tgz", - "integrity": "sha512-0DUHTeoIrGSY+KNyNDaQW7v5+mDstjSkjx8dzT925kXKYBDrN3sGs8kUcSSQbTK132U4CbgDEZkn7FDUa9x8Qw==", + "version": "5.5.3", + "resolved": "https://registry.npmjs.org/ionicons/-/ionicons-5.5.3.tgz", + "integrity": "sha512-L71djrMi8pAad66tpwdnO1vwcyluCFvehzxU1PpH1k/HpYBZhZ5IaYhqXipmqUvu5aEbd4cbRguYyI5Fd4bxTw==", "requires": { - "@stencil/core": "^2.4.0" + "@stencil/core": "^2.5.0" } }, "ios-sim": { @@ -16710,6 +16424,11 @@ "path-is-inside": "^1.0.2" } }, + "is-plain-obj": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-3.0.0.tgz", + "integrity": "sha512-gwsOE28k+23GP1B6vFl1oVh/WOzmawBrKwo5Ev6wMKzPkaXaCDIQKzLnvsA42DRlbVTWorkgTKIviAKCWkfUwA==" + }, "is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", @@ -30196,6 +29915,18 @@ } } }, + "http-proxy-middleware": { + "version": "0.19.1", + "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-0.19.1.tgz", + "integrity": "sha512-yHYTgWMQO8VvwNS22eLLloAkvungsKdKTLO8AJlftYIKNfJr3GK3zK0ZCfzDDGUBttdGc8xFy1mCitvNKQtC3Q==", + "dev": true, + "requires": { + "http-proxy": "^1.17.0", + "is-glob": "^4.0.0", + "lodash": "^4.17.11", + "micromatch": "^3.1.10" + } + }, "is-binary-path": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", diff --git a/package.json b/package.json index 3284cc68a..4cf7c423e 100644 --- a/package.json +++ b/package.json @@ -42,21 +42,22 @@ "@fullcalendar/interaction": "^5.3.0", "@ionic-native/camera": "^5.31.1", "@ionic-native/core": "^5.0.7", - "@ionic-native/file": "^5.30.0", + "@ionic-native/file": "^5.36.0", "@ionic-native/file-path": "^5.30.0", "@ionic-native/fingerprint-aio": "^4.20.0", "@ionic-native/http": "^5.31.1", "@ionic-native/in-app-browser": "^5.28.0", "@ionic-native/ionic-webview": "^5.35.0", "@ionic-native/local-notifications": "^4.20.0", + "@ionic-native/media": "^5.36.0", "@ionic-native/network": "^5.35.0", "@ionic-native/screen-orientation": "^5.35.0", "@ionic-native/splash-screen": "^5.31.1", - "@ionic-native/sqlite": "^5.31.1", + "@ionic-native/sqlite": "^5.36.0", "@ionic-native/sqlite-porter": "^5.31.1", "@ionic-native/status-bar": "^5.0.0", "@ionic-native/wheel-selector": "^5.31.1", - "@ionic/angular": "^5.5.4", + "@ionic/angular": "^5.7.0", "@ionic/pwa-elements": "^3.0.2", "@ionic/storage": "^2.3.1", "@logisticinfotech/ionic4-datepicker": "^1.4.4", @@ -82,6 +83,7 @@ "duration": "^0.2.2", "faker": "^5.5.3", "global": "^4.4.0", + "http-proxy-middleware": "^2.0.1", "http-server": "^0.12.3", "ibm-mfp-web-push": "^8.0.2020052213", "ibm-mfp-web-sdk": "^8.0.2021021706", @@ -114,7 +116,7 @@ "@angular/compiler": "^12.1.2", "@angular/compiler-cli": "^12.1.2", "@angular/language-service": "^12.1.2", - "@ionic/angular-toolkit": "^3.0.0", + "@ionic/angular-toolkit": "^4.0.0", "@ionic/lab": "3.1.7", "@types/jasmine": "~3.6.0", "@types/jasminewd2": "~2.0.3", @@ -136,6 +138,7 @@ "cordova-plugin-inappbrowser": "^4.0.0", "cordova-plugin-ionic-keyboard": "^2.2.0", "cordova-plugin-ionic-webview": "^5.0.0", + "cordova-plugin-media": "^5.0.3", "cordova-plugin-mfp": "^8.0.2021031007", "cordova-plugin-mfp-jsonstore": "^8.0.2021062408", "cordova-plugin-mfp-push": "^8.0.2021062405", @@ -180,6 +183,9 @@ "cordova-plugin-network-information": {}, "cordova-plugin-camera": { "ANDROID_SUPPORT_V4_VERSION": "27.+" + }, + "cordova-plugin-media": { + "KEEP_AVAUDIOSESSION_ALWAYS_ACTIVE": "NO" } }, "platforms": [ diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 0f7eca23f..32f783e8d 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -35,6 +35,8 @@ import {MatDatepickerModule} from '@angular/material/datepicker'; import {MAT_DATE_FORMATS, MAT_DATE_LOCALE} from '@angular/material/core'; import { NgxMatDateFormats, NGX_MAT_DATE_FORMATS } from '@angular-material-components/datetime-picker'; import { Network } from '@ionic-native/network/ngx'; +import { Media } from '@ionic-native/media/ngx'; +import { File } from '@ionic-native/file/ngx'; import { @@ -55,6 +57,7 @@ import { fab } from '@fortawesome/free-brands-svg-icons' import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx'; import { PdfViewerModule } from 'ng2-pdf-viewer'; +import { SQLite } from '@ionic-native/sqlite/ngx'; @NgModule({ @@ -106,7 +109,10 @@ import { PdfViewerModule } from 'ng2-pdf-viewer'; WebsocketService, ChatService, ScreenOrientation, - Network + Network, + Media, + File, + SQLite ], bootstrap: [AppComponent], schemas: [CUSTOM_ELEMENTS_SCHEMA] diff --git a/src/app/home/home.page.ts b/src/app/home/home.page.ts index db50b1bbe..ddc6983db 100644 --- a/src/app/home/home.page.ts +++ b/src/app/home/home.page.ts @@ -18,6 +18,8 @@ import { ExpedienteGdStore } from '../store/expedientegd-store.service'; import { InativityService } from '../services/inativity.service'; import { SessionStore } from '../store/session.service'; import { StorageService } from '../services/storage.service'; +import { Media, MediaObject } from '@ionic-native/media/ngx'; +import { File } from '@ionic-native/file/ngx'; import { WebNotificationPopupService } from '../services/notification/web-notification-popup.service'; @Component({ @@ -61,6 +63,8 @@ export class HomePage implements OnInit { synchro = synchro + status:string=""; + audioName:string=""; constructor( private zone: NgZone, private router: Router, @@ -109,10 +113,9 @@ export class HomePage implements OnInit { if (this.platform.is('desktop') || this.platform.is('mobileweb')) { this.webnotification.webconnection(); - this.webnotification.onReceviNotificationWeb(); + this.webnotification.register(); } else { this.mobilefirstConnect(); - this.notificationsService.getAndpostToken2(); this.notificationsService.onReceviNotification(); } @@ -129,6 +132,8 @@ export class HomePage implements OnInit { mobilefirstConnect() { + console.log("Mobileconecct"); + if(window['WLAuthorizationManager']) { if(window['WLAuthorizationManager'].obtainAccessToken) { window['WLAuthorizationManager'].obtainAccessToken("").then((token) => { @@ -173,12 +178,13 @@ export class HomePage implements OnInit { synchro.registerCallback('Online',()=>{ + console.log('Onlineee') }) synchro.registerCallback('Offline',()=>{ - + console.log('Offlineee') }) diff --git a/src/app/modals/profile/profile.page.ts b/src/app/modals/profile/profile.page.ts index a5ea4a616..0c72c221c 100644 --- a/src/app/modals/profile/profile.page.ts +++ b/src/app/modals/profile/profile.page.ts @@ -11,6 +11,7 @@ import { JsonStore } from '../../services/jsonStore.service'; import { StorageService } from '../../services/storage.service'; import { NotificationsService } from '../../services/notifications.service'; import { SessionStore } from 'src/app/store/session.service'; +import { EventTrigger } from '../../services/eventTrigger.service'; @Component({ selector: 'app-profile', @@ -43,6 +44,7 @@ export class ProfilePage implements OnInit { private notificationservice: NotificationsService, private platform: Platform, private notificationsService: NotificationsService, + private eventtrigger: EventTrigger ) { this.loggeduser = authService.ValidatedUser; @@ -200,6 +202,10 @@ export class ProfilePage implements OnInit { this.notificationservice.tempClearArray(); this.deleteNotification(index); + this.eventtrigger.publishSomeData({ + notification: "deleted" + }) + } diff --git a/src/app/pages/agenda/view-event/view-event.page.ts b/src/app/pages/agenda/view-event/view-event.page.ts index 127bfe520..c7da3ac5e 100644 --- a/src/app/pages/agenda/view-event/view-event.page.ts +++ b/src/app/pages/agenda/view-event/view-event.page.ts @@ -1,5 +1,5 @@ import { Component, OnInit } from '@angular/core'; -import { AlertController, ModalController, PopoverController } from '@ionic/angular'; +import { AlertController, ModalController, PopoverController, Platform } from '@ionic/angular'; import { EventBody } from 'src/app/models/eventbody.model'; import { AttachmentsService } from 'src/app/services/attachments.service'; import { EventsService } from 'src/app/services/events.service'; @@ -12,6 +12,8 @@ import { ActivatedRoute, Router } from '@angular/router'; import { ToastService } from 'src/app/services/toast.service'; import { EliminateEventPage } from 'src/app/modals/eliminate-event/eliminate-event.page'; import { Location } from '@angular/common' +import { SqliteService } from 'src/app/services/sqlite.service'; +import { synchro } from '../../../services/socket/synchro.service'; @Component({ selector: 'app-view-event', @@ -42,6 +44,7 @@ export class ViewEventPage implements OnInit { dicIndex = 0; isModal = false header = true + synch = synchro; constructor( private modalController: ModalController, @@ -55,7 +58,11 @@ export class ViewEventPage implements OnInit { private activatedRoute: ActivatedRoute, private router: Router, private toastService: ToastService, - private location: Location + private location: Location, + public platform: Platform, + private sqliteservice: SqliteService + + ) { this.isEventEdited = false; @@ -88,8 +95,29 @@ export class ViewEventPage implements OnInit { ngOnInit() { - this.loadEvent(); + synchro.registerCallback('Online', () => { + this.loadEvent(); + console.log('Onlineee view-event') + }) + + synchro.registerCallback('Offline', () => { + this.platform.ready().then(() => { + this.sqliteservice.getEventById(this.eventId).then((event) => { + this.loadedEvent = event[0]; + console.log("Event ditails local,", event[0]) + }) + console.log('Offlineee') + }) + + }) + + /* this.sqliteservice.getEventById(this.eventId).then((event) => { + this.loadedEvent = event[0]; + console.log("Event ditails local,", event[0]) + }) + this.loadEvent(); */ + window.onresize = (event) => { // if not mobile remove all component @@ -131,6 +159,7 @@ export class ViewEventPage implements OnInit { const loader = this.toastService.loading(); this.eventsService.getEvent(this.eventId).subscribe(res => { this.loadedEvent = res; + this.sqliteservice.addEvent(res); /* this.today = new Date(res.StartDate); this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]); */ loader.remove() @@ -294,4 +323,25 @@ export class ViewEventPage implements OnInit { this.dicIndex = index } + getEventsFromLocalDb() { + console.log("event id details ", this.eventId) + + synchro.registerCallback('Online', () => { + this.loadEvent(); + console.log('Onlineee view-event') + + }) + + synchro.registerCallback('Offline', () => { + this.platform.ready().then(() => { + this.sqliteservice.getEventById(this.eventId).then((event) => { + this.loadedEvent = event[0]; + console.log("Event ditails local,", event[0]) + }) + console.log('Offlineee') + }) + + }) + } + } diff --git a/src/app/pages/chat/messages/messages.page.ts b/src/app/pages/chat/messages/messages.page.ts index 090b34d78..f3d0e5b2d 100644 --- a/src/app/pages/chat/messages/messages.page.ts +++ b/src/app/pages/chat/messages/messages.page.ts @@ -352,6 +352,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { this.chatService.getRoomMessages(roomId).subscribe(async res => { + console.log("Chat message",res) if (res == 502) { diff --git a/src/app/pages/events/events.page.html b/src/app/pages/events/events.page.html index e6e5afaf3..fe5d6fef2 100644 --- a/src/app/pages/events/events.page.html +++ b/src/app/pages/events/events.page.html @@ -43,7 +43,7 @@
-
diff --git a/src/app/pages/events/events.page.ts b/src/app/pages/events/events.page.ts index 8beaab76f..c820daa5d 100644 --- a/src/app/pages/events/events.page.ts +++ b/src/app/pages/events/events.page.ts @@ -12,10 +12,12 @@ import { EventDetailPage } from './event-detail/event-detail.page'; import { ProcessesService } from '../../services/processes.service'; import { DailyWorkTask } from '../../models/dailyworktask.model'; import { LoginUserRespose } from 'src/app/models/user.model'; -import { ToDayEventStorage } from 'src/app/store/to-day-event-storage.service'; +import { ToDayEventStorage } from 'src/app/store/to-day-event-storage.service'; import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx'; import { ExpedienteTaskPipe } from 'src/app/pipes/expediente-task.pipe'; import { ExpedienteGdStore } from 'src/app/store/expedientegd-store.service'; +import { SqliteService } from 'src/app/services/sqlite.service'; +import { synchro } from '../../services/socket/synchro.service'; @Component({ selector: 'app-events', @@ -29,16 +31,16 @@ export class EventsPage implements OnInit { months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"]; days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"]; - customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]); + customDate = this.days[this.today.getDay()] + ", " + this.today.getDate() + " de " + (this.months[this.today.getMonth()]); /* Setting appropriate greeting according to the time */ grettings = ["Bom dia", "Boa tarde", "Boa noite"]; - greetting=''; + greetting = ''; timeDate = this.today.getHours() + ":" + this.today.getMinutes(); /* Set segment variable */ - segment:string; - public profile:string; + segment: string; + public profile: string; currentEvent: any; eventsList: Event[]; @@ -52,14 +54,14 @@ export class EventsPage implements OnInit { combinedEvents: Event[]; customText = false; - totalEvent=0; + totalEvent = 0; currentHoursMinutes: Date | string; showLoader: boolean; - taskslist:DailyWorkTask[] = []; - expedientList:any; - hideSearchBtn: boolean=false; + taskslist: DailyWorkTask[] = []; + expedientList: any; + hideSearchBtn: boolean = false; // shared data toDayEventStorage = ToDayEventStorage @@ -67,43 +69,52 @@ export class EventsPage implements OnInit { pdfSrc = "https://www.tabularium.pt/file-upload/FSovLiyEa8Hqy2iDA/TK-Justificativo.pdf"; + listToPresent expedienteTaskPipe = new ExpedienteTaskPipe() - @Output() openExpedientListPage:EventEmitter = new EventEmitter(); + @Output() openExpedientListPage: EventEmitter = new EventEmitter(); loggeduser: LoginUserRespose; existingScreenOrientation: string; + synch = synchro constructor( private eventService: EventsService, private router: Router, - private storageService:StorageService, + private storageService: StorageService, public activatedRoute: ActivatedRoute, private alertController: AlertService, private authService: AuthService, - private processes:ProcessesService, + private processes: ProcessesService, /* private gabineteService: GabineteDigitalPage, */ - private modalController:ModalController, + private modalController: ModalController, private screenOrientation: ScreenOrientation, public platform: Platform, - ) { - this.existingScreenOrientation = this.screenOrientation.type; - console.log(this.existingScreenOrientation); + private sqliteservice: SqliteService, + ) { + this.existingScreenOrientation = this.screenOrientation.type; + console.log(this.existingScreenOrientation); - this.loggeduser = authService.ValidatedUser; + this.loggeduser = authService.ValidatedUser; - this.prEventList = null; + this.prEventList = null; - this.platform.resize.subscribe(async () => { - //console.log('Resize event detected'); - // console.log('Resize event detected'); + this.platform.resize.subscribe(async () => { + //console.log('Resize event detected'); + // console.log('Resize event detected'); - }); + }); + try { + this.sqliteservice.databaseConn(); + } catch (error) { + console.log("Error creating local database: ", error) } + } + ngOnInit() { this.segment = "Combinada"; @@ -112,7 +123,7 @@ export class EventsPage implements OnInit { this.showGreeting(); this.router.events.forEach((event) => { - if(event instanceof NavigationEnd && event.url == '/home/events') { + if (event instanceof NavigationEnd && event.url == '/home/events') { this.RefreshEvents(); setTimeout(()=>{ this.LoadList(); @@ -121,11 +132,13 @@ export class EventsPage implements OnInit { }); this.hideSearch(); + this.getEventsFromLocalDb(); + //this.checkScreenOrientation(); } - hideSearch(){ - if(this.router.url == '/home/events'){ + hideSearch() { + if (this.router.url == '/home/events') { this.hideSearchBtn = true; } } @@ -141,28 +154,28 @@ export class EventsPage implements OnInit { } // Lock to portrait - lockToPortrait(){ + lockToPortrait() { this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.PORTRAIT); console.log('set'); } - // Lock to landscape - lockToLandscape(){ + // Lock to landscape + lockToLandscape() { this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.LANDSCAPE); } - // Unlock screen orientation - unlockScreenOrientation(){ + // Unlock screen orientation + unlockScreenOrientation() { this.screenOrientation.unlock(); } - checkScreenOrientation(){ - if( window.innerWidth < 701) { + checkScreenOrientation() { + if (window.innerWidth < 701) { this.lockToPortrait(); console.log('was here'); } - else{ + else { this.unlockScreenOrientation(); } } @@ -173,20 +186,24 @@ export class EventsPage implements OnInit { let date = new Date(); date.setMonth(date.getMonth() + 1); - let start = date.getFullYear()+"-"+ date.getMonth()+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+ ":"+date.getSeconds(); - let end = date.getFullYear()+"-"+ date.getMonth()+"-"+date.getDate()+" 23:59:59"; + let start = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds(); + let end = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " 23:59:59"; - if(this.loggeduser.Profile == 'MDGPR') { + if (this.loggeduser.Profile == 'MDGPR') { let mdOficialEvents = await this.eventService.getAllMdOficialEvents(start, end).toPromise(); let mdPessoalEvents = await this.eventService.getAllMdPessoalEvents(start, end).toPromise(); const list = mdOficialEvents.concat(mdPessoalEvents); - + console.log("getAllMdOficialPessoalEvents", list) + this.SqliteAddEvent(list); + this.listToPresent = this.toDayEventStorage.eventsList this.toDayEventStorage.reset(list) - if(this.toDayEventStorage.eventsList.length > 0){ + + + if (this.toDayEventStorage.eventsList.length > 0) { this.currentEvent = this.toDayEventStorage.eventsList[0].Subject; this.currentHoursMinutes = this.toDayEventStorage.eventsList[0].StartDate; } @@ -197,18 +214,20 @@ export class EventsPage implements OnInit { } else if (this.loggeduser.Profile == 'PR') { - let prOficialEvents= await this.eventService.getAllPrOficialEvents(start, end).toPromise(); - let prPessoalEvents= await this.eventService.getAllPrPessoalEvents(start, end).toPromise(); + let prOficialEvents = await this.eventService.getAllPrOficialEvents(start, end).toPromise(); + let prPessoalEvents = await this.eventService.getAllPrPessoalEvents(start, end).toPromise(); const list = prOficialEvents.concat(prPessoalEvents); - + console.log("getAllPrOficialPessoalEvents", list) + this.SqliteAddEvent(list); this.toDayEventStorage.reset(list) - if(this.toDayEventStorage.eventsList.length > 0) { + if (this.toDayEventStorage.eventsList.length > 0) { this.currentEvent = this.toDayEventStorage.eventsList[0].Subject; this.currentHoursMinutes = this.toDayEventStorage.eventsList[0].StartDate; } + this.listToPresent = this.toDayEventStorage.eventsList; this.totalEvent = this.toDayEventStorage.eventsList.length; this.showLoader = false; @@ -284,48 +303,110 @@ export class EventsPage implements OnInit { break; } */ } + SqliteAddEvent(list) { + list.forEach((event) => { + let data = { + EventId: event.EventId, + HasAttachments: event.HasAttachments, + Subject: event.Subject, + Location: event.Location, + CalendarId: event.CalendarId, + CalendarName: event.CalendarName, + StartDate: event.StartDate, + EndDate: event.EndDate, + EventType: "", + Attendees: "", + IsMeeting: "", + IsRecurring: "", + IsAllDayEvent: event.IsAllDayEvent, + AppointmentState: "", + TimeZone: "", + Organizer: "", + Category: "", + EventRecurrence: "", + Attachments: "", + Body: "" + } - showGreeting(){ - if(this.today.getHours() >= 6 && this.today.getHours() < 12){ + if(!event.Organizer){ + this.sqliteservice.addEvent(data); + console.log("Events page add event sqllite") + } + }) + + } + + getEventsFromLocalDb() { + + synchro.registerCallback('Online', () => { + this.router.events.forEach((event) => { + if (event instanceof NavigationEnd && event.url == '/home/events') { + this.RefreshEvents(); + this.LoadList(); + } + }); + console.log('Onlineee') + + }) + + + synchro.registerCallback('Offline', () => { + this.platform.ready().then(() => { + this.sqliteservice.getAllEvents().then((event) => { + this.listToPresent = event + this.totalEvent = this.listToPresent.length + this.currentEvent = this.listToPresent[0].Subject + this.currentHoursMinutes = this.listToPresent[0].StartDate + console.log("All events from local,", event) + }) + console.log('Offlineee') + }) + + }) + } + + + + showGreeting() { + if (this.today.getHours() >= 6 && this.today.getHours() < 12) { this.greetting = this.grettings[0]; } - else if(this.today.getHours() >= 12 && this.today.getHours() < 18){ + else if (this.today.getHours() >= 12 && this.today.getHours() < 18) { this.greetting = this.grettings[1]; } - else /* if(this.today.getHours() < 6 && this.today.getHours() >= 18) */{ + else /* if(this.today.getHours() < 6 && this.today.getHours() >= 18) */ { this.greetting = this.grettings[2]; } } - gotTo(){ + gotTo() { this.router.navigate(['/home/events']); } - changeProfile(){ - if(this.profile == "mdgpr"){ + changeProfile() { + if (this.profile == "mdgpr") { console.log('pr'); - this.profile ="pr"; + this.profile = "pr"; this.RefreshEvents(); } - else{ + else { console.log('mdgpr'); - this.profile ="mdgpr"; + this.profile = "mdgpr"; this.RefreshEvents(); } } - logout() - { + logout() { this.authService.ValidatedUser.BasicAuthKey = ""; this.router.navigate(['/home/login']); } - async openEventDetail1(id:any){ + async openEventDetail1(id: any) { console.log(id); const modal = await this.modalController.create({ component: EventDetailPage, - componentProps: { + componentProps: { eventId: id, }, cssClass: 'event-detail', @@ -340,27 +421,27 @@ export class EventsPage implements OnInit { this.processes.GetTaskListExpediente(false).subscribe(result => { console.log("Expediente", result); - const ExpedienteTask = result.map( e=> this.expedienteTaskPipe.transform(e)) + const ExpedienteTask = result.map(e => this.expedienteTaskPipe.transform(e)) this.expedienteGdStore.reset(ExpedienteTask) }); } - sortArrayISODate(myArray: any){ - return myArray.sort(function(a, b) { + sortArrayISODate(myArray: any) { + return myArray.sort(function (a, b) { return (a.CreateDate < b.CreateDate) ? -1 : ((a.CreateDate > b.CreateDate) ? 1 : 0); }); } - goToEvent(eventId:any){ + goToEvent(eventId: any) { this.router.navigate(['/home/events', eventId, 'events']); } - goToExpediente(SerialNumber:any) { - if(this.loggeduser.Profile == 'MDGPR'){ + goToExpediente(SerialNumber: any) { + if (this.loggeduser.Profile == 'MDGPR') { this.router.navigate(['/home/events/expediente', SerialNumber, 'events']); } - else if(this.loggeduser.Profile == 'PR'){ + else if (this.loggeduser.Profile == 'PR') { this.router.navigate(['/home/events/expedientes-pr', SerialNumber, 'events']); } } @@ -370,8 +451,8 @@ export class EventsPage implements OnInit { if( window.innerWidth < 701){ this.router.navigate(['/home/gabinete-digital/expediente']); } - else{ - let navigationExtras: NavigationExtras = { queryParams: {"expedientes": true,} }; + else { + let navigationExtras: NavigationExtras = { queryParams: { "expedientes": true, } }; this.router.navigate(['/home/gabinete-digital'], navigationExtras); } } @@ -379,13 +460,16 @@ export class EventsPage implements OnInit { if( window.innerWidth < 701){ this.router.navigate(['/home/gabinete-digital/expedientes-pr']); } - else{ - let navigationExtras: NavigationExtras = { queryParams: {"expedientes-pr": true,} }; + else { + let navigationExtras: NavigationExtras = { queryParams: { "expedientes-pr": true, } }; this.router.navigate(['/home/gabinete-digital'], navigationExtras); } } } + } + + diff --git a/src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.ts b/src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.ts index 6e05b6c58..467f5c94b 100644 --- a/src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.ts +++ b/src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.ts @@ -12,6 +12,10 @@ import { EditEventToApproveComponent } from 'src/app/shared/gabinete-digital/edi import { ToastService } from 'src/app/services/toast.service'; import { Location } from '@angular/common'; +import { SqliteService } from '../../../../services/sqlite.service'; +import { synchro } from '../../../../services/socket/synchro.service'; +import { Platform } from '@ionic/angular'; + @Component({ selector: 'app-approve-event', templateUrl: './approve-event.page.html', @@ -19,28 +23,30 @@ import { Location } from '@angular/common'; }) export class ApproveEventPage implements OnInit { event: Event; - loadedEvent:any = false - loadedAttachments:any; - customDate:any; - today:any; + loadedEvent: any = false + loadedAttachments: any; + customDate: any; + today: any; show: boolean = false; months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"]; days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"]; - serialNumber:string; - caller:string; - @Input() InstanceId:string; + serialNumber: string; + caller: string; + @Input() InstanceId: string; @Output() approveEventDismiss = new EventEmitter(); @Output() closeEventToApprove = new EventEmitter(); @Output() AproveEventEditEvent = new EventEmitter(); + synch = synchro; + constructor( - private router:Router, + private router: Router, private activatedRoute: ActivatedRoute, private modalController: ModalController, - private processes:ProcessesService, + private processes: ProcessesService, private attachmentsService: AttachmentsService, private popoverController: PopoverController, private menu: MenuController, @@ -49,14 +55,16 @@ export class ApproveEventPage implements OnInit { private animationController: AnimationController, private toastService: ToastService, private location: Location, + private sqliteservice: SqliteService, + private platform: Platform ) { this.activatedRoute.paramMap.subscribe(params => { // console.log(params["params"]); - if(params["params"].serialNumber) { + if (params["params"].serialNumber) { this.serialNumber = params["params"].serialNumber; } - if(params["params"].caller){ + if (params["params"].caller) { this.caller = params["params"].caller; } }); @@ -70,7 +78,7 @@ export class ApproveEventPage implements OnInit { ngOnInit() { console.log(this.serialNumber); console.log(this.caller); - + this.getProcessFromDB(); this.getTask(); } @@ -89,19 +97,97 @@ export class ApproveEventPage implements OnInit { } + addProcessToDB(data) { + this.platform.ready().then(() => { + this.sqliteservice.updateProcess(data); + }); + } + + getProcessFromDB() { + + synchro.registerCallback('Offline', () => { + this.platform.ready().then(() => { + + this.sqliteservice.getProcessById(this.serialNumber).then((process) => { + console.log('event aprove serial', process) + + var doc; + var action = []; + var origi = []; + var wordafi = {}; + if (process[0].Documents === "null" || process[0].Documents === "undefined") { + doc = [] + } else { + doc = JSON.parse(process[0].Documents) + } + + if (process[0].actions === "null" || process[0].actions === "undefined") { + action = [] + } else { + action = JSON.parse(process[0].Documents) + } + + if (process[0].originator === "null" || process[0].originator === "undefined") { + origi = [] + } else { + origi = JSON.parse(process[0].Documents) + } + if (process[0].workflowInstanceDataFields === "null" || process[0].workflowInstanceDataFields === "undefined") { + wordafi = [] + } else { + wordafi = JSON.parse(process[0].workflowInstanceDataFields) + } + + let task = { + "Documents": doc, + "actions": action, + "activityInstanceName": process[0].activityInstanceName, + "formURL": process[0].formURL, + "originator": origi, + "serialNumber": process[0].serialNumber, + "taskStartDate": process[0].taskStartDate, + "totalDocuments": process[0].totalDocuments, + "workflowDisplayName": process[0].workflowDisplayName, + "workflowID": process[0].workflowID, + "workflowInstanceDataFields": wordafi, + "workflowInstanceFolio": process[0].workflowInstanceFolio, + "workflowInstanceID": process[0].workflowInstanceID, + "workflowName": process[0].workflowInstanceID + + } + + this.loadedEvent = task + console.log('offline event',this.loadedEvent); + + this.today = new Date(this.loadedEvent.workflowInstanceDataFields.StartDate); + + this.customDate = this.days[this.today.getDay()] + ", " + this.today.getDate() + " de " + (this.months[this.today.getMonth()]); + + let instanceId = this.loadedEvent.workflowInstanceDataFields.InstanceId; + this.loadedAttachments = this.loadedEvent.Documents; + console.log('Attatara', this.loadedAttachments) + + }) + }) + console.log('Offlineee') + }) + } + async getTask() { this.loadedEvent = await this.processes.GetTask(this.serialNumber).toPromise(); console.log(this.loadedEvent); this.today = new Date(this.loadedEvent.workflowInstanceDataFields.StartDate); - this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]); + this.customDate = this.days[this.today.getDay()] + ", " + this.today.getDate() + " de " + (this.months[this.today.getMonth()]); let instanceId = this.loadedEvent.workflowInstanceDataFields.InstanceId; this.getAttachments(instanceId); + + this.addProcessToDB(this.loadedEvent) } - async approveTask(serialNumber:string) { + async approveTask(serialNumber: string) { let body = { "serialNumber": serialNumber, "action": "Aprovar" } console.log(body); @@ -131,12 +217,12 @@ export class ApproveEventPage implements OnInit { }); */ } - async emendTask(serialNumber:string){ + async emendTask(serialNumber: string) { console.log('Desktop'); const modal = await this.modalController.create({ component: EmendMessageModalPage, - componentProps:{ + componentProps: { }, cssClass: 'emend-message-modal', backdropDismiss: false @@ -145,41 +231,42 @@ export class ApproveEventPage implements OnInit { await modal.present(); modal.onDidDismiss() - .then( async (res) => { - console.log(res.data); + .then(async (res) => { + console.log(res.data); - if(res.data !== ''){ - let body = { "serialNumber": serialNumber, - "action": "Emendar", + if (res.data !== '') { + let body = { + "serialNumber": serialNumber, + "action": "Emendar", "dataFields": { - "ReviewUserComment": res.data, + "ReviewUserComment": res.data, + } } + console.log(body); + + const loader = this.toastService.loading() + + try { + await this.processes.PostTaskAction(body).toPromise(); + this.toastService.successMessage('Pedido enviado'); + this.goBack(); + } catch (error) { + this.toastService.badRequest(); + } finally { + loader.remove() + } + } - console.log(body); - - const loader = this.toastService.loading() - - try { - await this.processes.PostTaskAction(body).toPromise(); - this.toastService.successMessage('Pedido enviado'); - this.goBack(); - } catch (error) { - this.toastService.badRequest(); - } finally { - loader.remove() + else { + //this.alertService.presentAlert('Operação cancelada!'); } - - } - else{ - //this.alertService.presentAlert('Operação cancelada!'); - } - }); + }); //this.openEmendMessageModal(serialNumber); //this.goBack(); } - async rejeitar(serialNumber:string){ + async rejeitar(serialNumber: string) { let body = { "serialNumber": serialNumber, "action": "Rejeitar" } console.log(body); const loader = this.toastService.loading() @@ -195,10 +282,12 @@ export class ApproveEventPage implements OnInit { } } - async getAttachments(instanceId:string) { + async getAttachments(instanceId: string) { try { this.loadedAttachments = await this.attachmentsService.getAttachmentsById(instanceId).toPromise(); + this.sqliteservice.updateUser(JSON.stringify(this.serialNumber),JSON.stringify(this.loadedAttachments)) + console.log('Attatara', this.loadedAttachments) } catch (error) { @@ -206,23 +295,23 @@ export class ApproveEventPage implements OnInit { } - viewDocument(sourceId){ - this.processes.GetDocumentUrl(sourceId, '8').subscribe(res=>{ + viewDocument(sourceId) { + this.processes.GetDocumentUrl(sourceId, '8').subscribe(res => { /* console.log(res); */ - const url: string = res.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1"); - const browser = this.iab.create(url,"_blank"); + const url: string = res.replace("webTRIX.Viewer", "webTRIX.Viewer.Branch1"); + const browser = this.iab.create(url, "_blank"); browser.show(); }); } - async openOptions(ev:any) { + async openOptions(ev: any) { const popover = await this.popoverController.create({ component: EventActionsPopoverPage, cssClass: 'events-options', event: ev, translucent: true, - componentProps:{ + componentProps: { serialNumber: ev.serialNumber, InstanceId: ev.workflowInstanceDataFields.InstanceId, }, @@ -233,10 +322,10 @@ export class ApproveEventPage implements OnInit { openMenu() { this.menu.open(); } - async openEmendMessageModal(serialNumber:string) { + async openEmendMessageModal(serialNumber: string) { const modal = await this.modalController.create({ component: EmendMessageModalPage, - componentProps:{ + componentProps: { }, cssClass: 'emend-message-modal', backdropDismiss: false @@ -244,13 +333,14 @@ export class ApproveEventPage implements OnInit { await modal.present(); - modal.onDidDismiss().then( async (res) => { + modal.onDidDismiss().then(async (res) => { console.log(res.data); - if(res.data !== ''){ - let body = { "serialNumber": serialNumber, - "action": "Emendar", - "dataFields": { + if (res.data !== '') { + let body = { + "serialNumber": serialNumber, + "action": "Emendar", + "dataFields": { "ReviewUserComment": res.data, } } @@ -264,18 +354,18 @@ export class ApproveEventPage implements OnInit { this.goBack(); } catch (error) { this.toastService.badRequest(); - } finally { + } finally { loader.remove() } } - else{ + else { //this.alertService.presentAlert('Operação cancelada!'); } }); } - goToEventsToApprove(){ + goToEventsToApprove() { let navigationExtras: NavigationExtras = { queryParams: { "eventos": true, @@ -290,7 +380,7 @@ export class ApproveEventPage implements OnInit { component: EditEventToApproveComponent, componentProps: { serialNumber: serialNumber, - InstanceId:this.InstanceId + InstanceId: this.InstanceId }, cssClass: 'modal modal-desktop', // backdropDismiss: false diff --git a/src/app/pages/gabinete-digital/event-list/event-list.page.ts b/src/app/pages/gabinete-digital/event-list/event-list.page.ts index 56e95d9c1..0cddeb18c 100644 --- a/src/app/pages/gabinete-digital/event-list/event-list.page.ts +++ b/src/app/pages/gabinete-digital/event-list/event-list.page.ts @@ -8,6 +8,10 @@ import { NavigationStart, Router } from '@angular/router'; import { EventoAprovacaoStore } from 'src/app/store/eventoaprovacao-store.service'; import { Location } from '@angular/common'; +import { SqliteService } from '../../../services/sqlite.service'; +import { synchro } from '../../../services/socket/synchro.service'; +import { Platform } from '@ionic/angular'; + @Component({ selector: 'app-event-list', templateUrl: './event-list.page.html', @@ -29,12 +33,16 @@ export class EventListPage implements OnInit { skeletonLoader = true eventaprovacaostore = EventoAprovacaoStore; + synch = synchro; + constructor( private processes:ProcessesService, private modalController: ModalController, private router: Router, - private location: Location + private location: Location, + private sqliteservice: SqliteService, + private platform: Platform ) { } ngOnInit() { @@ -43,6 +51,9 @@ export class EventListPage implements OnInit { const location = window.location const pathname = location.pathname + location.search + this.getEventToAproveFromDB(); + + this.LoadToApproveEvents() this.router.events.forEach((event) => { @@ -65,6 +76,25 @@ export class EventListPage implements OnInit { } + getEventToAproveFromDB() { + + synchro.registerCallback('Offline', () => { + this.platform.ready().then(() => { + + this.sqliteservice.getListOfEventAprove('Agenda Oficial MDGPR','Agenda Pessoal MDGPR' ).then((event: any[]) => { + this.eventsMDGPRList = event + console.log("All evento to aprove from db ", event) + }) + + this.sqliteservice.getListOfEventAprove('Agenda Oficial PR','Agenda Pessoal PR' ).then((event: any[]) => { + this.eventsPRList = event + console.log("All evento to aprove from db ", event) + }) + }) + console.log('Offlineee') + }) + } + segmentChanged(ev: any) { this.LoadToApproveEvents(); } @@ -78,7 +108,8 @@ export class EventListPage implements OnInit { let mdEventsOficial = await this.processes.GetTasksList('Agenda Oficial MDGPR', false).toPromise(); let mdEventsPessoal = await this.processes.GetTasksList('Agenda Pessoal MDGPR', false).toPromise(); this.eventsMDGPRList = mdEventsOficial.concat(mdEventsPessoal); - console.log(this.eventsMDGPRList); + console.log('Event aprove',this.eventsMDGPRList); + this.eventaprovacaostore.resetmd(this.eventsMDGPRList); } @@ -92,6 +123,10 @@ export class EventListPage implements OnInit { this.skeletonLoader = false } + getEventToaproveFromDB() { + + } + async openApproveModal(eventSerialNumber, event){ const modal = await this.modalController.create({ component: ApproveEventModalPage, diff --git a/src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts b/src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts index 488cc9a8d..c562d7666 100644 --- a/src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts +++ b/src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts @@ -23,6 +23,10 @@ import { ExpedienteService } from 'src/app/Rules/expediente.service'; import { expedienteTask } from 'src/app/models/dailyworktask.model'; import { TaskService } from 'src/app/Rules/task.service'; +import { SqliteService } from 'src/app/services/sqlite.service'; +import { Platform } from '@ionic/angular'; +import { synchro } from 'src/app/services/socket/synchro.service'; + @Component({ selector: 'app-expediente-detail', templateUrl: './expediente-detail.page.html', @@ -49,6 +53,9 @@ export class ExpedienteDetailPage implements OnInit { hideSendToPendentes = true searchDocumentPipe = new SearchDocumentPipe() + synch = synchro + onlinecheck: boolean; + constructor( private processes: ProcessesService, private iab: InAppBrowser, @@ -63,7 +70,9 @@ export class ExpedienteDetailPage implements OnInit { private attachmentsService: AttachmentsService, public p: PermissionService, private taskService: TaskService, - private expedienteService: ExpedienteService + private expedienteService: ExpedienteService, + public platform: Platform, + private sqliteservice: SqliteService, ) { this.activatedRoute.paramMap.subscribe(params => { if(params["params"].SerialNumber) { @@ -76,7 +85,10 @@ export class ExpedienteDetailPage implements OnInit { } ngOnInit() { - this.LoadTaskDetail(this.serialNumber); + this.getFromDB(); + if(this.onlinecheck) { + this.LoadTaskDetail(this.serialNumber); + } } @@ -88,6 +100,45 @@ export class ExpedienteDetailPage implements OnInit { this.toastService.presentToast('Não foi possível fazer login"'); } + getFromDB() { + + synchro.registerCallback('Online', () => { + this.onlinecheck = true; + }) + + + synchro.registerCallback('Offline', () => { + this.platform.ready().then(() => { + this.onlinecheck = false; + this.sqliteservice.getProcessById(this.serialNumber).then((process) => { + console.log("expedient ditail", process) + + var workflow = JSON.parse(process[0].workflowInstanceDataFields); + var origina = JSON.parse(process[0].originator) + + this.task = { + "SerialNumber": process[0].serialNumber, + "Folio": workflow.Subject, + "Senders": origina.email, + "CreateDate": momentG(new Date(process[0].taskStartDate),'yyyy-MM-dd HH:mm:ss'), + "DocumentURL": workflow.ViewerRequest, + "Remetente": workflow.Sender, + "Note": workflow.TaskMessage || workflow.Note, + "FolderId": workflow.FolderID, + "FsId": workflow.FsId, + "DocId": workflow.DocID, + "WorkflowName": process[0].workflowDisplayName, + "Status": workflow.Status, + "DispatchNumber": workflow.DispatchNumber, + "AttachmentsProcessLastInstanceID": workflow.AttachmentsProcessLastInstanceID, + "InstanceID": workflow.InstanceID + } + + }) + }) + }) + } + async approve(note:string, documents:any) { let body = { @@ -261,6 +312,7 @@ export class ExpedienteDetailPage implements OnInit { } this.fulltask = res; + this.sqliteservice.updateProcess(res) let thedate = new Date(this.task.CreateDate); this.customDate = this.days[thedate.getDay()]+ ", " + thedate.getDate() +" de " + ( this.months[thedate.getMonth()]); diff --git a/src/app/pages/gabinete-digital/expediente/expediente.page.html b/src/app/pages/gabinete-digital/expediente/expediente.page.html index ee22b60c9..41a32a4cb 100644 --- a/src/app/pages/gabinete-digital/expediente/expediente.page.html +++ b/src/app/pages/gabinete-digital/expediente/expediente.page.html @@ -33,8 +33,8 @@
@@ -65,13 +65,13 @@
Lista vazia
-
+
diff --git a/src/app/pages/gabinete-digital/expediente/expediente.page.ts b/src/app/pages/gabinete-digital/expediente/expediente.page.ts index 385f3b67a..0f2833669 100644 --- a/src/app/pages/gabinete-digital/expediente/expediente.page.ts +++ b/src/app/pages/gabinete-digital/expediente/expediente.page.ts @@ -4,6 +4,9 @@ import { ProcessesService } from 'src/app/services/processes.service'; import { ToastService } from 'src/app/services/toast.service'; import { ExpedienteGdStore } from 'src/app/store/expedientegd-store.service'; import { ExpedienteTaskPipe } from 'src/app/pipes/expediente-task.pipe'; +import { SqliteService } from 'src/app/services/sqlite.service'; +import { Platform } from '@ionic/angular'; +import { synchro } from '../../../services/socket/synchro.service'; @Component({ selector: 'app-expediente', @@ -12,40 +15,49 @@ import { ExpedienteTaskPipe } from 'src/app/pipes/expediente-task.pipe'; }) export class ExpedientePage implements OnInit { - segment:string; + segment: string; skeletonLoader = true //profile:string; - showLoader:boolean; + showLoader: boolean; taskslist = []; - serialNumber:string; + serialNumber: string; expedienteGdStore = ExpedienteGdStore expedienteTaskPipe = new ExpedienteTaskPipe() - + onlinecheck: boolean; + + listToPresent; + synch = synchro constructor( - private processes:ProcessesService, + private processes: ProcessesService, private router: Router, - private toastService: ToastService - ) {} + private toastService: ToastService, + public platform: Platform, + private sqliteservice: SqliteService, + ) { } ngOnInit() { const location = window.location const pathname = location.pathname + location.search - this.LoadList() - - this.router.events.forEach((event) => { - if (event instanceof NavigationStart && event.url.startsWith(pathname)) { - if(window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) { - this.refreshing() - } else { - this.LoadList() + this.getEventsFromLocalDb(); + + if (this.onlinecheck) { + this.LoadList() + + this.router.events.forEach((event) => { + if (event instanceof NavigationStart && event.url.startsWith(pathname)) { + if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) { + this.refreshing() + } else { + this.LoadList() + } } - } - }); - + }); + } + } async LoadList() { @@ -54,17 +66,18 @@ export class ExpedientePage implements OnInit { try { const expediente: object[] = await this.processes.GetTaskListExpediente(false).toPromise() const result = expediente - + this.taskslist = new Array(); let res = result.reverse().filter((data: any) => data.workflowInstanceDataFields.Status == "Active"); res.forEach((element: any) => { - let task = this.expedienteTaskPipe.transform(element) + let task = this.expedienteTaskPipe.transform(element) this.taskslist.push(task); }); - - this.expedienteGdStore.reset(this.taskslist); + + this.listToPresent = this.taskslist + console.log('expediente list', this.listToPresent) } catch (error) { this.toastService.badRequest('Processo não encontrado') @@ -92,9 +105,75 @@ export class ExpedientePage implements OnInit { this.router.navigate(['/home/gabinete-digital']); } - goToExpediente(serialNumber:any){ + goToExpediente(serialNumber: any) { //console.log('ABRE'); - this.router.navigate(['/home/gabinete-digital/expediente',serialNumber,'gabinete-digital']); + this.router.navigate(['/home/gabinete-digital/expediente', serialNumber, 'gabinete-digital']); + } + + SqliteAddExpediente(list) { + list.forEach((expediente) => { + let data = { + serialNumber: expediente.serialNumber, + workflowInstanceFolio: expediente.workflowInstanceFolio, + Documents: expediente.Documents, + actions: expediente.actions, + activityInstanceName: expediente.activityInstanceName, + formURL: expediente.formURL, + originator: expediente.originator, + taskStartDate: expediente.taskStartDate, + totalDocuments: expediente.totalDocuments, + workflowDisplayName: expediente.workflowDisplayName, + workflowID: expediente.workflowID, + workflowInstanceDataFields: expediente.workflowInstanceDataFields, + workflowInstanceID: expediente.workflowInstanceID, + workflowName: expediente.workflowName + } + + this.sqliteservice.addExpediente(data); + }) + + } + + getEventsFromLocalDb() { + + synchro.registerCallback('Online', () => { + this.onlinecheck = true; + }) + + + + synchro.registerCallback('Offline', () => { + this.platform.ready().then(() => { + this.onlinecheck = false; + this.taskslist = new Array(); + this.sqliteservice.getprocessByworkflow("Expediente").then((expediente: any[]) => { + + expediente.forEach((element) => { + + var workflow = JSON.parse(element.workflowInstanceDataFields); + + let exped = { + "CreateDate": element.taskStartDate, + "DocumentsQty": element.totalDocuments, + "Senders": workflow.Senders, + "SerialNumber": element.serialNumber, + "Status": workflow.Status, + "Subject": workflow.Subject, + "WorkflowName": element.workflowDisplayName, + "activityInstanceName": element.activityInstanceName + } + + this.taskslist.push(exped) + + }); + + this.listToPresent = this.taskslist + console.log("All expedientes from local,", expediente) + }) + console.log('Offlineee') + }) + + }) } } diff --git a/src/app/pages/gabinete-digital/gabinete-digital.page.html b/src/app/pages/gabinete-digital/gabinete-digital.page.html index 11bb9a371..ce6a7031a 100644 --- a/src/app/pages/gabinete-digital/gabinete-digital.page.html +++ b/src/app/pages/gabinete-digital/gabinete-digital.page.html @@ -95,7 +95,7 @@

Todas as tarefas

-

{{ totalDocumentStore.count }} Documentos

+

{{ allProcessesList.length }} Documentos

diff --git a/src/app/pages/gabinete-digital/gabinete-digital.page.ts b/src/app/pages/gabinete-digital/gabinete-digital.page.ts index d3414e37c..360af0377 100644 --- a/src/app/pages/gabinete-digital/gabinete-digital.page.ts +++ b/src/app/pages/gabinete-digital/gabinete-digital.page.ts @@ -22,39 +22,43 @@ import { CustomTaskPipe } from 'src/app/pipes/custom-task.pipe'; import { NotificationsService } from 'src/app/services/notifications.service'; import { DespachoService } from 'src/app/Rules/despacho.service'; +import { SqliteService } from '../../services/sqlite.service'; +import { synchro } from '../../services/socket/synchro.service'; +import { Platform } from '@ionic/angular'; + @Component({ selector: 'app-gabinete-digital', templateUrl: './gabinete-digital.page.html', styleUrls: ['./gabinete-digital.page.scss'], }) -export class GabineteDigitalPage implements OnInit, DoCheck { +export class GabineteDigitalPage implements OnInit, DoCheck { - segment:string; - segmentVista:string; + segment: string; + segmentVista: string; showLoader: boolean; - public profile:string; + public profile: string; allProcessesList: any = new Array(); skeletonLoader: boolean; - count_exp_dailywork=0; - count_exp_pr =0 - count_desp_dailywork=0; - count_desp_pending=0; - count_par_dailywork=0; - count_par_pending=0; - count_def_dailywork=0; - count_def_pending=0; - count_exp_pp : string; - count_exp_pd : string; - count_dip_apr : string; - count_dip_as_pr =0 - count_dip_pv=0; + count_exp_dailywork = 0; + count_exp_pr = 0 + count_desp_dailywork = 0; + count_desp_pending = 0; + count_par_dailywork = 0; + count_par_pending = 0; + count_def_dailywork = 0; + count_def_pending = 0; + count_exp_pp: string; + count_exp_pd: string; + count_dip_apr: string; + count_dip_as_pr = 0 + count_dip_pv = 0; count_dip_as = 0; count_de_pr = 0; - count_ev_apr=0; - count_ev_md=0; + count_ev_apr = 0; + count_ev_md = 0; count_total_pending = 0; count_desp_pr_active = 0; count_all_processes = 0; @@ -63,7 +67,7 @@ export class GabineteDigitalPage implements OnInit, DoCheck { desktopComponent: any = { showEventList: false, - showExpediente : false, + showExpediente: false, } showAllProcesses = false; @@ -81,7 +85,7 @@ export class GabineteDigitalPage implements OnInit, DoCheck { showSignedDiploma = false; emptyTextDescription = 'Sem opção selecionada'; - serialNumber:string; + serialNumber: string; loggeduser: LoginUserRespose; mdgpr = "MDGPR"; @@ -102,6 +106,8 @@ export class GabineteDigitalPage implements OnInit, DoCheck { // // pipe + synch = synchro; + customTaskPipe = new CustomTaskPipe() @@ -110,7 +116,7 @@ export class GabineteDigitalPage implements OnInit, DoCheck { @ViewChild(EventsToApprovePage) eventsToApprove: EventsToApprovePage; constructor( - private processesbackend:ProcessesService, + private processesbackend: ProcessesService, private modalController: ModalController, private activatedRoute: ActivatedRoute, private router: Router, @@ -118,26 +124,28 @@ export class GabineteDigitalPage implements OnInit, DoCheck { public p: PermissionService, public waitForDomService: WaitForDomService, private notificationsService: NotificationsService, - private despachoRule: DespachoService - ) { + private despachoRule: DespachoService, + private sqliteservice: SqliteService, + private platform: Platform + ) { - this.loggeduser = authService.ValidatedUser; - window.onresize = (event) => { - // if not mobile remove all component - if( window.innerWidth < 701){ - this.modalController.dismiss(); - this.segmentVista = "listview"; - } - else{ - this.segmentVista = "boxview"; - } - }; - this.checkRoutes(); + this.loggeduser = authService.ValidatedUser; + window.onresize = (event) => { + // if not mobile remove all component + if (window.innerWidth < 701) { + this.modalController.dismiss(); + this.segmentVista = "listview"; + } + else { + this.segmentVista = "boxview"; + } + }; + this.checkRoutes(); - // this.eventoaprovacaostore.resetmd([]) - // this.eventoaprovacaostore.resetpr([]) - + // this.eventoaprovacaostore.resetmd([]) + // this.eventoaprovacaostore.resetpr([]) + } ngDoCheck(): void { @@ -159,22 +167,24 @@ export class GabineteDigitalPage implements OnInit, DoCheck { ngOnInit() { - if( window.innerWidth < 701) { + if (window.innerWidth < 701) { this.segmentVista = "listview"; } - else{ + else { this.segmentVista = "boxview" } const pathname = window.location.pathname + this.getAllProcessFromDB() + this.router.events.forEach((event) => { - if(event instanceof NavigationEnd && event.url == pathname) { + if (event instanceof NavigationEnd && event.url == pathname) { this.waitForDomService.selector({ selector: 'app-gabinete-digital ion-content .aside-wrapper', - callback: ()=> { + callback: () => { this.checkRoutes(); this.LoadCounts(); } @@ -186,7 +196,7 @@ export class GabineteDigitalPage implements OnInit, DoCheck { this.waitForDomService.selector({ selector: 'app-gabinete-digital ion-content .aside-wrapper', - callback: ()=> { + callback: () => { this.loadAllProcesses(); } }) @@ -194,16 +204,17 @@ export class GabineteDigitalPage implements OnInit, DoCheck { } async loadAllProcesses() { - let allProcessesList = await this.processesbackend.GetTasksList("", false).toPromise(); + let allProcessesList = await this.processesbackend.GetTasksList("", false).toPromise(); - if(!this.p.userRole(['PR'])) { - allProcessesList = allProcessesList.filter( element => element.activityInstanceName != 'Assinar Diplomas') + if (!this.p.userRole(['PR'])) { + allProcessesList = allProcessesList.filter(element => element.activityInstanceName != 'Assinar Diplomas') } else if (this.p.userRole(['PR'])) { - allProcessesList = allProcessesList.filter( element => element.activityInstanceName != 'Diploma Assinado') + allProcessesList = allProcessesList.filter(element => element.activityInstanceName != 'Diploma Assinado') } console.log(allProcessesList); + this.addProcessToDB(allProcessesList) this.skeletonLoader = true; this.allProcessesList = []; @@ -211,7 +222,7 @@ export class GabineteDigitalPage implements OnInit, DoCheck { allProcessesList.forEach(element => { let date = new Date(element.taskStartDate); date.setMonth(date.getMonth() + 1); - let taskDate = date.getFullYear()+"-"+ date.getMonth()+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+ ":"+date.getSeconds(); + let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds(); let task = { "SerialNumber": element.serialNumber, @@ -230,117 +241,194 @@ export class GabineteDigitalPage implements OnInit, DoCheck { "customDate": this.setFormatDate(new Date(element.workflowInstanceDataFields.StartDate), new Date(element.workflowInstanceDataFields.EndDate), element.workflowInstanceDataFields.IsAllDayEvent), } - this.allProcessesList.push(task); - this.allProcessesList = removeDuplicate( this.allProcessesList) - this.allProcessesList = this.sortArrayISODate(this.allProcessesList).reverse(); + this.allProcessesList.push(task); + this.allProcessesList = removeDuplicate(this.allProcessesList) + this.allProcessesList = this.sortArrayISODate(this.allProcessesList).reverse(); + + this.totalDocumentStore.resetCount(this.allProcessesList.length) - this.totalDocumentStore.resetCount( this.allProcessesList.length) }); this.skeletonLoader = false; } - sortArrayISODate(myArray: any){ - return myArray.sort(function(a, b) { + addProcessToDB(data) { + this.platform.ready().then(() => { + data.forEach(element => { + + let process = { + "serialNumber": element.serialNumber, + "workflowInstanceFolio": element.workflowInstanceFolio, + "Documents": element.Documents, + "actions": element.actions, + "activityInstanceName": element.activityInstanceName, + "formURL": element.formURL, + "originator": element.originator, + "taskStartDate": element.taskStartDate, + "totalDocuments": element.totalDocuments, + "workflowDisplayName": element.workflowDisplayName, + "workflowID": element.workflowID, + "workflowInstanceDataFields": element.workflowInstanceDataFields, + "workflowInstanceID": element.workflowInstanceID, + "workflowName": element.workflowName + } + + this.sqliteservice.addProcess(process); + }); + }); + } + + getAllProcessFromDB() { + + synchro.registerCallback('Online', () => { + this.platform.ready().then(() => { + this.loadAllProcesses(); + }) + }) + + synchro.registerCallback('Offline', () => { + this.platform.ready().then(() => { + + this.sqliteservice.getAllProcess().then((allprocess: any[]) => { + allprocess.forEach(element => { + let date = new Date(element.taskStartDate); + date.setMonth(date.getMonth() + 1); + let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds(); + + var workflowInstanceDataFields = JSON.parse(element.workflowInstanceDataFields); + console.log("WORKFLOW all process", workflowInstanceDataFields) + + let task = { + "SerialNumber": element.serialNumber, + "Folio": workflowInstanceDataFields.Subject, + "Senders": workflowInstanceDataFields.Sender, + "CreateDate": taskDate, + "DocumentURL": workflowInstanceDataFields.ViewerRequest, + "Remetente": workflowInstanceDataFields.Remetente, + "DocumentsQty": element.totalDocuments, + "DocId": workflowInstanceDataFields.DispatchDocId, + "FolderID": workflowInstanceDataFields.FolderID, + "WorkflowName": element.workflowDisplayName, + "activityInstanceName": element.activityInstanceName, + "Status": workflowInstanceDataFields.Status, + "Agenda": workflowInstanceDataFields.Agenda, + "customDate": this.setFormatDate(new Date(workflowInstanceDataFields.StartDate), new Date(workflowInstanceDataFields.EndDate), workflowInstanceDataFields.IsAllDayEvent), + } + + this.allProcessesList.push(task); + this.allProcessesList = removeDuplicate(this.allProcessesList) + this.allProcessesList = this.sortArrayISODate(this.allProcessesList).reverse(); + + this.totalDocumentStore.resetCount(this.allProcessesList.length) + + }); + console.log("All process from db ", allprocess) + }) + }) + console.log('Offlineee') + }) + } + + sortArrayISODate(myArray: any) { + return myArray.sort(function (a, b) { return (a.CreateDate < b.CreateDate) ? -1 : ((a.CreateDate > b.CreateDate) ? 1 : 0); }); } - setFormatDate(start:any, end:any, allday:boolean){ + setFormatDate(start: any, end: any, allday: boolean) { let customDate; /* start = new Date(); end= new Date("2021-08-04T18:01:04.753Z"); */ //end = new Date("2021-09-04T18:01:04.753Z"); - const totalSeconds = Math.floor((end - (start))/1000);; - const totalMinutes = Math.floor(totalSeconds/60); - const totalHours = Math.floor(totalMinutes/60); - const totalDays = Math.floor(totalHours/24); + const totalSeconds = Math.floor((end - (start)) / 1000);; + const totalMinutes = Math.floor(totalSeconds / 60); + const totalHours = Math.floor(totalMinutes / 60); + const totalDays = Math.floor(totalHours / 24); - const hours = totalHours - ( totalDays * 24 ); - const minutes = totalMinutes - ( totalDays * 24 * 60 ) - ( hours * 60 ); - const seconds = totalSeconds - ( totalDays * 24 * 60 * 60 ) - ( hours * 60 * 60 ) - ( minutes * 60 ); + const hours = totalHours - (totalDays * 24); + const minutes = totalMinutes - (totalDays * 24 * 60) - (hours * 60); + const seconds = totalSeconds - (totalDays * 24 * 60 * 60) - (hours * 60 * 60) - (minutes * 60); let diffDays = totalDays; let diffMinutes = minutes; - if(totalDays == 0){ - if(allday){ - customDate = this.getCustomDate(start)+", "+this.getCustomHours(start)+" (todo dia)"; + if (totalDays == 0) { + if (allday) { + customDate = this.getCustomDate(start) + ", " + this.getCustomHours(start) + " (todo dia)"; console.log(customDate); return customDate; } - else - { + else { //customDate = this.getCustomDate(start)+","+this.getCustomHours(start)+" ("+minutes+" mins)"; - customDate = this.getCustomDate(start)+", "+this.getCustomHours(start)+" | "+this.getCustomHours(end); + customDate = this.getCustomDate(start) + ", " + this.getCustomHours(start) + " | " + this.getCustomHours(end); return customDate; } } - else{ - customDate = this.getCustomDate(start)+","+this.getCustomHours(start)+ - " (termina:"+ this.getCustomDate(end)+","+this.getCustomHours(end)+")"; + else { + customDate = this.getCustomDate(start) + "," + this.getCustomHours(start) + + " (termina:" + this.getCustomDate(end) + "," + this.getCustomHours(end) + ")"; return customDate; } } - getCustomDate(thedate: Date){ + getCustomDate(thedate: Date) { return thedate.getDate() + "/" + - (thedate.getMonth()+1) + "/" + - thedate.getFullYear(); + (thedate.getMonth() + 1) + "/" + + thedate.getFullYear(); } - getCustomHours(thedate: Date){ + getCustomHours(thedate: Date) { return thedate.getHours() + ":" + - thedate.getMinutes(); + thedate.getMinutes(); } - goToProcess(serialNumber:string, workflowName:string, activityName:string){ - if(workflowName == 'Despacho') { - if(activityName == 'Tarefa de Despacho'){ - this.router.navigate(['/home/gabinete-digital/despachos',serialNumber,'gabinete-digital']); + goToProcess(serialNumber: string, workflowName: string, activityName: string) { + if (workflowName == 'Despacho') { + if (activityName == 'Tarefa de Despacho') { + this.router.navigate(['/home/gabinete-digital/despachos', serialNumber, 'gabinete-digital']); } } - else if(workflowName == 'Despacho do Presidente da República') { - if(activityName == 'Tarefa de Despacho'){ - this.router.navigate(['/home/gabinete-digital/despachos-pr',serialNumber,'gabinete-digital']); + else if (workflowName == 'Despacho do Presidente da República') { + if (activityName == 'Tarefa de Despacho') { + this.router.navigate(['/home/gabinete-digital/despachos-pr', serialNumber, 'gabinete-digital']); } - else if(activityName == 'Revisar Diploma' || activityName == 'Assinar Diploma'){ - this.router.navigate(['/home/gabinete-digital/diplomas',serialNumber,'gabinete-digital']); + else if (activityName == 'Revisar Diploma' || activityName == 'Assinar Diploma') { + this.router.navigate(['/home/gabinete-digital/diplomas', serialNumber, 'gabinete-digital']); } - else if(activityName == 'Diploma Assinado'){ - this.router.navigate(['/home/gabinete-digital/diplomas-assinar',serialNumber,'gabinete-digital']); + else if (activityName == 'Diploma Assinado') { + this.router.navigate(['/home/gabinete-digital/diplomas-assinar', serialNumber, 'gabinete-digital']); } } - else if(workflowName == 'Pedido de Parecer' || workflowName == 'Pedido de Deferimento') { - this.router.navigate(['/home/gabinete-digital/pedidos',serialNumber,'gabinete-digital']); + else if (workflowName == 'Pedido de Parecer' || workflowName == 'Pedido de Deferimento') { + this.router.navigate(['/home/gabinete-digital/pedidos', serialNumber, 'gabinete-digital']); } - else if(workflowName == 'Expediente') { - this.router.navigate(['/home/gabinete-digital/expediente',serialNumber,'gabinete-digital']); + else if (workflowName == 'Expediente') { + this.router.navigate(['/home/gabinete-digital/expediente', serialNumber, 'gabinete-digital']); } - else if(workflowName == 'Expediente' && this.loggeduser.Profile == 'PR') { - this.router.navigate(['/home/gabinete-digital/expedientes-pr',serialNumber,'gabinete-digital']); + else if (workflowName == 'Expediente' && this.loggeduser.Profile == 'PR') { + this.router.navigate(['/home/gabinete-digital/expedientes-pr', serialNumber, 'gabinete-digital']); } else if (workflowName == "Pedido de Parecer do Presidente") { - this.router.navigate(['/home/gabinete-digital/pedidos',serialNumber,'gabinete-digital']); + this.router.navigate(['/home/gabinete-digital/pedidos', serialNumber, 'gabinete-digital']); } /* else if (workflowName == "Expediente") { this.router.navigate(['/home/gabinete-digital/pedidos',serialNumber,'gabinete-digital']); } */ - else if(workflowName == 'Agenda Pessoal PR' || workflowName == 'Agenda Oficial PR' || workflowName == 'Agenda Oficial MDGPR' || workflowName == 'Agenda Pessoal MDGPR') { - this.router.navigate(['/home/gabinete-digital/event-list/approve-event',serialNumber, 'gabinete-digital']); + else if (workflowName == 'Agenda Pessoal PR' || workflowName == 'Agenda Oficial PR' || workflowName == 'Agenda Oficial MDGPR' || workflowName == 'Agenda Pessoal MDGPR') { + this.router.navigate(['/home/gabinete-digital/event-list/approve-event', serialNumber, 'gabinete-digital']); } - else { + else { console.log('cant find page for this task') } } - onSegmentVistaChange(){ + onSegmentVistaChange() { } - checkUser(){ - this.selectedElement='allProcessesTag'; + checkUser() { + this.selectedElement = 'allProcessesTag'; this.showAllProcesses = true; /* switch(this.loggeduser.Profile){ case 'MDGPR': @@ -352,77 +440,77 @@ export class GabineteDigitalPage implements OnInit, DoCheck { } */ } - hideRefreshButton(){ + hideRefreshButton() { window.onresize = (event) => { - if( window.innerWidth < 701) { + if (window.innerWidth < 701) { this.hideRefreshBtn = false; this.hideInMobile = false; this.segmentVista = "listview"; } - else{ + else { this.hideRefreshBtn = true; this.hideInMobile = true; this.segmentVista = "boxview"; } } - if(window.innerWidth < 701){ + if (window.innerWidth < 701) { this.hideRefreshBtn = false; this.hideInMobile = false; this.segmentVista = "listview"; } - else{ + else { this.hideRefreshBtn = true; this.hideInMobile = true; this.segmentVista = "boxview"; } } - checkRoutes(){ + checkRoutes() { this.closeAllDesktopComponents(); - if(this.router.url == '/home/gabinete-digital?processes=true'){ + if (this.router.url == '/home/gabinete-digital?processes=true') { this.openAllProcessesPage(); - this.selectedElement='allProcessesTag'; + this.selectedElement = 'allProcessesTag'; } - if(this.router.url == '/home/gabinete-digital?eventos=true'){ + if (this.router.url == '/home/gabinete-digital?eventos=true') { this.openEventsToApprovePage(); - this.selectedElement='approval'; + this.selectedElement = 'approval'; } - else if(this.router.url == '/home/gabinete-digital?expedientes=true'){ + else if (this.router.url == '/home/gabinete-digital?expedientes=true') { this.openExpedientListPage(); - if(this.loggeduser.Profile == 'MDGPR'){ - this.selectedElement='Correspondence'; + if (this.loggeduser.Profile == 'MDGPR') { + this.selectedElement = 'Correspondence'; } - else{ - this.selectedElement='Expediente Presidente' + else { + this.selectedElement = 'Expediente Presidente' } } - else if(this.router.url == '/home/gabinete-digital?pendentes=true'){ + else if (this.router.url == '/home/gabinete-digital?pendentes=true') { this.openPendentesPage(''); - this.selectedElement='Pending'; + this.selectedElement = 'Pending'; } - else if(this.router.url == '/home/gabinete-digital?despachos=true'){ + else if (this.router.url == '/home/gabinete-digital?despachos=true') { this.openDespachosPage(''); - this.selectedElement='Dispatches'; + this.selectedElement = 'Dispatches'; } - else if(this.router.url == '/home/gabinete-digital?pedidos=true'){ + else if (this.router.url == '/home/gabinete-digital?pedidos=true') { this.openPedidosPage('parecer'); - this.selectedElement='RequestsForOpinion'; + this.selectedElement = 'RequestsForOpinion'; } - else if(this.router.url == '/home/gabinete-digital?expedientespr=true'){ + else if (this.router.url == '/home/gabinete-digital?expedientespr=true') { this.openExpedientesPrPage(); - this.selectedElement='Expediente Presidente' + this.selectedElement = 'Expediente Presidente' } - else if(this.router.url == '/home/gabinete-digital?despachospr=true'){ + else if (this.router.url == '/home/gabinete-digital?despachospr=true') { this.openDespachosPrPage(''); - this.selectedElement='DispatchesPr' + this.selectedElement = 'DispatchesPr' } - else if(this.router.url == '/home/gabinete-digital?diplomas=true'){ + else if (this.router.url == '/home/gabinete-digital?diplomas=true') { this.openDiplomasPage('validar'); - this.selectedElement='DiplomasPorValidar'; + this.selectedElement = 'DiplomasPorValidar'; } - else if(this.router.url == '/home/gabinete-digital?diplomasassinar=true'){ - this. openDiplomasAssinarPage(); - this.selectedElement='DiplomasAssinar'; + else if (this.router.url == '/home/gabinete-digital?diplomasassinar=true') { + this.openDiplomasAssinarPage(); + this.selectedElement = 'DiplomasAssinar'; } else if (this.router.url == '/home/gabinete-digital?parecer=true') { this.openPedidosPage('parecer') @@ -430,7 +518,7 @@ export class GabineteDigitalPage implements OnInit, DoCheck { else if (this.router.url == '/home/gabinete-digital?deferimento=true') { this.openPedidosPage('deferimento') } - else{ + else { this.checkUser(); } } @@ -464,8 +552,8 @@ export class GabineteDigitalPage implements OnInit, DoCheck { this.expedientegbstore.count = expedientes.length - let despachos = await this.despachoRule.getList({updateStore: true}) - if(despachos) { + let despachos = await this.despachoRule.getList({ updateStore: true }) + if (despachos) { this.despachoStore.reset(despachos) } @@ -481,7 +569,7 @@ export class GabineteDigitalPage implements OnInit, DoCheck { this.count_def_dailywork = Object.keys(deferimentos.filter(data => data.workflowInstanceDataFields.Status == "Active")).length; this.pedidosstore.countdeferimento = this.count_def_dailywork; - let pendentes =await this.processesbackend.GetPendingTasks(false).toPromise(); + let pendentes = await this.processesbackend.GetPendingTasks(false).toPromise(); this.count_total_pending = Object.keys(pendentes).length; this.pendentesstore.count = this.count_total_pending; @@ -531,7 +619,7 @@ export class GabineteDigitalPage implements OnInit, DoCheck { this.count_dip_as_pr = Object.keys(diplomasAssinados).length; this.deplomasStore.resetDiplomasAssinadoList(diplomasAssinados) - this.processesbackend.GetToApprovedEvents('Agenda','true').subscribe(res=>{ + this.processesbackend.GetToApprovedEvents('Agenda', 'true').subscribe(res => { this.count_ev_apr = res; }); @@ -547,55 +635,55 @@ export class GabineteDigitalPage implements OnInit, DoCheck { console.log(event); // this.closeAllDesktopComponents(); - /* switch(this.loggeduser.Profile){ - case 'MDGPR': - this.selectedElement='Correspondence'; - this.showExpedients = true; - this.expedientesPage.doRefresh(); - break; - case 'PR': - this.selectedElement='ExpedientesPr'; - this.showExpedientesPr = true; - break; - } */ + /* switch(this.loggeduser.Profile){ + case 'MDGPR': + this.selectedElement='Correspondence'; + this.showExpedients = true; + this.expedientesPage.doRefresh(); + break; + case 'PR': + this.selectedElement='ExpedientesPr'; + this.showExpedientesPr = true; + break; + } */ this.LoadCounts(); //this.refreshExpedientes(); - if(event){ + if (event) { setTimeout(() => { event.target.complete(); }, 2000); } - else{ + else { console.log('null'); } } - selectedElementF(element:string) { + selectedElementF(element: string) { if (window.innerWidth > 701) { - return element == this.selectedElement + return element == this.selectedElement } return false; } openAllProcessesPage() { this.closeAllDesktopComponents(); - let navigationExtras: NavigationExtras = { queryParams: {"processes": true,}}; - if( window.innerWidth < 701) { + let navigationExtras: NavigationExtras = { queryParams: { "processes": true, } }; + if (window.innerWidth < 701) { this.router.navigate(['/home/gabinete-digital']); } else { this.router.navigate(['/home/gabinete-digital'], navigationExtras); this.showAllProcesses = true; - this.selectedElement="allProcessesTag"; + this.selectedElement = "allProcessesTag"; } } openEventsToApprovePage() { this.closeAllDesktopComponents(); - let navigationExtras: NavigationExtras = { queryParams: {"eventos": true,}}; - if( window.innerWidth < 701) { + let navigationExtras: NavigationExtras = { queryParams: { "eventos": true, } }; + if (window.innerWidth < 701) { //this.openEventsToApproveList(profile); this.router.navigate(['/home/gabinete-digital/event-list']); } @@ -608,26 +696,26 @@ export class GabineteDigitalPage implements OnInit, DoCheck { openExpedientListPage() { this.closeAllDesktopComponents(); - switch(this.loggeduser.Profile){ + switch (this.loggeduser.Profile) { case 'MDGPR': - if( window.innerWidth < 701) { + if (window.innerWidth < 701) { //this.openExpedientList(); this.router.navigate(['/home/gabinete-digital/expediente']); } else { - this.selectedElement='Correspondence' - let navigationExtras: NavigationExtras = { queryParams: {"expedientes": true,}}; + this.selectedElement = 'Correspondence' + let navigationExtras: NavigationExtras = { queryParams: { "expedientes": true, } }; this.router.navigate(['/home/gabinete-digital'], navigationExtras); this.showExpedients = true; } break; case 'PR': - if( window.innerWidth < 701) { + if (window.innerWidth < 701) { this.router.navigate(['/home/gabinete-digital/expedientes-pr']); } else { - this.selectedElement='ExpedientesPr' - let navigationExtras: NavigationExtras = { queryParams: {"expedientes": true,}}; + this.selectedElement = 'ExpedientesPr' + let navigationExtras: NavigationExtras = { queryParams: { "expedientes": true, } }; this.router.navigate(['/home/gabinete-digital'], navigationExtras); this.showExpedientesPr = true; } @@ -636,20 +724,20 @@ export class GabineteDigitalPage implements OnInit, DoCheck { } - openPedidosPage(segment:string) { + openPedidosPage(segment: string) { this.closeAllDesktopComponents(); let navigationExtras: NavigationExtras; if (segment == 'deferimento') { - navigationExtras= { queryParams: {"deferimento": true,}}; + navigationExtras = { queryParams: { "deferimento": true, } }; this.segment = 'deferimento' } else if (segment == 'parecer') { - navigationExtras = { queryParams: {"parecer": true,}}; + navigationExtras = { queryParams: { "parecer": true, } }; this.segment = 'parecer' } - if( window.innerWidth < 701) { + if (window.innerWidth < 701) { this.router.navigate(['/home/gabinete-digital/pedidos'], navigationExtras); } else { @@ -659,78 +747,78 @@ export class GabineteDigitalPage implements OnInit, DoCheck { if (segment == 'deferimento') { this.selectedElement = 'RequestForApproval' } else if (segment == 'parecer') { - this.selectedElement='RequestsForOpinion' + this.selectedElement = 'RequestsForOpinion' } } } - openDespachosPage(segment?:string) { + openDespachosPage(segment?: string) { this.closeAllDesktopComponents(); - if( window.innerWidth < 701){ + if (window.innerWidth < 701) { this.router.navigate(['/home/gabinete-digital/despachos']); } - else{ - let navigationExtras: NavigationExtras = {queryParams: {"despachos": true,}}; + else { + let navigationExtras: NavigationExtras = { queryParams: { "despachos": true, } }; this.router.navigate(['/home/gabinete-digital'], navigationExtras); this.showDespachos = true; } } - openDespachosPrPage(segment?:string) { + openDespachosPrPage(segment?: string) { this.closeAllDesktopComponents(); - if( window.innerWidth < 701){ + if (window.innerWidth < 701) { this.router.navigate(['/home/gabinete-digital/despachos-pr']); } - else{ - let navigationExtras: NavigationExtras = {queryParams: {"despachospr": true,}}; + else { + let navigationExtras: NavigationExtras = { queryParams: { "despachospr": true, } }; this.router.navigate(['/home/gabinete-digital'], navigationExtras); this.showDespachosPr = true; } } - openPendentesPage(segment?:string){ + openPendentesPage(segment?: string) { this.closeAllDesktopComponents(); - if( window.innerWidth < 701){ + if (window.innerWidth < 701) { this.router.navigate(['/home/gabinete-digital/pendentes']); } - else{ - let navigationExtras: NavigationExtras = { queryParams: {"pendentes": true,}}; + else { + let navigationExtras: NavigationExtras = { queryParams: { "pendentes": true, } }; this.router.navigate(['/home/gabinete-digital'], navigationExtras); this.showPendentes = true; } } - openExpedientesPrPage(segment?:string){ + openExpedientesPrPage(segment?: string) { this.closeAllDesktopComponents(); - if( window.innerWidth < 701) { + if (window.innerWidth < 701) { this.router.navigate(['/home/gabinete-digital/expedientes-pr']); } else { - this.selectedElement='ExpedientesPr' - let navigationExtras: NavigationExtras = { queryParams: {"expedientespr": true,}}; + this.selectedElement = 'ExpedientesPr' + let navigationExtras: NavigationExtras = { queryParams: { "expedientespr": true, } }; this.router.navigate(['/home/gabinete-digital'], navigationExtras); this.showExpedientesPr = true; } } - openDiplomasPage(segment:string) { + openDiplomasPage(segment: string) { let navigationExtras: NavigationExtras; if (segment == 'validar') { - navigationExtras= { queryParams: {"validar": true,}}; + navigationExtras = { queryParams: { "validar": true, } }; } else if (segment == 'assinados') { - navigationExtras = { queryParams: {"assinados": true,}}; + navigationExtras = { queryParams: { "assinados": true, } }; } this.segment = segment; - if( window.innerWidth < 701){ + if (window.innerWidth < 701) { this.router.navigate(['/home/gabinete-digital/diplomas'], navigationExtras); } - else{ + else { this.closeAllDesktopComponents(); this.segment = segment; - let navigationExtras: NavigationExtras = { queryParams: {"diplomas": true,}}; + let navigationExtras: NavigationExtras = { queryParams: { "diplomas": true, } }; this.router.navigate(['/home/gabinete-digital'], navigationExtras); this.showDiplomas = true; } @@ -738,14 +826,14 @@ export class GabineteDigitalPage implements OnInit, DoCheck { openDiplomasAssinarPage() { this.closeAllDesktopComponents(); - if( window.innerWidth < 701){ - this.router.navigate(['/home/gabinete-digital/diplomas-assinar']); - } - else{ - let navigationExtras: NavigationExtras = { queryParams: {"diplomasassinar": true,}}; - this.router.navigate(['/home/gabinete-digital'], navigationExtras); - this.showDiplomasAssinar = true; - } + if (window.innerWidth < 701) { + this.router.navigate(['/home/gabinete-digital/diplomas-assinar']); } + else { + let navigationExtras: NavigationExtras = { queryParams: { "diplomasassinar": true, } }; + this.router.navigate(['/home/gabinete-digital'], navigationExtras); + this.showDiplomasAssinar = true; + } + } } diff --git a/src/app/pages/login/login.page.ts b/src/app/pages/login/login.page.ts index b453225dc..b20a6d480 100644 --- a/src/app/pages/login/login.page.ts +++ b/src/app/pages/login/login.page.ts @@ -7,6 +7,7 @@ import { environment } from 'src/environments/environment'; import { AlertController } from '@ionic/angular'; import { NotificationsService } from 'src/app/services/notifications.service'; import { SessionStore } from 'src/app/store/session.service'; +import { SqliteService } from '../../services/sqlite.service'; @Component({ selector: 'app-login', @@ -31,11 +32,14 @@ export class LoginPage implements OnInit { private router: Router, private authService: AuthService, private toastService: ToastService, - public alertController: AlertController + public alertController: AlertController, + private sqliteservice: SqliteService ) { } - ngOnInit() {} + ngOnInit() { + + } //Function to validade the login inputs validateUsername() { @@ -85,7 +89,7 @@ export class LoginPage implements OnInit { await this.authService.SetSession(attempt, this.userattempt); await this.authService.loginChat(this.userattempt); this.getToken(); - SessionStore.setInativity(true) + SessionStore.setInativity(true); this.goback() } else { diff --git a/src/app/services/eventTrigger.service.spec.ts b/src/app/services/eventTrigger.service.spec.ts new file mode 100644 index 000000000..332ea2205 --- /dev/null +++ b/src/app/services/eventTrigger.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { EventTrigger } from './eventTrigger.service'; + +describe('EventsService', () => { + let service: EventTrigger; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(EventTrigger); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/services/eventTrigger.service.ts b/src/app/services/eventTrigger.service.ts new file mode 100644 index 000000000..e44f104d7 --- /dev/null +++ b/src/app/services/eventTrigger.service.ts @@ -0,0 +1,21 @@ +import { Injectable } from '@angular/core'; +import { Subject } from 'rxjs'; + +@Injectable({ + providedIn: 'root' +}) + + +export class EventTrigger { + + private eventSubject = new Subject() + + publishSomeData(data: any){ + this.eventSubject.next(data) + } + + getObservable(): Subject{ + return this.eventSubject + } + +} \ No newline at end of file diff --git a/src/app/services/notifications.service.ts b/src/app/services/notifications.service.ts index 54bd07f16..44d7c344d 100644 --- a/src/app/services/notifications.service.ts +++ b/src/app/services/notifications.service.ts @@ -14,7 +14,8 @@ import { ToastService } from '../services/toast.service'; import { Optional } from '@angular/core'; import { JsonStore } from './jsonStore.service'; import { synchro } from './socket/synchro.service'; -import { v4 as uuidv4 } from 'uuid' +import { v4 as uuidv4 } from 'uuid'; +import { EventTrigger } from '../services/eventTrigger.service'; @Injectable({ providedIn: 'root' }) @@ -41,7 +42,8 @@ export class NotificationsService { private toastService: ToastService, private zone: NgZone, private activeroute: ActivatedRoute, - private jsonstore: JsonStore) { + private jsonstore: JsonStore, + private eventtrigger: EventTrigger) { this.storageService.get("Notifications").then((value) => { @@ -83,7 +85,7 @@ export class NotificationsService { getAndpostToken(username) { if (this.platform.is('desktop') || this.platform.is('mobileweb')) { - console.log('Notifications not supported') + //console.log('Notifications not supported') } else { const geturl = environment.apiURL + 'notifications/token'; @@ -136,87 +138,10 @@ export class NotificationsService { } } - - } } - getAndpostToken2() { - - if (this.platform.is('desktop') || this.platform.is('mobileweb')) { - console.log('Notifications not supported') - } else { - - const geturl = environment.apiURL + 'notifications/token'; - if(window['WLAuthorizationManager']) { - if(window['WLAuthorizationManager'].obtainAccessToken) { - window['WLAuthorizationManager'].obtainAccessToken("push.mobileclient").then( - (token) => { - console.log('Push Notification: Success ' + token); - - window['MFPPush'].initialize( - function (successResponse) { - console.log("Push notification Successfully Service intialized: " + successResponse); - }, - function (failureResponse) { - console.log("Push notification failure Service intialized: " + failureResponse); - } - ); - - window['MFPPush'].registerDevice(null, (successResponse) => { - console.log("Successfully registered: " + JSON.stringify(successResponse)); - console.log('token: ', successResponse.deviceId) - /* this.storageService.store(username, successResponse.deviceId); - this.storageService.get(username).then(value => { - console.log('STORAGE TOKEN', value) - this.storageService.get(AuthConnstants.USER).then(res => { - console.log('USERID', res); - const headers = { 'Authorization': 'Basic cGF1bG8ucGludG9AZ2FiaW5ldGVkaWdpdGFsLmxvY2FsOnRhYnRlc3RlQDAwNg==' }; - const body = { - UserId: res.UserId, - TokenId: successResponse.deviceId, - Status: 1, - Service: 1 - }; - this.http.post(`${geturl}`, body, { headers }).subscribe(data => { - console.log('TOKEN USER MIDLE', data); - }) - }); - - }); */ - }, - function (failureResponse) { - console.log("Successfully failue: " + JSON.stringify(failureResponse)); - } - ); - }, (error) => { - console.log('Push notification recived: failure ' + error.responseText); - console.log(JSON.stringify(error)); - } - ) - } else { - console.log('not called') - } - } else { - console.log('not called') - } - - - } - - } - - removeDepartment(index): void { - /* this.DataArray[this.DataArray.findIndex(item => item.index == index)]; - this.DataArray.splice( this.DataArray.findIndex(item => item.indexOf(index.to) === 'William'),1); */ - const indexx = this.DataArray.indexOf(index, 0); - if (indexx > -1) { - this.DataArray.splice(index, 1); - console.log('This notificatio', this.DataArray); - } - } - tempClearArray(){ this.DataArray = []; } @@ -245,6 +170,9 @@ export class NotificationsService { this.storageService.store("Notifications",this.DataArray) console.log(message); + this.eventtrigger.publishSomeData({ + notification: "recive" + }) var data = JSON.parse(message.payload); synchro.$send(data) diff --git a/src/app/services/socket/synchro.service.ts b/src/app/services/socket/synchro.service.ts index dd19ac1f2..649e34dfd 100644 --- a/src/app/services/socket/synchro.service.ts +++ b/src/app/services/socket/synchro.service.ts @@ -3,6 +3,7 @@ import { SessionStore } from 'src/app/store/session.service'; import { v4 as uuidv4 } from 'uuid' import { BackgroundService } from '../background.service'; import { environment } from 'src/environments/environment'; +import { EventTrigger } from '../eventTrigger.service' export interface wss{ @@ -28,6 +29,7 @@ class SynchroService { private url: string = '' callback = function(){} private _connected = false; + private eventtrigger: EventTrigger; private BackgroundService = new BackgroundService() callBacks: { type: 'Offline' | 'Online' | 'Onmessage' | 'Chat' | 'Notification' | 'Notifications' | '', @@ -81,7 +83,7 @@ class SynchroService { - if(!this.conected) { + //if(!this._connected) { this.BackgroundService.online() this.callBacks.forEach((e)=>{ @@ -90,9 +92,13 @@ class SynchroService { } }) - } + //} console.log('open ======================= welcome to socket server') + this.eventtrigger.publishSomeData({ + internet: "online" + }) + this._connected = true // send all saved data due to internet connection @@ -177,14 +183,15 @@ class SynchroService { - if(this._connected) { + // if(this._connected){ this.BackgroundService.offline(); this.callBacks.forEach((e)=>{ if(e.type == 'Offline') { e.funx() } }) - } + //} + // status this._connected = false diff --git a/src/app/services/sqlite.service.spec.ts b/src/app/services/sqlite.service.spec.ts new file mode 100644 index 000000000..033257edb --- /dev/null +++ b/src/app/services/sqlite.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { SqliteService } from './sqlite.service'; + +describe('SqliteService', () => { + let service: SqliteService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(SqliteService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/services/sqlite.service.ts b/src/app/services/sqlite.service.ts new file mode 100644 index 000000000..a21f97653 --- /dev/null +++ b/src/app/services/sqlite.service.ts @@ -0,0 +1,373 @@ +import { Injectable } from '@angular/core'; +import { Platform } from '@ionic/angular'; +import { SQLite, SQLiteObject } from '@ionic-native/sqlite/ngx'; + +@Injectable({ + providedIn: 'root' +}) +export class SqliteService { + + private dbInstance: SQLiteObject; + readonly db_name: string = "gabinetedigital.db"; + readonly events: string = "Events"; + readonly expedientes: string = "Expedientes"; + readonly allprocess: string = "ALLPROCESS"; + EVENTS: Array; + EXPEDIENTES: Array; + ALLPROCESS: Array; + PROCESS: Array; + + constructor(private platform: Platform, + private sqlite: SQLite) { + this.databaseConn(); + } + + databaseConn() { + this.platform.ready().then(async () => { + await this.sqlite.create({ + name: this.db_name, + location: 'default' + }).then(async (sqLite: SQLiteObject) => { + this.dbInstance = sqLite; + await sqLite.executeSql(` + CREATE TABLE IF NOT EXISTS ${this.events} ( + EventId varchar(255) PRIMARY KEY, + Subject varchar(255), + HasAttachments BIT, + Location varchar(255), + CalendarId varchar(255), + CalendarName varchar(255), + StartDate varchar(255), + EndDate varchar(255), + EventType varchar(255), + Attendees Text, + IsMeeting BIT, + IsRecurring BIT, + IsAllDayEvent BIT, + AppointmentState INTERGER, + TimeZone varchar(255), + Organizer Text, + Category varchar(255), + EventRecurrence Text, + Attachments Text, + Body Text + )`, []) + .then((res) => { + console.log("Sucess Events Table created: ", res) + }) + .catch((error) => console.log(JSON.stringify(error))); + + await sqLite.executeSql(` + CREATE TABLE IF NOT EXISTS ${this.expedientes} ( + serialNumber varchar(255) PRIMARY KEY, + workflowInstanceFolio varchar(255), + Documents Text, + actions Text, + activityInstanceName varchar(255), + formURL varchar(255), + originator Text, + taskStartDate varchar(255), + totalDocuments INTERGER, + workflowDisplayName varchar(255), + workflowID INTERGER, + workflowInstanceDataFields Text, + workflowInstanceID INTERGER, + workflowName varchar(255) + )`, []) + .then((res) => { + console.log("Sucess Espedientes Table created: ", res) + }) + .catch((error) => console.log(JSON.stringify(error))); + + await sqLite.executeSql(` + CREATE TABLE IF NOT EXISTS ${this.allprocess} ( + serialNumber varchar(255) PRIMARY KEY, + workflowInstanceFolio varchar(255), + Documents Text, + actions Text, + activityInstanceName varchar(255), + formURL varchar(255), + originator Text, + taskStartDate varchar(255), + totalDocuments INTERGER, + workflowDisplayName varchar(255), + workflowID INTERGER, + workflowInstanceDataFields Text, + workflowInstanceID INTERGER, + workflowName varchar(255) + )`, []) + .then((res) => { + console.log("Sucess AllProcess Table created: ", res) + }) + .catch((error) => console.log(JSON.stringify(error))); + }) + .catch((error) => console.log(JSON.stringify(error))); + }); + } + + //addEvent + public addEvent(data) { + this.dbInstance.executeSql(` + INSERT OR REPLACE INTO ${this.events} (EventId,Subject,HasAttachments,Location,CalendarId,CalendarName,StartDate,EndDate,EventType,Attendees,IsMeeting,IsRecurring,IsAllDayEvent,AppointmentState,TimeZone,Organizer,Category,EventRecurrence,Attachments,Body ) + VALUES ('${data.EventId}','${data.Subject}', '${data.HasAttachments}','${data.Location}','${data.CalendarId}','${data.CalendarName}','${data.StartDate}','${data.EndDate}','${data.EventType}','${data.Attendees}','${data.IsMeeting}','${data.IsRecurring}', + '${data.IsAllDayEvent}','${data.AppointmentState}','${data.TimeZone}','${data.Organizer}','${data.Category}','${data.EventRecurrence}','${data.Attachments}','${data.Body}')`, []) + .then(() => { + console.log("event add with Success"); + + }, (e) => { + console.log(JSON.stringify(e.err)); + }); + } + + //addExpediente + public addExpediente(data) { + this.dbInstance.executeSql(` + INSERT OR REPLACE INTO ${this.expedientes} (serialNumber,workflowInstanceFolio,Documents,actions,activityInstanceName,formURL,originator,taskStartDate,totalDocuments,workflowDisplayName,workflowID,workflowInstanceDataFields,workflowInstanceID,workflowName) + VALUES ('${data.serialNumber}','${data.workflowInstanceFolio}', '${data.Documents}','${data.actions}','${data.activityInstanceName}','${data.formURL}','${data.originator}','${data.taskStartDate}','${data.totalDocuments}','${data.workflowDisplayName}','${data.workflowID}', + '${data.workflowInstanceDataFields}','${data.workflowInstanceID}','${data.workflowName}')`, []) + .then(() => { + console.log("expediente add with Success"); + + }, (e) => { + console.log(JSON.stringify(e.err)); + }); + } + + //addprocess + public addProcess(data) { + this.dbInstance.executeSql(` + INSERT OR IGNORE INTO ${this.allprocess} (serialNumber,workflowInstanceFolio,Documents,actions,activityInstanceName,formURL,originator,taskStartDate,totalDocuments,workflowDisplayName,workflowID,workflowInstanceDataFields,workflowInstanceID,workflowName) + VALUES ('${data.serialNumber}','${data.workflowInstanceFolio}', '${JSON.stringify(data.Documents)}','${JSON.stringify(data.actions)}','${data.activityInstanceName}','${data.formURL}','${JSON.stringify(data.originator)}','${data.taskStartDate}','${data.totalDocuments}','${data.workflowDisplayName}','${data.workflowID}', + '${JSON.stringify(data.workflowInstanceDataFields)}','${data.workflowInstanceID}','${data.workflowName}')`, []) + .then(() => { + console.log("process add with Success"); + + }, (e) => { + console.log(JSON.stringify(e.err)); + }); + } + + //updateprocess + public updateProcess(data) { + this.dbInstance.executeSql(` + INSERT OR REPLACE INTO ${this.allprocess} (serialNumber,workflowInstanceFolio,Documents,actions,activityInstanceName,formURL,originator,taskStartDate,totalDocuments,workflowDisplayName,workflowID,workflowInstanceDataFields,workflowInstanceID,workflowName) + VALUES ('${data.serialNumber}','${data.workflowInstanceFolio}', '${JSON.stringify(data.Documents)}','${JSON.stringify(data.actions)}','${data.activityInstanceName}','${data.formURL}','${JSON.stringify(data.originator)}','${data.taskStartDate}','${data.totalDocuments}','${data.workflowDisplayName}','${data.workflowID}', + '${JSON.stringify(data.workflowInstanceDataFields)}','${data.workflowInstanceID}','${data.workflowName}')`, []) + .then(() => { + console.log("process add with Success"); + + }, (e) => { + console.log(JSON.stringify(e.err)); + }); + } + + //updateAttachment + updateUser(id, document,) { + let data = [document]; + return this.dbInstance.executeSql(`UPDATE ${this.allprocess} SET Documents = ? WHERE serialNumber = ${id}`, [document]).then(() => { + console.log("process attachment updated") + }) + } + //getAllEvents + getAllEvents() { + var hashattachment = false; + var ismeeting = false; + var isrecurring = false; + var isallday = false; + return this.dbInstance.executeSql(`SELECT * FROM ${this.events}`, []).then((res) => { + this.EVENTS = []; + if (res.rows.length > 0) { + for (var i = 0; i < res.rows.length; i++) { + if (res.rows.item(i).HasAttachments === "true") { + hashattachment = true + } + if (res.rows.item(i).IsMeeting === "true") { + ismeeting = true + } + if (res.rows.item(i).IsRecurring === "true") { + isrecurring = true + } + if (res.rows.item(i).IsAllDayEvent === "true") { + isallday = true + } + let event = { + EventId: res.rows.item(i).EventId, + HasAttachments: hashattachment, + Subject: res.rows.item(i).Subject, + Location: res.rows.item(i).Location, + CalendarId: res.rows.item(i).CalendarId, + CalendarName: res.rows.item(i).CalendarName, + StartDate: res.rows.item(i).StartDate, + EndDate: res.rows.item(i).EndDate, + EventType: res.rows.item(i).EventType, + Attendees: res.rows.item(i).Attendees, + IsMeeting: ismeeting, + IsRecurring: isrecurring, + IsAllDayEvent: isallday, + AppointmentState: res.rows.item(i).AppointmentState, + TimeZone: res.rows.item(i).TimeZone, + Organizer: res.rows.item(i).Organizer, + Category: res.rows.item(i).Category, + EventRecurrence: res.rows.item(i).EventRecurrence, + Attachments: res.rows.item(i).Attachments + } + this.EVENTS.push(event); + } + + return this.EVENTS; + } + }, (e) => { + console.log(" Get all events error", JSON.stringify(e)); + }); + } + + getAllExpedientes() { + return this.dbInstance.executeSql(`SELECT * FROM ${this.expedientes}`, []).then((res) => { + this.EXPEDIENTES = []; + if (res.rows.length > 0) { + for (var i = 0; i < res.rows.length; i++) { + this.EXPEDIENTES.push(res.rows.item(i)); + } + return this.EXPEDIENTES; + } + }, (e) => { + console.log(" Get all expedientes error", JSON.stringify(e)); + }); + } + + getAllProcess() { + return this.dbInstance.executeSql(`SELECT * FROM ${this.allprocess}`, []).then((res) => { + this.ALLPROCESS = []; + if (res.rows.length > 0) { + for (var i = 0; i < res.rows.length; i++) { + this.ALLPROCESS.push(res.rows.item(i)); + } + return this.ALLPROCESS; + } + }, (e) => { + console.log(" Get all process error", JSON.stringify(e)); + }); + } + + //getlistOfEventAprove + getListOfEventAprove(process, type) { + return this.dbInstance.executeSql(`SELECT * FROM ${this.allprocess} WHERE workflowDisplayName = ? OR workflowDisplayName = ? `, [process,type]).then((res) => { + this.ALLPROCESS = []; + if (res.rows.length > 0) { + for (var i = 0; i < res.rows.length; i++) { + this.ALLPROCESS.push(res.rows.item(i)); + } + return this.ALLPROCESS; + } + }, (e) => { + console.log(" Get all process error", JSON.stringify(e)); + }); + } + + //getprocessByworkflow + getprocessByworkflow(process) { + return this.dbInstance.executeSql(`SELECT * FROM ${this.allprocess} WHERE workflowDisplayName = ? `, [process]).then((res) => { + this.ALLPROCESS = []; + if (res.rows.length > 0) { + for (var i = 0; i < res.rows.length; i++) { + this.ALLPROCESS.push(res.rows.item(i)); + } + return this.ALLPROCESS; + } + }, (e) => { + console.log(" Get all process error", JSON.stringify(e)); + }); + } + + getProcessById(serial) { + return this.dbInstance.executeSql(`SELECT * FROM ${this.allprocess} WHERE serialNumber = ? `, [serial]).then((res) => { + this.PROCESS = []; + if (res.rows.length > 0) { + for (var i = 0; i < res.rows.length; i++) { + this.PROCESS.push(res.rows.item(i)) + } + return this.PROCESS; + } + }, (e) => { + console.log(" Get process by serial error", JSON.stringify(e)); + }); + } + + //getEventBy id + getEventById(id) { + + var hashattachment = false; + var ismeeting = false; + var isrecurring = false; + var isallday = false; + var body; + var attendes; + var organizer; + var eventrecurrence; + var attachment; + + return this.dbInstance.executeSql(`SELECT * FROM ${this.events} WHERE EventId = ? `, [id]).then((res) => { + this.EVENTS = []; + if (res.rows.length > 0) { + for (var i = 0; i < res.rows.length; i++) { + if (res.rows.item(i).HasAttachments === "true") { + hashattachment = true + } + if (res.rows.item(i).IsMeeting === "true") { + ismeeting = true + } + if (res.rows.item(i).IsRecurring === "true") { + isrecurring = true + } + if (res.rows.item(i).IsAllDayEvent === "true") { + isallday = true + } + /* if (res.rows.item(i).Body != "") { + body = JSON.parse(res.rows.item(i).Body); + } + if (res.rows.item(i).Attendees !="") { + attendes = JSON.parse(res.rows.item(i).Attendees); + } + if(res.rows.item(i).Organizer !=""){ + organizer = JSON.parse(res.rows.item(i).Organizer); + } + if(res.row.item(i).EventRecurrence != ""){ + eventrecurrence = JSON.parse(res.row.item(i).EventRecurrence); + } + if(res.row.item(i).Attachments != ""){ + attachment = JSON.parse(res.row.item(i).Attachments); + } + */ + + let event = { + EventId: res.rows.item(i).EventId, + HasAttachments: hashattachment, + Subject: res.rows.item(i).Subject, + Location: res.rows.item(i).Location, + CalendarId: res.rows.item(i).CalendarId, + CalendarName: res.rows.item(i).CalendarName, + StartDate: res.rows.item(i).StartDate, + EndDate: res.rows.item(i).EndDate, + EventType: res.rows.item(i).EventType, + Attendees: res.rows.item(i).Attendees, + IsMeeting: ismeeting, + IsRecurring: isrecurring, + IsAllDayEvent: isallday, + Body: res.rows.item(i).Body, + AppointmentState: res.rows.item(i).AppointmentState, + TimeZone: res.rows.item(i).TimeZone, + Organizer: res.rows.item(i).Organizer, + Category: res.rows.item(i).Category, + EventRecurrence: res.rows.item(i).EventRecurrence, + Attachments: res.rows.item(i).Attachments + } + this.EVENTS.push(event); + } + + return this.EVENTS; + } + }, (e) => { + console.log(" Get events by id error", JSON.stringify(e)); + }); + } +} diff --git a/src/app/services/webnotifications.service.ts b/src/app/services/webnotifications.service.ts index 01b132504..f5d8321b8 100644 --- a/src/app/services/webnotifications.service.ts +++ b/src/app/services/webnotifications.service.ts @@ -5,7 +5,7 @@ import { StorageService } from 'src/app/services/storage.service'; import { AuthConnstants } from 'src/app/config/auth-constants'; import { Token } from '../models/token.model'; import { ModalController, AlertController, AnimationController, Platform } from '@ionic/angular'; -import { NavigationExtras,Router } from '@angular/router'; +import { NavigationExtras, Router } from '@angular/router'; import { ToastService } from './toast.service'; import MFPPush from 'ibm-mfp-web-push'; @@ -31,13 +31,27 @@ export class WebNotificationsService { webconnection() { + var inicializeObj = { + appId: "com.gpr.gabinetedigital", + mfpContextRoot: "/mfp", + /* serverUrl: "http://gpr-dev-10.gabinetedigital.local:9080", + safariWebsitePushId: "http://gpr-dev-10.gabinetedigital.local:9080", */ + } + + + MFPPush.initialize({ + appId: "com.gpr.gabinetedigital", + mfpContextRoot: "/mfp", + }); + + /* MFPPush.initialize({ appId: "com.gpr.gabinetedigital", mfpContextRoot: "/mfp", }); */ - MFPPush.registerDevice() + /* MFPPush.registerDevice() .then((res) => { console.log("WEB Successfully Registered Device..."); @@ -55,17 +69,129 @@ export class WebNotificationsService { }) .catch((err) => { console.log("WEB Registration Failed" + err); - }); + }); */ } -async onReceviNotificationWeb() { + register(){ + MFPPush.registerDevice() + .then((res) => { + console.log("WEB Successfully Registered Device...", res); + }) + .catch((err) => { + console.log("WEB Registration Failed" + err); + }); + } + + async onReceviNotificationWeb() { + + if (window['WLAuthorizationManager']) { + if (window['WLAuthorizationManager'].obtainAccessToken) { + window['WLAuthorizationManager'].obtainAccessToken("push.mobileclient").then( + (token) => { + console.log('Push Notification: Success ' + token); + + MFPPush.initialize( + function (successResponse) { + console.log("Push notification Successfully intialized: " + successResponse); + MFPPush.registerNotificationsCallback(notificationReceived); + }, + function (failureResponse) { + console.log("Push notification failure intialized: " + failureResponse); + } + ); + var notificationReceived = (message) => { + console.log(message); + var data = JSON.parse(message.payload); + console.log(data.Service); + console.log(data.IdObject); + console.log(data.Object); + + if (message.actionName) { + //this.notificatinsRoutes(data); + console.log("Web notification") + } else { + console.log("Web notification") + //this.toastService.notificationMessage(message.alert,this.notificatinsRoutes, data); + } + + } + }, (error) => { + console.log('Push notification recived: failure ' + error.responseText); + console.log(JSON.stringify(error)); + } + ); + } + } + + + } + + /* getTokenByUserIdAndId(user, userID) { + const geturl = environment.apiURL + 'notifications/user/' + userID; + + return this.http.get(`${geturl}`); + } */ + + /* getAndpostToken(username) { + if (this.platform.is('desktop') || this.platform.is('mobileweb')) { + console.log('Notifications not supported') + } else { + + const geturl = environment.apiURL + 'notifications/token'; */ + /* + window['WLAuthorizationManager'].obtainAccessToken("push.mobileclient").then( + (token) => { + console.log('Push Notification: Success ' + token); - if(window['WLAuthorizationManager']) { - if(window['WLAuthorizationManager'].obtainAccessToken) { + MFPPush.initialize( + function (successResponse) { + console.log("Push notification Successfully Service intialized: " + successResponse); + }, + function (failureResponse) { + console.log("Push notification failure Service intialized: " + failureResponse); + } + ); + + MFPPush.registerDevice(null, (successResponse) => { + console.log("Successfully registered: " + JSON.stringify(successResponse)); + console.log('token: ', successResponse.deviceId) + this.storageService.store(username, successResponse.deviceId); + this.storageService.get(username).then(value => { + console.log('STORAGE TOKEN', value) + this.storageService.get(AuthConnstants.USER).then(res => { + console.log('USERID', res); + const headers = { 'Authorization': 'Basic cGF1bG8ucGludG9AZ2FiaW5ldGVkaWdpdGFsLmxvY2FsOnRhYnRlc3RlQDAwNg==' }; + const body = { + UserId: res.UserId, + TokenId: successResponse.deviceId, + Status: 1, + Service: 1 + }; + this.http.post(`${geturl}`, body, { headers }).subscribe(data => { + console.log('TOKEN USER MIDLE', data); + }) + }); + + }); + }, + function (failureResponse) { + console.log("Successfully failue: " + JSON.stringify(failureResponse)); + } + ); + }, (error) => { + console.log('Push notification recived: failure ' + error.responseText); + console.log(JSON.stringify(error)); + } + ); + } + + } */ + /* + async onReceviNotification() { window['WLAuthorizationManager'].obtainAccessToken("push.mobileclient").then( (token) => { console.log('Push Notification: Success ' + token); - + MFPPush.initialize( function (successResponse) { console.log("Push notification Successfully intialized: " + successResponse); @@ -81,122 +207,20 @@ async onReceviNotificationWeb() { console.log(data.Service); console.log(data.IdObject); console.log(data.Object); - + if(message.actionName){ - //this.notificatinsRoutes(data); - console.log("Web notification") + this.notificatinsRoutes(data); } else { - console.log("Web notification") - //this.toastService.notificationMessage(message.alert,this.notificatinsRoutes, data); + this.toastService.notificationMessage(message.alert,this.notificatinsRoutes, data); } - + } }, (error) => { console.log('Push notification recived: failure ' + error.responseText); console.log(JSON.stringify(error)); } ); - } - } - - -} - - /* getTokenByUserIdAndId(user, userID) { - const geturl = environment.apiURL + 'notifications/user/' + userID; - - return this.http.get(`${geturl}`); - } */ - - /* getAndpostToken(username) { - if (this.platform.is('desktop') || this.platform.is('mobileweb')) { - console.log('Notifications not supported') - } else { - - const geturl = environment.apiURL + 'notifications/token'; */ -/* - window['WLAuthorizationManager'].obtainAccessToken("push.mobileclient").then( - (token) => { - console.log('Push Notification: Success ' + token); - - MFPPush.initialize( - function (successResponse) { - console.log("Push notification Successfully Service intialized: " + successResponse); - }, - function (failureResponse) { - console.log("Push notification failure Service intialized: " + failureResponse); - } - ); - - MFPPush.registerDevice(null, (successResponse) => { - console.log("Successfully registered: " + JSON.stringify(successResponse)); - console.log('token: ', successResponse.deviceId) - this.storageService.store(username, successResponse.deviceId); - this.storageService.get(username).then(value => { - console.log('STORAGE TOKEN', value) - this.storageService.get(AuthConnstants.USER).then(res => { - console.log('USERID', res); - const headers = { 'Authorization': 'Basic cGF1bG8ucGludG9AZ2FiaW5ldGVkaWdpdGFsLmxvY2FsOnRhYnRlc3RlQDAwNg==' }; - const body = { - UserId: res.UserId, - TokenId: successResponse.deviceId, - Status: 1, - Service: 1 - }; - this.http.post(`${geturl}`, body, { headers }).subscribe(data => { - console.log('TOKEN USER MIDLE', data); - }) - }); - - }); - }, - function (failureResponse) { - console.log("Successfully failue: " + JSON.stringify(failureResponse)); - } - ); - }, (error) => { - console.log('Push notification recived: failure ' + error.responseText); - console.log(JSON.stringify(error)); - } - ); - } - - } */ -/* - async onReceviNotification() { - window['WLAuthorizationManager'].obtainAccessToken("push.mobileclient").then( - (token) => { - console.log('Push Notification: Success ' + token); - - MFPPush.initialize( - function (successResponse) { - console.log("Push notification Successfully intialized: " + successResponse); - MFPPush.registerNotificationsCallback(notificationReceived); - }, - function (failureResponse) { - console.log("Push notification failure intialized: " + failureResponse); - } - ); - var notificationReceived = (message) => { - console.log(message); - var data = JSON.parse(message.payload); - console.log(data.Service); - console.log(data.IdObject); - console.log(data.Object); - - if(message.actionName){ - this.notificatinsRoutes(data); - } else { - this.toastService.notificationMessage(message.alert,this.notificatinsRoutes, data); - } - - } - }, (error) => { - console.log('Push notification recived: failure ' + error.responseText); - console.log(JSON.stringify(error)); - } - ); - } */ + } */ /* notificatinsRoutes = (data) => { if (data.Service === "agenda") { diff --git a/src/app/shared/gabinete-digital/all-processes/all-processes.page.ts b/src/app/shared/gabinete-digital/all-processes/all-processes.page.ts index 66532d60c..93ca56583 100644 --- a/src/app/shared/gabinete-digital/all-processes/all-processes.page.ts +++ b/src/app/shared/gabinete-digital/all-processes/all-processes.page.ts @@ -4,6 +4,9 @@ import { LoginUserRespose } from 'src/app/models/user.model'; import { AuthService } from 'src/app/services/auth.service'; import { ProcessesService } from 'src/app/services/processes.service'; import { removeDuplicate } from 'src/plugin/removeDuplicate.js'; +import { SqliteService } from '../../../services/sqlite.service'; +import { synchro } from '../../../services/socket/synchro.service'; +import { Platform } from '@ionic/angular'; @Component({ selector: 'app-all-processes', @@ -13,29 +16,55 @@ import { removeDuplicate } from 'src/plugin/removeDuplicate.js'; export class AllProcessesPage implements OnInit { skeletonLoader = true; - allProcessesList:any[] = []; + allProcessesList: any[] = []; loggeduser: LoginUserRespose; + synch = synchro; + constructor( private processesService: ProcessesService, private router: Router, private authService: AuthService, + private sqliteservice: SqliteService, + private platform: Platform ) { this.loggeduser = authService.ValidatedUser; - } + } ngOnInit() { - this.loadAllProcesses(); - this.router.events.forEach((event) => { - if (event instanceof NavigationStart && event.url.startsWith('/home/gabinete-digital')) { - if(window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) { - this.refreshing(); - } else { - this.loadAllProcesses(); - } - } - }); + this.sqliteservice.getAllProcess().then((allprocess: any[]) => { + this.allProcessesList = allprocess; + console.log("All process from db ", allprocess) + }) + + + /* synchro.registerCallback('Online', () => { + this.platform.ready().then(() => { + this.loadAllProcesses(); + + this.router.events.forEach((event) => { + if (event instanceof NavigationStart && event.url.startsWith('/home/gabinete-digital')) { + if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) { + this.refreshing(); + } else { + this.loadAllProcesses(); + } + } + }); + }) + }) + + synchro.registerCallback('Offline', () => { + this.platform.ready().then(() => { + + this.sqliteservice.getAllProcess().then((allprocess: any[]) => { + this.allProcessesList = allprocess; + console.log("All process from db ", allprocess) + }) + }) + console.log('Offlineee') + }) */ } doRefresh() { @@ -52,9 +81,10 @@ export class AllProcessesPage implements OnInit { }, 1000); } - async loadAllProcesses(){ - let allProcessesList = await this.processesService.GetTasksList("", false).toPromise(); + async loadAllProcesses() { + let allProcessesList = await this.processesService.GetTasksList("", false).toPromise(); console.log(allProcessesList); + this.addProcessToDB(allProcessesList) this.skeletonLoader = true; @@ -63,7 +93,8 @@ export class AllProcessesPage implements OnInit { allProcessesList.forEach(element => { let date = new Date(element.taskStartDate); date.setMonth(date.getMonth() + 1); - let taskDate = date.getFullYear()+"-"+ date.getMonth()+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+ ":"+date.getSeconds(); + let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds(); + let task = { "SerialNumber": element.serialNumber, @@ -81,104 +112,194 @@ export class AllProcessesPage implements OnInit { "Agenda": element.workflowInstanceDataFields.Agenda, "customDate": this.setFormatDate(new Date(element.workflowInstanceDataFields.StartDate), new Date(element.workflowInstanceDataFields.EndDate), element.workflowInstanceDataFields.IsAllDayEvent), } - this.allProcessesList.push(task); - this.allProcessesList = removeDuplicate( this.allProcessesList) - this.allProcessesList = this.sortArrayISODate(this.allProcessesList).reverse(); + this.allProcessesList.push(task); + this.allProcessesList = removeDuplicate(this.allProcessesList) + this.allProcessesList = this.sortArrayISODate(this.allProcessesList).reverse(); + }); this.skeletonLoader = false; } - sortArrayISODate(myArray: any){ - return myArray.sort(function(a, b) { + + addProcessToDB(data) { + + data.forEach(element => { + + let process = { + "serialNumber": element.serialNumber, + "workflowInstanceFolio": element.workflowInstanceFolio, + "Documents": element.Documents, + "actions": element.actions, + "activityInstanceName": element.activityInstanceName, + "formURL": element.formURL, + "originator": element.originator, + "taskStartDate": element.taskStartDate, + "totalDocuments": element.totalDocuments, + "workflowDisplayName": element.workflowDisplayName, + "workflowID": element.workflowID, + "workflowInstanceDataFields": element.workflowInstanceDataFields, + "workflowInstanceID": element.workflowInstanceID, + "workflowName": element.workflowName + } + + this.sqliteservice.addProcess(process); + }); + + } + + getAllProcessFromDB() { + + synchro.registerCallback('Online', () => { + this.platform.ready().then(() => { + this.loadAllProcesses(); + + this.router.events.forEach((event) => { + if (event instanceof NavigationStart && event.url.startsWith('/home/gabinete-digital')) { + if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) { + this.refreshing(); + } else { + this.loadAllProcesses(); + } + } + }); + }) + }) + + synchro.registerCallback('Offline', () => { + this.platform.ready().then(() => { + + this.sqliteservice.getAllProcess().then((allprocess: any[]) => { + allprocess.forEach(element => { + let date = new Date(element.taskStartDate); + date.setMonth(date.getMonth() + 1); + let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds(); + + var workflowInstanceDataFields = JSON.parse(element.workflowInstanceDataFields); + console.log("WORKFLOW all process", workflowInstanceDataFields) + + let task = { + "SerialNumber": element.serialNumber, + "Folio": workflowInstanceDataFields.Subject, + "Senders": workflowInstanceDataFields.Sender, + "CreateDate": taskDate, + "DocumentURL": workflowInstanceDataFields.ViewerRequest, + "Remetente": workflowInstanceDataFields.Remetente, + "DocumentsQty": element.totalDocuments, + "DocId": workflowInstanceDataFields.DispatchDocId, + "FolderID": workflowInstanceDataFields.FolderID, + "WorkflowName": element.workflowDisplayName, + "activityInstanceName": element.activityInstanceName, + "Status": workflowInstanceDataFields.Status, + "Agenda": workflowInstanceDataFields.Agenda, + "customDate": this.setFormatDate(new Date(workflowInstanceDataFields.StartDate), new Date(workflowInstanceDataFields.EndDate), workflowInstanceDataFields.IsAllDayEvent), + } + + this.allProcessesList.push(task); + this.allProcessesList = removeDuplicate(this.allProcessesList) + this.allProcessesList = this.sortArrayISODate(this.allProcessesList).reverse(); + + }); + + + + this.allProcessesList = allprocess; + console.log("All process from db ", allprocess) + }) + }) + console.log('Offlineee') + }) + } + + sortArrayISODate(myArray: any) { + return myArray.sort(function (a, b) { return (a.CreateDate < b.CreateDate) ? -1 : ((a.CreateDate > b.CreateDate) ? 1 : 0); }); } - setFormatDate(start:any, end:any, allday:boolean){ + setFormatDate(start: any, end: any, allday: boolean) { let customDate; /* start = new Date(); end= new Date("2021-08-04T18:01:04.753Z"); */ //end = new Date("2021-09-04T18:01:04.753Z"); - const totalSeconds = Math.floor((end - (start))/1000);; - const totalMinutes = Math.floor(totalSeconds/60); - const totalHours = Math.floor(totalMinutes/60); - const totalDays = Math.floor(totalHours/24); + const totalSeconds = Math.floor((end - (start)) / 1000);; + const totalMinutes = Math.floor(totalSeconds / 60); + const totalHours = Math.floor(totalMinutes / 60); + const totalDays = Math.floor(totalHours / 24); - const hours = totalHours - ( totalDays * 24 ); - const minutes = totalMinutes - ( totalDays * 24 * 60 ) - ( hours * 60 ); - const seconds = totalSeconds - ( totalDays * 24 * 60 * 60 ) - ( hours * 60 * 60 ) - ( minutes * 60 ); + const hours = totalHours - (totalDays * 24); + const minutes = totalMinutes - (totalDays * 24 * 60) - (hours * 60); + const seconds = totalSeconds - (totalDays * 24 * 60 * 60) - (hours * 60 * 60) - (minutes * 60); let diffDays = totalDays; let diffMinutes = minutes; - if(totalDays == 0) { - if(allday) { - customDate = this.getCustomDate(start)+", "+this.getCustomHours(start)+" (todo dia)"; + if (totalDays == 0) { + if (allday) { + customDate = this.getCustomDate(start) + ", " + this.getCustomHours(start) + " (todo dia)"; console.log(customDate); return customDate; } - else - { + else { //customDate = this.getCustomDate(start)+","+this.getCustomHours(start)+" ("+minutes+" mins)"; - customDate = this.getCustomDate(start)+", "+this.getCustomHours(start)+" | "+this.getCustomHours(end); + customDate = this.getCustomDate(start) + ", " + this.getCustomHours(start) + " | " + this.getCustomHours(end); return customDate; } } - else{ - customDate = this.getCustomDate(start)+","+this.getCustomHours(start)+ - " (termina:"+ this.getCustomDate(end)+","+this.getCustomHours(end)+")"; + else { + customDate = this.getCustomDate(start) + "," + this.getCustomHours(start) + + " (termina:" + this.getCustomDate(end) + "," + this.getCustomHours(end) + ")"; return customDate; } } - getCustomDate(thedate: Date){ - return (thedate.getDay()+1) + "/" + - (thedate.getMonth()+1) + "/" + - thedate.getFullYear(); + getCustomDate(thedate: Date) { + return (thedate.getDay() + 1) + "/" + + (thedate.getMonth() + 1) + "/" + + thedate.getFullYear(); } - getCustomHours(thedate: Date){ + getCustomHours(thedate: Date) { return thedate.getHours() + ":" + - thedate.getMinutes(); + thedate.getMinutes(); } - goToProcess(serialNumber:string, workflowName:string, activityName:string){ - if(workflowName == 'Despacho') { - if(activityName == 'Tarefa de Despacho'|| activityName == 'Concluir Despacho'){ - this.router.navigate(['/home/gabinete-digital/despachos',serialNumber,'gabinete-digital']); + goToProcess(serialNumber: string, workflowName: string, activityName: string) { + if (workflowName == 'Despacho') { + if (activityName == 'Tarefa de Despacho' || activityName == 'Concluir Despacho') { + this.router.navigate(['/home/gabinete-digital/despachos', serialNumber, 'gabinete-digital']); } } - else if(workflowName == 'Despacho do Presidente da República') { - if(activityName == 'Tarefa de Despacho' || activityName == 'Concluir Despacho'){ - this.router.navigate(['/home/gabinete-digital/despachos-pr',serialNumber,'gabinete-digital']); + else if (workflowName == 'Despacho do Presidente da República') { + if (activityName == 'Tarefa de Despacho' || activityName == 'Concluir Despacho') { + this.router.navigate(['/home/gabinete-digital/despachos-pr', serialNumber, 'gabinete-digital']); } - else if(activityName == 'Revisar Diploma' || activityName == 'Assinar Diploma'){ - this.router.navigate(['/home/gabinete-digital/diplomas',serialNumber,'gabinete-digital']); + else if (activityName == 'Revisar Diploma' || activityName == 'Assinar Diploma') { + this.router.navigate(['/home/gabinete-digital/diplomas', serialNumber, 'gabinete-digital']); } - else if(activityName == 'Diploma Assinado'){ - this.router.navigate(['/home/gabinete-digital/diplomas-assinar',serialNumber,'gabinete-digital']); + else if (activityName == 'Diploma Assinado') { + this.router.navigate(['/home/gabinete-digital/diplomas-assinar', serialNumber, 'gabinete-digital']); } } - else if(workflowName == 'Pedido de Parecer' || workflowName == 'Pedido de Deferimento') { - this.router.navigate(['/home/gabinete-digital/pedidos',serialNumber,'gabinete-digital']); + else if (workflowName == 'Pedido de Parecer' || workflowName == 'Pedido de Deferimento') { + this.router.navigate(['/home/gabinete-digital/pedidos', serialNumber, 'gabinete-digital']); } - else if(workflowName == 'Expediente') { - this.router.navigate(['/home/gabinete-digital/expediente',serialNumber,'gabinete-digital']); + else if (workflowName == 'Expediente') { + this.router.navigate(['/home/gabinete-digital/expediente', serialNumber, 'gabinete-digital']); } - else if(workflowName == 'Expediente' && this.loggeduser.Profile == 'PR') { - this.router.navigate(['/home/gabinete-digital/expedientes-pr',serialNumber,'gabinete-digital']); + else if (workflowName == 'Expediente' && this.loggeduser.Profile == 'PR') { + this.router.navigate(['/home/gabinete-digital/expedientes-pr', serialNumber, 'gabinete-digital']); } else if (workflowName == "Pedido de Parecer do Presidente") { - this.router.navigate(['/home/gabinete-digital/pedidos',serialNumber,'gabinete-digital']); + this.router.navigate(['/home/gabinete-digital/pedidos', serialNumber, 'gabinete-digital']); } /* else if (workflowName == "Expediente") { this.router.navigate(['/home/gabinete-digital/pedidos',serialNumber,'gabinete-digital']); } */ - else if(workflowName == 'Agenda Pessoal PR' || workflowName == 'Agenda Oficial PR' || workflowName == 'Agenda Oficial MDGPR' || workflowName == 'Agenda Pessoal MDGPR') { - this.router.navigate(['/home/gabinete-digital/event-list/approve-event',serialNumber, 'gabinete-digital']); + else if (workflowName == 'Agenda Pessoal PR' || workflowName == 'Agenda Oficial PR' || workflowName == 'Agenda Oficial MDGPR' || workflowName == 'Agenda Pessoal MDGPR') { + this.router.navigate(['/home/gabinete-digital/event-list/approve-event', serialNumber, 'gabinete-digital']); } - else { + else { console.log('cant find page for this task') } } diff --git a/src/app/shared/header/header.page.ts b/src/app/shared/header/header.page.ts index a0e0c561e..31ccac939 100644 --- a/src/app/shared/header/header.page.ts +++ b/src/app/shared/header/header.page.ts @@ -8,6 +8,7 @@ import { StorageService } from '../../services/storage.service'; import { SessionStore } from 'src/app/store/session.service'; import { NotificationsService } from '../../services/notifications.service'; import { environment } from 'src/environments/environment'; +import { EventTrigger } from '../../services/eventTrigger.service'; @Component({ selector: 'app-header', @@ -33,7 +34,8 @@ export class HeaderPage implements OnInit { private animationController: AnimationController, private storageservice: StorageService, private platform: Platform, - private notificationsService: NotificationsService, + private notificationsService: NotificationsService, + private eventrigger: EventTrigger ) { this.loggeduser = SessionStore.user; router.events.subscribe((val) => { @@ -46,12 +48,20 @@ export class HeaderPage implements OnInit { this.hideSearch(); this.notificationLengthData(); - if (this.platform.is('desktop') || this.platform.is('mobileweb')) { + /* if (this.platform.is('desktop') || this.platform.is('mobileweb')) { console.log('Notifications not supported') this.UpdateNotificationCount(); } else { this.UpdateNotificationCount(); - } + } */ + + this.eventrigger.getObservable().subscribe((data)=>{ + if(data.notification == "delete" || "recive"){ + this.notificationLengthData(); + console.log('Deleted notification',data ) + } + + }) } diff --git a/src/assets/js/MFPPushServiceWorker.js b/src/assets/js/MFPPushServiceWorker.js deleted file mode 100644 index 2c67c2807..000000000 --- a/src/assets/js/MFPPushServiceWorker.js +++ /dev/null @@ -1,117 +0,0 @@ -/* eslint-disable no-unused-vars */ -/* eslint-disable no-undef */ -/* eslint-disable no-restricted-globals */ - -const regex = /{{\s*([^}]+)\s*}}/g; -var _pushVaribales = ""; - -function interpolate(messageData) { - return function interpolate(o) { - return messageData.replace(regex, function (a, b) { - var r = o[b]; - return typeof r === 'string' || typeof r === 'number' ? r : a; - }); - } -} - -function createTemplateMessage(messageData) { - if (Object.keys(_pushVaribales).length > 0 ) { - var message = interpolate(messageData)(_pushVaribales); - return message; - } else { - return messageData; - } -} - -function displayNotification(event) { - var messageJson = event.data.text(); - messageJson = JSON.parse(messageJson); - var title = messageJson.title ? messageJson.title : "New message"; - var imageUrl = messageJson.iconUrl ? messageJson.iconUrl : "images/icon.png"; -// var tagJson = messageJson.payload; -// var tag = tagJson.tag ? tagJson.tag : ""; - var bodyAlert = messageJson.alert ? messageJson.alert : "Example message" - var payloadData = messageJson.payload ? messageJson.payload : "Example message" - let messageTemp; - if ((messageTemp = regex.exec(bodyAlert)) !== null) { - bodyAlert = createTemplateMessage(bodyAlert); - } - self.registration.showNotification(title, { - body: bodyAlert, - icon: imageUrl, - data: payloadData, -// tag: tag - }); - return Promise.resolve(); -} - - -function triggerSeenEvent(strMsg) { - send_message_to_all_clients("msgEventSeen:" + strMsg); -} - -function triggerOpenEvent(strMsg) { - send_message_to_all_clients("msgEventOpen:" + strMsg); -} - -function onPushNotificationReceived(event) { - console.log('Push notification received : ', event); - if (event.data) { - console.log('Event data is : ', event.data.text()); - } - event.waitUntil(displayNotification(event).then(() => triggerSeenEvent(event.data.text()))); -}; - -self.addEventListener('push', onPushNotificationReceived); - -function send_message_to_client(client, msg) { - return new Promise(function (resolve, reject) { - var msg_chan = new MessageChannel(); - - msg_chan.port1.onmessage = function (event) { - if (event.data.error) { - reject(event.data.error); - } else { - resolve(event.data); - } - }; - - client.postMessage(msg, [msg_chan.port2]); - }); -} - -function send_message_to_all_clients(msg) { - clients.matchAll().then(clients => { - clients.forEach(client => { - send_message_to_client(client, msg); - }) - }); -} - -self.addEventListener('install', function (event) { - self.skipWaiting(); - console.log('Installed Service Worker : ', event); - //event.postMessage("SW Says 'Hello back!'"); -}); - -self.addEventListener('message', function (event) { - replyPort = event.ports[0]; - _pushVaribales = event.data; -}); - -self.addEventListener('activate', function (event) { - console.log('Activated Service Worker : ', event); - event.waitUntil(self.clients.claim()); -}); - -self.addEventListener('notificationclick', function (event) { - console.log('Notification clicked with tag' + event.notification.tag + " and data " + event.notification.data); - let nidjson = event.notification.data; - event.notification.close(); - event.waitUntil(triggerOpenEvent(nidjson)); -}); - -self.addEventListener('pushsubscriptionchange', function () { - console.log('Push Subscription change'); - send_message_to_all_clients("updateRegistration:"); -}); \ No newline at end of file diff --git a/src/assets/json/manifest.json b/src/assets/manifest.json similarity index 100% rename from src/assets/json/manifest.json rename to src/assets/manifest.json diff --git a/src/index.html b/src/index.html index b2adebd28..8313dca0c 100644 --- a/src/index.html +++ b/src/index.html @@ -7,14 +7,16 @@ - - + + - + +