예제 #1
0
 def addPassword(self, name, title, placeholder=''):
     self[name] = M(_type='password',
                    name=name,
                    title=title,
                    placeholder=placeholder)
     self._order << name
     return self
예제 #2
0
 def add(self, title, badge=None, icon=None, cmd=None):
     self.item << M(title=title,
                    link=self.__create_link__((None, cmd)),
                    cmd=cmd,
                    icon=icon,
                    badge=badge)
     return self
예제 #3
0
 def addTextArea(self, name, title, placeholder=''):
     self[name] = M(_type='textarea',
                    name=name,
                    title=title,
                    placeholder=placeholder)
     self._order << name
     return self
예제 #4
0
 def add(self, xdata, *ydata):
     self.labels << xdata
     idx = 0
     for s in self.series:
         s << M(meta=self.lines[idx], value=ydata[idx])
         idx += 1
     return self
예제 #5
0
 def add(self, xdata, *ydata):
     record = M()
     record['tstamp'] = xdata
     idx = 0
     for line in self.lines:
         record[line] = ydata[idx]
         idx += 1
     self.data << record
     return self
예제 #6
0
 def add(self, *cols, **option):
     rec = M(cols=L(*cols))
     rec['type'] = ''' class="%s"''' % option[
         'type'] if 'type' in option else ''
     rec['link'] = self.__create_link__(
         option['link']) if 'link' in option else ''
     rec['did'] = self.__create_del__(
         option['did']) if 'did' in option else ''
     self.recs << rec
     return self
예제 #7
0
 def __init__(self, *lines, **option):
     __View__.__init__(self, 'ctst_slide', lines=L(*lines), opts=M(seriesBarDistance=5), labels=L(), series=L(), size=5, anima=False)
     if len(self.lines) > 0:
         for l in self.lines: self.series << L()
         self.add = self.__addMapped__
     else:
         self.add = self.__addLinear__
         self.opts['distributeSeries'] = True
     self._link = self.__create_link__(option['link']) if 'link' in option else ''
     self._title = '<h3 class="cw-css-elem-title">%s</h3>' % option['title'] if 'title' in option else ''
     if 'height' in option: self.opts['height'] = str(option['height']) + 'px'
예제 #8
0
 def __init__(self, chart_name, *lines, **option):
     __View__.__init__(self,
                       chart_name,
                       lines=L(*lines),
                       opts=M(),
                       data=L())
     if len(self.lines) == 0: self.lines << 'Data'
     self._link = self.__create_link__(
         option['link']) if 'link' in option else ''
     self._title = '<h3 class="cw-css-elem-title">%s</h3>' % option[
         'title'] if 'title' in option else ''
     self._height = ' style="height:%dpx"' % option[
         'height'] if 'height' in option else ''
예제 #9
0
 def __init__(self, value, min=0, max=100, **option):
     __View__.__init__(self,
                       'justgage',
                       value=value,
                       min=min,
                       max=max,
                       opts=M())
     if 'desc' in option: self.opts['title'] = option['desc']
     self._link = self.__create_link__(
         option['link']) if 'link' in option else ''
     self._title = '<h3 class="cw-css-elem-title">%s</h3>' % option[
         'title'] if 'title' in option else ''
     self._height = ' style="height:%dpx;"' % option[
         'height'] if 'height' in option else ''
예제 #10
0
 def __init__(self, *lines, **option):
     __View__.__init__(self, 'ctst_area', lines=L(*lines), opts=M(), labels=L(), series=L(), anima=False)
     for l in self.lines: self.series << L()
     self._link = self.__create_link__(option['link']) if 'link' in option else ''
     self._title = '<h3 class="cw-css-elem-title">%s</h3>' % option['title'] if 'title' in option else ''
     if 'height' in option: self.opts['height'] = str(option['height']) + 'px'
예제 #11
0
 def __init__(self, ux, **kargs):
     M.__init__(self, _ux=ux, **kargs)
예제 #12
0
 def __init__(self, **option):
     __View__.__init__(self, 'ctst_donut', opts=M(donutWidth='100%'), labels=L(), series=L())
     self._link = self.__create_link__(option['link']) if 'link' in option else ''
     self._title = '<h3 class="cw-css-elem-title">%s</h3>' % option['title'] if 'title' in option else ''
     if 'height' in option: self.opts['height'] = str(option['height']) + 'px'
예제 #13
0
 def add(self, label, value):
     self.labels << label
     self.series << M(meta=label, value=value)
     return self
예제 #14
0
 def __addLinear__(self, label, value):
     self.labels << label
     self.series << M(meta=label, value=value)
     return self
예제 #15
0
 def __init__(self, tick, icon):
     M.__init__(self, _tick=tick*1000, _icon=icon)
예제 #16
0
 def __init__(self, ux, **kargs):
     M.__init__(self, _ux=ux, **kargs)
예제 #17
0
 def add(self, label, value):
     self.data << M(label=label, value=value)
     return self
예제 #18
0
    def __load_features__(self):
        self.products = M()
        self.products['_porder'] = L()
        greg('PRODUCTS', self.products)
        for p in PRODUCT_ORDER:
            self.products._porder << p.lower()

        p_paths = Dir.showall('product/')
        for p_path in p_paths:
            if not Dir.isDir(p_path) or not Dir.isDir(p_path): continue
            p_raw = os.path.split(p_path)[-1]
            p_name = p_raw.lower()
            p_code = p_name
            p_url = '/' + p_name + '/'
            p_title = p_raw.replace('_', ' ')
            self.products[p_name] = M()
            self.products[p_name]['_name'] = p_name
            self.products[p_name]['_code'] = p_code
            self.products[p_name]['_url'] = p_url
            self.products[p_name]['_title'] = p_title

            # Add-on Feature
            features = NameSpace(p_path, inherited=nameof(Feature))
            for f_raw, f_mod in iterkv(features):
                f_name = f_raw.lower()
                f_code = p_code + '_' + f_name
                f_url = p_url + f_name + '/'
                f_title = f_raw.replace('_', ' ')

                for cls_code, cls_obj in iterkv(f_mod):
                    if classof(cls_obj, Feature) and not classof(
                            cls_obj,
                            SubFeature) and nameof(cls_obj) != nameof(Feature):
                        self.products[p_name][f_name] = cls_obj.NEW()
                        self.products[p_name][f_name]['_term'] = True
                        self.products[p_name][f_name]['_name'] = f_name
                        self.products[p_name][f_name]['_code'] = f_code
                        self.products[p_name][f_name]['_url'] = f_url
                        self.products[p_name][f_name]['_title'] = f_title
                        if cls_obj.__doc__ != None:
                            self.products[p_name][f_name][
                                '_desc'] = ' ' + cls_obj.__doc__
                        if cls_obj.__doc__ == None:
                            self.products[p_name][f_name]['_desc'] = ''
                        break

                for cls_raw, cls_obj in iterkv(f_mod):
                    if classof(cls_obj, SubFeature
                               ) and nameof(cls_obj) != nameof(SubFeature):
                        cls_name = cls_raw.lower()
                        cls_code = f_code + '_' + cls_name
                        cls_url = f_url + cls_name + '/'
                        cls_title = cls_raw.replace('_', ' ')
                        self.products[p_name][f_name]['_term'] = False
                        self.products[p_name][f_name][cls_name] = cls_obj.NEW()
                        self.products[p_name][f_name][cls_name]['_term'] = True
                        self.products[p_name][f_name][cls_name][
                            '_name'] = cls_name
                        self.products[p_name][f_name][cls_name][
                            '_code'] = cls_code
                        self.products[p_name][f_name][cls_name][
                            '_url'] = cls_url
                        self.products[p_name][f_name][cls_name][
                            '_title'] = cls_title
                        if cls_obj.__doc__ != None:
                            self.products[p_name][f_name][cls_name][
                                '_desc'] = ' ' + cls_obj.__doc__
                        if cls_obj.__doc__ == None:
                            self.products[p_name][f_name][cls_name][
                                '_desc'] = ''

            # Ordering
            order = Module(p_path + '/__init__.py')
            self.products[p_name]['_forder'] = L()
            for f in order.FEATURE_ORDER:
                if '.' in f:
                    self.products[p_name]._forder << (f.lower().split('.')[0],
                                                      f.lower().split('.')[1])
                else:
                    self.products[p_name]._forder << f.lower()

        # Dashboard
        self.products['dashboard'] = Dashboard()
        self.products.dashboard['_term'] = True
        self.products.dashboard['_name'] = 'dashboard'
        self.products.dashboard['_code'] = 'dashboard'
        self.products.dashboard['_url'] = '/dashboard/'
        self.products.dashboard['_title'] = 'Dashboard'
        self.products.dashboard['_desc'] = 'Cisco Webkit'
예제 #19
0
    def __build_template__(self):
        self.pfm = M()
        greg('PFM', self.pfm)
        pnav = ''
        fnav = ''
        page = ''

        for p_name in self.products._porder:
            if p_name in self.products:
                self.pfm[p_name] = None
                pnav += '''                <a id="cw-pnav-%s" class="cw-pnav" onclick="show_product(\'%s\');">%s</a>\n''' % (
                    p_name, p_name, self.products[p_name]._title)
                fnav += '            <ul id="cw-fnav-%s" class="nav navbar-nav side-nav cw-fnav">\n' % p_name
                now_sub = None
                for f_name in self.products[p_name]._forder:
                    if instof(f_name, tuple):
                        m_name, s_name = f_name
                        feature = self.products[p_name][m_name][s_name]
                        if now_sub != None and now_sub != m_name:
                            fnav += '''            </ul></li>
            <li id="cw-fnav-%s_%s" class="ftbar cw-fnavitem"><a href="javascript:;" data-toggle="collapse" data-target="#cw-fsnav-%s-%s" class="collapsed" aria-expanded="false"><i class="fa fa-fw %s"></i> %s <i class="fa fa-fw fa-caret-down"></i></a><ul id="cw-fsnav-%s-%s" class="collapse" aria-expanded="false">
''' % (p_name, m_name, p_name, m_name, self.products[p_name][m_name]._icon,
                            self.products[p_name][m_name]._title, p_name, m_name)
                        if now_sub == None:
                            fnav += '''            <li id="cw-fnav-%s_%s" class="ftbar cw-fnavitem"><a href="javascript:;" data-toggle="collapse" data-target="#cw-fsnav-%s-%s" class="collapsed" aria-expanded="false"><i class="fa fa-fw %s"></i> %s <i class="fa fa-fw fa-caret-down"></i></a><ul id="cw-fsnav-%s-%s" class="collapse" aria-expanded="false">
''' % (p_name, m_name, p_name, m_name, self.products[p_name][m_name]._icon,
                            self.products[p_name][m_name]._title, p_name, m_name)
                        now_sub = m_name
                        fnav += '            <li id="cw-fnav-%s_%s_%s" class="ftbar cw-fnavitem" onclick="show_feature(\'%s\',\'\');"><a><i class="fa fa-fw %s"></i> %s</a></li>' % (
                            p_name, m_name, s_name, feature._code,
                            feature._icon, feature._title)
                        page += '<div id="cw-page-%s_%s_%s" class="cw-page"></div>\n' % (
                            p_name, m_name, s_name)
                        if self.pfm[p_name] == None: self.pfm[p_name] = feature
                        self.pfm[feature._code] = feature
                    else:
                        if now_sub != None:
                            fnav += '            </ul></li>\n'
                            now_sub = None
                        feature = self.products[p_name][f_name]
                        fnav += '            <li id="cw-fnav-%s_%s" class="ftbar cw-fnavitem" onclick="show_feature(\'%s\',\'\');"><a><i class="fa fa-fw %s"></i> %s</a></li>\n' % (
                            p_name, f_name, feature._code, feature._icon,
                            feature._title)
                        page += '<div id="cw-page-%s_%s" class="cw-page"></div>\n' % (
                            p_name, f_name)
                        if self.pfm[p_name] == None: self.pfm[p_name] = feature
                        self.pfm[feature._code] = feature
                if now_sub != None:
                    fnav += '</ul></li>\n'
                fnav += '</ul>\n'
        self.pfm['dashboard'] = self.products.dashboard

        self.product_nav_tpl = Template(pnav).render(Context())
        self.feature_nav_tpl = Template(fnav).render(Context())
        self.page_html_tpl = Template(page).render(Context())

        self.page_js_products_tpl = Template(
            'var pfm = %s;' % Struct.CODE2JSON(self.pfm)).render(Context())
        self.page_js_tpl = self.ciscowebkit_js_tpl.render({
            'pfm':
            Template('var pfm = %s;' % Struct.CODE2JSON(self.pfm)).render(
                Context())
        })
        self.ciscowebkit_build = self.ciscowebkit_tpl.render({
            'cw_pnav':
            self.product_nav_tpl,
            'cw_fnav':
            self.feature_nav_tpl,
            'cw_page_html':
            self.page_html_tpl,
            'cw_page_js':
            self.page_js_tpl
        })
예제 #20
0
 def __init__(self, tick, icon):
     M.__init__(self, _tick=tick * 1000, _icon=icon)