コード例 #1
0
    def post_process_return_data(self, return_data):

        return_data['publishers_link'] = '<a href="{}">{}</a>'.format(
            django_url_reverse('pubsub-topic-publishers',
                               kwargs={
                                   'cluster_id': self.req.zato.cluster_id,
                                   'topic_id': return_data['id'],
                                   'name_slug': slugify(return_data['name'])
                               }), 'Publishers')

        return_data['subscribers_link'] = '<a href="{}">{}</a>'.format(
            django_url_reverse('pubsub-topic-subscribers',
                               kwargs={
                                   'cluster_id': self.req.zato.cluster_id,
                                   'topic_id': return_data['id'],
                                   'name_slug': slugify(return_data['name'])
                               }), 'Subscribers')

        item = self.req.zato.client.invoke('zato.pubsub.topic.get', {
            'cluster_id': self.req.zato.cluster_id,
            'id': return_data['id'],
        }).data.response

        return_data['has_gd'] = item.has_gd
        if item.get('last_pub_time'):
            return_data['last_pub_time'] = from_utc_to_user(
                item.last_pub_time + '+00:00', self.req.zato.user_profile)
        else:
            return_data['last_pub_time'] = None

        return_data['current_depth_link'] = """
            <a href="{}?cluster={}">{}</a>
            /
            <a href="{}?cluster={}">{}</a>
            """.format(

            # GD messages
            django_url_reverse('pubsub-topic-messages',
                               kwargs={
                                   'topic_id': return_data['id'],
                                   'name_slug': slugify(return_data['name'])
                               }),
            self.req.zato.cluster_id,
            item.current_depth_gd,

            # Non-GD messages
            django_url_reverse('pubsub-topic-in-ram-backlog',
                               kwargs={
                                   'topic_id': return_data['id'],
                                   'name_slug': slugify(return_data['name'])
                               }),
            self.req.zato.cluster_id,
            item.current_depth_gd)
コード例 #2
0
ファイル: __init__.py プロジェクト: xulong2005/zato
def get_client_html(item, security_id, cluster_id):
    """ Client is a string representation of a WebSockets channel, HTTP credentials or a service.
    """
    client = ''
    path_name = ''

    if security_id:
        path_name = 'security-basic-auth'
        id_value = security_id
        name = item.sec_name
        protocol = 'HTTP'

    elif item.ws_channel_id:
        path_name = 'channel-web-socket'
        id_value = item.ws_channel_id
        name = item.ws_channel_name
        protocol = 'WebSockets'

    elif getattr(item, 'service_id', None):
        path_name = 'service'
        id_value = item.service_id
        name = item.service_name
        protocol = 'Service'

    if path_name:
        path = django_url_reverse(path_name)
        client = '<span style="font-size:smaller">{}</span><br/><a href="{}?cluster={}&amp;highlight={}">{}</a>'.format(
            protocol, path, cluster_id, id_value, name)

    return client
コード例 #3
0
    def post_process_return_data(self, return_data):

        response = self.req.zato.client.invoke(
            'zato.pubsub.endpoint.get-endpoint-summary', {
                'cluster_id': self.req.zato.cluster_id,
                'endpoint_id': self.input.endpoint_id,
            }).data

        if response['last_seen']:
            response['last_seen'] = from_utc_to_user(
                response['last_seen'] + '+00:00', self.req.zato.user_profile)

        if response['last_deliv_time']:
            response['last_deliv_time'] = from_utc_to_user(
                response['last_deliv_time'] + '+00:00',
                self.req.zato.user_profile)

        response['pubsub_endpoint_queues_link'] = \
            django_url_reverse('pubsub-endpoint-queues',
                    kwargs={
                        'cluster_id':self.req.zato.cluster_id,
                        'endpoint_id':response['id'],
                        'name_slug':slugify(response['endpoint_name'])}
                    ),

        return_data.update(response)
コード例 #4
0
def enrich_item(cluster_id, item):
    item.topic_patterns = item.topic_patterns or ''
    item.topic_patterns_html = '<br/>'.join(item.topic_patterns.splitlines())

    is_pub = 'pub' in item.role
    is_sub = 'sub' in item.role

    # Making a copy because it will be replaced with a concatenation of sec_type and security_id,
    # yet we still need it for the client string.
    security_id = item.security_id

    if item.security_id:
        item.security_id = '{}/{}'.format(item.sec_type, item.security_id)

    item.client_html = get_client_html(item, security_id, cluster_id)

    html_kwargs = {
        'cluster_id': cluster_id,
        'endpoint_id': item.id,
        'name_slug': slugify(item.name)
    }

    if is_pub:
        endpoint_topics_path = django_url_reverse('pubsub-endpoint-topics',
                                                  kwargs=html_kwargs)
        item.endpoint_topics_html = '<a href="{}">Topics</a>'.format(
            endpoint_topics_path)
    else:
        item.endpoint_topics_html = '<span class="form_hint">---</span>'

    if is_sub:
        endpoint_queues_path = django_url_reverse('pubsub-endpoint-queues',
                                                  kwargs=html_kwargs)
        item.endpoint_queues_html = '<a href="{}">Queues</a>'.format(
            endpoint_queues_path)
    else:
        item.endpoint_queues_html = '<span class="form_hint">---</span>'

    # This is also needed by the edit action so as not to construct it in JavaScript
    if item.is_internal:
        item.delete_html = '<span class="form_hint">Delete</span>'
    else:
        item.delete_html = """<a href="javascript:$.fn.zato.pubsub.endpoint.delete_('{}')">Delete</a>""".format(
            item.id)

    return item
コード例 #5
0
def get_endpoint_html(item, cluster_id, endpoint_id_attr='endpoint_id', endpoint_name_attr='endpoint_name'):
    id_value = getattr(item, endpoint_id_attr, None) or item[endpoint_id_attr]
    name = getattr(item, endpoint_name_attr, None) or item[endpoint_name_attr]

    path = django_url_reverse('pubsub-endpoint')
    endpoint = '<span style="font-size:smaller"><a href="{}?cluster={}&amp;highlight={}">{}</a>'.format(
        path, cluster_id, id_value, name)

    return endpoint