Skip to content

Commit

Permalink
updates for tethys 4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jakeymac committed Aug 17, 2024
1 parent 35bb0c8 commit 1bead3c
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 65 deletions.
10 changes: 5 additions & 5 deletions install.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file should be committed to your app code.
version: 1.0
version: 1.1
# This should be greater or equal to your tethys-platform in your environment
tethys_version: ">=4.0.0"
# This should match the app - package name in your setup.py
Expand All @@ -10,12 +10,12 @@ requirements:
skip: false
conda:
channels:
- conda-forge
- conda-forge
packages:
- earthengine-api
- oauth2client
- earthengine-api
- oauth2client
pip:

npm:

post:
post:
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
dependencies = []

# -- Get Resource File -- #
resource_files = find_all_resource_files(app_package, TethysAppBase.package_namespace)

resource_files = find_all_resource_files(
app_package, TethysAppBase.package_namespace
)

setup(
name=release_package,
Expand All @@ -28,4 +29,4 @@
include_package_data=True,
zip_safe=False,
install_requires=dependencies,
)
)
7 changes: 3 additions & 4 deletions tethysapp/earth_engine/app.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from tethys_sdk.base import TethysAppBase


class EarthEngine(TethysAppBase):
class App(TethysAppBase):
"""
Tethys app class for Earth Engine.
"""

name = 'Google Earth Engine Tutorial'
name = 'Earth Engine'
description = ''
package = 'earth_engine' # WARNING: Do not change this value
index = 'home'
Expand All @@ -15,4 +14,4 @@ class EarthEngine(TethysAppBase):
color = '#524745'
tags = ''
enable_feedback = False
feedback_emails = []
feedback_emails = []
55 changes: 27 additions & 28 deletions tethysapp/earth_engine/controllers.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import datetime as dt
from django.shortcuts import render
from tethys_sdk.routing import controller
from tethys_sdk.gizmos import SelectInput, DatePicker, Button
from tethys_sdk.gizmos import MapView, MVView
from tethys_sdk.gizmos import SelectInput, DatePicker, Button, MapView, MVView
from .gee.products import EE_PRODUCTS
from .app import App


@controller
Expand Down Expand Up @@ -116,31 +115,30 @@ def home(request):
style='outline-secondary',
attributes={'id': 'load_map'}
)

map_view = MapView(
height='100%',
width='100%',
controls=[
'ZoomSlider', 'Rotate', 'FullScreen',
{'ZoomToExtent': {
'projection': 'EPSG:4326',
'extent': [29.25, -4.75, 46.25, 5.2] #: Kenya
}}
],
basemap=[
'CartoDB',
{'CartoDB': {'style': 'dark'}},
'OpenStreetMap',
'Stamen',
'ESRI'
],
view=MVView(
projection='EPSG:4326',
center=[37.880859, 0.219726],
zoom=7,
maxZoom=18,
minZoom=2
)
height='100%',
width='100%',
controls=[
'ZoomSlider', 'Rotate', 'FullScreen',
{'ZoomToExtent': {
'projection': 'EPSG:4326',
'extent': [29.25, -4.75, 46.25, 5.2] #: Kenya
}}
],
basemap=[
'CartoDB',
{'CartoDB': {'style': 'dark'}},
'OpenStreetMap',
'Stamen',
'ESRI'
],
view=MVView(
projection='EPSG:4326',
center=[37.880859, 0.219726],
zoom=7,
maxZoom=18,
minZoom=2
)
)

context = {
Expand All @@ -155,4 +153,5 @@ def home(request):
'map_view': map_view
}

return render(request, 'earth_engine/home.html', context)

return App.render(request, 'home.html', context)
2 changes: 1 addition & 1 deletion tethysapp/earth_engine/gee/products.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,4 @@
},
}
}
}
}
Binary file added tethysapp/earth_engine/public/images/icon.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 11 additions & 12 deletions tethysapp/earth_engine/public/js/gee_datasets.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,64 +35,63 @@ var GEE_DATASETS = (function() {
bind_controls = function() {
$('#platform').on('change', function() {
let platform = $('#platform').val();

if (platform !== m_platform) {
m_platform = platform;
console.log(`Platform Changed to: ${m_platform}`);
// Update the sensor options when platform changes
update_sensor_options();
}
});

$('#sensor').on('change', function() {
let sensor = $('#sensor').val();

if (sensor !== m_sensor) {
m_sensor = sensor;
console.log(`Sensor Changed to: ${m_sensor}`);
// Update the product options when sensor changes
update_product_options();
}
});

$('#product').on('change', function() {
let product = $('#product').val();

if (product !== m_product) {
m_product = product;
console.log(`Product Changed to: ${m_product}`);
// Update the valid date range when product changes
update_date_bounds();
}
});

$('#start_date').on('change', function() {
let start_date = $('#start_date').val();

if (start_date !== m_start_date) {
m_start_date = start_date;
console.log(`Start Date Changed to: ${m_start_date}`);
}
});

$('#end_date').on('change', function() {
let end_date = $('#end_date').val();

if (end_date !== m_end_date) {
m_end_date = end_date;
console.log(`End Date Changed to: ${m_end_date}`);
}
});

$('#reducer').on('change', function() {
let reducer = $('#reducer').val();

if (reducer !== m_reducer) {
m_reducer = reducer;
console.log(`Reducer Changed to: ${m_reducer}`);
}
});

$('#load_map').on('click', function() {
let data = collect_data();
console.log(data);
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions tethysapp/earth_engine/templates/earth_engine/base.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "tethys_apps/app_base.html" %}

{% load static %}
{% load static tethys %}

{% block title %}{{ tethys_app.name }}{% endblock %}

Expand Down Expand Up @@ -33,10 +33,10 @@

{% block content_dependent_styles %}
{{ block.super }}
<link href="{% static 'earth_engine/css/main.css' %}" rel="stylesheet"/>
<link href="{% static tethys_app|public:'css/main.css' %}" rel="stylesheet"/>
{% endblock %}

{% block scripts %}
{{ block.super }}
<script src="{% static 'earth_engine/js/main.js' %}" type="text/javascript"></script>
<script src="{% static tethys_app|public:'js/main.js' %}" type="text/javascript"></script>
{% endblock %}
18 changes: 9 additions & 9 deletions tethysapp/earth_engine/templates/earth_engine/home.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "earth_engine/base.html" %}
{% load tethys_gizmos static %}
{% extends tethys_app.package|add:"/base.html" %}
{% load static tethys %}

{% block app_navigation_items %}
<li class="title">Select Dataset</li>
Expand All @@ -17,17 +17,17 @@
{% gizmo map_view %}
{% endblock %}

{# Use the after_app_content block for modals #}
{% block after_app_content %}
<div id="ee-products" data-ee-products="{{ ee_products|jsonify }}"></div>
{% block content_dependent_styles %}
{{ block.super }}
<link rel="stylesheet" href="{% static tethys_app|public:'css/map.css' %}" />
{% endblock %}

{% block scripts %}
{{ block.super }}
<script src="{% static 'earth_engine/js/gee_datasets.js' %}" type="text/javascript"></script>
<script src="{% static tethys_app|public:'js/gee_datasets.js' %}" type="text/javascript"></script>
{% endblock %}

{% block content_dependent_styles %}
{{ block.super }}
<link rel="stylesheet" href="{% static 'earth_engine/css/map.css' %}" />
{# Use the after_app_content block for modals #}
{% block after_app_content %}
<div id="ee-products" data-ee-products="{{ ee_products|jsonify }}"></div>
{% endblock %}
Empty file.

0 comments on commit 1bead3c

Please sign in to comment.