cedar-embeddable-editor 0.9.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/.browserslistrc +18 -0
- package/.editorconfig +16 -0
- package/README.md +302 -0
- package/angular.json +153 -0
- package/cedar-embeddable-editor-0.9.0.tgz +0 -0
- package/e2e/protractor.conf.js +36 -0
- package/e2e/src/app.e2e-spec.ts +23 -0
- package/e2e/src/app.po.ts +11 -0
- package/e2e/tsconfig.json +14 -0
- package/karma.conf.js +32 -0
- package/license.txt +26 -0
- package/package.json +61 -0
- package/src/app/app.component.dev.ts +74 -0
- package/src/app/app.component.html +5 -0
- package/src/app/app.component.prod.ts +76 -0
- package/src/app/app.component.scss +1 -0
- package/src/app/app.module.dev.ts +58 -0
- package/src/app/app.module.prod.ts +56 -0
- package/src/app/modules/input-types/components/cedar-foo-bar/cedar-foo-bar.component.html +0 -0
- package/src/app/modules/input-types/components/cedar-foo-bar/cedar-foo-bar.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-foo-bar/cedar-foo-bar.component.spec.ts +24 -0
- package/src/app/modules/input-types/components/cedar-foo-bar/cedar-foo-bar.component.ts +39 -0
- package/src/app/modules/input-types/components/cedar-input-attribute-value/cedar-input-attribute-value.component.html +25 -0
- package/src/app/modules/input-types/components/cedar-input-attribute-value/cedar-input-attribute-value.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-input-attribute-value/cedar-input-attribute-value.component.spec.ts +25 -0
- package/src/app/modules/input-types/components/cedar-input-attribute-value/cedar-input-attribute-value.component.ts +91 -0
- package/src/app/modules/input-types/components/cedar-input-checkbox/cedar-input-checkbox.component.html +8 -0
- package/src/app/modules/input-types/components/cedar-input-checkbox/cedar-input-checkbox.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-input-checkbox/cedar-input-checkbox.component.spec.ts +25 -0
- package/src/app/modules/input-types/components/cedar-input-checkbox/cedar-input-checkbox.component.ts +104 -0
- package/src/app/modules/input-types/components/cedar-input-controlled/cedar-input-controlled.component.html +22 -0
- package/src/app/modules/input-types/components/cedar-input-controlled/cedar-input-controlled.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-input-controlled/cedar-input-controlled.component.spec.ts +24 -0
- package/src/app/modules/input-types/components/cedar-input-controlled/cedar-input-controlled.component.ts +135 -0
- package/src/app/modules/input-types/components/cedar-input-datetime/cedar-input-datetime.component.html +44 -0
- package/src/app/modules/input-types/components/cedar-input-datetime/cedar-input-datetime.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-input-datetime/cedar-input-datetime.component.spec.ts +25 -0
- package/src/app/modules/input-types/components/cedar-input-datetime/cedar-input-datetime.component.ts +451 -0
- package/src/app/modules/input-types/components/cedar-input-email/cedar-input-email.component.html +16 -0
- package/src/app/modules/input-types/components/cedar-input-email/cedar-input-email.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-input-email/cedar-input-email.component.spec.ts +25 -0
- package/src/app/modules/input-types/components/cedar-input-email/cedar-input-email.component.ts +91 -0
- package/src/app/modules/input-types/components/cedar-input-link/cedar-input-link.component.html +16 -0
- package/src/app/modules/input-types/components/cedar-input-link/cedar-input-link.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-input-link/cedar-input-link.component.spec.ts +25 -0
- package/src/app/modules/input-types/components/cedar-input-link/cedar-input-link.component.ts +92 -0
- package/src/app/modules/input-types/components/cedar-input-multiple-choice/cedar-input-multiple-choice.component.html +18 -0
- package/src/app/modules/input-types/components/cedar-input-multiple-choice/cedar-input-multiple-choice.component.scss +5 -0
- package/src/app/modules/input-types/components/cedar-input-multiple-choice/cedar-input-multiple-choice.component.spec.ts +25 -0
- package/src/app/modules/input-types/components/cedar-input-multiple-choice/cedar-input-multiple-choice.component.ts +78 -0
- package/src/app/modules/input-types/components/cedar-input-numeric/cedar-input-numeric.component.html +15 -0
- package/src/app/modules/input-types/components/cedar-input-numeric/cedar-input-numeric.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-input-numeric/cedar-input-numeric.component.spec.ts +25 -0
- package/src/app/modules/input-types/components/cedar-input-numeric/cedar-input-numeric.component.ts +169 -0
- package/src/app/modules/input-types/components/cedar-input-phone/cedar-input-phone.component.html +15 -0
- package/src/app/modules/input-types/components/cedar-input-phone/cedar-input-phone.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-input-phone/cedar-input-phone.component.spec.ts +25 -0
- package/src/app/modules/input-types/components/cedar-input-phone/cedar-input-phone.component.ts +94 -0
- package/src/app/modules/input-types/components/cedar-input-select/cedar-input-select.component.html +19 -0
- package/src/app/modules/input-types/components/cedar-input-select/cedar-input-select.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-input-select/cedar-input-select.component.spec.ts +25 -0
- package/src/app/modules/input-types/components/cedar-input-select/cedar-input-select.component.ts +108 -0
- package/src/app/modules/input-types/components/cedar-input-text/cedar-input-text.component.html +25 -0
- package/src/app/modules/input-types/components/cedar-input-text/cedar-input-text.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-input-text/cedar-input-text.component.spec.ts +25 -0
- package/src/app/modules/input-types/components/cedar-input-text/cedar-input-text.component.ts +125 -0
- package/src/app/modules/input-types/components/cedar-static-image/cedar-static-image.component.html +8 -0
- package/src/app/modules/input-types/components/cedar-static-image/cedar-static-image.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-static-image/cedar-static-image.component.spec.ts +24 -0
- package/src/app/modules/input-types/components/cedar-static-image/cedar-static-image.component.ts +40 -0
- package/src/app/modules/input-types/components/cedar-static-page-break/cedar-static-page-break.component.html +20 -0
- package/src/app/modules/input-types/components/cedar-static-page-break/cedar-static-page-break.component.scss +24 -0
- package/src/app/modules/input-types/components/cedar-static-page-break/cedar-static-page-break.component.spec.ts +25 -0
- package/src/app/modules/input-types/components/cedar-static-page-break/cedar-static-page-break.component.ts +36 -0
- package/src/app/modules/input-types/components/cedar-static-rich-text/cedar-static-rich-text.component.html +2 -0
- package/src/app/modules/input-types/components/cedar-static-rich-text/cedar-static-rich-text.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-static-rich-text/cedar-static-rich-text.component.spec.ts +25 -0
- package/src/app/modules/input-types/components/cedar-static-rich-text/cedar-static-rich-text.component.ts +35 -0
- package/src/app/modules/input-types/components/cedar-static-section-break/cedar-static-section-break.component.html +8 -0
- package/src/app/modules/input-types/components/cedar-static-section-break/cedar-static-section-break.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-static-section-break/cedar-static-section-break.component.spec.ts +24 -0
- package/src/app/modules/input-types/components/cedar-static-section-break/cedar-static-section-break.component.ts +39 -0
- package/src/app/modules/input-types/components/cedar-static-youtube/cedar-static-youtube.component.html +6 -0
- package/src/app/modules/input-types/components/cedar-static-youtube/cedar-static-youtube.component.scss +0 -0
- package/src/app/modules/input-types/components/cedar-static-youtube/cedar-static-youtube.component.spec.ts +24 -0
- package/src/app/modules/input-types/components/cedar-static-youtube/cedar-static-youtube.component.ts +42 -0
- package/src/app/modules/input-types/input-types.module.ts +139 -0
- package/src/app/modules/shared/components/cedar-component-header/cedar-component-header.component.html +13 -0
- package/src/app/modules/shared/components/cedar-component-header/cedar-component-header.component.scss +12 -0
- package/src/app/modules/shared/components/cedar-component-header/cedar-component-header.component.spec.ts +25 -0
- package/src/app/modules/shared/components/cedar-component-header/cedar-component-header.component.ts +42 -0
- package/src/app/modules/shared/components/cedar-component-renderer/cedar-component-renderer.component.html +117 -0
- package/src/app/modules/shared/components/cedar-component-renderer/cedar-component-renderer.component.scss +5 -0
- package/src/app/modules/shared/components/cedar-component-renderer/cedar-component-renderer.component.spec.ts +25 -0
- package/src/app/modules/shared/components/cedar-component-renderer/cedar-component-renderer.component.ts +101 -0
- package/src/app/modules/shared/components/cedar-data-saver/cedar-data-saver.component.html +22 -0
- package/src/app/modules/shared/components/cedar-data-saver/cedar-data-saver.component.scss +23 -0
- package/src/app/modules/shared/components/cedar-data-saver/cedar-data-saver.component.spec.ts +24 -0
- package/src/app/modules/shared/components/cedar-data-saver/cedar-data-saver.component.ts +139 -0
- package/src/app/modules/shared/components/cedar-embeddable-metadata-editor/cedar-embeddable-metadata-editor.component.html +56 -0
- package/src/app/modules/shared/components/cedar-embeddable-metadata-editor/cedar-embeddable-metadata-editor.component.scss +13 -0
- package/src/app/modules/shared/components/cedar-embeddable-metadata-editor/cedar-embeddable-metadata-editor.component.spec.ts +25 -0
- package/src/app/modules/shared/components/cedar-embeddable-metadata-editor/cedar-embeddable-metadata-editor.component.ts +184 -0
- package/src/app/modules/shared/components/cedar-embeddable-metadata-editor-wrapper/cedar-embeddable-metadata-editor-wrapper.component.html +15 -0
- package/src/app/modules/shared/components/cedar-embeddable-metadata-editor-wrapper/cedar-embeddable-metadata-editor-wrapper.component.scss +2 -0
- package/src/app/modules/shared/components/cedar-embeddable-metadata-editor-wrapper/cedar-embeddable-metadata-editor-wrapper.component.spec.ts +25 -0
- package/src/app/modules/shared/components/cedar-embeddable-metadata-editor-wrapper/cedar-embeddable-metadata-editor-wrapper.component.ts +240 -0
- package/src/app/modules/shared/components/cedar-multi-pager/cedar-multi-pager.component.html +35 -0
- package/src/app/modules/shared/components/cedar-multi-pager/cedar-multi-pager.component.scss +41 -0
- package/src/app/modules/shared/components/cedar-multi-pager/cedar-multi-pager.component.spec.ts +25 -0
- package/src/app/modules/shared/components/cedar-multi-pager/cedar-multi-pager.component.ts +282 -0
- package/src/app/modules/shared/components/date-picker/date-picker.component.html +46 -0
- package/src/app/modules/shared/components/date-picker/date-picker.component.scss +7 -0
- package/src/app/modules/shared/components/date-picker/date-picker.component.spec.ts +25 -0
- package/src/app/modules/shared/components/date-picker/date-picker.component.ts +100 -0
- package/src/app/modules/shared/components/file-uploader/bytes/bytes.pipe.spec.ts +33 -0
- package/src/app/modules/shared/components/file-uploader/bytes/bytes.pipe.ts +16 -0
- package/src/app/modules/shared/components/file-uploader/file-upload-input-for/file-upload-input-for.directive.spec.ts +54 -0
- package/src/app/modules/shared/components/file-uploader/file-upload-input-for/file-upload-input-for.directive.ts +67 -0
- package/src/app/modules/shared/components/file-uploader/file-uploader.component.html +26 -0
- package/src/app/modules/shared/components/file-uploader/file-uploader.component.scss +55 -0
- package/src/app/modules/shared/components/file-uploader/file-uploader.component.spec.ts +25 -0
- package/src/app/modules/shared/components/file-uploader/file-uploader.component.ts +67 -0
- package/src/app/modules/shared/components/file-uploader/mat-file-upload/mat-file-upload.component.html +42 -0
- package/src/app/modules/shared/components/file-uploader/mat-file-upload/mat-file-upload.component.scss +31 -0
- package/src/app/modules/shared/components/file-uploader/mat-file-upload/mat-file-upload.component.spec.ts +177 -0
- package/src/app/modules/shared/components/file-uploader/mat-file-upload/mat-file-upload.component.ts +145 -0
- package/src/app/modules/shared/components/file-uploader/mat-file-upload/mat-file-upload.service.ts +21 -0
- package/src/app/modules/shared/components/file-uploader/mat-file-upload-queue/mat-file-upload-queue.component.html +1 -0
- package/src/app/modules/shared/components/file-uploader/mat-file-upload-queue/mat-file-upload-queue.component.scss +0 -0
- package/src/app/modules/shared/components/file-uploader/mat-file-upload-queue/mat-file-upload-queue.component.spec.ts +59 -0
- package/src/app/modules/shared/components/file-uploader/mat-file-upload-queue/mat-file-upload-queue.component.ts +139 -0
- package/src/app/modules/shared/components/file-uploader/mat-file-upload-queue/mat-file-upload-queue.service.spec.ts +33 -0
- package/src/app/modules/shared/components/file-uploader/mat-file-upload-queue/mat-file-upload-queue.service.ts +17 -0
- package/src/app/modules/shared/components/file-uploader/mat-file-upload.module.ts +35 -0
- package/src/app/modules/shared/components/file-uploader/mat-file-upload.type.ts +24 -0
- package/src/app/modules/shared/components/preferences-menu/preferences-menu.component.html +18 -0
- package/src/app/modules/shared/components/preferences-menu/preferences-menu.component.scss +0 -0
- package/src/app/modules/shared/components/preferences-menu/preferences-menu.component.spec.ts +23 -0
- package/src/app/modules/shared/components/preferences-menu/preferences-menu.component.ts +10 -0
- package/src/app/modules/shared/components/sample-templates/sample-template-select/sample-template-select.component.html +16 -0
- package/src/app/modules/shared/components/sample-templates/sample-template-select/sample-template-select.component.scss +0 -0
- package/src/app/modules/shared/components/sample-templates/sample-template-select/sample-template-select.component.spec.ts +25 -0
- package/src/app/modules/shared/components/sample-templates/sample-template-select/sample-template-select.component.ts +89 -0
- package/src/app/modules/shared/components/sample-templates/sample-templates.component.html +19 -0
- package/src/app/modules/shared/components/sample-templates/sample-templates.component.scss +0 -0
- package/src/app/modules/shared/components/sample-templates/sample-templates.component.spec.ts +25 -0
- package/src/app/modules/shared/components/sample-templates/sample-templates.component.ts +66 -0
- package/src/app/modules/shared/components/sample-templates/sample-templates.service.ts +175 -0
- package/src/app/modules/shared/components/source-panels/source-panels.component.html +98 -0
- package/src/app/modules/shared/components/source-panels/source-panels.component.scss +0 -0
- package/src/app/modules/shared/components/source-panels/source-panels.component.spec.ts +25 -0
- package/src/app/modules/shared/components/source-panels/source-panels.component.ts +36 -0
- package/src/app/modules/shared/components/static-footer/static-footer.component.html +17 -0
- package/src/app/modules/shared/components/static-footer/static-footer.component.scss +110 -0
- package/src/app/modules/shared/components/static-footer/static-footer.component.spec.ts +25 -0
- package/src/app/modules/shared/components/static-footer/static-footer.component.ts +16 -0
- package/src/app/modules/shared/components/static-header/static-header.component.html +10 -0
- package/src/app/modules/shared/components/static-header/static-header.component.scss +13 -0
- package/src/app/modules/shared/components/static-header/static-header.component.spec.ts +25 -0
- package/src/app/modules/shared/components/static-header/static-header.component.ts +21 -0
- package/src/app/modules/shared/components/timezone-picker/timezone-picker.component.html +16 -0
- package/src/app/modules/shared/components/timezone-picker/timezone-picker.component.scss +0 -0
- package/src/app/modules/shared/components/timezone-picker/timezone-picker.component.spec.ts +25 -0
- package/src/app/modules/shared/components/timezone-picker/timezone-picker.component.ts +251 -0
- package/src/app/modules/shared/factory/template-representation.factory.ts +323 -0
- package/src/app/modules/shared/handler/component-type.handler.ts +51 -0
- package/src/app/modules/shared/handler/data-object-builder.handler.ts +159 -0
- package/src/app/modules/shared/handler/data-object-data-value.handler.ts +270 -0
- package/src/app/modules/shared/handler/data-object-structure.handler.ts +145 -0
- package/src/app/modules/shared/handler/multi-instance-object.handler.ts +317 -0
- package/src/app/modules/shared/models/cedar-input-template.model.ts +3 -0
- package/src/app/modules/shared/models/cedar-model.model.ts +48 -0
- package/src/app/modules/shared/models/component/cedar-component.model.ts +16 -0
- package/src/app/modules/shared/models/component/component-representation.model.ts +30 -0
- package/src/app/modules/shared/models/component/element-component.model.ts +11 -0
- package/src/app/modules/shared/models/component/field-component.model.ts +23 -0
- package/src/app/modules/shared/models/component/multi-component.model.ts +10 -0
- package/src/app/modules/shared/models/component/null-component.model.ts +20 -0
- package/src/app/modules/shared/models/component/single-component.model.ts +6 -0
- package/src/app/modules/shared/models/element/abstract-element-component.model.ts +26 -0
- package/src/app/modules/shared/models/element/multi-element-component.model.ts +19 -0
- package/src/app/modules/shared/models/element/single-element-component.model.ts +16 -0
- package/src/app/modules/shared/models/enum/data-object-building-mode.model.ts +6 -0
- package/src/app/modules/shared/models/field/abstract-field-component.model.ts +28 -0
- package/src/app/modules/shared/models/field/multi-field-component.model.ts +21 -0
- package/src/app/modules/shared/models/field/single-field-component.model.ts +18 -0
- package/src/app/modules/shared/models/info/basic-info.model.ts +8 -0
- package/src/app/modules/shared/models/info/choice-info.model.ts +9 -0
- package/src/app/modules/shared/models/info/choice-option.model.ts +6 -0
- package/src/app/modules/shared/models/info/content-info.model.ts +5 -0
- package/src/app/modules/shared/models/info/controlled-info.model.ts +8 -0
- package/src/app/modules/shared/models/info/current-multi-info.model.ts +7 -0
- package/src/app/modules/shared/models/info/label-info.model.ts +7 -0
- package/src/app/modules/shared/models/info/multi-info.model.ts +10 -0
- package/src/app/modules/shared/models/info/multi-instance-info.model.ts +20 -0
- package/src/app/modules/shared/models/info/multi-instance-object-info.model.ts +30 -0
- package/src/app/modules/shared/models/info/number-info.model.ts +9 -0
- package/src/app/modules/shared/models/info/value-info.model.ts +9 -0
- package/src/app/modules/shared/models/input-type.model.ts +21 -0
- package/src/app/modules/shared/models/instance-extract-data.model.ts +3 -0
- package/src/app/modules/shared/models/instance-full-data.model.ts +5 -0
- package/src/app/modules/shared/models/javascript-types.model.ts +7 -0
- package/src/app/modules/shared/models/json-schema.model.ts +39 -0
- package/src/app/modules/shared/models/numbers.model.ts +10 -0
- package/src/app/modules/shared/models/rest/integrated-search/integrated-search-request-parameter-object.ts +8 -0
- package/src/app/modules/shared/models/rest/integrated-search/integrated-search-request-value-constraints.ts +8 -0
- package/src/app/modules/shared/models/rest/integrated-search/integrated-search-request.ts +9 -0
- package/src/app/modules/shared/models/rest/integrated-search/integrated-search-response-item.ts +10 -0
- package/src/app/modules/shared/models/rest/integrated-search/integrated-search-response.ts +13 -0
- package/src/app/modules/shared/models/static/static-field-component.model.ts +24 -0
- package/src/app/modules/shared/models/template/cedar-template.model.ts +24 -0
- package/src/app/modules/shared/models/template/empty-template.model.ts +5 -0
- package/src/app/modules/shared/models/template/null-template.model.ts +23 -0
- package/src/app/modules/shared/models/template/template-component.model.ts +12 -0
- package/src/app/modules/shared/models/temporal.model.ts +13 -0
- package/src/app/modules/shared/models/ui/cedar-ui-component.model.ts +17 -0
- package/src/app/modules/shared/models/xsd.model.ts +11 -0
- package/src/app/modules/shared/pipe/keep-html.pipe.ts +13 -0
- package/src/app/modules/shared/pipe/rdf.pipe.ts +10 -0
- package/src/app/modules/shared/service/active-component-registry.service.ts +134 -0
- package/src/app/modules/shared/service/component-data.service.ts +25 -0
- package/src/app/modules/shared/service/controlled-field-data.service.ts +37 -0
- package/src/app/modules/shared/service/date-time/custom-date-adapter.ts +19 -0
- package/src/app/modules/shared/service/date-time/date-time.service.ts +30 -0
- package/src/app/modules/shared/service/local-settings.service.ts +22 -0
- package/src/app/modules/shared/service/message-handler.service.ts +35 -0
- package/src/app/modules/shared/service/page-break-paginator.service.ts +78 -0
- package/src/app/modules/shared/shared.module.ts +97 -0
- package/src/app/modules/shared/util/data-context.ts +42 -0
- package/src/app/modules/shared/util/data-object-util.ts +102 -0
- package/src/app/modules/shared/util/handler-context.ts +81 -0
- package/src/app/modules/shared/util/template-object-util.ts +21 -0
- package/src/assets/.gitkeep +0 -0
- package/src/assets/fonts/MaterialIcons-Regular.eot +0 -0
- package/src/assets/fonts/MaterialIcons-Regular.ttf +0 -0
- package/src/assets/fonts/MaterialIcons-Regular.woff +0 -0
- package/src/assets/fonts/MaterialIcons-Regular.woff2 +0 -0
- package/src/assets/i18n-cee/en.json +86 -0
- package/src/assets/i18n-cee/hu.json +86 -0
- package/src/assets/images/bmir-logo.png +0 -0
- package/src/assets/images/cedar-logo-80x80.png +0 -0
- package/src/environments/environment.prod.ts +5 -0
- package/src/environments/environment.ts +18 -0
- package/src/favicon.ico +0 -0
- package/src/index.html +16 -0
- package/src/main.ts +28 -0
- package/src/polyfills.ts +65 -0
- package/src/styles-own.scss +352 -0
- package/src/styles.scss +116 -0
- package/src/test.ts +25 -0
- package/tsconfig.app.json +16 -0
- package/tsconfig.base.json +20 -0
- package/tsconfig.json +20 -0
- package/tsconfig.spec.json +18 -0
- package/tslint.json +152 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ComponentFixture,
|
|
3
|
+
TestBed,
|
|
4
|
+
tick,
|
|
5
|
+
fakeAsync,
|
|
6
|
+
} from '@angular/core/testing';
|
|
7
|
+
|
|
8
|
+
import {MatFileUploadComponent} from './mat-file-upload.component';
|
|
9
|
+
import {MatFileUploadQueueService} from '../mat-file-upload-queue/mat-file-upload-queue.service';
|
|
10
|
+
import {BehaviorSubject, of} from 'rxjs';
|
|
11
|
+
import {IInput} from '../mat-file-upload.type';
|
|
12
|
+
import {MatProgressBarModule} from '@angular/material/progress-bar';
|
|
13
|
+
import {MatCardModule} from '@angular/material/card';
|
|
14
|
+
import {MatButtonModule} from '@angular/material/button';
|
|
15
|
+
import {MatIconModule} from '@angular/material/icon';
|
|
16
|
+
import {HttpClientModule} from '@angular/common/http';
|
|
17
|
+
import {CommonModule} from '@angular/common';
|
|
18
|
+
import {BytesPipe} from '../bytes/bytes.pipe';
|
|
19
|
+
import {
|
|
20
|
+
HttpClientTestingModule,
|
|
21
|
+
HttpTestingController,
|
|
22
|
+
} from '@angular/common/http/testing';
|
|
23
|
+
|
|
24
|
+
export class StubMatFileUploadQueueService {
|
|
25
|
+
inputValueSubject = new BehaviorSubject<IInput>(null);
|
|
26
|
+
inputValue$ = this.inputValueSubject.asObservable();
|
|
27
|
+
|
|
28
|
+
initialize(input: IInput) {
|
|
29
|
+
this.inputValueSubject.next(input);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getInputValue() {
|
|
33
|
+
return this.inputValueSubject.getValue();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export class StubFile {
|
|
38
|
+
name = 'testName';
|
|
39
|
+
size = 1024;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
describe('MatFileUploadComponent', () => {
|
|
43
|
+
let component: MatFileUploadComponent;
|
|
44
|
+
let fixture: ComponentFixture<MatFileUploadComponent>;
|
|
45
|
+
let service: StubMatFileUploadQueueService;
|
|
46
|
+
let httpTestingController: HttpTestingController;
|
|
47
|
+
|
|
48
|
+
beforeEach(async () => {
|
|
49
|
+
await TestBed.configureTestingModule({
|
|
50
|
+
imports: [
|
|
51
|
+
MatProgressBarModule,
|
|
52
|
+
MatCardModule,
|
|
53
|
+
MatButtonModule,
|
|
54
|
+
MatIconModule,
|
|
55
|
+
HttpClientModule,
|
|
56
|
+
CommonModule,
|
|
57
|
+
HttpClientTestingModule,
|
|
58
|
+
],
|
|
59
|
+
declarations: [MatFileUploadComponent, BytesPipe],
|
|
60
|
+
providers: [MatFileUploadQueueService],
|
|
61
|
+
}).compileComponents();
|
|
62
|
+
service = TestBed.get(MatFileUploadQueueService);
|
|
63
|
+
|
|
64
|
+
httpTestingController = TestBed.get(HttpTestingController);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
afterEach(() => {
|
|
68
|
+
httpTestingController.verify();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
function initComponent() {
|
|
72
|
+
fixture = TestBed.createComponent(MatFileUploadComponent);
|
|
73
|
+
component = fixture.componentInstance;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
describe('', () => {
|
|
77
|
+
it('should create', () => {
|
|
78
|
+
initComponent();
|
|
79
|
+
component.file = new StubFile();
|
|
80
|
+
let result;
|
|
81
|
+
component.uploadProgress$.subscribe((vm) => (result = vm));
|
|
82
|
+
fixture.detectChanges();
|
|
83
|
+
expect(component).toBeTruthy();
|
|
84
|
+
expect(result).toEqual({
|
|
85
|
+
progressPercentage: 0,
|
|
86
|
+
loaded: 0,
|
|
87
|
+
total: 1024,
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('should use the Queue inputs if inputs are not set', fakeAsync(() => {
|
|
92
|
+
service.inputValueSubject.next({
|
|
93
|
+
httpUrl: 'http://queue.url',
|
|
94
|
+
httpRequestHeaders: { queuekey: 'queuevalue' },
|
|
95
|
+
httpRequestParams: { queueParamkey: 'queueParamValue' },
|
|
96
|
+
fileAlias: 'queue alias',
|
|
97
|
+
});
|
|
98
|
+
initComponent();
|
|
99
|
+
component.file = new StubFile();
|
|
100
|
+
tick();
|
|
101
|
+
fixture.detectChanges();
|
|
102
|
+
expect(component.httpUrl).toBe('http://queue.url');
|
|
103
|
+
expect(component.httpRequestHeaders).toEqual({ queuekey: 'queuevalue' });
|
|
104
|
+
expect(component.httpRequestParams).toEqual({
|
|
105
|
+
queueParamkey: 'queueParamValue',
|
|
106
|
+
});
|
|
107
|
+
expect(component.fileAlias).toBe('queue alias');
|
|
108
|
+
}));
|
|
109
|
+
|
|
110
|
+
it('should NOT use the Queue inputs if inputs are set', () => {
|
|
111
|
+
service.inputValueSubject.next({
|
|
112
|
+
httpUrl: 'http://queue.url',
|
|
113
|
+
httpRequestHeaders: { queuekey: 'queuevalue' },
|
|
114
|
+
httpRequestParams: { queueParamkey: 'queueParamValue' },
|
|
115
|
+
fileAlias: 'queue alias',
|
|
116
|
+
});
|
|
117
|
+
initComponent();
|
|
118
|
+
component.file = new StubFile();
|
|
119
|
+
component.httpUrl = 'http://fileupload.url';
|
|
120
|
+
component.httpRequestHeaders = { queuekey: 'fileUploadqueuevalue' };
|
|
121
|
+
component.httpRequestParams = {
|
|
122
|
+
queueParamkey: 'fileUploadqueueParamValue',
|
|
123
|
+
};
|
|
124
|
+
component.fileAlias = 'file upload queue alias';
|
|
125
|
+
fixture.detectChanges();
|
|
126
|
+
|
|
127
|
+
expect(component.httpUrl).toBe('http://fileupload.url');
|
|
128
|
+
expect(component.httpRequestHeaders).toEqual({
|
|
129
|
+
queuekey: 'fileUploadqueuevalue',
|
|
130
|
+
});
|
|
131
|
+
expect(component.httpRequestParams).toEqual({
|
|
132
|
+
queueParamkey: 'fileUploadqueueParamValue',
|
|
133
|
+
});
|
|
134
|
+
expect(component.fileAlias).toBe('file upload queue alias');
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('should upload', fakeAsync(() => {
|
|
138
|
+
service.inputValueSubject.next({
|
|
139
|
+
httpUrl: 'http://queue.url',
|
|
140
|
+
httpRequestHeaders: { queuekey: 'queuevalue' },
|
|
141
|
+
httpRequestParams: { queueParamkey: 'queueParamValue' },
|
|
142
|
+
fileAlias: 'queue alias',
|
|
143
|
+
});
|
|
144
|
+
initComponent();
|
|
145
|
+
component.file = new Blob();
|
|
146
|
+
fixture.detectChanges();
|
|
147
|
+
|
|
148
|
+
component.upload();
|
|
149
|
+
const req = httpTestingController.expectOne(
|
|
150
|
+
'http://queue.url?queueParamkey=queueParamValue'
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
expect(req.request.method).toEqual('POST');
|
|
154
|
+
expect(req.request.headers.get('queuekey')).toEqual('queuevalue');
|
|
155
|
+
expect(req.request.params.get('queueParamkey')).toEqual(
|
|
156
|
+
'queueParamValue'
|
|
157
|
+
);
|
|
158
|
+
req.flush(null);
|
|
159
|
+
}));
|
|
160
|
+
|
|
161
|
+
it('should send remove event on remove()', fakeAsync(() => {
|
|
162
|
+
service.inputValueSubject.next({
|
|
163
|
+
httpUrl: 'http://queue.url',
|
|
164
|
+
httpRequestHeaders: { queuekey: 'queuevalue' },
|
|
165
|
+
httpRequestParams: { queueParamkey: 'queueParamValue' },
|
|
166
|
+
fileAlias: 'queue alias',
|
|
167
|
+
});
|
|
168
|
+
initComponent();
|
|
169
|
+
component.file = new Blob();
|
|
170
|
+
fixture.detectChanges();
|
|
171
|
+
let result;
|
|
172
|
+
component.removeEvent.subscribe((vm) => (result = vm));
|
|
173
|
+
component.remove();
|
|
174
|
+
expect(result).toBe(component);
|
|
175
|
+
}));
|
|
176
|
+
});
|
|
177
|
+
});
|
package/src/app/modules/shared/components/file-uploader/mat-file-upload/mat-file-upload.component.ts
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import {Component, OnInit, ChangeDetectionStrategy, OnDestroy, Input, Output, EventEmitter} from '@angular/core';
|
|
2
|
+
import {ReplaySubject, BehaviorSubject, Subscription} from 'rxjs';
|
|
3
|
+
import {HttpHeaders, HttpParams, HttpClient, HttpEventType} from '@angular/common/http';
|
|
4
|
+
import {MatFileUploadQueueService} from '../mat-file-upload-queue/mat-file-upload-queue.service';
|
|
5
|
+
import {IUploadProgress} from '../mat-file-upload.type';
|
|
6
|
+
import {MatFileUploadService} from './mat-file-upload.service';
|
|
7
|
+
import {MessageHandlerService} from '../../../service/message-handler.service';
|
|
8
|
+
|
|
9
|
+
@Component({
|
|
10
|
+
selector: 'mat-file-upload',
|
|
11
|
+
templateUrl: './mat-file-upload.component.html',
|
|
12
|
+
styleUrls: ['./mat-file-upload.component.scss'],
|
|
13
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
14
|
+
})
|
|
15
|
+
export class MatFileUploadComponent implements OnInit, OnDestroy {
|
|
16
|
+
|
|
17
|
+
private uploadProgressSubject = new ReplaySubject<IUploadProgress>();
|
|
18
|
+
uploadProgress$ = this.uploadProgressSubject.asObservable();
|
|
19
|
+
|
|
20
|
+
private uploadInProgressSubject = new BehaviorSubject<boolean>(false);
|
|
21
|
+
uploadInProgress$ = this.uploadInProgressSubject.asObservable();
|
|
22
|
+
|
|
23
|
+
public subs = new Subscription();
|
|
24
|
+
|
|
25
|
+
/* Http request input bindings */
|
|
26
|
+
@Input()
|
|
27
|
+
httpUrl: string;
|
|
28
|
+
|
|
29
|
+
@Input()
|
|
30
|
+
httpRequestHeaders:
|
|
31
|
+
| HttpHeaders
|
|
32
|
+
| {
|
|
33
|
+
[header: string]: string | string[];
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
@Input()
|
|
37
|
+
httpRequestParams:
|
|
38
|
+
| HttpParams
|
|
39
|
+
| {
|
|
40
|
+
[param: string]: string | string[];
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
@Input()
|
|
44
|
+
fileAlias: string;
|
|
45
|
+
|
|
46
|
+
private _file: any;
|
|
47
|
+
private _id: number;
|
|
48
|
+
|
|
49
|
+
@Input()
|
|
50
|
+
get file(): any {
|
|
51
|
+
return this._file;
|
|
52
|
+
}
|
|
53
|
+
set file(file: any) {
|
|
54
|
+
this._file = file;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@Input()
|
|
58
|
+
set id(id: number) {
|
|
59
|
+
this._id = id;
|
|
60
|
+
}
|
|
61
|
+
get id(): number {
|
|
62
|
+
return this._id;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@Input()
|
|
66
|
+
fileUploadAriaLabel = 'File Upload';
|
|
67
|
+
|
|
68
|
+
@Input()
|
|
69
|
+
cancelAriaLabel = 'Cancel File Upload';
|
|
70
|
+
|
|
71
|
+
/** Output */
|
|
72
|
+
@Output() removeEvent = new EventEmitter<MatFileUploadComponent>();
|
|
73
|
+
@Output() onUpload = new EventEmitter();
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
constructor(private httpClient: HttpClient, private matFileUploadQueueService: MatFileUploadQueueService,
|
|
77
|
+
private matFileUploadService: MatFileUploadService, private messageHandlerService: MessageHandlerService) {
|
|
78
|
+
const queueInput = this.matFileUploadQueueService.getInputValue();
|
|
79
|
+
if (queueInput) {
|
|
80
|
+
this.httpUrl = this.httpUrl || queueInput.httpUrl;
|
|
81
|
+
this.httpRequestHeaders =
|
|
82
|
+
this.httpRequestHeaders || queueInput.httpRequestHeaders;
|
|
83
|
+
this.httpRequestParams =
|
|
84
|
+
this.httpRequestParams || queueInput.httpRequestParams;
|
|
85
|
+
this.fileAlias = this.fileAlias || queueInput.fileAlias;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
ngOnInit(): void {
|
|
90
|
+
this.uploadProgressSubject.next({
|
|
91
|
+
progressPercentage: 0,
|
|
92
|
+
loaded: 0,
|
|
93
|
+
total: this._file.size,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
public upload(): void {
|
|
98
|
+
this.uploadInProgressSubject.next(true);
|
|
99
|
+
// How to set the alias?
|
|
100
|
+
const formData = new FormData();
|
|
101
|
+
formData.set(this.fileAlias, this._file, this._file.name);
|
|
102
|
+
this.subs.add(
|
|
103
|
+
this.httpClient.post(this.httpUrl, formData, {
|
|
104
|
+
headers: this.httpRequestHeaders,
|
|
105
|
+
observe: 'events',
|
|
106
|
+
params: this.httpRequestParams,
|
|
107
|
+
reportProgress: true,
|
|
108
|
+
responseType: 'json',
|
|
109
|
+
}).subscribe(
|
|
110
|
+
(event: any) => {
|
|
111
|
+
if (event.type === HttpEventType.UploadProgress) {
|
|
112
|
+
this.uploadProgressSubject.next({
|
|
113
|
+
progressPercentage: Math.floor(
|
|
114
|
+
(event.loaded * 100) / event.total
|
|
115
|
+
),
|
|
116
|
+
loaded: event.loaded,
|
|
117
|
+
total: event.total,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
const value = {file: this._file, event: event};
|
|
121
|
+
this.matFileUploadService.setUploadedFile(value);
|
|
122
|
+
this.onUpload.emit(value);
|
|
123
|
+
},
|
|
124
|
+
(error: any) => {
|
|
125
|
+
this.uploadInProgressSubject.next(false);
|
|
126
|
+
const value = {file: this._file, event: error};
|
|
127
|
+
this.matFileUploadService.setUploadedFile(value);
|
|
128
|
+
this.messageHandlerService.error('Error uploading template file: ' + JSON.stringify(error));
|
|
129
|
+
this.onUpload.emit(value);
|
|
130
|
+
},
|
|
131
|
+
() => this.uploadInProgressSubject.next(false)
|
|
132
|
+
)
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
public remove(): void {
|
|
137
|
+
this.subs.unsubscribe();
|
|
138
|
+
this.removeEvent.emit(this);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
ngOnDestroy(): void {
|
|
142
|
+
this.subs.unsubscribe();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
}
|
package/src/app/modules/shared/components/file-uploader/mat-file-upload/mat-file-upload.service.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {Injectable} from '@angular/core';
|
|
2
|
+
import {BehaviorSubject} from 'rxjs';
|
|
3
|
+
|
|
4
|
+
@Injectable({
|
|
5
|
+
providedIn: 'root'
|
|
6
|
+
})
|
|
7
|
+
export class MatFileUploadService {
|
|
8
|
+
|
|
9
|
+
private uploadedFileSubject = new BehaviorSubject<object>(null);
|
|
10
|
+
uploadedFile$ = this.uploadedFileSubject.asObservable();
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
setUploadedFile(file): void {
|
|
14
|
+
this.uploadedFileSubject.next(file);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getUploadedFile(): object {
|
|
18
|
+
return this.uploadedFileSubject.getValue();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<ng-content></ng-content>
|
|
File without changes
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
|
2
|
+
import {MatFileUploadQueueComponent} from './mat-file-upload-queue.component';
|
|
3
|
+
import {MatProgressBarModule} from '@angular/material/progress-bar';
|
|
4
|
+
import {MatCardModule} from '@angular/material/card';
|
|
5
|
+
import {MatButtonModule} from '@angular/material/button';
|
|
6
|
+
import {MatIconModule} from '@angular/material/icon';
|
|
7
|
+
import {CommonModule} from '@angular/common';
|
|
8
|
+
|
|
9
|
+
describe('MatFileUploadQueueComponent', () => {
|
|
10
|
+
let component: MatFileUploadQueueComponent;
|
|
11
|
+
let fixture: ComponentFixture<MatFileUploadQueueComponent>;
|
|
12
|
+
|
|
13
|
+
beforeEach(async () => {
|
|
14
|
+
await TestBed.configureTestingModule({
|
|
15
|
+
imports: [
|
|
16
|
+
MatProgressBarModule,
|
|
17
|
+
MatCardModule,
|
|
18
|
+
MatButtonModule,
|
|
19
|
+
MatIconModule,
|
|
20
|
+
CommonModule,
|
|
21
|
+
],
|
|
22
|
+
declarations: [MatFileUploadQueueComponent],
|
|
23
|
+
}).compileComponents();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
fixture = TestBed.createComponent(MatFileUploadQueueComponent);
|
|
28
|
+
component = fixture.componentInstance;
|
|
29
|
+
fixture.detectChanges();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should create', () => {
|
|
33
|
+
expect(component).toBeTruthy();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should add file', () => {
|
|
37
|
+
expect(component.files).toEqual([]);
|
|
38
|
+
component.add(new Blob());
|
|
39
|
+
expect(component.files.length).toBe(1);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should add more file', () => {
|
|
43
|
+
expect(component.files).toEqual([]);
|
|
44
|
+
component.add(new Blob());
|
|
45
|
+
component.add(new Blob());
|
|
46
|
+
component.add(new Blob());
|
|
47
|
+
expect(component.files.length).toBe(3);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('should remove all files', () => {
|
|
51
|
+
expect(component.files).toEqual([]);
|
|
52
|
+
component.add(new Blob());
|
|
53
|
+
component.add(new Blob());
|
|
54
|
+
component.add(new Blob());
|
|
55
|
+
expect(component.files.length).toBe(3);
|
|
56
|
+
component.removeAll();
|
|
57
|
+
expect(component.files).toEqual([]);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component, ChangeDetectionStrategy, ContentChildren, forwardRef, OnDestroy, OnChanges,
|
|
3
|
+
QueryList, SimpleChanges, Input, ChangeDetectorRef, AfterViewInit
|
|
4
|
+
} from '@angular/core';
|
|
5
|
+
import {Subscription, Observable, merge} from 'rxjs';
|
|
6
|
+
import {HttpHeaders, HttpParams} from '@angular/common/http';
|
|
7
|
+
import {startWith} from 'rxjs/operators';
|
|
8
|
+
import {MatFileUploadQueueService} from './mat-file-upload-queue.service';
|
|
9
|
+
import {MatFileUploadComponent} from '../mat-file-upload/mat-file-upload.component';
|
|
10
|
+
|
|
11
|
+
@Component({
|
|
12
|
+
selector: 'mat-file-upload-queue',
|
|
13
|
+
templateUrl: './mat-file-upload-queue.component.html',
|
|
14
|
+
styleUrls: ['./mat-file-upload-queue.component.scss'],
|
|
15
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
16
|
+
providers: [MatFileUploadQueueService],
|
|
17
|
+
})
|
|
18
|
+
export class MatFileUploadQueueComponent implements OnChanges, OnDestroy, AfterViewInit {
|
|
19
|
+
@ContentChildren(forwardRef(() => MatFileUploadComponent))
|
|
20
|
+
fileUploads: QueryList<MatFileUploadComponent>;
|
|
21
|
+
|
|
22
|
+
/** Subscription to remove changes in files. */
|
|
23
|
+
private _fileRemoveSubscription: Subscription | null;
|
|
24
|
+
|
|
25
|
+
/** Subscription to changes in the files. */
|
|
26
|
+
private _changeSubscription: Subscription;
|
|
27
|
+
|
|
28
|
+
/** Combined stream of all of the file upload remove change events. */
|
|
29
|
+
get fileUploadRemoveEvents(): Observable<MatFileUploadComponent> {
|
|
30
|
+
return merge(
|
|
31
|
+
...this.fileUploads.map((fileUpload) => fileUpload.removeEvent)
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public files: Array<any> = [];
|
|
36
|
+
|
|
37
|
+
ngOnChanges(changes: SimpleChanges): void {
|
|
38
|
+
this.matFileUploadQueueService.initialize({
|
|
39
|
+
httpUrl: changes.httpUrl ? changes.httpUrl.currentValue : undefined,
|
|
40
|
+
httpRequestHeaders: changes.httpRequestHeaders
|
|
41
|
+
? changes.httpRequestHeaders.currentValue
|
|
42
|
+
: undefined,
|
|
43
|
+
httpRequestParams: changes.httpRequestParams
|
|
44
|
+
? changes.httpRequestParams.currentValue
|
|
45
|
+
: undefined,
|
|
46
|
+
fileAlias: changes.fileAlias
|
|
47
|
+
? changes.fileAlias.currentValue
|
|
48
|
+
: undefined,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
constructor(private matFileUploadQueueService: MatFileUploadQueueService, private changeDetectorRef: ChangeDetectorRef) {
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* Http request input bindings */
|
|
56
|
+
@Input()
|
|
57
|
+
httpUrl: string;
|
|
58
|
+
|
|
59
|
+
@Input()
|
|
60
|
+
httpRequestHeaders:
|
|
61
|
+
| HttpHeaders
|
|
62
|
+
| {
|
|
63
|
+
[header: string]: string | string[];
|
|
64
|
+
} = new HttpHeaders();
|
|
65
|
+
|
|
66
|
+
@Input()
|
|
67
|
+
httpRequestParams:
|
|
68
|
+
| HttpParams
|
|
69
|
+
| {
|
|
70
|
+
[param: string]: string | string[];
|
|
71
|
+
} = new HttpParams();
|
|
72
|
+
|
|
73
|
+
@Input()
|
|
74
|
+
fileAlias = 'file';
|
|
75
|
+
|
|
76
|
+
@Input()
|
|
77
|
+
uploadAllColor = 'primary';
|
|
78
|
+
|
|
79
|
+
@Input()
|
|
80
|
+
uploadAllLabel = 'Upload All';
|
|
81
|
+
|
|
82
|
+
@Input()
|
|
83
|
+
removeAllColor = 'primary';
|
|
84
|
+
|
|
85
|
+
@Input()
|
|
86
|
+
removeAllLabel = 'Remove All';
|
|
87
|
+
|
|
88
|
+
ngAfterViewInit(): void {
|
|
89
|
+
// When the list changes, re-subscribe
|
|
90
|
+
this._changeSubscription = this.fileUploads.changes
|
|
91
|
+
.pipe(startWith(null))
|
|
92
|
+
.subscribe(() => {
|
|
93
|
+
if (this._fileRemoveSubscription) {
|
|
94
|
+
this._fileRemoveSubscription.unsubscribe();
|
|
95
|
+
}
|
|
96
|
+
this._listenTofileRemoved();
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private _listenTofileRemoved(): void {
|
|
101
|
+
this._fileRemoveSubscription = this.fileUploadRemoveEvents.subscribe(
|
|
102
|
+
(event: MatFileUploadComponent) => {
|
|
103
|
+
this.files.splice(event.id, 1);
|
|
104
|
+
this.changeDetectorRef.markForCheck();
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
add(file: any): void {
|
|
110
|
+
this.files.push(file);
|
|
111
|
+
this.changeDetectorRef.markForCheck();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
public uploadAll(): void {
|
|
115
|
+
this.fileUploads.forEach((fileUpload) => {
|
|
116
|
+
fileUpload.upload();
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
public removeAll(): void {
|
|
121
|
+
this.files.splice(0, this.files.length);
|
|
122
|
+
this.changeDetectorRef.markForCheck();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
ngOnDestroy(): void {
|
|
126
|
+
if (this._changeSubscription) {
|
|
127
|
+
this._changeSubscription.unsubscribe();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (this._fileRemoveSubscription) {
|
|
131
|
+
this._fileRemoveSubscription.unsubscribe();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (this.files) {
|
|
135
|
+
this.removeAll();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { MatFileUploadQueueService } from './mat-file-upload-queue.service';
|
|
4
|
+
|
|
5
|
+
describe('MatFileUploadQueueService', () => {
|
|
6
|
+
let service: MatFileUploadQueueService;
|
|
7
|
+
beforeEach(async () => {
|
|
8
|
+
await TestBed.configureTestingModule({
|
|
9
|
+
providers: [MatFileUploadQueueService],
|
|
10
|
+
}).compileComponents();
|
|
11
|
+
service = TestBed.get(MatFileUploadQueueService);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('should be created', () => {
|
|
15
|
+
expect(service).toBeTruthy();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should initialize', () => {
|
|
19
|
+
expect(service.getInputValue()).toBe(null);
|
|
20
|
+
service.initialize({
|
|
21
|
+
fileAlias: 'test',
|
|
22
|
+
httpRequestHeaders: {},
|
|
23
|
+
httpRequestParams: {},
|
|
24
|
+
httpUrl: 'test',
|
|
25
|
+
});
|
|
26
|
+
expect(service.getInputValue()).toEqual({
|
|
27
|
+
fileAlias: 'test',
|
|
28
|
+
httpRequestHeaders: {},
|
|
29
|
+
httpRequestParams: {},
|
|
30
|
+
httpUrl: 'test',
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {Injectable} from '@angular/core';
|
|
2
|
+
import {BehaviorSubject} from 'rxjs';
|
|
3
|
+
import {IInput} from '../mat-file-upload.type';
|
|
4
|
+
|
|
5
|
+
@Injectable()
|
|
6
|
+
export class MatFileUploadQueueService {
|
|
7
|
+
private inputValueSubject = new BehaviorSubject<IInput>(null);
|
|
8
|
+
inputValue$ = this.inputValueSubject.asObservable();
|
|
9
|
+
|
|
10
|
+
initialize(input: IInput): void {
|
|
11
|
+
this.inputValueSubject.next(input);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
getInputValue(): IInput {
|
|
15
|
+
return this.inputValueSubject.getValue();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {NgModule} from '@angular/core';
|
|
2
|
+
import {BytesPipe} from './bytes/bytes.pipe';
|
|
3
|
+
import {MatIconModule} from '@angular/material/icon';
|
|
4
|
+
import {MatProgressBarModule} from '@angular/material/progress-bar';
|
|
5
|
+
import {MatCardModule} from '@angular/material/card';
|
|
6
|
+
import {MatButtonModule} from '@angular/material/button';
|
|
7
|
+
import {CommonModule} from '@angular/common';
|
|
8
|
+
import {HttpClientModule} from '@angular/common/http';
|
|
9
|
+
import {MatFileUploadQueueComponent} from './mat-file-upload-queue/mat-file-upload-queue.component';
|
|
10
|
+
import {MatFileUploadComponent} from './mat-file-upload/mat-file-upload.component';
|
|
11
|
+
import {FileUploadInputForDirective} from './file-upload-input-for/file-upload-input-for.directive';
|
|
12
|
+
|
|
13
|
+
@NgModule({
|
|
14
|
+
declarations: [
|
|
15
|
+
BytesPipe,
|
|
16
|
+
MatFileUploadQueueComponent,
|
|
17
|
+
MatFileUploadComponent,
|
|
18
|
+
FileUploadInputForDirective
|
|
19
|
+
],
|
|
20
|
+
imports: [
|
|
21
|
+
MatProgressBarModule,
|
|
22
|
+
MatCardModule,
|
|
23
|
+
MatButtonModule,
|
|
24
|
+
MatIconModule,
|
|
25
|
+
HttpClientModule,
|
|
26
|
+
CommonModule,
|
|
27
|
+
],
|
|
28
|
+
exports: [
|
|
29
|
+
BytesPipe,
|
|
30
|
+
MatFileUploadQueueComponent,
|
|
31
|
+
MatFileUploadComponent,
|
|
32
|
+
FileUploadInputForDirective
|
|
33
|
+
],
|
|
34
|
+
})
|
|
35
|
+
export class MatFileUploadModule {}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { HttpHeaders, HttpParams } from '@angular/common/http';
|
|
2
|
+
|
|
3
|
+
export interface IInput {
|
|
4
|
+
httpUrl: string;
|
|
5
|
+
httpRequestHeaders:
|
|
6
|
+
| HttpHeaders
|
|
7
|
+
| {
|
|
8
|
+
[header: string]: string | string[];
|
|
9
|
+
};
|
|
10
|
+
httpRequestParams:
|
|
11
|
+
| HttpParams
|
|
12
|
+
| {
|
|
13
|
+
[param: string]: string | string[];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
fileAlias: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface IUploadProgress {
|
|
20
|
+
isLoading?: boolean;
|
|
21
|
+
progressPercentage?: number;
|
|
22
|
+
loaded?: number;
|
|
23
|
+
total?: number;
|
|
24
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<button mat-icon-button [matMenuTriggerFor]="menu" aria-label="Example icon-button with a menu">
|
|
2
|
+
<mat-icon>more_vert</mat-icon>
|
|
3
|
+
</button>
|
|
4
|
+
<mat-menu #menu="matMenu">
|
|
5
|
+
<mat-slide-toggle>Slide me!</mat-slide-toggle>
|
|
6
|
+
<button mat-menu-item>
|
|
7
|
+
<mat-icon>dialpad</mat-icon>
|
|
8
|
+
<span>Redial</span>
|
|
9
|
+
</button>
|
|
10
|
+
<button mat-menu-item disabled>
|
|
11
|
+
<mat-icon>voicemail</mat-icon>
|
|
12
|
+
<span>Check voice mail</span>
|
|
13
|
+
</button>
|
|
14
|
+
<button mat-menu-item>
|
|
15
|
+
<mat-icon>notifications_off</mat-icon>
|
|
16
|
+
<span>Disable alerts</span>
|
|
17
|
+
</button>
|
|
18
|
+
</mat-menu>
|
|
File without changes
|