示例#1
0
 def iterRows(self, **kwargs: object) -> Iterator[XMLContent]:
     proc = cast(TaskMatrix_GET.Processor, kwargs['proc'])
     args = proc.args
     week = args.week
     assert isinstance(week, int)
     year = args.year
     assert isinstance(year, int)
     dateRange = proc.dateRange
     yield (cell[
         'Year: ',
         xhtml.span(class_='nobreak')[
             dateLink(args, year - 1, min(week, weeksInYear(year -
                                                            1)))['\u2190'],
             dropDownList(
                 name='year')[range(dateRange.minYear, dateRange.maxYear +
                                    1)],
             dateLink(args, year +
                      1, min(week, weeksInYear(year + 1)))['\u2192']]],
            cell['Week: ',
                 xhtml.span(class_='nobreak')[
                     dateLink(args, *normalizeWeek(year, week -
                                                   1))['\u2190'],
                     dropDownList(
                         name='week')[range(1,
                                            weeksInYear(year) + 1)],
                     dateLink(args, *normalizeWeek(year, week +
                                                   1))['\u2192']]],
            cell['Configuration: ',
                 dropDownList(name='config')[
                     emptyOption['(All - no filter)'],
                     sorted(proc.configDB.uniqueValues('name'))]],
            cell[submitButton['Apply']])
示例#2
0
    def __presentLinkButton(self, button: LinkBarButton,
                            **kwargs: object) -> XMLNode:
        iconStyle = ['navicon']
        iconModifier = button.modifier
        if iconModifier is not IconModifier.NONE:
            iconStyle.append(self.__iconModifierStyle[button.modifier])

        return xhtml.div(class_='navthis' if button.active else None)[xhtml.a(
            href=button.url)[xhtml.span(
                class_=' '.join(iconStyle))[button.icon.present(**kwargs)],
                             xhtml.span(class_='navlabel')[button.label]]]
示例#3
0
    def presentHeaderContent(self, **kwargs: object) -> XMLContent:
        table = cast(DataTable, kwargs.pop('table'))
        proc = cast(PageProcessor, kwargs['proc'])
        content = super().presentHeaderContent(**kwargs)

        # Is this a column with data attached?
        keyName = self.keyName
        if keyName is None:
            return content
        sortField = table.sortField
        if sortField is None or not proc.args.isArgument(sortField):
            return content

        # Determine index in current sort order and compute new sort order.
        sortOrder: List[str] = list(getattr(proc.args, sortField))
        index = sortOrder.index(keyName)
        del sortOrder[index]
        sortOrder.insert(0, keyName)

        override: Dict[str, object] = {sortField: sortOrder}
        tabOffsetField = table.tabOffsetField
        if tabOffsetField is not None:
            override[tabOffsetField] = 0
        return pageLink(proc.page.name, proc.args.override(**override))(
            class_='sortorder')[content, ' ',
                                xhtml.span(
                                    class_='sortorder')[f'{index + 1:d}']]
示例#4
0
 def iterRows(self, **kwargs: object) -> Iterator[XMLContent]:
     proc = cast(FabPage.Processor, kwargs['proc'])
     yield 'Up since', (formatTime(getBootTime()))
     dbVersion = proc.project.dbVersion
     yield 'Database version', (
         dbVersion if parseVersion(dbVersion)[:2]
         == parseVersion(softFabVersion)[:2] else xhtml.span(
             style='color: red')[dbVersion +
                                 ' (database must be upgraded)'])
示例#5
0
 def iterRows(self, **kwargs: object) -> Iterator[XMLContent]:
     claim = cast(ResourceClaim, kwargs['claim'])
     for spec in claim:
         ref = spec.reference
         resType = spec.typeName
         capabilities = spec.capabilities
         yield ((createCapabilityLink(resType),
                 '\u00A0'), ('as ', xhtml.span(class_='var')[ref]),
                ('\u00A0with capabilities: ',
                 presentCapabilities(capabilities, resType)))
示例#6
0
    def iterRows(self, **kwargs: object) -> Iterator[XMLContent]:
        proc = cast(PageProcessor, kwargs['proc'])
        resTypeDB: ResTypeDB = getattr(proc, 'resTypeDB')
        resWidget = dropDownList(name='type')[resTypeOptions(resTypeDB)]

        # pylint: disable=line-too-long
        reqMap: DefaultDict[str, DefaultDict[str, List[Tuple[
            bool, List[str]]]]] = defaultdict(lambda: defaultdict(list))
        #       type -> ref -> (inherited, caps)*
        parentClaim = self.__parentClaim
        if parentClaim is not None:
            for spec in parentClaim:
                ref = spec.reference
                resTypeName = spec.typeName
                reqMap[resTypeName][ref].append(
                    (True, sorted(spec.capabilities)))
        args = cast(_ResourceRequirementsArgs, proc.args)
        for ref, resTypeName, caps in zip(args.ref, args.type, args.caps):
            reqMap[resTypeName][ref].append((False, sorted(caps.split())))

        for resType in iterResourceTypes(resTypeDB):
            resTypeName = resType.getId()
            refMap = reqMap[resTypeName]

            for ref in sorted(refMap.keys()):
                capMap = dict(refMap[ref])
                inherited = True in capMap
                if inherited or resTypeName == taskRunnerResourceTypeName:
                    # Type and reference are fixed.
                    typeControl: XMLContent = (presentResTypeName(resTypeName),
                                               hiddenInput(name='type',
                                                           value=resTypeName))
                    refControl: XMLContent = (xhtml.span(class_='var')[ref],
                                              hiddenInput(name='ref',
                                                          value=ref))
                else:
                    # User can edit type and reference.
                    typeControl = resWidget(selected=resTypeName)
                    refControl = _refInput(value=ref)

                if inherited:
                    capsControl = _CapabilitiesTable.instance.present(
                        resType=resTypeName, capMap=capMap, **kwargs)
                else:
                    capsControl = _capsInput(value=' '.join(capMap[False]))

                yield typeControl, refControl, capsControl

        # Empty entry at the end.
        yield resWidget(selected=''), _refInput(value=''), _capsInput(value='')
示例#7
0
def _splitLines(
        tokens: Iterator[Tuple[TokenType, str]]) -> Iterator[XMLContent]:
    for ttype, value in tokens:
        cssclass = STANDARD_TYPES.get(ttype)
        span = xhtml.span(class_=cssclass) if cssclass else None

        first = True
        for part in value.split('\n'):
            if first:
                first = False
            else:
                yield '\n'
            if part:
                yield part if span is None else span[part]
示例#8
0
    def renderIcon(self, arg: str) -> XMLContent:
        # Parse arguments.
        iconStyle = ['navicon']
        args = arg.split()
        if len(args) == 1:
            icon, = args
        elif len(args) == 2:
            icon, modifier = args
            iconStyle.append(modifier + 'icon')
        else:
            raise ValueError(arg)

        # Determine relative URL to style resources.
        depth = 0
        resource: Optional[DocResource] = self.resource
        while resource is not None:
            resource = resource.parent
            depth += 1
        styleURL = '../' * depth + styleRoot.relativeURL

        # Render.
        yield xhtml.span(
            class_=' '.join(iconStyle))[styleRoot.addIcon(icon).present(
                styleURL=styleURL)]
示例#9
0
 def __title(self, proc: ProcT) -> XMLContent:
     return (xhtml.span(class_='project')[proc.project.name],
             xhtml.span(class_='softfab')[' SoftFab'],
             xhtml.span(class_='project')[' \u2013 '], self.pageTitle(proc))
示例#10
0
 def __presentGraph(self, name: str, **kwargs: object) -> XMLContent:
     try:
         svg = self.graphCache[name]
     except KeyError:
         svg = xhtml.span(class_='notice')['Graph rendering failed']
     return xhtml.div(class_='graph')[xhtml.div[svg]]