-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Musilah <[email protected]>
- Loading branch information
Musilah
committed
Aug 3, 2023
1 parent
0d1a59a
commit e4b5dfb
Showing
4 changed files
with
56 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,6 @@ | |
<script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/1.5.1/leaflet.markercluster.js"></script> | ||
<script src="https://d3js.org/d3.v3.min.js" type="text/javascript"></script> | ||
|
||
<title>Mainflux Deployments</title> | ||
</head> | ||
<body> | ||
|
@@ -26,16 +25,9 @@ <h2>Mainflux Deployment Summary</h2> | |
</div> | ||
<div class="container"> | ||
<div id="filter-container"> | ||
<form id="filter-form" onsubmit="applyFilter(event)"> | ||
<label for="from-date">From:</label> | ||
<input type="date" id="from-date" name="from-date" value="{{.From}}"> | ||
<label for="to-date">To:</label> | ||
<input type="date" id="to-date" name="to-date" value="{{.To}}"> | ||
<input class="btn btn-primary" type="submit" value="Apply"> | ||
</form> | ||
<!-- Button trigger modal --> | ||
<button type="button" class="btn btn-primary" id="btn" data-bs-toggle="modal" data-bs-target="#applyFilters"> | ||
More Filters | ||
Filters | ||
</button> | ||
<!-- Modal --> | ||
<div class="modal fade" id="applyFilters" tabindex="-1" aria-labelledby="applyFiltersLabel" aria-hidden="true"> | ||
|
@@ -45,27 +37,32 @@ <h2>Mainflux Deployment Summary</h2> | |
<h1 class="modal-title fs-5" id="applyFiltersLabel">Apply Filters</h1> | ||
</div> | ||
<div class="modal-body"> | ||
<div class="mb-3"> | ||
<label for="country-filter" class="form-label">Country</label> | ||
<div class="mb-3"> | ||
<form id="country-filter-form" onsubmit="applyFilter(event)"> | ||
<select id="country-filter" class="form-select"> | ||
<option value="">Select a country</option> | ||
{{range $i, $country := .FilterCountries}} | ||
<option value="{{$country.Country}}">{{$country.Country}}</option> | ||
{{end}} | ||
</select> | ||
<button type="submit" class="btn btn-primary">Apply</button> | ||
</form> | ||
</div> | ||
<div class="mb-3"> | ||
<label for="city-filter" class="form-label">City</label> | ||
<form id="city-filter-form" onsubmit="applyFilter(event)"> | ||
<select id="city-filter" class="form-select"> | ||
<option value="">Select a city</option> | ||
|
||
</select> | ||
<button type="submit" class="btn btn-primary">Apply</button> | ||
<div> | ||
<label for="from-date">From:</label> | ||
<input type="date" id="from-date" name="from-date" value="{{.From}}"> | ||
<label for="to-date">To:</label> | ||
<input type="date" id="to-date" name="to-date" value="{{.To}}"> | ||
</div> | ||
<label for="country-filter" class="form-label">Country</label> | ||
<select id="country-filter" class="form-select"> | ||
<option value="">Select a country</option> | ||
{{range $i, $country := .FilterCountries}} | ||
<option value="{{$country.Country}}">{{$country.Country}}</option> | ||
{{end}} | ||
</select> | ||
<label for="city-filter" class="form-label">City</label> | ||
<select id="city-filter" class="form-select"> | ||
<option value="">Select a city</option> | ||
{{range $i, $city := .FilterCities}} | ||
<option value="{{$city.City}}">{{$city.City}}</option> | ||
{{end}} | ||
</select> | ||
<button type="submit" class="btn btn-primary">Apply</button> | ||
|
||
</form> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
|
@@ -78,7 +75,6 @@ <h1 class="modal-title fs-5" id="applyFiltersLabel">Apply Filters</h1> | |
<div id="map"></div> | ||
</div> | ||
</div> | ||
|
||
<script type="text/javascript"> | ||
//create map object and set default positions and zoom level | ||
var map = L.map('map').setView([20, 0], 2); | ||
|
@@ -90,6 +86,7 @@ <h1 class="modal-title fs-5" id="applyFiltersLabel">Apply Filters</h1> | |
var fromDateInput = document.getElementById('from-date').value; | ||
var toDateInput = document.getElementById('to-date').value; | ||
var selectedCountry = document.getElementById('country-filter').value; | ||
var selectedCity = document.getElementById('city-filter').value | ||
var fromDate = fromDateInput ? new Date(fromDateInput) : null; | ||
var toDate = toDateInput ? new Date(toDateInput) : null; | ||
if (fromDate && toDate && fromDate > toDate) { | ||
|
@@ -105,7 +102,7 @@ <h1 class="modal-title fs-5" id="applyFiltersLabel">Apply Filters</h1> | |
var fromDate = fromDateInput ? new Date(fromDateInput).toISOString() : ''; | ||
var toDate = toDateInput ? new Date(toDateInput).toISOString() : ''; | ||
|
||
var url = `/?from=${encodeURIComponent(fromDate)}&to=${encodeURIComponent(toDate)}&country=${encodeURIComponent(selectedCountry)}`; | ||
var url = `/?from=${encodeURIComponent(fromDate)}&to=${encodeURIComponent(toDate)}&country=${encodeURIComponent(selectedCountry)}&city=${encodeURIComponent(selectedCity)}`; | ||
window.location.href = url; | ||
} | ||
|
||
|
@@ -179,12 +176,8 @@ <h1 class="modal-title fs-5" id="applyFiltersLabel">Apply Filters</h1> | |
map.addLayer(countryMarkers); | ||
}); | ||
} | ||
|
||
logJSONData(); | ||
|
||
</script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-HwwvtgBNo3bZJJLYd8oVXjrBZt8cqVSpeBNS5n7C8IVInixGAoxmnlMuBnhbgrkm" crossorigin="anonymous"></script> | ||
|
||
</body> | ||
|
||
</html> |