ngx-sp-infra 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.angular/cache/16.2.0/ng-packagr/content-v2/sha512/2a/a3/eba6ea21e2e566c49202226aa3c1a4d439fa0a2c077374e48d864f20f5f804dbd931f042ddaa359fd35903a0bd3663a223e24dc11e1ec44501cc688a0a9c +1 -0
- package/.angular/cache/16.2.0/ng-packagr/content-v2/sha512/46/44/91b55887c08130e8014b3dbe56b69c0c29f4e127bceafcd610165f4c8e77fefa799ab68c415c1b45cc4fa114565650f3fc3c258e1dc7b792935cbee43fa7 +1 -0
- package/.angular/cache/16.2.0/ng-packagr/content-v2/sha512/7e/62/f8e6238b8f05aeaee2346bcaeda2226be7ab048d3b15e3dbbdf37170d9d7fade0fdfc6cc265d1ecc1b47509c962115d0d4b9a503907d6790c632e191001b +1 -0
- package/.angular/cache/16.2.0/ng-packagr/content-v2/sha512/8d/53/ad58764bc240411378ae1c47c0c20525da378a3b143795a11bc3fdbf6c9cde6fb2de6c3947d673d5872b9ce205d6274114b3b4dfd27609a636df7fd0b600 +1 -0
- package/.angular/cache/16.2.0/ng-packagr/content-v2/sha512/9e/70/9fc33090191a9df303901910a34f5d1cc7ea38ac92e21006bf923a814a4dffe9ad5b7357989f95d4e371cd00318c29339ec3e935832e84f3571ba0ed5f25 +1 -0
- package/.angular/cache/16.2.0/ng-packagr/content-v2/sha512/a1/3a/6a6f351adef4b7c8b7d643b092ca26e0ceeb2a285456285f866504493c9c7db8d420d3a4f282c699a11f2f9933c828c8f8388f28e96372408d7b456f32a1 +1 -0
- package/.angular/cache/16.2.0/ng-packagr/content-v2/sha512/d3/e3/2852d10551b620a4dfaabb1268bf0ac681e206bfb66451e18ac43a2e5c7cdc8a75291e3a1a4038129f3e40cc11317edffe8434d7110d9579585a25843e15 +1 -0
- package/.angular/cache/16.2.0/ng-packagr/content-v2/sha512/f2/ee/05ff4c2260f161b6295a8507440a1b86c0f666f313866e5bf1de6829ae5fe384d6612d732d09c815fe515bd3d6379ed5f8136cf4a4e228b322309840240e +1 -0
- package/.angular/cache/16.2.0/ng-packagr/content-v2/sha512/fe/15/fb0370939f075c14617e0d5fd8411f76edb53e439e19683e5c4554ae7cabd0387c922f6ec6893ced3321ed77df2c851b82eea6a70b38b7396f68493eea19 +1 -0
- package/.angular/cache/16.2.0/ng-packagr/index-v5/10/17/ae308ad3e0cad0afd27bf9eafe0177fdb23b463e70e0dd30d23c117517f6 +2 -0
- package/.angular/cache/16.2.0/ng-packagr/index-v5/14/18/88eabde022c32e7a38011f4ab6f7945e52f018be1abbe6a96864f8f9e22c +2 -0
- package/.angular/cache/16.2.0/ng-packagr/index-v5/1c/b7/dcd00bf2f1de70eab7d9e1d9601fbd87f49d46c7b49671d81ccd4b20b3f1 +2 -0
- package/.angular/cache/16.2.0/ng-packagr/index-v5/4b/31/217b5311dae6305f9b5dc82062276c77f272d61fc3e27c2df5eb0d6b1fb7 +2 -0
- package/.angular/cache/16.2.0/ng-packagr/index-v5/6a/b0/e5091f9ee02b3fcac9821e92cc5113d6b0593bd8bacfb5cbac7dfca306c3 +2 -0
- package/.angular/cache/16.2.0/ng-packagr/index-v5/9b/66/70a7c5990683795072c8b98eb25407b36f55f8efa8d2e0bdef67a8e989ab +2 -0
- package/.angular/cache/16.2.0/ng-packagr/index-v5/a6/8b/af2670adca8f5d06d3d9577ffad4449e4897eaf85de2f4e7f43f93934a16 +2 -0
- package/.angular/cache/16.2.0/ng-packagr/index-v5/da/da/502cfd37a0e9e7f413a569ccf28dc682f9e942ec5e460c93c1dd7c4e531f +3 -0
- package/.angular/cache/16.2.0/ng-packagr/index-v5/f3/8b/4e00bb8eddd473ae09b0b5dee39fa8416aee7b659a770d18c767e5027992 +2 -0
- package/.editorconfig +16 -0
- package/README.md +27 -0
- package/angular.json +41 -0
- package/dist/ngx-sp-infra/README.md +12 -0
- package/dist/ngx-sp-infra/esm2022/lib/infra.module.mjs +137 -0
- package/dist/ngx-sp-infra/esm2022/lib/message/alert/alert.component.mjs +32 -0
- package/dist/ngx-sp-infra/esm2022/lib/message/confirm/confirm.component.mjs +52 -0
- package/dist/ngx-sp-infra/esm2022/lib/message/confirm-modal/confirm-modal.component.mjs +72 -0
- package/dist/ngx-sp-infra/esm2022/lib/message/message-enum.mjs +23 -0
- package/dist/ngx-sp-infra/esm2022/lib/message/message.service.mjs +132 -0
- package/dist/ngx-sp-infra/esm2022/lib/message/save/save.component.mjs +46 -0
- package/dist/ngx-sp-infra/esm2022/lib/models/DownloadArquivos.mjs +3 -0
- package/dist/ngx-sp-infra/esm2022/lib/models/email-model.mjs +35 -0
- package/dist/ngx-sp-infra/esm2022/lib/models/ierror.mjs +2 -0
- package/dist/ngx-sp-infra/esm2022/lib/models/ipagination.mjs +2 -0
- package/dist/ngx-sp-infra/esm2022/lib/models/report-file.mjs +7 -0
- package/dist/ngx-sp-infra/esm2022/lib/models/ret-error.mjs +3 -0
- package/dist/ngx-sp-infra/esm2022/lib/models/ret-feedback-message.mjs +7 -0
- package/dist/ngx-sp-infra/esm2022/lib/models/ret-report-file.mjs +3 -0
- package/dist/ngx-sp-infra/esm2022/lib/pipes/cpf-cnpj.pipe.mjs +23 -0
- package/dist/ngx-sp-infra/esm2022/lib/pipes/currency.pipe.mjs +16 -0
- package/dist/ngx-sp-infra/esm2022/lib/pipes/to-url.pipe.mjs +32 -0
- package/dist/ngx-sp-infra/esm2022/lib/utils/check-url-and-method.service.mjs +70 -0
- package/dist/ngx-sp-infra/esm2022/lib/utils/form-utils.mjs +38 -0
- package/dist/ngx-sp-infra/esm2022/lib/utils/ip-service.service.mjs +22 -0
- package/dist/ngx-sp-infra/esm2022/lib/utils/settings.service.mjs +32 -0
- package/dist/ngx-sp-infra/esm2022/lib/utils/utils.mjs +335 -0
- package/dist/ngx-sp-infra/esm2022/lib/validators/cpf-cnpj.validator.directive.mjs +24 -0
- package/dist/ngx-sp-infra/esm2022/lib/validators/cpf-cnpj.validator.mjs +54 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/breadcrumb/infra-breadcrumb/infra-breadcrumb.component.mjs +35 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/breadcrumb/infra-breadcrumb-item/infra-breadcrumb-item.component.mjs +28 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/breadcrumb/portalrh-breadcrumb/breadcrumb.component.mjs +21 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/click-outside/clickoutside.directive.mjs +167 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/combobox/combobox.component.mjs +545 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/combobox/pipes/filter-by.pipe.mjs +44 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/combobox/pipes/limit-to.pipe.mjs +19 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/field-control-error/field-control-error.component.mjs +23 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/field-error-message/field-error-message.component.mjs +33 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/loading/loading.component.mjs +12 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/loading-button/loading-button.component.mjs +15 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/ordering/ordering.component.mjs +56 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/svg-storage/svg-storage.component.mjs +94 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/tree/models/ret-tree.mjs +3 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/tree/models/tree-item.mjs +7 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/tree/pipes/search-tree.pipe.mjs +17 -0
- package/dist/ngx-sp-infra/esm2022/lib/widgets/tree/tree.component.mjs +91 -0
- package/dist/ngx-sp-infra/esm2022/ngx-sp-infra.mjs +5 -0
- package/dist/ngx-sp-infra/esm2022/public-api.mjs +51 -0
- package/dist/ngx-sp-infra/fesm2022/ngx-sp-infra.mjs +2313 -0
- package/dist/ngx-sp-infra/fesm2022/ngx-sp-infra.mjs.map +1 -0
- package/dist/ngx-sp-infra/index.d.ts +5 -0
- package/dist/ngx-sp-infra/lib/infra.module.d.ts +32 -0
- package/dist/ngx-sp-infra/lib/message/alert/alert.component.d.ts +14 -0
- package/dist/ngx-sp-infra/lib/message/confirm/confirm.component.d.ts +22 -0
- package/dist/ngx-sp-infra/lib/message/confirm-modal/confirm-modal.component.d.ts +33 -0
- package/dist/ngx-sp-infra/lib/message/message-enum.d.ts +20 -0
- package/dist/ngx-sp-infra/lib/message/message.service.d.ts +31 -0
- package/dist/ngx-sp-infra/lib/message/save/save.component.d.ts +21 -0
- package/dist/ngx-sp-infra/lib/models/DownloadArquivos.d.ts +11 -0
- package/dist/ngx-sp-infra/lib/models/email-model.d.ts +30 -0
- package/dist/ngx-sp-infra/lib/models/ierror.d.ts +4 -0
- package/dist/ngx-sp-infra/lib/models/ipagination.d.ts +5 -0
- package/dist/ngx-sp-infra/lib/models/report-file.d.ts +4 -0
- package/dist/ngx-sp-infra/lib/models/ret-error.d.ts +5 -0
- package/dist/ngx-sp-infra/lib/models/ret-feedback-message.d.ts +7 -0
- package/dist/ngx-sp-infra/lib/models/ret-report-file.d.ts +7 -0
- package/dist/ngx-sp-infra/lib/pipes/cpf-cnpj.pipe.d.ts +7 -0
- package/dist/ngx-sp-infra/lib/pipes/currency.pipe.d.ts +7 -0
- package/dist/ngx-sp-infra/lib/pipes/to-url.pipe.d.ts +16 -0
- package/dist/ngx-sp-infra/lib/utils/check-url-and-method.service.d.ts +35 -0
- package/dist/ngx-sp-infra/lib/utils/form-utils.d.ts +7 -0
- package/dist/ngx-sp-infra/lib/utils/ip-service.service.d.ts +9 -0
- package/dist/ngx-sp-infra/lib/utils/settings.service.d.ts +9 -0
- package/dist/ngx-sp-infra/lib/utils/utils.d.ts +58 -0
- package/dist/ngx-sp-infra/lib/validators/cpf-cnpj.validator.d.ts +18 -0
- package/dist/ngx-sp-infra/lib/validators/cpf-cnpj.validator.directive.d.ts +7 -0
- package/dist/ngx-sp-infra/lib/widgets/breadcrumb/infra-breadcrumb/infra-breadcrumb.component.d.ts +29 -0
- package/dist/ngx-sp-infra/lib/widgets/breadcrumb/infra-breadcrumb-item/infra-breadcrumb-item.component.d.ts +14 -0
- package/dist/ngx-sp-infra/lib/widgets/breadcrumb/portalrh-breadcrumb/breadcrumb.component.d.ts +10 -0
- package/dist/ngx-sp-infra/lib/widgets/click-outside/clickoutside.directive.d.ts +40 -0
- package/dist/ngx-sp-infra/lib/widgets/combobox/combobox.component.d.ts +174 -0
- package/dist/ngx-sp-infra/lib/widgets/combobox/pipes/filter-by.pipe.d.ts +10 -0
- package/dist/ngx-sp-infra/lib/widgets/combobox/pipes/limit-to.pipe.d.ts +7 -0
- package/dist/ngx-sp-infra/lib/widgets/field-control-error/field-control-error.component.d.ts +12 -0
- package/dist/ngx-sp-infra/lib/widgets/field-error-message/field-error-message.component.d.ts +14 -0
- package/dist/ngx-sp-infra/lib/widgets/loading/loading.component.d.ts +6 -0
- package/dist/ngx-sp-infra/lib/widgets/loading-button/loading-button.component.d.ts +7 -0
- package/dist/ngx-sp-infra/lib/widgets/ordering/ordering.component.d.ts +18 -0
- package/dist/ngx-sp-infra/lib/widgets/svg-storage/svg-storage.component.d.ts +16 -0
- package/dist/ngx-sp-infra/lib/widgets/tree/models/ret-tree.d.ts +7 -0
- package/dist/ngx-sp-infra/lib/widgets/tree/models/tree-item.d.ts +11 -0
- package/dist/ngx-sp-infra/lib/widgets/tree/pipes/search-tree.pipe.d.ts +8 -0
- package/dist/ngx-sp-infra/lib/widgets/tree/tree.component.d.ts +20 -0
- package/dist/ngx-sp-infra/package.json +37 -0
- package/dist/ngx-sp-infra/public-api.d.ts +47 -0
- package/package.json +43 -0
- package/projects/ngx-sp-infra/README.md +12 -0
- package/projects/ngx-sp-infra/karma.conf.js +44 -0
- package/projects/ngx-sp-infra/ng-package.json +7 -0
- package/projects/ngx-sp-infra/package-lock.json +225 -0
- package/projects/ngx-sp-infra/package.json +18 -0
- package/projects/ngx-sp-infra/src/lib/infra.module.ts +85 -0
- package/projects/ngx-sp-infra/src/lib/message/alert/alert.component.html +6 -0
- package/projects/ngx-sp-infra/src/lib/message/alert/alert.component.scss +5 -0
- package/projects/ngx-sp-infra/src/lib/message/alert/alert.component.ts +39 -0
- package/projects/ngx-sp-infra/src/lib/message/confirm/confirm.component.html +15 -0
- package/projects/ngx-sp-infra/src/lib/message/confirm/confirm.component.scss +0 -0
- package/projects/ngx-sp-infra/src/lib/message/confirm/confirm.component.ts +52 -0
- package/projects/ngx-sp-infra/src/lib/message/confirm-modal/confirm-modal.component.html +39 -0
- package/projects/ngx-sp-infra/src/lib/message/confirm-modal/confirm-modal.component.scss +0 -0
- package/projects/ngx-sp-infra/src/lib/message/confirm-modal/confirm-modal.component.ts +73 -0
- package/projects/ngx-sp-infra/src/lib/message/message-enum.ts +21 -0
- package/projects/ngx-sp-infra/src/lib/message/message.service.ts +169 -0
- package/projects/ngx-sp-infra/src/lib/message/save/save.component.html +35 -0
- package/projects/ngx-sp-infra/src/lib/message/save/save.component.scss +110 -0
- package/projects/ngx-sp-infra/src/lib/message/save/save.component.ts +44 -0
- package/projects/ngx-sp-infra/src/lib/models/DownloadArquivos.ts +12 -0
- package/projects/ngx-sp-infra/src/lib/models/email-model.ts +33 -0
- package/projects/ngx-sp-infra/src/lib/models/ierror.ts +4 -0
- package/projects/ngx-sp-infra/src/lib/models/ipagination.ts +5 -0
- package/projects/ngx-sp-infra/src/lib/models/report-file.ts +4 -0
- package/projects/ngx-sp-infra/src/lib/models/ret-error.ts +6 -0
- package/projects/ngx-sp-infra/src/lib/models/ret-feedback-message.ts +8 -0
- package/projects/ngx-sp-infra/src/lib/models/ret-report-file.ts +8 -0
- package/projects/ngx-sp-infra/src/lib/pipes/cpf-cnpj.pipe.ts +21 -0
- package/projects/ngx-sp-infra/src/lib/pipes/currency.pipe.ts +13 -0
- package/projects/ngx-sp-infra/src/lib/pipes/to-url.pipe.ts +33 -0
- package/projects/ngx-sp-infra/src/lib/utils/check-url-and-method.service.ts +84 -0
- package/projects/ngx-sp-infra/src/lib/utils/form-utils.ts +50 -0
- package/projects/ngx-sp-infra/src/lib/utils/ip-service.service.ts +22 -0
- package/projects/ngx-sp-infra/src/lib/utils/settings.service.ts +32 -0
- package/projects/ngx-sp-infra/src/lib/utils/utils.ts +427 -0
- package/projects/ngx-sp-infra/src/lib/validators/cpf-cnpj.validator.directive.ts +14 -0
- package/projects/ngx-sp-infra/src/lib/validators/cpf-cnpj.validator.ts +74 -0
- package/projects/ngx-sp-infra/src/lib/widgets/breadcrumb/infra-breadcrumb/infra-breadcrumb.component.css +0 -0
- package/projects/ngx-sp-infra/src/lib/widgets/breadcrumb/infra-breadcrumb/infra-breadcrumb.component.html +3 -0
- package/projects/ngx-sp-infra/src/lib/widgets/breadcrumb/infra-breadcrumb/infra-breadcrumb.component.ts +34 -0
- package/projects/ngx-sp-infra/src/lib/widgets/breadcrumb/infra-breadcrumb-item/infra-breadcrumb-item.component.css +0 -0
- package/projects/ngx-sp-infra/src/lib/widgets/breadcrumb/infra-breadcrumb-item/infra-breadcrumb-item.component.html +1 -0
- package/projects/ngx-sp-infra/src/lib/widgets/breadcrumb/infra-breadcrumb-item/infra-breadcrumb-item.component.ts +29 -0
- package/projects/ngx-sp-infra/src/lib/widgets/breadcrumb/portalrh-breadcrumb/breadcrumb.component.css +0 -0
- package/projects/ngx-sp-infra/src/lib/widgets/breadcrumb/portalrh-breadcrumb/breadcrumb.component.html +5 -0
- package/projects/ngx-sp-infra/src/lib/widgets/breadcrumb/portalrh-breadcrumb/breadcrumb.component.ts +18 -0
- package/projects/ngx-sp-infra/src/lib/widgets/click-outside/clickoutside.directive.ts +183 -0
- package/projects/ngx-sp-infra/src/lib/widgets/combobox/combobox.component.html +40 -0
- package/projects/ngx-sp-infra/src/lib/widgets/combobox/combobox.component.scss +185 -0
- package/projects/ngx-sp-infra/src/lib/widgets/combobox/combobox.component.ts +637 -0
- package/projects/ngx-sp-infra/src/lib/widgets/combobox/combobox.service.ts +15 -0
- package/projects/ngx-sp-infra/src/lib/widgets/combobox/pipes/filter-by.pipe.ts +38 -0
- package/projects/ngx-sp-infra/src/lib/widgets/combobox/pipes/limit-to.pipe.ts +13 -0
- package/projects/ngx-sp-infra/src/lib/widgets/field-control-error/field-control-error.component.css +0 -0
- package/projects/ngx-sp-infra/src/lib/widgets/field-control-error/field-control-error.component.html +4 -0
- package/projects/ngx-sp-infra/src/lib/widgets/field-control-error/field-control-error.component.ts +18 -0
- package/projects/ngx-sp-infra/src/lib/widgets/field-error-message/field-error-message.component.css +0 -0
- package/projects/ngx-sp-infra/src/lib/widgets/field-error-message/field-error-message.component.html +4 -0
- package/projects/ngx-sp-infra/src/lib/widgets/field-error-message/field-error-message.component.ts +35 -0
- package/projects/ngx-sp-infra/src/lib/widgets/loading/loading.component.css +7 -0
- package/projects/ngx-sp-infra/src/lib/widgets/loading/loading.component.html +4 -0
- package/projects/ngx-sp-infra/src/lib/widgets/loading/loading.component.ts +12 -0
- package/projects/ngx-sp-infra/src/lib/widgets/loading-button/loading-button.component.css +3 -0
- package/projects/ngx-sp-infra/src/lib/widgets/loading-button/loading-button.component.html +2 -0
- package/projects/ngx-sp-infra/src/lib/widgets/loading-button/loading-button.component.ts +13 -0
- package/projects/ngx-sp-infra/src/lib/widgets/ordering/ordering.component.html +23 -0
- package/projects/ngx-sp-infra/src/lib/widgets/ordering/ordering.component.scss +0 -0
- package/projects/ngx-sp-infra/src/lib/widgets/ordering/ordering.component.ts +50 -0
- package/projects/ngx-sp-infra/src/lib/widgets/svg-storage/svg-storage.component.html +728 -0
- package/projects/ngx-sp-infra/src/lib/widgets/svg-storage/svg-storage.component.scss +0 -0
- package/projects/ngx-sp-infra/src/lib/widgets/svg-storage/svg-storage.component.ts +105 -0
- package/projects/ngx-sp-infra/src/lib/widgets/tree/README.md +33 -0
- package/projects/ngx-sp-infra/src/lib/widgets/tree/models/ret-tree.ts +8 -0
- package/projects/ngx-sp-infra/src/lib/widgets/tree/models/tree-item.ts +11 -0
- package/projects/ngx-sp-infra/src/lib/widgets/tree/pipes/search-tree.pipe.ts +15 -0
- package/projects/ngx-sp-infra/src/lib/widgets/tree/tree.component.html +51 -0
- package/projects/ngx-sp-infra/src/lib/widgets/tree/tree.component.scss +57 -0
- package/projects/ngx-sp-infra/src/lib/widgets/tree/tree.component.ts +88 -0
- package/projects/ngx-sp-infra/src/public-api.ts +58 -0
- package/projects/ngx-sp-infra/src/test.ts +15 -0
- package/projects/ngx-sp-infra/tsconfig.lib.json +15 -0
- package/projects/ngx-sp-infra/tsconfig.lib.prod.json +10 -0
- package/projects/ngx-sp-infra/tsconfig.spec.json +17 -0
- package/sp-ng-infra-0.0.0.tgz +0 -0
- package/tsconfig.json +42 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { Injectable, TemplateRef } from '@angular/core';
|
|
2
|
+
import { take } from 'rxjs/operators';
|
|
3
|
+
|
|
4
|
+
import { Observable } from 'rxjs';
|
|
5
|
+
|
|
6
|
+
import { BsModalRef, BsModalService, ModalOptions } from 'ngx-bootstrap/modal';
|
|
7
|
+
|
|
8
|
+
import { alertIds, alertTypes } from './message-enum';
|
|
9
|
+
import { AlertComponent } from './alert/alert.component';
|
|
10
|
+
import { ConfirmComponent } from './confirm/confirm.component';
|
|
11
|
+
import { SaveComponent } from './save/save.component';
|
|
12
|
+
|
|
13
|
+
@Injectable(
|
|
14
|
+
{ providedIn: 'root' }
|
|
15
|
+
)
|
|
16
|
+
export class MessageService {
|
|
17
|
+
constructor(private bsModalService: BsModalService) { }
|
|
18
|
+
|
|
19
|
+
// Exibe uma mesagem conforme o tipo (privado)
|
|
20
|
+
private showAlert(
|
|
21
|
+
message: string,
|
|
22
|
+
type: alertTypes,
|
|
23
|
+
dismissTimeout?: number,
|
|
24
|
+
id?: number | undefined
|
|
25
|
+
) {
|
|
26
|
+
const initialState: any = {
|
|
27
|
+
message: message,
|
|
28
|
+
type: type,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const bsModalRef: BsModalRef = this.bsModalService.show(AlertComponent, {
|
|
32
|
+
initialState, class: 'modal-md', id: id
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (dismissTimeout) {
|
|
36
|
+
setTimeout(() => bsModalRef.hide(), dismissTimeout);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Exibe uma mensagem do tipo danger
|
|
41
|
+
showAlertDanger(message: string) {
|
|
42
|
+
this.showAlert(message, alertTypes.DANGER, 0, alertIds.DANGER);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Exibe uma mesagem do tipo success
|
|
46
|
+
showAlertSuccess(message: string) {
|
|
47
|
+
this.showAlert(message, alertTypes.SUCCESS, 3000, alertIds.SUCCESS);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Exibe uma mesagem do tipo info
|
|
51
|
+
showAlertInfo(message: string) {
|
|
52
|
+
this.showAlert(message, alertTypes.INFO, 3000, alertIds.INFO);
|
|
53
|
+
}
|
|
54
|
+
// Exibe uma mesagem do tipo primary(
|
|
55
|
+
showAlertPrimary(message: string) {
|
|
56
|
+
this.showAlert(message, alertTypes.PRIMARY, 3000, alertIds.PRIMARY);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Exibe uma mesagem do tipo secondary(
|
|
60
|
+
showAlertSecondary(message: string) {
|
|
61
|
+
this.showAlert(message, alertTypes.SECONDARY, 3000, alertIds.SECONDARY);
|
|
62
|
+
}
|
|
63
|
+
// Exibe uma mesagem do tipo warning
|
|
64
|
+
showAlertWarning(message: string) {
|
|
65
|
+
this.showAlert(message, alertTypes.WARNING, 0, alertIds.WARNING);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Exibe uma mesagem do tipo light
|
|
69
|
+
showAlertLight(message: string) {
|
|
70
|
+
this.showAlert(message, alertTypes.LIGHT, 0, alertIds.LIGHT);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Exibe uma mesagem do tipo dark
|
|
74
|
+
showAlertDark(message: string) {
|
|
75
|
+
this.showAlert(message, alertTypes.DARK, 0, alertIds.DARK);
|
|
76
|
+
}
|
|
77
|
+
// Exibe um modal de inserção no banco
|
|
78
|
+
showCreate(
|
|
79
|
+
title: string,
|
|
80
|
+
message: string,
|
|
81
|
+
okText: string,
|
|
82
|
+
cancelText: string,
|
|
83
|
+
okButton: Function,
|
|
84
|
+
fields: string[],
|
|
85
|
+
): Observable<boolean> {
|
|
86
|
+
if (!okText) {
|
|
87
|
+
okText = 'Criar';
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (!okButton) {
|
|
91
|
+
}
|
|
92
|
+
const initialState: any = {
|
|
93
|
+
title: title,
|
|
94
|
+
message: message,
|
|
95
|
+
fields: fields,
|
|
96
|
+
okText: okText,
|
|
97
|
+
cancelText: cancelText,
|
|
98
|
+
okButton: okButton,
|
|
99
|
+
};
|
|
100
|
+
const bsModalRef: BsModalRef = this.bsModalService.show(SaveComponent, {
|
|
101
|
+
initialState,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
return (<SaveComponent>bsModalRef.content).confirmResult
|
|
105
|
+
.asObservable()
|
|
106
|
+
.pipe(take(1));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Exibe uma mesagem do tipo confirmação
|
|
110
|
+
showConfirm(
|
|
111
|
+
title: string,
|
|
112
|
+
message: string,
|
|
113
|
+
okText?: string,
|
|
114
|
+
cancelText?: string,
|
|
115
|
+
okButton?: Function,
|
|
116
|
+
paramatroOkButton?: boolean
|
|
117
|
+
): Observable<'confirmado' | 'cancelado'> {
|
|
118
|
+
if (!okText) {
|
|
119
|
+
okText = 'Sim';
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (!cancelText) {
|
|
123
|
+
cancelText = 'Cancelar';
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (!okButton) {
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const initialState: any = {
|
|
130
|
+
title: title,
|
|
131
|
+
message: message,
|
|
132
|
+
okText: okText,
|
|
133
|
+
cancelText: cancelText,
|
|
134
|
+
okButton: okButton,
|
|
135
|
+
parametroOkButton: paramatroOkButton,
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const bsModalRef: BsModalRef = this.bsModalService.show(ConfirmComponent, {
|
|
139
|
+
initialState,
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
return ((<ConfirmComponent>bsModalRef.content)).confirmResult
|
|
143
|
+
.asObservable()
|
|
144
|
+
.pipe(take(1));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Utilize este método para mostrar na tela um modal que não tem fundo branco, bordas e
|
|
149
|
+
* backdrop (no quesito sair do modal)
|
|
150
|
+
*
|
|
151
|
+
* O modal também vai estar centralizado no meio da tela (verticalmente e horizontalmente).
|
|
152
|
+
* @param elemento Elemento a ser mostrado na tela.
|
|
153
|
+
* @param id Id especifico a este modal. Opcional.
|
|
154
|
+
* @returns Referencia ao modal mostrado na tela.
|
|
155
|
+
*/
|
|
156
|
+
showModalLoading(elemento: TemplateRef<any> | (new (...args: any[]) => unknown), elemID?: string | number, initialState?: Partial<unknown>): BsModalRef {
|
|
157
|
+
|
|
158
|
+
let options: ModalOptions = {
|
|
159
|
+
id: elemID,
|
|
160
|
+
class: "modal-dialog-centered justify-content-center modal-hide-background",
|
|
161
|
+
backdrop: true,
|
|
162
|
+
ignoreBackdropClick: true,
|
|
163
|
+
animated: false,
|
|
164
|
+
initialState: initialState
|
|
165
|
+
} as ModalOptions;
|
|
166
|
+
|
|
167
|
+
return this.bsModalService.show(elemento, options);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<div class="modal-content ">
|
|
2
|
+
<div class="modal-header">
|
|
3
|
+
<h4 class="modal-title">{{ title }}</h4>
|
|
4
|
+
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close" (click)="closeConfirm()">
|
|
5
|
+
<span aria-hidden="true">×</span>
|
|
6
|
+
</button>
|
|
7
|
+
</div>
|
|
8
|
+
<div class="modal-body">
|
|
9
|
+
<h4>{{ message }}</h4>
|
|
10
|
+
|
|
11
|
+
<div class="body-config ">
|
|
12
|
+
<form>
|
|
13
|
+
<fieldset>
|
|
14
|
+
<legend> dados </legend>
|
|
15
|
+
|
|
16
|
+
<div class="input-config" *ngFor="let field of fields ; let i = index" >
|
|
17
|
+
<form>
|
|
18
|
+
<div class="input-group">
|
|
19
|
+
<input type="text" required>
|
|
20
|
+
<span class="highlight"></span>
|
|
21
|
+
<span class="bar"></span>
|
|
22
|
+
<label>{{field}}</label>
|
|
23
|
+
</div>
|
|
24
|
+
</form>
|
|
25
|
+
</div>
|
|
26
|
+
</fieldset>
|
|
27
|
+
</form>
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
</div>
|
|
31
|
+
<div class="modal-footer">
|
|
32
|
+
<button type="button" class="btn btn-primary" (click)="confirm()">{{okText}}</button>
|
|
33
|
+
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" (click)="closeConfirm()">{{ cancelText }}</button>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
.input-config{
|
|
2
|
+
padding: 10px;
|
|
3
|
+
}
|
|
4
|
+
.body-config{
|
|
5
|
+
padding-top: 15px;
|
|
6
|
+
padding-bottom: 20px ;
|
|
7
|
+
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.input-group {
|
|
11
|
+
position: relative;
|
|
12
|
+
margin: 40px 0 20px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
input {
|
|
16
|
+
font-size: 18px;
|
|
17
|
+
padding: 10px 10px 10px 5px;
|
|
18
|
+
display: block;
|
|
19
|
+
width: 300px;
|
|
20
|
+
border: none;
|
|
21
|
+
border-bottom: 1px solid #757575;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
input:focus {
|
|
25
|
+
outline: none;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
label {
|
|
29
|
+
color: #999;
|
|
30
|
+
font-size: 18px;
|
|
31
|
+
font-weight: normal;
|
|
32
|
+
position: absolute;
|
|
33
|
+
pointer-events: none;
|
|
34
|
+
left: 5px;
|
|
35
|
+
top: 10px;
|
|
36
|
+
transition: 0.2s ease all;
|
|
37
|
+
-moz-transition: 0.2s ease all;
|
|
38
|
+
-webkit-transition: 0.2s ease all;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
input:focus ~ label,
|
|
42
|
+
input:valid ~ label {
|
|
43
|
+
top: -20px;
|
|
44
|
+
font-size: 14px;
|
|
45
|
+
color: #5B7CFD;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.bar {
|
|
49
|
+
position: relative;
|
|
50
|
+
display:block;
|
|
51
|
+
width:315px;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.bar:before,
|
|
55
|
+
.bar:after {
|
|
56
|
+
content: '';
|
|
57
|
+
height: 2px;
|
|
58
|
+
width: 0;
|
|
59
|
+
bottom: 0;
|
|
60
|
+
position: absolute;
|
|
61
|
+
background: #5B7CFD;
|
|
62
|
+
transition: 0.2s ease all;
|
|
63
|
+
-moz-transition: 0.2s ease all;
|
|
64
|
+
-webkit-transition: 0.2s ease all;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.bar:before {
|
|
68
|
+
left: 50%;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.bar:after {
|
|
72
|
+
right: 50%;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
input:focus ~ .bar:before,
|
|
76
|
+
input:focus ~ .bar:after {
|
|
77
|
+
width: 50%;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.highlight {
|
|
81
|
+
position: absolute;
|
|
82
|
+
height: 60%;
|
|
83
|
+
width: 100px;
|
|
84
|
+
top: 25%;
|
|
85
|
+
left: 0;
|
|
86
|
+
pointer-events: none;
|
|
87
|
+
opacity: 0.5;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
input:focus ~ .highlight {
|
|
91
|
+
-webkit-animation: inputHighlighter 0.3s ease;
|
|
92
|
+
-moz-animation: inputHighlighter 0.3s ease;
|
|
93
|
+
animation: inputHighlighter 0.3s ease;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* animations */
|
|
97
|
+
@-webkit-keyframes inputHighlighter {
|
|
98
|
+
from { background: #4285f4; }
|
|
99
|
+
to { width: 0; background: transparent; }
|
|
100
|
+
}
|
|
101
|
+
@-moz-keyframes inputHighlighter {
|
|
102
|
+
from { background: #4285f4; }
|
|
103
|
+
to { width: 0; background: transparent; }
|
|
104
|
+
}
|
|
105
|
+
@keyframes inputHighlighter {
|
|
106
|
+
from { background: #4285f4; }
|
|
107
|
+
to { width: 0; background: transparent; }
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Component, Input, OnInit } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
import { Subject } from 'rxjs';
|
|
4
|
+
|
|
5
|
+
import { BsModalRef } from 'ngx-bootstrap/modal';
|
|
6
|
+
|
|
7
|
+
@Component({
|
|
8
|
+
selector: 'app-save',
|
|
9
|
+
templateUrl: './save.component.html',
|
|
10
|
+
styleUrls: ['./save.component.scss'],
|
|
11
|
+
})
|
|
12
|
+
export class SaveComponent implements OnInit {
|
|
13
|
+
@Input() title: string;
|
|
14
|
+
@Input() message: string;
|
|
15
|
+
@Input() cancelText: string = 'Cancelar';
|
|
16
|
+
@Input() okText: string = 'Sim';
|
|
17
|
+
@Input() okButton: Function;
|
|
18
|
+
@Input() fields: string[];
|
|
19
|
+
|
|
20
|
+
confirmResult: Subject<boolean>;
|
|
21
|
+
|
|
22
|
+
constructor(public bsModalRef: BsModalRef) {}
|
|
23
|
+
|
|
24
|
+
ngOnInit(): void {
|
|
25
|
+
this.confirmResult = new Subject();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
confirm() {
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
this.okButton({Id: 15});
|
|
32
|
+
this.confirmAndClose(true);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
closeConfirm() {
|
|
36
|
+
this.confirmAndClose(false);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private confirmAndClose(value: boolean) {
|
|
40
|
+
this.confirmResult.next(value);
|
|
41
|
+
|
|
42
|
+
this.bsModalRef.hide();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modelo de dados para envio de e-mails
|
|
3
|
+
*/
|
|
4
|
+
export class EmailModel {
|
|
5
|
+
public tipoEmail: number = 0;
|
|
6
|
+
public moduloID: number = 0;
|
|
7
|
+
public moduloNome: string = "";
|
|
8
|
+
public adressFrom: string = "";
|
|
9
|
+
public remetenteNome: string = "";
|
|
10
|
+
public adressTo: string = "";
|
|
11
|
+
public adressesCC: string = "";
|
|
12
|
+
public assuntoEmail: string = "";
|
|
13
|
+
public tituloEmail: string = "";
|
|
14
|
+
public corpoEmail: string = "";
|
|
15
|
+
public htmlLinks: string | null = "";
|
|
16
|
+
public anexosList: EmailAnexoRecord[] = [];
|
|
17
|
+
public estabelecimentoID: string | null = "";
|
|
18
|
+
public emailHomologacao: string | null = "";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Modelo de dados para anexos de e-mail
|
|
23
|
+
*/
|
|
24
|
+
export class EmailAnexoRecord {
|
|
25
|
+
/** Base64 do arquivo */
|
|
26
|
+
public File: string = "";
|
|
27
|
+
|
|
28
|
+
/** Nome do arquivo com sua extensão */
|
|
29
|
+
public FileName: string = "";
|
|
30
|
+
|
|
31
|
+
/** Tipo do conteúdo do arquivo */
|
|
32
|
+
public ContentType: string = "";
|
|
33
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Pipe, PipeTransform } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Pipe({
|
|
4
|
+
name: 'cpfCnpj'
|
|
5
|
+
})
|
|
6
|
+
export class CpfCnpjPipe implements PipeTransform {
|
|
7
|
+
|
|
8
|
+
public transform(value: string): string {
|
|
9
|
+
|
|
10
|
+
if (value.length == 11) {
|
|
11
|
+
return `${value.substring(0, 3)}.${value.substring(3, 6)}.${value.substring(6, 9)}-${value.substring(9)}`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
else if (value.length == 14) {
|
|
15
|
+
return `${value.substring(0, 2)}.${value.substring(2, 5)}.${value.substring(5, 8)}/${value.substring(8, 12)}-${value.substring(12)}`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
else return value;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Pipe, PipeTransform } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Pipe({
|
|
4
|
+
name: 'currencyBRL'
|
|
5
|
+
})
|
|
6
|
+
export class CurrencyPipe implements PipeTransform {
|
|
7
|
+
|
|
8
|
+
public transform(value: number): string {
|
|
9
|
+
|
|
10
|
+
return `R$ ${value.toFixed(2).toString().replace('.', ',')}`;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Pipe, PipeTransform } from '@angular/core';
|
|
2
|
+
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @description
|
|
6
|
+
* Transforma um Blob ou MediaSource em uma URL para ser utilizada em imagens.
|
|
7
|
+
*
|
|
8
|
+
* Ela aceita valors não definidos em casos onde o valor vai ser trazido em outro momento.
|
|
9
|
+
*/
|
|
10
|
+
@Pipe(
|
|
11
|
+
{ name: 'toUrl' }
|
|
12
|
+
)
|
|
13
|
+
export class ToUrlPipe implements PipeTransform {
|
|
14
|
+
|
|
15
|
+
constructor(
|
|
16
|
+
private sanitizer: DomSanitizer
|
|
17
|
+
) {}
|
|
18
|
+
|
|
19
|
+
transform(value: Blob | MediaSource | undefined, ...args: unknown[]): SafeUrl {
|
|
20
|
+
|
|
21
|
+
if (value) {
|
|
22
|
+
let url: string = URL.createObjectURL(value);
|
|
23
|
+
// Devemos dizer que a URL passada é segura e pode ser usada.
|
|
24
|
+
// Se não limpada a url vai estar da seguinte forma: [unsafe][blob] ao invés de [blob]
|
|
25
|
+
let safeUrl: SafeUrl = this.sanitizer.bypassSecurityTrustUrl(url);
|
|
26
|
+
return safeUrl;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Se não estiver definida, retorna nada.
|
|
30
|
+
return "";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @description
|
|
5
|
+
*
|
|
6
|
+
* Auxilia na injeção de dados de autenticação em endpoints que necessitam de tal ação.
|
|
7
|
+
*/
|
|
8
|
+
@Injectable(
|
|
9
|
+
{ providedIn: 'root' }
|
|
10
|
+
)
|
|
11
|
+
export class CheckUrlAndMethodService {
|
|
12
|
+
|
|
13
|
+
constructor() { }
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @description
|
|
17
|
+
*
|
|
18
|
+
* Verifica se a url da requisição precisa ou não ser autenticada.
|
|
19
|
+
*
|
|
20
|
+
* É utilizado REGEX para a formatação.
|
|
21
|
+
*
|
|
22
|
+
* @param url URL da requisição que está sendo enviada ou que foi recebida.
|
|
23
|
+
* @param method Método da requisição.
|
|
24
|
+
* @param urls Urls e métodos atrelados aos endpoints.
|
|
25
|
+
* @returns Verdadeiro se deve ser autenticado e falso se não deve.
|
|
26
|
+
*/
|
|
27
|
+
needsAuthRequest(url: string, method: string, urls: Map<string, string[]>): boolean {
|
|
28
|
+
// Adiciona a URL uma barra no final para fazer match.
|
|
29
|
+
let urlToBeVerified = url;
|
|
30
|
+
|
|
31
|
+
// TODO: Remover redundância de / nas URLs.
|
|
32
|
+
let lastUrlChar = urlToBeVerified.charAt(urlToBeVerified.length - 1);
|
|
33
|
+
|
|
34
|
+
if (lastUrlChar !== "/") {
|
|
35
|
+
urlToBeVerified += "/";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let urlsToVerify: IterableIterator<string> = urls.keys();
|
|
39
|
+
|
|
40
|
+
for(let urlToVerify of urlsToVerify) {
|
|
41
|
+
let regexString: string = `${ this.sanitizeForRegex(urlToVerify) }`;
|
|
42
|
+
|
|
43
|
+
// Faz com que o caractere * fique com um ponto para pegar qualquer caractere no regex.
|
|
44
|
+
regexString = regexString.replace("*", ".*");
|
|
45
|
+
|
|
46
|
+
let regexMatch: RegExpMatchArray | null = urlToBeVerified.match(regexString);
|
|
47
|
+
|
|
48
|
+
// Verifica se a url da match no regex construído a partir da url a ser autenticada.
|
|
49
|
+
if (regexMatch && regexMatch.length === 1) {
|
|
50
|
+
|
|
51
|
+
// Verifica se o método da ação necessita de autenticação.
|
|
52
|
+
for(let methodAux of urls.get(urlToVerify)!) {
|
|
53
|
+
methodAux = methodAux.replace("*", ".*");
|
|
54
|
+
|
|
55
|
+
let regexMatchedMethod: RegExpMatchArray | null = method.match(methodAux);
|
|
56
|
+
|
|
57
|
+
if (regexMatchedMethod && regexMatchedMethod.length === 1) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @description
|
|
72
|
+
*
|
|
73
|
+
* Insere caracteres de escape em palavras chaves de um regex.
|
|
74
|
+
*
|
|
75
|
+
* pego de https://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
|
|
76
|
+
*
|
|
77
|
+
* @param unsanitizedString String a ser "limpada".
|
|
78
|
+
* @returns String limpa para uso em regex.
|
|
79
|
+
*/
|
|
80
|
+
private sanitizeForRegex(unsanitizedString: string): string {
|
|
81
|
+
return unsanitizedString.replace(/[.+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { AbstractControl, NgControl, UntypedFormGroup, UntypedFormArray } from '@angular/forms';
|
|
2
|
+
|
|
3
|
+
export class FormUtils {
|
|
4
|
+
|
|
5
|
+
// Verifica se um campo é inválido (Template Driven)
|
|
6
|
+
static isInvalidFieldTemplate(control: NgControl): boolean {
|
|
7
|
+
const ret: any = !control.valid && (control.dirty || control.touched);
|
|
8
|
+
|
|
9
|
+
return (ret ? ret : false)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Verifica se um campo é inválido (Data Driven)
|
|
13
|
+
static isInvalidField(control: AbstractControl | null): boolean {
|
|
14
|
+
return (control ? !control.valid && (control.dirty || control.touched) : false);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Valida todos os campos do formulário
|
|
18
|
+
static validateFields(formGroup: UntypedFormGroup | UntypedFormArray): void {
|
|
19
|
+
Object.keys(formGroup.controls).forEach(field => {
|
|
20
|
+
const control = formGroup.get(field);
|
|
21
|
+
|
|
22
|
+
control?.markAsDirty();
|
|
23
|
+
control?.markAsTouched();
|
|
24
|
+
|
|
25
|
+
if (control instanceof UntypedFormGroup || control instanceof UntypedFormArray) {
|
|
26
|
+
this.validateFields(control);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Obtém a mensagem de erro conforme o validador utilizado
|
|
34
|
+
static getErrorMessage(fieldName: string, validatorName: string, validatorValue?: any): string {
|
|
35
|
+
|
|
36
|
+
const config : any = {
|
|
37
|
+
'required': `${fieldName} é obrigatório.`,
|
|
38
|
+
'minlength': `${fieldName} precisa ter no mínimo ${validatorValue.requiredLength} caracteres.`,
|
|
39
|
+
'maxlength': `${fieldName} precisa ter no máximo ${validatorValue.requiredLength} caracteres.`,
|
|
40
|
+
'min': `${fieldName} precisam ser no mínimo ${validatorValue.min}.`,
|
|
41
|
+
'max': `${fieldName} podem ser no máximo ${validatorValue.max}.`,
|
|
42
|
+
'cpcnpjInvalid': `${fieldName} é inválido.`,
|
|
43
|
+
'cpcnpjInvalidDigit': `${fieldName} com digito inválido.`,
|
|
44
|
+
'incorrect': `O valor de ${fieldName} é inválido.`,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return (config[validatorName] ? config[validatorName] : `${validatorName} não implementado`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { HttpClient } from '@angular/common/http';
|
|
3
|
+
|
|
4
|
+
import { take } from 'rxjs/operators';
|
|
5
|
+
|
|
6
|
+
@Injectable({
|
|
7
|
+
providedIn: 'root'
|
|
8
|
+
})
|
|
9
|
+
export class IpServiceService {
|
|
10
|
+
|
|
11
|
+
constructor( private _httpClient: HttpClient ) { }
|
|
12
|
+
|
|
13
|
+
getIPAddress(): any
|
|
14
|
+
{
|
|
15
|
+
return this._httpClient.get("http://api.ipify.org/?format=json")
|
|
16
|
+
.pipe(
|
|
17
|
+
take(1)
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
}
|