Commit b1d5bd4f authored by Cédric Bonhomme's avatar Cédric Bonhomme
parents ddef3a69 82421138
#! /bin/sh
python3.5 src/manager.py db_empty
python3.5 src/manager.py db_create
# Import the 'help' pages in the database
python3.5 src/manager.py import_page Bibliography data/pages/bibliography.html en
python3.5 src/manager.py import_page Recommendations data/pages/recommendations.html en
python3.5 src/manager.py import_page Glossary data/pages/glossary.html en
python3.5 src/manager.py import_page About data/pages/about.html en
python3.5 src/manager.py import_page About data/pages/about_fr.html fr
# Initializes the structure of the shelters
python3.5 src/manager.py init_shelters_structure data/shelters/Shelters_Structure.csv data/shelters/drawning
# Initializes the administrator (owner of the imported shelters)
python3.5 src/manager.py create_admin_user
# Import of the shelters from the CSV files
python3.5 src/manager.py import_shelters admin data/shelters/20150518_Haiti_shelters.csv
python3.5 src/manager.py import_shelters admin data/shelters/Phil-Bangla-Burundi.csv
# Import pictures of the shelters
python3.5 src/manager.py import_shelters_pictures data/shelters/pictures/
# Import documents of the shelters
python3.5 src/manager.py import_shelters_documents data/shelters/documents/
# Import of the translations
python3.5 src/manager.py import_translation data/translations/sheltersDataTraduction_FR_rev_ED.csv fr
# Create database triggers for materialized view table
python3.5 src/manager.py create_db_triggers
#! /bin/sh
python3.5 src/manager.py db_empty
python3.5 src/manager.py db_create
# Import the 'help' pages in the database
python3.5 src/manager.py import_page Bibliography data/pages/bibliography.html en
python3.5 src/manager.py import_page Recommendations data/pages/recommendations.html en
python3.5 src/manager.py import_page Glossary data/pages/glossary.html en
python3.5 src/manager.py import_page About data/pages/about.html en
python3.5 src/manager.py import_page About data/pages/about_fr.html fr
# Initializes the structure of the shelters
python3.5 src/manager.py init_shelters_structure data/shelters/Shelters_Structure.csv data/shelters/drawning
# Initializes the administrator (owner of the imported shelters)
python3.5 src/manager.py create_admin_user
# Import of the shelters from the CSV files
python3.5 src/manager.py import_shelters admin data/shelters/20150518_Haiti_shelters.csv
python3.5 src/manager.py import_shelters admin data/shelters/Phil-Bangla-Burundi.csv
# Import pictures of the shelters
python3.5 src/manager.py import_shelters_pictures data/shelters/pictures/
# Import documents of the shelters
python3.5 src/manager.py import_shelters_documents data/shelters/documents/
# Import of the translations
python3.5 src/manager.py import_translation data/translations/sheltersDataTraduction_FR_rev_ED.csv fr
# Create database triggers for materialized view table
python3.5 src/manager.py create_db_triggers
......@@ -787,6 +787,7 @@ section.first {
margin: 30px 0; }
@media only screen and (min-width: 768px) {
section.first {
min-height: 540px;
height: 100vh; }
section.first .toplayer {
padding-top: 100px; } }
......
This diff is collapsed.
var _swipe = {}
_swipe.container = document.getElementsByClassName("panes").length ? document.getElementsByClassName("panes")[0] : null
_swipe.dots = document.getElementsByClassName("dots").length ? Array.prototype.slice.call(document.getElementsByClassName("dots")[0].children, 0) : null;
_swipe.panes = Array.prototype.slice.call(_swipe.container.children, 0)
_swipe.containerSize = null;
_swipe.currentIndex = 0;
dots =
_swipe.show = function(showIndex, percent, animate){
showIndex = Math.max(0, Math.min(showIndex, _swipe.panes.length - 1))
percent = showIndex == 0 && percent > 0 || showIndex == _swipe.panes.length - 1 && percent < 0 ? percent/3 || 0 : percent || 0
var className = _swipe.container.className
if(animate) {
if(className.indexOf('animate') === -1) {
_swipe.container.className += ' animate';
}
} else {
if(className.indexOf('animate') !== -1) {
_swipe.container.className = className.replace('animate', '').trim()
}
}
var paneIndex, pos, translate
for (paneIndex = 0; paneIndex < _swipe.panes.length; paneIndex++) {
pos = (_swipe.containerSize / 100) * (((paneIndex - showIndex) * 100) + percent)
translate = 'translate3d(' + pos + 'px, 0, 0)';
_swipe.panes[paneIndex].style.transform = translate
_swipe.panes[paneIndex].style.mozTransform = translate
_swipe.panes[paneIndex].style.webkitTransform = translate
}
// update Dots
for(var i = 0; i < _swipe.dots.length; i++){
_swipe.dots[i].className = "dot"
}
_swipe.dots[showIndex].className = "dot selected"
}
_swipe.onPan = function(ev) {
var delta = ev.deltaX;
var percent = (100 / _swipe.containerSize) * delta;
var animate = false;
if (ev.type == 'panend' || ev.type == 'pancancel') {
if (Math.abs(percent) > 20 && ev.type == 'panend') {
_swipe.currentIndex += (percent < 0) ? 1 : -1;
}
percent = 0;
animate = true;
}
_swipe.show(_swipe.currentIndex, percent, animate)
}
_swipe.init = function(index){
_swipe.setSize()
var mc = new Hammer(_swipe.container)
mc.on("panstart panmove panend pancancel", _swipe.onPan)
_swipe.show(index)
}
_swipe.setSize = function(){
_swipe.containerSize = _swipe.container.offsetWidth || 1000
}
_swipe.init(0)
window.onresize = function(event) {
_swipe.setSize()
}
\ No newline at end of file
......@@ -31,7 +31,9 @@
</head>
<body>
<div id="wrapper">
{% block wrapper_start %}
{% endblock %}
<header>
<nav>
<a class="home" href="/"><i class="fa fa-plus-square"></i><span class="text">Shelter Database</span></a>
......@@ -87,7 +89,7 @@
&copy; Copyright 2016
</footer>
</main>
{% block footer %}
<!-- Bootstrap core JavaScript -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="{{ url_for('static', filename = 'lib/bootstrap/dist/js/bootstrap.min.js') }}"></script>
......@@ -102,6 +104,9 @@
}
});
</script>
</div>
{% endblock %}
{% block wrapper_end %}
{% endblock %}
</body>
</html>
......@@ -5,16 +5,19 @@
{{ super() }}
<script src="{{ url_for('static', filename = 'lib/dc/d3.js') }}"></script>
<script src="{{ url_for('static', filename = 'lib/leaflet/leaflet.js') }}"></script>
<script src="{{ url_for('static', filename = 'lib/dc/d3.js') }}"></script>
<link href="{{ url_for('static', filename='lib/leaflet/leaflet.css') }}" rel="stylesheet" media="screen" />
{% endblock %}
{% block wrapper_start %}
<div id="wrapper">
{% endblock %}
{% block content %}
<section class="shelterheader">
<div class="content">
<h1>Cordaid, TS Urban</h1>
<h1 id="shelter-name">[UNKNOWN NAME]</h1>
</div>
</section>
<section class="shelterimg" style="background-image: url('{{ url_for('static', filename = 'img/shelter.jpg') }}')">
<section class="shelterimg" onclick="modalOpen()" style="background-image: url('{{ url_for('static', filename = 'img/shelter.jpg') }}')">
<div class="dots">
<div class="dot selected"></div>
<div class="dot"></div>
......@@ -23,13 +26,21 @@
</section>
<section class="details">
<div class="content">
<table id="identification"></table>
<table id="identification">
<tr>
<td>No data available in this category</td>
</tr>
</table>
</div>
</section>
<section class="details details-1">
<div class="content">
<h3>General</h3>
<table id="general"></table>
<table id="general">
<tr>
<td>No data available in this category</td>
</tr>
</table>
</div>
</section>
<section>
......@@ -40,84 +51,154 @@
<section class="details details-2">
<div class="content">
<h3>Disaster & Response</h3>
<table id="disasterresponse"></table>
<table id="disasterresponse">
<tr>
<td>No data available in this category</td>
</tr>
</table>
</div>
</section>
<section class="details details-1">
<div class="content">
<h3>Site</h3>
<table id="site"></table>
<table id="site">
<tr>
<td>No data available in this category</td>
</tr>
</table>
</div>
</section>
<section class="details details-2">
<div class="content">
<h3>Foundation</h3>
<table id="foundation"></table>
<table id="foundation">
<tr>
<td>No data available in this category</td>
</tr>
</table>
</div>
</section>
<section class="shelterimg" style="background-image: url('{{ url_for('static', filename = 'img/shelter.jpg') }}')">
<section class="shelterimg" onclick="modalOpen()" style="background-image: url('{{ url_for('static', filename = 'img/shelter.jpg') }}')">
<div class="dots">
<div class="dot selected"></div>
<div class="dot"></div>
<div class="dot"></div>
</div>
</section>
<script type="text/javascript" class="source">
$(document).ready(function() {
$( ".attribute-multimedia-asset" ).click(show_multimedia_assets);
});
{% endblock %}
var shelter_id = {{shelter_id}};
{% block footer %}
<div class="mymodal">
<div class="mymodal-close" onclick="modalClose()"></div>
<div class="swipe">
<div class="panes">
<div class="pane" style="background-image: url('{{ url_for('static', filename = 'img/shelter.jpg') }}"></div>
<div class="pane" style="background-image: url('{{ url_for('static', filename = 'img/1.jpg') }}"></div>
<div class="pane" style="background-image: url('{{ url_for('static', filename = 'img/2.jpg') }}"></div>
<div class="pane" style="background-image: url('{{ url_for('static', filename = 'img/3.jpg') }}')"></div>
</div>
<div class="dots">
<div class="dot" onclick="show(0, 0, true)"></div>
<div class="dot" onclick="show(1, 0, true)"></div>
<div class="dot" onclick="show(2, 0, true)"></div>
<div class="dot" onclick="show(2, 0, true)"></div>
</div>
</div>
</div>
<script type="text/javascript">
var wrapper = document.getElementById("wrapper")
var modalOpen = function(){
wrapper.className = "modal-open modal-open-dark"
}
var modalClose = function(){
wrapper.className = ""
}
</script>
d3.json('/api/v0.2/shelters/' + shelter_id + '?format=prettytext', function (error, data) {
// render the table(s)
var site = data[shelter_id]['Site']['Attributes'];
tabulate("#site", site, d3.keys(site));
var general = data[shelter_id]['General']['Attributes'];
tabulate("#general", general, d3.keys(general));
var disasterresponse = data[shelter_id]['Disaster & Response']['Attributes'];
tabulate("#disasterresponse", disasterresponse, d3.keys(disasterresponse));
var foundation = data[shelter_id]['Foundation']['Attributes'];
tabulate("#foundation", foundation, d3.keys(general));
// Get coordinates for this shelter
var lat = data[shelter_id]['Identification']['Attributes']['GPS Latitude'];
var lon = data[shelter_id]['Identification']['Attributes']['GPS Longitude'];
<script src="{{ url_for('static', filename = 'js/hammer.min.js') }}"></script>
<script src="{{ url_for('static', filename = 'js/swipe.js') }}"></script>
{{ super() }}
// Initiate leaflet map
var map = L.map('location-map').setView([lat, lon], 13);
L.marker([lat, lon]).addTo(map);
});
<script type="text/javascript" class="source">
//$(document).ready(function() {
// $( ".attribute-multimedia-asset" ).click(show_multimedia_assets);
//});
function tabulate(table_id, d, columns) {
var shelter_id = {{shelter_id}};
// convert object keys to an attribute value pair
var data = Object.keys(d).map(function(k) { return {attribute:k, value:d[k]} })
var table = d3.select(table_id)
var tbody = table.append('tbody');
d3.json('/api/v0.2/shelters/' + shelter_id + '?format=prettytext', function (error, data) {
// render the table(s)
if(typeof data[shelter_id]['Site'] !== 'undefined') {
var site = data[shelter_id]['Site']['Attributes'];
$("#site").empty();
tabulate('#site', site, d3.keys(site));
}
if(typeof data[shelter_id]['General'] !== 'undefined') {
var general = data[shelter_id]['General']['Attributes'];
$("#general").empty();
tabulate("#general", general, d3.keys(general));
}
if(typeof data[shelter_id]['Disaster & Response'] !== 'undefined') {
var disasterresponse = data[shelter_id]['Disaster & Response']['Attributes'];
$("#disasterresponse").empty();
tabulate("#disasterresponse", disasterresponse, d3.keys(disasterresponse));
}
if(typeof data[shelter_id]['Foundation'] !== 'undefined') {
var foundation = data[shelter_id]['Foundation']['Attributes'];
$("#foundation").empty();
tabulate("#foundation", foundation, d3.keys(general));
}
if(typeof data[shelter_id]['Identification'] !== 'undefined') {
// Set shelter name
$('#shelter-name').text(data[shelter_id]['Identification']['Attributes']['Name of shelter']);
// Get coordinates for this shelter
var lat = data[shelter_id]['Identification']['Attributes']['GPS Latitude'];
var lon = data[shelter_id]['Identification']['Attributes']['GPS Longitude'];
// Initiate leaflet map
var map = L.map('location-map').setView([lat, lon], 13);
L.marker([lat, lon]).addTo(map);
}
});
function tabulate(table_id, d, columns) {
// create a row for each object in the data
var rows = tbody.selectAll('tr')
.data(data)
.enter()
.append('tr');
// convert object keys to an attribute value pair
var data = Object.keys(d).map(function(k) { return {attribute:k, value:d[k]} })
var table = d3.select(table_id)
var tbody = table.append('tbody');
// Add column with attribute names
rows.append('th')
.text(function (d) { return d.attribute; });
// Add column with values
rows.append('td')
.text(function (d) { return d.value; });
}
</script>
// create a row for each object in the data
var rows = tbody.selectAll('tr')
.data(data)
.enter()
.append('tr');
// Add column with attribute names
rows.append('th')
.text(function (d) { return d.attribute; });
// Add column with values
rows.append('td')
.text(function (d) { return d.value; });
}
</script>
{% endblock %}
{% block wrapper_end %}
</div>
{% endblock %}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment