@ngageoint/mage.web-core-lib 6.2.2

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.
Files changed (181) hide show
  1. package/README.md +24 -0
  2. package/bundles/ngageoint-mage.web-core-lib-common.umd.js +146 -0
  3. package/bundles/ngageoint-mage.web-core-lib-common.umd.js.map +1 -0
  4. package/bundles/ngageoint-mage.web-core-lib-common.umd.min.js +2 -0
  5. package/bundles/ngageoint-mage.web-core-lib-common.umd.min.js.map +1 -0
  6. package/bundles/ngageoint-mage.web-core-lib-event.umd.js +14 -0
  7. package/bundles/ngageoint-mage.web-core-lib-event.umd.js.map +1 -0
  8. package/bundles/ngageoint-mage.web-core-lib-event.umd.min.js +2 -0
  9. package/bundles/ngageoint-mage.web-core-lib-event.umd.min.js.map +1 -0
  10. package/bundles/ngageoint-mage.web-core-lib-feed.umd.js +114 -0
  11. package/bundles/ngageoint-mage.web-core-lib-feed.umd.js.map +1 -0
  12. package/bundles/ngageoint-mage.web-core-lib-feed.umd.min.js +2 -0
  13. package/bundles/ngageoint-mage.web-core-lib-feed.umd.min.js.map +1 -0
  14. package/bundles/ngageoint-mage.web-core-lib-paging.umd.js +313 -0
  15. package/bundles/ngageoint-mage.web-core-lib-paging.umd.js.map +1 -0
  16. package/bundles/ngageoint-mage.web-core-lib-paging.umd.min.js +16 -0
  17. package/bundles/ngageoint-mage.web-core-lib-paging.umd.min.js.map +1 -0
  18. package/bundles/ngageoint-mage.web-core-lib-plugin.umd.js +11 -0
  19. package/bundles/ngageoint-mage.web-core-lib-plugin.umd.js.map +1 -0
  20. package/bundles/ngageoint-mage.web-core-lib-plugin.umd.min.js +2 -0
  21. package/bundles/ngageoint-mage.web-core-lib-plugin.umd.min.js.map +1 -0
  22. package/bundles/ngageoint-mage.web-core-lib-static-icon.umd.js +391 -0
  23. package/bundles/ngageoint-mage.web-core-lib-static-icon.umd.js.map +1 -0
  24. package/bundles/ngageoint-mage.web-core-lib-static-icon.umd.min.js +2 -0
  25. package/bundles/ngageoint-mage.web-core-lib-static-icon.umd.min.js.map +1 -0
  26. package/bundles/ngageoint-mage.web-core-lib-user.umd.js +492 -0
  27. package/bundles/ngageoint-mage.web-core-lib-user.umd.js.map +1 -0
  28. package/bundles/ngageoint-mage.web-core-lib-user.umd.min.js +16 -0
  29. package/bundles/ngageoint-mage.web-core-lib-user.umd.min.js.map +1 -0
  30. package/bundles/ngageoint-mage.web-core-lib.umd.js +32 -0
  31. package/bundles/ngageoint-mage.web-core-lib.umd.js.map +1 -0
  32. package/bundles/ngageoint-mage.web-core-lib.umd.min.js +2 -0
  33. package/bundles/ngageoint-mage.web-core-lib.umd.min.js.map +1 -0
  34. package/common/mage-common.module.d.ts +7 -0
  35. package/common/ngageoint-mage.web-core-lib-common.d.ts +5 -0
  36. package/common/package.json +12 -0
  37. package/common/public-api.d.ts +2 -0
  38. package/common/xhr-img.component.d.ts +58 -0
  39. package/esm2015/common/mage-common.module.js +26 -0
  40. package/esm2015/common/ngageoint-mage.web-core-lib-common.js +5 -0
  41. package/esm2015/common/public-api.js +3 -0
  42. package/esm2015/common/xhr-img.component.js +109 -0
  43. package/esm2015/event/event-read.service.js +3 -0
  44. package/esm2015/event/event.model.js +1 -0
  45. package/esm2015/event/ngageoint-mage.web-core-lib-event.js +5 -0
  46. package/esm2015/event/public-api.js +2 -0
  47. package/esm2015/feed/feed.model.js +1 -0
  48. package/esm2015/feed/feed.service.js +105 -0
  49. package/esm2015/feed/ngageoint-mage.web-core-lib-feed.js +5 -0
  50. package/esm2015/feed/public-api.js +2 -0
  51. package/esm2015/mage-core-lib.module.js +20 -0
  52. package/esm2015/ngageoint-mage.web-core-lib.js +5 -0
  53. package/esm2015/paging/ngageoint-mage.web-core-lib-paging.js +5 -0
  54. package/esm2015/paging/paging.cdk-data-source.adapter.js +52 -0
  55. package/esm2015/paging/paging.model.js +25 -0
  56. package/esm2015/paging/public-api.js +3 -0
  57. package/esm2015/plugin/ngageoint-mage.web-core-lib-plugin.js +4 -0
  58. package/esm2015/plugin/plugin.model.js +1 -0
  59. package/esm2015/plugin/public-api.js +1 -0
  60. package/esm2015/public-api.js +5 -0
  61. package/esm2015/static-icon/ngageoint-mage.web-core-lib-static-icon.js +5 -0
  62. package/esm2015/static-icon/public-api.js +7 -0
  63. package/esm2015/static-icon/static-icon-form-field/static-icon-form-field.component.js +152 -0
  64. package/esm2015/static-icon/static-icon-img/static-icon-img.component.js +35 -0
  65. package/esm2015/static-icon/static-icon-select/static-icon-select.component.js +61 -0
  66. package/esm2015/static-icon/static-icon.model.js +10 -0
  67. package/esm2015/static-icon/static-icon.module.js +55 -0
  68. package/esm2015/static-icon/static-icon.service.js +82 -0
  69. package/esm2015/user/ngageoint-mage.web-core-lib-user.js +5 -0
  70. package/esm2015/user/public-api.js +4 -0
  71. package/esm2015/user/user-read.service.js +40 -0
  72. package/esm2015/user/user-select/user-select.component.js +165 -0
  73. package/esm2015/user/user.model.js +1 -0
  74. package/esm2015/user/user.module.js +65 -0
  75. package/esm5/common/mage-common.module.js +30 -0
  76. package/esm5/common/ngageoint-mage.web-core-lib-common.js +5 -0
  77. package/esm5/common/public-api.js +3 -0
  78. package/esm5/common/xhr-img.component.js +112 -0
  79. package/esm5/event/event-read.service.js +3 -0
  80. package/esm5/event/event.model.js +1 -0
  81. package/esm5/event/ngageoint-mage.web-core-lib-event.js +5 -0
  82. package/esm5/event/public-api.js +2 -0
  83. package/esm5/feed/feed.model.js +1 -0
  84. package/esm5/feed/feed.service.js +108 -0
  85. package/esm5/feed/ngageoint-mage.web-core-lib-feed.js +5 -0
  86. package/esm5/feed/public-api.js +2 -0
  87. package/esm5/mage-core-lib.module.js +24 -0
  88. package/esm5/ngageoint-mage.web-core-lib.js +5 -0
  89. package/esm5/paging/ngageoint-mage.web-core-lib-paging.js +5 -0
  90. package/esm5/paging/paging.cdk-data-source.adapter.js +60 -0
  91. package/esm5/paging/paging.model.js +25 -0
  92. package/esm5/paging/public-api.js +3 -0
  93. package/esm5/plugin/ngageoint-mage.web-core-lib-plugin.js +4 -0
  94. package/esm5/plugin/plugin.model.js +1 -0
  95. package/esm5/plugin/public-api.js +1 -0
  96. package/esm5/public-api.js +5 -0
  97. package/esm5/static-icon/ngageoint-mage.web-core-lib-static-icon.js +5 -0
  98. package/esm5/static-icon/public-api.js +7 -0
  99. package/esm5/static-icon/static-icon-form-field/static-icon-form-field.component.js +157 -0
  100. package/esm5/static-icon/static-icon-img/static-icon-img.component.js +38 -0
  101. package/esm5/static-icon/static-icon-select/static-icon-select.component.js +65 -0
  102. package/esm5/static-icon/static-icon.model.js +10 -0
  103. package/esm5/static-icon/static-icon.module.js +59 -0
  104. package/esm5/static-icon/static-icon.service.js +84 -0
  105. package/esm5/user/ngageoint-mage.web-core-lib-user.js +5 -0
  106. package/esm5/user/public-api.js +4 -0
  107. package/esm5/user/user-read.service.js +42 -0
  108. package/esm5/user/user-select/user-select.component.js +175 -0
  109. package/esm5/user/user.model.js +1 -0
  110. package/esm5/user/user.module.js +69 -0
  111. package/event/event-read.service.d.ts +11 -0
  112. package/event/event.model.d.ts +6 -0
  113. package/event/ngageoint-mage.web-core-lib-event.d.ts +5 -0
  114. package/event/package.json +12 -0
  115. package/event/public-api.d.ts +2 -0
  116. package/feed/feed.model.d.ts +83 -0
  117. package/feed/feed.service.d.ts +40 -0
  118. package/feed/ngageoint-mage.web-core-lib-feed.d.ts +5 -0
  119. package/feed/package.json +12 -0
  120. package/feed/public-api.d.ts +2 -0
  121. package/fesm2015/ngageoint-mage.web-core-lib-common.js +137 -0
  122. package/fesm2015/ngageoint-mage.web-core-lib-common.js.map +1 -0
  123. package/fesm2015/ngageoint-mage.web-core-lib-event.js +10 -0
  124. package/fesm2015/ngageoint-mage.web-core-lib-event.js.map +1 -0
  125. package/fesm2015/ngageoint-mage.web-core-lib-feed.js +111 -0
  126. package/fesm2015/ngageoint-mage.web-core-lib-feed.js.map +1 -0
  127. package/fesm2015/ngageoint-mage.web-core-lib-paging.js +83 -0
  128. package/fesm2015/ngageoint-mage.web-core-lib-paging.js.map +1 -0
  129. package/fesm2015/ngageoint-mage.web-core-lib-plugin.js +4 -0
  130. package/fesm2015/ngageoint-mage.web-core-lib-plugin.js.map +1 -0
  131. package/fesm2015/ngageoint-mage.web-core-lib-static-icon.js +379 -0
  132. package/fesm2015/ngageoint-mage.web-core-lib-static-icon.js.map +1 -0
  133. package/fesm2015/ngageoint-mage.web-core-lib-user.js +267 -0
  134. package/fesm2015/ngageoint-mage.web-core-lib-user.js.map +1 -0
  135. package/fesm2015/ngageoint-mage.web-core-lib.js +30 -0
  136. package/fesm2015/ngageoint-mage.web-core-lib.js.map +1 -0
  137. package/fesm5/ngageoint-mage.web-core-lib-common.js +142 -0
  138. package/fesm5/ngageoint-mage.web-core-lib-common.js.map +1 -0
  139. package/fesm5/ngageoint-mage.web-core-lib-event.js +10 -0
  140. package/fesm5/ngageoint-mage.web-core-lib-event.js.map +1 -0
  141. package/fesm5/ngageoint-mage.web-core-lib-feed.js +113 -0
  142. package/fesm5/ngageoint-mage.web-core-lib-feed.js.map +1 -0
  143. package/fesm5/ngageoint-mage.web-core-lib-paging.js +90 -0
  144. package/fesm5/ngageoint-mage.web-core-lib-paging.js.map +1 -0
  145. package/fesm5/ngageoint-mage.web-core-lib-plugin.js +4 -0
  146. package/fesm5/ngageoint-mage.web-core-lib-plugin.js.map +1 -0
  147. package/fesm5/ngageoint-mage.web-core-lib-static-icon.js +392 -0
  148. package/fesm5/ngageoint-mage.web-core-lib-static-icon.js.map +1 -0
  149. package/fesm5/ngageoint-mage.web-core-lib-user.js +280 -0
  150. package/fesm5/ngageoint-mage.web-core-lib-user.js.map +1 -0
  151. package/fesm5/ngageoint-mage.web-core-lib.js +33 -0
  152. package/fesm5/ngageoint-mage.web-core-lib.js.map +1 -0
  153. package/mage-core-lib.module.d.ts +6 -0
  154. package/ngageoint-mage.web-core-lib.d.ts +5 -0
  155. package/package.json +35 -0
  156. package/paging/ngageoint-mage.web-core-lib-paging.d.ts +5 -0
  157. package/paging/package.json +12 -0
  158. package/paging/paging.cdk-data-source.adapter.d.ts +20 -0
  159. package/paging/paging.model.d.ts +27 -0
  160. package/paging/public-api.d.ts +2 -0
  161. package/plugin/ngageoint-mage.web-core-lib-plugin.d.ts +5 -0
  162. package/plugin/package.json +12 -0
  163. package/plugin/plugin.model.d.ts +13 -0
  164. package/plugin/public-api.d.ts +1 -0
  165. package/public-api.d.ts +1 -0
  166. package/static-icon/ngageoint-mage.web-core-lib-static-icon.d.ts +5 -0
  167. package/static-icon/package.json +12 -0
  168. package/static-icon/public-api.d.ts +6 -0
  169. package/static-icon/static-icon-form-field/static-icon-form-field.component.d.ts +31 -0
  170. package/static-icon/static-icon-img/static-icon-img.component.d.ts +12 -0
  171. package/static-icon/static-icon-select/static-icon-select.component.d.ts +21 -0
  172. package/static-icon/static-icon.model.d.ts +19 -0
  173. package/static-icon/static-icon.module.d.ts +13 -0
  174. package/static-icon/static-icon.service.d.ts +20 -0
  175. package/user/ngageoint-mage.web-core-lib-user.d.ts +5 -0
  176. package/user/package.json +12 -0
  177. package/user/public-api.d.ts +4 -0
  178. package/user/user-read.service.d.ts +24 -0
  179. package/user/user-select/user-select.component.d.ts +38 -0
  180. package/user/user.model.d.ts +85 -0
  181. package/user/user.module.d.ts +16 -0
package/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # CoreLib
2
+
3
+ This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.13.
4
+
5
+ ## Code scaffolding
6
+
7
+ Run `ng generate component component-name --project core-lib` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project core-lib`.
8
+ > Note: Don't forget to add `--project core-lib` or else it will be added to the default project in your `angular.json` file.
9
+
10
+ ## Build
11
+
12
+ Run `ng build core-lib` to build the project. The build artifacts will be stored in the `dist/` directory.
13
+
14
+ ## Publishing
15
+
16
+ After building your library with `ng build core-lib`, go to the dist folder `cd dist/core-lib` and run `npm publish`.
17
+
18
+ ## Running unit tests
19
+
20
+ Run `ng test core-lib` to execute the unit tests via [Karma](https://karma-runner.github.io).
21
+
22
+ ## Further help
23
+
24
+ To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
@@ -0,0 +1,146 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common/http'), require('@angular/platform-browser')) :
3
+ typeof define === 'function' && define.amd ? define('@ngageoint/mage.web-core-lib/common', ['exports', '@angular/core', '@angular/common/http', '@angular/platform-browser'], factory) :
4
+ (global = global || self, factory((global.ngageoint = global.ngageoint || {}, global.ngageoint.mage = global.ngageoint.mage || {}, global.ngageoint.mage['web-core-lib'] = global.ngageoint.mage['web-core-lib'] || {}, global.ngageoint.mage['web-core-lib'].common = {}), global.ng.core, global.ng.common.http, global.ng.platformBrowser));
5
+ }(this, (function (exports, core, http, platformBrowser) { 'use strict';
6
+
7
+ var selector = 'mage-xhr-img';
8
+ var OBJECT_URL_SERVICE = new core.InjectionToken(selector + ".objectUrlService");
9
+ /**
10
+ * This component allows fetching images by `XMLHttpRequest` rather than the
11
+ * browser's native mechanism. These image requests are subject to HTTP
12
+ * interceptors that can add authorization headers to the request instead of
13
+ * using cache-defeating URL query parameters to set an auth token. Applying
14
+ * headers to the browser's native `img` requests is impossible, so a query
15
+ * parameter is necessary for authorization, but adding the parameter to the
16
+ * URL effectively bypasses the browser's caching mechanism when the auth token
17
+ * changes for images that
18
+ * should otherwise be subject to caching.
19
+ *
20
+ * The catch to fetching images by XHR is the response must be fetched as a
21
+ * `Blob`. The user then gets a browser-specific URL for the blob by
22
+ * `URL.createObjectURL(blob)`, which can then be assigned to the `src`
23
+ * attribute of an `img` tag. These blob URLs must then be "revoked" by
24
+ * `URL.revokeObjectURL(url)` in order to reclaim object URL's associated
25
+ * resources. See [Mozilla's docs](https://developer.mozilla.org/en-US/docs/Web/API/File/Using_files_from_web_applications#example_using_object_urls_to_display_images)
26
+ * on the subject.
27
+ *
28
+ * To use the component, simply add the tag to a template and bind the `src`
29
+ * attribute to the source URL of the desired image.
30
+ * ```
31
+ * <mage-xhr-img [src]="someComponent.imageUrlRequiresAuth"></mage-xhr-img>
32
+ * ```
33
+ * The component encapsulates the logic of creating and releasing the object
34
+ * URLs for the image data, preventing memory leaks.
35
+ */
36
+ var XhrImgComponent = /** @class */ (function () {
37
+ function XhrImgComponent(objectUrlService, http, sanitizer) {
38
+ this.objectUrlService = objectUrlService;
39
+ this.http = http;
40
+ this.sanitizer = sanitizer;
41
+ this.sourceUrl = null;
42
+ this.safeBlobUrl = null;
43
+ }
44
+ XhrImgComponent.prototype.ngOnChanges = function (changes) {
45
+ var _this = this;
46
+ if (!changes.sourceUrl) {
47
+ return;
48
+ }
49
+ if (changes.sourceUrl.isFirstChange() && !this.sourceUrl) {
50
+ return;
51
+ }
52
+ this.disposeCurrent();
53
+ if (!this.sourceUrl) {
54
+ return;
55
+ }
56
+ this.subscription = this.http.get(this.sourceUrl, { responseType: 'blob' })
57
+ .subscribe(function (x) {
58
+ _this.objectUrlService.revokeObjectURL(_this.blobUrl);
59
+ _this.blobUrl = _this.objectUrlService.createObjectURL(x);
60
+ _this.safeBlobUrl = _this.sanitizer.bypassSecurityTrustUrl(_this.blobUrl);
61
+ });
62
+ };
63
+ XhrImgComponent.prototype.ngOnDestroy = function () {
64
+ this.disposeCurrent();
65
+ };
66
+ XhrImgComponent.prototype.onImgLoad = function () {
67
+ this.disposeCurrent();
68
+ };
69
+ XhrImgComponent.prototype.disposeCurrent = function () {
70
+ if (this.blobUrl) {
71
+ this.objectUrlService.revokeObjectURL(this.blobUrl);
72
+ }
73
+ if (this.subscription) {
74
+ this.subscription.unsubscribe();
75
+ }
76
+ this.blobUrl = null;
77
+ };
78
+ XhrImgComponent.ɵfac = function XhrImgComponent_Factory(t) { return new (t || XhrImgComponent)(core.ɵɵdirectiveInject(OBJECT_URL_SERVICE), core.ɵɵdirectiveInject(http.HttpClient), core.ɵɵdirectiveInject(platformBrowser.DomSanitizer)); };
79
+ XhrImgComponent.ɵcmp = core.ɵɵdefineComponent({ type: XhrImgComponent, selectors: [["mage-xhr-img"]], inputs: { sourceUrl: ["src", "sourceUrl"] }, features: [core.ɵɵProvidersFeature([
80
+ {
81
+ provide: OBJECT_URL_SERVICE,
82
+ useValue: URL
83
+ }
84
+ ]), core.ɵɵNgOnChangesFeature], decls: 1, vars: 1, consts: [[3, "load"]], template: function XhrImgComponent_Template(rf, ctx) { if (rf & 1) {
85
+ core.ɵɵelementStart(0, "img", 0);
86
+ core.ɵɵlistener("load", function XhrImgComponent_Template_img_load_0_listener() { return ctx.onImgLoad(); });
87
+ core.ɵɵelementEnd();
88
+ } if (rf & 2) {
89
+ core.ɵɵattribute("src", ctx.safeBlobUrl, core.ɵɵsanitizeUrl);
90
+ } }, styles: ["img[_ngcontent-%COMP%] { height: 100%; width: 100% }"] });
91
+ return XhrImgComponent;
92
+ }());
93
+ /*@__PURE__*/ (function () { core.ɵsetClassMetadata(XhrImgComponent, [{
94
+ type: core.Component,
95
+ args: [{
96
+ selector: "" + selector,
97
+ template: "<img [attr.src]=\"safeBlobUrl\" (load)=\"onImgLoad()\"/>",
98
+ styles: ["img { height: 100%; width: 100% }"],
99
+ providers: [
100
+ {
101
+ provide: OBJECT_URL_SERVICE,
102
+ useValue: URL
103
+ }
104
+ ]
105
+ }]
106
+ }], function () { return [{ type: undefined, decorators: [{
107
+ type: core.Inject,
108
+ args: [OBJECT_URL_SERVICE]
109
+ }] }, { type: http.HttpClient }, { type: platformBrowser.DomSanitizer }]; }, { sourceUrl: [{
110
+ type: core.Input,
111
+ args: ['src']
112
+ }] }); })();
113
+
114
+ var MageCommonModule = /** @class */ (function () {
115
+ function MageCommonModule() {
116
+ }
117
+ MageCommonModule.ɵmod = core.ɵɵdefineNgModule({ type: MageCommonModule });
118
+ MageCommonModule.ɵinj = core.ɵɵdefineInjector({ factory: function MageCommonModule_Factory(t) { return new (t || MageCommonModule)(); }, imports: [[
119
+ platformBrowser.BrowserModule
120
+ ]] });
121
+ return MageCommonModule;
122
+ }());
123
+ (function () { (typeof ngJitMode === "undefined" || ngJitMode) && core.ɵɵsetNgModuleScope(MageCommonModule, { declarations: [XhrImgComponent], imports: [platformBrowser.BrowserModule], exports: [XhrImgComponent] }); })();
124
+ /*@__PURE__*/ (function () { core.ɵsetClassMetadata(MageCommonModule, [{
125
+ type: core.NgModule,
126
+ args: [{
127
+ imports: [
128
+ platformBrowser.BrowserModule
129
+ ],
130
+ declarations: [
131
+ XhrImgComponent
132
+ ],
133
+ exports: [
134
+ XhrImgComponent
135
+ ]
136
+ }]
137
+ }], null, null); })();
138
+
139
+ exports.MageCommonModule = MageCommonModule;
140
+ exports.OBJECT_URL_SERVICE = OBJECT_URL_SERVICE;
141
+ exports.XhrImgComponent = XhrImgComponent;
142
+
143
+ Object.defineProperty(exports, '__esModule', { value: true });
144
+
145
+ })));
146
+ //# sourceMappingURL=ngageoint-mage.web-core-lib-common.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ngageoint-mage.web-core-lib-common.umd.js","sources":["ng://@ngageoint/mage.web-core-lib/common/xhr-img.component.ts","ng://@ngageoint/mage.web-core-lib/common/mage-common.module.ts"],"sourcesContent":["import { Component, ElementRef, Inject, InjectionToken, Input, OnChanges, OnDestroy, SimpleChanges } from '@angular/core'\nimport { HttpClient } from '@angular/common/http'\nimport { DomSanitizer, SafeUrl } from '@angular/platform-browser'\nimport { Subscription } from 'rxjs'\n\nconst selector = 'mage-xhr-img'\n\n/**\n * This is a simple interface that includes the [methods](https://www.w3.org/TR/FileAPI/#creating-revoking)\n * from the [URL API](https://developer.mozilla.org/en-US/docs/Web/API/URL) for\n * managing blob URLs. This allows a service to be injected into\n * `XhrImgComponent` and overridden for testing.\n */\nexport interface ObjectUrlService {\n createObjectURL: (typeof URL)['createObjectURL']\n revokeObjectURL: (typeof URL)['revokeObjectURL']\n}\nexport const OBJECT_URL_SERVICE = new InjectionToken<ObjectUrlService>(`${selector}.objectUrlService`)\n\n/**\n * This component allows fetching images by `XMLHttpRequest` rather than the\n * browser's native mechanism. These image requests are subject to HTTP\n * interceptors that can add authorization headers to the request instead of\n * using cache-defeating URL query parameters to set an auth token. Applying\n * headers to the browser's native `img` requests is impossible, so a query\n * parameter is necessary for authorization, but adding the parameter to the\n * URL effectively bypasses the browser's caching mechanism when the auth token\n * changes for images that\n * should otherwise be subject to caching.\n *\n * The catch to fetching images by XHR is the response must be fetched as a\n * `Blob`. The user then gets a browser-specific URL for the blob by\n * `URL.createObjectURL(blob)`, which can then be assigned to the `src`\n * attribute of an `img` tag. These blob URLs must then be \"revoked\" by\n * `URL.revokeObjectURL(url)` in order to reclaim object URL's associated\n * resources. See [Mozilla's docs](https://developer.mozilla.org/en-US/docs/Web/API/File/Using_files_from_web_applications#example_using_object_urls_to_display_images)\n * on the subject.\n *\n * To use the component, simply add the tag to a template and bind the `src`\n * attribute to the source URL of the desired image.\n * ```\n * <mage-xhr-img [src]=\"someComponent.imageUrlRequiresAuth\"></mage-xhr-img>\n * ```\n * The component encapsulates the logic of creating and releasing the object\n * URLs for the image data, preventing memory leaks.\n */\n@Component({\n selector: `${selector}`,\n template: `<img [attr.src]=\"safeBlobUrl\" (load)=\"onImgLoad()\"/>`,\n styles: [ `img { height: 100%; width: 100% }` ],\n providers: [\n {\n provide: OBJECT_URL_SERVICE,\n useValue: URL\n }\n ]\n})\nexport class XhrImgComponent implements OnChanges, OnDestroy {\n\n @Input('src')\n sourceUrl: string | null = null\n safeBlobUrl: SafeUrl | null = null\n\n private blobUrl: string\n private subscription: Subscription\n\n constructor(@Inject(OBJECT_URL_SERVICE) private objectUrlService: ObjectUrlService, private http: HttpClient, private sanitizer: DomSanitizer) {}\n\n ngOnChanges(changes: SimpleChanges) {\n if (!changes.sourceUrl) {\n return\n }\n if (changes.sourceUrl.isFirstChange() && !this.sourceUrl) {\n return\n }\n this.disposeCurrent()\n if (!this.sourceUrl) {\n return\n }\n this.subscription = this.http.get(this.sourceUrl, { responseType: 'blob' })\n .subscribe(x => {\n this.objectUrlService.revokeObjectURL(this.blobUrl)\n this.blobUrl = this.objectUrlService.createObjectURL(x)\n this.safeBlobUrl = this.sanitizer.bypassSecurityTrustUrl(this.blobUrl)\n })\n }\n\n ngOnDestroy() {\n this.disposeCurrent()\n }\n\n onImgLoad() {\n this.disposeCurrent()\n }\n\n private disposeCurrent() {\n if (this.blobUrl) {\n this.objectUrlService.revokeObjectURL(this.blobUrl)\n }\n if (this.subscription) {\n this.subscription.unsubscribe()\n }\n this.blobUrl = null\n }\n}","import { NgModule } from '@angular/core'\nimport { BrowserModule } from '@angular/platform-browser'\nimport { XhrImgComponent } from './xhr-img.component'\n\n@NgModule({\n imports: [\n BrowserModule\n ],\n declarations: [\n XhrImgComponent\n ],\n exports: [\n XhrImgComponent\n ]\n})\nexport class MageCommonModule {}"],"names":["InjectionToken","i0.ɵɵelementStart","i0.ɵɵlistener","i0.ɵɵelementEnd","i0.ɵɵattribute","Component","Inject","Input","BrowserModule","NgModule"],"mappings":";;;;;;IAKA,IAAM,QAAQ,GAAG,cAAc,CAAA;QAYlB,kBAAkB,GAAG,IAAIA,mBAAc,CAAsB,QAAQ,sBAAmB,EAAC;IAEtG;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA+CE,yBAAgD,gBAAkC,EAAU,IAAgB,EAAU,SAAuB;YAA7F,qBAAgB,GAAhB,gBAAgB,CAAkB;YAAU,SAAI,GAAJ,IAAI,CAAY;YAAU,cAAS,GAAT,SAAS,CAAc;YAN7I,cAAS,GAAkB,IAAI,CAAA;YAC/B,gBAAW,GAAmB,IAAI,CAAA;SAK+G;QAEjJ,qCAAW,GAAX,UAAY,OAAsB;YAAlC,iBAiBC;YAhBC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE;gBACtB,OAAM;aACP;YACD,IAAI,OAAO,CAAC,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,S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,QAAQ,EAAE,KAAG,QAAU;oBACvB,QAAQ,EAAE,0DAAsD;oBAChE,MAAM,EAAE,CAAE,mCAAmC,CAAE;oBAC/C,SAAS,EAAE;wBACT;4BACE,OAAO,EAAE,kBAAkB;4BAC3B,QAAQ,EAAE,GAAG;yBACd;qBACF;iBACF;;0BAUcC,WAAM;2BAAC,kBAAkB;;sBAPrCC,UAAK;uBAAC,KAAK;;;;QCvDd;SAWgC;8DAAnB,gBAAgB;yHAAhB,gBAAgB,kBAVlB;oBACPC,6BAAa;iBACd;+BAPH;KAIA,IAWgC;8FAAnB,gBAAgB,mBANzB,eAAe,aAHfA,6BAAa,aAMb,eAAe;wDAGN,gBAAgB;kBAX5BC,aAAQ;mBAAC;oBACR,OAAO,EAAE;wBACPD,6BAAa;qBACd;oBACD,YAAY,EAAE;wBACZ,eAAe;qBAChB;oBACD,OAAO,EAAE;wBACP,eAAe;qBAChB;iBACF;;;;;;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common/http"),require("@angular/platform-browser")):"function"==typeof define&&define.amd?define("@ngageoint/mage.web-core-lib/common",["exports","@angular/core","@angular/common/http","@angular/platform-browser"],t):t(((e=e||self).ngageoint=e.ngageoint||{},e.ngageoint.mage=e.ngageoint.mage||{},e.ngageoint.mage["web-core-lib"]=e.ngageoint.mage["web-core-lib"]||{},e.ngageoint.mage["web-core-lib"].common={}),e.ng.core,e.ng.common.http,e.ng.platformBrowser)}(this,(function(e,t,r,o){"use strict";var n=new t.InjectionToken("mage-xhr-img.objectUrlService"),i=function(){function e(e,t,r){this.objectUrlService=e,this.http=t,this.sanitizer=r,this.sourceUrl=null,this.safeBlobUrl=null}return e.prototype.ngOnChanges=function(e){var t=this;e.sourceUrl&&(e.sourceUrl.isFirstChange()&&!this.sourceUrl||(this.disposeCurrent(),this.sourceUrl&&(this.subscription=this.http.get(this.sourceUrl,{responseType:"blob"}).subscribe((function(e){t.objectUrlService.revokeObjectURL(t.blobUrl),t.blobUrl=t.objectUrlService.createObjectURL(e),t.safeBlobUrl=t.sanitizer.bypassSecurityTrustUrl(t.blobUrl)})))))},e.prototype.ngOnDestroy=function(){this.disposeCurrent()},e.prototype.onImgLoad=function(){this.disposeCurrent()},e.prototype.disposeCurrent=function(){this.blobUrl&&this.objectUrlService.revokeObjectURL(this.blobUrl),this.subscription&&this.subscription.unsubscribe(),this.blobUrl=null},e.ɵfac=function(i){return new(i||e)(t.ɵɵdirectiveInject(n),t.ɵɵdirectiveInject(r.HttpClient),t.ɵɵdirectiveInject(o.DomSanitizer))},e.ɵcmp=t.ɵɵdefineComponent({type:e,selectors:[["mage-xhr-img"]],inputs:{sourceUrl:["src","sourceUrl"]},features:[t.ɵɵProvidersFeature([{provide:n,useValue:URL}]),t.ɵɵNgOnChangesFeature],decls:1,vars:1,consts:[[3,"load"]],template:function(e,r){1&e&&(t.ɵɵelementStart(0,"img",0),t.ɵɵlistener("load",(function(){return r.onImgLoad()})),t.ɵɵelementEnd()),2&e&&t.ɵɵattribute("src",r.safeBlobUrl,t.ɵɵsanitizeUrl)},styles:["img[_ngcontent-%COMP%] { height: 100%; width: 100% }"]}),e}(),s=function(){function e(){}return e.ɵmod=t.ɵɵdefineNgModule({type:e}),e.ɵinj=t.ɵɵdefineInjector({factory:function(t){return new(t||e)},imports:[[o.BrowserModule]]}),e}();("undefined"==typeof ngJitMode||ngJitMode)&&t.ɵɵsetNgModuleScope(s,{declarations:[i],imports:[o.BrowserModule],exports:[i]}),e.MageCommonModule=s,e.OBJECT_URL_SERVICE=n,e.XhrImgComponent=i,Object.defineProperty(e,"__esModule",{value:!0})}));
2
+ //# sourceMappingURL=ngageoint-mage.web-core-lib-common.umd.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["ng://@ngageoint/mage.web-core-lib/common/xhr-img.component.ts","ng://@ngageoint/mage.web-core-lib/common/mage-common.module.ts"],"names":["OBJECT_URL_SERVICE","InjectionToken","selector","XhrImgComponent","objectUrlService","http","sanitizer","this","sourceUrl","safeBlobUrl","prototype","ngOnChanges","changes","_this","isFirstChange","disposeCurrent","subscription","get","responseType","subscribe","x","revokeObjectURL","blobUrl","createObjectURL","bypassSecurityTrustUrl","ngOnDestroy","onImgLoad","unsubscribe","core","ɵɵdirectiveInject","HttpClient","platformBrowser","DomSanitizer","selectors","inputs","features","ɵɵProvidersFeature","provide","useValue","URL","ɵɵNgOnChangesFeature","decls","vars","consts","template","rf","ctx","i0.ɵɵelementStart","i0.ɵɵlistener","i0.ɵɵelementEnd","i0.ɵɵattribute","MageCommonModule","imports","BrowserModule","declarations","exports"],"mappings":"0mBAKA,IAYaA,EAAqB,IAAIC,EAAAA,eAAoCC,8CAiDxE,SAAAC,EAAgDC,EAA4CC,EAA0BC,GAAtEC,KAAAH,iBAAAA,EAA4CG,KAAAF,KAAAA,EAA0BE,KAAAD,UAAAA,EANtHC,KAAAC,UAA2B,KAC3BD,KAAAE,YAA8B,YAO9BN,EAAAO,UAAAC,YAAA,SAAYC,GAAZ,IAAAC,EAAAN,KACOK,EAAQJ,YAGTI,EAAQJ,UAAUM,kBAAoBP,KAAKC,YAG/CD,KAAKQ,iBACAR,KAAKC,YAGVD,KAAKS,aAAeT,KAAKF,KAAKY,IAAIV,KAAKC,UAAW,CAAEU,aAAc,SAC/DC,WAAU,SAAAC,GACTP,EAAKT,iBAAiBiB,gBAAgBR,EAAKS,SAC3CT,EAAKS,QAAUT,EAAKT,iBAAiBmB,gBAAgBH,GACrDP,EAAKJ,YAAcI,EAAKP,UAAUkB,uBAAuBX,EAAKS,gBAIpEnB,EAAAO,UAAAe,YAAA,WACElB,KAAKQ,kBAGPZ,EAAAO,UAAAgB,UAAA,WACEnB,KAAKQ,kBAGCZ,EAAAO,UAAAK,eAAR,WACMR,KAAKe,SACPf,KAAKH,iBAAiBiB,gBAAgBd,KAAKe,SAEzCf,KAAKS,cACPT,KAAKS,aAAaW,cAEpBpB,KAAKe,QAAU,uCA7CNnB,GAAeyB,EAAAC,kBASN7B,GAAkB4B,EAAAC,kBAAAxB,EAAAyB,YAAAF,EAAAC,kBAAAE,EAAAC,iDAT3B7B,EAAe8B,UAAA,CAAA,CAAA,iBAAAC,OAAA,CAAA1B,UAAA,CAAA,MAAA,cAAA2B,SAAA,CAAAP,EAAAQ,mBAPf,CACT,CACEC,QAASrC,EACTsC,SAAUC,OAEbX,EAAAY,sBAAAC,MAAA,EAAAC,KAAA,EAAAC,OAAA,CAAA,CAAA,EAAA,SAAAC,SAAA,SAAAC,EAAAC,GAAA,EAAAD,IAPUE,EAAAA,eAAAA,EAAAA,MAAAA,GAA8BC,EAAAA,WAAAA,QAAAA,WAAAA,OAAQF,EAAApB,eAAtCuB,EAAAA,qBAAKC,EAAAA,YAAAA,MAAAA,EAAAA,YAAAA,EAAAA,oGC5ClB,SAAAC,4CAWaA,iEAAAA,IAAgBC,QAAA,CAVlB,CACPC,EAAAA,wFASSF,EAAgB,CAAAG,aAAA,CANzBnD,GAAeiD,QAAA,CAHfC,EAAAA,eAAaE,QAAA,CAMbpD","sourcesContent":["import { Component, ElementRef, Inject, InjectionToken, Input, OnChanges, OnDestroy, SimpleChanges } from '@angular/core'\nimport { HttpClient } from '@angular/common/http'\nimport { DomSanitizer, SafeUrl } from '@angular/platform-browser'\nimport { Subscription } from 'rxjs'\n\nconst selector = 'mage-xhr-img'\n\n/**\n * This is a simple interface that includes the [methods](https://www.w3.org/TR/FileAPI/#creating-revoking)\n * from the [URL API](https://developer.mozilla.org/en-US/docs/Web/API/URL) for\n * managing blob URLs. This allows a service to be injected into\n * `XhrImgComponent` and overridden for testing.\n */\nexport interface ObjectUrlService {\n createObjectURL: (typeof URL)['createObjectURL']\n revokeObjectURL: (typeof URL)['revokeObjectURL']\n}\nexport const OBJECT_URL_SERVICE = new InjectionToken<ObjectUrlService>(`${selector}.objectUrlService`)\n\n/**\n * This component allows fetching images by `XMLHttpRequest` rather than the\n * browser's native mechanism. These image requests are subject to HTTP\n * interceptors that can add authorization headers to the request instead of\n * using cache-defeating URL query parameters to set an auth token. Applying\n * headers to the browser's native `img` requests is impossible, so a query\n * parameter is necessary for authorization, but adding the parameter to the\n * URL effectively bypasses the browser's caching mechanism when the auth token\n * changes for images that\n * should otherwise be subject to caching.\n *\n * The catch to fetching images by XHR is the response must be fetched as a\n * `Blob`. The user then gets a browser-specific URL for the blob by\n * `URL.createObjectURL(blob)`, which can then be assigned to the `src`\n * attribute of an `img` tag. These blob URLs must then be \"revoked\" by\n * `URL.revokeObjectURL(url)` in order to reclaim object URL's associated\n * resources. See [Mozilla's docs](https://developer.mozilla.org/en-US/docs/Web/API/File/Using_files_from_web_applications#example_using_object_urls_to_display_images)\n * on the subject.\n *\n * To use the component, simply add the tag to a template and bind the `src`\n * attribute to the source URL of the desired image.\n * ```\n * <mage-xhr-img [src]=\"someComponent.imageUrlRequiresAuth\"></mage-xhr-img>\n * ```\n * The component encapsulates the logic of creating and releasing the object\n * URLs for the image data, preventing memory leaks.\n */\n@Component({\n selector: `${selector}`,\n template: `<img [attr.src]=\"safeBlobUrl\" (load)=\"onImgLoad()\"/>`,\n styles: [ `img { height: 100%; width: 100% }` ],\n providers: [\n {\n provide: OBJECT_URL_SERVICE,\n useValue: URL\n }\n ]\n})\nexport class XhrImgComponent implements OnChanges, OnDestroy {\n\n @Input('src')\n sourceUrl: string | null = null\n safeBlobUrl: SafeUrl | null = null\n\n private blobUrl: string\n private subscription: Subscription\n\n constructor(@Inject(OBJECT_URL_SERVICE) private objectUrlService: ObjectUrlService, private http: HttpClient, private sanitizer: DomSanitizer) {}\n\n ngOnChanges(changes: SimpleChanges) {\n if (!changes.sourceUrl) {\n return\n }\n if (changes.sourceUrl.isFirstChange() && !this.sourceUrl) {\n return\n }\n this.disposeCurrent()\n if (!this.sourceUrl) {\n return\n }\n this.subscription = this.http.get(this.sourceUrl, { responseType: 'blob' })\n .subscribe(x => {\n this.objectUrlService.revokeObjectURL(this.blobUrl)\n this.blobUrl = this.objectUrlService.createObjectURL(x)\n this.safeBlobUrl = this.sanitizer.bypassSecurityTrustUrl(this.blobUrl)\n })\n }\n\n ngOnDestroy() {\n this.disposeCurrent()\n }\n\n onImgLoad() {\n this.disposeCurrent()\n }\n\n private disposeCurrent() {\n if (this.blobUrl) {\n this.objectUrlService.revokeObjectURL(this.blobUrl)\n }\n if (this.subscription) {\n this.subscription.unsubscribe()\n }\n this.blobUrl = null\n }\n}","import { NgModule } from '@angular/core'\nimport { BrowserModule } from '@angular/platform-browser'\nimport { XhrImgComponent } from './xhr-img.component'\n\n@NgModule({\n imports: [\n BrowserModule\n ],\n declarations: [\n XhrImgComponent\n ],\n exports: [\n XhrImgComponent\n ]\n})\nexport class MageCommonModule {}"]}
@@ -0,0 +1,14 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core')) :
3
+ typeof define === 'function' && define.amd ? define('@ngageoint/mage.web-core-lib/event', ['exports', '@angular/core'], factory) :
4
+ (global = global || self, factory((global.ngageoint = global.ngageoint || {}, global.ngageoint.mage = global.ngageoint.mage || {}, global.ngageoint.mage['web-core-lib'] = global.ngageoint.mage['web-core-lib'] || {}, global.ngageoint.mage['web-core-lib'].event = {}), global.ng.core));
5
+ }(this, (function (exports, core) { 'use strict';
6
+
7
+ var EVENT_READ_SERVICE = new core.InjectionToken('EventReadService');
8
+
9
+ exports.EVENT_READ_SERVICE = EVENT_READ_SERVICE;
10
+
11
+ Object.defineProperty(exports, '__esModule', { value: true });
12
+
13
+ })));
14
+ //# sourceMappingURL=ngageoint-mage.web-core-lib-event.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ngageoint-mage.web-core-lib-event.umd.js","sources":["ng://@ngageoint/mage.web-core-lib/event/event-read.service.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core'\nimport { PagingParameters } from '@ngageoint/mage.web-core-lib/paging'\nimport { Observable } from 'rxjs'\nimport { MageEvent } from './event.model'\n\nexport interface EventReadService {\n find(which: EventReadParams): Observable<MageEvent[]>\n}\n\nexport interface EventReadParams {\n page: PagingParameters\n}\n\nexport const EVENT_READ_SERVICE = new InjectionToken<EventReadService>('EventReadService')"],"names":["InjectionToken"],"mappings":";;;;;;KAaa,kBAAkB,GAAG,IAAIA,mBAAc,CAAmB,kBAAkB;;;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@angular/core")):"function"==typeof define&&define.amd?define("@ngageoint/mage.web-core-lib/event",["exports","@angular/core"],n):n(((e=e||self).ngageoint=e.ngageoint||{},e.ngageoint.mage=e.ngageoint.mage||{},e.ngageoint.mage["web-core-lib"]=e.ngageoint.mage["web-core-lib"]||{},e.ngageoint.mage["web-core-lib"].event={}),e.ng.core)}(this,(function(e,n){"use strict";var o=new n.InjectionToken("EventReadService");e.EVENT_READ_SERVICE=o,Object.defineProperty(e,"__esModule",{value:!0})}));
2
+ //# sourceMappingURL=ngageoint-mage.web-core-lib-event.umd.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["ng://@ngageoint/mage.web-core-lib/event/event-read.service.ts"],"names":["EVENT_READ_SERVICE","InjectionToken"],"mappings":"0cAaaA,EAAqB,IAAIC,EAAAA,eAAiC","sourcesContent":["import { InjectionToken } from '@angular/core'\nimport { PagingParameters } from '@ngageoint/mage.web-core-lib/paging'\nimport { Observable } from 'rxjs'\nimport { MageEvent } from './event.model'\n\nexport interface EventReadService {\n find(which: EventReadParams): Observable<MageEvent[]>\n}\n\nexport interface EventReadParams {\n page: PagingParameters\n}\n\nexport const EVENT_READ_SERVICE = new InjectionToken<EventReadService>('EventReadService')"]}
@@ -0,0 +1,114 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('@angular/common/http')) :
3
+ typeof define === 'function' && define.amd ? define('@ngageoint/mage.web-core-lib/feed', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', '@angular/common/http'], factory) :
4
+ (global = global || self, factory((global.ngageoint = global.ngageoint || {}, global.ngageoint.mage = global.ngageoint.mage || {}, global.ngageoint.mage['web-core-lib'] = global.ngageoint.mage['web-core-lib'] || {}, global.ngageoint.mage['web-core-lib'].feed = {}), global.ng.core, global.rxjs, global.rxjs.operators, global.ng.common.http));
5
+ }(this, (function (exports, core, rxjs, operators, http) { 'use strict';
6
+
7
+ var FeedService = /** @class */ (function () {
8
+ function FeedService(http) {
9
+ this.http = http;
10
+ // TODO: there is probably a better solution than maintaining this map here
11
+ this._feeds = new rxjs.BehaviorSubject([]);
12
+ this.feeds = this._feeds.asObservable();
13
+ this._feedItems = new Map();
14
+ }
15
+ FeedService.prototype.feedItems = function (feedId) {
16
+ return this._feedItems.get(feedId).asObservable();
17
+ };
18
+ FeedService.prototype.fetchAllFeeds = function () {
19
+ return this.http.get('/api/feeds/');
20
+ };
21
+ FeedService.prototype.fetchFeed = function (feedId) {
22
+ return this.http.get("/api/feeds/" + feedId);
23
+ };
24
+ FeedService.prototype.fetchService = function (serviceId) {
25
+ return this.http.get("/api/feeds/services/" + serviceId);
26
+ };
27
+ FeedService.prototype.createService = function (service) {
28
+ return this.http.post("/api/feeds/services", service);
29
+ };
30
+ FeedService.prototype.fetchServices = function () {
31
+ return this.http.get("/api/feeds/services");
32
+ };
33
+ FeedService.prototype.fetchServiceFeeds = function (serviceId) {
34
+ return this.http.get("/api/feeds/services/" + serviceId + "/feeds");
35
+ };
36
+ FeedService.prototype.fetchServiceType = function (serviceTypeId) {
37
+ return this.http.get("/api/feeds/service_types/" + serviceTypeId);
38
+ };
39
+ FeedService.prototype.fetchTopics = function (serviceId) {
40
+ return this.http.get("/api/feeds/services/" + serviceId + "/topics");
41
+ };
42
+ FeedService.prototype.previewFeed = function (serviceId, topicId, feedSpec, opts) {
43
+ opts = opts || {};
44
+ var skipContentFetch = opts.skipContentFetch === true;
45
+ return this.http.post("/api/feeds/services/" + serviceId + "/topics/" + topicId + "/feed_preview?skip_content_fetch=" + skipContentFetch, { feed: feedSpec });
46
+ };
47
+ FeedService.prototype.fetchTopic = function (serviceId, topicId) {
48
+ return this.http.get("/api/feeds/services/" + serviceId + "/topics/" + topicId);
49
+ };
50
+ FeedService.prototype.fetchServiceTypes = function () {
51
+ return this.http.get("/api/feeds/service_types");
52
+ };
53
+ FeedService.prototype.createFeed = function (serviceId, topicId, feedConfiguration) {
54
+ return this.http.post("/api/feeds/services/" + serviceId + "/topics/" + topicId + "/feeds", feedConfiguration);
55
+ };
56
+ FeedService.prototype.updateFeed = function (feed) {
57
+ return this.http.put("/api/feeds/" + feed.id, feed);
58
+ };
59
+ FeedService.prototype.deleteFeed = function (feed) {
60
+ return this.http.delete("/api/feeds/" + feed.id, { responseType: 'text' });
61
+ };
62
+ FeedService.prototype.deleteService = function (service) {
63
+ console.log('delete');
64
+ return this.http.delete("/api/feeds/services/" + service.id, { responseType: 'text' });
65
+ };
66
+ FeedService.prototype.fetchFeeds = function (eventId) {
67
+ var _this = this;
68
+ var subject = new rxjs.Subject();
69
+ this.http.get("/api/events/" + eventId + "/feeds").subscribe(function (feeds) {
70
+ feeds.map(function (feed) {
71
+ feed.id = feed.id.toString();
72
+ return feed;
73
+ });
74
+ feeds.forEach(function (feed) {
75
+ var feedItems = _this._feedItems.get(feed.id);
76
+ if (!feedItems) {
77
+ feedItems = new rxjs.BehaviorSubject([]);
78
+ _this._feedItems.set(feed.id, feedItems);
79
+ }
80
+ });
81
+ subject.next(feeds);
82
+ _this._feeds.next(feeds);
83
+ });
84
+ return subject;
85
+ };
86
+ FeedService.prototype.fetchFeedItems = function (event, feed) {
87
+ var feedItems = this._feedItems.get(feed.id);
88
+ return this.http.post("/api/events/" + event.id + "/feeds/" + feed.id + "/content", {}).pipe(operators.map(function (content) {
89
+ var features = content.items.features;
90
+ features.forEach(function (feature) {
91
+ feature.id = String(feature.id);
92
+ feature.properties = feature.properties || {};
93
+ });
94
+ feedItems.next(features);
95
+ return content;
96
+ }));
97
+ };
98
+ FeedService.ɵfac = function FeedService_Factory(t) { return new (t || FeedService)(core.ɵɵinject(http.HttpClient)); };
99
+ FeedService.ɵprov = core.ɵɵdefineInjectable({ token: FeedService, factory: FeedService.ɵfac, providedIn: 'root' });
100
+ return FeedService;
101
+ }());
102
+ /*@__PURE__*/ (function () { core.ɵsetClassMetadata(FeedService, [{
103
+ type: core.Injectable,
104
+ args: [{
105
+ providedIn: 'root'
106
+ }]
107
+ }], function () { return [{ type: http.HttpClient }]; }, null); })();
108
+
109
+ exports.FeedService = FeedService;
110
+
111
+ Object.defineProperty(exports, '__esModule', { value: true });
112
+
113
+ })));
114
+ //# sourceMappingURL=ngageoint-mage.web-core-lib-feed.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ngageoint-mage.web-core-lib-feed.umd.js","sources":["ng://@ngageoint/mage.web-core-lib/feed/feed.service.ts"],"sourcesContent":["import { HttpClient } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { Feature } from 'geojson'\nimport { BehaviorSubject, Observable, Subject } from 'rxjs'\nimport { map } from 'rxjs/operators'\nimport { Feed, FeedContent, FeedExpanded, FeedPost, FeedPreview, FeedTopic, Service, ServiceType, StyledFeature } from './feed.model'\n\n\nexport interface FeedPreviewOptions {\n skipContentFetch?: boolean\n}\n\n@Injectable({\n providedIn: 'root'\n})\nexport class FeedService {\n\n constructor(private http: HttpClient) { }\n\n // TODO: there is probably a better solution than maintaining this map here\n private _feeds = new BehaviorSubject<Array<Feed>>([]);\n readonly feeds = this._feeds.asObservable();\n\n private _feedItems = new Map<string, BehaviorSubject<Array<Feature>>>();\n feedItems(feedId: string): Observable<Array<Feature>> {\n return this._feedItems.get(feedId).asObservable();\n }\n\n fetchAllFeeds(): Observable<Array<Feed>> {\n return this.http.get<Array<Feed>>('/api/feeds/');\n }\n\n fetchFeed(feedId: string): Observable<FeedExpanded> {\n return this.http.get<FeedExpanded>(`/api/feeds/${feedId}`);\n }\n\n fetchService(serviceId: string): Observable<Service> {\n return this.http.get<Service>(`/api/feeds/services/${serviceId}`);\n }\n\n createService(service: { title: string, summary?: string, serviceType: string, config: any}): Observable<Service> {\n return this.http.post<Service>(`/api/feeds/services`, service);\n }\n\n fetchServices(): Observable<Array<Service>> {\n return this.http.get<Array<Service>>(`/api/feeds/services`);\n }\n\n fetchServiceFeeds(serviceId: string): Observable<Array<Feed>> {\n return this.http.get<Array<Feed>>(`/api/feeds/services/${serviceId}/feeds`);\n }\n\n fetchServiceType(serviceTypeId: string): Observable<ServiceType> {\n return this.http.get<ServiceType>(`/api/feeds/service_types/${serviceTypeId}`);\n }\n\n fetchTopics(serviceId: string): Observable<Array<FeedTopic>> {\n return this.http.get<Array<FeedTopic>>(`/api/feeds/services/${serviceId}/topics`);\n }\n\n previewFeed(serviceId: string, topicId: string, feedSpec: Partial<Omit<FeedPost, 'service' | 'topic'>>, opts?: FeedPreviewOptions): Observable<FeedPreview> {\n opts = opts || {}\n const skipContentFetch: boolean = opts.skipContentFetch === true\n return this.http.post<FeedPreview>(\n `/api/feeds/services/${serviceId}/topics/${topicId}/feed_preview?skip_content_fetch=${skipContentFetch}`,\n { feed: feedSpec });\n }\n\n fetchTopic(serviceId: string, topicId: string): Observable<FeedTopic> {\n return this.http.get<FeedTopic>(`/api/feeds/services/${serviceId}/topics/${topicId}`);\n }\n\n fetchServiceTypes(): Observable<Array<ServiceType>> {\n return this.http.get<Array<ServiceType>>(`/api/feeds/service_types`);\n }\n\n createFeed(serviceId: string, topicId: string, feedConfiguration: any): Observable<FeedExpanded> {\n return this.http.post<FeedExpanded>(`/api/feeds/services/${serviceId}/topics/${topicId}/feeds`, feedConfiguration);\n }\n\n updateFeed(feed: Partial<Omit<FeedPost, 'id'>> & Pick<Feed, 'id'>): Observable<FeedExpanded> {\n return this.http.put<FeedExpanded>(`/api/feeds/${feed.id}`, feed);\n }\n\n deleteFeed(feed: Feed | FeedExpanded): Observable<{}> {\n return this.http.delete(`/api/feeds/${feed.id}`, {responseType: 'text'});\n }\n\n deleteService(service: Service): Observable<{}> {\n console.log('delete')\n return this.http.delete(`/api/feeds/services/${service.id}`, { responseType: 'text' });\n }\n\n fetchFeeds(eventId: number): Observable<Array<Feed>> {\n const subject = new Subject<Array<Feed>>();\n this.http.get<Array<Feed>>(`/api/events/${eventId}/feeds`).subscribe(feeds => {\n feeds.map(feed => {\n feed.id = feed.id.toString();\n return feed;\n });\n\n feeds.forEach(feed => {\n let feedItems = this._feedItems.get(feed.id);\n if (!feedItems) {\n feedItems = new BehaviorSubject<Array<Feature>>([]);\n this._feedItems.set(feed.id, feedItems);\n }\n })\n\n subject.next(feeds);\n this._feeds.next(feeds);\n });\n\n return subject;\n }\n\n fetchFeedItems(event: any, feed: Feed): Observable<FeedContent> {\n const feedItems = this._feedItems.get(feed.id)\n return this.http.post<FeedContent>(`/api/events/${event.id}/feeds/${feed.id}/content`, {}).pipe(\n map(content => {\n const features = content.items.features\n features.forEach((feature: StyledFeature) => {\n feature.id = String(feature.id)\n feature.properties = feature.properties || {}\n })\n feedItems.next(features)\n return content\n })\n )\n }\n}\n"],"names":["BehaviorSubject","Subject","map","Injectable"],"mappings":";;;;;;;QAiBE,qBAAoB,IAAgB;YAAhB,SAAI,GAAJ,IAAI,CAAY;;YAG5B,WAAM,GAAG,IAAIA,oBAAe,CAAc,EAAE,CAAC,CAAC;YAC7C,UAAK,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YAEpC,eAAU,GAAG,IAAI,GAAG,EAA2C,CAAC;SAN/B;QAOzC,+BAAS,GAAT,UAAU,MAAc;YACtB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,YAAY,EAAE,CAAC;SACnD;QAED,mCAAa,GAAb;YACE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAc,aAAa,CAAC,CAAC;SAClD;QAED,+BAAS,GAAT,UAAU,MAAc;YACtB,O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2 @@
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("rxjs"),require("rxjs/operators"),require("@angular/common/http")):"function"==typeof define&&define.amd?define("@ngageoint/mage.web-core-lib/feed",["exports","@angular/core","rxjs","rxjs/operators","@angular/common/http"],t):t(((e=e||self).ngageoint=e.ngageoint||{},e.ngageoint.mage=e.ngageoint.mage||{},e.ngageoint.mage["web-core-lib"]=e.ngageoint.mage["web-core-lib"]||{},e.ngageoint.mage["web-core-lib"].feed={}),e.ng.core,e.rxjs,e.rxjs.operators,e.ng.common.http)}(this,(function(e,t,i,r,n){"use strict";var o=function(){function e(e){this.http=e,this._feeds=new i.BehaviorSubject([]),this.feeds=this._feeds.asObservable(),this._feedItems=new Map}return e.prototype.feedItems=function(e){return this._feedItems.get(e).asObservable()},e.prototype.fetchAllFeeds=function(){return this.http.get("/api/feeds/")},e.prototype.fetchFeed=function(e){return this.http.get("/api/feeds/"+e)},e.prototype.fetchService=function(e){return this.http.get("/api/feeds/services/"+e)},e.prototype.createService=function(e){return this.http.post("/api/feeds/services",e)},e.prototype.fetchServices=function(){return this.http.get("/api/feeds/services")},e.prototype.fetchServiceFeeds=function(e){return this.http.get("/api/feeds/services/"+e+"/feeds")},e.prototype.fetchServiceType=function(e){return this.http.get("/api/feeds/service_types/"+e)},e.prototype.fetchTopics=function(e){return this.http.get("/api/feeds/services/"+e+"/topics")},e.prototype.previewFeed=function(e,t,i,r){var n=!0===(r=r||{}).skipContentFetch;return this.http.post("/api/feeds/services/"+e+"/topics/"+t+"/feed_preview?skip_content_fetch="+n,{feed:i})},e.prototype.fetchTopic=function(e,t){return this.http.get("/api/feeds/services/"+e+"/topics/"+t)},e.prototype.fetchServiceTypes=function(){return this.http.get("/api/feeds/service_types")},e.prototype.createFeed=function(e,t,i){return this.http.post("/api/feeds/services/"+e+"/topics/"+t+"/feeds",i)},e.prototype.updateFeed=function(e){return this.http.put("/api/feeds/"+e.id,e)},e.prototype.deleteFeed=function(e){return this.http.delete("/api/feeds/"+e.id,{responseType:"text"})},e.prototype.deleteService=function(e){return console.log("delete"),this.http.delete("/api/feeds/services/"+e.id,{responseType:"text"})},e.prototype.fetchFeeds=function(e){var t=this,r=new i.Subject;return this.http.get("/api/events/"+e+"/feeds").subscribe((function(e){e.map((function(e){return e.id=e.id.toString(),e})),e.forEach((function(e){var r=t._feedItems.get(e.id);r||(r=new i.BehaviorSubject([]),t._feedItems.set(e.id,r))})),r.next(e),t._feeds.next(e)})),r},e.prototype.fetchFeedItems=function(e,t){var i=this._feedItems.get(t.id);return this.http.post("/api/events/"+e.id+"/feeds/"+t.id+"/content",{}).pipe(r.map((function(e){var t=e.items.features;return t.forEach((function(e){e.id=String(e.id),e.properties=e.properties||{}})),i.next(t),e})))},e.ɵfac=function(i){return new(i||e)(t.ɵɵinject(n.HttpClient))},e.ɵprov=t.ɵɵdefineInjectable({token:e,factory:e.ɵfac,providedIn:"root"}),e}();e.FeedService=o,Object.defineProperty(e,"__esModule",{value:!0})}));
2
+ //# sourceMappingURL=ngageoint-mage.web-core-lib-feed.umd.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["ng://@ngageoint/mage.web-core-lib/feed/feed.service.ts"],"names":["FeedService","http","this","_feeds","BehaviorSubject","feeds","asObservable","_feedItems","Map","prototype","feedItems","feedId","get","fetchAllFeeds","fetchFeed","fetchService","serviceId","createService","service","post","fetchServices","fetchServiceFeeds","fetchServiceType","serviceTypeId","fetchTopics","previewFeed","topicId","feedSpec","opts","skipContentFetch","feed","fetchTopic","fetchServiceTypes","createFeed","feedConfiguration","updateFeed","put","id","deleteFeed","delete","responseType","deleteService","console","log","fetchFeeds","eventId","_this","subject","Subject","subscribe","map","toString","forEach","set","next","fetchFeedItems","event","pipe","content","features","items","feature","String","properties","core","ɵɵinject","HttpClient","factory","ɵfac","providedIn"],"mappings":"6nBAiBE,SAAAA,EAAoBC,GAAAC,KAAAD,KAAAA,EAGZC,KAAAC,OAAS,IAAIC,E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B,EAAQE,WAAaF,EAAQE,YAAc,MAE7CrD,EAAU4C,KAAKK,GACRD,wCA/GF1D,GAAWgE,EAAAC,SAAAhE,EAAAiE,kDAAXlE,EAAWmE,QAAXnE,EAAWoE,KAAAC,WAFV","sourcesContent":["import { HttpClient } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { Feature } from 'geojson'\nimport { BehaviorSubject, Observable, Subject } from 'rxjs'\nimport { map } from 'rxjs/operators'\nimport { Feed, FeedContent, FeedExpanded, FeedPost, FeedPreview, FeedTopic, Service, ServiceType, StyledFeature } from './feed.model'\n\n\nexport interface FeedPreviewOptions {\n skipContentFetch?: boolean\n}\n\n@Injectable({\n providedIn: 'root'\n})\nexport class FeedService {\n\n constructor(private http: HttpClient) { }\n\n // TODO: there is probably a better solution than maintaining this map here\n private _feeds = new BehaviorSubject<Array<Feed>>([]);\n readonly feeds = this._feeds.asObservable();\n\n private _feedItems = new Map<string, BehaviorSubject<Array<Feature>>>();\n feedItems(feedId: string): Observable<Array<Feature>> {\n return this._feedItems.get(feedId).asObservable();\n }\n\n fetchAllFeeds(): Observable<Array<Feed>> {\n return this.http.get<Array<Feed>>('/api/feeds/');\n }\n\n fetchFeed(feedId: string): Observable<FeedExpanded> {\n return this.http.get<FeedExpanded>(`/api/feeds/${feedId}`);\n }\n\n fetchService(serviceId: string): Observable<Service> {\n return this.http.get<Service>(`/api/feeds/services/${serviceId}`);\n }\n\n createService(service: { title: string, summary?: string, serviceType: string, config: any}): Observable<Service> {\n return this.http.post<Service>(`/api/feeds/services`, service);\n }\n\n fetchServices(): Observable<Array<Service>> {\n return this.http.get<Array<Service>>(`/api/feeds/services`);\n }\n\n fetchServiceFeeds(serviceId: string): Observable<Array<Feed>> {\n return this.http.get<Array<Feed>>(`/api/feeds/services/${serviceId}/feeds`);\n }\n\n fetchServiceType(serviceTypeId: string): Observable<ServiceType> {\n return this.http.get<ServiceType>(`/api/feeds/service_types/${serviceTypeId}`);\n }\n\n fetchTopics(serviceId: string): Observable<Array<FeedTopic>> {\n return this.http.get<Array<FeedTopic>>(`/api/feeds/services/${serviceId}/topics`);\n }\n\n previewFeed(serviceId: string, topicId: string, feedSpec: Partial<Omit<FeedPost, 'service' | 'topic'>>, opts?: FeedPreviewOptions): Observable<FeedPreview> {\n opts = opts || {}\n const skipContentFetch: boolean = opts.skipContentFetch === true\n return this.http.post<FeedPreview>(\n `/api/feeds/services/${serviceId}/topics/${topicId}/feed_preview?skip_content_fetch=${skipContentFetch}`,\n { feed: feedSpec });\n }\n\n fetchTopic(serviceId: string, topicId: string): Observable<FeedTopic> {\n return this.http.get<FeedTopic>(`/api/feeds/services/${serviceId}/topics/${topicId}`);\n }\n\n fetchServiceTypes(): Observable<Array<ServiceType>> {\n return this.http.get<Array<ServiceType>>(`/api/feeds/service_types`);\n }\n\n createFeed(serviceId: string, topicId: string, feedConfiguration: any): Observable<FeedExpanded> {\n return this.http.post<FeedExpanded>(`/api/feeds/services/${serviceId}/topics/${topicId}/feeds`, feedConfiguration);\n }\n\n updateFeed(feed: Partial<Omit<FeedPost, 'id'>> & Pick<Feed, 'id'>): Observable<FeedExpanded> {\n return this.http.put<FeedExpanded>(`/api/feeds/${feed.id}`, feed);\n }\n\n deleteFeed(feed: Feed | FeedExpanded): Observable<{}> {\n return this.http.delete(`/api/feeds/${feed.id}`, {responseType: 'text'});\n }\n\n deleteService(service: Service): Observable<{}> {\n console.log('delete')\n return this.http.delete(`/api/feeds/services/${service.id}`, { responseType: 'text' });\n }\n\n fetchFeeds(eventId: number): Observable<Array<Feed>> {\n const subject = new Subject<Array<Feed>>();\n this.http.get<Array<Feed>>(`/api/events/${eventId}/feeds`).subscribe(feeds => {\n feeds.map(feed => {\n feed.id = feed.id.toString();\n return feed;\n });\n\n feeds.forEach(feed => {\n let feedItems = this._feedItems.get(feed.id);\n if (!feedItems) {\n feedItems = new BehaviorSubject<Array<Feature>>([]);\n this._feedItems.set(feed.id, feedItems);\n }\n })\n\n subject.next(feeds);\n this._feeds.next(feeds);\n });\n\n return subject;\n }\n\n fetchFeedItems(event: any, feed: Feed): Observable<FeedContent> {\n const feedItems = this._feedItems.get(feed.id)\n return this.http.post<FeedContent>(`/api/events/${event.id}/feeds/${feed.id}/content`, {}).pipe(\n map(content => {\n const features = content.items.features\n features.forEach((feature: StyledFeature) => {\n feature.id = String(feature.id)\n feature.properties = feature.properties || {}\n })\n feedItems.next(features)\n return content\n })\n )\n }\n}\n"]}