-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecords.html
More file actions
153 lines (136 loc) · 5.03 KB
/
records.html
File metadata and controls
153 lines (136 loc) · 5.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>OGC API Records</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body { font-family: Arial, sans-serif; margin: 2em; background: #f9f9f9; }
h1 { color: #2c3e50; }
table { border-collapse: collapse; width: 100%; background: #fff; }
th, td { border: 1px solid #ddd; padding: 8px; }
th { background: #f0f0f0; }
tr:hover { background: #f5f5f5; }
.loading { color: #888; }
.error { color: red; }
</style>
</head>
<body>
<h1>OGC API Records</h1>
<div id="status" class="loading">Loading records...</div>
<table id="recordsTable" style="display:none;">
<thead>
<tr>
<th>Title</th>
<th>Type</th>
<th>Identifier</th>
<th>Links</th>
</tr>
</thead>
<tbody id="recordsBody"></tbody>
</table>
<div>
<app-objectinfo-view id="objectinfooutside" > </app-objectinfo-view>
</div>
<script>
let baseUrl = 'https://api.pdok.nl/catalogus/v1-demo/collections/metadata:main/items';
let currentQ = '';
// Create search box and button
document.addEventListener('DOMContentLoaded', () => {
const searchDiv = document.createElement('div');
searchDiv.style.marginBottom = '1em';
const input = document.createElement('input');
input.type = 'text';
input.id = 'searchInput';
input.placeholder = 'Enter search term...';
input.value = currentQ;
input.style.marginRight = '0.5em';
const button = document.createElement('button');
button.textContent = 'Search';
searchDiv.appendChild(input);
searchDiv.appendChild(button);
document.body.insertBefore(searchDiv, document.body.firstChild);
button.addEventListener('click', () => {
currentQ = input.value.trim();
fetchAndRender();
});
input.addEventListener('keydown', (e) => {
if (e.key === 'Enter') {
currentQ = input.value.trim();
fetchAndRender();
}
});
});
function fetchAndRender() {
const apiUrl = `${baseUrl}?q=${encodeURIComponent(currentQ)},f=json`;
// Update JSON link
const jsonLink = document.querySelector('a[href^="https://api.pdok.nl"]');
if (jsonLink) jsonLink.href = apiUrl;
document.getElementById('status').className = 'loading';
document.getElementById('status').textContent = 'Loading records...';
document.getElementById('status').style.display = '';
document.getElementById('recordsTable').style.display = 'none';
document.getElementById('recordsBody').innerHTML = '';
fetch(apiUrl)
.then(response => {
if (!response.ok) throw new Error('Network response was not ok');
return response.json();
})
.then(data => {
const records = data.features || [];
const tbody = document.getElementById('recordsBody');
if (records.length === 0) {
document.getElementById('status').textContent = 'No records found.';
return;
}
records.forEach(record => {
const props = record.properties || {};
const id = record.id || '';
const title = props.title || '';
const description = props.description || '';
const type = props.type || '';
const date = props['created'] || props['date'] || '';
const tr = document.createElement('tr');
tr.innerHTML = `
<td>
<a title="${title}" href="./recorditems.html?id=${id}">
${title}</a><br/>
${description}
</td>
<td>${type}</td>
<td>${id}</td>
<td>
${(record.links || []).map(link => `<a href="${link.href}" target="_blank">${link.rel || 'link'}</a>`).join(', ')}
</td>
`;
tbody.appendChild(tr);
});
document.getElementById('status').style.display = 'none';
document.getElementById('recordsTable').style.display = '';
})
.catch(error => {
document.getElementById('status').className = 'error';
document.getElementById('status').textContent = 'Error loading records: ' + error.message;
});
}
// Initial fetch
fetchAndRender();
//const baseUrl = 'https://catalogue.ejpsoil.eu/collections/metadata:main/items?q=inventaris';
const apiUrl = baseUrl + '?q=,f=json';
// Add JSON link at the top right
document.addEventListener('DOMContentLoaded', () => {
const jsonLink = document.createElement('a');
jsonLink.href = apiUrl;
jsonLink.textContent = 'JSON';
jsonLink.style.position = 'absolute';
jsonLink.style.right = '2em';
jsonLink.style.top = '1em';
jsonLink.style.fontSize = '1em';
jsonLink.style.textDecoration = 'underline';
jsonLink.style.color = '#2980b9';
jsonLink.target = '_blank';
document.body.appendChild(jsonLink);
});
</script>
</body>
</html>