@teipublisher/pb-components 2.26.0-next-3.11 → 2.26.0-next-3.13
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/.github/workflows/main.yml +3 -3
- package/.github/workflows/node.js.yml +3 -3
- package/.github/workflows/release.js.yml +3 -3
- package/CHANGELOG.md +38 -0
- package/Dockerfile +78 -70
- package/css/components.css +5 -5
- package/dist/demo/components.css +2 -8
- package/dist/demo/pb-drawer2.html +1 -1
- package/dist/demo/pb-leaflet-map.html +1 -1
- package/dist/demo/pb-progress.html +2 -2
- package/dist/demo/pb-repeat.html +1 -3
- package/dist/demo/pb-view3.html +1 -1
- package/dist/{paper-icon-button-0fb125c4.js → paper-icon-button-72125e67.js} +1 -1
- package/dist/pb-code-editor.js +25 -20
- package/dist/pb-component-docs.js +58 -54
- package/dist/pb-components-bundle.js +1937 -1782
- package/dist/pb-edit-app.js +167 -107
- package/dist/pb-elements.json +45 -45
- package/dist/{pb-i18n-0611135a.js → pb-i18n-4cc00bfe.js} +1 -1
- package/dist/pb-leaflet-map.js +23 -23
- package/dist/pb-mei.js +56 -41
- package/dist/{pb-mixin-b1caa22e.js → pb-mixin-886ece32.js} +1 -1
- package/dist/pb-odd-editor.js +923 -756
- package/dist/pb-tify.js +2 -2
- package/dist/{vaadin-element-mixin-6633322b.js → vaadin-element-mixin-84fb7d82.js} +181 -143
- package/gh-pages.js +5 -3
- package/i18n/common/pl.json +2 -2
- package/lib/openseadragon.min.js +1 -1
- package/package.json +2 -2
- package/pb-elements.json +45 -45
- package/src/assets/components.css +5 -5
- package/src/authority/airtable.js +20 -21
- package/src/authority/anton.js +129 -129
- package/src/authority/custom.js +23 -21
- package/src/authority/geonames.js +38 -32
- package/src/authority/gnd.js +47 -42
- package/src/authority/kbga.js +137 -134
- package/src/authority/metagrid.js +44 -46
- package/src/authority/reconciliation.js +66 -67
- package/src/authority/registry.js +4 -4
- package/src/docs/pb-component-docs.js +2 -2
- package/src/docs/pb-component-view.js +5 -5
- package/src/docs/pb-components-list.js +2 -2
- package/src/docs/pb-demo-snippet.js +2 -2
- package/src/dts-client.js +299 -297
- package/src/dts-select-endpoint.js +90 -82
- package/src/parse-date-service.js +184 -135
- package/src/pb-ajax.js +150 -146
- package/src/pb-authority-lookup.js +183 -146
- package/src/pb-autocomplete.js +292 -280
- package/src/pb-blacklab-highlight.js +264 -259
- package/src/pb-blacklab-results.js +236 -221
- package/src/pb-browse-docs.js +540 -475
- package/src/pb-browse.js +68 -65
- package/src/pb-clipboard.js +79 -76
- package/src/pb-code-editor.js +110 -102
- package/src/pb-code-highlight.js +209 -204
- package/src/pb-codepen.js +79 -72
- package/src/pb-collapse.js +212 -207
- package/src/pb-combo-box.js +190 -190
- package/src/pb-components-bundle.js +1 -1
- package/src/pb-custom-form.js +151 -149
- package/src/pb-dialog.js +96 -60
- package/src/pb-document.js +89 -90
- package/src/pb-download.js +210 -198
- package/src/pb-drawer.js +145 -148
- package/src/pb-edit-app.js +301 -229
- package/src/pb-edit-xml.js +98 -96
- package/src/pb-events.js +114 -107
- package/src/pb-facs-link.js +104 -102
- package/src/pb-facsimile.js +411 -413
- package/src/pb-formula.js +151 -153
- package/src/pb-geolocation.js +129 -131
- package/src/pb-grid-action.js +53 -56
- package/src/pb-grid.js +231 -228
- package/src/pb-highlight.js +140 -140
- package/src/pb-hotkeys.js +40 -42
- package/src/pb-i18n.js +101 -104
- package/src/pb-image-strip.js +84 -78
- package/src/pb-lang.js +132 -128
- package/src/pb-leaflet-map.js +488 -485
- package/src/pb-link.js +126 -124
- package/src/pb-load.js +431 -426
- package/src/pb-login.js +291 -248
- package/src/pb-manage-odds.js +364 -318
- package/src/pb-map-icon.js +89 -89
- package/src/pb-map-layer.js +85 -85
- package/src/pb-markdown.js +90 -99
- package/src/pb-media-query.js +74 -72
- package/src/pb-mei.js +306 -295
- package/src/pb-message.js +144 -144
- package/src/pb-mixin.js +269 -264
- package/src/pb-navigation.js +80 -82
- package/src/pb-observable.js +38 -38
- package/src/pb-odd-editor.js +1053 -955
- package/src/pb-odd-elementspec-editor.js +348 -297
- package/src/pb-odd-model-editor.js +1061 -901
- package/src/pb-odd-parameter-editor.js +200 -178
- package/src/pb-odd-rendition-editor.js +136 -124
- package/src/pb-page.js +431 -421
- package/src/pb-paginate.js +202 -190
- package/src/pb-panel.js +191 -179
- package/src/pb-popover-themes.js +7 -5
- package/src/pb-popover.js +296 -287
- package/src/pb-print-preview.js +127 -127
- package/src/pb-progress.js +51 -51
- package/src/pb-repeat.js +105 -104
- package/src/pb-restricted.js +84 -77
- package/src/pb-search.js +252 -241
- package/src/pb-select-feature.js +127 -120
- package/src/pb-select-odd.js +132 -124
- package/src/pb-select-template.js +89 -78
- package/src/pb-select.js +251 -227
- package/src/pb-split-list.js +179 -174
- package/src/pb-svg.js +80 -79
- package/src/pb-table-column.js +54 -54
- package/src/pb-table-grid.js +221 -203
- package/src/pb-tabs.js +61 -63
- package/src/pb-tify.js +154 -154
- package/src/pb-timeline.js +271 -229
- package/src/pb-toggle-feature.js +182 -175
- package/src/pb-upload.js +184 -174
- package/src/pb-version.js +30 -30
- package/src/pb-view-annotate.js +132 -98
- package/src/pb-view.js +1289 -1270
- package/src/pb-zoom.js +75 -59
- package/src/polymer-hack.js +1 -1
- package/src/search-result-service.js +256 -223
- package/src/seed-element.js +13 -20
- package/src/settings.js +4 -4
- package/src/theming.js +96 -96
- package/src/urls.js +289 -289
- package/src/utils.js +53 -51
package/src/authority/kbga.js
CHANGED
|
@@ -1,156 +1,159 @@
|
|
|
1
|
-
import { internalProperty } from
|
|
2
|
-
import { Registry } from
|
|
1
|
+
import { internalProperty } from 'lit-element';
|
|
2
|
+
import { Registry } from './registry.js';
|
|
3
3
|
|
|
4
4
|
export class KBGA extends Registry {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
5
|
+
constructor(configElem) {
|
|
6
|
+
super(configElem);
|
|
7
|
+
this._api = configElem.getAttribute('api');
|
|
8
|
+
this._limit = configElem.getAttribute('limit') || 999999;
|
|
9
|
+
}
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const register = this.getRegister();
|
|
16
|
-
const searchParam = register === 'bibls' ? 'biblsearch' : 'search';
|
|
17
|
-
const url = `https://meta.karl-barth.ch/api/${register}?${searchParam}=${encodeURIComponent(key)}&perPage=${this._limit}`;
|
|
18
|
-
const label = this.getLabelField();
|
|
19
|
-
return new Promise((resolve) => {
|
|
20
|
-
fetch(url)
|
|
21
|
-
.then(response => response.json())
|
|
22
|
-
.then(json => {
|
|
23
|
-
json.data.forEach(item => {
|
|
24
|
-
|
|
25
|
-
if ((this._register === 'organization' && item.authority_type !== 'organisation') ||
|
|
26
|
-
(this._register === 'person' && item.authority_type !== 'person')) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const result = {
|
|
30
|
-
register: this._register,
|
|
31
|
-
id: (this._prefix ? `${this._prefix}:${item['full-id']}` : item['full-id']),
|
|
32
|
-
label: typeof label === "string" ? item[label] : label(item),
|
|
33
|
-
details: `${item['full-id']}`,
|
|
34
|
-
link: `https://meta.karl-barth.ch/${register}/${item.id}`,
|
|
35
|
-
strings: [typeof label === "string" ? item[label] : label(item)],
|
|
36
|
-
provider: 'KBGA'
|
|
37
|
-
};
|
|
38
|
-
results.push(result);
|
|
39
|
-
});
|
|
40
|
-
resolve({
|
|
41
|
-
totalItems: json.meta.total,
|
|
42
|
-
items: results,
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
})
|
|
46
|
-
}
|
|
11
|
+
async query(key) {
|
|
12
|
+
const results = [];
|
|
47
13
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
14
|
+
const register = this.getRegister();
|
|
15
|
+
const searchParam = register === 'bibls' ? 'biblsearch' : 'search';
|
|
16
|
+
const url = `https://meta.karl-barth.ch/api/${register}?${searchParam}=${encodeURIComponent(
|
|
17
|
+
key,
|
|
18
|
+
)}&perPage=${this._limit}`;
|
|
19
|
+
const label = this.getLabelField();
|
|
20
|
+
return new Promise(resolve => {
|
|
21
|
+
fetch(url)
|
|
22
|
+
.then(response => response.json())
|
|
55
23
|
.then(json => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
24
|
+
json.data.forEach(item => {
|
|
25
|
+
if (
|
|
26
|
+
(this._register === 'organization' && item.authority_type !== 'organisation') ||
|
|
27
|
+
(this._register === 'person' && item.authority_type !== 'person')
|
|
28
|
+
) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const result = {
|
|
32
|
+
register: this._register,
|
|
33
|
+
id: this._prefix ? `${this._prefix}:${item['full-id']}` : item['full-id'],
|
|
34
|
+
label: typeof label === 'string' ? item[label] : label(item),
|
|
35
|
+
details: `${item['full-id']}`,
|
|
36
|
+
link: `https://meta.karl-barth.ch/${register}/${item.id}`,
|
|
37
|
+
strings: [typeof label === 'string' ? item[label] : label(item)],
|
|
38
|
+
provider: 'KBGA',
|
|
39
|
+
};
|
|
40
|
+
results.push(result);
|
|
41
|
+
});
|
|
42
|
+
resolve({
|
|
43
|
+
totalItems: json.meta.total,
|
|
44
|
+
items: results,
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
info(key, container) {
|
|
51
|
+
if (!key) {
|
|
52
|
+
return Promise.resolve({});
|
|
53
|
+
}
|
|
54
|
+
const label = this.getLabelField();
|
|
55
|
+
return new Promise(resolve => {
|
|
56
|
+
this.getRecord(key).then(json => {
|
|
57
|
+
const died = json.data.death ? `† ${json.data.death}` : '';
|
|
58
|
+
const dates = json.data.birth ? `<p>* ${json.data.birth} ${died}</p>` : '';
|
|
59
|
+
const note = json.data.note_bio ? `<p>${json.data.note_bio}</p>` : '';
|
|
60
|
+
const output = `
|
|
61
|
+
<h3 class="label"><a href="https://${json.wikipediaURL}" target="_blank">${
|
|
62
|
+
typeof label === 'string' ? json.data[label] : label(json.data)
|
|
63
|
+
}</a></h3>
|
|
61
64
|
${dates}
|
|
62
65
|
${note}
|
|
63
66
|
`;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
});
|
|
67
|
+
container.innerHTML = output;
|
|
68
|
+
resolve({
|
|
69
|
+
id: json.data['full-id'],
|
|
70
|
+
strings: [typeof label === 'string' ? json.data[label] : label(json.data)],
|
|
69
71
|
});
|
|
70
72
|
});
|
|
71
|
-
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
72
75
|
|
|
73
|
-
|
|
76
|
+
/**
|
|
74
77
|
* Retrieve a raw JSON record for the given key as returned by the endpoint.
|
|
75
|
-
*
|
|
78
|
+
*
|
|
76
79
|
* @param {string} key the key to look up
|
|
77
80
|
* @returns {Promise<any>} promise resolving to the JSON record returned by the endpoint
|
|
78
81
|
*/
|
|
79
82
|
async getRecord(key) {
|
|
80
|
-
const id = key.replace(/^.*-([^-]+)$/, '$1')
|
|
83
|
+
const id = key.replace(/^.*-([^-]+)$/, '$1');
|
|
81
84
|
return fetch(`https://meta.karl-barth.ch/api/${this.getRegister()}/${id}`)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
case 'place':
|
|
88
|
-
output.country = json.data.country;
|
|
89
|
-
output.location = json.data.location.coordinates;
|
|
90
|
-
output.links = json.data.links.map((link) => link.url);
|
|
91
|
-
break;
|
|
92
|
-
case 'person':
|
|
93
|
-
output.birth = json.data.birth;
|
|
94
|
-
output.death = json.data.death;
|
|
95
|
-
output.note = json.data.note_bio;
|
|
96
|
-
output.links = [`https://${json.wikipediaURL}`];
|
|
97
|
-
break;
|
|
98
|
-
default:
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
return output;
|
|
102
|
-
})
|
|
103
|
-
.catch((reason) => Promise.reject(reason));
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
getLabelField() {
|
|
107
|
-
let label;
|
|
108
|
-
switch (this._register) {
|
|
85
|
+
.then(response => response.json())
|
|
86
|
+
.then(json => {
|
|
87
|
+
const output = { ...json };
|
|
88
|
+
output.name = json.data[this.getLabelField()];
|
|
89
|
+
switch (this._register) {
|
|
109
90
|
case 'place':
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
label = 'asHtml';
|
|
121
|
-
break;
|
|
91
|
+
output.country = json.data.country;
|
|
92
|
+
output.location = json.data.location.coordinates;
|
|
93
|
+
output.links = json.data.links.map(link => link.url);
|
|
94
|
+
break;
|
|
95
|
+
case 'person':
|
|
96
|
+
output.birth = json.data.birth;
|
|
97
|
+
output.death = json.data.death;
|
|
98
|
+
output.note = json.data.note_bio;
|
|
99
|
+
output.links = [`https://${json.wikipediaURL}`];
|
|
100
|
+
break;
|
|
122
101
|
default:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
return output;
|
|
105
|
+
})
|
|
106
|
+
.catch(reason => Promise.reject(reason));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
getLabelField() {
|
|
110
|
+
let label;
|
|
111
|
+
switch (this._register) {
|
|
112
|
+
case 'place':
|
|
113
|
+
label = 'placeName_full';
|
|
114
|
+
break;
|
|
115
|
+
case 'term':
|
|
116
|
+
label = 'fullLabel';
|
|
117
|
+
break;
|
|
118
|
+
case 'abbreviation':
|
|
119
|
+
label = 'label';
|
|
120
|
+
break;
|
|
121
|
+
case 'bibl':
|
|
122
|
+
case 'songs':
|
|
123
|
+
label = 'asHtml';
|
|
124
|
+
break;
|
|
125
|
+
default:
|
|
126
|
+
label = 'persName_full';
|
|
127
|
+
break;
|
|
127
128
|
}
|
|
129
|
+
return label;
|
|
130
|
+
}
|
|
128
131
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
let register;
|
|
134
|
-
switch(this._register) {
|
|
135
|
-
case 'person':
|
|
136
|
-
case 'organization':
|
|
137
|
-
register = 'actors';
|
|
138
|
-
break;
|
|
139
|
-
case 'place':
|
|
140
|
-
register = 'places';
|
|
141
|
-
break;
|
|
142
|
-
case 'term':
|
|
143
|
-
register = 'terms';
|
|
144
|
-
break;
|
|
145
|
-
case 'abbreviation':
|
|
146
|
-
register = 'abbreviations';
|
|
147
|
-
break;
|
|
148
|
-
case 'bibl':
|
|
149
|
-
register = 'bibls';
|
|
150
|
-
break;
|
|
151
|
-
default:
|
|
152
|
-
register = this._register;
|
|
153
|
-
}
|
|
154
|
-
return register;
|
|
132
|
+
getRegister() {
|
|
133
|
+
if (this._api) {
|
|
134
|
+
return this._api;
|
|
155
135
|
}
|
|
156
|
-
|
|
136
|
+
let register;
|
|
137
|
+
switch (this._register) {
|
|
138
|
+
case 'person':
|
|
139
|
+
case 'organization':
|
|
140
|
+
register = 'actors';
|
|
141
|
+
break;
|
|
142
|
+
case 'place':
|
|
143
|
+
register = 'places';
|
|
144
|
+
break;
|
|
145
|
+
case 'term':
|
|
146
|
+
register = 'terms';
|
|
147
|
+
break;
|
|
148
|
+
case 'abbreviation':
|
|
149
|
+
register = 'abbreviations';
|
|
150
|
+
break;
|
|
151
|
+
case 'bibl':
|
|
152
|
+
register = 'bibls';
|
|
153
|
+
break;
|
|
154
|
+
default:
|
|
155
|
+
register = this._register;
|
|
156
|
+
}
|
|
157
|
+
return register;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -2,42 +2,40 @@
|
|
|
2
2
|
import { Registry } from './registry.js';
|
|
3
3
|
|
|
4
4
|
export class Metagrid extends Registry {
|
|
5
|
-
|
|
6
5
|
async query(key) {
|
|
7
6
|
const query = key.replace(/[^\w\s]+/g, '');
|
|
8
7
|
const results = [];
|
|
9
8
|
const url = `https://api.metagrid.ch/search?query=${encodeURIComponent(query)}`;
|
|
10
|
-
|
|
11
|
-
return new Promise(
|
|
12
|
-
|
|
13
|
-
.then(
|
|
14
|
-
.then(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
9
|
+
|
|
10
|
+
return new Promise(resolve => {
|
|
11
|
+
fetch(url)
|
|
12
|
+
.then(response => response.json())
|
|
13
|
+
.then(json => {
|
|
14
|
+
json.resources.forEach(item => {
|
|
15
|
+
const name = `${item.metadata.last_name}, ${item.metadata.first_name} `;
|
|
16
|
+
const result = {
|
|
17
|
+
register: this._register,
|
|
18
|
+
id: `${item.provider.slug}-${item.identifier}`,
|
|
19
|
+
label: name,
|
|
20
|
+
details: `${item.metadata.birth_date} - ${item.metadata.death_date}`,
|
|
21
|
+
link: item.link.uri,
|
|
22
|
+
provider: item.provider.slug,
|
|
23
|
+
};
|
|
24
|
+
results.push(result);
|
|
25
|
+
});
|
|
26
|
+
resolve({
|
|
27
|
+
totalItems: json.meta.total,
|
|
28
|
+
items: results,
|
|
29
|
+
});
|
|
31
30
|
});
|
|
32
|
-
})
|
|
31
|
+
});
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
info(key, container) {
|
|
36
35
|
const p = key.indexOf('-');
|
|
37
36
|
const slug = key.substring(0, p);
|
|
38
|
-
return new Promise(
|
|
39
|
-
this.getRecord(key)
|
|
40
|
-
.then(json => {
|
|
37
|
+
return new Promise(resolve => {
|
|
38
|
+
this.getRecord(key).then(json => {
|
|
41
39
|
const output = `
|
|
42
40
|
<h3 class="label">
|
|
43
41
|
<a href="https://${json.link.uri}" target="_blank">
|
|
@@ -49,37 +47,37 @@ export class Metagrid extends Registry {
|
|
|
49
47
|
container.innerHTML = output;
|
|
50
48
|
resolve({
|
|
51
49
|
id: `${slug}-${json.identifier}`,
|
|
52
|
-
strings: [`${json.metadata.first_name} ${json.metadata.last_name}`]
|
|
53
|
-
})
|
|
50
|
+
strings: [`${json.metadata.first_name} ${json.metadata.last_name}`],
|
|
51
|
+
});
|
|
54
52
|
});
|
|
55
53
|
});
|
|
56
54
|
}
|
|
57
55
|
|
|
58
56
|
/**
|
|
59
57
|
* Retrieve a raw JSON record for the given key as returned by the endpoint.
|
|
60
|
-
*
|
|
58
|
+
*
|
|
61
59
|
* @param {string} key the key to look up
|
|
62
60
|
* @returns {Promise<any>} promise resolving to the JSON record returned by the endpoint
|
|
63
61
|
*/
|
|
64
|
-
|
|
62
|
+
async getRecord(key) {
|
|
65
63
|
const p = key.indexOf('-');
|
|
66
64
|
const slug = key.substring(0, p);
|
|
67
65
|
const id = key.substring(p + 1);
|
|
68
66
|
return fetch(`https://api.metagrid.ch/search?slug=${slug}&query=${id}`)
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
67
|
+
.then(response => response.json())
|
|
68
|
+
.then(json => {
|
|
69
|
+
const item = json.resources[0];
|
|
70
|
+
const output = { ...item };
|
|
71
|
+
output.name = `${item.metadata.first_name} ${item.metadata.last_name}`;
|
|
72
|
+
output.links = [`https://${item.link.uri}`];
|
|
73
|
+
if (item.metadata.birth_date && item.metadata.birth_date.length > 0) {
|
|
74
|
+
output.birth = item.metadata.birth_date;
|
|
75
|
+
}
|
|
76
|
+
if (item.metadata.death_date && item.metadata.death_date.length > 0) {
|
|
77
|
+
output.death = item.metadata.death_date;
|
|
78
|
+
}
|
|
79
|
+
return output;
|
|
80
|
+
})
|
|
81
|
+
.catch(reason => Promise.reject(reason));
|
|
82
|
+
}
|
|
85
83
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable class-methods-use-this */
|
|
2
|
-
import { Registry } from './registry.js'
|
|
2
|
+
import { Registry } from './registry.js';
|
|
3
3
|
|
|
4
4
|
// Todo:
|
|
5
5
|
// - strings <- types
|
|
@@ -7,26 +7,28 @@ import { Registry } from './registry.js'
|
|
|
7
7
|
// - test with other providers, inside custom connector
|
|
8
8
|
// - documentation
|
|
9
9
|
|
|
10
|
-
async function getServiceManifest
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
async function getServiceManifest(endpoint) {
|
|
11
|
+
const response = await fetch(endpoint);
|
|
12
|
+
const data = await response.json();
|
|
13
13
|
return data;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export class ReconciliationService extends Registry {
|
|
17
17
|
constructor(configElem) {
|
|
18
|
-
super(configElem)
|
|
18
|
+
super(configElem);
|
|
19
19
|
this.endpoint = configElem.getAttribute('endpoint');
|
|
20
20
|
this.debug = configElem.getAttribute('debug');
|
|
21
|
-
getServiceManifest(this.endpoint).then(
|
|
21
|
+
getServiceManifest(this.endpoint).then(result => {
|
|
22
22
|
this.ORConfig = result;
|
|
23
23
|
if (this.debug) {
|
|
24
24
|
console.log(
|
|
25
|
-
|
|
26
|
-
this._register,
|
|
25
|
+
"OpenReconcile connector for register '%s' at endpoint <%s>. Using config: %o",
|
|
26
|
+
this._register,
|
|
27
|
+
this.endpoint,
|
|
28
|
+
this.ORConfig,
|
|
27
29
|
);
|
|
28
30
|
}
|
|
29
|
-
})
|
|
31
|
+
});
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
/**
|
|
@@ -37,57 +39,54 @@ export class ReconciliationService extends Registry {
|
|
|
37
39
|
async query(key) {
|
|
38
40
|
const results = [];
|
|
39
41
|
const paramsObj = {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
q1: {
|
|
43
|
+
query: key,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
44
46
|
|
|
45
|
-
return new Promise(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
.then(
|
|
55
|
-
.then(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
if (item.description) {
|
|
63
|
-
this.description = item.description;
|
|
64
|
-
} else if (item.type) {
|
|
65
|
-
this.description = item.type.map(t => t.name.toString() ).join(', ')
|
|
66
|
-
} else {
|
|
67
|
-
this.description = ""
|
|
68
|
-
}
|
|
69
|
-
const result = {
|
|
70
|
-
register: this._register,
|
|
71
|
-
id: (this._prefix ? `${this._prefix}-${item.id}` : item.id),
|
|
72
|
-
label: item.name,
|
|
73
|
-
link: this.view,
|
|
74
|
-
details: this.description,
|
|
75
|
-
provider: 'OpenReconcile'
|
|
76
|
-
};
|
|
77
|
-
results.push(result);
|
|
78
|
-
});
|
|
79
|
-
if (this.debug) {
|
|
80
|
-
console.log(
|
|
81
|
-
'OpenReconcile results: %o',
|
|
82
|
-
results
|
|
83
|
-
);
|
|
47
|
+
return new Promise(resolve => {
|
|
48
|
+
fetch(this.endpoint, {
|
|
49
|
+
method: 'POST',
|
|
50
|
+
headers: {
|
|
51
|
+
Accept: 'application/json',
|
|
52
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
53
|
+
},
|
|
54
|
+
body: 'queries='.concat(JSON.stringify(paramsObj)),
|
|
55
|
+
})
|
|
56
|
+
.then(response => response.json())
|
|
57
|
+
.then(json => {
|
|
58
|
+
json.q1.result.forEach(item => {
|
|
59
|
+
if (this.ORConfig.view) {
|
|
60
|
+
this.view = this.ORConfig.view.url.replace('{{id}}', item.id);
|
|
61
|
+
} else {
|
|
62
|
+
this.view = item.id;
|
|
84
63
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
64
|
+
if (item.description) {
|
|
65
|
+
this.description = item.description;
|
|
66
|
+
} else if (item.type) {
|
|
67
|
+
this.description = item.type.map(t => t.name.toString()).join(', ');
|
|
68
|
+
} else {
|
|
69
|
+
this.description = '';
|
|
70
|
+
}
|
|
71
|
+
const result = {
|
|
72
|
+
register: this._register,
|
|
73
|
+
id: this._prefix ? `${this._prefix}-${item.id}` : item.id,
|
|
74
|
+
label: item.name,
|
|
75
|
+
link: this.view,
|
|
76
|
+
details: this.description,
|
|
77
|
+
provider: 'OpenReconcile',
|
|
78
|
+
};
|
|
79
|
+
results.push(result);
|
|
80
|
+
});
|
|
81
|
+
if (this.debug) {
|
|
82
|
+
console.log('OpenReconcile results: %o', results);
|
|
83
|
+
}
|
|
84
|
+
resolve({
|
|
85
|
+
totalItems: json.q1.result.length,
|
|
86
|
+
items: results,
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
});
|
|
91
90
|
}
|
|
92
91
|
|
|
93
92
|
/**
|
|
@@ -103,7 +102,7 @@ export class ReconciliationService extends Registry {
|
|
|
103
102
|
return Promise.resolve({});
|
|
104
103
|
}
|
|
105
104
|
if (!this.ORConfig.preview) {
|
|
106
|
-
container.innerHTML =
|
|
105
|
+
container.innerHTML = "no 'preview' information in endpoint's manifest";
|
|
107
106
|
return Promise.resolve();
|
|
108
107
|
}
|
|
109
108
|
|
|
@@ -111,14 +110,14 @@ export class ReconciliationService extends Registry {
|
|
|
111
110
|
const rawid = this._prefix ? id.substring(this._prefix.length + 1) : id;
|
|
112
111
|
const url = this.ORConfig.preview.url.replace('{{id}}', encodeURIComponent(rawid));
|
|
113
112
|
fetch(url)
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
113
|
+
.then(response => response.text())
|
|
114
|
+
.then(output => {
|
|
115
|
+
container.innerHTML = output;
|
|
116
|
+
resolve({
|
|
117
|
+
id: this._prefix ? `${this._prefix}-${rawid}` : rawid,
|
|
118
|
+
});
|
|
119
|
+
})
|
|
120
|
+
.catch(() => reject());
|
|
122
121
|
});
|
|
123
122
|
}
|
|
124
123
|
}
|
|
@@ -29,11 +29,11 @@ export class Registry {
|
|
|
29
29
|
set name(name) {
|
|
30
30
|
this._register = name;
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
get editable() {
|
|
34
34
|
return false;
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
/**
|
|
38
38
|
* Query the authority and return a RegistryResult.
|
|
39
39
|
*
|
|
@@ -69,11 +69,11 @@ export class Registry {
|
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
71
|
* Retrieve a raw JSON record for the given key as returned by the endpoint.
|
|
72
|
-
*
|
|
72
|
+
*
|
|
73
73
|
* @param {string} key the key to look up
|
|
74
74
|
* @returns {Promise<any>} promise resolving to the JSON record returned by the endpoint
|
|
75
75
|
*/
|
|
76
76
|
async getRecord(key) {
|
|
77
|
-
|
|
77
|
+
return Promise.reject();
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -8,7 +8,7 @@ import { PbComponentView } from './pb-component-view.js';
|
|
|
8
8
|
/**
|
|
9
9
|
* An API viewer for webcomponents based on the JSON format produced
|
|
10
10
|
* by web-component-analyzer.
|
|
11
|
-
*
|
|
11
|
+
*
|
|
12
12
|
* @slot logo - HTML to show as logo on top of the drawer
|
|
13
13
|
* @listens pb-api-component if another webcomponent should be shown
|
|
14
14
|
*/
|
|
@@ -171,4 +171,4 @@ export class PbComponentDocs extends LitElement {
|
|
|
171
171
|
`;
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
-
customElements.define('pb-component-docs', PbComponentDocs);
|
|
174
|
+
customElements.define('pb-component-docs', PbComponentDocs);
|