@one-paragon/angular-utilities 2.1.5 → 2.1.7
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/action-state/action-state-spinner/action-state-spinner.component.d.ts +12 -0
- package/action-state/action-state-ui/action-state-ui.module.d.ts +7 -0
- package/{src/action-state/index.ts → action-state/index.d.ts} +4 -8
- package/action-state/ngrx-ext/ngrx-ext.module.d.ts +8 -0
- package/action-state/ngrx.d.ts +31 -0
- package/fesm2022/one-paragon-angular-utilities.mjs +6346 -0
- package/fesm2022/one-paragon-angular-utilities.mjs.map +1 -0
- package/http-request-state/RequestStateFactory.d.ts +17 -0
- package/http-request-state/RequestStateStore.d.ts +101 -0
- package/{src/http-request-state/deprecated.ts → http-request-state/deprecated.d.ts} +20 -20
- package/http-request-state/directives/HttpStateDirectiveBase.d.ts +14 -0
- package/http-request-state/directives/http-error-state-directive.d.ts +9 -0
- package/http-request-state/directives/http-inProgress-state-directive.d.ts +9 -0
- package/http-request-state/directives/http-notStarted-state-directive.d.ts +9 -0
- package/http-request-state/directives/http-success-state-directive.d.ts +16 -0
- package/{src/http-request-state/directives/index.ts → http-request-state/directives/index.d.ts} +5 -5
- package/http-request-state/directives/request-state-directive.d.ts +34 -0
- package/http-request-state/helpers.d.ts +9 -0
- package/http-request-state/http-state-module.d.ts +11 -0
- package/{src/http-request-state/index.ts → http-request-state/index.d.ts} +7 -7
- package/http-request-state/request-state.d.ts +12 -0
- package/http-request-state/rxjs/getRequestorBody.d.ts +3 -0
- package/http-request-state/rxjs/getRequestorState.d.ts +3 -0
- package/{src/http-request-state/rxjs/index.ts → http-request-state/rxjs/index.d.ts} +4 -4
- package/http-request-state/rxjs/tapError.d.ts +3 -0
- package/http-request-state/rxjs/tapSuccess.d.ts +3 -0
- package/http-request-state/types.d.ts +41 -0
- package/index.d.ts +5 -0
- package/ngrx/actionable-selector.d.ts +32 -0
- package/ngrx/index.d.ts +1 -0
- package/package.json +27 -15
- package/{src/public-api.ts → public-api.d.ts} +16 -35
- package/rxjs/defaultShareReplay.d.ts +2 -0
- package/{src/rxjs/index.ts → rxjs/index.d.ts} +5 -5
- package/rxjs/mapError.d.ts +2 -0
- package/rxjs/rxjs-operators.d.ts +13 -0
- package/rxjs/subjectifier.d.ts +10 -0
- package/rxjs/subscriber.directive.d.ts +14 -0
- package/table-builder/classes/DefaultSettings.d.ts +9 -0
- package/table-builder/classes/MatTableObservableDataSource.d.ts +9 -0
- package/table-builder/classes/TableBuilderConfig.d.ts +23 -0
- package/table-builder/classes/TableBuilderDataSource.d.ts +18 -0
- package/table-builder/classes/TableState.d.ts +81 -0
- package/table-builder/classes/data-store.d.ts +8 -0
- package/{src/table-builder/classes/display-col.ts → table-builder/classes/display-col.d.ts} +5 -5
- package/table-builder/classes/filter-info.d.ts +39 -0
- package/table-builder/classes/table-builder-general-settings.d.ts +117 -0
- package/table-builder/classes/table-builder.d.ts +22 -0
- package/table-builder/classes/table-store.d.ts +146 -0
- package/table-builder/classes/table-store.helpers.d.ts +31 -0
- package/table-builder/components/array-column.component.d.ts +15 -0
- package/table-builder/components/column-builder/column-builder.component.d.ts +41 -0
- package/table-builder/components/column-builder/column-helpers.d.ts +38 -0
- package/table-builder/components/column-header-menu/column-header-menu.component.d.ts +50 -0
- package/table-builder/components/date-filter/date-filter.component.d.ts +37 -0
- package/table-builder/components/date-time-filter/date-time-filter.component.d.ts +37 -0
- package/table-builder/components/filter/filter.component.d.ts +48 -0
- package/table-builder/components/filter/in-list/in-list-filter.component.d.ts +23 -0
- package/table-builder/components/gen-col-displayer/gen-col-displayer.component.d.ts +17 -0
- package/table-builder/components/generic-table/generic-table.component.d.ts +84 -0
- package/table-builder/components/generic-table/paginator.component.d.ts +26 -0
- package/table-builder/components/group-by-list/group-by-list.component.d.ts +11 -0
- package/table-builder/components/in-filter/in-filter.component.d.ts +20 -0
- package/{src/table-builder/components/index.ts → table-builder/components/index.d.ts} +9 -9
- package/table-builder/components/initialization-component/initialization-component.d.ts +15 -0
- package/table-builder/components/link-column.component.d.ts +23 -0
- package/table-builder/components/number-filter/number-filter.component.d.ts +39 -0
- package/table-builder/components/profiles-menu/profiles-menu.component.d.ts +33 -0
- package/table-builder/components/reset-menu/reset-menu.component.d.ts +25 -0
- package/table-builder/components/scroll-strategy.d.ts +45 -0
- package/table-builder/components/sort-menu/sort-menu.component-store.d.ts +24 -0
- package/table-builder/components/sort-menu/sort-menu.component.d.ts +19 -0
- package/table-builder/components/table-container/table-container.d.ts +104 -0
- package/table-builder/components/table-container/table-container.helpers/data-state.helpers.d.ts +7 -0
- package/table-builder/components/table-container/table-container.helpers/filter-state.helpers.d.ts +19 -0
- package/table-builder/components/table-container/table-container.helpers/groupBy.helpers.d.ts +19 -0
- package/table-builder/components/table-container/table-container.helpers/meta-data.helpers.d.ts +2 -0
- package/table-builder/components/table-container/table-container.helpers/sort-state.helpers.d.ts +12 -0
- package/table-builder/components/table-container/tableProps.d.ts +10 -0
- package/table-builder/components/table-container/virtual-scroll-container.d.ts +40 -0
- package/table-builder/components/table-container-filter/filter-list/filter-list.component.d.ts +15 -0
- package/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.d.ts +12 -0
- package/table-builder/components/table-container-filter/table-wrapper-filter-store.d.ts +14 -0
- package/table-builder/components/table-header-menu/table-header-menu.component.d.ts +15 -0
- package/table-builder/directives/custom-cell-directive.d.ts +34 -0
- package/{src/table-builder/directives/index.ts → table-builder/directives/index.d.ts} +5 -6
- package/table-builder/directives/multi-sort.directive.d.ts +10 -0
- package/table-builder/directives/resize-column.directive.d.ts +43 -0
- package/table-builder/directives/table-wrapper.directive.d.ts +8 -0
- package/table-builder/directives/tb-filter.directive.d.ts +116 -0
- package/table-builder/enums/filterTypes.d.ts +36 -0
- package/table-builder/functions/boolean-filter-function.d.ts +3 -0
- package/table-builder/functions/date-filter-function.d.ts +4 -0
- package/table-builder/functions/download-data.d.ts +1 -0
- package/table-builder/functions/null-filter-function.d.ts +2 -0
- package/table-builder/functions/number-filter-function.d.ts +4 -0
- package/table-builder/functions/sort-data-function.d.ts +6 -0
- package/table-builder/functions/string-filter-function.d.ts +5 -0
- package/{src/table-builder/interfaces/ColumnInfo.ts → table-builder/interfaces/ColumnInfo.d.ts} +6 -7
- package/{src/table-builder/interfaces/dictionary.ts → table-builder/interfaces/dictionary.d.ts} +3 -3
- package/table-builder/interfaces/report-def.d.ts +171 -0
- package/table-builder/ngrx/tableBuilderStateStore.d.ts +69 -0
- package/table-builder/pipes/column-total.pipe.d.ts +8 -0
- package/table-builder/pipes/format-filter-type.pipe.d.ts +8 -0
- package/table-builder/pipes/format-filter-value.pipe.d.ts +11 -0
- package/table-builder/pipes/key-display.d.ts +9 -0
- package/table-builder/services/export-to-csv.service.d.ts +14 -0
- package/table-builder/services/link-creator.service.d.ts +16 -0
- package/table-builder/services/table-template-service.d.ts +14 -0
- package/table-builder/services/transform-creator.d.ts +7 -0
- package/table-builder/table-builder.module.d.ts +14 -0
- package/utilities/array-helpers.d.ts +1 -0
- package/utilities/directives/auto-focus.directive.d.ts +9 -0
- package/utilities/directives/clickEmitterDirective.d.ts +7 -0
- package/utilities/directives/clickSubject.d.ts +9 -0
- package/utilities/directives/conditional-classes.directive.d.ts +12 -0
- package/utilities/directives/dialog-service.d.ts +10 -0
- package/utilities/directives/dialog.d.ts +45 -0
- package/utilities/directives/mat-toggle-group-directive.d.ts +21 -0
- package/utilities/directives/prevent-enter.directive.d.ts +6 -0
- package/utilities/directives/stop-propagation.directive.d.ts +7 -0
- package/utilities/directives/styler.d.ts +16 -0
- package/utilities/directives/trim-whitespace.directive.d.ts +7 -0
- package/{src/utilities/index.ts → utilities/index.d.ts} +15 -22
- package/utilities/module.d.ts +19 -0
- package/utilities/pipes/function.pipe.d.ts +11 -0
- package/utilities/pipes/phone.pipe.d.ts +8 -0
- package/utilities/pipes/space-case.pipes.d.ts +17 -0
- package/karma.conf.js +0 -44
- package/ng-package.json +0 -7
- package/src/action-state/action-state-spinner/action-state-spinner.component.css +0 -16
- package/src/action-state/action-state-spinner/action-state-spinner.component.html +0 -6
- package/src/action-state/action-state-spinner/action-state-spinner.component.spec.ts +0 -25
- package/src/action-state/action-state-spinner/action-state-spinner.component.ts +0 -25
- package/src/action-state/action-state-ui/action-state-ui.module.ts +0 -13
- package/src/action-state/ngrx-ext/ngrx-ext.module.ts +0 -15
- package/src/action-state/ngrx.ts +0 -69
- package/src/http-request-state/RequestStateFactory.ts +0 -56
- package/src/http-request-state/RequestStateStore.ts +0 -284
- package/src/http-request-state/directives/HttpStateDirectiveBase.ts +0 -29
- package/src/http-request-state/directives/http-error-state-directive.ts +0 -21
- package/src/http-request-state/directives/http-inProgress-state-directive.ts +0 -19
- package/src/http-request-state/directives/http-notStarted-state-directive.ts +0 -19
- package/src/http-request-state/directives/http-success-state-directive.ts +0 -29
- package/src/http-request-state/directives/request-state-directive.spec.ts +0 -73
- package/src/http-request-state/directives/request-state-directive.ts +0 -78
- package/src/http-request-state/helpers.ts +0 -30
- package/src/http-request-state/http-state-module.ts +0 -23
- package/src/http-request-state/models/view-context.ts +0 -18
- package/src/http-request-state/observable.spec.ts +0 -43
- package/src/http-request-state/request-state.ts +0 -69
- package/src/http-request-state/rxjs/getRequestorBody.ts +0 -10
- package/src/http-request-state/rxjs/getRequestorState.ts +0 -8
- package/src/http-request-state/rxjs/tapError.ts +0 -16
- package/src/http-request-state/rxjs/tapSuccess.ts +0 -16
- package/src/http-request-state/strategies.spec.ts +0 -42
- package/src/http-request-state/types.ts +0 -54
- package/src/ngrx/actionable-selector.ts +0 -160
- package/src/ngrx/index.ts +0 -1
- package/src/rxjs/defaultShareReplay.ts +0 -8
- package/src/rxjs/mapError.ts +0 -8
- package/src/rxjs/rxjs-operators.ts +0 -130
- package/src/rxjs/subjectifier.ts +0 -17
- package/src/rxjs/subscriber.directive.ts +0 -57
- package/src/specs/clickSubject.spec.ts +0 -95
- package/src/specs/dialog.spec.ts +0 -101
- package/src/specs/toggleGroupDirective.spec.ts +0 -229
- package/src/table-builder/classes/DefaultSettings.ts +0 -11
- package/src/table-builder/classes/MatTableObservableDataSource.ts +0 -23
- package/src/table-builder/classes/TableBuilderConfig.ts +0 -42
- package/src/table-builder/classes/TableBuilderDataSource.ts +0 -65
- package/src/table-builder/classes/TableState.ts +0 -125
- package/src/table-builder/classes/data-store.ts +0 -10
- package/src/table-builder/classes/filter-info.ts +0 -126
- package/src/table-builder/classes/table-builder-general-settings.ts +0 -198
- package/src/table-builder/classes/table-builder.ts +0 -105
- package/src/table-builder/classes/table-store.helpers.ts +0 -104
- package/src/table-builder/classes/table-store.ts +0 -440
- package/src/table-builder/components/array-column.component.ts +0 -34
- package/src/table-builder/components/column-builder/column-builder.component.html +0 -73
- package/src/table-builder/components/column-builder/column-builder.component.scss +0 -43
- package/src/table-builder/components/column-builder/column-builder.component.spec.ts +0 -49
- package/src/table-builder/components/column-builder/column-builder.component.ts +0 -129
- package/src/table-builder/components/column-builder/column-helpers.ts +0 -54
- package/src/table-builder/components/column-header-menu/column-header-menu.component.html +0 -109
- package/src/table-builder/components/column-header-menu/column-header-menu.component.scss +0 -97
- package/src/table-builder/components/column-header-menu/column-header-menu.component.ts +0 -94
- package/src/table-builder/components/date-filter/date-filter.component.html +0 -23
- package/src/table-builder/components/date-filter/date-filter.component.ts +0 -22
- package/src/table-builder/components/date-time-filter/date-time-filter.component.html +0 -9
- package/src/table-builder/components/date-time-filter/date-time-filter.component.ts +0 -20
- package/src/table-builder/components/filter/filter.component.html +0 -103
- package/src/table-builder/components/filter/filter.component.scss +0 -60
- package/src/table-builder/components/filter/filter.component.spec.ts +0 -87
- package/src/table-builder/components/filter/filter.component.ts +0 -64
- package/src/table-builder/components/filter/in-list/in-list-filter.component.ts +0 -85
- package/src/table-builder/components/gen-col-displayer/gen-col-displayer.component.html +0 -60
- package/src/table-builder/components/gen-col-displayer/gen-col-displayer.component.scss +0 -57
- package/src/table-builder/components/gen-col-displayer/gen-col-displayer.component.ts +0 -44
- package/src/table-builder/components/generic-table/generic-table.component.html +0 -96
- package/src/table-builder/components/generic-table/generic-table.component.scss +0 -38
- package/src/table-builder/components/generic-table/generic-table.component.ts +0 -399
- package/src/table-builder/components/generic-table/paginator.component.ts +0 -106
- package/src/table-builder/components/group-by-list/group-by-list.component.css +0 -17
- package/src/table-builder/components/group-by-list/group-by-list.component.html +0 -14
- package/src/table-builder/components/group-by-list/group-by-list.component.spec.ts +0 -23
- package/src/table-builder/components/group-by-list/group-by-list.component.ts +0 -18
- package/src/table-builder/components/in-filter/in-filter.component.css +0 -3
- package/src/table-builder/components/in-filter/in-filter.component.html +0 -19
- package/src/table-builder/components/in-filter/in-filter.component.ts +0 -65
- package/src/table-builder/components/initialization-component/initialization-component.html +0 -78
- package/src/table-builder/components/initialization-component/initialization-component.ts +0 -27
- package/src/table-builder/components/link-column.component.ts +0 -42
- package/src/table-builder/components/number-filter/number-filter.component.css +0 -10
- package/src/table-builder/components/number-filter/number-filter.component.html +0 -22
- package/src/table-builder/components/number-filter/number-filter.component.spec.ts +0 -30
- package/src/table-builder/components/number-filter/number-filter.component.ts +0 -25
- package/src/table-builder/components/profiles-menu/profiles-menu.component.html +0 -76
- package/src/table-builder/components/profiles-menu/profiles-menu.component.scss +0 -126
- package/src/table-builder/components/profiles-menu/profiles-menu.component.spec.ts +0 -23
- package/src/table-builder/components/profiles-menu/profiles-menu.component.ts +0 -63
- package/src/table-builder/components/reset-menu/reset-menu.component.css +0 -3
- package/src/table-builder/components/reset-menu/reset-menu.component.html +0 -10
- package/src/table-builder/components/reset-menu/reset-menu.component.ts +0 -87
- package/src/table-builder/components/scroll-strategy.ts +0 -139
- package/src/table-builder/components/sort-menu/sort-menu.component-store.ts +0 -57
- package/src/table-builder/components/sort-menu/sort-menu.component.html +0 -109
- package/src/table-builder/components/sort-menu/sort-menu.component.scss +0 -119
- package/src/table-builder/components/sort-menu/sort-menu.component.ts +0 -88
- package/src/table-builder/components/table-container/table-container.helpers/data-state.helpers.ts +0 -112
- package/src/table-builder/components/table-container/table-container.helpers/filter-state.helpers.ts +0 -125
- package/src/table-builder/components/table-container/table-container.helpers/groupBy.helpers.ts +0 -120
- package/src/table-builder/components/table-container/table-container.helpers/meta-data.helpers.ts +0 -16
- package/src/table-builder/components/table-container/table-container.helpers/sort-state.helpers.ts +0 -47
- package/src/table-builder/components/table-container/table-container.html +0 -79
- package/src/table-builder/components/table-container/table-container.scss +0 -47
- package/src/table-builder/components/table-container/table-container.ts +0 -403
- package/src/table-builder/components/table-container/tableProps.ts +0 -18
- package/src/table-builder/components/table-container/virtual-scroll-container.ts +0 -216
- package/src/table-builder/components/table-container-filter/filter-list/filter-list.component.html +0 -34
- package/src/table-builder/components/table-container-filter/filter-list/filter-list.component.ts +0 -44
- package/src/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.css +0 -42
- package/src/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.html +0 -11
- package/src/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.spec.ts +0 -85
- package/src/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.ts +0 -36
- package/src/table-builder/components/table-container-filter/table-wrapper-filter-store.ts +0 -23
- package/src/table-builder/components/table-header-menu/table-header-menu.component.css +0 -21
- package/src/table-builder/components/table-header-menu/table-header-menu.component.html +0 -48
- package/src/table-builder/components/table-header-menu/table-header-menu.component.ts +0 -35
- package/src/table-builder/directives/custom-cell-directive.ts +0 -59
- package/src/table-builder/directives/multi-sort.directive.spec.ts +0 -124
- package/src/table-builder/directives/multi-sort.directive.ts +0 -50
- package/src/table-builder/directives/resize-column.directive.ts +0 -107
- package/src/table-builder/directives/table-wrapper.directive.ts +0 -13
- package/src/table-builder/directives/tb-filter.directive.ts +0 -376
- package/src/table-builder/enums/filterTypes.ts +0 -40
- package/src/table-builder/functions/boolean-filter-function.ts +0 -12
- package/src/table-builder/functions/date-filter-function.ts +0 -68
- package/src/table-builder/functions/download-data.ts +0 -11
- package/src/table-builder/functions/null-filter-function.ts +0 -9
- package/src/table-builder/functions/number-filter-function.ts +0 -41
- package/src/table-builder/functions/sort-data-function.ts +0 -80
- package/src/table-builder/functions/string-filter-function.ts +0 -51
- package/src/table-builder/interfaces/column-template.ts +0 -9
- package/src/table-builder/interfaces/report-def.ts +0 -186
- package/src/table-builder/ngrx/tableBuilderStateStore.ts +0 -197
- package/src/table-builder/pipes/column-total.pipe.ts +0 -16
- package/src/table-builder/pipes/format-filter-type.pipe.ts +0 -12
- package/src/table-builder/pipes/format-filter-value.pipe.ts +0 -40
- package/src/table-builder/pipes/key-display.ts +0 -13
- package/src/table-builder/services/export-to-csv.service.ts +0 -75
- package/src/table-builder/services/link-creator.service.ts +0 -98
- package/src/table-builder/services/table-template-service.ts +0 -47
- package/src/table-builder/services/transform-creator.ts +0 -96
- package/src/table-builder/specs/table-custom-filters.spec.ts +0 -262
- package/src/table-builder/styles/collapser.styles.scss +0 -16
- package/src/table-builder/table-builder.module.ts +0 -38
- package/src/test.ts +0 -17
- package/src/utilities/array-helpers.ts +0 -13
- package/src/utilities/directives/auto-focus.directive.ts +0 -20
- package/src/utilities/directives/clickEmitterDirective.ts +0 -15
- package/src/utilities/directives/clickSubject.ts +0 -19
- package/src/utilities/directives/conditional-classes.directive.ts +0 -36
- package/src/utilities/directives/dialog-service.ts +0 -19
- package/src/utilities/directives/dialog.ts +0 -144
- package/src/utilities/directives/mat-toggle-group-directive.ts +0 -60
- package/src/utilities/directives/prevent-enter.directive.ts +0 -12
- package/src/utilities/directives/stop-propagation.directive.ts +0 -19
- package/src/utilities/directives/styler.ts +0 -44
- package/src/utilities/directives/trim-whitespace.directive.ts +0 -20
- package/src/utilities/module.ts +0 -55
- package/src/utilities/pipes/function.pipe.ts +0 -21
- package/src/utilities/pipes/phone.pipe.ts +0 -20
- package/src/utilities/pipes/space-case.pipes.spec.ts +0 -47
- package/src/utilities/pipes/space-case.pipes.ts +0 -26
- package/tsconfig.lib.json +0 -20
- package/tsconfig.lib.prod.json +0 -10
- package/tsconfig.spec.json +0 -17
package/karma.conf.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// Karma configuration file, see link for more information
|
|
2
|
-
// https://karma-runner.github.io/1.0/config/configuration-file.html
|
|
3
|
-
|
|
4
|
-
module.exports = function (config) {
|
|
5
|
-
config.set({
|
|
6
|
-
basePath: '',
|
|
7
|
-
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
|
8
|
-
plugins: [
|
|
9
|
-
require('karma-jasmine'),
|
|
10
|
-
require('karma-chrome-launcher'),
|
|
11
|
-
require('karma-jasmine-html-reporter'),
|
|
12
|
-
require('karma-coverage'),
|
|
13
|
-
require('@angular-devkit/build-angular/plugins/karma')
|
|
14
|
-
],
|
|
15
|
-
client: {
|
|
16
|
-
jasmine: {
|
|
17
|
-
// you can add configuration options for Jasmine here
|
|
18
|
-
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
|
|
19
|
-
// for example, you can disable the random execution with `random: false`
|
|
20
|
-
// or set a specific seed with `seed: 4321`
|
|
21
|
-
},
|
|
22
|
-
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
|
23
|
-
},
|
|
24
|
-
jasmineHtmlReporter: {
|
|
25
|
-
suppressAll: true // removes the duplicated traces
|
|
26
|
-
},
|
|
27
|
-
coverageReporter: {
|
|
28
|
-
dir: require('path').join(__dirname, '../../coverage/http-request-state'),
|
|
29
|
-
subdir: '.',
|
|
30
|
-
reporters: [
|
|
31
|
-
{ type: 'html' },
|
|
32
|
-
{ type: 'text-summary' }
|
|
33
|
-
]
|
|
34
|
-
},
|
|
35
|
-
reporters: ['progress', 'kjhtml'],
|
|
36
|
-
port: 9876,
|
|
37
|
-
colors: true,
|
|
38
|
-
logLevel: config.LOG_INFO,
|
|
39
|
-
autoWatch: true,
|
|
40
|
-
browsers: ['Chrome'],
|
|
41
|
-
singleRun: false,
|
|
42
|
-
restartOnFileChange: true
|
|
43
|
-
});
|
|
44
|
-
};
|
package/ng-package.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#blocker {
|
|
2
|
-
position:fixed;
|
|
3
|
-
top: 0px;
|
|
4
|
-
left: 0px;
|
|
5
|
-
width:100%;
|
|
6
|
-
height:100%;
|
|
7
|
-
background-color:rgba(14, 13, 13, 0.411);
|
|
8
|
-
z-index:999999;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.spinner{
|
|
12
|
-
position: absolute;
|
|
13
|
-
top:50%;
|
|
14
|
-
left:40%;
|
|
15
|
-
transform: translate(-50%, -50%);
|
|
16
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
|
|
3
|
-
import { ActionStateSpinnerComponent } from './action-state-spinner.component';
|
|
4
|
-
|
|
5
|
-
describe('ActionStateSpinnerComponent', () => {
|
|
6
|
-
let component: ActionStateSpinnerComponent;
|
|
7
|
-
let fixture: ComponentFixture<ActionStateSpinnerComponent>;
|
|
8
|
-
|
|
9
|
-
beforeEach(async(() => {
|
|
10
|
-
TestBed.configureTestingModule({
|
|
11
|
-
declarations: [ ActionStateSpinnerComponent ]
|
|
12
|
-
})
|
|
13
|
-
.compileComponents();
|
|
14
|
-
}));
|
|
15
|
-
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
fixture = TestBed.createComponent(ActionStateSpinnerComponent);
|
|
18
|
-
component = fixture.componentInstance;
|
|
19
|
-
fixture.detectChanges();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('should create', () => {
|
|
23
|
-
expect(component).toBeTruthy();
|
|
24
|
-
});
|
|
25
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Component, OnInit, Input } from '@angular/core';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { ActionStatus, serverStatusTypes } from '../ngrx';
|
|
4
|
-
import { delayOn } from '../../rxjs';
|
|
5
|
-
import { AsyncPipe } from '@angular/common';
|
|
6
|
-
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
|
7
|
-
|
|
8
|
-
@Component({
|
|
9
|
-
selector: 'lib-action-state-spinner',
|
|
10
|
-
templateUrl: './action-state-spinner.component.html',
|
|
11
|
-
styleUrls: ['./action-state-spinner.component.css'],
|
|
12
|
-
imports: [AsyncPipe, MatProgressSpinnerModule]
|
|
13
|
-
})
|
|
14
|
-
export class ActionStateSpinnerComponent implements OnInit {
|
|
15
|
-
|
|
16
|
-
@Input() status$!: Observable<ActionStatus>;
|
|
17
|
-
serverActionStatus$!: Observable<ActionStatus>;
|
|
18
|
-
serverStatusTypes = serverStatusTypes;
|
|
19
|
-
|
|
20
|
-
ngOnInit() {
|
|
21
|
-
this.serverActionStatus$ = this.status$.pipe(
|
|
22
|
-
delayOn( a => a.status === serverStatusTypes.inProgress , 500)
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { NgModule } from '@angular/core';
|
|
2
|
-
import { ActionStateSpinnerComponent } from '../action-state-spinner/action-state-spinner.component';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
@NgModule({
|
|
6
|
-
imports: [
|
|
7
|
-
ActionStateSpinnerComponent,
|
|
8
|
-
],
|
|
9
|
-
exports: [
|
|
10
|
-
ActionStateSpinnerComponent,
|
|
11
|
-
]
|
|
12
|
-
})
|
|
13
|
-
export class ActionStateUiModule { }
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { NgModule } from '@angular/core';
|
|
2
|
-
import { CommonModule } from '@angular/common';
|
|
3
|
-
import { actionStatusReducer } from '../ngrx';
|
|
4
|
-
import { StoreModule } from '@ngrx/store';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
@NgModule({
|
|
9
|
-
declarations: [],
|
|
10
|
-
imports: [
|
|
11
|
-
CommonModule,
|
|
12
|
-
StoreModule.forFeature('ActionStatus', actionStatusReducer),
|
|
13
|
-
]
|
|
14
|
-
})
|
|
15
|
-
export class NgrxExtModule { }
|
package/src/action-state/ngrx.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { Action, createFeatureSelector, createSelector } from '@ngrx/store';
|
|
2
|
-
import { createEntityAdapter, EntityState } from '@ngrx/entity';
|
|
3
|
-
import { get } from 'lodash';
|
|
4
|
-
|
|
5
|
-
// State
|
|
6
|
-
export class AppStatusState {
|
|
7
|
-
readonly ActionStatusBar!: ActionStatus[];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface StatusState {
|
|
11
|
-
ids: string[];
|
|
12
|
-
entities: {[id: string]: ActionStatus};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export class ActionStatus {
|
|
16
|
-
id!: string;
|
|
17
|
-
displayName?: string;
|
|
18
|
-
status!: serverStatusTypes;
|
|
19
|
-
responsePayload?: any;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const InitialState: StatusState = {
|
|
23
|
-
ids: [],
|
|
24
|
-
entities: {}
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export enum serverStatusTypes {
|
|
28
|
-
notStarted = 0,
|
|
29
|
-
inProgress = 1,
|
|
30
|
-
success = 2,
|
|
31
|
-
error = 3
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Entity and Selectors
|
|
35
|
-
export const statusAdapter = createEntityAdapter<ActionStatus>();
|
|
36
|
-
export interface State extends EntityState<ActionStatus> {}
|
|
37
|
-
export const initialState: StatusState = statusAdapter.getInitialState(InitialState);
|
|
38
|
-
|
|
39
|
-
export const getStatusState = createFeatureSelector<State>('ActionStatus');
|
|
40
|
-
export const {
|
|
41
|
-
selectIds,
|
|
42
|
-
selectEntities,
|
|
43
|
-
selectAll,
|
|
44
|
-
selectTotal
|
|
45
|
-
} = statusAdapter.getSelectors(getStatusState);
|
|
46
|
-
|
|
47
|
-
export const selectEntity = (id: string) => createSelector(
|
|
48
|
-
selectEntities,
|
|
49
|
-
(entities: any) => entities[id]
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
// Reducers
|
|
53
|
-
export function actionStatusReducer(state: StatusState = initialState, action: Action) {
|
|
54
|
-
|
|
55
|
-
const actionStatus: ActionStatus = get(action, 'payload.actionStatus' ) as any;
|
|
56
|
-
|
|
57
|
-
if ( actionStatus ) {
|
|
58
|
-
if ( state.ids.find(id => id === actionStatus.id) ) {
|
|
59
|
-
const modifiedObj = {...state.entities[actionStatus.id] };
|
|
60
|
-
modifiedObj.status = actionStatus.status;
|
|
61
|
-
modifiedObj.responsePayload = actionStatus.responsePayload;
|
|
62
|
-
return statusAdapter.upsertOne( modifiedObj, state);
|
|
63
|
-
} else {
|
|
64
|
-
return statusAdapter.addOne(actionStatus , state);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
return state;
|
|
69
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Injectable, Injector, OnDestroy, assertInInjectionContext, inject, runInInjectionContext } from "@angular/core";
|
|
2
|
-
import { RequestFactory, RequestStateOptions, RequestCreatorOptions } from "./types";
|
|
3
|
-
import { RequestStateStore } from './RequestStateStore';
|
|
4
|
-
import { Observable } from "rxjs";
|
|
5
|
-
|
|
6
|
-
@Injectable()
|
|
7
|
-
export class RequestStateFactory implements OnDestroy {
|
|
8
|
-
|
|
9
|
-
constructor() {}
|
|
10
|
-
ngOnDestroy(): void {
|
|
11
|
-
this.requestors.forEach( request => request.destroy());
|
|
12
|
-
}
|
|
13
|
-
private requestors: RequestStateStore<any, any, any>[] = [];
|
|
14
|
-
|
|
15
|
-
create<TParam extends any[], V>( req: RequestFactory<TParam, V>, options?: RequestStateOptions<TParam>) : RequestStateStore<TParam, V>
|
|
16
|
-
create<TParam extends any[], V, R, T = R>( req: RequestFactory<TParam, V>, project: (v: V) => R , options?: RequestStateOptions<TParam>) : RequestStateStore<TParam, V, T>
|
|
17
|
-
create<TParam extends any[], V, R = null, T = R extends null ? V : R>(req: RequestFactory<TParam, V>, optionsOrProject?: RequestStateOptions<TParam> | ((v: V) => R), options?: RequestStateOptions<TParam> ) : RequestStateStore<TParam, V, R, T> {
|
|
18
|
-
const requestor = (typeof(optionsOrProject) === 'function' ? new RequestStateStore<TParam, V, R, T>(req, options, optionsOrProject) : new RequestStateStore<TParam, V, R, T>(req, optionsOrProject));
|
|
19
|
-
this.requestors.push(requestor);
|
|
20
|
-
return requestor;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
createHttpClient<T>( r: (o: Observable<T> ) => Observable<T> , options?: RequestStateOptions<any> ) {
|
|
24
|
-
const requestor = new RequestStateStore(r, options);
|
|
25
|
-
this.requestors.push(requestor);
|
|
26
|
-
return requestor;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function createRequestor<TParam extends any[], V>( req: RequestFactory<TParam, V>, options?: RequestCreatorOptions<TParam>) : RequestStateStore<TParam, V>
|
|
31
|
-
export function createRequestor<TParam extends any[], V, R, T = R>( req: RequestFactory<TParam, V>, project: (v: V) => R , options?: RequestCreatorOptions<TParam>) : RequestStateStore<TParam, V, T>
|
|
32
|
-
export function createRequestor<TParam extends any[], V, R = null, T = R extends null ? V : R>( req: RequestFactory<TParam, V>, optionsOrProject?: RequestCreatorOptions<TParam> | ((v: V) => R), options?: RequestCreatorOptions<TParam> ) : RequestStateStore<TParam, V, R, T>{
|
|
33
|
-
const ops = typeof(optionsOrProject) === 'function' ? options : optionsOrProject;
|
|
34
|
-
const injector = getInjector(ops);
|
|
35
|
-
return runInInjectionContext(injector, () => {
|
|
36
|
-
const requestStore = typeof(optionsOrProject) === 'function' ?
|
|
37
|
-
new RequestStateStore<TParam, V, R, T>(req, options, optionsOrProject)
|
|
38
|
-
: new RequestStateStore<TParam, V, R, T>(req, optionsOrProject);
|
|
39
|
-
|
|
40
|
-
return requestStore;
|
|
41
|
-
})
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function getInjector(options?: RequestCreatorOptions<any>){
|
|
45
|
-
const providedInjector = options?.injector;
|
|
46
|
-
|
|
47
|
-
if(!providedInjector){
|
|
48
|
-
try {
|
|
49
|
-
assertInInjectionContext(createRequestor);
|
|
50
|
-
} catch (error) {
|
|
51
|
-
throw new Error('createRequestor() must be used in an Injection Context or you must provide an injector to createRequestor()');
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return providedInjector ?? inject(Injector);
|
|
56
|
-
}
|
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
import { combineLatest, Observable, of, pipe, Subject, Subscription } from 'rxjs';
|
|
2
|
-
import { RequestFactory as RequestFactory, RequestStrategy as RequestStrategy, RequestStatus, RequestState, RequestStateOptions, RequestStateCancelled } from './types';
|
|
3
|
-
import { createFailure, createSuccess, inProgress, isErrorState, isSuccessOrErrorState, isSuccessState, notStarted } from './helpers';
|
|
4
|
-
import { concatMap, filter, map, mergeMap, startWith, switchMap, takeUntil, tap } from 'rxjs/operators';
|
|
5
|
-
import { HttpErrorResponse } from '@angular/common/http';
|
|
6
|
-
import { mapError } from '../rxjs/mapError';
|
|
7
|
-
import { defaultShareReplay } from '../rxjs/defaultShareReplay';
|
|
8
|
-
import { assertInInjectionContext, computed, DestroyRef, inject, InjectionToken, Injector, isSignal, signal, Signal } from '@angular/core';
|
|
9
|
-
import { toObservable } from '@angular/core/rxjs-interop';
|
|
10
|
-
import { notNull } from '../rxjs';
|
|
11
|
-
|
|
12
|
-
export interface RequestResponse<TParam extends any[], T> {
|
|
13
|
-
requestParams: [...TParam];
|
|
14
|
-
response: RequestState<T>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class RequestStateStore<TParam extends any[], V, R = null, T = R extends null ? V : R> {
|
|
18
|
-
private _state = signal<RequestResponse<TParam, T>>({ requestParams: null as any, response: notStarted });
|
|
19
|
-
private setState = (state: RequestResponse<TParam, T>) => this._state.set(state);
|
|
20
|
-
state = this._state.asReadonly();
|
|
21
|
-
state$ = toObservable(this.state);
|
|
22
|
-
private options?: RequestStateOptions;
|
|
23
|
-
private project?: (v: V) => R;
|
|
24
|
-
private req: RequestFactory<TParam, V>;
|
|
25
|
-
private injector = inject(Injector)
|
|
26
|
-
private destroy$ = new Subject<void>();
|
|
27
|
-
private defaultErrorHandling?: (e?: any) => void;
|
|
28
|
-
private _useDefaultErrorHandler?: boolean;
|
|
29
|
-
private defaultSuccessHandling?: (e?: T) => void;
|
|
30
|
-
|
|
31
|
-
constructor(req: RequestFactory<TParam, V> ,options?: RequestStateOptions<TParam>, project?: (v: V) => R) {
|
|
32
|
-
this.assertInjectionContext();
|
|
33
|
-
this.injector.get(DestroyRef).onDestroy(() => this.destroy$.next());
|
|
34
|
-
|
|
35
|
-
this.project = project;
|
|
36
|
-
this.options = options;
|
|
37
|
-
this.req = req;
|
|
38
|
-
|
|
39
|
-
const config = inject(RequestStateStoreConfigToken, { optional: true});
|
|
40
|
-
if(config){
|
|
41
|
-
this.defaultErrorHandling = config.defaultErrorHandling;
|
|
42
|
-
this._useDefaultErrorHandler = config.useDefaultErrorHandler;
|
|
43
|
-
this.defaultSuccessHandling = config.defaultSuccessHandling;
|
|
44
|
-
|
|
45
|
-
if(this._useDefaultErrorHandler){
|
|
46
|
-
this.subscriber(this.selectError$, e => {
|
|
47
|
-
if(!this.errorHandled){
|
|
48
|
-
this.#onDefaultErrorHandling(e);
|
|
49
|
-
}
|
|
50
|
-
})
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
this.request = (this.options?.strategy === RequestStrategy.singleUse) ? this.singleUseRequest : this.flattenedRequest;
|
|
55
|
-
if(options?.autoRequest){
|
|
56
|
-
(this.request as any)();
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
reset() {
|
|
61
|
-
this._state.set({ requestParams:null as any, response: notStarted });
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
private flatteningStrategy = () => {
|
|
65
|
-
if(this.options?.strategy === RequestStrategy.concurrent)
|
|
66
|
-
return mergeMap( (params: [...TParam]) => this.createRequest(...params));
|
|
67
|
-
|
|
68
|
-
if(this.options?.strategy === RequestStrategy.sequential)
|
|
69
|
-
return concatMap( (params: [...TParam]) => this.createRequest(...params));
|
|
70
|
-
|
|
71
|
-
return switchMap( (params: [...TParam]) => ((params[0] as any) instanceof CancellationToken) ?
|
|
72
|
-
of({ requestParams: params[0], response: { status: RequestStatus.cancelled } as RequestStateCancelled } ) : this.createRequest(...params) );
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
private createRequestPipeline = () => {
|
|
76
|
-
const origin$ = new Subject<[...TParam]>();
|
|
77
|
-
const sub = origin$.pipe(
|
|
78
|
-
this.flatteningStrategy(),
|
|
79
|
-
tap<RequestResponse<TParam, T>>(state => this.setState(state)),
|
|
80
|
-
pipe(takeUntil(this.destroy$))
|
|
81
|
-
).subscribe();
|
|
82
|
-
return (params: [...TParam]) => {
|
|
83
|
-
origin$.next(params);
|
|
84
|
-
return sub;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
private requestPipeLine = this.createRequestPipeline();
|
|
89
|
-
|
|
90
|
-
private flattenedRequest = (...value: [...TParam]) => {
|
|
91
|
-
return this.requestPipeLine(value);
|
|
92
|
-
}
|
|
93
|
-
private singleUseRequest = (...value: [...TParam]) => {
|
|
94
|
-
if (this.state().response.status !== RequestStatus.notStarted) {
|
|
95
|
-
throw new Error("state can not be reused. either reset the state by calling reset() or use a state requester that allows concurrent requests.");
|
|
96
|
-
}
|
|
97
|
-
return this.requestPipeLine(value);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
$selectRequestState = computed(() => this.state().response);
|
|
101
|
-
selectRequestState$ = this.state$.pipe(map(s => s.response));
|
|
102
|
-
/**
|
|
103
|
-
* @deprecated use selectRequestState$ instead
|
|
104
|
-
*/
|
|
105
|
-
selectHttpState$ = this.selectRequestState$;
|
|
106
|
-
$selectStatus = computed(() => this.$selectRequestState()?.status);
|
|
107
|
-
selectStatus$ = this.selectRequestState$.pipe(map(s => s.status));
|
|
108
|
-
$isSuccess = computed(() => isSuccessState(this.$selectRequestState()));
|
|
109
|
-
$isError = computed(() => isErrorState(this.$selectRequestState()));
|
|
110
|
-
$isInProgress = computed(() => this.$selectStatus() === RequestStatus.inProgress);
|
|
111
|
-
$isNotStarted = computed(() => this.$selectStatus() === RequestStatus.notStarted);
|
|
112
|
-
|
|
113
|
-
selectError$ = this.selectRequestState$.pipe(
|
|
114
|
-
filter(isErrorState),
|
|
115
|
-
map(state => state.error)
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
$selectError = computed(() => {
|
|
119
|
-
const state = this.$selectRequestState();
|
|
120
|
-
if(isErrorState(state)) return state.error
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
selectResponse$: Observable<T> = this.selectRequestState$.pipe(
|
|
124
|
-
filter(isSuccessState),
|
|
125
|
-
map( state => state.body)
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
$selectResponse = computed(() => {
|
|
129
|
-
const state = this.$selectRequestState();
|
|
130
|
-
if(isSuccessState(state)){
|
|
131
|
-
return state.body
|
|
132
|
-
}
|
|
133
|
-
return undefined;
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
private selectSuccessOrError$: Observable<void> = this.state$.pipe(
|
|
137
|
-
map(r => r.response),
|
|
138
|
-
filter(isSuccessOrErrorState),
|
|
139
|
-
map(() => undefined)
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
errorHandled = false;
|
|
143
|
-
onError( cb: (error: HttpErrorResponse) => void) {
|
|
144
|
-
this.errorHandled = true;
|
|
145
|
-
this.subscriber(this.selectError$, cb);
|
|
146
|
-
return this;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
#onDefaultErrorHandling = (e: any) => {
|
|
150
|
-
if(this.defaultErrorHandling) this.defaultErrorHandling(e)
|
|
151
|
-
else console.error(e)
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* if no handler was provided will call `console.error`
|
|
155
|
-
*/
|
|
156
|
-
useDefaultErrorHandler(){
|
|
157
|
-
this.subscriber(this.selectError$, this.#onDefaultErrorHandling);
|
|
158
|
-
return this;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* if no handler was provided will call `console.log` with 'Success'
|
|
163
|
-
*/
|
|
164
|
-
useDefaultSuccessHandler(){
|
|
165
|
-
this.subscriber(this.selectResponse$, this.defaultSuccessHandling || (() => console.log('Success')));
|
|
166
|
-
return this;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
onSuccess( cb: (body?: T) => void) {
|
|
170
|
-
this.subscriber(this.selectResponse$, cb);
|
|
171
|
-
return this;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
onSuccessOrError(cb: () => void){
|
|
175
|
-
this.subscriber(this.selectSuccessOrError$, cb);
|
|
176
|
-
return this;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
onSuccessWithRequest(
|
|
180
|
-
func: (state: { requestParams: [...TParam]; body: T; }) => void
|
|
181
|
-
) {
|
|
182
|
-
this.subscriber(this.state$,
|
|
183
|
-
({ requestParams, response }) => {
|
|
184
|
-
|
|
185
|
-
if(isSuccessState(response)) func({requestParams,body: response.body});
|
|
186
|
-
}
|
|
187
|
-
);
|
|
188
|
-
return this;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
onErrorWithRequest(
|
|
192
|
-
func: (state: { error: HttpErrorResponse; requestParams: [...TParam]; }) => void
|
|
193
|
-
) {
|
|
194
|
-
this.errorHandled = true;
|
|
195
|
-
this.subscriber(this.state$,
|
|
196
|
-
({ requestParams, response }) => {
|
|
197
|
-
|
|
198
|
-
if(isErrorState(response)) func({ requestParams, error: response.error });
|
|
199
|
-
}
|
|
200
|
-
);
|
|
201
|
-
|
|
202
|
-
return this;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
private createRequest(...params: [...TParam]): Observable<RequestResponse<TParam, T>> {
|
|
206
|
-
return this.req(...params).pipe(
|
|
207
|
-
map(re => createSuccess((this.project ? this.project(re) : re) as T)),
|
|
208
|
-
mapError(createFailure),
|
|
209
|
-
startWith(inProgress),
|
|
210
|
-
map( state => ({ requestParams: params, response: state })),
|
|
211
|
-
defaultShareReplay()
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
private subscriber = <V>(srcObservable: Observable<V>, func: (obj: V) => void): Subscription => {
|
|
216
|
-
return srcObservable.pipe(tap(func), takeUntil(this.destroy$)).subscribe();
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* @deprecated use the standalone subscriber helper function
|
|
221
|
-
*/
|
|
222
|
-
on = this.subscriber;
|
|
223
|
-
request: (...value: [...TParam] ) => Subscription;
|
|
224
|
-
|
|
225
|
-
requestWith = (params: Observable<[...TParam]> | Signal<[...TParam]>) => {
|
|
226
|
-
if(isSignal(params)){
|
|
227
|
-
params = toObservable(params, { injector: this.injector }).pipe(notNull());
|
|
228
|
-
}
|
|
229
|
-
params.pipe(takeUntil(this.destroy$)).subscribe((p) => this.request(...p));
|
|
230
|
-
return this;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
private assertInjectionContext(){
|
|
234
|
-
try {
|
|
235
|
-
assertInInjectionContext(RequestStateStore);
|
|
236
|
-
} catch (error) {
|
|
237
|
-
throw new Error('RequestStateStore must be created in an Injection Context');
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
destroy() {
|
|
242
|
-
this.destroy$.next();
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
export class CancellationToken {}
|
|
246
|
-
|
|
247
|
-
export function wrapInArr<T extends [Signal<any>, ...Signal<any>[]]>(...sigs: T) : Signal<{ [K in keyof T]: T[K] extends Signal<infer U> ? U : never }>;
|
|
248
|
-
export function wrapInArr<T extends [Observable<any>, ...Observable<any>[]]>(...obs: T): Observable<{ [K in keyof T]: T[K] extends Observable<infer U> ? U : never }>;
|
|
249
|
-
/**
|
|
250
|
-
* If any values from the array of signals or observables are null or undefined, all values will be filtered
|
|
251
|
-
*/
|
|
252
|
-
export function wrapInArr<T extends Signal<any>[] | Observable<any>[]>(...sigOrObs: T){
|
|
253
|
-
if(isSignal(sigOrObs[0])){
|
|
254
|
-
return computed(() => {
|
|
255
|
-
const arr = (sigOrObs as Signal<T>[]).map(s => s()) as { [K in keyof T]: T[K] extends Signal<infer U> ? U : never };
|
|
256
|
-
if(arr.some(s => s == undefined)) return undefined;
|
|
257
|
-
return arr;
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
else {
|
|
261
|
-
return combineLatest(sigOrObs as Observable<any>[]).pipe(filter(vals => vals.every(val=> val != undefined))) as Observable<{ [K in keyof T]: T[K] extends Observable<infer U> ? U : never }>;
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
export interface RequestStateStoreConfig {
|
|
267
|
-
/**
|
|
268
|
-
* if `useDefaultErrorHandler` is `true` this will run on each error if no other handler provided.
|
|
269
|
-
* else can be used by call `.useDefaultHandler`
|
|
270
|
-
*/
|
|
271
|
-
defaultErrorHandling?: (e?: any) => void;
|
|
272
|
-
/**
|
|
273
|
-
* if `useDefaultErrorHandler` is `true` `defaultErrorHandling` will run on each error if no other handler provided.
|
|
274
|
-
*/
|
|
275
|
-
useDefaultErrorHandler?: boolean;
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* will be called if `useDefaultSuccess` is used
|
|
279
|
-
*/
|
|
280
|
-
defaultSuccessHandling?: <T>(e?: T) => void;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
export const RequestStateStoreConfigToken = new InjectionToken<RequestStateStoreConfig>('RequestStateConfig');
|
|
284
|
-
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Directive, inject, Injector, TemplateRef, ViewContainerRef } from '@angular/core';
|
|
2
|
-
import { RequestState } from '../types';
|
|
3
|
-
import { HttpRequestStateDirective } from './request-state-directive';
|
|
4
|
-
|
|
5
|
-
@Directive()
|
|
6
|
-
export abstract class HttpStateDirectiveBase<V, R = null> {
|
|
7
|
-
hasView = false;
|
|
8
|
-
private injector = inject(Injector);
|
|
9
|
-
protected templateRef = inject(TemplateRef<{ $implicit: R extends null ? V : R }>);
|
|
10
|
-
protected viewContainer = inject(ViewContainerRef);
|
|
11
|
-
ngOnInit() {
|
|
12
|
-
const parent = this.injector.get(HttpRequestStateDirective);
|
|
13
|
-
if (parent == null) {
|
|
14
|
-
throw new Error('You can only use an http state directive as a child of the httpRequestState directive.');
|
|
15
|
-
}
|
|
16
|
-
parent.hooks.push(this.baseRender);
|
|
17
|
-
this.baseRender(parent.ViewContext.state);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
private baseRender = (state: RequestState): void => {
|
|
21
|
-
if (this.hasView) {
|
|
22
|
-
this.viewContainer.clear();
|
|
23
|
-
this.hasView = false;
|
|
24
|
-
}
|
|
25
|
-
this.hasView = this.render(state);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
abstract render: (state: RequestState) => boolean;
|
|
29
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Directive } from '@angular/core';
|
|
2
|
-
import { isErrorState } from '../helpers';
|
|
3
|
-
import { RequestState } from '../types';
|
|
4
|
-
import { HttpStateDirectiveBase } from './HttpStateDirectiveBase';
|
|
5
|
-
|
|
6
|
-
@Directive({ selector: '[httpErrorState]', })
|
|
7
|
-
export class HttpErrorStateDirective<V, R = null> extends HttpStateDirectiveBase<V, R> {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
render = (state: RequestState<any>) => {
|
|
11
|
-
if (isErrorState(state)) {
|
|
12
|
-
this.viewContainer.createEmbeddedView(this.templateRef, { $implicit: state.error });
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
return false;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
ngOnInit() {
|
|
19
|
-
super.ngOnInit();
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Directive } from '@angular/core';
|
|
2
|
-
import { HttpStateDirectiveBase } from './HttpStateDirectiveBase';
|
|
3
|
-
import { RequestState, RequestStatus } from '../types'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
@Directive({ selector: '[httpInProgressState]', })
|
|
7
|
-
export class HttpInProgressStateDirective<V, R = null> extends HttpStateDirectiveBase<V, R> {
|
|
8
|
-
render = (state: RequestState<any>) => {
|
|
9
|
-
if(state.status === RequestStatus.inProgress){
|
|
10
|
-
this.viewContainer.createEmbeddedView(this.templateRef );
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
return false;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
ngOnInit() {
|
|
17
|
-
super.ngOnInit();
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Directive } from '@angular/core';
|
|
2
|
-
import { RequestState, RequestStatus } from '../types';
|
|
3
|
-
import { HttpStateDirectiveBase } from './HttpStateDirectiveBase';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
@Directive({ selector: '[httpNotStartedState]', })
|
|
7
|
-
export class HttpNotStartedStateDirective<V, R = null> extends HttpStateDirectiveBase<V, R> {
|
|
8
|
-
render = (state: RequestState<any>) => {
|
|
9
|
-
if(state.status === RequestStatus.notStarted){
|
|
10
|
-
this.viewContainer.createEmbeddedView(this.templateRef );
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
return false;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
ngOnInit() {
|
|
17
|
-
super.ngOnInit();
|
|
18
|
-
}
|
|
19
|
-
}
|