How to use the horizon.tables function in horizon

To help you get started, we’ve selected a few horizon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github intel / virtual-storage-manager / source / vsm-dashboard / vsm_dashboard / dashboards / vsm / monitor-status / tables.py View on Github external
if "monitor" in _server.type:
                server['is_monitor'] = "yes"
        else:
                server['is_monitor'] = "no"
        if _server.zone_id in zones:
            server['zone'] = zones[_server.zone_id]

        return server

STATUS_DISPLAY_CHOICES = (
    ("resize", "Resize/Migrate"),
    ("verify_resize", "Confirm or Revert Resize/Migrate"),
    ("revert_resize", "Revert Resize/Migrate"),
)

class ListMonitorStatusTable(tables.DataTable):
    STATUS_CHOICES = (
        ("active", True),
        ("available", True),
        ("Active", True),
    )

    #server_id = tables.Column("id", verbose_name=_("ID"))
    ordinal = tables.Column("id", verbose_name=_("ordinal"))
    name = tables.Column("name", verbose_name=_("Name"))
    address = tables.Column("address", verbose_name=_("Address"))
    health = tables.Column("health", verbose_name=_("Health"))
    details = tables.Column("details", verbose_name=_("Detail"))
    skew = tables.Column("skew", verbose_name=_("Skew"))
    latency = tables.Column("latency", verbose_name=_("Latency"))
    kb_total = tables.Column("mb_total", verbose_name=_("MB Total (disk)"))
    kb_used = tables.Column("mb_used", verbose_name=_("MB Used (disk)"))
github openstack / horizon / openstack_dashboard / dashboards / admin / routers / tables.py View on Github external
class UpdateRow(tables.Row):
    ajax = True

    def get_data(self, request, router_id):
        router = api.neutron.router_get(request, router_id)
        return router


class AdminRoutersFilterAction(r_tables.RoutersFilterAction):
    name = 'filter_admin_routers'
    filter_choices = r_tables.RoutersFilterAction.filter_choices + (
        ('project', _("Project ="), True),)


class RoutersTable(r_tables.RoutersTable):
    tenant = tables.Column("tenant_name", verbose_name=_("Project"))
    name = tables.WrappingColumn("name",
                                 verbose_name=_("Name"),
                                 link="horizon:admin:routers:detail")

    class Meta(object):
        name = "routers"
        verbose_name = _("Routers")
        status_columns = ["status"]
        row_class = UpdateRow
        table_actions = (CreateRouter, DeleteRouter,
                         AdminRoutersFilterAction)
        row_actions = (EditRouter, DeleteRouter,)
        columns = ('tenant', 'name', 'status', 'distributed', 'ext_net',
                   'ha', 'availability_zones', 'admin_state',)
github openstack / horizon / horizon / dashboards / project / networks / subnets / tables.py View on Github external
data_type_singular = _("Subnet")
    data_type_plural = _("Subnets")

    def delete(self, request, obj_id):
        try:
            api.quantum.subnet_delete(request, obj_id)
        except:
            msg = _('Failed to delete subnet %s') % obj_id
            LOG.info(msg)
            network_id = self.table.kwargs['network_id']
            redirect = reverse('horizon:project:networks:detail',
                               args=[network_id])
            exceptions.handle(request, msg, redirect=redirect)


class CreateSubnet(CheckNetworkEditable, tables.LinkAction):
    name = "create"
    verbose_name = _("Create Subnet")
    url = "horizon:project:networks:addsubnet"
    classes = ("ajax-modal", "btn-create")

    def get_link_url(self, datum=None):
        network_id = self.table.kwargs['network_id']
        return reverse(self.url, args=(network_id,))


class UpdateSubnet(CheckNetworkEditable, tables.LinkAction):
    name = "update"
    verbose_name = _("Edit Subnet")
    url = "horizon:project:networks:editsubnet"
    classes = ("ajax-modal", "btn-edit")
github openstack / manila-ui / manila_ui / dashboards / project / shares / tables.py View on Github external
status_columns = ["status"]
        row_class = UpdateRuleRow
        table_actions = (
            AddRule,
            DeleteRule)
        row_actions = (
            DeleteRule,)


def get_share_network(share):
    name = share.share_network_name
    return name if name != "None" else None


class SharesTable(SharesTableBase):
    name = tables.WrappingColumn(
        "name", verbose_name=_("Name"),
        link="horizon:project:shares:detail")
    visibility = tables.Column(
        "is_public", verbose_name=_("Visibility"),
        help_text=("Whether this share visible to all tenants (public) or "
                   "only for owner (private)."),
        filters=(lambda d: 'public' if d is True else 'private', ),
    )
    proto = tables.Column("share_proto", verbose_name=_("Protocol"))
    share_network = tables.Column("share_network",
                                  verbose_name=_("Share Network"),
                                  empty_value="-")

    class Meta(object):
        name = "shares"
        verbose_name = _("Shares")
github openstack / horizon / horizon / dashboards / project / networks / subnets / tables.py View on Github external
LOG = logging.getLogger(__name__)


class CheckNetworkEditable(object):
    """Mixin class to determine the specified network is editable."""

    def allowed(self, request, datum=None):
        # Only administrator is allowed to create and manage subnets
        # on shared networks.
        network = self.table._get_network()
        if network.shared:
            return False
        return True


class DeleteSubnet(CheckNetworkEditable, tables.DeleteAction):
    data_type_singular = _("Subnet")
    data_type_plural = _("Subnets")

    def delete(self, request, obj_id):
        try:
            api.quantum.subnet_delete(request, obj_id)
        except:
            msg = _('Failed to delete subnet %s') % obj_id
            LOG.info(msg)
            network_id = self.table.kwargs['network_id']
            redirect = reverse('horizon:project:networks:detail',
                               args=[network_id])
            exceptions.handle(request, msg, redirect=redirect)


class CreateSubnet(CheckNetworkEditable, tables.LinkAction):
github openstack / horizon / openstack_dashboard / dashboards / identity / application_credentials / tables.py View on Github external
    @staticmethod
    def action_past(count):
        return ungettext_lazy(
            "Deleted Application Credential",
            "Deleted Application Credentialss",
            count
        )

    policy_rules = (("identity", "identity:delete_application_credential"),)

    def delete(self, request, obj_id):
        api.keystone.application_credential_delete(request, obj_id)


class ApplicationCredentialFilterAction(tables.FilterAction):
    filter_type = "query"
    filter_choices = (("name", _("Application Credential Name ="), True))


def _render_roles(obj):
    names = [role['name'] for role in obj.roles]
    return ', '.join(names)


class ApplicationCredentialsTable(tables.DataTable):
    name = tables.WrappingColumn('name',
                                 link=APP_CRED_DETAILS_LINK,
                                 verbose_name=_('Name'))
    project_id = tables.Column('project_id', verbose_name=_('Project ID'))
    description = tables.Column('description',
                                verbose_name=_('Description'))
github a10networks / a10-neutron-lbaas / a10_neutron_lbaas / dashboard / a10devices / tables.py View on Github external
class A10ApplianceTable(tables.DataTable):
    id = tables.Column("id", verbose_name=_("ID"), hidden=True)
    name = tables.Column("name", verbose_name=_("Hostname"), hidden=False)
    ip = tables.Column("ip_mgmt", verbose_name="Management IP")

    class Meta(object):
        name = "a10appliancestable"
        verbose_name = _("A10 Appliances")
        table_actions = (AddApplianceAction,)
        row_actions = ()


class A10ImageTable(tables.DataTable):
    id = tables.Column("id", verbose_name=_("ID"), hidden=True)
    name = tables.Column("name", verbose_name=_("Name"))
    filename = tables.Column("filename", verbose_name=_("Filename"))

    class Meta(object):
        name = "a10imagestable"
        verbose_name = _("A10 Images")
        table_actions = (AddImageAction,)
        row_actions = ()
github openstack / sahara-dashboard / sahara_dashboard / content / data_processing / jobs / data_sources / tables.py View on Github external
from sahara_dashboard.api import sahara as saharaclient
from sahara_dashboard.content.data_processing \
    import tables as sahara_table
from sahara_dashboard.content.data_processing.utils \
    import acl as acl_utils


class CreateDataSource(tables.LinkAction):
    name = "create data source"
    verbose_name = _("Create Data Source")
    url = "horizon:project:data_processing.jobs:create-data-source"
    classes = ("ajax-modal",)
    icon = "plus"


class DeleteDataSource(tables.DeleteAction):
    @staticmethod
    def action_present(count):
        return ungettext_lazy(
            u"Delete Data Source",
            u"Delete Data Sources",
            count
        )

    @staticmethod
    def action_past(count):
        return ungettext_lazy(
            u"Deleted Data Source",
            u"Deleted Data Sources",
            count
        )
github openstack / horizon / openstack_dashboard / dashboards / project / networks / ports / extensions / allowed_address_pairs / tables.py View on Github external
import logging

from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy

from horizon import tables

from openstack_dashboard import api
from openstack_dashboard import policy


LOG = logging.getLogger(__name__)


class AddAllowedAddressPair(policy.PolicyTargetMixin, tables.LinkAction):
    name = "AddAllowedAddressPair"
    verbose_name = _("Add Allowed Address Pair")
    url = "horizon:project:networks:ports:addallowedaddresspairs"
    classes = ("ajax-modal",)
    icon = "plus"
    policy_rules = (
        ("network", "update_port"),
        ("network", "update_port:allowed_address_pairs"),
    )

    def get_policy_target(self, request, datum=None):
        policy_target = super(AddAllowedAddressPair, self).\
            get_policy_target(request, datum)
        policy_target["network:tenant_id"] = (
            self.table.kwargs['port'].tenant_id)
github openstack / horizon / openstack_dashboard / dashboards / admin / networks / subnets / tables.py View on Github external
from horizon import exceptions
from horizon import tables
from horizon.utils import memoized

from openstack_dashboard import api
from openstack_dashboard.dashboards.project.networks.subnets \
    import tables as proj_tables
from openstack_dashboard.dashboards.project.networks.subnets.tabs \
    import SubnetsTab as project_tabs_subnets_tab
from openstack_dashboard.usage import quotas

LOG = logging.getLogger(__name__)


class CreateSubnet(proj_tables.SubnetPolicyTargetMixin, tables.LinkAction):
    name = "create"
    verbose_name = _("Create Subnet")
    url = "horizon:admin:networks:createsubnet"
    classes = ("ajax-modal",)
    icon = "plus"
    policy_rules = (("network", "create_subnet"),)

    def get_link_url(self, datum=None):
        network_id = self.table.kwargs['network_id']
        return reverse(self.url, args=(network_id,))

    def allowed(self, request, datum=None):
        network = self.table._get_network()
        usages = quotas.tenant_quota_usages(
            request, tenant_id=network.tenant_id, targets=('subnet', ))