How to use the horizon.tables.Column 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 openstack / horizon / openstack_dashboard / dashboards / project / data_processing / data_plugins / tables.py View on Github external
import logging

from django.template import defaultfilters as filters
from django.utils.translation import ugettext_lazy as _

from horizon import tables

LOG = logging.getLogger(__name__)


class PluginsTable(tables.DataTable):
    title = tables.Column("title",
        verbose_name=_("Title"),
        link=("horizon:project:data_processing.data_plugins:details"))

    versions = tables.Column("versions",
                             verbose_name=_("Supported Versions"),
                             wrap_list=True,
                             filters=(filters.unordered_list,))

    description = tables.Column("description",
                                verbose_name=_("Description"))

    class Meta:
        name = "plugins"
        verbose_name = _("Plugins")
github openstack / horizon / openstack_dashboard / dashboards / admin / floating_ips / tables.py View on Github external
def single(self, table, request, obj_id):
        try:
            fip = table.get_object_by_id(filters.get_int_or_uuid(obj_id))
            api.network.floating_ip_disassociate(request, fip.id)
            LOG.info('Disassociating Floating IP "%s".' % obj_id)
            messages.success(request,
                             _('Successfully disassociated Floating IP: %s')
                             % fip.ip)
        except Exception:
            exceptions.handle(request,
                              _('Unable to disassociate floating IP.'))
        return shortcuts.redirect('horizon:admin:floating_ips:index')


class FloatingIPsTable(project_tables.FloatingIPsTable):
    tenant = tables.Column("tenant_name", verbose_name=_("Project"))
    ip = tables.Column("ip",
                       link=("horizon:admin:floating_ips:detail"),
                       verbose_name=_("IP Address"),
                       attrs={'data-type': "ip"})

    class Meta(object):
        name = "floating_ips"
        verbose_name = _("Floating IPs")
        status_columns = ["status"]
        table_actions = (FloatingIPFilterAction,
                         AdminAllocateFloatingIP,
                         AdminReleaseFloatingIP)
        row_actions = (AdminSimpleDisassociateIP,
                       AdminReleaseFloatingIP)
        columns = ('tenant', 'ip', 'fixed_ip', 'pool', 'status')
github openstack / mistral-dashboard / mistraldashboard / executions / tables.py View on Github external
"",
        verbose_name=_("Input"),
        empty_value=_("View"),
        link="horizon:mistral:executions:input",
        link_classes=("ajax-modal",)
    )

    output = tables.Column(
        "",
        verbose_name=_("Output"),
        empty_value=_("View"),
        link="horizon:mistral:executions:output",
        link_classes=("ajax-modal",)
    )

    created_at = tables.Column(
        "created_at",
        verbose_name=_("Created at"),
        filters=[humantime]
    )

    updated_at = tables.Column(
        "updated_at",
        verbose_name=_("Updated at"),
        filters=[humantime]
    )

    state = tables.Column(
        "state",
        verbose_name=_("State"),
        filters=[label],
        status=True,
github intel / virtual-storage-manager / source / vsm-dashboard / vsm_dashboard / dashboards / vsm / zonemgmt / tables.py View on Github external
from vsm_dashboard.api import vsm as vsmapi

from .utils import checkbox_transform

STRING_SEPARATOR = "__"
LOG = logging.getLogger(__name__)

class CreateZonesAction(tables.LinkAction):
    name = "create zone"
    verbose_name = _("Add Zone")
    url = "horizon:vsm:zonemgmt:create"
    classes = ("ajax-modal", "btn-create")

class ListZoneTable(tables.DataTable):

    zone_id = tables.Column("id", verbose_name=_("ID"), classes=("zone_list",))
    name = tables.Column("name", verbose_name=_("Name"))

    class Meta:
        name = "zone_list"
        verbose_name = _("Zone List")
        table_actions = (CreateZonesAction, )
        multi_select = False

    def get_object_id(self, datum):
        if hasattr(datum, "id"):
            return datum.id
        else:
            return datum["id"]

    def get_object_display(self, datum):
        if hasattr(datum, "name"):
github openstack / octavia-dashboard / octavia_dashboard / dashboards / project / loadbalancersv2 / tables.py View on Github external
def get_lb(instance):
    if hasattr(instance, "vip_address"):
        return "%s:%s" % (instance.vip_address,
                          instance.listener['protocol_port'])
    return _("Not available")


class LoadBalancersTable(tables.DataTable):
    vip = tables.Column(get_lb,
                        link=("horizon:project:loadbalancersv2:detail"),
                        verbose_name=_("Load Balancer"))
    name = tables.Column("name",
                         link=("horizon:project:loadbalancersv2:detail"),
                         verbose_name=_("Name"))
    lb_method = tables.Column(get_lb_method,
                              filters=(upper_case,),
                              verbose_name=_("Method"))
    protocol = tables.Column(get_protocol,
                             filters=(upper_case,),
                             verbose_name=_("Protocol"))
    monitor = tables.Column(get_monitor,
                            filters=(upper_case,),
                            verbose_name=_("Monitor"))
    status = tables.Column("provisioning_status",
                           filters=(convert_camel, linebreaksbr),
                           verbose_name=_("Provisioning Status"))
    operating_status = tables.Column("operating_status",
                                     filters=(convert_camel, linebreaksbr),
                                     verbose_name=_("Operating Status"))
    enabled = tables.Column("admin_state_up",
                            filters=(convert_status,),
github django-leonardo / django-leonardo / leonardo / module / system / maintenance / forms.py View on Github external
management.call_command(
                    'sync_all', force=data.get('sync_force', False))
            if data.get('reload_server', None):
                import os
                os.kill(os.getpid(), 9)
        except Exception as e:
            messages.error(request, str(e))
        else:
            return True
        return False


class SettingsTable(tables.DataTable):

    key = tables.Column('key')
    value = tables.Column('value')

    def get_object_id(self, datum):
        return datum['key']

    class Meta:
        name = 'settings'
        table_actions = (FilterAction,)

PRETTY = """
{% if short %}
<div tabindex="-1" class="codeblock">
    <pre class="short" lang="json">{{ short }}</pre>
    <pre class="full" lang="json">{{ full }}</pre>
{% else %}
<div class="codeblock">
    <pre class="short" lang="json">{{ full }}</pre></div></div>
github openstack / mistral-dashboard / mistraldashboard / workbooks / tables.py View on Github external
def delete(self, request, workbook_name):
        api.workbook_delete(request, workbook_name)


def tags_to_string(workbook):
    return ', '.join(workbook.tags) if workbook.tags else None


class WorkbooksTable(tables.DataTable):
    name = tables.Column(
        "name",
        verbose_name=_("Name"),
        link="horizon:mistral:workbooks:detail"
    )
    tags = tables.Column(tags_to_string, verbose_name=_("Tags"))
    created = tables.Column(
        "created_at",
        verbose_name=_("Created"),
        filters=(
            filters.parse_isotime,
            filters.timesince_or_never
        )
    )
    updated = tables.Column(
        "updated_at",
        verbose_name=_("Updated"),
        filters=(
            filters.parse_isotime,
            filters.timesince_or_never
        )
    )
github openstack / manila-ui / manila_ui / dashboards / admin / share_group_snapshots / tables.py View on Github external
# License for the specific language governing permissions and limitations
# under the License.

from django.template.defaultfilters import title
from django.urls import reverse
from django.utils.translation import pgettext_lazy
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy
from horizon import exceptions
from horizon import tables
from horizon.utils import filters

from manila_ui.api import manila


class ShareGroupSnapshotShareGroupNameColumn(tables.Column):
    def get_link_url(self, snapshot):
        return reverse(self.link, args=(snapshot.share_group_id,))


class DeleteShareGroupSnapshot(tables.DeleteAction):

    @staticmethod
    def action_present(count):
        return ungettext_lazy(
            u"Delete Share Group Snapshot",
            u"Delete Share Group Snapshots",
            count
        )

    @staticmethod
    def action_past(count):
github openstack / heat-dashboard / heat_dashboard / content / stacks / tables.py View on Github external
return urls.reverse('horizon:project:stacks:resource',
                        args=(obj.stack_id, obj.resource_name))


class EventsTable(tables.DataTable):

    logical_resource = tables.Column('resource_name',
                                     verbose_name=_("Stack Resource"),
                                     link=get_resource_url)
    physical_resource = tables.Column('physical_resource_id',
                                      verbose_name=_("Resource"))
    timestamp = tables.Column('event_time',
                              verbose_name=_("Time Since Event"),
                              filters=(filters.parse_isotime,
                                       filters.timesince_or_never))
    status = tables.Column("resource_status",
                           filters=(title, filters.replace_underscores),
                           verbose_name=_("Status"),)

    statusreason = tables.Column("resource_status_reason",
                                 verbose_name=_("Status Reason"),)

    class Meta(object):
        name = "events"
        verbose_name = _("Stack Events")
        pagination_param = 'event_marker'


class ResourcesUpdateRow(tables.Row):
    ajax = True

    def get_data(self, request, resource_name):
github openstack / sahara-dashboard / savannadashboard / job_origins / tables.py View on Github external
class DeleteJobOrigin(tables.BatchAction):
    name = "delete"
    action_present = _("Delete")
    action_past = _("Deleted")
    data_type_singular = _("Job origin")
    data_type_plural = _("Job origins")
    classes = ('btn-danger', 'btn-terminate')

    def action(self, request, obj_id):
        savanna = savannaclient.Client(request)
        savanna.job_origins.delete(obj_id)


class JobOriginsTable(tables.DataTable):
    name = tables.Column("name",
                         verbose_name=_("Name"),
                         link=("horizon:savanna:job_origins:details"))
    description = tables.Column("description",
                                verbose_name=_("Description"))

    class Meta:
        name = "job_origins"
        verbose_name = _("Job Origins")
        table_actions = (CreateJobOrigin,
                         DeleteJobOrigin)
        row_actions = (DeleteJobOrigin,)