Skip to content

Commit cb5ea63

Browse files
committed
Latest in merge to load preloaded schemas
1 parent 01dae42 commit cb5ea63

4 files changed

+554
-20
lines changed

catalog.json

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"id": "https://project-open-data.cio.gov/v1.1/schema/catalog.json#",
4+
"title": "Project Open Data Catalog",
5+
"description": "Validates an entire collection of Project Open Data metadata JSON objects. Agencies produce said collections in the form of Data.json files.",
6+
"type": "object",
7+
"dependencies": {
8+
"@type": [
9+
"@context"
10+
]
11+
},
12+
"required": [
13+
"conformsTo",
14+
"dataset"
15+
],
16+
"properties": {
17+
"@context": {
18+
"title": "Metadata Context",
19+
"description": "URL or JSON object for the JSON-LD Context that defines the schema used",
20+
"type": "string",
21+
"format": "uri"
22+
},
23+
"@id": {
24+
"title": "Metadata Catalog ID",
25+
"description": "IRI for the JSON-LD Node Identifier of the Catalog. This should be the URL of the data.json file itself.",
26+
"type": "string",
27+
"format": "uri"
28+
},
29+
"@type": {
30+
"title": "Metadata Context",
31+
"description": "IRI for the JSON-LD data type. This should be dcat:Catalog for the Catalog",
32+
"enum": [
33+
"dcat:Catalog"
34+
]
35+
},
36+
"conformsTo": {
37+
"description": "Version of Schema",
38+
"title": "Version of Schema",
39+
"enum": [
40+
"https://project-open-data.cio.gov/v1.1/schema"
41+
]
42+
},
43+
"describedBy": {
44+
"description": "URL for the JSON Schema file that defines the schema used",
45+
"title": "Data Dictionary",
46+
"type": "string",
47+
"format": "uri"
48+
},
49+
"dataset": {
50+
"type": "array",
51+
"items": {
52+
"$ref": "dataset.json",
53+
"minItems": 1,
54+
"uniqueItems": true
55+
}
56+
}
57+
}
58+
}

datasourceeditor.html

+175
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
<!doctype html>
2+
<html class="no-js" lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>TerriaJS catalog editor</title>
7+
8+
<script src="js/jquery.js"></script>
9+
10+
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
11+
12+
<link rel="stylesheet" href="overrides.css">
13+
14+
15+
<style>
16+
#jsonoutput {
17+
/*display: none; */
18+
width: 98%;
19+
height: 200px;
20+
font-family:monospace;
21+
background-color: hsl(220,80%,95%);
22+
}
23+
#jsonoutputbox label {
24+
color: #555;
25+
font-size: 16px;
26+
}
27+
#sourceurl {
28+
width: 60em;
29+
}
30+
body {
31+
transform: scale(0.75);
32+
transform-origin: top;
33+
}
34+
</style>
35+
36+
37+
</head>
38+
<body>
39+
<div class="container">
40+
<div class="row">
41+
<div class="large-12 columns">
42+
<h1>TerriaJS catalog editor (alpha)</h1>
43+
</div>
44+
</div>
45+
<div class="row">
46+
<div class="span4 collapse-group">
47+
<h2>Help</h2>
48+
<a href="terriajs.io" target="_blank">TerriaJS</a> is the software that runs National Map, AREMI, Northern Australia Map, NEII Viewer, and related sites. This tool is for TerriaJS administrators in charge of managing the catalogs for those sites. It lets you load a catalog (a list of datasources), make changes to it, and then save a copy to the web.
49+
<div class="collapse">
50+
<h3>Loading a catalog</h3>
51+
<p>To load a catalog, either:
52+
<ol>
53+
<li>Click the name of one of the National Map catalog groups, then click the <b>Load</b> button.</li>
54+
<li>If the catalog JSON code is on the web somewhere, paste the URL into the URL box then click the <b>Load</b> button.</li>
55+
<li>Copy the JSON code for the catalog from somewhere else. Paste it into the JSON code box, then click anywhere outside the box to load from it.</li>
56+
57+
</ol>
58+
</p>
59+
<h3>Saving changes</h3>
60+
Click the <b>Save to Gist</b> button. A copy of the catalog will be saved to Gist, a website for storing text files
61+
run by GitHub. The contents is private unless you share the URL with someone. You can then preview the changes or
62+
send a copy to the system administrator.
63+
<h3>Adding properties</h3>
64+
There are many additional properties you can add to each catalog item or group besides its name and type.
65+
<ol><li>Click the <b>Properties</b> button at the top of the item</li>
66+
<li>Scroll down to find the property you want to add, then click its checkbox</li>
67+
<li>Now close the <b>Properties</b> list, and go and find that property, to give it a value.</li>
68+
</ol>
69+
70+
<h3>Moving items up and down</h3>
71+
To reorder items within a group, click the &uarr; and &darr; buttons located <b>below and to the right</b> of the list of items. Reordering items in the primary group level can be slow.
72+
<h3>Adding an item</h3>
73+
To add a new item into a group:
74+
<ol><li>Click <b>✚ Item</b>, located <b>above</b> the list of items. (To add a new top-level group, click <b>✚ Top-level group</b> located <b>at the bottom</b>.)</li>
75+
<li>Choose a type from the drop down list. The default is "Group"</li>
76+
<li>Enter a name</li>
77+
<li>Add additional properties (See "<i>Adding properties</i>", above)</li>
78+
</ul>
79+
</div>
80+
<p><a class="btn" href="#" style="background:hsl(240,50%,95%)">Click for help &raquo;</a></p>
81+
</div>
82+
</div>
83+
84+
<div class="row" id="jsonoutputbox">
85+
<div class="large-12 columns">
86+
<!--<button id='load'>Load from JSON</button>-->
87+
<label for="jsonoutput">JSON code</label>
88+
<textarea id="jsonoutput" value="{ catalog: [] }" >
89+
</textarea>
90+
<!-- This button doesn't "do" anything, but by receiving focus it causes the edit box's change() event
91+
to be triggered -->
92+
<button class="btn">Update</button>
93+
</div>
94+
</div>
95+
96+
97+
<form class="form-horizontal">
98+
<div class="form-group">
99+
<label for="sourceurl" class="col-sm-1 control-label">
100+
Load from:
101+
</label>
102+
<div class="col-sm-5">
103+
<h3>National Map</h3>
104+
<ul id="nm-jsons" style="display:none">
105+
<!--<li><a href="#">test-special</a></a></li>
106+
<li><a href="#">test</a></li>
107+
<li><a href="#">nm</a></li>
108+
<li><a href="#">abs</a></li>
109+
<li><a href="#">ckan</a></li>
110+
<li><a href="#">csiro</a></li>
111+
<li><a href="#">dgakml</a></li>
112+
<li><a href="#">ganew</a></li>
113+
<li><a href="#">geelong</a></li>
114+
<li><a href="#">qld</a></li>
115+
<li><a href="#">sa</a></li>
116+
<li><a href="#">vic</a></li>
117+
<li><a href="#">aremi</a></li>
118+
<li><a href="#">(blank)</a></li>
119+
</ul>-->
120+
</div>
121+
<div class="col-sm-5">
122+
<ul id="other-jsons">
123+
<h3>Other TerriaJS projects</h3>
124+
<li><a href="#">test-special</a></a></li>
125+
<li><a href="#">test</a></li>
126+
<!-- <li><a href="#">aremi</a></li>-->
127+
<li><a href="#">(blank)</a></li>
128+
</ul>
129+
</div>
130+
</div>
131+
<div class="form-group">
132+
133+
<label for="sourceurl" class="col-sm-1 control-label">
134+
URL:
135+
</label>
136+
<div class="col-sm-10 form-inline">
137+
<input type="text" id="sourceurl" class="form-control">
138+
<button type="submit" id="loadjson" class="btn btn-primary">Load</button>
139+
</div>
140+
</div>
141+
<div class="form-group">
142+
<div class="col-sm-1 col-sm-offset-10">
143+
<button type="button" id="savejson" class="btn btn-danger">Save to Gist</button>
144+
</div>
145+
</div>
146+
</form>
147+
148+
<div id="loading" class="centre-block" style="display: none">
149+
<div class="row">
150+
<div class="large-4" id="loadingmsg">
151+
<h2>Loading JSON</h2> Large files take aaaaaaages.
152+
</div>
153+
</div>
154+
</div>
155+
156+
<div class="row">
157+
<div class="col-md-12">
158+
<div id='editor_holder' style="display: none"></div>
159+
</formset>
160+
161+
</div>
162+
</div>
163+
</div>
164+
165+
166+
https://raw.githubusercontent.com/TerriaJS/DataSourceEditor/gh-pages/datasourceeditor.js
167+
<script src="dist/datasourceeditorOrginal.js"></script>
168+
<!--<script src="dist/datasourceeditor.js"></script>-->
169+
<!-- Latest compiled and minified JavaScript -->
170+
<script src="bootstrap/js/bootstrap.min.js"></script>
171+
<script src="dist/jsoneditor.js"></script>
172+
<script src="js/FileSaver.js/FileSaver.js"></script>
173+
174+
</body>
175+
</html>

dist/datasourceeditor.js

+18-20
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,21 @@ function afterSchemaLoad(json) {
2121
// Initialize the editor
2222
schema = json;
2323

24+
JSONEditor.defaults.iconlibs.mybootstrap = JSONEditor.AbstractIconLib.extend({
25+
mapping: {
26+
collapse: 'resize-small',
27+
expand: 'resize-full',
28+
"delete": 'remove',
29+
edit: 'pencil',
30+
add: 'plus',
31+
cancel: 'floppy-remove',
32+
save: 'floppy-saved',
33+
moveup: 'arrow-up',
34+
movedown: 'arrow-down'
35+
},
36+
icon_prefix: 'glyphicon glyphicon-'
37+
});
38+
2439
var alwaysname = {
2540
compile: function() {
2641
return function (vars) {
@@ -29,6 +44,7 @@ function afterSchemaLoad(json) {
2944
}
3045
};
3146

47+
3248
editor = new JSONEditor(document.getElementById('editor'),{
3349
// Enable fetching schemas via ajax
3450
ajax: true,
@@ -44,10 +60,11 @@ function afterSchemaLoad(json) {
4460
disable_edit_json: true
4561
});
4662
editor.on('ready', function() {
47-
$("#schemas-jsons").show();
63+
$("#nm-jsons").show();
4864
});
4965

5066

67+
5168
$("#output").change(function() {
5269
var t;
5370
try {
@@ -89,25 +106,6 @@ function afterSchemaLoad(json) {
89106

90107
});
91108

92-
// Hook up the validation indicator to update its
93-
// status whenever the editor changes
94-
editor.on('change',function() {
95-
// Get an array of errors from the validator
96-
var errors = editor.validate();
97-
98-
// Not valid
99-
if(errors.length) {
100-
// probably not an issue, validation errors are shown already.
101-
// alert("Error in the schema file.")
102-
// console.log(JSON.stringify(errors,null,2));
103-
} else {
104-
//if (!$("#loading").is(":visible"))
105-
$("#output").val(JSON.stringify(editor.getValue(), null, 2));
106-
}
107-
});
108-
109-
populateSources();
110-
}
111109

112110
function clickedExternalJson(e) {
113111
e.preventDefault();

0 commit comments

Comments
 (0)