Пример #1
0
 def presentContent(self, **kwargs: object) -> XMLContent:
     proc = cast(ScheduleIndex_GET.Processor, kwargs['proc'])
     yield makeForm(args=proc.args)[ScheduleTable.instance].present(
         **kwargs)
     if proc.finishedSchedules:
         yield xhtml.p[pageLink('DelFinishedSchedules')
                       ['Delete all finished schedules']]
Пример #2
0
 def presentForm(self,
         prefill: Optional[PageArgs], **kwargs: object
         ) -> XMLContent:
     proc = cast(ProcT, kwargs['proc'])
     return makeForm(args = prefill)[
         self.__presentFormBody(proc.user)
         ].present(**kwargs)
Пример #3
0
 def presentContent(self, **kwargs: object) -> XMLContent:
     proc = cast(FastExecute_GET.Processor, kwargs['proc'])
     configs = proc.configs
     tagged = proc.args.configId is None
     if configs:
         numJobs = sum(len(config.targets) or 1 for config in configs)
         yield xhtml.p['Create ', xhtml.b[str(numJobs), ' ',
                                          pluralize('job', numJobs)],
                       ' from the ',
                       pluralize('configuration', len(configs)),
                       ' listed below?']
         yield makeForm(args=PostArgs(
             # Args used by 'cancel':
             RefererArgs.subset(proc.args),
             # Args used by 'execute':
             confirmedId=(config.getId() for config in configs
                          )))[xhtml.p[actionButtons(Actions)]].present(
                              **kwargs)
         yield FastConfigTable.instance.present(**kwargs)
     elif tagged:
         yield (xhtml.p['No configuration matches'
                        ' tag key ', xhtml.b[proc.args.tagkey],
                        ' and value ', xhtml.b[proc.args.tagvalue],
                        '.'], self.backToReferer(proc.args))
     else:
         yield (xhtml.p['No configuration named ',
                        xhtml.b[proc.args.configId],
                        ' exists.'], self.backToReferer(proc.args))
Пример #4
0
    def presentContent(self, **kwargs: object) -> XMLContent:
        proc = cast(BatchExecute_GET.Processor, kwargs['proc'])
        for notice in proc.notices:
            yield xhtml.p(class_='notice')[notice]
        configs = proc.configs
        if configs:
            yield xhtml.h3['Selected configurations:']
            yield BatchConfigTable.instance.present(**kwargs)

            taskSet = proc.taskSet
            if taskSet is None:
                yield xhtml.p['Cannot execute because of conflict.']
            else:
                yield makeForm(args=ParentArgs.subset(proc.args))[
                    BatchInputTable.instance, submitButtons, decoration[
                        xhtml.hr, ParamTable.instance,
                        # Second set of submit buttons after parameter tables.
                        submitButtons],
                    (hiddenInput(name=f'config.{i:d}', value=cfg.getId())
                     for i, cfg in enumerate(configs)), ].present(
                         taskSet=taskSet, **kwargs)
                return
        else:
            yield xhtml.h3['No configurations selected']

        yield xhtml.p[xhtml.a(
            href=proc.args.refererURL or parentPage)['Back to Configurations']]
Пример #5
0
 def presentCell(self, record: ResourceBase,
                 **kwargs: object) -> XMLContent:
     proc = cast(PageProcessor[PageArgs], kwargs['proc'])
     action = Actions.RESUME if record.isSuspended() else Actions.SUSPEND
     return makeForm(args=PostArgs(proc.args, resource=record.getId()),
                     setFocus=False)[submitButton(name='action',
                                                  value=action)]
Пример #6
0
 def presentContent(self, **kwargs: object) -> XMLContent:
     proc = cast(TaskMatrix_GET.Processor, kwargs['proc'])
     yield makeForm(
         method='get',
         args=proc.args)[NavigationBar.instance].present(**kwargs)
     yield presentCSVLink('TaskMatrixCSV', TaskMatrixCSVArgs(proc.args))
     yield Matrix.instance.present(**kwargs)
Пример #7
0
    def presentContent(self, **kwargs: object) -> XMLContent:
        proc = cast(ConfigTagsBase.Processor[ArgsT], kwargs['proc'])
        for notice in proc.notices:
            yield xhtml.p(class_='notice')[notice]
        configs = proc.configs
        if configs:
            yield xhtml.h3['Selected Configurations:']
            yield TagConfigTable.instance.present(**kwargs)

            yield xhtml.h3['Common Selection Tags:']
            tagKeys = proc.project.getTagKeys()
            commonTags = getCommonTags(tagKeys,
                                       (config.tags for config in configs))
            yield makeForm(args=ParentArgs.subset(proc.args).override(
                sel={config.getId()
                     for config in configs}
            ))[ConfigTagValueEditTable.instance,
               xhtml.p[actionButtons(Actions)],
               (hiddenInput(name=f'commontags.{index:d}', value=tagName)
                for index, tagKey in enumerate(tagKeys)
                for tagName in commonTags[tagKey])].present(
                    getValues=lambda key: valuesToText(commonTags[key]),
                    **kwargs)
        else:
            yield (xhtml.h3['No configurations selected'],
                   xhtml.p[xhtml.a(href=proc.args.refererURL or parentPage)
                           ['Back to Configurations']])
Пример #8
0
 def present(self, **kwargs: object) -> XMLContent:
     yield makeForm(method='get',
                    formId='filters',
                    onsubmit='return checkFilters()')[xhtml.table(
                        class_='filters')[xhtml.tbody[self.presentRows(
                            **kwargs)]]].present(**kwargs)
     yield self.dateCheckScript.present(**kwargs)
Пример #9
0
 def presentContent(self, **kwargs: object) -> XMLContent:
     '''Presents this step.
     Is only called if process() returned True.
     The default implementation presents a form.
     '''
     proc = cast(DialogProcT, kwargs['proc'])
     buttons = _backAndNextButton(proc.backName, proc.nextLabel)
     return makeForm(formId='dialog',
                     action=self._page.name,
                     args=proc.args)[buttons, self._formBodyPresenter,
                                     buttons].present(**kwargs)
Пример #10
0
 def presentContent(self, **kwargs: object) -> XMLContent:
     # Ask for confirmation.
     proc = cast(FabPage.Processor[TaskIdArgs], kwargs['proc'])
     taskName = proc.args.taskName
     if taskName == '/all-waiting':
         yield xhtml.p['Abort all waiting tasks?']
     elif taskName == '/all':
         yield xhtml.p['Abort all unfinished tasks?']
     else:
         yield xhtml.p['Abort task ', xhtml.b[taskName], '?']
     yield makeForm(
         args=proc.args)[xhtml.p[actionButtons(Actions)]].present(**kwargs)
Пример #11
0
 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), ' ',
                             submitButton['Apply']].present(**kwargs)
     else:
         return role
Пример #12
0
    def presentContent(self, **kwargs: object) -> XMLContent:
        proc = cast(UserList_GET.Processor, kwargs['proc'])

        yield makeForm(
            method='get',
            formId='inactive')[FilterTable.instance].present(**kwargs)

        yield UserTable.instance.present(**kwargs)
        if proc.canChangeRoles:
            yield xhtml.p['To deny an existing user access to your SoftFab, '
                          'set the user\'s role to "inactive".']
            yield roleApplyScript.present(**kwargs)

        if proc.canChangeAnonGuest:
            yield makeForm(
                formId='anonguest',
                action='AnonGuest',
                setFocus=False,
                args=AnonGuestArgs(anonguest=proc.project.anonguest))[
                    AnonGuestTable.instance].present(**kwargs)
        else:
            yield presentAnonGuestSetting(proc.project)
Пример #13
0
def presentForm(args: MailConfigArgs, **kwargs: object) -> XMLContent:
    yield xhtml.h3['E-mail']
    if sendmail is None:
        yield xhtml.p(class_='notice')['Cannot send e-mail notifications.']
        yield xhtml.p['Notifications by e-mail require the ',
                      xhtml.code['twisted.mail'],
                      ' package, which is not installed.']
        if (twistedVersion.major, twistedVersion.minor) < (17, 5):
            yield xhtml.p[
                'The Python 3 version of ', xhtml.code['twisted.mail'],
                ' is only available since Twisted 17.5.0, '
                'while this SoftFab is currently running on Twisted ',
                twistedVersion.public(), '.']
    yield makeForm(args=args)[presentEmailForm()].present(**kwargs)
Пример #14
0
    def presentContent(self, **kwargs: object) -> XMLContent:
        proc = cast(ExtractedData_GET.Processor, kwargs['proc'])
        parentArgs = ReportTaskArgs.subset(proc.args)

        yield xhtml.p[self.presentTaskFilter(parentArgs)]
        yield xhtml.p[pageLink('ReportTasks',
                               parentArgs)['Change task filters']]

        yield makeForm(
            formId='keys',
            method='get')[KeysTable.instance, VisualizationTable.instance,
                          xhtml.p[submitButton['Apply']], ].present(**kwargs)

        yield presentCSVLink(
            'ReportTasksCSV',
            ReportTaskCSVArgs(ReportTaskArgs.subset(proc.args)))

        if len(proc.tasks) == 0:
            yield xhtml.p['No tasks match the given filters.']
        elif proc.args.vistype is VisualizationType.CHART_BAR:
            yield visualizeBarCharts(proc)
        elif proc.args.vistype is VisualizationType.TABLE:
            yield ExtractedDataTable.instance.present(**kwargs)
Пример #15
0
def presentForm(**kwargs: object) -> XMLContent:
    proc = cast(PageProcessor[PasswordSetArgs], kwargs['proc'])
    return makeForm(args=proc.args)[presentFormBody(**kwargs)].present(
        **kwargs)
Пример #16
0
 def presentContent(self, **kwargs: object) -> XMLContent:
     yield xhtml.p['Delete all finished schedules?']
     yield makeForm()[xhtml.p[actionButtons(Actions)]].present(**kwargs)
Пример #17
0
def selectDialog(formAction: str, tagCache: TagCache, filterTable: XMLContent,
                 basketTable: XMLContent, title: str,
                 **kwargs: object) -> Iterator[XML]:
    proc = cast(SelectProcMixin[BasketArgs, SelectableRecordABC],
                kwargs['proc'])
    tagKey = proc.args.tagkey
    tagValue = proc.args.tagvalue
    selected = proc.selected
    filtered = proc.filtered

    cleanedArgs = proc.args.override(sel=selected, bsk=set(), action=None)

    yield xhtml.p[f'Number of {proc.db.description}s shown: '
                  f'{len(filtered):d} of {len(proc.db):d}']

    def actionButtons() -> List[XMLContent]:
        return [
            submitButton(name='action', value=value)[label]
            for value, label, action_ in proc.iterActions()
        ]

    tagKeys = tagCache.getKeys()
    if len(tagKeys) == 0:
        yield makeForm(
            formId='selform1',
            action=formAction,
            method='get',
            args=cleanedArgs
        )[filterTable, addRemoveStyleScript, _selectScript2,
          script["window.onload = function() { RowSelection('selform1'); }"],
          xhtml.p[xhtml['\u00A0'].join(
              chain([
                  _scriptButton(True)[_selButtonLabel],
                  _scriptButton(False)[_resButtonLabel]
              ], actionButtons()))]].present(getRowStyle=lambda record: None,
                                             selectName='sel',
                                             selectFunc=lambda recordId:
                                             (recordId in selected, True),
                                             **kwargs)
        return

    def createKeyCell(key: str) -> XML:
        label = preserveSpaces(key) if key else '(show all)'
        if key == tagKey:
            return xhtml.td(class_='navthis')[label]
        else:
            return xhtml.td(class_='navother')[pageLink(
                formAction,
                cleanedArgs.override(tagkey=key, tagvalue=None,
                                     first=0))[label]]

    yield xhtml.table(
        class_='nav')[xhtml.tbody[xhtml.tr[xhtml.th['Tag Keys:'],
                                           (createKeyCell(key)
                                            for key in chain(tagKeys, ['']))]]]

    if tagKey:

        def createTagCell(value: str) -> XML:
            label = preserveSpaces(value) if value else '(undefined)'
            if value == tagValue:
                return xhtml.td(class_='navthis')[label]
            else:
                return xhtml.td(class_='navother')[pageLink(
                    formAction, cleanedArgs.override(tagvalue=value,
                                                     first=0))[label]]

        valueTable: XMLContent = xhtml.table(
            class_='nav')[xhtml.tbody[xhtml.tr[xhtml.th['Tag Values:']], (
                xhtml.tr[createTagCell(value)]
                for value in sorted(tagCache.getValues(tagKey)) + [''])]]
    else:
        valueTable = None

    def selectedDisable(recordId: str) -> Tuple[bool, bool]:
        sel = recordId in selected
        return sel, not sel

    if filtered - selected:
        buttons: List[XMLContent] = [
            _scriptButton(True)[_selButtonLabel], resetButton[_resButtonLabel],
            submitButton(name='action', value='add')
        ]
        if not selected:
            buttons += actionButtons()
        setFocus = True
    else:
        buttons = [
            disabledButton[_selButtonLabel],
            disabledButton[_resButtonLabel],
            disabledButton['Add'],
        ]
        setFocus = False

    def rowStyle(record: SelectableRecord) -> Optional[str]:
        return 'selected' if record.getId() in selected else None

    yield makeForm(
        formId='selform1',
        action=formAction,
        method='get',
        args=cleanedArgs,
        setFocus=setFocus
    )[hgroup[valueTable, filterTable], _selectScript1,
      # Store basket contents.
      # There will be checkboxes named "sel" as well; the results from the
      # active checkboxes will be merged with these hidden fields.
      (hiddenInput(name='sel', value=item) for item in selected),
      xhtml.p[xhtml['\u00A0'].join(buttons)]].present(
          getRowStyle=rowStyle,
          selectName='sel',
          selectFunc=selectedDisable,
          **kwargs)

    if selected:
        yield xhtml.hr
        yield xhtml.h2[title]
        yield xhtml.p[f'Number of {proc.db.description}s in basket: '
                      f'{len(proc.selectedRecords):d}']
        yield makeForm(
            formId='selform2',
            action=formAction,
            method='get',
            args=cleanedArgs,
            setFocus=not setFocus)[basketTable, xhtml.p[xhtml['\u00A0'].join(
                chain([
                    _scriptButton(True, 'bsk')[_selButtonLabel],
                    resetButton[_resButtonLabel],
                    submitButton(name='action', value='remove')
                ], actionButtons()))]].present(
                    getRowStyle=lambda record: 'selected',
                    selectName='bsk',
                    selectFunc=lambda recordId: (False, True),
                    **kwargs)
Пример #18
0
 def presentContent(self, **kwargs: object) -> XMLContent:
     proc = cast(RecordDelete_GET.Processor[DBRecord], kwargs['proc'])
     yield xhtml.p['Delete ', proc.recordName, ' ', xhtml.b[proc.args.id],
                   '?']
     yield makeForm(
         args=proc.args)[xhtml.p[actionButtons(Actions)]].present(**kwargs)