@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.
- package/README.md +24 -0
- package/bundles/ngageoint-mage.web-core-lib-common.umd.js +146 -0
- package/bundles/ngageoint-mage.web-core-lib-common.umd.js.map +1 -0
- package/bundles/ngageoint-mage.web-core-lib-common.umd.min.js +2 -0
- package/bundles/ngageoint-mage.web-core-lib-common.umd.min.js.map +1 -0
- package/bundles/ngageoint-mage.web-core-lib-event.umd.js +14 -0
- package/bundles/ngageoint-mage.web-core-lib-event.umd.js.map +1 -0
- package/bundles/ngageoint-mage.web-core-lib-event.umd.min.js +2 -0
- package/bundles/ngageoint-mage.web-core-lib-event.umd.min.js.map +1 -0
- package/bundles/ngageoint-mage.web-core-lib-feed.umd.js +114 -0
- package/bundles/ngageoint-mage.web-core-lib-feed.umd.js.map +1 -0
- package/bundles/ngageoint-mage.web-core-lib-feed.umd.min.js +2 -0
- package/bundles/ngageoint-mage.web-core-lib-feed.umd.min.js.map +1 -0
- package/bundles/ngageoint-mage.web-core-lib-paging.umd.js +313 -0
- package/bundles/ngageoint-mage.web-core-lib-paging.umd.js.map +1 -0
- package/bundles/ngageoint-mage.web-core-lib-paging.umd.min.js +16 -0
- package/bundles/ngageoint-mage.web-core-lib-paging.umd.min.js.map +1 -0
- package/bundles/ngageoint-mage.web-core-lib-plugin.umd.js +11 -0
- package/bundles/ngageoint-mage.web-core-lib-plugin.umd.js.map +1 -0
- package/bundles/ngageoint-mage.web-core-lib-plugin.umd.min.js +2 -0
- package/bundles/ngageoint-mage.web-core-lib-plugin.umd.min.js.map +1 -0
- package/bundles/ngageoint-mage.web-core-lib-static-icon.umd.js +391 -0
- package/bundles/ngageoint-mage.web-core-lib-static-icon.umd.js.map +1 -0
- package/bundles/ngageoint-mage.web-core-lib-static-icon.umd.min.js +2 -0
- package/bundles/ngageoint-mage.web-core-lib-static-icon.umd.min.js.map +1 -0
- package/bundles/ngageoint-mage.web-core-lib-user.umd.js +492 -0
- package/bundles/ngageoint-mage.web-core-lib-user.umd.js.map +1 -0
- package/bundles/ngageoint-mage.web-core-lib-user.umd.min.js +16 -0
- package/bundles/ngageoint-mage.web-core-lib-user.umd.min.js.map +1 -0
- package/bundles/ngageoint-mage.web-core-lib.umd.js +32 -0
- package/bundles/ngageoint-mage.web-core-lib.umd.js.map +1 -0
- package/bundles/ngageoint-mage.web-core-lib.umd.min.js +2 -0
- package/bundles/ngageoint-mage.web-core-lib.umd.min.js.map +1 -0
- package/common/mage-common.module.d.ts +7 -0
- package/common/ngageoint-mage.web-core-lib-common.d.ts +5 -0
- package/common/package.json +12 -0
- package/common/public-api.d.ts +2 -0
- package/common/xhr-img.component.d.ts +58 -0
- package/esm2015/common/mage-common.module.js +26 -0
- package/esm2015/common/ngageoint-mage.web-core-lib-common.js +5 -0
- package/esm2015/common/public-api.js +3 -0
- package/esm2015/common/xhr-img.component.js +109 -0
- package/esm2015/event/event-read.service.js +3 -0
- package/esm2015/event/event.model.js +1 -0
- package/esm2015/event/ngageoint-mage.web-core-lib-event.js +5 -0
- package/esm2015/event/public-api.js +2 -0
- package/esm2015/feed/feed.model.js +1 -0
- package/esm2015/feed/feed.service.js +105 -0
- package/esm2015/feed/ngageoint-mage.web-core-lib-feed.js +5 -0
- package/esm2015/feed/public-api.js +2 -0
- package/esm2015/mage-core-lib.module.js +20 -0
- package/esm2015/ngageoint-mage.web-core-lib.js +5 -0
- package/esm2015/paging/ngageoint-mage.web-core-lib-paging.js +5 -0
- package/esm2015/paging/paging.cdk-data-source.adapter.js +52 -0
- package/esm2015/paging/paging.model.js +25 -0
- package/esm2015/paging/public-api.js +3 -0
- package/esm2015/plugin/ngageoint-mage.web-core-lib-plugin.js +4 -0
- package/esm2015/plugin/plugin.model.js +1 -0
- package/esm2015/plugin/public-api.js +1 -0
- package/esm2015/public-api.js +5 -0
- package/esm2015/static-icon/ngageoint-mage.web-core-lib-static-icon.js +5 -0
- package/esm2015/static-icon/public-api.js +7 -0
- package/esm2015/static-icon/static-icon-form-field/static-icon-form-field.component.js +152 -0
- package/esm2015/static-icon/static-icon-img/static-icon-img.component.js +35 -0
- package/esm2015/static-icon/static-icon-select/static-icon-select.component.js +61 -0
- package/esm2015/static-icon/static-icon.model.js +10 -0
- package/esm2015/static-icon/static-icon.module.js +55 -0
- package/esm2015/static-icon/static-icon.service.js +82 -0
- package/esm2015/user/ngageoint-mage.web-core-lib-user.js +5 -0
- package/esm2015/user/public-api.js +4 -0
- package/esm2015/user/user-read.service.js +40 -0
- package/esm2015/user/user-select/user-select.component.js +165 -0
- package/esm2015/user/user.model.js +1 -0
- package/esm2015/user/user.module.js +65 -0
- package/esm5/common/mage-common.module.js +30 -0
- package/esm5/common/ngageoint-mage.web-core-lib-common.js +5 -0
- package/esm5/common/public-api.js +3 -0
- package/esm5/common/xhr-img.component.js +112 -0
- package/esm5/event/event-read.service.js +3 -0
- package/esm5/event/event.model.js +1 -0
- package/esm5/event/ngageoint-mage.web-core-lib-event.js +5 -0
- package/esm5/event/public-api.js +2 -0
- package/esm5/feed/feed.model.js +1 -0
- package/esm5/feed/feed.service.js +108 -0
- package/esm5/feed/ngageoint-mage.web-core-lib-feed.js +5 -0
- package/esm5/feed/public-api.js +2 -0
- package/esm5/mage-core-lib.module.js +24 -0
- package/esm5/ngageoint-mage.web-core-lib.js +5 -0
- package/esm5/paging/ngageoint-mage.web-core-lib-paging.js +5 -0
- package/esm5/paging/paging.cdk-data-source.adapter.js +60 -0
- package/esm5/paging/paging.model.js +25 -0
- package/esm5/paging/public-api.js +3 -0
- package/esm5/plugin/ngageoint-mage.web-core-lib-plugin.js +4 -0
- package/esm5/plugin/plugin.model.js +1 -0
- package/esm5/plugin/public-api.js +1 -0
- package/esm5/public-api.js +5 -0
- package/esm5/static-icon/ngageoint-mage.web-core-lib-static-icon.js +5 -0
- package/esm5/static-icon/public-api.js +7 -0
- package/esm5/static-icon/static-icon-form-field/static-icon-form-field.component.js +157 -0
- package/esm5/static-icon/static-icon-img/static-icon-img.component.js +38 -0
- package/esm5/static-icon/static-icon-select/static-icon-select.component.js +65 -0
- package/esm5/static-icon/static-icon.model.js +10 -0
- package/esm5/static-icon/static-icon.module.js +59 -0
- package/esm5/static-icon/static-icon.service.js +84 -0
- package/esm5/user/ngageoint-mage.web-core-lib-user.js +5 -0
- package/esm5/user/public-api.js +4 -0
- package/esm5/user/user-read.service.js +42 -0
- package/esm5/user/user-select/user-select.component.js +175 -0
- package/esm5/user/user.model.js +1 -0
- package/esm5/user/user.module.js +69 -0
- package/event/event-read.service.d.ts +11 -0
- package/event/event.model.d.ts +6 -0
- package/event/ngageoint-mage.web-core-lib-event.d.ts +5 -0
- package/event/package.json +12 -0
- package/event/public-api.d.ts +2 -0
- package/feed/feed.model.d.ts +83 -0
- package/feed/feed.service.d.ts +40 -0
- package/feed/ngageoint-mage.web-core-lib-feed.d.ts +5 -0
- package/feed/package.json +12 -0
- package/feed/public-api.d.ts +2 -0
- package/fesm2015/ngageoint-mage.web-core-lib-common.js +137 -0
- package/fesm2015/ngageoint-mage.web-core-lib-common.js.map +1 -0
- package/fesm2015/ngageoint-mage.web-core-lib-event.js +10 -0
- package/fesm2015/ngageoint-mage.web-core-lib-event.js.map +1 -0
- package/fesm2015/ngageoint-mage.web-core-lib-feed.js +111 -0
- package/fesm2015/ngageoint-mage.web-core-lib-feed.js.map +1 -0
- package/fesm2015/ngageoint-mage.web-core-lib-paging.js +83 -0
- package/fesm2015/ngageoint-mage.web-core-lib-paging.js.map +1 -0
- package/fesm2015/ngageoint-mage.web-core-lib-plugin.js +4 -0
- package/fesm2015/ngageoint-mage.web-core-lib-plugin.js.map +1 -0
- package/fesm2015/ngageoint-mage.web-core-lib-static-icon.js +379 -0
- package/fesm2015/ngageoint-mage.web-core-lib-static-icon.js.map +1 -0
- package/fesm2015/ngageoint-mage.web-core-lib-user.js +267 -0
- package/fesm2015/ngageoint-mage.web-core-lib-user.js.map +1 -0
- package/fesm2015/ngageoint-mage.web-core-lib.js +30 -0
- package/fesm2015/ngageoint-mage.web-core-lib.js.map +1 -0
- package/fesm5/ngageoint-mage.web-core-lib-common.js +142 -0
- package/fesm5/ngageoint-mage.web-core-lib-common.js.map +1 -0
- package/fesm5/ngageoint-mage.web-core-lib-event.js +10 -0
- package/fesm5/ngageoint-mage.web-core-lib-event.js.map +1 -0
- package/fesm5/ngageoint-mage.web-core-lib-feed.js +113 -0
- package/fesm5/ngageoint-mage.web-core-lib-feed.js.map +1 -0
- package/fesm5/ngageoint-mage.web-core-lib-paging.js +90 -0
- package/fesm5/ngageoint-mage.web-core-lib-paging.js.map +1 -0
- package/fesm5/ngageoint-mage.web-core-lib-plugin.js +4 -0
- package/fesm5/ngageoint-mage.web-core-lib-plugin.js.map +1 -0
- package/fesm5/ngageoint-mage.web-core-lib-static-icon.js +392 -0
- package/fesm5/ngageoint-mage.web-core-lib-static-icon.js.map +1 -0
- package/fesm5/ngageoint-mage.web-core-lib-user.js +280 -0
- package/fesm5/ngageoint-mage.web-core-lib-user.js.map +1 -0
- package/fesm5/ngageoint-mage.web-core-lib.js +33 -0
- package/fesm5/ngageoint-mage.web-core-lib.js.map +1 -0
- package/mage-core-lib.module.d.ts +6 -0
- package/ngageoint-mage.web-core-lib.d.ts +5 -0
- package/package.json +35 -0
- package/paging/ngageoint-mage.web-core-lib-paging.d.ts +5 -0
- package/paging/package.json +12 -0
- package/paging/paging.cdk-data-source.adapter.d.ts +20 -0
- package/paging/paging.model.d.ts +27 -0
- package/paging/public-api.d.ts +2 -0
- package/plugin/ngageoint-mage.web-core-lib-plugin.d.ts +5 -0
- package/plugin/package.json +12 -0
- package/plugin/plugin.model.d.ts +13 -0
- package/plugin/public-api.d.ts +1 -0
- package/public-api.d.ts +1 -0
- package/static-icon/ngageoint-mage.web-core-lib-static-icon.d.ts +5 -0
- package/static-icon/package.json +12 -0
- package/static-icon/public-api.d.ts +6 -0
- package/static-icon/static-icon-form-field/static-icon-form-field.component.d.ts +31 -0
- package/static-icon/static-icon-img/static-icon-img.component.d.ts +12 -0
- package/static-icon/static-icon-select/static-icon-select.component.d.ts +21 -0
- package/static-icon/static-icon.model.d.ts +19 -0
- package/static-icon/static-icon.module.d.ts +13 -0
- package/static-icon/static-icon.service.d.ts +20 -0
- package/user/ngageoint-mage.web-core-lib-user.d.ts +5 -0
- package/user/package.json +12 -0
- package/user/public-api.d.ts +4 -0
- package/user/user-read.service.d.ts +24 -0
- package/user/user-select/user-select.component.d.ts +38 -0
- package/user/user.model.d.ts +85 -0
- package/user/user.module.d.ts +16 -0
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/cdk/scrolling'), require('@angular/common'), require('@angular/core'), require('@angular/forms'), require('@angular/material/card'), require('@ngageoint/mage.web-core-lib/common'), require('@angular/common/http'), require('rxjs'), require('rxjs/operators'), require('@angular/platform-browser'), require('@ngageoint/mage.web-core-lib/paging')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@ngageoint/mage.web-core-lib/static-icon', ['exports', '@angular/cdk/scrolling', '@angular/common', '@angular/core', '@angular/forms', '@angular/material/card', '@ngageoint/mage.web-core-lib/common', '@angular/common/http', 'rxjs', 'rxjs/operators', '@angular/platform-browser', '@ngageoint/mage.web-core-lib/paging'], 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']['static-icon'] = {}), global.ng.cdk.scrolling, global.ng.common, global.ng.core, global.ng.forms, global.ng.material.card, global.ngageoint.mage['web-core-lib'].common, global.ng.common.http, global.rxjs, global.rxjs.operators, global.ng.platformBrowser, global.ngageoint.mage['web-core-lib'].paging));
|
|
5
|
+
}(this, (function (exports, scrolling, common, core, forms, card, common$1, http, rxjs, operators, platformBrowser, paging) { 'use strict';
|
|
6
|
+
|
|
7
|
+
var contentPathOfIcon = function (icon) {
|
|
8
|
+
if (!icon) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (typeof icon !== 'string') {
|
|
12
|
+
icon = icon.id;
|
|
13
|
+
}
|
|
14
|
+
return "/api/icons/" + icon + "/content";
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
var StaticIconService = /** @class */ (function () {
|
|
18
|
+
function StaticIconService(http) {
|
|
19
|
+
this.http = http;
|
|
20
|
+
}
|
|
21
|
+
StaticIconService.prototype.fetchIcons = function (fetch) {
|
|
22
|
+
var now = Date.now();
|
|
23
|
+
var results = new rxjs.Observable(function (observer) {
|
|
24
|
+
var icons = [];
|
|
25
|
+
var remaining = 100;
|
|
26
|
+
while (remaining--) {
|
|
27
|
+
var id = now - remaining;
|
|
28
|
+
icons.unshift({
|
|
29
|
+
id: String(id),
|
|
30
|
+
title: "Icon " + id,
|
|
31
|
+
fileName: "icon-" + id + ".png",
|
|
32
|
+
sourceUrl: "https://test.mage/" + id + ".png",
|
|
33
|
+
contentPath: "/icons/" + id + "/content"
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
setTimeout(function () {
|
|
37
|
+
observer.next({
|
|
38
|
+
pageSize: 100,
|
|
39
|
+
pageIndex: 0,
|
|
40
|
+
totalCount: 100,
|
|
41
|
+
items: icons
|
|
42
|
+
});
|
|
43
|
+
observer.complete();
|
|
44
|
+
}, 0);
|
|
45
|
+
return {
|
|
46
|
+
unsubscribe: function () { }
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
return results;
|
|
50
|
+
};
|
|
51
|
+
StaticIconService.prototype.fetchIconById = function (id) {
|
|
52
|
+
return this.http.get("/api/icons/" + id).pipe(operators.catchError(function (err, caught) {
|
|
53
|
+
// TODO: this is probably better practice to insulate app layer from
|
|
54
|
+
// http errors
|
|
55
|
+
// if (err instanceof HttpErrorResponse) {
|
|
56
|
+
// if (err.status === 404) {
|
|
57
|
+
// return null
|
|
58
|
+
// }
|
|
59
|
+
// }
|
|
60
|
+
return rxjs.throwError(err);
|
|
61
|
+
}));
|
|
62
|
+
};
|
|
63
|
+
StaticIconService.prototype.fetchIconBySourceUrl = function (url) {
|
|
64
|
+
return this.http.get("/api/icons", {
|
|
65
|
+
params: new http.HttpParams().set('source_url', url)
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
StaticIconService.prototype.fetchIconByReference = function (ref) {
|
|
69
|
+
if (ref.id) {
|
|
70
|
+
return this.fetchIconById(ref.id);
|
|
71
|
+
}
|
|
72
|
+
else if (ref.sourceUrl) {
|
|
73
|
+
return this.fetchIconBySourceUrl(ref.sourceUrl);
|
|
74
|
+
}
|
|
75
|
+
throw new Error('no icon id or source url');
|
|
76
|
+
};
|
|
77
|
+
StaticIconService.prototype.registerIconUrl = function (url) {
|
|
78
|
+
throw new Error('unimplemented');
|
|
79
|
+
};
|
|
80
|
+
StaticIconService.prototype.uploadIcon = function () {
|
|
81
|
+
throw new Error('unimplemented');
|
|
82
|
+
};
|
|
83
|
+
StaticIconService.ɵfac = function StaticIconService_Factory(t) { return new (t || StaticIconService)(core.ɵɵinject(http.HttpClient)); };
|
|
84
|
+
StaticIconService.ɵprov = core.ɵɵdefineInjectable({ token: StaticIconService, factory: StaticIconService.ɵfac, providedIn: 'root' });
|
|
85
|
+
return StaticIconService;
|
|
86
|
+
}());
|
|
87
|
+
/*@__PURE__*/ (function () { core.ɵsetClassMetadata(StaticIconService, [{
|
|
88
|
+
type: core.Injectable,
|
|
89
|
+
args: [{
|
|
90
|
+
providedIn: 'root'
|
|
91
|
+
}]
|
|
92
|
+
}], function () { return [{ type: http.HttpClient }]; }, null); })();
|
|
93
|
+
|
|
94
|
+
var StaticIconFormFieldComponent = /** @class */ (function () {
|
|
95
|
+
function StaticIconFormFieldComponent(iconService, httpClient, sanitizer) {
|
|
96
|
+
var _this = this;
|
|
97
|
+
this.iconService = iconService;
|
|
98
|
+
this.httpClient = httpClient;
|
|
99
|
+
this.sanitizer = sanitizer;
|
|
100
|
+
this.iconRef = null;
|
|
101
|
+
this.form = new forms.FormGroup({
|
|
102
|
+
iconRefToken: new forms.FormControl(null),
|
|
103
|
+
iconRefType: new forms.FormControl(null, forms.Validators.required)
|
|
104
|
+
});
|
|
105
|
+
this.onChange = function (iconRef) { };
|
|
106
|
+
this.onValidatorChange = function () { };
|
|
107
|
+
this.onTouched = function () { };
|
|
108
|
+
this.form.valueChanges.subscribe(function (x) {
|
|
109
|
+
_this.iconRef = iconRefForFormValue(x);
|
|
110
|
+
_this.onChange(_this.iconRef);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
StaticIconFormFieldComponent.prototype.registerOnValidatorChange = function (fn) {
|
|
114
|
+
this.onValidatorChange = fn;
|
|
115
|
+
};
|
|
116
|
+
StaticIconFormFieldComponent.prototype.ngOnChanges = function (changes) { };
|
|
117
|
+
StaticIconFormFieldComponent.prototype.ngOnDestroy = function () { };
|
|
118
|
+
StaticIconFormFieldComponent.prototype.onSelectIcon = function () { };
|
|
119
|
+
StaticIconFormFieldComponent.prototype.writeValue = function (iconRef) {
|
|
120
|
+
this.iconRef = iconRef;
|
|
121
|
+
var formValue = formValueForIconRef(iconRef);
|
|
122
|
+
this.form.setValue(formValue, { emitEvent: false });
|
|
123
|
+
this.resolveIconRef();
|
|
124
|
+
};
|
|
125
|
+
StaticIconFormFieldComponent.prototype.registerOnChange = function (fn) {
|
|
126
|
+
this.onChange = fn;
|
|
127
|
+
};
|
|
128
|
+
StaticIconFormFieldComponent.prototype.registerOnTouched = function (fn) {
|
|
129
|
+
this.onTouched = fn;
|
|
130
|
+
};
|
|
131
|
+
StaticIconFormFieldComponent.prototype.setDisabledState = function (isDisabled) {
|
|
132
|
+
if (isDisabled) {
|
|
133
|
+
this.form.disable();
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
this.form.enable();
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
StaticIconFormFieldComponent.prototype.validate = function (control) {
|
|
140
|
+
return this.form.errors;
|
|
141
|
+
};
|
|
142
|
+
StaticIconFormFieldComponent.prototype.resolveIconRef = function () {
|
|
143
|
+
var _this = this;
|
|
144
|
+
if (!this.iconRef) {
|
|
145
|
+
this.icon = null;
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
this.iconService.fetchIconByReference(this.iconRef).subscribe(function (x) {
|
|
149
|
+
_this.icon = x;
|
|
150
|
+
if (!_this.icon) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
StaticIconFormFieldComponent.ɵfac = function StaticIconFormFieldComponent_Factory(t) { return new (t || StaticIconFormFieldComponent)(core.ɵɵdirectiveInject(StaticIconService), core.ɵɵdirectiveInject(http.HttpClient), core.ɵɵdirectiveInject(platformBrowser.DomSanitizer)); };
|
|
156
|
+
StaticIconFormFieldComponent.ɵcmp = core.ɵɵdefineComponent({ type: StaticIconFormFieldComponent, selectors: [["mage-static-icon-form-field"]], features: [core.ɵɵProvidersFeature([
|
|
157
|
+
{
|
|
158
|
+
provide: forms.NG_VALUE_ACCESSOR,
|
|
159
|
+
multi: true,
|
|
160
|
+
useExisting: StaticIconFormFieldComponent
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
provide: forms.NG_VALIDATORS,
|
|
164
|
+
multi: true,
|
|
165
|
+
useExisting: StaticIconFormFieldComponent
|
|
166
|
+
},
|
|
167
|
+
]), core.ɵɵNgOnChangesFeature], decls: 4, vars: 2, consts: [[3, "formGroup"], [1, "icon-image", 3, "src"], ["type", "hidden", "formControlName", "iconRefType"], ["type", "hidden", "formControlName", "iconRefToken"]], template: function StaticIconFormFieldComponent_Template(rf, ctx) { if (rf & 1) {
|
|
168
|
+
core.ɵɵelementStart(0, "div", 0);
|
|
169
|
+
core.ɵɵelement(1, "mage-xhr-img", 1);
|
|
170
|
+
core.ɵɵelement(2, "input", 2);
|
|
171
|
+
core.ɵɵelement(3, "input", 3);
|
|
172
|
+
core.ɵɵelementEnd();
|
|
173
|
+
} if (rf & 2) {
|
|
174
|
+
core.ɵɵproperty("formGroup", ctx.form);
|
|
175
|
+
core.ɵɵadvance(1);
|
|
176
|
+
core.ɵɵproperty("src", ctx.icon == null ? null : ctx.icon.contentPath);
|
|
177
|
+
} }, directives: [forms.NgControlStatusGroup, forms.FormGroupDirective, common$1.XhrImgComponent, forms.DefaultValueAccessor, forms.NgControlStatus, forms.FormControlName], styles: [".icon-image[_ngcontent-%COMP%]{display:block;height:3em;width:3em}"] });
|
|
178
|
+
return StaticIconFormFieldComponent;
|
|
179
|
+
}());
|
|
180
|
+
/*@__PURE__*/ (function () { core.ɵsetClassMetadata(StaticIconFormFieldComponent, [{
|
|
181
|
+
type: core.Component,
|
|
182
|
+
args: [{
|
|
183
|
+
selector: 'mage-static-icon-form-field',
|
|
184
|
+
templateUrl: './static-icon-form-field.component.html',
|
|
185
|
+
styleUrls: ['./static-icon-form-field.component.scss'],
|
|
186
|
+
providers: [
|
|
187
|
+
{
|
|
188
|
+
provide: forms.NG_VALUE_ACCESSOR,
|
|
189
|
+
multi: true,
|
|
190
|
+
useExisting: StaticIconFormFieldComponent
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
provide: forms.NG_VALIDATORS,
|
|
194
|
+
multi: true,
|
|
195
|
+
useExisting: StaticIconFormFieldComponent
|
|
196
|
+
},
|
|
197
|
+
]
|
|
198
|
+
}]
|
|
199
|
+
}], function () { return [{ type: StaticIconService }, { type: http.HttpClient }, { type: platformBrowser.DomSanitizer }]; }, null); })();
|
|
200
|
+
var IconRefType;
|
|
201
|
+
(function (IconRefType) {
|
|
202
|
+
IconRefType["Registered"] = "id";
|
|
203
|
+
IconRefType["SourceUrl"] = "sourceUrl";
|
|
204
|
+
})(IconRefType || (IconRefType = {}));
|
|
205
|
+
function iconRefForFormValue(x) {
|
|
206
|
+
var _a, _b;
|
|
207
|
+
if (!x.iconRefType) {
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
switch (x.iconRefType) {
|
|
211
|
+
case IconRefType.Registered:
|
|
212
|
+
return _a = {}, _a[IconRefType.Registered] = x.iconRefToken, _a;
|
|
213
|
+
case IconRefType.SourceUrl:
|
|
214
|
+
return _b = {}, _b[IconRefType.SourceUrl] = x.iconRefToken, _b;
|
|
215
|
+
default:
|
|
216
|
+
throw new Error('invalid icon ref type: ' + x.iconRefToken);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function formValueForIconRef(x) {
|
|
220
|
+
if (!x) {
|
|
221
|
+
return {
|
|
222
|
+
iconRefType: null,
|
|
223
|
+
iconRefToken: null
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
var iconRefType = null;
|
|
227
|
+
var iconRefToken = null;
|
|
228
|
+
if (x.hasOwnProperty(IconRefType.Registered)) {
|
|
229
|
+
iconRefType = IconRefType.Registered || null;
|
|
230
|
+
iconRefToken = x[IconRefType.Registered] || null;
|
|
231
|
+
}
|
|
232
|
+
else if (x.hasOwnProperty(IconRefType.SourceUrl)) {
|
|
233
|
+
iconRefType = IconRefType.SourceUrl || null;
|
|
234
|
+
iconRefToken = x[IconRefType.SourceUrl] || null;
|
|
235
|
+
}
|
|
236
|
+
return {
|
|
237
|
+
iconRefType: iconRefType,
|
|
238
|
+
iconRefToken: iconRefToken
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
var StaticIconImgComponent = /** @class */ (function () {
|
|
243
|
+
function StaticIconImgComponent() {
|
|
244
|
+
}
|
|
245
|
+
StaticIconImgComponent.prototype.ngOnInit = function () {
|
|
246
|
+
};
|
|
247
|
+
StaticIconImgComponent.prototype.ngOnChanges = function (changes) {
|
|
248
|
+
if (changes.iconRef) {
|
|
249
|
+
if (this.iconRef) {
|
|
250
|
+
this.iconPath = contentPathOfIcon(this.iconRef);
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
this.iconPath = null;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
StaticIconImgComponent.ɵfac = function StaticIconImgComponent_Factory(t) { return new (t || StaticIconImgComponent)(); };
|
|
258
|
+
StaticIconImgComponent.ɵcmp = core.ɵɵdefineComponent({ type: StaticIconImgComponent, selectors: [["mage-static-icon-img"]], inputs: { iconRef: "iconRef" }, features: [core.ɵɵNgOnChangesFeature], decls: 1, vars: 1, consts: [[3, "src"]], template: function StaticIconImgComponent_Template(rf, ctx) { if (rf & 1) {
|
|
259
|
+
core.ɵɵelement(0, "mage-xhr-img", 0);
|
|
260
|
+
} if (rf & 2) {
|
|
261
|
+
core.ɵɵproperty("src", ctx.iconPath);
|
|
262
|
+
} }, directives: [common$1.XhrImgComponent], encapsulation: 2 });
|
|
263
|
+
return StaticIconImgComponent;
|
|
264
|
+
}());
|
|
265
|
+
/*@__PURE__*/ (function () { core.ɵsetClassMetadata(StaticIconImgComponent, [{
|
|
266
|
+
type: core.Component,
|
|
267
|
+
args: [{
|
|
268
|
+
selector: 'mage-static-icon-img',
|
|
269
|
+
template: "<mage-xhr-img [src]=\"iconPath\"></mage-xhr-img>",
|
|
270
|
+
}]
|
|
271
|
+
}], function () { return []; }, { iconRef: [{
|
|
272
|
+
type: core.Input
|
|
273
|
+
}] }); })();
|
|
274
|
+
|
|
275
|
+
function StaticIconSelectComponent_mat_card_2_Template(rf, ctx) { if (rf & 1) {
|
|
276
|
+
core.ɵɵelementStart(0, "mat-card", 3);
|
|
277
|
+
core.ɵɵelementStart(1, "mat-card-header");
|
|
278
|
+
core.ɵɵelementStart(2, "mat-card-title");
|
|
279
|
+
core.ɵɵtext(3);
|
|
280
|
+
core.ɵɵelementEnd();
|
|
281
|
+
core.ɵɵelementEnd();
|
|
282
|
+
core.ɵɵelement(4, "img", 4);
|
|
283
|
+
core.ɵɵelementEnd();
|
|
284
|
+
} if (rf & 2) {
|
|
285
|
+
var icon_r1 = ctx.$implicit;
|
|
286
|
+
core.ɵɵadvance(3);
|
|
287
|
+
core.ɵɵtextInterpolate(icon_r1.title);
|
|
288
|
+
core.ɵɵadvance(1);
|
|
289
|
+
core.ɵɵproperty("src", icon_r1.path, core.ɵɵsanitizeUrl);
|
|
290
|
+
} }
|
|
291
|
+
var StaticIconSelectComponent = /** @class */ (function () {
|
|
292
|
+
function StaticIconSelectComponent(iconService) {
|
|
293
|
+
var _this = this;
|
|
294
|
+
this.iconService = iconService;
|
|
295
|
+
this.icons = null;
|
|
296
|
+
this.dataSource = new paging.PagingDataSource(250, function (paging) {
|
|
297
|
+
return _this.iconService.fetchIcons(paging);
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
StaticIconSelectComponent.prototype.ngOnInit = function () {
|
|
301
|
+
var _this = this;
|
|
302
|
+
this.iconService.fetchIcons().subscribe(function (x) {
|
|
303
|
+
_this.icons = x.items;
|
|
304
|
+
});
|
|
305
|
+
};
|
|
306
|
+
StaticIconSelectComponent.prototype.onBrowseForUploadIcon = function () {
|
|
307
|
+
throw new Error('unimplemented');
|
|
308
|
+
};
|
|
309
|
+
StaticIconSelectComponent.ɵfac = function StaticIconSelectComponent_Factory(t) { return new (t || StaticIconSelectComponent)(core.ɵɵdirectiveInject(StaticIconService)); };
|
|
310
|
+
StaticIconSelectComponent.ɵcmp = core.ɵɵdefineComponent({ type: StaticIconSelectComponent, selectors: [["static-icon-select"]], decls: 3, vars: 2, consts: [[1, "icon-select"], [3, "itemSize"], ["class", "icon-select-item", 4, "cdkVirtualFor", "cdkVirtualForOf"], [1, "icon-select-item"], ["mat-card-img", "", 3, "src"]], template: function StaticIconSelectComponent_Template(rf, ctx) { if (rf & 1) {
|
|
311
|
+
core.ɵɵelementStart(0, "div", 0);
|
|
312
|
+
core.ɵɵelementStart(1, "cdk-virtual-scroll-viewport", 1);
|
|
313
|
+
core.ɵɵtemplate(2, StaticIconSelectComponent_mat_card_2_Template, 5, 2, "mat-card", 2);
|
|
314
|
+
core.ɵɵelementEnd();
|
|
315
|
+
core.ɵɵelementEnd();
|
|
316
|
+
} if (rf & 2) {
|
|
317
|
+
core.ɵɵadvance(1);
|
|
318
|
+
core.ɵɵproperty("itemSize", 40);
|
|
319
|
+
core.ɵɵadvance(1);
|
|
320
|
+
core.ɵɵproperty("cdkVirtualForOf", ctx.icons);
|
|
321
|
+
} }, directives: [scrolling.CdkVirtualScrollViewport, scrolling.CdkFixedSizeVirtualScroll, scrolling.CdkVirtualForOf, card.MatCard, card.MatCardHeader, card.MatCardTitle], styles: ["virtual-scroll[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(3,33%);grid-auto-rows:min-content;grid-gap:0;justify-content:center;gap:0}"] });
|
|
322
|
+
return StaticIconSelectComponent;
|
|
323
|
+
}());
|
|
324
|
+
/*@__PURE__*/ (function () { core.ɵsetClassMetadata(StaticIconSelectComponent, [{
|
|
325
|
+
type: core.Component,
|
|
326
|
+
args: [{
|
|
327
|
+
selector: 'static-icon-select',
|
|
328
|
+
templateUrl: './static-icon-select.component.html',
|
|
329
|
+
styleUrls: ['./static-icon-select.component.scss']
|
|
330
|
+
}]
|
|
331
|
+
}], function () { return [{ type: StaticIconService }]; }, null); })();
|
|
332
|
+
|
|
333
|
+
var StaticIconModule = /** @class */ (function () {
|
|
334
|
+
function StaticIconModule() {
|
|
335
|
+
}
|
|
336
|
+
StaticIconModule.ɵmod = core.ɵɵdefineNgModule({ type: StaticIconModule });
|
|
337
|
+
StaticIconModule.ɵinj = core.ɵɵdefineInjector({ factory: function StaticIconModule_Factory(t) { return new (t || StaticIconModule)(); }, imports: [[
|
|
338
|
+
common.CommonModule,
|
|
339
|
+
forms.FormsModule,
|
|
340
|
+
forms.ReactiveFormsModule,
|
|
341
|
+
card.MatCardModule,
|
|
342
|
+
common$1.MageCommonModule,
|
|
343
|
+
scrolling.ScrollingModule
|
|
344
|
+
]] });
|
|
345
|
+
return StaticIconModule;
|
|
346
|
+
}());
|
|
347
|
+
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && core.ɵɵsetNgModuleScope(StaticIconModule, { declarations: [StaticIconFormFieldComponent,
|
|
348
|
+
StaticIconImgComponent,
|
|
349
|
+
StaticIconSelectComponent], imports: [common.CommonModule,
|
|
350
|
+
forms.FormsModule,
|
|
351
|
+
forms.ReactiveFormsModule,
|
|
352
|
+
card.MatCardModule,
|
|
353
|
+
common$1.MageCommonModule,
|
|
354
|
+
scrolling.ScrollingModule], exports: [StaticIconFormFieldComponent,
|
|
355
|
+
StaticIconImgComponent,
|
|
356
|
+
StaticIconSelectComponent] }); })();
|
|
357
|
+
/*@__PURE__*/ (function () { core.ɵsetClassMetadata(StaticIconModule, [{
|
|
358
|
+
type: core.NgModule,
|
|
359
|
+
args: [{
|
|
360
|
+
imports: [
|
|
361
|
+
common.CommonModule,
|
|
362
|
+
forms.FormsModule,
|
|
363
|
+
forms.ReactiveFormsModule,
|
|
364
|
+
card.MatCardModule,
|
|
365
|
+
common$1.MageCommonModule,
|
|
366
|
+
scrolling.ScrollingModule
|
|
367
|
+
],
|
|
368
|
+
declarations: [
|
|
369
|
+
StaticIconFormFieldComponent,
|
|
370
|
+
StaticIconImgComponent,
|
|
371
|
+
StaticIconSelectComponent,
|
|
372
|
+
],
|
|
373
|
+
exports: [
|
|
374
|
+
StaticIconFormFieldComponent,
|
|
375
|
+
StaticIconImgComponent,
|
|
376
|
+
StaticIconSelectComponent,
|
|
377
|
+
]
|
|
378
|
+
}]
|
|
379
|
+
}], null, null); })();
|
|
380
|
+
|
|
381
|
+
exports.StaticIconFormFieldComponent = StaticIconFormFieldComponent;
|
|
382
|
+
exports.StaticIconImgComponent = StaticIconImgComponent;
|
|
383
|
+
exports.StaticIconModule = StaticIconModule;
|
|
384
|
+
exports.StaticIconSelectComponent = StaticIconSelectComponent;
|
|
385
|
+
exports.StaticIconService = StaticIconService;
|
|
386
|
+
exports.contentPathOfIcon = contentPathOfIcon;
|
|
387
|
+
|
|
388
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
389
|
+
|
|
390
|
+
})));
|
|
391
|
+
//# sourceMappingURL=ngageoint-mage.web-core-lib-static-icon.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngageoint-mage.web-core-lib-static-icon.umd.js","sources":["ng://@ngageoint/mage.web-core-lib/static-icon/static-icon.model.ts","ng://@ngageoint/mage.web-core-lib/static-icon/static-icon.service.ts","ng://@ngageoint/mage.web-core-lib/static-icon/static-icon-form-field/static-icon-form-field.component.ts","ng://@ngageoint/mage.web-core-lib/static-icon/static-icon-form-field/static-icon-form-field.component.html","ng://@ngageoint/mage.web-core-lib/static-icon/static-icon-img/static-icon-img.component.ts","ng://@ngageoint/mage.web-core-lib/static-icon/static-icon-select/static-icon-select.component.html","ng://@ngageoint/mage.web-core-lib/static-icon/static-icon-select/static-icon-select.component.ts","ng://@ngageoint/mage.web-core-lib/static-icon/static-icon.module.ts"],"sourcesContent":["\nexport interface StaticIcon {\n id: string\n sourceUrl: string\n contentPath: string\n title?: string\n summary?: string\n fileName?: string\n tags?: string[]\n}\n\nexport interface RegisteredStaticIconReference {\n id: string\n sourceUrl?: never\n}\n\nexport interface SourceUrlStaticIconReference {\n sourceUrl: string\n id?: never\n}\n\nexport const contentPathOfIcon = (icon?: StaticIcon | RegisteredStaticIconReference | string | null | undefined): string | undefined => {\n if (!icon) {\n return\n }\n if (typeof icon !== 'string') {\n icon = icon.id\n }\n return `/api/icons/${icon}/content`\n}\n\nexport type StaticIconReference = RegisteredStaticIconReference | SourceUrlStaticIconReference\n","import { HttpClient, HttpParams } from '@angular/common/http'\nimport { Injectable } from '@angular/core';\nimport { Observable, throwError } from 'rxjs'\nimport { catchError } from 'rxjs/operators'\nimport { PageOf, PagingParameters } from '@ngageoint/mage.web-core-lib/paging'\nimport { StaticIcon, StaticIconReference } from './static-icon.model'\n\n\nexport interface IconFetch extends PagingParameters {\n searchText?: string\n}\n\n@Injectable({\n providedIn: 'root'\n})\nexport class StaticIconService {\n\n constructor(private http: HttpClient) { }\n\n fetchIcons(fetch?: IconFetch): Observable<PageOf<StaticIcon>> {\n const now = Date.now()\n const results = new Observable<PageOf<StaticIcon>>(observer => {\n const icons: StaticIcon[] = []\n let remaining = 100\n while (remaining--) {\n const id = now - remaining\n icons.unshift({\n id: String(id),\n title: `Icon ${id}`,\n fileName: `icon-${id}.png`,\n sourceUrl: `https://test.mage/${id}.png`,\n contentPath: `/icons/${id}/content`\n })\n }\n setTimeout(() => {\n observer.next({\n pageSize: 100,\n pageIndex: 0,\n totalCount: 100,\n items: icons\n })\n observer.complete()\n }, 0)\n return {\n unsubscribe() { }\n }\n })\n return results\n }\n\n fetchIconById(id: string): Observable<StaticIcon | null> {\n return this.http.get<StaticIcon>(`/api/icons/${id}`).pipe(\n catchError((err, caught) => {\n // TODO: this is probably better practice to insulate app layer from\n // http errors\n // if (err instanceof HttpErrorResponse) {\n // if (err.status === 404) {\n // return null\n // }\n // }\n return throwError(err)\n })\n )\n }\n\n fetchIconBySourceUrl(url: string): Observable<StaticIcon> {\n return this.http.get<StaticIcon | null>(`/api/icons`, {\n params: new HttpParams().set('source_url', url)\n })\n }\n\n fetchIconByReference(ref: StaticIconReference): Observable<StaticIcon | null> {\n if (ref.id) {\n return this.fetchIconById(ref.id)\n }\n else if (ref.sourceUrl) {\n return this.fetchIconBySourceUrl(ref.sourceUrl)\n }\n throw new Error('no icon id or source url')\n }\n\n registerIconUrl(url: string): Observable<StaticIcon> {\n throw new Error('unimplemented')\n }\n\n uploadIcon(): void {\n throw new Error('unimplemented')\n }\n}\n","import { HttpClient } from '@angular/common/http'\nimport { Component, OnChanges, OnDestroy, SimpleChanges } from '@angular/core'\nimport { AbstractControl, ControlValueAccessor, FormControl, FormGroup, NG_VALIDATORS, NG_VALUE_ACCESSOR, ValidationErrors, Validator, Validators } from '@angular/forms'\nimport { DomSanitizer } from '@angular/platform-browser'\nimport { StaticIcon, StaticIconReference } from '../static-icon.model'\nimport { StaticIconService } from '../static-icon.service'\n\n\n@Component({\n selector: 'mage-static-icon-form-field',\n templateUrl: './static-icon-form-field.component.html',\n styleUrls: ['./static-icon-form-field.component.scss'],\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n multi: true,\n useExisting: StaticIconFormFieldComponent\n },\n {\n provide: NG_VALIDATORS,\n multi: true,\n useExisting: StaticIconFormFieldComponent\n },\n ]\n})\nexport class StaticIconFormFieldComponent implements OnChanges, OnDestroy, ControlValueAccessor, Validator {\n\n iconRef: StaticIconReference = null\n\n form: FormGroup = new FormGroup({\n iconRefToken: new FormControl(null),\n iconRefType: new FormControl(null, Validators.required)\n })\n icon: StaticIcon | null\n\n private onChange: (iconRef: StaticIconReference) => void = (iconRef: StaticIconReference) => {}\n private onValidatorChange: () => void = () => {}\n private onTouched: () => void = () => {}\n\n constructor(private iconService: StaticIconService, private httpClient: HttpClient, private sanitizer: DomSanitizer) {\n this.form.valueChanges.subscribe((x: IconRefFormValue) => {\n this.iconRef = iconRefForFormValue(x)\n this.onChange(this.iconRef)\n })\n }\n\n registerOnValidatorChange?(fn: () => void): void {\n this.onValidatorChange = fn\n }\n\n ngOnChanges(changes: SimpleChanges) { }\n\n ngOnDestroy() { }\n\n onSelectIcon() { }\n\n writeValue(iconRef: StaticIconReference): void {\n this.iconRef = iconRef\n const formValue = formValueForIconRef(iconRef)\n this.form.setValue(formValue, { emitEvent: false })\n this.resolveIconRef()\n }\n\n registerOnChange(fn: (x: StaticIconReference | null) => void): void {\n this.onChange = fn\n }\n\n registerOnTouched(fn: () => void): void {\n this.onTouched = fn\n }\n\n setDisabledState?(isDisabled: boolean): void {\n if (isDisabled) {\n this.form.disable()\n }\n else {\n this.form.enable()\n }\n }\n\n validate(control: AbstractControl): ValidationErrors {\n return this.form.errors\n }\n\n private resolveIconRef() {\n if (!this.iconRef) {\n this.icon = null\n return\n }\n this.iconService.fetchIconByReference(this.iconRef).subscribe(x => {\n this.icon = x\n if (!this.icon) {\n return\n }\n })\n }\n}\n\nenum IconRefType {\n Registered = 'id',\n SourceUrl = 'sourceUrl'\n}\n\ntype IconRefFormValue = {\n iconRefToken: string | null\n iconRefType: IconRefType | null\n}\n\nfunction iconRefForFormValue(x: IconRefFormValue): StaticIconReference | null {\n if (!x.iconRefType) {\n return null\n }\n switch (x.iconRefType) {\n case IconRefType.Registered:\n return { [IconRefType.Registered]: x.iconRefToken }\n case IconRefType.SourceUrl:\n return { [IconRefType.SourceUrl]: x.iconRefToken }\n default:\n throw new Error('invalid icon ref type: ' + x.iconRefToken)\n }\n}\n\nfunction formValueForIconRef(x: StaticIconReference | null): IconRefFormValue {\n if (!x) {\n return {\n iconRefType: null,\n iconRefToken: null\n }\n }\n let iconRefType: IconRefType | null = null\n let iconRefToken: string | null = null\n if (x.hasOwnProperty(IconRefType.Registered)) {\n iconRefType = IconRefType.Registered || null\n iconRefToken = x[IconRefType.Registered] || null\n }\n else if (x.hasOwnProperty(IconRefType.SourceUrl)) {\n iconRefType = IconRefType.SourceUrl || null\n iconRefToken = x[IconRefType.SourceUrl] || null\n }\n return {\n iconRefType,\n iconRefToken\n }\n}\n","<div [formGroup]=\"form\">\n <mage-xhr-img class=\"icon-image\" [src]=\"icon?.contentPath\"></mage-xhr-img>\n <input type=\"hidden\" formControlName=\"iconRefType\"/>\n <input type=\"hidden\" formControlName=\"iconRefToken\"/>\n</div>","import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core';\nimport { RegisteredStaticIconReference, contentPathOfIcon } from '../static-icon.model'\n\n@Component({\n selector: 'mage-static-icon-img',\n template: `<mage-xhr-img [src]=\"iconPath\"></mage-xhr-img>`,\n})\nexport class StaticIconImgComponent implements OnInit, OnChanges {\n\n @Input()\n iconRef: RegisteredStaticIconReference | string | null\n iconPath: string | null\n\n constructor() { }\n\n ngOnInit(): void {\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n if (changes.iconRef) {\n if (this.iconRef) {\n this.iconPath = contentPathOfIcon(this.iconRef)\n }\n else {\n this.iconPath = null\n }\n }\n }\n}\n","<div class=\"icon-select\">\n <cdk-virtual-scroll-viewport [itemSize]=\"40\">\n <mat-card *cdkVirtualFor=\"let icon of icons\" class=icon-select-item>\n <mat-card-header>\n <mat-card-title>{{icon.title}}</mat-card-title>\n </mat-card-header>\n <img mat-card-img [src]=\"icon.path\" />\n </mat-card>\n </cdk-virtual-scroll-viewport>\n</div>\n<!--\n <button mat-button class=\"add__button\" type=\"button\" color=\"primary\" (click)=\"file.click()\">\n Upload Icon\n </button>\n <input [hidden]=\"true\" type=\"file\" #file multiple (change)=\"onAttachmentFile($event)\">\n-->","import { Component, OnInit } from '@angular/core'\nimport { PagingParameters, PagingDataSource } from '@ngageoint/mage.web-core-lib/paging'\nimport { StaticIcon } from '../static-icon.model'\nimport { StaticIconService } from '../static-icon.service'\n\nexport interface StaticIconSelectItem {\n id: string\n path: string\n title: string\n fileName: string\n}\n\n@Component({\n selector: 'static-icon-select',\n templateUrl: './static-icon-select.component.html',\n styleUrls: ['./static-icon-select.component.scss']\n})\nexport class StaticIconSelectComponent implements OnInit {\n\n icons: StaticIcon[] | null = null\n dataSource: PagingDataSource<StaticIcon>\n\n constructor(\n private iconService: StaticIconService\n ) {\n this.dataSource = new PagingDataSource<StaticIcon>(250, (paging: PagingParameters) => {\n return this.iconService.fetchIcons(paging)\n })\n }\n\n ngOnInit() {\n this.iconService.fetchIcons().subscribe(x => {\n this.icons = x.items\n })\n }\n\n onBrowseForUploadIcon() {\n throw new Error('unimplemented')\n }\n}\n\n","import { ScrollingModule } from '@angular/cdk/scrolling'\nimport { CommonModule } from '@angular/common'\nimport { NgModule } from '@angular/core'\nimport { FormsModule, ReactiveFormsModule } from '@angular/forms'\nimport { MatCardModule } from '@angular/material/card'\nimport { MageCommonModule } from '@ngageoint/mage.web-core-lib/common'\nimport { StaticIconFormFieldComponent } from './static-icon-form-field/static-icon-form-field.component'\nimport { StaticIconImgComponent } from './static-icon-img/static-icon-img.component'\nimport { StaticIconSelectComponent } from './static-icon-select/static-icon-select.component'\n\n\n@NgModule({\n imports: [\n CommonModule,\n FormsModule,\n ReactiveFormsModule,\n MatCardModule,\n MageCommonModule,\n ScrollingModule\n ],\n declarations: [\n StaticIconFormFieldComponent,\n StaticIconImgComponent,\n StaticIconSelectComponent,\n ],\n exports: [\n StaticIconFormFieldComponent,\n StaticIconImgComponent,\n StaticIconSelectComponent,\n ]\n})\nexport class StaticIconModule {}"],"names":["Observable","catchError","throwError","HttpParams","Injectable","FormGroup","FormControl","Validators","NG_VALUE_ACCESSOR","NG_VALIDATORS","i0.ɵɵelementStart","i0.ɵɵelement","i0.ɵɵelementEnd","i0.ɵɵproperty","i0.ɵɵadvance","Component","Input","i0.ɵɵtext","i0.ɵɵtextInterpolate","PagingDataSource","i0.ɵɵtemplate","CommonModule","FormsModule","ReactiveFormsModule","MatCardModule","MageCommonModule","ScrollingModule","NgModule"],"mappings":";;;;;;QAqBa,iBAAiB,GAAG,UAAC,IAA6E;QAC7G,IAAI,CAAC,IAAI,EAAE;YACT,OAAM;SACP;QACD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YAC5B,IAAI,GAAG,IAAI,CAAC,EAAE,CAAA;SACf;QACD,OAAO,gBAAc,IAAI,aAAU,CAAA;IACrC;;;QCZE,2BAAoB,IAAgB;YAAhB,SAAI,GAAJ,IAAI,CAAY;SAAK;QAEzC,sCAAU,GAAV,UAAW,KAAiB;YAC1B,IAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;YACtB,IAAM,OAAO,GAAG,IAAIA,eAAU,CAAqB,UAAA,QAAQ;gBACzD,IAAM,KAAK,GAAiB,EAAE,CAAA;gBAC9B,IAAI,SAAS,GAAG,GAAG,CAAA;gBACnB,OAAO,SAAS,EAAE,EAAE;oBAClB,IAAM,EAAE,GAAG,GAAG,GAAG,SAAS,CAAA;oBAC1B,KAAK,CAAC,OAAO,CAAC;wBACZ,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC;wBACd,KAAK,EAAE,UAAQ,EAAI;wBACnB,QAAQ,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gBAAgB;kBApB5BC,aAAQ;mBAAC;oBACR,OAAO,EAAE;wBACPN,mBAAY;wBACZC,iBAAW;wBACXC,yBAAmB;wBACnBC,kBAAa;wBACbC,yBAAgB;wBAChBC,yBAAe;qBAChB;oBACD,YAAY,EAAE;wBACZ,4BAA4B;wBAC5B,sBAAsB;wBACtB,yBAAyB;qBAC1B;oBACD,OAAO,EAAE;wBACP,4BAA4B;wBAC5B,sBAAsB;wBACtB,yBAAyB;qBAC1B;iBACF;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@angular/cdk/scrolling"),require("@angular/common"),require("@angular/core"),require("@angular/forms"),require("@angular/material/card"),require("@ngageoint/mage.web-core-lib/common"),require("@angular/common/http"),require("rxjs"),require("rxjs/operators"),require("@angular/platform-browser"),require("@ngageoint/mage.web-core-lib/paging")):"function"==typeof define&&define.amd?define("@ngageoint/mage.web-core-lib/static-icon",["exports","@angular/cdk/scrolling","@angular/common","@angular/core","@angular/forms","@angular/material/card","@ngageoint/mage.web-core-lib/common","@angular/common/http","rxjs","rxjs/operators","@angular/platform-browser","@ngageoint/mage.web-core-lib/paging"],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"]["static-icon"]={}),e.ng.cdk.scrolling,e.ng.common,e.ng.core,e.ng.forms,e.ng.material.card,e.ngageoint.mage["web-core-lib"].common,e.ng.common.http,e.rxjs,e.rxjs.operators,e.ng.platformBrowser,e.ngageoint.mage["web-core-lib"].paging)}(this,(function(e,n,t,o,r,i,c,a,u,l,s,f){"use strict";var m,p=function(e){if(e)return"string"!=typeof e&&(e=e.id),"/api/icons/"+e+"/content"},g=function(){function e(e){this.http=e}return e.prototype.fetchIcons=function(e){var n=Date.now();return new u.Observable((function(e){for(var t=[],o=100;o--;){var r=n-o;t.unshift({id:String(r),title:"Icon "+r,fileName:"icon-"+r+".png",sourceUrl:"https://test.mage/"+r+".png",contentPath:"/icons/"+r+"/content"})}return setTimeout((function(){e.next({pageSize:100,pageIndex:0,totalCount:100,items:t}),e.complete()}),0),{unsubscribe:function(){}}}))},e.prototype.fetchIconById=function(e){return this.http.get("/api/icons/"+e).pipe(l.catchError((function(e,n){return u.throwError(e)})))},e.prototype.fetchIconBySourceUrl=function(e){return this.http.get("/api/icons",{params:(new a.HttpParams).set("source_url",e)})},e.prototype.fetchIconByReference=function(e){if(e.id)return this.fetchIconById(e.id);if(e.sourceUrl)return this.fetchIconBySourceUrl(e.sourceUrl);throw new Error("no icon id or source url")},e.prototype.registerIconUrl=function(e){throw new Error("unimplemented")},e.prototype.uploadIcon=function(){throw new Error("unimplemented")},e.ɵfac=function(n){return new(n||e)(o.ɵɵinject(a.HttpClient))},e.ɵprov=o.ɵɵdefineInjectable({token:e,factory:e.ɵfac,providedIn:"root"}),e}(),d=function(){function e(e,n,t){var o=this;this.iconService=e,this.httpClient=n,this.sanitizer=t,this.iconRef=null,this.form=new r.FormGroup({iconRefToken:new r.FormControl(null),iconRefType:new r.FormControl(null,r.Validators.required)}),this.onChange=function(e){},this.onValidatorChange=function(){},this.onTouched=function(){},this.form.valueChanges.subscribe((function(e){o.iconRef=function(e){var n,t;if(!e.iconRefType)return null;switch(e.iconRefType){case m.Registered:return(n={})[m.Registered]=e.iconRefToken,n;case m.SourceUrl:return(t={})[m.SourceUrl]=e.iconRefToken,t;default:throw new Error("invalid icon ref type: "+e.iconRefToken)}}(e),o.onChange(o.iconRef)}))}return e.prototype.registerOnValidatorChange=function(e){this.onValidatorChange=e},e.prototype.ngOnChanges=function(e){},e.prototype.ngOnDestroy=function(){},e.prototype.onSelectIcon=function(){},e.prototype.writeValue=function(e){this.iconRef=e;var n=function(e){if(!e)return{iconRefType:null,iconRefToken:null};var n=null,t=null;e.hasOwnProperty(m.Registered)?(n=m.Registered||null,t=e[m.Registered]||null):e.hasOwnProperty(m.SourceUrl)&&(n=m.SourceUrl||null,t=e[m.SourceUrl]||null);return{iconRefType:n,iconRefToken:t}}(e);this.form.setValue(n,{emitEvent:!1}),this.resolveIconRef()},e.prototype.registerOnChange=function(e){this.onChange=e},e.prototype.registerOnTouched=function(e){this.onTouched=e},e.prototype.setDisabledState=function(e){e?this.form.disable():this.form.enable()},e.prototype.validate=function(e){return this.form.errors},e.prototype.resolveIconRef=function(){var e=this;this.iconRef?this.iconService.fetchIconByReference(this.iconRef).subscribe((function(n){e.icon=n,e.icon})):this.icon=null},e.ɵfac=function(n){return new(n||e)(o.ɵɵdirectiveInject(g),o.ɵɵdirectiveInject(a.HttpClient),o.ɵɵdirectiveInject(s.DomSanitizer))},e.ɵcmp=o.ɵɵdefineComponent({type:e,selectors:[["mage-static-icon-form-field"]],features:[o.ɵɵProvidersFeature([{provide:r.NG_VALUE_ACCESSOR,multi:!0,useExisting:e},{provide:r.NG_VALIDATORS,multi:!0,useExisting:e}]),o.ɵɵNgOnChangesFeature],decls:4,vars:2,consts:[[3,"formGroup"],[1,"icon-image",3,"src"],["type","hidden","formControlName","iconRefType"],["type","hidden","formControlName","iconRefToken"]],template:function(e,n){1&e&&(o.ɵɵelementStart(0,"div",0),o.ɵɵelement(1,"mage-xhr-img",1),o.ɵɵelement(2,"input",2),o.ɵɵelement(3,"input",3),o.ɵɵelementEnd()),2&e&&(o.ɵɵproperty("formGroup",n.form),o.ɵɵadvance(1),o.ɵɵproperty("src",null==n.icon?null:n.icon.contentPath))},directives:[r.NgControlStatusGroup,r.FormGroupDirective,c.XhrImgComponent,r.DefaultValueAccessor,r.NgControlStatus,r.FormControlName],styles:[".icon-image[_ngcontent-%COMP%]{display:block;height:3em;width:3em}"]}),e}();!function(e){e.Registered="id",e.SourceUrl="sourceUrl"}(m||(m={}));var h=function(){function e(){}return e.prototype.ngOnInit=function(){},e.prototype.ngOnChanges=function(e){e.iconRef&&(this.iconRef?this.iconPath=p(this.iconRef):this.iconPath=null)},e.ɵfac=function(n){return new(n||e)},e.ɵcmp=o.ɵɵdefineComponent({type:e,selectors:[["mage-static-icon-img"]],inputs:{iconRef:"iconRef"},features:[o.ɵɵNgOnChangesFeature],decls:1,vars:1,consts:[[3,"src"]],template:function(e,n){1&e&&o.ɵɵelement(0,"mage-xhr-img",0),2&e&&o.ɵɵproperty("src",n.iconPath)},directives:[c.XhrImgComponent],encapsulation:2}),e}();function y(e,n){if(1&e&&(o.ɵɵelementStart(0,"mat-card",3),o.ɵɵelementStart(1,"mat-card-header"),o.ɵɵelementStart(2,"mat-card-title"),o.ɵɵtext(3),o.ɵɵelementEnd(),o.ɵɵelementEnd(),o.ɵɵelement(4,"img",4),o.ɵɵelementEnd()),2&e){var t=n.$implicit;o.ɵɵadvance(3),o.ɵɵtextInterpolate(t.title),o.ɵɵadvance(1),o.ɵɵproperty("src",t.path,o.ɵɵsanitizeUrl)}}var v=function(){function e(e){var n=this;this.iconService=e,this.icons=null,this.dataSource=new f.PagingDataSource(250,(function(e){return n.iconService.fetchIcons(e)}))}return e.prototype.ngOnInit=function(){var e=this;this.iconService.fetchIcons().subscribe((function(n){e.icons=n.items}))},e.prototype.onBrowseForUploadIcon=function(){throw new Error("unimplemented")},e.ɵfac=function(n){return new(n||e)(o.ɵɵdirectiveInject(g))},e.ɵcmp=o.ɵɵdefineComponent({type:e,selectors:[["static-icon-select"]],decls:3,vars:2,consts:[[1,"icon-select"],[3,"itemSize"],["class","icon-select-item",4,"cdkVirtualFor","cdkVirtualForOf"],[1,"icon-select-item"],["mat-card-img","",3,"src"]],template:function(e,n){1&e&&(o.ɵɵelementStart(0,"div",0),o.ɵɵelementStart(1,"cdk-virtual-scroll-viewport",1),o.ɵɵtemplate(2,y,5,2,"mat-card",2),o.ɵɵelementEnd(),o.ɵɵelementEnd()),2&e&&(o.ɵɵadvance(1),o.ɵɵproperty("itemSize",40),o.ɵɵadvance(1),o.ɵɵproperty("cdkVirtualForOf",n.icons))},directives:[n.CdkVirtualScrollViewport,n.CdkFixedSizeVirtualScroll,n.CdkVirtualForOf,i.MatCard,i.MatCardHeader,i.MatCardTitle],styles:["virtual-scroll[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(3,33%);grid-auto-rows:min-content;grid-gap:0;justify-content:center;gap:0}"]}),e}(),C=function(){function e(){}return e.ɵmod=o.ɵɵdefineNgModule({type:e}),e.ɵinj=o.ɵɵdefineInjector({factory:function(n){return new(n||e)},imports:[[t.CommonModule,r.FormsModule,r.ReactiveFormsModule,i.MatCardModule,c.MageCommonModule,n.ScrollingModule]]}),e}();("undefined"==typeof ngJitMode||ngJitMode)&&o.ɵɵsetNgModuleScope(C,{declarations:[d,h,v],imports:[t.CommonModule,r.FormsModule,r.ReactiveFormsModule,i.MatCardModule,c.MageCommonModule,n.ScrollingModule],exports:[d,h,v]}),e.StaticIconFormFieldComponent=d,e.StaticIconImgComponent=h,e.StaticIconModule=C,e.StaticIconSelectComponent=v,e.StaticIconService=g,e.contentPathOfIcon=p,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
2
|
+
//# sourceMappingURL=ngageoint-mage.web-core-lib-static-icon.umd.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["ng://@ngageoint/mage.web-core-lib/static-icon/static-icon-form-field/static-icon-form-field.component.ts","ng://@ngageoint/mage.web-core-lib/static-icon/static-icon.model.ts","ng://@ngageoint/mage.web-core-lib/static-icon/static-icon.service.ts","ng://@ngageoint/mage.web-core-lib/static-icon/static-icon-form-field/static-icon-form-field.component.html","ng://@ngageoint/mage.web-core-lib/static-icon/static-icon-img/static-icon-img.component.ts","ng://@ngageoint/mage.web-core-lib/static-icon/static-icon-select/static-icon-select.component.html","ng://@ngageoint/mage.web-core-lib/static-icon/static-icon-select/static-icon-select.component.ts","ng://@ngageoint/mage.web-core-lib/static-icon/static-icon.module.ts"],"names":["IconRefType","contentPathOfIcon","icon","id","StaticIconService","http","this","prototype","fetchIcons","fetch","now","Date","Observable","observer","icons","remaining","unshift","String","title","fileName","sourceUrl","contentPath","setTimeout","next","pageSize","pageIndex","totalCount","items","complete","unsubscribe","fetchIconById","get","pipe","catchError","err","caught","throwError","fetchIconBySourceUrl","url","params","HttpParams","set","fetchIconByReference","ref","Error","registerIconUrl","uploadIcon","core","ɵɵinject","HttpClient","factory","ɵfac","providedIn","StaticIconFormFieldComponent","iconService","httpClient","sanitizer","_this","iconRef","form","FormGroup","iconRefToken","FormControl","iconRefType","Validators","required","onChange","onValidatorChange","onTouched","valueChanges","subscribe","x","Registered","_a","SourceUrl","_b","iconRefForFormValue","registerOnValidatorChange","fn","ngOnChanges","changes","ngOnDestroy","onSelectIcon","writeValue","formValue","hasOwnProperty","formValueForIconRef","setValue","emitEvent","resolveIconRef","registerOnChange","registerOnTouched","setDisabledState","isDisabled","disable","enable","validate","control","errors","ɵɵdirectiveInject","platformBrowser","DomSanitizer","selectors","features","ɵɵProvidersFeature","provide","NG_VALUE_ACCESSOR","multi","useExisting","NG_VALIDATORS","ɵɵNgOnChangesFeature","decls","vars","consts","template","rf","ctx","i0.ɵɵelementStart","i0.ɵɵelement","i0.ɵɵelementEnd","i0.ɵɵproperty","i0.ɵɵadvance","StaticIconImgComponent","ngOnInit","iconPath","inputs","i0.ɵɵtext","i0.ɵɵtextInterpolate","StaticIconSelectComponent","dataSource","PagingDataSource","paging","onBrowseForUploadIcon","i0.ɵɵtemplate","StaticIconModule","imports","CommonModule","FormsModule","ReactiveFormsModule","MatCardModule","MageCommonModule","ScrollingModule","declarations","exports"],"mappings":"0uCAkGKA,EC7EQC,EAAoB,SAACC,GAChC,GAAKA,EAML,MAHoB,iBAATA,IACTA,EAAOA,EAAKC,IAEP,cAAcD,EAAI,yBCXzB,SAAAE,EAAoBC,GAAAC,KAAAD,KAAAA,SAEpBD,EAAAG,UAAAC,WAAA,SAAWC,GACT,IAAMC,EAAMC,KAAKD,MA2BjB,OA1BgB,IAAIE,EAAAA,YA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K3C,MAAQyD,EAAE5C,UAInBqG,EAAAzH,UAAA6H,sBAAA,WACE,MAAM,IAAIxF,MAAM,mDApBPoF,GAAyBjF,EAAAoD,kBAAA/F,sCAAzB4H,EAAyB1B,UAAA,CAAA,CAAA,uBAAAS,MAAA,EAAAC,KAAA,EAAAC,OAAA,CAAA,CAAA,EAAA,eAAA,CAAA,EAAA,YAAA,CAAA,QAAA,mBAAA,EAAA,gBAAA,mBAAA,CAAA,EAAA,oBAAA,CAAA,eAAA,GAAA,EAAA,QAAAC,SAAA,SAAAC,EAAAC,GAAA,EAAAD,IDjBtCE,EAAAA,eAAAA,EAAAA,MAAAA,GACEA,EAAAA,eAAAA,EAAAA,8BAAAA,GACEgB,EAAAA,WAAAA,EAAAA,EAAAA,EAAAA,EAAAA,WAAAA,GAMFd,EAAAA,eACFA,EAAAA,sBAR+BE,EAAAA,UAAAA,GAAAD,EAAAA,WAAAA,WAAAA,IACjBC,EAAAA,UAAAA,GAAAD,EAAAA,WAAAA,kBAAAA,EAAAA,8TESd,SAAAc,4CAoBaA,iEAAAA,IAAgBC,QAAA,CAnBlB,CACPC,EAAAA,aACAC,EAAAA,YACAC,EAAAA,oBACAC,EAAAA,cACAC,EAAAA,iBACAC,EAAAA,0FAaSP,EAAgB,CAAAQ,aAAA,CAVzBzF,EACAqE,EACAM,GAAyBO,QAAA,CAVzBC,EAAAA,aACAC,EAAAA,YACAC,EAAAA,oBACAC,EAAAA,cACAC,EAAAA,iBACAC,EAAAA,iBAAeE,QAAA,CAQf1F,EACAqE,EACAM","sourcesContent":["import { HttpClient } from '@angular/common/http'\nimport { Component, OnChanges, OnDestroy, SimpleChanges } from '@angular/core'\nimport { AbstractControl, ControlValueAccessor, FormControl, FormGroup, NG_VALIDATORS, NG_VALUE_ACCESSOR, ValidationErrors, Validator, Validators } from '@angular/forms'\nimport { DomSanitizer } from '@angular/platform-browser'\nimport { StaticIcon, StaticIconReference } from '../static-icon.model'\nimport { StaticIconService } from '../static-icon.service'\n\n\n@Component({\n selector: 'mage-static-icon-form-field',\n templateUrl: './static-icon-form-field.component.html',\n styleUrls: ['./static-icon-form-field.component.scss'],\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n multi: true,\n useExisting: StaticIconFormFieldComponent\n },\n {\n provide: NG_VALIDATORS,\n multi: true,\n useExisting: StaticIconFormFieldComponent\n },\n ]\n})\nexport class StaticIconFormFieldComponent implements OnChanges, OnDestroy, ControlValueAccessor, Validator {\n\n iconRef: StaticIconReference = null\n\n form: FormGroup = new FormGroup({\n iconRefToken: new FormControl(null),\n iconRefType: new FormControl(null, Validators.required)\n })\n icon: StaticIcon | null\n\n private onChange: (iconRef: StaticIconReference) => void = (iconRef: StaticIconReference) => {}\n private onValidatorChange: () => void = () => {}\n private onTouched: () => void = () => {}\n\n constructor(private iconService: StaticIconService, private httpClient: HttpClient, private sanitizer: DomSanitizer) {\n this.form.valueChanges.subscribe((x: IconRefFormValue) => {\n this.iconRef = iconRefForFormValue(x)\n this.onChange(this.iconRef)\n })\n }\n\n registerOnValidatorChange?(fn: () => void): void {\n this.onValidatorChange = fn\n }\n\n ngOnChanges(changes: SimpleChanges) { }\n\n ngOnDestroy() { }\n\n onSelectIcon() { }\n\n writeValue(iconRef: StaticIconReference): void {\n this.iconRef = iconRef\n const formValue = formValueForIconRef(iconRef)\n this.form.setValue(formValue, { emitEvent: false })\n this.resolveIconRef()\n }\n\n registerOnChange(fn: (x: StaticIconReference | null) => void): void {\n this.onChange = fn\n }\n\n registerOnTouched(fn: () => void): void {\n this.onTouched = fn\n }\n\n setDisabledState?(isDisabled: boolean): void {\n if (isDisabled) {\n this.form.disable()\n }\n else {\n this.form.enable()\n }\n }\n\n validate(control: AbstractControl): ValidationErrors {\n return this.form.errors\n }\n\n private resolveIconRef() {\n if (!this.iconRef) {\n this.icon = null\n return\n }\n this.iconService.fetchIconByReference(this.iconRef).subscribe(x => {\n this.icon = x\n if (!this.icon) {\n return\n }\n })\n }\n}\n\nenum IconRefType {\n Registered = 'id',\n SourceUrl = 'sourceUrl'\n}\n\ntype IconRefFormValue = {\n iconRefToken: string | null\n iconRefType: IconRefType | null\n}\n\nfunction iconRefForFormValue(x: IconRefFormValue): StaticIconReference | null {\n if (!x.iconRefType) {\n return null\n }\n switch (x.iconRefType) {\n case IconRefType.Registered:\n return { [IconRefType.Registered]: x.iconRefToken }\n case IconRefType.SourceUrl:\n return { [IconRefType.SourceUrl]: x.iconRefToken }\n default:\n throw new Error('invalid icon ref type: ' + x.iconRefToken)\n }\n}\n\nfunction formValueForIconRef(x: StaticIconReference | null): IconRefFormValue {\n if (!x) {\n return {\n iconRefType: null,\n iconRefToken: null\n }\n }\n let iconRefType: IconRefType | null = null\n let iconRefToken: string | null = null\n if (x.hasOwnProperty(IconRefType.Registered)) {\n iconRefType = IconRefType.Registered || null\n iconRefToken = x[IconRefType.Registered] || null\n }\n else if (x.hasOwnProperty(IconRefType.SourceUrl)) {\n iconRefType = IconRefType.SourceUrl || null\n iconRefToken = x[IconRefType.SourceUrl] || null\n }\n return {\n iconRefType,\n iconRefToken\n }\n}\n","\nexport interface StaticIcon {\n id: string\n sourceUrl: string\n contentPath: string\n title?: string\n summary?: string\n fileName?: string\n tags?: string[]\n}\n\nexport interface RegisteredStaticIconReference {\n id: string\n sourceUrl?: never\n}\n\nexport interface SourceUrlStaticIconReference {\n sourceUrl: string\n id?: never\n}\n\nexport const contentPathOfIcon = (icon?: StaticIcon | RegisteredStaticIconReference | string | null | undefined): string | undefined => {\n if (!icon) {\n return\n }\n if (typeof icon !== 'string') {\n icon = icon.id\n }\n return `/api/icons/${icon}/content`\n}\n\nexport type StaticIconReference = RegisteredStaticIconReference | SourceUrlStaticIconReference\n","import { HttpClient, HttpParams } from '@angular/common/http'\nimport { Injectable } from '@angular/core';\nimport { Observable, throwError } from 'rxjs'\nimport { catchError } from 'rxjs/operators'\nimport { PageOf, PagingParameters } from '@ngageoint/mage.web-core-lib/paging'\nimport { StaticIcon, StaticIconReference } from './static-icon.model'\n\n\nexport interface IconFetch extends PagingParameters {\n searchText?: string\n}\n\n@Injectable({\n providedIn: 'root'\n})\nexport class StaticIconService {\n\n constructor(private http: HttpClient) { }\n\n fetchIcons(fetch?: IconFetch): Observable<PageOf<StaticIcon>> {\n const now = Date.now()\n const results = new Observable<PageOf<StaticIcon>>(observer => {\n const icons: StaticIcon[] = []\n let remaining = 100\n while (remaining--) {\n const id = now - remaining\n icons.unshift({\n id: String(id),\n title: `Icon ${id}`,\n fileName: `icon-${id}.png`,\n sourceUrl: `https://test.mage/${id}.png`,\n contentPath: `/icons/${id}/content`\n })\n }\n setTimeout(() => {\n observer.next({\n pageSize: 100,\n pageIndex: 0,\n totalCount: 100,\n items: icons\n })\n observer.complete()\n }, 0)\n return {\n unsubscribe() { }\n }\n })\n return results\n }\n\n fetchIconById(id: string): Observable<StaticIcon | null> {\n return this.http.get<StaticIcon>(`/api/icons/${id}`).pipe(\n catchError((err, caught) => {\n // TODO: this is probably better practice to insulate app layer from\n // http errors\n // if (err instanceof HttpErrorResponse) {\n // if (err.status === 404) {\n // return null\n // }\n // }\n return throwError(err)\n })\n )\n }\n\n fetchIconBySourceUrl(url: string): Observable<StaticIcon> {\n return this.http.get<StaticIcon | null>(`/api/icons`, {\n params: new HttpParams().set('source_url', url)\n })\n }\n\n fetchIconByReference(ref: StaticIconReference): Observable<StaticIcon | null> {\n if (ref.id) {\n return this.fetchIconById(ref.id)\n }\n else if (ref.sourceUrl) {\n return this.fetchIconBySourceUrl(ref.sourceUrl)\n }\n throw new Error('no icon id or source url')\n }\n\n registerIconUrl(url: string): Observable<StaticIcon> {\n throw new Error('unimplemented')\n }\n\n uploadIcon(): void {\n throw new Error('unimplemented')\n }\n}\n","<div [formGroup]=\"form\">\n <mage-xhr-img class=\"icon-image\" [src]=\"icon?.contentPath\"></mage-xhr-img>\n <input type=\"hidden\" formControlName=\"iconRefType\"/>\n <input type=\"hidden\" formControlName=\"iconRefToken\"/>\n</div>","import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core';\nimport { RegisteredStaticIconReference, contentPathOfIcon } from '../static-icon.model'\n\n@Component({\n selector: 'mage-static-icon-img',\n template: `<mage-xhr-img [src]=\"iconPath\"></mage-xhr-img>`,\n})\nexport class StaticIconImgComponent implements OnInit, OnChanges {\n\n @Input()\n iconRef: RegisteredStaticIconReference | string | null\n iconPath: string | null\n\n constructor() { }\n\n ngOnInit(): void {\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n if (changes.iconRef) {\n if (this.iconRef) {\n this.iconPath = contentPathOfIcon(this.iconRef)\n }\n else {\n this.iconPath = null\n }\n }\n }\n}\n","<div class=\"icon-select\">\n <cdk-virtual-scroll-viewport [itemSize]=\"40\">\n <mat-card *cdkVirtualFor=\"let icon of icons\" class=icon-select-item>\n <mat-card-header>\n <mat-card-title>{{icon.title}}</mat-card-title>\n </mat-card-header>\n <img mat-card-img [src]=\"icon.path\" />\n </mat-card>\n </cdk-virtual-scroll-viewport>\n</div>\n<!--\n <button mat-button class=\"add__button\" type=\"button\" color=\"primary\" (click)=\"file.click()\">\n Upload Icon\n </button>\n <input [hidden]=\"true\" type=\"file\" #file multiple (change)=\"onAttachmentFile($event)\">\n-->","import { Component, OnInit } from '@angular/core'\nimport { PagingParameters, PagingDataSource } from '@ngageoint/mage.web-core-lib/paging'\nimport { StaticIcon } from '../static-icon.model'\nimport { StaticIconService } from '../static-icon.service'\n\nexport interface StaticIconSelectItem {\n id: string\n path: string\n title: string\n fileName: string\n}\n\n@Component({\n selector: 'static-icon-select',\n templateUrl: './static-icon-select.component.html',\n styleUrls: ['./static-icon-select.component.scss']\n})\nexport class StaticIconSelectComponent implements OnInit {\n\n icons: StaticIcon[] | null = null\n dataSource: PagingDataSource<StaticIcon>\n\n constructor(\n private iconService: StaticIconService\n ) {\n this.dataSource = new PagingDataSource<StaticIcon>(250, (paging: PagingParameters) => {\n return this.iconService.fetchIcons(paging)\n })\n }\n\n ngOnInit() {\n this.iconService.fetchIcons().subscribe(x => {\n this.icons = x.items\n })\n }\n\n onBrowseForUploadIcon() {\n throw new Error('unimplemented')\n }\n}\n\n","import { ScrollingModule } from '@angular/cdk/scrolling'\nimport { CommonModule } from '@angular/common'\nimport { NgModule } from '@angular/core'\nimport { FormsModule, ReactiveFormsModule } from '@angular/forms'\nimport { MatCardModule } from '@angular/material/card'\nimport { MageCommonModule } from '@ngageoint/mage.web-core-lib/common'\nimport { StaticIconFormFieldComponent } from './static-icon-form-field/static-icon-form-field.component'\nimport { StaticIconImgComponent } from './static-icon-img/static-icon-img.component'\nimport { StaticIconSelectComponent } from './static-icon-select/static-icon-select.component'\n\n\n@NgModule({\n imports: [\n CommonModule,\n FormsModule,\n ReactiveFormsModule,\n MatCardModule,\n MageCommonModule,\n ScrollingModule\n ],\n declarations: [\n StaticIconFormFieldComponent,\n StaticIconImgComponent,\n StaticIconSelectComponent,\n ],\n exports: [\n StaticIconFormFieldComponent,\n StaticIconImgComponent,\n StaticIconSelectComponent,\n ]\n})\nexport class StaticIconModule {}"]}
|