Ejemplo n.º 1
0
class DataElementGrid(Dhis2Grid):
    title = StaticText("Data elements")
    lead = LeadingColumn(
        label="Name",
        text="name",
        secondary_text="get_value_type_display",
        icon="get_icon",
        translate=False,
    )
    dhis2_id = TextColumn(text="dhis2_id", label="ID", translate=False)
    code = TextColumn(text="code", translate=False)
    tags = TagColumn(value="index.tags.all")
    last_synced = DateColumn(date="instance.last_synced_at")
    view = LinkColumn(text="View")

    download = Action(label="Download all",
                      url="get_download_url",
                      icon="table")

    @property
    def download_url(self):
        return "connector_dhis2:data_element_download"

    @property
    def export_suffix(self):
        return "data_elements"

    def get_icon(self, data_element: DataElement):
        if data_element.domain_type == DomainType.AGGREGATE:
            return "ui/icons/chart_bar.html"
        elif data_element.domain_type == DomainType.TRACKER:
            return "ui/icons/user_circle.html"

        return "ui/icons/exclamation.html"
Ejemplo n.º 2
0
class OrganisationUnitGrid(Dhis2Grid):
    title = StaticText("Organisation units")
    lead = LeadingColumn(
        label="Name",
        text="name",
        secondary_text=None,
        icon="get_icon",
        translate=False,
    )
    dhis2_id = TextColumn(text="dhis2_id", label="ID", translate=False)
    code = TextColumn(text="code", translate=False)
    tags = TagColumn(value="index.tags.all")
    last_synced = DateColumn(date="instance.last_synced_at")
    view = LinkColumn(text="View")

    download = Action(label="Download all",
                      url="get_download_url",
                      icon="table")

    @property
    def download_url(self):
        return "connector_dhis2:organisation_unit_download"

    @property
    def export_suffix(self):
        return "organisation_units"

    def get_icon(self, _: OrganisationUnit):
        return "ui/icons/location_marker.html"
Ejemplo n.º 3
0
class DatasetGrid(Dhis2Grid):
    title = StaticText("Datasets")

    lead = LeadingColumn(
        label="Name",
        text="name",
        icon="get_icon",
        translate=False,
    )
    dhis2_id = TextColumn(text="dhis2_id", label="ID", translate=False)
    code = TextColumn(text="code", translate=False)
    tags = TextColumn(text="todo_tags", translate=False)
    last_synced = DateColumn(date="instance.last_synced_at",
                             label=_("Last synced"))
    view = LinkColumn(text="View")

    download = Action(label="Download all",
                      url="get_download_url",
                      icon="table")

    @property
    def download_url(self):
        return "connector_dhis2:dataset_download"

    @property
    def export_suffix(self):
        return "datasets"

    def get_icon(self, _):
        return "ui/icons/collection.html"
Ejemplo n.º 4
0
class IndicatorGrid(Dhis2Grid):
    title = StaticText("Indicators")
    lead = LeadingColumn(
        label="Name",
        text="name",
        secondary_text="indicator_type.name",
        icon="get_icon",
        translate=False,
    )
    dhis2_id = TextColumn(text="dhis2_id", label="ID", translate=False)
    code = TextColumn(text="code", translate=False)
    tags = TagColumn(value="index.tags.all")
    last_synced = DateColumn(date="instance.last_synced_at")
    view = LinkColumn(text="View")

    download = Action(label="Download all",
                      url="get_download_url",
                      icon="table")

    @property
    def download_url(self):
        return "connector_dhis2:indicator_download"

    @property
    def export_suffix(self):
        return "indicators"

    def get_icon(self, _):
        return "ui/icons/trending_up.html"
Ejemplo n.º 5
0
class ObjectSection(Section):
    title = StaticText("S3 Data")

    name = TextProperty(text="filename", translate=False)
    path = TextProperty(text="full_path", translate=False)
    file_type = TextProperty(label="File type",
                             text="type_display",
                             translate=False)
    file_size = TextProperty(label="File size",
                             text="file_size_display",
                             translate=False)
Ejemplo n.º 6
0
class BucketCard(Datacard):
    title = StaticText("Bucket details")

    external = BucketSection()
    metadata = OpenHexaMetaDataSection(value="index")

    @property
    def generic_description(self):
        return _("GCS Bucket")

    @property
    def gcs_image_src(self):
        return static("connector_gcs/img/symbol.svg")
Ejemplo n.º 7
0
class ObjectCard(Datacard):
    title = StaticText("Object details")

    external = ObjectSection()

    @property
    def generic_description(self):
        return _("S3 Bucket")

    @property
    def s3_image_src(self):
        return static("connector_s3/img/symbol.svg")

    def get_download_url(self, s3_object: Object):
        return s3_object.download_url
Ejemplo n.º 8
0
class ObjectGrid(Datagrid):
    title = StaticText("Objects")

    lead = LeadingColumn(
        label="Name",
        text="filename",
        icon="get_table_icon",
        translate=False,
    )
    directory = TextColumn(text="parent_key", translate=False)
    tags = TagColumn(value="index.tags.all")
    size = TextColumn(text="file_size_display", translate=False)
    type = TextColumn(text="type_display")
    last_modified = DateColumn(date="last_modified", date_format="%Y-%m-%d %H:%M:%S %Z")
    link = LinkColumn(text="View")

    upload = UploadAction()

    def __init__(self, queryset, *, prefix: str, **kwargs):
        self.prefix = prefix
        super().__init__(queryset, **kwargs)

    def get_table_icon(self, obj: Object):
        if obj.type == "directory":
            return "ui/icons/folder_open.html"
        else:
            return "ui/icons/document_text.html"

    @property
    def template(self):
        return "connector_s3/components/object_grid.html"

    def context(self):
        return {
            **super().context(),
            "refresh_url": reverse(
                "connector_s3:bucket_refresh", args=[self.parent_model.id]
            ),
            "upload_url": reverse(
                "connector_s3:object_upload", args=[self.parent_model.id]
            ),
            "prefix": self.prefix,
        }