@teipublisher/pb-components 2.26.1-next.2 → 3.0.0-next-4.1
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/docker-cypress.yml +54 -0
- package/.github/workflows/main.yml +6 -4
- package/.github/workflows/node.js.yml +56 -21
- package/.github/workflows/release.js.yml +19 -17
- package/.releaserc.json +1 -1
- package/CHANGELOG.md +351 -9
- package/Dockerfile +78 -70
- package/README.md +112 -4
- package/css/components.css +5 -5
- package/css/gridjs/mermaid.min.css +1 -1
- package/css/leaflet/Control.Geocoder.css +1 -126
- package/css/leaflet/images/layers.png +0 -0
- package/css/tify/tify.css +6 -5
- package/css/tom-select/tom-select.bootstrap4.min.css +1 -1
- package/css/tom-select/tom-select.bootstrap5.min.css +1 -1
- package/css/tom-select/tom-select.default.min.css +1 -1
- package/css/tom-select/tom-select.default.min.css.map +1 -0
- package/css/tom-select/tom-select.min.css +1 -1
- package/cypress.config.js +84 -0
- package/dist/api.html +1 -1
- package/dist/css/design-system.css +607 -0
- package/dist/demo/bundle-test.html +4 -3
- package/dist/demo/components.css +46 -1
- package/dist/demo/design-system.html +710 -0
- package/dist/demo/dts-client.html +2 -2
- package/dist/demo/pb-autocomplete.html +23 -11
- package/dist/demo/pb-autocomplete2.html +66 -55
- package/dist/demo/pb-autocomplete3.html +17 -8
- package/dist/demo/pb-blacklab-highlight.html +28 -11
- package/dist/demo/pb-blacklab-results.html +3 -2
- package/dist/demo/pb-browse-docs.html +24 -24
- package/dist/demo/pb-browse-docs2.html +3 -3
- package/dist/demo/pb-clipboard.html +32 -28
- package/dist/demo/pb-code-editor.html +6 -6
- package/dist/demo/pb-code-highlight.html +63 -63
- package/dist/demo/pb-codepen.html +1 -1
- package/dist/demo/pb-collapse.html +1 -1
- package/dist/demo/pb-collapse2.html +2 -2
- package/dist/demo/pb-combo-box.html +135 -130
- package/dist/demo/pb-custom-form.html +64 -55
- package/dist/demo/pb-dialog.html +12 -6
- package/dist/demo/pb-document.html +1 -1
- package/dist/demo/pb-download.html +68 -59
- package/dist/demo/pb-drawer.html +67 -46
- package/dist/demo/pb-drawer2.html +65 -58
- package/dist/demo/pb-edit-app.html +2 -2
- package/dist/demo/pb-edit-xml.html +1 -1
- package/dist/demo/pb-facsimile-2.html +26 -11
- package/dist/demo/pb-facsimile-3.html +25 -10
- package/dist/demo/pb-facsimile-dedup-test-2.html +48 -0
- package/dist/demo/pb-facsimile-dedup-test.html +48 -0
- package/dist/demo/pb-facsimile.html +4 -4
- package/dist/demo/pb-formula.html +1 -1
- package/dist/demo/pb-grid.html +22 -8
- package/dist/demo/pb-highlight.html +2 -2
- package/dist/demo/pb-i18n-simple.html +1 -0
- package/dist/demo/pb-i18n.html +15 -5
- package/dist/demo/pb-image-strip-standalone.html +2 -2
- package/dist/demo/pb-image-strip-view.html +2 -2
- package/dist/demo/pb-leaflet-map.html +3 -3
- package/dist/demo/pb-leaflet-map2.html +2 -2
- package/dist/demo/pb-leaflet-map3.html +3 -3
- package/dist/demo/pb-link.html +1 -1
- package/dist/demo/pb-load.html +2 -6
- package/dist/demo/pb-login.html +1 -3
- package/dist/demo/pb-manage-odds.html +9 -4
- package/dist/demo/pb-markdown.html +1 -1
- package/dist/demo/pb-media-query.html +2 -2
- package/dist/demo/pb-mei.html +2 -2
- package/dist/demo/pb-mei2.html +2 -2
- package/dist/demo/pb-message.html +2 -3
- package/dist/demo/pb-odd-editor.html +54 -52
- package/dist/demo/pb-page-header.html +27 -0
- package/dist/demo/pb-popover.html +1 -1
- package/dist/demo/pb-print-preview.html +2 -2
- package/dist/demo/pb-progress.html +4 -4
- package/dist/demo/pb-repeat.html +32 -36
- package/dist/demo/pb-search.html +16 -5
- package/dist/demo/pb-search2.html +4 -4
- package/dist/demo/pb-search3.html +3 -3
- package/dist/demo/pb-search4.html +3 -3
- package/dist/demo/pb-select-feature.html +4 -4
- package/dist/demo/pb-select-feature2.html +4 -4
- package/dist/demo/pb-select-feature3.html +2 -2
- package/dist/demo/pb-select-i18n.html +58 -53
- package/dist/demo/pb-select-odd.html +1 -1
- package/dist/demo/pb-select.html +190 -75
- package/dist/demo/pb-select2.html +91 -37
- package/dist/demo/pb-select3.html +109 -41
- package/dist/demo/pb-svg.html +1 -1
- package/dist/demo/pb-table-grid.html +26 -15
- package/dist/demo/pb-tabs.html +15 -7
- package/dist/demo/pb-tify.html +7 -7
- package/dist/demo/pb-timeline.html +1 -1
- package/dist/demo/pb-timeline2.html +1 -1
- package/dist/demo/pb-toggle-feature.html +26 -23
- package/dist/demo/pb-toggle-feature2.html +4 -4
- package/dist/demo/pb-toggle-feature3.html +2 -2
- package/dist/demo/pb-toggle-feature4.html +56 -54
- package/dist/demo/pb-version.html +2 -2
- package/dist/demo/pb-view.html +78 -40
- package/dist/demo/pb-view2.html +69 -46
- package/dist/demo/pb-view3.html +53 -48
- package/dist/demo/pb-view4.html +70 -49
- package/dist/demo/pb-zoom.html +2 -2
- package/dist/{es-global-bridge-d8ce175d.js → es-global-bridge-D8ZcUcx_.js} +0 -4
- package/dist/focus-mixin-VCsFap6b.js +768 -0
- package/dist/images/icons.svg +217 -0
- package/dist/jinn-codemirror-DETLdm08.js +1 -0
- package/dist/lib/openseadragon.min.js +80 -0
- package/dist/lib/openseadragon.min.js.map +1 -0
- package/dist/pb-code-editor.js +25 -20
- package/dist/pb-component-docs.js +414 -3225
- package/dist/pb-components-bundle.js +3046 -4402
- package/dist/pb-dialog-tklYGWfc.js +121 -0
- package/dist/pb-edit-app.js +208 -107
- package/dist/pb-elements.json +716 -249
- package/dist/pb-facsimile.js +46 -0
- package/dist/pb-i18n-C0NDma4h.js +1 -0
- package/dist/pb-leaflet-map.js +23 -23
- package/dist/pb-mei.js +152 -134
- package/dist/pb-mixin-DHoWQheB.js +1 -0
- package/dist/pb-odd-editor.js +1671 -1231
- package/dist/pb-tify.js +1 -27
- package/dist/unsafe-html-D5VGo9Oq.js +1 -0
- package/dist/urls-BEONu_g4.js +1 -0
- package/eslint.config.mjs +92 -0
- package/gh-pages.js +5 -3
- package/i18n/common/en.json +6 -0
- package/i18n/common/pl.json +2 -2
- package/images/icons.svg +217 -0
- package/index.html +0 -5
- package/lib/leaflet-src.js.map +1 -0
- package/lib/leaflet.markercluster-src.js.map +1 -0
- package/lib/openseadragon.min.js +6 -6
- package/package.json +56 -81
- package/pb-elements.json +716 -249
- package/rollup.config.mjs +312 -0
- package/src/assets/components.css +5 -5
- package/src/assets/design-system.css +607 -0
- package/src/authority/airtable.js +20 -21
- package/src/authority/anton.js +129 -129
- package/src/authority/custom.js +70 -27
- package/src/authority/geonames.js +38 -32
- package/src/authority/gnd.js +50 -42
- package/src/authority/kbga.js +136 -134
- package/src/authority/metagrid.js +44 -46
- package/src/authority/reconciliation.js +66 -68
- package/src/authority/registry.js +4 -4
- package/src/docs/demo-utils.js +91 -0
- package/src/docs/pb-component-docs.js +287 -147
- package/src/docs/pb-component-view.js +380 -273
- package/src/docs/pb-components-list.js +115 -51
- package/src/docs/pb-demo-snippet.js +199 -174
- package/src/dts-client.js +306 -303
- package/src/dts-select-endpoint.js +125 -85
- package/src/parse-date-service.js +184 -135
- package/src/pb-ajax.js +175 -173
- package/src/pb-authority-lookup.js +198 -158
- package/src/pb-autocomplete.js +731 -313
- package/src/pb-blacklab-highlight.js +266 -260
- package/src/pb-blacklab-results.js +230 -225
- package/src/pb-browse-docs.js +601 -484
- package/src/pb-browse.js +68 -65
- package/src/pb-clipboard.js +97 -76
- package/src/pb-code-editor.js +111 -103
- package/src/pb-code-highlight.js +234 -204
- package/src/pb-codepen.js +81 -73
- package/src/pb-collapse.js +265 -152
- package/src/pb-combo-box.js +191 -191
- package/src/pb-components-bundle.js +1 -7
- package/src/pb-components.js +2 -6
- package/src/pb-custom-form.js +230 -141
- package/src/pb-dialog.js +99 -63
- package/src/pb-document.js +118 -91
- package/src/pb-download.js +214 -198
- package/src/pb-drawer.js +146 -149
- package/src/pb-edit-app.js +471 -240
- package/src/pb-edit-xml.js +101 -98
- package/src/pb-events.js +126 -107
- package/src/pb-facs-link.js +130 -101
- package/src/pb-facsimile.js +494 -410
- package/src/pb-fetch.js +389 -0
- package/src/pb-formula.js +152 -154
- package/src/pb-geolocation.js +130 -132
- package/src/pb-grid-action.js +59 -56
- package/src/pb-grid.js +388 -228
- package/src/pb-highlight.js +142 -142
- package/src/pb-hotkeys.js +40 -42
- package/src/pb-i18n.js +115 -127
- package/src/pb-icon-button.js +108 -0
- package/src/pb-icon.js +283 -0
- package/src/pb-image-strip.js +85 -79
- package/src/pb-lang.js +142 -57
- package/src/pb-leaflet-map.js +551 -483
- package/src/pb-link.js +132 -126
- package/src/pb-load.js +495 -428
- package/src/pb-login.js +303 -248
- package/src/pb-manage-odds.js +384 -338
- package/src/pb-map-icon.js +90 -90
- package/src/pb-map-layer.js +86 -86
- package/src/pb-markdown.js +107 -110
- package/src/pb-media-query.js +75 -73
- package/src/pb-mei.js +523 -303
- package/src/pb-message.js +144 -98
- package/src/pb-mixin.js +268 -265
- package/src/pb-navigation.js +83 -96
- package/src/pb-observable.js +39 -39
- package/src/pb-odd-editor.js +1209 -948
- package/src/pb-odd-elementspec-editor.js +375 -310
- package/src/pb-odd-model-editor.js +1189 -941
- package/src/pb-odd-parameter-editor.js +269 -170
- package/src/pb-odd-rendition-editor.js +184 -131
- package/src/pb-page.js +451 -422
- package/src/pb-paginate.js +260 -178
- package/src/pb-panel.js +217 -183
- package/src/pb-popover-themes.js +16 -9
- package/src/pb-popover.js +297 -288
- package/src/pb-print-preview.js +128 -128
- package/src/pb-progress.js +52 -52
- package/src/pb-repeat.js +141 -108
- package/src/pb-restricted.js +85 -78
- package/src/pb-search.js +258 -230
- package/src/pb-select-feature.js +210 -126
- package/src/pb-select-odd.js +184 -118
- package/src/pb-select-template.js +113 -78
- package/src/pb-select.js +330 -229
- package/src/pb-split-list.js +181 -176
- package/src/pb-svg.js +81 -80
- package/src/pb-table-column.js +55 -55
- package/src/pb-table-grid.js +334 -205
- package/src/pb-tabs.js +238 -61
- package/src/pb-tify.js +3331 -126
- package/src/pb-timeline.js +394 -255
- package/src/pb-toggle-feature.js +196 -188
- package/src/pb-upload.js +201 -176
- package/src/pb-version.js +22 -34
- package/src/pb-view-annotate.js +138 -102
- package/src/pb-view.js +1722 -1272
- package/src/pb-zoom.js +144 -46
- package/src/search-result-service.js +256 -223
- package/src/seed-element.js +14 -22
- package/src/settings.js +4 -4
- package/src/theming.js +98 -91
- package/src/urls.js +403 -289
- package/src/utils.js +53 -51
- package/vite.config.js +86 -0
- package/css/pb-styles.css +0 -51
- package/dist/iron-form-3b8dcaa7.js +0 -210
- package/dist/jinn-codemirror-da0e2d1f.js +0 -1
- package/dist/paper-checkbox-515a5284.js +0 -1597
- package/dist/paper-icon-button-b1d31571.js +0 -398
- package/dist/paper-listbox-a3b7175c.js +0 -1265
- package/dist/pb-i18n-0611135a.js +0 -1
- package/dist/pb-mixin-b1caa22e.js +0 -158
- package/dist/polymer-hack.js +0 -1
- package/dist/vaadin-element-mixin-6e4cee3a.js +0 -527
- package/lib/Control.Geocoder.min.js +0 -2
- package/lib/Control.Geocoder.min.js.map +0 -1
- package/src/assets/pb-styles.css +0 -51
- package/src/pb-light-dom.js +0 -40
- package/src/polymer-hack.js +0 -6
package/src/dts-client.js
CHANGED
|
@@ -1,361 +1,364 @@
|
|
|
1
|
-
import { LitElement, html, css } from 'lit
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
2
|
import { pbMixin } from './pb-mixin.js';
|
|
3
3
|
import { translate } from './pb-i18n.js';
|
|
4
4
|
import { registry } from './urls.js';
|
|
5
|
-
|
|
6
|
-
import '
|
|
7
|
-
import '@polymer/iron-icon';
|
|
8
|
-
import '@polymer/iron-icons';
|
|
9
|
-
import '@polymer/paper-button';
|
|
5
|
+
import './pb-icon.js';
|
|
6
|
+
import './pb-fetch.js';
|
|
10
7
|
|
|
11
8
|
/**
|
|
12
9
|
* A client for the Distributed Text Services (DTS) protocol. This defines an API
|
|
13
10
|
* for working with collections of text.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
11
|
+
*
|
|
12
|
+
*
|
|
16
13
|
* @slot toolbar - toolbar area
|
|
17
14
|
* @slot pagination - pagination area
|
|
18
|
-
*
|
|
15
|
+
*
|
|
19
16
|
* @csspart parent-link - Link to parent collection
|
|
20
17
|
* @csspart collection-title - Collection title
|
|
21
18
|
* @csspart title - Member title
|
|
22
19
|
* @csspart author - Author
|
|
23
20
|
* @csspart license - License information
|
|
24
21
|
* @csspart link - Links
|
|
25
|
-
*
|
|
22
|
+
*
|
|
26
23
|
* @fires pb-start-update - Fired before the element updates its content
|
|
27
24
|
* @fires pb-results-received - Fired when results are received from the server
|
|
28
25
|
* @fires pb-end-update - Fired after the element has finished updating its content
|
|
29
26
|
* @fires dts-endpoint - When received sets the endpoint to the one passed in from the event
|
|
30
|
-
* @fires pb-load - When received triggers the refresh accorting to the selected page
|
|
27
|
+
* @fires pb-load - When received triggers the refresh accorting to the selected page
|
|
31
28
|
*/
|
|
32
29
|
export class DtsClient extends pbMixin(LitElement) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
30
|
+
static get properties() {
|
|
31
|
+
return {
|
|
32
|
+
...super.properties,
|
|
33
|
+
baseUri: {
|
|
34
|
+
type: String,
|
|
35
|
+
},
|
|
36
|
+
data: {
|
|
37
|
+
type: Object,
|
|
38
|
+
},
|
|
39
|
+
collection: {
|
|
40
|
+
type: String,
|
|
41
|
+
},
|
|
42
|
+
page: {
|
|
43
|
+
type: Number,
|
|
44
|
+
},
|
|
45
|
+
perPage: {
|
|
46
|
+
type: Number,
|
|
47
|
+
},
|
|
48
|
+
_collectionEndpoint: {
|
|
49
|
+
type: String,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
56
53
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
constructor() {
|
|
55
|
+
super();
|
|
56
|
+
this._parentCollections = [];
|
|
57
|
+
this.collection = 'default';
|
|
58
|
+
}
|
|
62
59
|
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
connectedCallback() {
|
|
61
|
+
super.connectedCallback();
|
|
65
62
|
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
this.collection = registry.state.id;
|
|
64
|
+
this.page = registry.state.page;
|
|
68
65
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
66
|
+
this.subscribeTo('dts-endpoint', ev => {
|
|
67
|
+
this._setEndpoint(ev.detail.endpoint, ev.detail.collection, ev.detail.reload);
|
|
68
|
+
});
|
|
69
|
+
this.subscribeTo('pb-load', ev => {
|
|
70
|
+
this.page = ev.detail.params.page;
|
|
71
|
+
console.log('<dts-client> Loading page %d', this.page);
|
|
72
|
+
this._update();
|
|
73
|
+
});
|
|
74
|
+
}
|
|
78
75
|
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
firstUpdated() {
|
|
77
|
+
super.firstUpdated();
|
|
81
78
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
this.queryAPI = this.shadowRoot.getElementById('queryAPI');
|
|
80
|
+
this.documentsAPI = this.shadowRoot.getElementById('documentsAPI');
|
|
81
|
+
this.signalReady();
|
|
82
|
+
}
|
|
86
83
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
this.collection = collection;
|
|
92
|
-
this._configureEndpoint(endpoint);
|
|
93
|
-
this.baseUri = endpoint;
|
|
84
|
+
_setEndpoint(endpoint, collection, reload) {
|
|
85
|
+
if (!reload) {
|
|
86
|
+
this.page = null;
|
|
94
87
|
}
|
|
88
|
+
this.collection = collection;
|
|
89
|
+
this._configureEndpoint(endpoint);
|
|
90
|
+
this.baseUri = endpoint;
|
|
91
|
+
}
|
|
95
92
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
93
|
+
_configureEndpoint(newBaseUri) {
|
|
94
|
+
if (newBaseUri) {
|
|
95
|
+
console.log('<dts-client> initializing connection to endpoint %s', newBaseUri);
|
|
96
|
+
this.emitTo('pb-start-update');
|
|
97
|
+
this.queryAPI.url = newBaseUri;
|
|
98
|
+
this.queryAPI.generateRequest();
|
|
103
99
|
}
|
|
100
|
+
}
|
|
104
101
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
this.collection = member && typeof member === 'object' ? member['@id'] : member;
|
|
111
|
-
this.page = null;
|
|
112
|
-
console.log('<dts-client> navigating to collection %s', this.collection);
|
|
113
|
-
this._update();
|
|
102
|
+
_navigate(ev, member, downwards = true) {
|
|
103
|
+
ev.preventDefault();
|
|
104
|
+
if (downwards) {
|
|
105
|
+
this._parentCollections.push(this.collection);
|
|
114
106
|
}
|
|
107
|
+
this.collection = member && typeof member === 'object' ? member['@id'] : member;
|
|
108
|
+
this.page = null;
|
|
109
|
+
console.log('<dts-client> navigating to collection %s', this.collection);
|
|
110
|
+
this._update();
|
|
111
|
+
}
|
|
115
112
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
this._navigate(ev, this._parentCollections.pop(), false);
|
|
113
|
+
_navigateUp(ev) {
|
|
114
|
+
if (this._parentCollections.length === 0) {
|
|
115
|
+
return;
|
|
121
116
|
}
|
|
117
|
+
this._navigate(ev, this._parentCollections.pop(), false);
|
|
118
|
+
}
|
|
122
119
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
this.documentsAPI.generateRequest();
|
|
120
|
+
_preview(ev, member) {
|
|
121
|
+
ev.preventDefault();
|
|
122
|
+
this.emitTo('pb-start-update');
|
|
123
|
+
const path = member['dts:passage'] || member['dts:download'];
|
|
124
|
+
const url = new URL(path, this.baseUri).toString();
|
|
125
|
+
console.log('<dts-client> downloading %s', url);
|
|
126
|
+
if (this.lessThanApiVersion('1.0.0')) {
|
|
127
|
+
this.documentsAPI.url = `${this.getEndpoint()}/modules/lib/dts.xql`;
|
|
128
|
+
this.documentsAPI.params = {
|
|
129
|
+
preview: url,
|
|
130
|
+
id: member['@id'],
|
|
131
|
+
};
|
|
132
|
+
} else {
|
|
133
|
+
this.documentsAPI.url = `${this.getEndpoint()}/api/dts/import`;
|
|
134
|
+
this.documentsAPI.params = {
|
|
135
|
+
uri: url,
|
|
136
|
+
temp: true,
|
|
137
|
+
};
|
|
143
138
|
}
|
|
139
|
+
this.documentsAPI.generateRequest();
|
|
140
|
+
}
|
|
144
141
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
this.documentsAPI.generateRequest();
|
|
142
|
+
_download(ev, member) {
|
|
143
|
+
this.emitTo('pb-start-update');
|
|
144
|
+
const path = member['dts:passage'] || member['dts:download'];
|
|
145
|
+
const url = new URL(path, this.baseUri).toString();
|
|
146
|
+
console.log('<dts-client> importing %s', url);
|
|
147
|
+
if (this.lessThanApiVersion('1.0.0')) {
|
|
148
|
+
this.documentsAPI.url = `${this.getEndpoint()}/modules/lib/dts.xql`;
|
|
149
|
+
this.documentsAPI.params = {
|
|
150
|
+
import: url,
|
|
151
|
+
id: member['@id'],
|
|
152
|
+
};
|
|
153
|
+
} else {
|
|
154
|
+
this.documentsAPI.url = `${this.getEndpoint()}/api/dts/import`;
|
|
155
|
+
this.documentsAPI.params = {
|
|
156
|
+
uri: url,
|
|
157
|
+
temp: false,
|
|
158
|
+
};
|
|
164
159
|
}
|
|
160
|
+
this.documentsAPI.generateRequest();
|
|
161
|
+
}
|
|
165
162
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
if (this.page) {
|
|
173
|
-
newState.page = this.page + 1;
|
|
174
|
-
}
|
|
175
|
-
registry.commit(this, newState);
|
|
176
|
-
|
|
177
|
-
this.queryAPI.params = newState;
|
|
178
|
-
this.queryAPI.url = this._collectionEndpoint;
|
|
179
|
-
this.queryAPI.generateRequest();
|
|
163
|
+
_update() {
|
|
164
|
+
this.emitTo('pb-start-update');
|
|
165
|
+
const newState = {};
|
|
166
|
+
if (this.collection) {
|
|
167
|
+
newState.id = this.collection;
|
|
180
168
|
}
|
|
169
|
+
if (this.page) {
|
|
170
|
+
newState.page = this.page + 1;
|
|
171
|
+
}
|
|
172
|
+
registry.commit(this, newState);
|
|
181
173
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
console.log('<dts-client> configured collection endpoint: %s', this._collectionEndpoint);
|
|
174
|
+
this.queryAPI.params = newState;
|
|
175
|
+
this.queryAPI.url = this._collectionEndpoint;
|
|
176
|
+
this.queryAPI.generateRequest();
|
|
177
|
+
}
|
|
187
178
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
this.perPage = json.member.length;
|
|
194
|
-
}
|
|
195
|
-
this.emitTo('pb-results-received', {
|
|
196
|
-
start: this.page && this.page > 0 ? this.page * this.perPage + 1 : 1,
|
|
197
|
-
count: json.totalItems
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
this.emitTo('pb-end-update');
|
|
201
|
-
}
|
|
179
|
+
_handleResponse() {
|
|
180
|
+
const json = this.queryAPI.lastResponse;
|
|
181
|
+
if (json['@type'] === 'EntryPoint') {
|
|
182
|
+
this._collectionEndpoint = new URL(json.collections, this.baseUri).toString();
|
|
183
|
+
console.log('<dts-client> configured collection endpoint: %s', this._collectionEndpoint);
|
|
202
184
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
185
|
+
this._update();
|
|
186
|
+
} else {
|
|
187
|
+
this.data = json;
|
|
188
|
+
console.log('<dts-client> received collection data: %o', json);
|
|
189
|
+
if (!this.page && json.totalItems > json.member.length) {
|
|
190
|
+
this.perPage = json.member.length;
|
|
191
|
+
}
|
|
192
|
+
this.emitTo('pb-results-received', {
|
|
193
|
+
start: this.page && this.page > 0 ? this.page * this.perPage + 1 : 1,
|
|
194
|
+
count: json.totalItems,
|
|
195
|
+
});
|
|
209
196
|
}
|
|
197
|
+
this.emitTo('pb-end-update');
|
|
198
|
+
}
|
|
210
199
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
200
|
+
_handlePreview() {
|
|
201
|
+
const json = this.documentsAPI.lastResponse;
|
|
202
|
+
this.emitTo('pb-end-update');
|
|
203
|
+
const url = new URL(json.path, window.location.href);
|
|
204
|
+
// use registry here?
|
|
205
|
+
window.location.replace(url);
|
|
206
|
+
}
|
|
217
207
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
dialog.open();
|
|
226
|
-
}
|
|
208
|
+
_handleError(ev) {
|
|
209
|
+
this.emitTo('pb-end-update');
|
|
210
|
+
const msg = ev.target.lastError.response;
|
|
211
|
+
const parser = new DOMParser();
|
|
212
|
+
const doc = parser.parseFromString(msg, 'application/xml');
|
|
213
|
+
const node = doc.querySelector('message');
|
|
227
214
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
215
|
+
const dialog = document.getElementById('errorDialog');
|
|
216
|
+
const body = dialog.querySelector('paper-dialog-scrollable');
|
|
217
|
+
if (node) {
|
|
218
|
+
body.innerHTML = node.textContent;
|
|
219
|
+
} else {
|
|
220
|
+
body.innerHTML = ev.detail.error.message;
|
|
231
221
|
}
|
|
222
|
+
dialog.open();
|
|
223
|
+
}
|
|
232
224
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
225
|
+
static _getCreator(item) {
|
|
226
|
+
const dc = item['dts:dublincore'];
|
|
227
|
+
return dc ? dc['dc:creator'] : null;
|
|
228
|
+
}
|
|
237
229
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
<iron-ajax
|
|
244
|
-
id="queryAPI"
|
|
245
|
-
verbose
|
|
246
|
-
handle-as="json"
|
|
247
|
-
method="get"
|
|
248
|
-
@response="${this._handleResponse}"
|
|
249
|
-
@error="${this._handleError}"></iron-ajax>
|
|
250
|
-
<iron-ajax
|
|
251
|
-
id="documentsAPI"
|
|
252
|
-
verbose
|
|
253
|
-
handle-as="json"
|
|
254
|
-
method="get"
|
|
255
|
-
@response="${this._handlePreview}"
|
|
256
|
-
@error="${this._handleError}"></iron-ajax>
|
|
257
|
-
`;
|
|
258
|
-
}
|
|
230
|
+
static _getLicense(item) {
|
|
231
|
+
const dc = item['dts:dublincore'];
|
|
232
|
+
return dc ? dc['dc:license'] : null;
|
|
233
|
+
}
|
|
259
234
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
<slot name="pagination"></slot>
|
|
265
|
-
${
|
|
266
|
-
this._parentCollections.length > 0 || this.collection ?
|
|
267
|
-
html`
|
|
268
|
-
<paper-button part="parent-link" @click="${this._navigateUp}">
|
|
269
|
-
<iron-icon icon="icons:arrow-upward"></iron-icon>
|
|
270
|
-
${translate('browse.up')}
|
|
271
|
-
</paper-button>`
|
|
272
|
-
: null
|
|
273
|
-
}
|
|
274
|
-
${this.data ? this._renderMembers() : ''}
|
|
275
|
-
`;
|
|
276
|
-
}
|
|
235
|
+
render() {
|
|
236
|
+
return html`
|
|
237
|
+
<slot name="toolbar"></slot>
|
|
238
|
+
${this.baseUri ? this._renderClient() : ''}
|
|
277
239
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
240
|
+
<pb-fetch
|
|
241
|
+
id="queryAPI"
|
|
242
|
+
verbose
|
|
243
|
+
handle-as="json"
|
|
244
|
+
method="get"
|
|
245
|
+
@response="${this._handleResponse}"
|
|
246
|
+
@error="${this._handleError}"
|
|
247
|
+
></pb-fetch>
|
|
248
|
+
<pb-fetch
|
|
249
|
+
id="documentsAPI"
|
|
250
|
+
verbose
|
|
251
|
+
handle-as="json"
|
|
252
|
+
method="get"
|
|
253
|
+
@response="${this._handlePreview}"
|
|
254
|
+
@error="${this._handleError}"
|
|
255
|
+
></pb-fetch>
|
|
256
|
+
`;
|
|
257
|
+
}
|
|
285
258
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
<h4 part="title">
|
|
306
|
-
${member.title}
|
|
307
|
-
</h4>
|
|
308
|
-
</a>
|
|
309
|
-
<p part="creator" class="creator">${DtsClient._getCreator(member)}</p>
|
|
310
|
-
${license ? html`<p part="license" class="license"><a href="${license}">${translate('dts.licence')}</a></p>` : ''}
|
|
311
|
-
</div>
|
|
312
|
-
<iron-icon title="${translate('dts.import')}" icon="icons:file-download"
|
|
313
|
-
@click="${(ev) => this._download(ev, member)}">
|
|
314
|
-
</iron-icon>
|
|
315
|
-
</div>
|
|
316
|
-
`;
|
|
317
|
-
}
|
|
259
|
+
_renderClient() {
|
|
260
|
+
return html`
|
|
261
|
+
<div class="uri">${this.baseUri}</div>
|
|
262
|
+
<h3 part="collection-title">${this.data ? this.data.title : 'Loading ...'}</h3>
|
|
263
|
+
<slot name="pagination"></slot>
|
|
264
|
+
${this._parentCollections.length > 0 || this.collection
|
|
265
|
+
? html` <button
|
|
266
|
+
part="parent-link"
|
|
267
|
+
class="pb-button pb-button--text"
|
|
268
|
+
type="button"
|
|
269
|
+
@click="${this._navigateUp}"
|
|
270
|
+
>
|
|
271
|
+
<pb-icon icon="icons:arrow-upward" decorative></pb-icon>
|
|
272
|
+
${translate('browse.up')}
|
|
273
|
+
</button>`
|
|
274
|
+
: null}
|
|
275
|
+
${this.data ? this._renderMembers() : ''}
|
|
276
|
+
`;
|
|
277
|
+
}
|
|
318
278
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
279
|
+
_renderMembers() {
|
|
280
|
+
const members = [];
|
|
281
|
+
this.data.member.forEach(member => {
|
|
282
|
+
members.push(html`<div class="member">${this._renderMember(member)}</div>`);
|
|
283
|
+
});
|
|
284
|
+
return members;
|
|
285
|
+
}
|
|
324
286
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
}
|
|
336
|
-
.member .details {
|
|
337
|
-
flex: 2;
|
|
338
|
-
margin-left: 20px;
|
|
339
|
-
display: flex;
|
|
340
|
-
justify-content: space-between;
|
|
341
|
-
}
|
|
342
|
-
.member iron-icon {
|
|
343
|
-
width: 24px;
|
|
344
|
-
}
|
|
345
|
-
.member h4 {
|
|
346
|
-
margin: 0;
|
|
347
|
-
}
|
|
348
|
-
.member h4.collection {
|
|
349
|
-
margin-bottom: 10px;
|
|
350
|
-
}
|
|
351
|
-
[name='toolbar'] {
|
|
352
|
-
display: flex;
|
|
353
|
-
justify-content: space-between;
|
|
354
|
-
align-items: center;
|
|
355
|
-
color: #f6a622;
|
|
356
|
-
font-size: 85%;
|
|
357
|
-
}
|
|
358
|
-
`;
|
|
287
|
+
_renderMember(member) {
|
|
288
|
+
if (member['@type'] === 'Collection') {
|
|
289
|
+
return html`
|
|
290
|
+
<pb-icon icon="icons:folder-open" decorative></pb-icon>
|
|
291
|
+
<div class="details">
|
|
292
|
+
<button @click="${ev => this._navigate(ev, member)}" part="link" type="button">
|
|
293
|
+
<h4 class="collection" part="collection-title">${member.title}</h4>
|
|
294
|
+
</button>
|
|
295
|
+
</div>
|
|
296
|
+
`;
|
|
359
297
|
}
|
|
298
|
+
const license = DtsClient._getLicense(member);
|
|
299
|
+
return html`
|
|
300
|
+
<pb-icon icon="icons:code" decorative></pb-icon>
|
|
301
|
+
<div class="details">
|
|
302
|
+
<div>
|
|
303
|
+
<button @click="${ev => this._preview(ev, member)}" part="link" type="button">
|
|
304
|
+
<h4 part="title">${member.title}</h4>
|
|
305
|
+
</button>
|
|
306
|
+
<p part="creator" class="creator">${DtsClient._getCreator(member)}</p>
|
|
307
|
+
${license
|
|
308
|
+
? html`<p part="license" class="license">
|
|
309
|
+
<a href="${license}">${translate('dts.licence')}</a>
|
|
310
|
+
</p>`
|
|
311
|
+
: ''}
|
|
312
|
+
</div>
|
|
313
|
+
<pb-icon
|
|
314
|
+
title="${translate('dts.import')}"
|
|
315
|
+
icon="icons:file-download"
|
|
316
|
+
@click="${ev => this._download(ev, member)}"
|
|
317
|
+
></pb-icon>
|
|
318
|
+
</div>
|
|
319
|
+
`;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
static get styles() {
|
|
323
|
+
return css`
|
|
324
|
+
:host {
|
|
325
|
+
display: block;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
.uri {
|
|
329
|
+
color: #607d8a;
|
|
330
|
+
margin-top: 12px;
|
|
331
|
+
font-weight: bold;
|
|
332
|
+
}
|
|
333
|
+
h3 {
|
|
334
|
+
margin-top: 0;
|
|
335
|
+
}
|
|
336
|
+
.member {
|
|
337
|
+
display: flex;
|
|
338
|
+
}
|
|
339
|
+
.member .details {
|
|
340
|
+
flex: 2;
|
|
341
|
+
margin-left: 20px;
|
|
342
|
+
display: flex;
|
|
343
|
+
justify-content: space-between;
|
|
344
|
+
}
|
|
345
|
+
.member pb-icon {
|
|
346
|
+
width: 24px;
|
|
347
|
+
}
|
|
348
|
+
.member h4 {
|
|
349
|
+
margin: 0;
|
|
350
|
+
}
|
|
351
|
+
.member h4.collection {
|
|
352
|
+
margin-bottom: 10px;
|
|
353
|
+
}
|
|
354
|
+
[name='toolbar'] {
|
|
355
|
+
display: flex;
|
|
356
|
+
justify-content: space-between;
|
|
357
|
+
align-items: center;
|
|
358
|
+
color: #f6a622;
|
|
359
|
+
font-size: 85%;
|
|
360
|
+
}
|
|
361
|
+
`;
|
|
362
|
+
}
|
|
360
363
|
}
|
|
361
|
-
customElements.define('dts-client', DtsClient);
|
|
364
|
+
customElements.define('dts-client', DtsClient);
|