Exemple #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']])
 def iterRows(self, **kwargs: object) -> Iterator[XMLContent]:
     args = cast(EditProcessor[FrameworkEditArgs, Framework],
                 kwargs['proc']).args
     productDefDB: ProductDefDB = getattr(kwargs['proc'], 'productDefDB')
     name = self.argName
     options: List[XMLContent] = [emptyOption['(none)']]
     options += sorted(cast(Iterable[str], productDefDB.uniqueValues('id')))
     products: Iterable[str] = getattr(args, name)
     for prod in sorted(products) + ['']:
         yield dropDownList(name=name, selected=prod)[options],
Exemple #3
0
 def iterRows(self, **kwargs: object) -> Iterator[XMLContent]:
     taskSet = cast(TaskSetWithInputs, kwargs['taskSet'])
     grouped = taskSet.getInputsGrouped()
     localInputs = taskSet.hasLocalInputs()
     resourceDB: ResourceDB = getattr(kwargs['proc'], 'resourceDB')
     taskRunners = None
     for group, groupInputs in grouped:
         first: Optional[str] = None
         for inp in groupInputs:
             inputName = inp.getName()
             cells: List[XMLContent] = [inputName]
             prodType = inp.getType()
             local = inp.isLocal()
             locator = inp.getLocator() or ''
             if prodType is ProductType.TOKEN:
                 if local:
                     cells.append('token')
                 else:
                     # Global token: do not include this.
                     continue
             else:
                 cells.append(
                     textInput(name='prod.' + inputName,
                               value=locator,
                               size=80))
             if localInputs and first is None:
                 if local:
                     if taskRunners is None:
                         taskRunners = sorted(runner.getId(
                         ) for runner in resourceDB.iterTaskRunners(
                         ) if self.filterTaskRunner(
                             # TODO: Passing "inp" should not be needed,
                             #       but this requires non-trivial
                             #       changes in BatchExecute.
                             runner,
                             taskSet,
                             group,
                             inp))
                     cellData: XMLContent = dropDownList(
                         name='local.' + inputName,
                         selected=inp.getLocalAt() or '',
                         required=True)[emptyOption(
                             disabled=True)['(select Task Runner)'],
                                        taskRunners]
                 else:
                     cellData = '-'
                 cells.append(cell(rowspan=len(groupInputs))[cellData])
             if first is None:
                 first = inputName
             elif local:
                 cells[0] = (cells[0],
                             hiddenInput(name='lref.' + inputName,
                                         value=first))
             yield cells
Exemple #4
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='')
Exemple #5
0
 def iterRows(self, **kwargs: object) -> Iterator[XMLContent]:
     args = cast(EditProcessor[TaskEditArgs, TaskDef], kwargs['proc']).args
     frameworkDB: FrameworkDB = getattr(kwargs['proc'], 'frameworkDB')
     yield 'Task ID', args.id or '(untitled)'
     yield 'Title', textInput(name='title', size=80)
     yield 'Description', textArea(name='descr', cols=80, rows=3)
     yield 'Framework', dropDownList(
         name='framework', required=True, onchange='form.submit()'
         )[
         emptyOption(disabled=True)[ '(select framework)' ],
         sorted(frameworkDB.keys())
         ]
     yield 'Timeout', (
         textInput(name='timeout', size=4),
         'minutes; 0 means "never".'
         )
Exemple #6
0
 def iterRows(self, **kwargs: object) -> Iterator[XMLContent]:
     getValues = cast(Callable[[str], Sequence[str]], kwargs['getValues'])
     tagCache = self.getTagCache(**kwargs)
     tagKeys = tagCache.getKeys()
     for index, key in enumerate(tagKeys):
         indexStr = str(index)
         inputName = 'tagvalues.' + indexStr
         values = sorted(tagCache.getValues(key))
         yield (preserveSpaces(key),
                (hiddenInput(name='tagkeys.' + indexStr, value=key),
                 textInput(name=inputName, value=getValues(key), size=80)),
                cell(class_='taglist')[dropDownList(
                    selected='',
                    style='width: 100%',
                    onchange="AddTagValue('" + inputName +
                    "', event);")[chain([''], values)]] if values else cell)
Exemple #7
0
def executionStateBox(objectName: str) -> XMLPresentable:
    return dropDownList(name='execState',
                        style='width:20ex')[(option(
                            value=state)[f'{state.name.lower()} {objectName}']
                                             for state in ExecutionState)]
Exemple #8
0
 def iterFields(self, **kwargs: object) -> Iterator[Tuple[str, XMLContent]]:
     yield 'User name', textInput(name = 'user')
     yield 'Role', dropDownList(name = 'role')[ UIRoleNames ]
Exemple #9
0
from softfab.userlib import UserAccount, UserDB
from softfab.users import User, checkPrivilege, rolesGrantPrivilege
from softfab.userview import presentAnonGuestSetting
from softfab.webgui import pageLink, pageURL, script
from softfab.xmlgen import XML, XMLContent, xhtml


class NameColumn(DataColumn[UserAccount]):
    label = 'Name'
    keyName = 'id'

    def presentCell(self, record: UserAccount, **kwargs: object) -> XMLContent:
        return createUserDetailsLink(record.getId())


roleDropDownList = dropDownList(name='role')[UIRoleNames]


class RoleColumn(DataColumn[UserAccount]):
    label = 'Role'
    keyName = 'uirole'

    def presentCell(self, record: UserAccount, **kwargs: object) -> XMLContent:
        proc = cast(UserList_GET.Processor, kwargs['proc'])
        role = record.uiRole
        if proc.canChangeRoles:
            userName = record.getId()
            return makeForm(
                formId=f'role_{userName}', args=proc.args,
                setFocus=False)[hiddenInput(name='user', value=userName),
                                roleDropDownList(selected=role), ' ',