Beispiel #1
0
 def get_context_data(self, **kwargs):
     ret = super(NetworksMixin, self).get_context_data(**kwargs)
     tab_menu = [
         MenuItem('Info',
                  fugue_icon='fugue-wooden-box',
                  href=self.tab_href('info')),
         MenuItem('Addresses',
                  fugue_icon='fugue-network-ip',
                  href=self.tab_href('addresses')),
         MenuItem('Autoscan',
                  fugue_icon='fugue-radar',
                  href=self.tab_href('autoscan')),
     ]
     show_tabs = [
         'info',
         'addresses',
         'autoscan',
     ]
     context = {
         'show_tabs': show_tabs,
         'tab_items': tab_menu,
     }
     context['network'] = self.set_network()
     ret.update(context)
     return ret
Beispiel #2
0
 def get_context_data(self, **kwargs):
     ret = super(RacksDeviceList, self).get_context_data(**kwargs)
     profile = self.request.user.get_profile()
     has_perm = profile.has_perm
     tab_items = ret['tab_items']
     if ret['subsection']:
         tab_items.append(
             MenuItem(
                 'Rack',
                 fugue_icon='fugue-media-player-phone',
                 href='../rack/?%s' % self.request.GET.urlencode()
             )
         )
     if has_perm(Perm.create_device, self.rack.venture if
                 self.rack else None):
         tab_items.append(
             MenuItem(
                 'Deploy',
                 fugue_icon='fugue-wand-hat',
                 name='add_device',
                 href='../add_device/?%s' % (self.request.GET.urlencode())
             )
         )
     ret.update({
         'subsection': self.rack.name if self.rack else self.rack,
         'subsection_slug': _get_identifier(self.rack),
     })
     return ret
Beispiel #3
0
def ventures_menu(href='', selected=None):
    top_items = []
    stack = [
        (None, top_items, Venture.objects.root_nodes()),
    ]
    while stack:
        parent, items, ventures = stack.pop()
        for venture in ventures.order_by('name'):
            item = MenuItem(
                venture.name,
                name='{}'.format(venture.id),
                subitems=[],
                fugue_icon='fugue-store-medium',
                indent=' ',
                href='{}/{}/'.format(href, venture.id),
                collapsed=True,
                collapsible=True,
            )
            item.parent = parent
            items.append(item)
            stack.append((item, item.subitems, venture.get_children()))
            if item.name == selected:
                while item:
                    item.kwargs['collapsed'] = False
                    item = item.parent
    return top_items
Beispiel #4
0
    def get_context_data(self, **kwargs):
        context = super(Base, self).get_context_data(**kwargs)
        footer_items = []
        if self.request.user.is_staff:
            footer_items.append(
                MenuItem(
                    'Admin',
                    fugue_icon='fugue-toolbox',
                    href='/admin/ralph_pricing',
                ), )
        footer_items.append(
            MenuItem(
                'logout',
                fugue_icon='fugue-door-open-out',
                pull_right=True,
                href=settings.LOGOUT_URL,
            ))
        footer_items.append(
            MenuItem(
                'Ralph',
                fugue_icon='fugue-home',
                href=reverse('search'),
            ))
        footer_items.append(
            MenuItem(
                "Version %s" % '.'.join((str(part) for part in VERSION)),
                fugue_icon='fugue-document-number',
            ))

        context.update({
            'mainmenu_items': MAIN_MENU,
            'footer_items': footer_items,
            'home_url': reverse('home'),
        })
        return context
Beispiel #5
0
 def get_submodules(self):
     return [
         MenuItem(
             'Configuration items',
             name='configuration_items',
             fugue_icon='fugue-block',
             view_name='cmdb_timeline',
         ),
         MenuItem(
             'CI by layers',
             name='layers',
             fugue_icon='fugue-applications-blue',
             href='/cmdb/search',
         ),
         MenuItem(
             'Reports',
             name='ci_reports',
             fugue_icon='fugue-reports',
             href='/cmdb/changes/reports?kind=top_changes',
         ),
         MenuItem(
             'Events and changes',
             name='events',
             fugue_icon='fugue-arrow-circle-double',
             href='/cmdb/changes/changes',
         ),
         MenuItem(
             'Others',
             name='ci_others',
             fugue_icon='fugue-beaker',
             href='/cmdb/archive/assets/',
         ),
     ]
Beispiel #6
0
 def get_context_data(self, **kwargs):
     self.set_rack()
     ret = super(SidebarRacks, self).get_context_data(**kwargs)
     icon = presentation.get_device_icon
     sidebar_items = [
         MenuItem(
             _("Unknown"),
             name='',
             fugue_icon='fugue-prohibition',
             view_name='racks',
             view_args=['-', ret['details'], '']
         )
     ]
     for dc in Device.objects.filter(
             model__type=DeviceType.data_center.id).order_by('name'):
         subitems = []
         sidebar_items.append(
             MenuItem(
                 dc.name,
                 name=_get_identifier(dc),
                 fugue_icon=icon(dc),
                 view_name='data_center_view',
                 subitems=subitems,
                 indent=' ',
                 view_args=[
                     _slug(dc.name),
                 ],
                 collapsible=True,
                 collapsed=not (
                     self.rack and (
                         self.rack == dc or self.rack.parent == dc
                     )
                 )
             )
         )
         for r in Device.objects.filter(
             model__type=DeviceType.rack.id
         ).filter(
             parent=dc
         ).order_by('name'):
             subitems.append(
                 MenuItem(
                     r.name,
                     name=_get_identifier(r),
                     indent=' ',
                     fugue_icon=icon(r),
                     view_name='racks',
                     view_args=[
                         _get_identifier(r), ret['details'], ''
                     ]
                 )
             )
     ret.update({
         'sidebar_items': sidebar_items,
         'sidebar_selected': _get_identifier(self.rack),
         'section': 'racks',
         'subsection': _get_identifier(self.rack),
         'show_bulk': True if self.rack else False,
     })
     return ret
Beispiel #7
0
 def get_mainmenu_items(self):
     mainmenu = [
         MenuItem(
             label='Data center',
             name='dc',
             fugue_icon='fugue-building',
             href='/assets/dc',
         ),
         MenuItem(
             label='BackOffice',
             fugue_icon='fugue-printer',
             name='back_office',
             href='/assets/back_office',
         ),
     ]
     if 'ralph_pricing' in settings.INSTALLED_APPS:
         mainmenu.append(
             MenuItem(
                 label='Ralph Pricing',
                 fugue_icon='fugue-money-coin',
                 name='back_office',
                 href='/pricing/all-ventures/',
             ),
         )
     return mainmenu
Beispiel #8
0
def ventures_menu(href='', selected=None):
    """
    Generate ventures submenu

    :param string href: base url for submenu items
    :param string selected: name of selected row
    :returns list: list of menu items
    :rtype list:
    """
    top_items = []
    stack = [
        (None, top_items, Venture.objects.root_nodes()),
    ]
    while stack:
        parent, items, ventures = stack.pop()
        for venture in ventures.order_by('name'):
            item = MenuItem(
                venture.name,
                name='{}'.format(venture.id),
                subitems=[],
                fugue_icon='fugue-store-medium',
                indent=' ',
                href='{}/{}/'.format(href, venture.id),
                collapsed=True,
                collapsible=True,
            )
            item.parent = parent
            items.append(item)
            stack.append((item, item.subitems, venture.get_children()))
            if item.name == selected:
                while item:
                    item.kwargs['collapsed'] = False
                    item = item.parent
    return top_items
Beispiel #9
0
def teams_menu(href, selected=None):
    """
    Create menus for teams percent definitions.
    """
    teams = Team.objects.filter(billing_type='TIME').order_by('name')
    items = []
    for team in teams:
        item = MenuItem(
            team.name,
            name=team.name,
            subitems=[],
            fugue_icon='fugue-user-worker',
            href='{}/{}'.format(href, team.name),
            indent=' ',
            collapsed=True,
            collapsible=True,
        )
        if item.name == selected:
            item.kwargs['collapsed'] = False
        for dates in team.dateranges.values('start', 'end', 'id'):
            daterange = '{0} - {1}'.format(dates['start'], dates['end'])
            subitem = MenuItem(
                daterange,
                name=dates['id'],
                subitems=[],
                fugue_icon='fugue-clock',
                href='{}/{}/{}'.format(href, team.name, dates['id']),
                indent=' '
            )
            subitem.parent = item
            item.subitems.append(subitem)
        items.append(item)
    return items
Beispiel #10
0
 def get_context_data(self, **kwargs):
     context = super(SidebarReports, self).get_context_data(**kwargs)
     sidebar_items = [
         MenuItem("Devices",
                  fugue_icon='fugue-computer',
                  view_name='reports_devices'),
         MenuItem("Margins",
                  fugue_icon='fugue-piggy-bank',
                  view_name='reports_margins'),
         MenuItem("Services",
                  fugue_icon='fugue-disc-share',
                  view_name='reports_services'),
         MenuItem("Ventures",
                  fugue_icon='fugue-store',
                  view_name='reports_ventures'),
         MenuItem("Device prices per venture",
                  fugue_icon='fugue-computer',
                  view_name='device_prices_per_venture'),
     ]
     context.update({
         'sidebar_items': sidebar_items,
         'sidebar_selected': self.subsection,
         'section': 'reports',
         'subsection': self.subsection,
     })
     return context
Beispiel #11
0
 def get_context_data(self, **kwargs):
     ret = super(Catalog, self).get_context_data(**kwargs)
     try:
         model_type_id = int(self.kwargs.get('type', ''))
     except ValueError:
         model_type_id = None
     kind = self.kwargs.get('kind')
     sidebar_items = (
         [
             MenuHeader('Component groups'),
         ] + [
             MenuItem(
                 label=t.raw.title(),
                 name='component-%d' % t.id,
                 fugue_icon=COMPONENT_ICONS.get(t.id),
                 view_name='catalog',
                 view_args=('component', t.id),
             ) for t in ComponentType(item=lambda t: t)
         ] + [
             MenuHeader('Device groups'),
         ] + [
             MenuItem(
                 label=t.raw.title(),
                 name='device-%d' % t.id,
                 fugue_icon=DEVICE_ICONS.get(t.id),
                 view_name='catalog',
                 view_args=('device', t.id),
             ) for t in DeviceType(item=lambda t: t)
         ] + [
             MenuHeader('Tools'),
             MenuItem(
                 'History',
                 name='history',
                 fugue_icon='fugue-hourglass',
                 view_name='catalog_history',
             ),
             MenuItem(
                 'Pricing groups',
                 name='pricing',
                 fugue_icon='fugue-shopping-basket',
                 view_name='catalog_pricing',
                 view_args=('pricing',),
             ),
         ]
     )
     selected = '%s-%d' % (kind, model_type_id) if model_type_id else ''
     ret.update({
         'component_model_types': ComponentType(item=lambda a: a),
         'details': self.kwargs.get('details', 'info'),
         'device_model_types': DeviceType(item=lambda a: a),
         'editable': True,
         'kind': kind,
         'model_type_id': model_type_id,
         'sidebar_items': sidebar_items,
         'sidebar_selected': selected,
         'subsection': model_type_id,
     })
     return ret
Beispiel #12
0
    def get_context_data(self, **kwargs):
        ret = super(SidebarVentures, self).get_context_data(**kwargs)
        self.set_venture()
        details = ret['details']
        profile = self.request.user.get_profile()
        has_perm = profile.has_perm
        ventures = profile.perm_ventures(Perm.list_devices_generic)
        show_all = self.request.GET.get('show_all')
        ventures = ventures.order_by('-is_infrastructure', 'name')

        sidebar_items = [
            MenuItem(fugue_icon='fugue-prohibition', label="Unknown",
                     name='-', view_name='ventures',
                     view_args=['-', details, '']),
            MenuItem(fugue_icon='fugue-asterisk', label="All ventures",
                     name='*', view_name='ventures',
                     view_args=['*', details, ''])
        ]
        sidebar_items.extend(venture_tree_menu(
                ventures.filter(parent=None), details, show_all))
        if self.venture and self.venture != '*':
            stack = list(sidebar_items)
            while stack:
                item = stack.pop()
                if getattr(item, 'venture_id', None) == self.venture.id:
                    parent = getattr(item, 'parent', None)
                    while parent:
                        parent.kwargs['collapsed'] = False
                        parent = getattr(parent, 'parent', None)
                    break
                stack.extend(getattr(item, 'subitems', []))

        self.set_venture()
        tab_items = ret['tab_items']
        if has_perm(Perm.read_device_info_generic, self.venture if
                    self.venture and self.venture != '*' else None):
            tab_items.append(MenuItem('Roles', fugue_icon='fugue-mask',
                            href='../roles/?%s' % self.request.GET.urlencode()))
        if has_perm(Perm.list_devices_financial, self.venture if
                    self.venture and self.venture != '*' else None):
            tab_items.append(MenuItem('Venture', fugue_icon='fugue-store',
                            href='../venture/?%s' %
                            self.request.GET.urlencode()))
        ret.update({
            'sidebar_items': sidebar_items,
            'sidebar_selected': (_normalize_venture(self.venture.symbol) if
                self.venture and self.venture != '*' else self.venture or '-'),
            'section': 'ventures',
            'subsection': (_normalize_venture(self.venture.symbol) if
                self.venture and self.venture != '*' else self.venture),
            'searchform': VentureFilterForm(self.request.GET),
            'searchform_filter': True,
        })
        return ret
Beispiel #13
0
    def get_submodules(self):
        submodules = []
        submodules.append(
            MenuItem(_('Search'), fugue_icon='fugue-application-search-result',
                     view_name='search', name='search'))
        if self.has_perm(Perm.has_core_access):
            submodules.append(
                MenuItem(
                    _('Services'),
                    fugue_icon='fugue-application-share',
                    view_name='services',
                )
            )
            submodules.append(
                MenuItem(
                    _('Ventures'),
                    fugue_icon='fugue-store',
                    view_name='ventures',
                )
            )
        if self.has_perm(Perm.read_dc_structure):
            submodules.append(MenuItem(_('Racks'), view_name='racks'))
            submodules.append(MenuItem(
                _('DC View'), name='dc_view', view_name='dc_view')
            )
        if all((
            self.has_perm(Perm.read_network_structure),
            'Networks' not in settings.HIDE_MENU,
        )):
            submodules.append(
                MenuItem(
                    _('Networks'),
                    fugue_icon='fugue-weather-clouds',
                    view_name='networks'
                )
            )
        submodules.append(
            MenuItem(_('Ralph CLI'), fugue_icon='fugue-terminal',
                     href='#beast'))
        submodules.append(
            MenuItem(_('Quick scan'), fugue_icon='fugue-radar',
                     href='#quickscan'))

        pending_changes = get_pending_changes()
        submodules.append(MenuItem(
            _('Pending changes {}/{}').format(
                pending_changes.new_devices,
                pending_changes.changed_devices,
            ),
            view_kwargs={'change_type': (
                'new' if pending_changes.new_devices else 'existing'
            )},
            name='scan_list',
            view_name='scan_list',
            fugue_icon='fugue-light-bulb',
        ))
        return submodules
Beispiel #14
0
    def get_context_data(self, **kwargs):
        self.set_rack()
        ret = super(SidebarRacks, self).get_context_data(**kwargs)
        icon = presentation.get_device_icon

        def slug(sn):
            return sn.replace(' ', '-').lower()

        sidebar_items = [
            MenuItem("Unknown",
                     name='',
                     fugue_icon='fugue-prohibition',
                     view_name='racks',
                     view_args=['', ret['details'], ''])
        ]
        for dc in Device.objects.filter(
                model__type=DeviceType.data_center.id).order_by('name'):
            subitems = []
            sidebar_items.append(
                MenuItem(dc.name,
                         name=slug(dc.sn),
                         fugue_icon=icon(dc),
                         view_name='racks',
                         subitems=subitems,
                         indent=' ',
                         view_args=[slug(dc.sn), ret['details'], ''],
                         collapsible=True,
                         collapsed=not (self.rack and
                                        (self.rack == dc
                                         or self.rack.parent == dc))))
            for r in Device.objects.filter(
                    model__type=DeviceType.rack.id).filter(
                        parent=dc).order_by('name'):
                subitems.append(
                    MenuItem(r.name,
                             name=slug(r.sn),
                             indent=' ',
                             fugue_icon=icon(r),
                             view_name='racks',
                             view_args=[slug(r.sn), ret['details'], '']))
        ret.update({
            'sidebar_items':
            sidebar_items,
            'sidebar_selected':
            slug(self.rack.sn) if self.rack else self.rack,
            'section':
            'racks',
            'subsection':
            slug(self.rack.sn) if self.rack else self.rack,
        })
        return ret
Beispiel #15
0
 def get_context_data(self, **kwargs):
     ret = super(CatalogPricing, self).get_context_data(**kwargs)
     self.parse_args()
     date = datetime.date(self.year, self.month, 1)
     group_items = [
         MenuItem(
             'Add a new group',
             name='',
             fugue_icon='fugue-shopping-basket--plus',
             view_name='catalog_pricing',
             view_args=(
                 'pricing',
                 '%04d' % self.year,
                 '%02d' % self.month
             ),
         ),
     ] + [
         MenuItem(
             g.name,
             name=g.name,
             fugue_icon = 'fugue-shopping-basket',
             view_name='catalog_pricing',
             view_args=(
                 'pricing',
                 '%04d' % self.year,
                 '%02d' % self.month,
                 g.name,
             ),
         ) for g in PricingGroup.objects.filter(date=date)
     ]
     aggr = PricingGroup.objects.aggregate(db.Min('date'))
     min_year = aggr['date__min'].year if aggr['date__min'] else self.year
     aggr = PricingGroup.objects.aggregate(db.Max('date'))
     max_year = aggr['date__max'].year if aggr['date__max'] else self.year
     min_year = min(self.year, self.today.year, min_year)
     max_year = max(self.year, self.today.year, max_year)
     ret.update({
         'sidebar_selected': 'pricing',
         'subsection': 'pricing',
         'group_items': group_items,
         'year': self.year,
         'month': self.month,
         'months': list(enumerate(calendar.month_abbr))[1:],
         'years': range(min_year - 1, max_year + 2),
         'today': self.today,
         'group_name': self.group_name,
     })
     return ret
Beispiel #16
0
 def generate_menu_items(data):
     return [
         MenuItem(
             label=t[1],
             fugue_icon=t[2],
             href=t[0],
         ) for t in data]
Beispiel #17
0
def network_tree_menu(networks, details, get_params, show_ip=False, status=''):
    icon = presentation.get_network_icon
    items = []

    def get_href(view_args):
        view_args = map(
            lambda arg: urllib.quote(arg.encode('utf-8'), ''),
            view_args,
        )
        url = reverse("networks", args=view_args)
        return '%s?%s' % (
            url,
            get_params,
        )
    for n in networks:
        items.append(MenuItem(
            "{} ({})".format(n['network'].name, n['network'].address,),
            fugue_icon=icon(n['network']),
            view_name='networks',
            indent='  ',
            href=get_href(view_args=[str(n['network'].id), details, status]),
            name=n['network'].name,
            subitems=network_tree_menu(
                n['subnetworks'], details, get_params, show_ip, status,
            ),
            collapsible=True,
            collapsed=not getattr(n['network'], 'expanded', False),
        ))
    return items
Beispiel #18
0
 def get_context_data(self, **kwargs):
     context = super(SidebarReports, self).get_context_data(**kwargs)
     sidebar_items = [
         MenuItem("Ventures",
                  fugue_icon='fugue-store',
                  view_name='reports_ventures'),
         MenuItem("Margins",
                  fugue_icon='fugue-piggy-bank',
                  view_name='reports_margins'),
     ]
     context.update({
         'sidebar_items': sidebar_items,
         'sidebar_selected': self.subsection,
         'section': 'reports',
         'subsection': self.subsection,
     })
     return context
Beispiel #19
0
 def get_context_data(self, **kwargs):
     ret = super(SidebarNetworks, self).get_context_data(**kwargs)
     self.set_network()
     networks = Network.objects.all()
     contains = self.request.GET.get('contains')
     if contains:
         networks = networks.filter(
             Q(name__contains=contains) | Q(address__contains=contains))
     self.networks = list(networks.order_by('min_ip', 'max_ip'))
     stack = []
     children = collections.defaultdict(list)
     for network in self.networks:
         network.parent = None
         while stack:
             if network in stack[-1]:
                 network.parent = stack[-1]
                 children[stack[-1].id].append(network)
                 break
             else:
                 stack.pop()
         if network.parent:
             network.depth = network.parent.depth + 1
         else:
             network.depth = 0
         network.indent = ' ' * network.depth
         stack.append(network)
         if network == self.network:
             parent = getattr(network, 'parent', None)
             while parent:
                 parent.expanded = True
                 parent = getattr(parent, 'parent', None)
     sidebar_items = [
         MenuItem(fugue_icon='fugue-prohibition',
                  label="None",
                  name='',
                  view_name='networks',
                  view_args=['-', ret['details'], ''])
     ]
     sidebar_items.extend(
         network_tree_menu([n for n in self.networks if n.parent is None],
                           ret['details'],
                           children,
                           show_ip=self.request.GET.get('show_ip')))
     ret.update({
         'sidebar_items':
         sidebar_items,
         'sidebar_selected':
         (self.network.name if self.network else self.network),
         'section':
         'networks',
         'subsection':
         self.network.name if self.network else self.network,
         'searchform':
         NetworksFilterForm(self.request.GET),
         'searchform_filter':
         True,
     })
     return ret
Beispiel #20
0
 def get_sidebar_items(self):
     items = (('/assets/dc/add/device', 'Add device', 'fugue-block--plus'),
              ('/assets/dc/add/part', 'Add part', 'fugue-block--plus'),
              ('/assets/dc/search', 'Search', 'fugue-magnifier'),
              ('/admin/ralph_assets', 'Admin', 'fugue-toolbox'))
     sidebar_menu = (
         [MenuHeader('Data center actions')] +
         [MenuItem(label=t[1], fugue_icon=t[2], href=t[0]) for t in items])
     return sidebar_menu
Beispiel #21
0
 def get_sidebar_items(self):
     preferences = ((reverse('user_home_page',
                             args=[]), _('Home Page'), 'fugue-home'), )
     sidebar_items = ([MenuHeader('Preferences')] + [
         MenuItem(label=preference[1],
                  fugue_icon=preference[2],
                  href=preference[0]) for preference in preferences
     ])
     return sidebar_items
Beispiel #22
0
    def get_context_data(self, **kwargs):
        ret = super(RacksAddDevice, self).get_context_data(**kwargs)
        tab_items = ret['tab_items']
        ret['template_menu_items'] = TEMPLATE_MENU_ITEMS
        ret['template_selected'] = 'device'
        if ret['subsection']:
            tab_items.append(
                MenuItem('Rack',
                         fugue_icon='fugue-media-player-phone',
                         href='../rack/?%s' % self.request.GET.urlencode()))

        tab_items.append(
            MenuItem('Deploy',
                     name='add_device',
                     fugue_icon='fugue-wand-hat',
                     href='../add_device/?%s' %
                     (self.request.GET.urlencode())))
        return ret
Beispiel #23
0
 def _get_menu(self, tree):
     items = []
     for bl_id, bl_data in tree.iteritems():
         bl_item = MenuItem(label=bl_data['name'],
                            name='bl_%s' % bl_id,
                            fugue_icon='fugue-tie',
                            view_name='services',
                            view_args=['bl-%s' % bl_id],
                            indent=' ',
                            collapsible=True,
                            collapsed=False
                            if self.businessline_id == str(bl_id) else True)
         bl_item.subitems = []
         for s_id, s_data in bl_data.get('childs', {}).iteritems():
             s_item = MenuItem(
                 label=s_data['name'],
                 name='bl_%s_s_%s' % (bl_id, s_id),
                 fugue_icon='fugue-disc-share',
                 view_name='services',
                 view_args=['bl-%s' % bl_id,
                            'ser-%s' % s_id],
                 indent=' ',
                 collapsible=True,
                 collapsed=False if self.service_id == str(s_id) else True)
             s_item.subitems = []
             for e_id, e_data in s_data.get('childs', {}).iteritems():
                 e_item = MenuItem(label=e_data['name'],
                                   name='bl_%s_s_%s_env_%s' %
                                   (bl_id, s_id, e_id),
                                   fugue_icon='fugue-tree',
                                   view_name='services',
                                   view_args=[
                                       'bl-%s' % bl_id,
                                       'ser-%s' % s_id,
                                       'env-%s' % e_id
                                   ],
                                   indent=' ')
                 e_item.parent = s_item
                 s_item.subitems.append(e_item)
             s_item.parent = bl_item
             bl_item.subitems.append(s_item)
         items.append(bl_item)
     return items
Beispiel #24
0
 def get_context_data(self, **kwargs):
     ret = super(RacksAddDevice, self).get_context_data(**kwargs)
     tab_items = ret['tab_items']
     tab_items.append(
         MenuItem('Add Device',
                  name='add_device',
                  fugue_icon='fugue-wooden-box--plus',
                  href='../add_device/?%s' %
                  (self.request.GET.urlencode(), )))
     return ret
Beispiel #25
0
def usages_menu(href='', selected=None):
    items = [
        MenuItem(
            usage_type.name,
            name=usage_type.name,
            subitems=[],
            fugue_icon='fugue-beaker',
            href='{}/{}/'.format(href, usage_type.name),
        ) for usage_type in UsageType.objects.order_by('name')
    ]
    return items
Beispiel #26
0
 def get_sidebar_items(self):
     items = (
         ('/assets/back_office/add/device/', 'Add device',
          'fugue-block--plus'),
         ('/assets/back_office/add/part/', 'Add part', 'fugue-block--plus'),
         ('/assets/back_office/search', 'Search', 'fugue-magnifier'),
     )
     sidebar_menu = (
         [MenuHeader('Back office actions')] +
         [MenuItem(label=t[1], fugue_icon=t[2], href=t[0]) for t in items])
     return sidebar_menu
Beispiel #27
0
def extra_costs_menu(href='', selected=None):
    extra_costs_type = ExtraCostType.objects.all().order_by('name')
    return [
        MenuItem(
            extra_cost_type.name,
            name=extra_cost_type.name,
            subitems=[],
            fugue_icon='fugue-money-coin',
            href='{}/{}/'.format(href, extra_cost_type.id),
        ) for extra_cost_type in extra_costs_type
    ]
Beispiel #28
0
 def get_submodules(self):
     return [
         MenuItem(
             _("Ventures report"),
             name='all-ventures',
             fugue_icon='fugue-store-medium',
             view_name='all_ventures',
         ),
         MenuItem(
             _("Devices report"),
             name='devices',
             fugue_icon='fugue-wooden-box',
             view_name='devices',
         ),
         MenuItem(
             _("Ventures daily usages"),
             name='ventures-daily-usages',
             fugue_icon='fugue-calendar-day',
             view_name='ventures_daily_usages',
         ),
         MenuItem(
             _("Devices ventures changes"),
             name='ventures-changes',
             fugue_icon='fugue-arrow-switch',
             view_name='ventures_changes',
         ),
         MenuItem(
             _("Extra costs"),
             name='extra-costs',
             fugue_icon='fugue-money-coin',
             view_name='extra_costs',
         ),
         MenuItem(
             _("Usage types"),
             name='usages',
             fugue_icon='fugue-beaker',
             view_name='usages',
         ),
         MenuItem(
             _("Teams"),
             name='teams',
             fugue_icon='fugue-users',
             view_name='teams',
         ),
         MenuItem(
             _("Statements"),
             name='statement',
             fugue_icon='fugue-clock-history',
             view_name='statement',
         ),
     ]
Beispiel #29
0
 def get_context_data(self, **kwargs):
     result = super(ReportDeviceList, self).get_context_data(**kwargs)
     report_menu_items = (MenuItem(desc, href=name)
                          for name, desc in ReportType(
                              item=lambda v: (v.name, v.desc)))
     report_type = self.get_report_type()
     result.update({
         'report_menu_items': report_menu_items,
         'report_selected': report_type.desc.lower(),
         'columns': report_type.columns,
     })
     return result
Beispiel #30
0
 def get_sidebar_items(self):
     ci = (
         ('/cmdb/search', 'All Cis', 'fugue-magnifier'),
         ('/cmdb/search?layer=7&top_level=1', 'Services',
          'fugue-disc-share'),
         ('/cmdb/add', 'Add CI', 'fugue-block--plus'),
         ('/cmdb/changes/dashboard', 'Dashboard', 'fugue-dashboard'),
         ('/cmdb/changes/timeline', 'Timeline View', 'fugue-dashboard'),
         ('/admin/cmdb', 'Admin', 'fugue-toolbox'),
     )
     reports = (
         ('/cmdb/changes/reports?kind=top_changes', 'Top CI changes',
          'fugue-reports'),
         ('/cmdb/changes/reports?kind=top_problems', 'Top CI problems',
          'fugue-reports'),
         ('/cmdb/changes/reports?kind=top_incidents', 'Top CI incidents',
          'fugue-reports'),
         ('/cmdb/changes/reports?kind=usage', 'Cis w/o changes',
          'fugue-reports'),
     )
     events = (('/cmdb/changes/changes', 'All Events', 'fugue-arrow'),
               ('/cmdb/changes/changes?type=3', 'Asset attr. changes',
                'fugue-wooden-box--arrow'),
               ('/cmdb/changes/changes?type=4', 'Monitoring events',
                'fugue-thermometer'), ('/cmdb/changes/changes?type=1',
                                       'Repo changes', 'fugue-git'),
               ('/cmdb/changes/changes?type=2', 'Agent events',
                'fugue-flask'), ('/cmdb/changes/changes?type=5',
                                 'Status Office events', 'fugue-plug'),
               ('/cmdb/changes/incidents', 'Incidents', 'fugue-question'),
               ('/cmdb/changes/problems', 'Problems', 'fugue-bomb'))
     sidebar_items = (
         [MenuHeader('Configuration Items')] +
         [MenuItem(label=t[1], fugue_icon=t[2], href=t[0])
          for t in ci] + [MenuHeader('Reports')] + [
              MenuItem(label=t[1], fugue_icon=t[2], href=t[0])
              for t in reports
          ] + [MenuHeader('Events and  Changes')] +
         [MenuItem(label=t[1], fugue_icon=t[2], href=t[0]) for t in events])
     return sidebar_items
Beispiel #31
0
 def get_context_data(self, **kwargs):
     ret = super(NetworksAutoscan, self).get_context_data(**kwargs)
     status_menu_items = [
         MenuItem(
             'New',
             fugue_icon='fugue-star',
             href=self.tab_href('autoscan', 'new'),
         ),
         MenuItem(
             'Changed',
             fugue_icon='fugue-question',
             href=self.tab_href('autoscan', 'changed'),
         ),
         MenuItem(
             'Dead',
             fugue_icon='fugue-skull',
             href=self.tab_href('autoscan', 'dead'),
         ),
         MenuItem(
             'Buried',
             fugue_icon='fugue-headstone',
             href=self.tab_href('autoscan', 'buried'),
         ),
         MenuItem(
             'All',
             fugue_icon='fugue-network-ip',
             href=self.tab_href('autoscan', 'all'),
         ),
     ]
     self.append_scan_summary_info(ret['object_list'])
     ret.update({
         'status_menu_items': status_menu_items,
         'status_selected': self.status,
         'network': self.network,
         'details': 'autoscan',
         'network_name': self.network.name if self.network else '-',
         'network_id': self.network.id,
     })
     return ret
Beispiel #32
0
def venture_tree_menu(ventures, details, show_all=False):
    items = []
    if not show_all:
        ventures = ventures.filter(show_in_ralph=True)
    for v in ventures.order_by('-is_infrastructure', 'name'):
        symbol = _normalize_venture(v.symbol)
        icon = presentation.get_venture_icon(v)
        item = MenuItem(
            v.name, name=symbol,
            fugue_icon=icon,
            view_name='ventures',
            view_args=[symbol, details, ''],
            indent = ' ',
            collapsed = True,
            collapsible = True,
        )
        item.venture_id = v.id
        item.subitems = venture_tree_menu(
                v.child_set.all(), details, show_all)
        for subitem in item.subitems:
            subitem.parent = item
        items.append(item)
    return items
Beispiel #33
0
 def _get_menu(self, tree):
     items = []
     for bl_id, bl_data in tree.iteritems():
         bl_item = MenuItem(
             label=bl_data['name'],
             name='bl_%s' % bl_id,
             fugue_icon='fugue-tie',
             view_name='services',
             view_args=['bl-%s' % bl_id],
             indent=' ',
             collapsible=True,
             collapsed=False if self.businessline_id == str(bl_id) else True
         )
         bl_item.subitems = []
         for s_id, s_data in bl_data.get('childs', {}).iteritems():
             s_item = MenuItem(
                 label=s_data['name'],
                 name='bl_%s_s_%s' % (bl_id, s_id),
                 fugue_icon='fugue-disc-share',
                 view_name='services',
                 view_args=['bl-%s' % bl_id, 'ser-%s' % s_id],
                 indent=' ',
                 collapsible=True,
                 collapsed=False if self.service_id == str(s_id) else True
             )
             s_item.subitems = []
             for e_id, e_data in s_data.get('childs', {}).iteritems():
                 e_item = MenuItem(
                     label=e_data['name'],
                     name='bl_%s_s_%s_env_%s' % (bl_id, s_id, e_id),
                     fugue_icon='fugue-tree',
                     view_name='services',
                     view_args=[
                         'bl-%s' % bl_id, 'ser-%s' % s_id, 'env-%s' % e_id
                     ],
                     indent=' '
                 )
                 e_item.parent = s_item
                 s_item.subitems.append(e_item)
             s_item.parent = bl_item
             bl_item.subitems.append(s_item)
         items.append(bl_item)
     return items