コード例 #1
0
    def __init__(self, alert_model, map_):

        # listen the alert_model
        self.alert_model = alert_model

        # get the map as a member
        self.map = map_

        # add the base widgets
        self.close = sw.Icon(children=["mdi-close"], x_small=True)
        self.title = sw.CardTitle(class_="pa-0 ma-0",
                                  children=[sw.Spacer(), self.close])

        # create the control widgets
        self.w_color = cw.MapBtn("fas fa-palette")
        self.w_prev = cw.MapBtn("fas fa-chevron-left", class_="ma-0")
        self.w_now = cw.MapBtn("far fa-circle", class_="ma-0")
        self.w_next = cw.MapBtn("fas fa-chevron-right", class_="ma-0")
        self.w_date = sw.Select(
            label=cm.view.planet.date.label,
            items=[],
            v_model=None,
            dense=True,
            class_="ml-1 mr-1",
            clearable=True,
        )

        # agregate the btns
        btn_list = sw.ItemGroup(
            class_="mr-1 ml-1 v-btn-toggle",
            children=[self.w_prev, self.w_now, self.w_next],
        )

        # create a line with all the widgets
        row = sw.Row(
            align="center",
            class_="ma-1",
            children=[self.w_color, btn_list, self.w_date],
        )

        # disable before any point is selected
        self.disable()

        # create the planet control widgets
        super().__init__(
            class_="pa-1",
            children=[self.title, row],
            viz=False,
        )

        # add javascript events
        self.close.on_event("click", lambda *args: self.hide())
        self.alert_model.observe(self.load_dates, "current_id")
        self.alert_model.observe(self._toggle_widget, "valid_key")
        self.w_prev.on_event("click", self.prev_)
        self.w_next.on_event("click", self.next_)
        self.w_now.on_event("click", self.now_)
        self.w_date.observe(self.update_layer, "v_model")
        self.observe(self.update_layer, "color")
        self.w_color.on_event("click", self._on_palette_change)
コード例 #2
0
    def __init__(self, value, tooltip, icon, unit):

        text = f"{value} {unit}"
        icon = sw.Icon(class_="mr-1", x_small=True, children=[icon])
        chip = sw.Chip(class_="ml-1 mr-1", x_small=True, children=[icon, text])

        super().__init__(chip, tooltip, bottom=True)
コード例 #3
0
ファイル: map_btn.py プロジェクト: openforis/alert_module
    def __init__(self, icon_name, **kwargs):

        # set the default parameters
        kwargs["color"] = kwargs.pop("color", sc.secondary)
        kwargs["x_small"] = kwargs.pop("x_small", True)
        kwargs["class_"] = kwargs.pop("class_", "ml-1 mr-1")
        kwargs["children"] = [sw.Icon(children=[icon_name], x_small=True)]

        super().__init__(**kwargs)
コード例 #4
0
    def __init__(self, map_):

        # create the 2 subtiles
        self.aoi_view = AoiView(map_=map_)
        self.alert_view = AlertView(self.aoi_view.model, map_)
        self.planet_view = PlanetView(self.alert_view.alert_model)

        # set them into a tab widget
        tabs = sw.Tabs(
            fixed_tabs=True,
            v_model=0,
            children=[
                sw.Tab(children=[cm.view.setting.aoi], key=0),
                sw.Tab(children=[cm.view.setting.planet], key=1),
                sw.Tab(children=[cm.view.setting.alert], key=2),
            ],
        )

        contents = sw.TabsItems(
            class_="mt-5",
            v_model=0,
            children=[
                sw.TabItem(children=[self.aoi_view], key=0),
                sw.TabItem(children=[self.planet_view], key=1),
                sw.TabItem(children=[self.alert_view], key=2),
            ],
        )

        # add parameter to close the widget
        self.close = sw.Icon(children=["mdi-close"], small=True)
        title = sw.CardTitle(class_="pa-0 ma-0",
                             children=[sw.Spacer(), self.close])

        # create the card
        super().__init__(
            children=[title, tabs, contents],
            min_height="370px",
            min_width="462px",
            max_width="462px",
            class_="pa-2",
        )

        # add js behaviour
        self.close.on_event("click", lambda *args: self.toggle_viz())
        link((tabs, "v_model"), (contents, "v_model"))
        self.alert_view.alert_model.observe(self._hide_on_success, "gdf")
コード例 #5
0
    def __init__(self, alert_model, map_):

        # listent to the alert model
        self.alert_model = alert_model

        # get the map as a member
        self.map = map_

        # init the layer list
        self.layers = []

        # add the base widgets
        self.close = sw.Icon(children=["mdi-close"], x_small=True)
        self.title = sw.CardTitle(class_="pa-0 ma-0",
                                  children=[sw.Spacer(), self.close])

        # create the control widgets
        self.w_prev_month = cw.MapBtn("fa fa-chevron-double-left",
                                      class_="ma-0",
                                      attributes={"increm": -20})
        self.w_prev_day = cw.MapBtn("fas fa-chevron-left",
                                    class_="ma-0",
                                    attributes={"increm": -1})
        self.w_now = cw.MapBtn("fas fa-circle", class_="ma-0", attributes=None)
        self.w_next_day = cw.MapBtn("fas fa-chevron-right",
                                    class_="ma-0",
                                    attributes={"increm": 1})
        self.w_next_month = cw.MapBtn("fas fa-chevron-double-right",
                                      class_="ma-0",
                                      attributes={"increm": 20})
        self.w_date = sw.TextField(
            label=cm.view.planet.date.label,
            v_model=None,
            dense=True,
            class_="ml-1 mr-1",
            readonly=True,
        )

        # affreaget the btns
        btn_list = sw.ItemGroup(
            class_="mr-1 ml-1 v-btn-toggle",
            children=[
                self.w_prev_month,
                self.w_prev_day,
                self.w_now,
                self.w_next_day,
                self.w_next_month,
            ],
        )

        # create a row with all the action widgets
        row = sw.Row(
            align="center",
            class_="ma-1",
            children=[btn_list, self.w_date],
        )

        # create the planet control widgets
        super().__init__(
            class_="pa-1",
            children=[self.title, row],
            viz=False,
        )

        # add javascript event
        self.close.on_event("click", lambda *Args: self.hide())
        self.alert_model.observe(self._toggle_widget, "valid_key")
        self.alert_model.observe(self.load_data, "current_id")
        self.w_prev_month.on_event("click", self._month)
        self.w_prev_day.on_event("click", self._day)
        self.w_now.on_event("click", self._now)
        self.w_next_day.on_event("click", self._day)
        self.w_next_month.on_event("click", self._month)
        self.w_date.observe(self.update_image, "v_model")
コード例 #6
0
    def __init__(self, alert_model, map_, aoi_model):

        # listen the alert_model
        self.alert_model = alert_model
        self.aoi_model = aoi_model

        # get the map as a member
        self.map = map_

        # add the base widgets
        self.close = sw.Icon(children=["mdi-close"], small=True)
        self.title = sw.CardTitle(class_="pa-0 ma-0",
                                  children=[sw.Spacer(), self.close])
        self.w_id = cw.DynamicSelect()
        self.w_alert = sw.TextField(small=True, readonly=True, v_model="")
        self.w_date = sw.TextField(small=True, readonly=True, v_model="")
        self.w_surface = sw.TextField(small=True,
                                      readonly=True,
                                      v_model="",
                                      suffix="px")
        self.w_coords = sw.TextField(small=True, readonly=True, v_model="")
        self.w_review = sw.RadioGroup(
            disabled=True,
            small=True,
            row=True,
            v_model="unset",
            children=[
                sw.Radio(label=cm.view.metadata.status.valid,
                         value="yes",
                         color=sc.success),
                sw.Radio(label=cm.view.metadata.status.unvalid,
                         value="no",
                         color=sc.error),
                sw.Radio(label=cm.view.metadata.status.unset,
                         value="unset",
                         color=sc.info),
            ],
        )

        # add the default card buton and alert
        self.btn_csv = sw.Btn(cm.view.metadata.btn.csv,
                              small=True,
                              disabled=True)
        self.btn_gpkg = sw.Btn(cm.view.metadata.btn.gpkg,
                               small=True,
                               disabled=True)
        btn_list = sw.Row(children=[
            sw.Spacer(),
            self.btn_csv,
            sw.Spacer(),
            self.btn_gpkg,
            sw.Spacer(),
        ])
        self.alert = sw.Alert(small=True)

        # create a table out of the widgets
        table = sw.SimpleTable(
            dense=True,
            children=[
                self.row(cm.view.metadata.row.alert, self.w_alert),
                self.row(cm.view.metadata.row.date, self.w_date),
                self.row(cm.view.metadata.row.pixels, self.w_surface),
                self.row(cm.view.metadata.row.coords, self.w_coords),
                self.row(cm.view.metadata.row.review, self.w_review),
            ],
        )

        # manually decorate the btn
        self.to_csv = su.loading_button(alert=self.alert,
                                        button=self.btn_csv)(self.to_csv)
        self.to_gpkg = su.loading_button(alert=self.alert,
                                         button=self.btn_gpkg)(self.to_gpkg)

        # create the metadata object
        super().__init__(
            max_width="410px",
            class_="pa-1",
            children=[self.title, self.w_id, table, btn_list, self.alert],
            viz=False,
        )

        # add javascript events
        self.close.on_event("click", lambda *args: self.hide())
        self.alert_model.observe(self._on_alerts_change, "gdf")
        self.w_id.observe(self._on_id_change, "v_model")
        self.w_review.observe(self._on_review_change, "v_model")
        self.btn_csv.on_event("click", self.to_csv)
        self.btn_gpkg.on_event("click", self.to_gpkg)
        self.alert_model.observe(self._id_click, "current_id")