Esempio n. 1
0
    def sendText(self,
                 components: List[primitives.HtmlModel],
                 attrs: dict = None):
        """
    Description:
    ------------
    Send a complex message from components.

    Related Pages:

      https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_client_applications

    Attributes:
    ----------
    :param List[primitives.HtmlModel] components: The list of HTML components (it will get the dom.content
      automatically)
    :param dict attrs: Optional. Attach some static attributes to the request
    """
        from epyk.core.data import primitives
        from epyk.core.data import datamap

        dfl_attrs = {"type": 'message', 'date': primitives.date()}
        if attrs is not None:
            dfl_attrs.update(attrs)
        data = JsUtils.jsConvertData(datamap(components, attrs=dfl_attrs),
                                     None)
        return JsObjects.JsVoid("%(varName)s.send(JSON.stringify(%(data)s))" %
                                {
                                    "varName": self._selector,
                                    "connect": self.__connect,
                                    "data": data
                                })
Esempio n. 2
0
def get_page(page):
    """

    :param page:

    :type page: epyk.core.Page.Report
    """
    page.headers.dev()
    contents = page.ui.contents("Contente")
    md = page.ui.rich.markdown()
    # md.tooltips({"value": 'Ok'})

    md.onReady([
        page.js.post(
            primitives.str("/docs/get/") +
            page.js.location.urlSearchParams.get("type"),
            datamap(attrs={"category": 'file'})).onSuccess([
                md.build(events.data['markdown']),
                contents.build(events.data['contents'])
            ])
    ])
Esempio n. 3
0
from epyk.core.Page import Report
from epyk.core.data import datamap


page = Report()
page.headers.dev()


page.ui.layouts.br(10)
drop_file = page.ui.network.dropfile()

input = page.ui.input(htmlCode="test")
drop_file.drop([
  drop_file.transfer("/file")
], jsData=datamap([input], attrs={"value": 'test'}))
Esempio n. 4
0
page.ui.row([dt, col])

timeline2 = page.ui.charts.vis.timeline(data,
                                        content="content",
                                        start='start',
                                        end="end",
                                        type="type",
                                        group="group",
                                        options={"type": 'box'})
timeline2.options.stack = True
timeline2.setGroups(groups)

page.components['button'].click([
    timeline2.js.addItem(
        datamap(page.get_components(['content', 'type', 'start',
                                     'end'])).attrs({"group": 3})),
    timeline2.js.fit()
])

scatter = page.ui.charts.chartJs.bar([])
pie = page.ui.charts.chartJs.pie([])

page.ui.row([scatter, pie])

dt.select([
    page.js.post("http://127.0.0.1:8000/data", jsData={
        "test": 4557
    }).onSuccess([
        scatter.build(events.data['chart']),
        pie.build(events.data['pie']),
        page.js.console.log("data", skip_data_convert=True)
Esempio n. 5
0
# Group data for the processing on the JavaScript side
grp = page.data.js.record(std.var("covidData",
                                  global_scope=True)).filterGroup("aggData")
grp2 = page.data.js.record(std.var("covidData",
                                   global_scope=True)).filterGroup("aggData2")
grp3 = page.data.js.record(std.var("covidData",
                                   global_scope=True)).filterGroup("aggData3")
grp4 = page.data.js.record(std.var("covidData",
                                   global_scope=True)).filterGroup("aggData4")
grp5 = page.data.js.record(std.var("covidData",
                                   global_scope=True)).filterGroup("aggData5")

# Events sections for the interactivity
dt.select([
    bar_states.build(
        grp.match(datamap(components=[dt])).group().sumBy(
            ["cases", "deaths", "flips"], ["state"], cast_vals=True)),
])

bar_states.click([
    title_state.build(bar_states.activePoints().label),
    bar.build(
        grp.match(
            datamap(attrs={"state": bar_states.activePoints().label},
                    components=[dt])).group().sumBy(["cases", "deaths"],
                                                    ["county"],
                                                    cast_vals=True)),
    bar_total.build(
        grp4.match(
            datamap(attrs={"state": bar_states.activePoints().label},
                    components=[dt
Esempio n. 6
0
# Create a container for the HTML page
box = page.studio.containers.box()
box.extend([dt, page.ui.row([us, [title_state, line_cumul]]), title_county, row, title, line_cumul_county])
box.style.configs.doc(background=page.theme.greys[0])

# Group data for the processing on the JavaScript side
grp = page.data.js.record(std.var("covidData", global_scope=True)).filterGroup("aggData")
grp2 = page.data.js.record(std.var("covidData", global_scope=True)).filterGroup("aggData2")
grp3 = page.data.js.record(std.var("covidData", global_scope=True)).filterGroup("aggData3")
grp4 = page.data.js.record(std.var("covidData", global_scope=True)).filterGroup("aggData4")
grp5 = page.data.js.record(std.var("covidData", global_scope=True)).filterGroup("aggData5")

# Events sections for the interactivity
dt.select(
  us.build(grp.match(datamap(components=[dt])).group().sumBy(["deaths"], ["state"], cast_vals=True).to_dict('state', 'deaths') )
)

us.click([
  title_state.build(us.activePoints().label),
  bar.build(grp.match(datamap(attrs={"state": us.activePoints().label}, components=[dt])).group().sumBy(["cases", "deaths"], ["county"], cast_vals=True)),
  bar_total.build(grp4.match(datamap(attrs={"state": us.activePoints().label}, components=[dt])).group().sumBy(["cases", "deaths", "fips"], ["state"], cast_vals=True)),
  line_cumul.build(grp2.match(datamap(attrs={"state": us.activePoints().label})).group().sumBy(["cases", "deaths"], ["date"], cast_vals=True)),
  line_cumul_county.build([]),
  title.build(""),
])

bar.click([
  title.build(bar.activePoints().label),
  line_cumul_county.build(grp3.match(datamap(attrs={"state": title_state.dom.content, "county": bar.activePoints().label})).group().sumBy(["cases", "deaths"], ["date"], cast_vals=True)),
])
Esempio n. 7
0
                                       url="https://github.com/rsharankumar/Learn_Data_Science_in_100Days")

# Create a container for the HTML page
box = page.ui.div()
box.extend([title, powered, row, row2, ref])
box.style.configs.doc(background="white")

# Group data for the processing on the JavaScript side
grp = page.data.js.record(std.var("covidData", global_scope=True)).filterGroup("aggData")
grp3 = page.data.js.record(std.var("covidData", global_scope=True)).filterGroup("aggData3")
grp2 = page.data.js.record(std.var("covidData", global_scope=True)).filterGroup("aggData2")

world.click([
  page.js.if_(world.activePoints().label == "United States of America", [
    title_country.build("US"),
    bar.build(grp.match(datamap(attrs={"Country/Region": "US"})).group().sumBy(
      ["Deaths", 'Confirmed', 'Recovered'], ["Country/Region"], cast_vals=True))
  ]).else_([
    title_country.build(world.activePoints().label),
    bar.build(grp3.match(datamap(attrs={"Country/Region": world.activePoints().label})).group().sumBy(
      ["Deaths", 'Confirmed', 'Recovered'], ["Country/Region"], cast_vals=True))
  ])
])

world2.click([
  page.js.if_(world2.activePoints().label == "United States of America", [
    title_country2.build("US"),
    bar2.build(grp.match(datamap(attrs={"Country/Region": "US"})).group().sumBy(
      ["Deaths", 'Confirmed', 'Recovered'], ["Country/Region"], cast_vals=True))
  ]).else_([
    title_country2.build(world2.activePoints().label),