Skip to content

Commit 07a8f3e

Browse files
Merge pull request #13 from Open-EO/development
Complete rewrite for openEO API version 0.3.x
2 parents c9b5d96 + d8cd1bc commit 07a8f3e

11 files changed

+792
-754
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ node_modules/
44

55
/nbproject/
66
.vscode
7+
8+
coverage/
9+
/test-report.html

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ cache:
1010
- "node_modules"
1111

1212
script:
13-
- npm test
13+
- npm run test
14+
- npm run test_node

README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
JavaScript client for the openEO API.
44

5-
[![Status](https://img.shields.io/badge/Status-proof--of--concept-yellow.svg)]()
65
[![Build Status](https://travis-ci.org/Open-EO/openeo-js-client.svg?branch=master)](https://travis-ci.org/Open-EO/openeo-js-client)
76

7+
This client is in **version 0.3.0** and supports **openEO API versions 0.3.0 and 0.3.1**. Legacy versions are available as releases.
8+
89
## Usage
910
This library can run in a recent browser supporting ECMAScript 2015 or node.js.
1011

@@ -16,8 +17,6 @@ To use it in a browser environment simply add the following code to your HTML fi
1617

1718
To install it with npm: `npm install @openeo/js-client`
1819

19-
See [examples/](examples/) for usage examples.
20-
2120
Dependencies required to run the openEO JS client:
2221
* [axios](https://github.com/axios/axios)
2322

examples/auth.html

-29
This file was deleted.

examples/discovery.html

+38-56
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,53 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title>JS Client Test</title>
4+
<title>openEO JS client - Discovery example</title>
55
<meta charset="UTF-8">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
88
<script src="../openeo.js"></script>
9-
<script src="examples.js"></script>
10-
<script type="text/javascript">
11-
window.onload = function () {
12-
OpenEO.API.baseUrl = "http://localhost/api";
13-
OpenEO.API.driver = 'openeo-r-backend';
14-
15-
OpenEO.API.getCapabilities().then(obj => {
16-
replaceWithList("capabilities", obj.rawData);
17-
});
18-
19-
OpenEO.Data.get()
20-
.then(data => {
21-
replaceWithList("data", data);
22-
}).catch(function(errorCode) {
23-
replace("data", "Request returned error " + errorCode);
24-
});
9+
<script type="text/javascript">
10+
var url = "https://earthengine.openeo.org/v0.3"; // Insert the openEO server URL here
11+
var connection = null;
2512

26-
OpenEO.Data.getById('landsat7_ndvi')
27-
.then(data => {
28-
replaceWithList("data_id", data);
29-
}).catch(errorCode => {
30-
replace("data_id", "Request returned error " + errorCode);
31-
});
13+
window.onload = function () {
14+
document.getElementById('url').innerText = url;
3215

33-
OpenEO.Processes.get("ndvi")
34-
.then(data => {
35-
replaceWithList("processes", data);
36-
}).catch(errorCode => {
37-
replace("processes", "Request returned error " + errorCode);
38-
});
16+
var client = new OpenEO();
17+
document.getElementById('clientVersion').innerText = client.version();
3918

40-
OpenEO.Processes.getById('calculate_ndvi')
41-
.then(data => {
42-
replaceWithList("processes_id", data);
43-
}).catch(errorCode => {
44-
replace("processes_id", "Request returned error " + errorCode);
45-
});
19+
client.connect(url)
20+
.then(c => {
21+
connection = c;
22+
return connection.capabilities();
23+
})
24+
.then(capabilities => {
25+
document.getElementById('serverVersion').innerText = capabilities.version();
26+
return connection.listCollections();
27+
})
28+
.then(collections => {
29+
document.getElementById('collectionCount').innerText = collections.collections.length;
30+
return connection.listProcesses();
31+
})
32+
.then(processes => {
33+
document.getElementById('processCount').innerText = processes.processes.length;
34+
return;
35+
})
36+
.catch(err => alert(err.message));;
4637
};
4738
</script>
4839
</head>
4940
<body>
50-
<h2>Capabilities</h2>
51-
<div id="capabilities">
52-
Loading data...
53-
</div>
54-
<h2>Data</h2>
55-
<div id="data">
56-
Loading data...
57-
</div>
58-
<h2>Data: Landsat NDVI</h2>
59-
<div id="data_id">
60-
Loading data...
61-
</div>
62-
<h2>Processes (containing ndvi)</h2>
63-
<div id="processes">
64-
Loading data...
65-
</div>
66-
<h2>Processes: calculate_ndvi</h2>
67-
<div id="processes_id">
68-
Loading data...
69-
</div>
41+
<h1>Server information</h1>
42+
<p>URL: <span id="url"></span></p>
43+
<h2>Versions</h2>
44+
<ul>
45+
<li>Client Version: <span id="clientVersion">Loading...</span></li>
46+
<li>Server Version: <span id="serverVersion">Loading...</span></li>
47+
</ul>
48+
<h2>EO Data Discovery</h2>
49+
<p>Number of supported collections: <span id="collectionCount">Loading...</span></p>
50+
<h2>Process Discovery</h2>
51+
<p>Number of supported processes: <span id="processCount">Loading...</span></p>
7052
</body>
71-
</html>
53+
</html>

examples/examples.js

-26
This file was deleted.

jest.config.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = {
2+
3+
// Indicates whether the coverage information should be collected while executing the test
4+
collectCoverage: true,
5+
6+
// The directory where Jest should output its coverage files
7+
coverageDirectory: "coverage",
8+
9+
// Make calling deprecated APIs throw helpful error messages
10+
errorOnDeprecated: true,
11+
12+
// Use this configuration option to add custom reporters to Jest
13+
"reporters": [
14+
"default",
15+
["./node_modules/jest-html-reporter", {
16+
"pageTitle": "Test Report for openeo-js-client"
17+
}]
18+
]
19+
20+
};

0 commit comments

Comments
 (0)