-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from sepal-contrib/deprecate
Deprecate
- Loading branch information
Showing
7 changed files
with
114 additions
and
326 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import json | ||
import shutil | ||
|
||
from sepal_ui import sepalwidgets as sw | ||
from sepal_ui.scripts import utils as su | ||
import ipyvuetify as v | ||
|
||
from component.message import cm | ||
from component import parameter as cp | ||
from component import widget as cw | ||
from component import scripts as cs | ||
|
||
from .gwb_tile import GwbTile | ||
|
||
|
||
class DeprecatedTile(sw.Tile): | ||
def __init__(self, tile_id): | ||
alert = sw.Alert().show() | ||
markdown = sw.Markdown( | ||
f"The module {tile_id} has been deprecated. For details and alternatives, please view <a href='https://ies-ows.jrc.ec.europa.eu/gtb/GWB/GWB_changelog.txt' target='_blank'>the changelog</a>." | ||
) | ||
alert.add_msg(markdown, "info") | ||
inputs = [alert] | ||
|
||
super().__init__( | ||
tile_id, | ||
title="Deprecated process", | ||
inputs=inputs, | ||
) |
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 |
---|---|---|
@@ -1,64 +1,6 @@ | ||
import json | ||
import shutil | ||
from .deprecated_tile import DeprecatedTile | ||
|
||
from sepal_ui import sepalwidgets as sw | ||
from sepal_ui.scripts import utils as su | ||
import ipyvuetify as v | ||
|
||
from component.message import cm | ||
from component import parameter as cp | ||
from component import widget as cw | ||
from component import scripts as cs | ||
|
||
from .gwb_tile import GwbTile | ||
|
||
|
||
class FadTile(GwbTile): | ||
def __init__(self, model): | ||
|
||
# create the widgets | ||
connectivity = v.Select( | ||
label=cm.acc.connectivity, | ||
items=cp.connectivity, | ||
v_model=cp.connectivity[0]["value"], | ||
) | ||
prescision = v.Select( | ||
label=cm.fad.prescision, | ||
items=cp.prescision, | ||
v_model=cp.prescision[0]["value"], | ||
) | ||
options = v.Select( | ||
label=cm.acc.options, | ||
items=cp.fad_options, | ||
v_model=cp.fad_options[0]["value"], | ||
) | ||
|
||
# bind to the io | ||
( | ||
model.bind(connectivity, "connectivity") | ||
.bind(prescision, "prescision") | ||
.bind(options, "options") | ||
) | ||
|
||
super().__init__( | ||
model=model, | ||
inputs=[connectivity, prescision, options], | ||
) | ||
|
||
@su.loading_button() | ||
def _on_click(self, widget, event, data): | ||
|
||
# check inputs | ||
if not all( | ||
[ | ||
self.alert.check_input(self.model.connectivity, cm.acc.no_connex), | ||
self.alert.check_input(self.model.prescision, cm.fad.no_prescision), | ||
self.alert.check_input(self.model.options, cm.acc.no_options), | ||
self.alert.check_input(self.model.bin_map, cm.bin.no_bin), | ||
] | ||
): | ||
return | ||
|
||
super()._on_click(widget, event, data) | ||
|
||
return | ||
class FadTile(DeprecatedTile): | ||
def __init__(self): | ||
super().__init__("fad_tile") |
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 |
---|---|---|
@@ -1,81 +1,6 @@ | ||
import json | ||
import shutil | ||
from .deprecated_tile import DeprecatedTile | ||
|
||
from sepal_ui import sepalwidgets as sw | ||
from sepal_ui.scripts import utils as su | ||
import ipyvuetify as v | ||
|
||
from component.message import cm | ||
from component import parameter as cp | ||
from component import widget as cw | ||
from component import scripts as cs | ||
|
||
from .gwb_tile import GwbTile | ||
|
||
|
||
class P223Tile(GwbTile): | ||
def __init__(self, model): | ||
|
||
# create the widgets | ||
algorithm = v.Select( | ||
label=cm.p223.algo, items=cp.algo, v_model=cp.algo[0]["value"] | ||
) | ||
kdim = v.TextField( | ||
label=cm.lm.kdim, type="number", hint=cm.frag.invalid_window, v_model=None | ||
) | ||
prescision = v.Select( | ||
label=cm.fad.prescision, | ||
items=cp.prescision, | ||
v_model=cp.prescision[0]["value"], | ||
) | ||
|
||
# bind to the io | ||
( | ||
model.bind(algorithm, "algorithm") | ||
.bind(kdim, "kdim") | ||
.bind(prescision, "prescision") | ||
) | ||
|
||
# create extra js behaviour | ||
kdim.on_event("focusout", self._on_focusout) | ||
|
||
super().__init__( | ||
model=model, | ||
inputs=[ | ||
algorithm, | ||
kdim, | ||
prescision, | ||
], | ||
) | ||
|
||
@su.loading_button() | ||
def _on_click(self, widget, event, data): | ||
|
||
# check inputs | ||
if not all( | ||
[ | ||
self.alert.check_input(self.model.kdim, cm.lm.no_kdim), | ||
self.alert.check_input(self.model.bin_map, cm.bin.no_bin), | ||
] | ||
): | ||
return | ||
|
||
super()._on_click(widget, event, data) | ||
|
||
return | ||
|
||
def _on_focusout(self, widget, event, data): | ||
|
||
# clear the error message | ||
widget.error_messages = None | ||
|
||
# check if an input exist | ||
if not widget.v_model: | ||
return self | ||
|
||
# test the value over the limits | ||
if not cs.is_valid_window(widget.v_model): | ||
widget.v_model = False | ||
widget.error_messages = [cm.frag.invalid_window] | ||
|
||
return self | ||
class P223Tile(DeprecatedTile): | ||
def __init__(self): | ||
super().__init__("p223_tile") |
Oops, something went wrong.