def _generateTimeWalker(self, dParams, tsEffective, sCurPeriod):
        """
        Generates HTML code for walking back and forth in time.
        """
        # Have to do some math here. :-/
        if tsEffective is None:
            self._oDb.execute('SELECT CURRENT_TIMESTAMP - \'' + sCurPeriod + '\'::interval');
            tsNext = None;
            tsPrev = self._oDb.fetchOne()[0];
        else:
            self._oDb.execute('SELECT %s::TIMESTAMP - \'' + sCurPeriod + '\'::interval,\n'
                              '       %s::TIMESTAMP + \'' + sCurPeriod + '\'::interval',
                              (tsEffective, tsEffective,));
            tsPrev, tsNext = self._oDb.fetchOne();

        # Forget about page No when changing a period
        if WuiDispatcherBase.ksParamPageNo in dParams:
            del dParams[WuiDispatcherBase.ksParamPageNo]

        # Format.
        dParams[WuiDispatcherBase.ksParamEffectiveDate] = str(tsPrev);
        sPrev = '<a href="?%s" title="One period earlier">&lt;&lt;</a>&nbsp;&nbsp;' \
              % (webutils.encodeUrlParams(dParams),);

        if tsNext is not None:
            dParams[WuiDispatcherBase.ksParamEffectiveDate] = str(tsNext);
            sNext = '&nbsp;&nbsp;<a href="?%s" title="One period later">&gt;&gt;</a>' \
                   % (webutils.encodeUrlParams(dParams),);
        else:
            sNext = '&nbsp;&nbsp;&gt;&gt;';

        return self._generateTimeSelector(self.getParameters(), sPrev, sNext);
    def _generateReportNavigation(self, tsEffective, cHoursPerPeriod, cPeriods):
        """ Make time navigation bar for the reports. """

        # The period length selector.
        dParams = self.getParameters();
        if WuiMain.ksParamReportPeriodInHours in dParams:
            del dParams[WuiMain.ksParamReportPeriodInHours];
        sHtmlPeriodLength  = '';
        sHtmlPeriodLength += '<form name="ReportPeriodInHoursForm" method="GET">\n' \
                             '  Period length <select name="%s" onchange="window.location=\'?%s&%s=\' + ' \
                             'this.options[this.selectedIndex].value;" title="Statistics period length in hours.">\n' \
                           % (WuiMain.ksParamReportPeriodInHours,
                              webutils.encodeUrlParams(dParams),
                              WuiMain.ksParamReportPeriodInHours)
        for cHours in [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 18, 24, 48, 72, 96, 120, 144, 168 ]:
            sHtmlPeriodLength += '    <option value="%d"%s>%d hour%s</option>\n' \
                               % (cHours, 'selected="selected"' if cHours == cHoursPerPeriod else '', cHours,
                                  's' if cHours > 1 else '');
        sHtmlPeriodLength += '  </select>\n' \
                             '</form>\n'

        # The period count selector.
        dParams = self.getParameters();
        if WuiMain.ksParamReportPeriods in dParams:
            del dParams[WuiMain.ksParamReportPeriods];
        sHtmlCountOfPeriods  = '';
        sHtmlCountOfPeriods += '<form name="ReportPeriodsForm" method="GET">\n' \
                               '  Periods <select name="%s" onchange="window.location=\'?%s&%s=\' + ' \
                               'this.options[this.selectedIndex].value;" title="Statistics periods to report.">\n' \
                             % (WuiMain.ksParamReportPeriods,
                                webutils.encodeUrlParams(dParams),
                                WuiMain.ksParamReportPeriods)
        for cCurPeriods in range(2, 43):
            sHtmlCountOfPeriods += '    <option value="%d"%s>%d</option>\n' \
                                 % (cCurPeriods, 'selected="selected"' if cCurPeriods == cPeriods else '', cCurPeriods);
        sHtmlCountOfPeriods += '  </select>\n' \
                               '</form>\n'

        # The time walker.
        sHtmlTimeWalker = self._generateTimeWalker(self.getParameters(), tsEffective, '%d hours' % (cHoursPerPeriod));

        # Combine them all.
        sHtml = '<table width=100%>\n' \
                ' <tr>\n' \
                '  <td width=30% align="center">\n' + sHtmlPeriodLength + '</td>\n' \
                '  <td width=40% align="center">\n' + sHtmlTimeWalker + '</td>' \
                '  <td width=30% align="center">\n' + sHtmlCountOfPeriods + '</td>\n' \
                ' </tr>\n' \
                '</table>\n';
        return sHtml;
예제 #3
0
    def __init__(self,
                 sName,
                 sUrlBase,
                 dParams=None,
                 sConfirm=None,
                 sTitle=None,
                 sFragmentId=None,
                 fBracketed=True,
                 sExtraAttrs=''):
        WuiHtmlBase.__init__(self)
        self.sName = sName
        self.sUrl = sUrlBase
        self.sConfirm = sConfirm
        self.sTitle = sTitle
        self.fBracketed = fBracketed
        self.sExtraAttrs = sExtraAttrs

        if dParams is not None and len(dParams) > 0:
            # Do some massaging of None arguments.
            dParams = dict(dParams)
            for sKey in dParams:
                if dParams[sKey] is None:
                    dParams[sKey] = ''
            self.sUrl += '?' + webutils.encodeUrlParams(dParams)

        if sFragmentId is not None:
            self.sUrl += '#' + sFragmentId
예제 #4
0
    def __init__(self, oSrvGlue, sScriptName):
        self._oSrvGlue          = oSrvGlue;
        self._oDb               = TMDatabaseConnection(self.dprint if config.g_kfWebUiSqlDebug else None, oSrvGlue = oSrvGlue);
        self._asCheckedParams   = [];
        self._dParams           = None;  # Set by dispatchRequest.
        self._sAction           = None;  # Set by dispatchRequest.
        self._dDispatch         = { self.ksActionDefault: self._actionDefault, };

        # Template bits.
        self._sTemplate         = 'template-default.html';
        self._sPageTitle        = '$$TODO$$';   # The page title.
        self._aaoMenus          = [];           # List of [sName, sLink, [ [sSideName, sLink], .. ] tuples.
        self._sPageBody         = '$$TODO$$';   # The body text.
        self._sRedirectTo       = None;
        self._sDebug            = '';

        # Debugger bits.
        self._fDbgSqlTrace      = False;
        self._fDbgSqlExplain    = False;
        self._dDbgParams        = dict();
        for sKey, sValue in oSrvGlue.getParameters().iteritems():
            if sKey in self.kasDbgParams:
                self._dDbgParams[sKey] = sValue;
        if len(self._dDbgParams) > 0:
            from testmanager.webui.wuicontentbase import WuiTmLink;
            WuiTmLink.kdDbgParams = self._dDbgParams;

        # Determine currently logged in user credentials
        self._oCurUser          = UserAccountLogic(self._oDb).tryFetchAccountByLoginName(oSrvGlue.getLoginName());

        # Calc a couple of URL base strings for this dispatcher.
        self._sUrlBase          = sScriptName + '?';
        if len(self._dDbgParams) > 0:
            self._sUrlBase     += webutils.encodeUrlParams(self._dDbgParams) + '&';
        self._sActionUrlBase    = self._sUrlBase + self.ksParamAction + '=';
예제 #5
0
파일: wuibase.py 프로젝트: mcenirm/vbox
    def __init__(self, oSrvGlue, sScriptName):
        self._oSrvGlue          = oSrvGlue;
        self._oDb               = TMDatabaseConnection(self.dprint if config.g_kfWebUiSqlDebug else None, oSrvGlue = oSrvGlue);
        self._asCheckedParams   = [];
        self._dParams           = None;  # Set by dispatchRequest.
        self._sAction           = None;  # Set by dispatchRequest.
        self._dDispatch         = { self.ksActionDefault: self._actionDefault, };

        # Template bits.
        self._sTemplate         = 'template-default.html';
        self._sPageTitle        = '$$TODO$$';   # The page title.
        self._aaoMenus          = [];           # List of [sName, sLink, [ [sSideName, sLink], .. ] tuples.
        self._sPageBody         = '$$TODO$$';   # The body text.
        self._sRedirectTo       = None;
        self._sDebug            = '';

        # Debugger bits.
        self._fDbgSqlTrace      = False;
        self._fDbgSqlExplain    = False;
        self._dDbgParams        = dict();
        for sKey, sValue in oSrvGlue.getParameters().iteritems():
            if sKey in self.kasDbgParams:
                self._dDbgParams[sKey] = sValue;
        if len(self._dDbgParams) > 0:
            from testmanager.webui.wuicontentbase import WuiTmLink;
            WuiTmLink.kdDbgParams = self._dDbgParams;

        # Determine currently logged in user credentials
        self._oCurUser          = UserAccountLogic(self._oDb).tryFetchAccountByLoginName(oSrvGlue.getLoginName());

        # Calc a couple of URL base strings for this dispatcher.
        self._sUrlBase          = sScriptName + '?';
        if len(self._dDbgParams) > 0:
            self._sUrlBase     += webutils.encodeUrlParams(self._dDbgParams) + '&';
        self._sActionUrlBase    = self._sUrlBase + self.ksParamAction + '=';
    def __init__(
        self,
        sName,
        sUrlBase,
        dParams=None,
        sConfirm=None,
        sTitle=None,
        sFragmentId=None,
        fBracketed=True,
        sExtraAttrs="",
    ):
        WuiHtmlBase.__init__(self)
        self.sName = sName
        self.sUrl = sUrlBase
        self.sConfirm = sConfirm
        self.sTitle = sTitle
        self.fBracketed = fBracketed
        self.sExtraAttrs = sExtraAttrs

        if dParams is not None and len(dParams) > 0:
            # Do some massaging of None arguments.
            dParams = dict(dParams)
            for sKey in dParams:
                if dParams[sKey] is None:
                    dParams[sKey] = ""
            self.sUrl += "?" + webutils.encodeUrlParams(dParams)

        if sFragmentId is not None:
            self.sUrl += "#" + sFragmentId
    def _generateItemPerPageSelector(self, dParams, cItemsPerPage):
        """
        Generate HTML code for items per page selector
        """

        if WuiDispatcherBase.ksParamItemsPerPage in dParams:
            del dParams[WuiDispatcherBase.ksParamItemsPerPage]

        # Forced reset of the page number
        dParams[WuiDispatcherBase.ksParamPageNo] = 0
        sHtmlItemsPerPageSelector  = '<form name="AgesPerPageForm" method="GET">\n' \
                                     '  Max <select name="%s" onchange="window.location=\'?%s&%s=\' + ' \
                                     'this.options[this.selectedIndex].value;" title="Max items per page">\n' \
                                   % (WuiDispatcherBase.ksParamItemsPerPage,
                                      webutils.encodeUrlParams(dParams),
                                      WuiDispatcherBase.ksParamItemsPerPage)

        aiItemsPerPage = [16, 32, 64, 128, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096];
        for iItemsPerPage in aiItemsPerPage:
            sHtmlItemsPerPageSelector += '    <option value="%d" %s>%d</option>\n' \
                                       % (iItemsPerPage,
                                          'selected="selected"' if iItemsPerPage == cItemsPerPage else '',
                                          iItemsPerPage)
        sHtmlItemsPerPageSelector += '  </select> items per page\n' \
                                     '</form>\n'

        return sHtmlItemsPerPageSelector
    def _generateGroupContentSelector(self, aoGroupMembers, iCurrentMember, sAltAction):
        """
        Generate HTML code for group content selector.
        """

        dParams = self.getParameters()

        if self.ksParamGroupMemberId in dParams:
            del dParams[self.ksParamGroupMemberId]

        if sAltAction is not None:
            if self.ksParamAction in dParams:
                del dParams[self.ksParamAction];
            dParams[self.ksParamAction] = sAltAction;

        sHtmlSelector  = '<form name="GroupContentForm" method="GET">\n'
        sHtmlSelector += '  <select name="%s" onchange="window.location=' % self.ksParamGroupMemberId
        sHtmlSelector += '\'?%s&%s=\' + ' % (webutils.encodeUrlParams(dParams), self.ksParamGroupMemberId)
        sHtmlSelector += 'this.options[this.selectedIndex].value;">\n'

        sHtmlSelector += '<option value="-1">All</option>\n'

        for iGroupMemberId, sGroupMemberName in aoGroupMembers:
            if iGroupMemberId is not None:
                sHtmlSelector += '    <option value="%s"%s>%s</option>\n' \
                                    % (iGroupMemberId,
                                       ' selected="selected"' if iGroupMemberId == iCurrentMember else '',
                                       sGroupMemberName)

        sHtmlSelector += '  </select>\n' \
                         '</form>\n'

        return sHtmlSelector
    def _generateResultPeriodSelector(self, dParams, sCurPeriod):
        """
        Generate HTML code for result period selector.
        """

        if self.ksParamEffectivePeriod in dParams:
            del dParams[self.ksParamEffectivePeriod];

        # Forget about page No when changing a period
        if WuiDispatcherBase.ksParamPageNo in dParams:
            del dParams[WuiDispatcherBase.ksParamPageNo]

        sHtmlPeriodSelector  = '<form name="PeriodForm" method="GET">\n'
        sHtmlPeriodSelector += '  Period is\n'
        sHtmlPeriodSelector += '  <select name="%s" onchange="window.location=' % self.ksParamEffectivePeriod
        sHtmlPeriodSelector += '\'?%s&%s=\' + ' % (webutils.encodeUrlParams(dParams), self.ksParamEffectivePeriod)
        sHtmlPeriodSelector += 'this.options[this.selectedIndex].value;">\n'

        for sPeriodValue, sPeriodCaption, _ in self.kaoResultPeriods:
            sHtmlPeriodSelector += '    <option value="%s"%s>%s</option>\n' \
                                % (webutils.quoteUrl(sPeriodValue),
                                   ' selected="selected"' if sPeriodValue == sCurPeriod else '',
                                   sPeriodCaption)

        sHtmlPeriodSelector += '  </select>\n' \
                               '</form>\n'

        return sHtmlPeriodSelector
예제 #10
0
    def _actionGenericFormEditPost(self,
                                   oDataType,
                                   oLogicType,
                                   oFormType,
                                   sRedirAction,
                                   fStrict=True):
        """
        Generic edit POST request handling from a WuiFormContentBase child.

        oDataType is a ModelDataBase child class.
        oLogicType is a class that implements addEntry.
        oFormType is a WuiFormContentBase child class.
        sRedirAction is what action to redirect to on success.
        """
        assert issubclass(oDataType, ModelDataBase)
        assert issubclass(oLogicType, ModelLogicBase)
        from testmanager.webui.wuicontentbase import WuiFormContentBase
        assert issubclass(oFormType, WuiFormContentBase)

        oLogic = oLogicType(self._oDb)
        return self._actionGenericFormPost(
            WuiFormContentBase.ksMode_Edit,
            oLogic.editEntry,
            oDataType,
            oFormType,
            '?' + webutils.encodeUrlParams({self.ksParamAction: sRedirAction}),
            fStrict=fStrict)
    def _generatePagesSelector(self, dParams, cItems, cItemsPerPage, iPage):
        """
        Generate HTML code for pages (1, 2, 3 ... N) selector
        """

        if WuiDispatcherBase.ksParamPageNo in dParams:
            del dParams[WuiDispatcherBase.ksParamPageNo]

        sHrefPtr    = '<a href="?%s&%s=' % (webutils.encodeUrlParams(dParams).replace('%', '%%'),
                                            WuiDispatcherBase.ksParamPageNo)
        sHrefPtr   += '%d">%s</a>'

        cNumOfPages      = (cItems + cItemsPerPage - 1) / cItemsPerPage;
        cPagesToDisplay  = 10
        cPagesRangeStart = iPage - cPagesToDisplay / 2 \
                           if not iPage - cPagesToDisplay / 2 < 0 else 0
        cPagesRangeEnd   = cPagesRangeStart + cPagesToDisplay \
                           if not cPagesRangeStart + cPagesToDisplay > cNumOfPages else cNumOfPages
        # Adjust pages range
        if cNumOfPages < cPagesToDisplay:
            cPagesRangeStart = 0
            cPagesRangeEnd   = cNumOfPages

        # 1 2 3 4...
        sHtmlPager  = '&nbsp;\n'.join(sHrefPtr % (x, str(x + 1)) if x != iPage else str(x + 1)
                                      for x in range(cPagesRangeStart, cPagesRangeEnd))
        if cPagesRangeStart > 0:
            sHtmlPager = '%s&nbsp; ... &nbsp;\n' % (sHrefPtr % (0, str(1))) + sHtmlPager
        if cPagesRangeEnd < cNumOfPages:
            sHtmlPager += ' ... %s\n' % (sHrefPtr % (cNumOfPages, str(cNumOfPages + 1)))

        # Prev/Next (using << >> because &laquo; and &raquo are too tiny).
        if iPage > 0:
            dParams[WuiDispatcherBase.ksParamPageNo] = iPage - 1
            sHtmlPager = ('<a title="Previous page" href="?%s">&lt;&lt;</a>&nbsp;&nbsp;\n'
                          % (webutils.encodeUrlParams(dParams), )) \
                          + sHtmlPager;
        else:
            sHtmlPager = '&lt;&lt;&nbsp;&nbsp;\n' + sHtmlPager

        if iPage + 1 < cNumOfPages:
            dParams[WuiDispatcherBase.ksParamPageNo] = iPage + 1
            sHtmlPager += '\n&nbsp; <a title="Next page" href="?%s">&gt;&gt;</a>\n' % (webutils.encodeUrlParams(dParams),)
        else:
            sHtmlPager += '\n&nbsp; &gt;&gt;\n'

        return sHtmlPager
예제 #12
0
    def _generateNavigation(self, sWhere):
        """
        Return HTML for navigation.
        """

        #
        # ASSUMES the dispatcher/controller code fetches one entry more than
        # needed to fill the page to indicate further records.
        #
        sNavigation = '<div class="tmlistnav-%s">\n' % sWhere
        sNavigation += '  <table class="tmlistnavtab">\n' \
                       '    <tr>\n'
        dParams = self._oDisp.getParameters()
        dParams[WuiDispatcherBase.ksParamItemsPerPage] = self._cItemsPerPage
        dParams[WuiDispatcherBase.ksParamPageNo] = self._iPage
        if self._tsEffectiveDate is not None:
            dParams[
                WuiDispatcherBase.ksParamEffectiveDate] = self._tsEffectiveDate

        # Prev
        if self._iPage > 0:
            dParams[WuiDispatcherBase.ksParamPageNo] = self._iPage - 1
            sNavigation += '    <td align="left"><a href="?%s">Previous</a></td>\n' % (
                webutils.encodeUrlParams(dParams), )
        else:
            sNavigation += '      <td></td>\n'

        # Time scale.
        sNavigation += '<td align="center" class="tmtimenav">'
        sNavigation += self._generateTimeNavigation(sWhere)
        sNavigation += '</td>'

        # Next
        if len(self._aoEntries) > self._cItemsPerPage:
            dParams[WuiDispatcherBase.ksParamPageNo] = self._iPage + 1
            sNavigation += '    <td align="right"><a href="?%s">Next</a></td>\n' % (
                webutils.encodeUrlParams(dParams), )
        else:
            sNavigation += '      <td></td>\n'

        sNavigation += '    </tr>\n' \
                       '  </table>\n' \
                       '</div>\n'
        return sNavigation
예제 #13
0
    def showForm(self, dErrors=None, sErrorMsg=None):
        """
        Render the form.
        """
        oForm = WuiHlpForm(
            self._sId,
            '?' + webutils.encodeUrlParams(
                {WuiDispatcherBase.ksParamAction: self._sSubmitAction}),
            dErrors if dErrors is not None else dict(),
            fReadOnly=self._sMode == self.ksMode_Show)

        self._oData.convertToParamNull()

        # If form cannot be constructed due to some reason we
        # need to show this reason
        try:
            self._populateForm(oForm, self._oData)
            if self._sRedirectTo is not None:
                oForm.addTextHidden(self._oDisp.ksParamRedirectTo,
                                    self._sRedirectTo)
        except WuiException as oXcpt:
            sContent = unicode(oXcpt)
        else:
            sContent = oForm.finalize()

        # Add any post form content.
        atPostFormContent = self._generatePostFormContent(self._oData)
        if atPostFormContent:
            for iSection, tSection in enumerate(atPostFormContent):
                (sSectionTitle, sSectionContent) = tSection
                sContent += u'<div id="postform-%d"  class="tmformpostsection">\n' % (
                    iSection, )
                if sSectionTitle:
                    sContent += '<h3 class="tmformpostheader">%s</h3>\n' % (
                        webutils.escapeElem(sSectionTitle), )
                sContent += u' <div id="postform-%d-content" class="tmformpostcontent">\n' % (
                    iSection, )
                sContent += sSectionContent
                sContent += u' </div>\n' \
                            u'</div>\n'

        # Add action to the top.
        aoActions = self._generateTopRowFormActions(self._oData)
        if aoActions:
            sActionLinks = '<p>%s</p>' % (' '.join(
                unicode(oLink) for oLink in aoActions))
            sContent = sActionLinks + sContent

        # Add error info to the top.
        if sErrorMsg is not None:
            sContent = '<p class="tmerrormsg">' + webutils.escapeElem(
                sErrorMsg) + '</p>\n' + sContent

        return (self._sTitle, sContent)
    def _generateNavigation(self, sWhere):
        """
        Return HTML for navigation.
        """

        #
        # ASSUMES the dispatcher/controller code fetches one entry more than
        # needed to fill the page to indicate further records.
        #
        sNavigation = '<div class="tmlistnav-%s">\n' % sWhere
        sNavigation += '  <table class="tmlistnavtab">\n' "    <tr>\n"
        dParams = self._oDisp.getParameters()
        dParams[WuiDispatcherBase.ksParamItemsPerPage] = self._cItemsPerPage
        dParams[WuiDispatcherBase.ksParamPageNo] = self._iPage
        if self._tsEffectiveDate is not None:
            dParams[WuiDispatcherBase.ksParamEffectiveDate] = self._tsEffectiveDate

        # Prev
        if self._iPage > 0:
            dParams[WuiDispatcherBase.ksParamPageNo] = self._iPage - 1
            sNavigation += '    <td align="left"><a href="?%s">Previous</a></td>\n' % (
                webutils.encodeUrlParams(dParams),
            )
        else:
            sNavigation += "      <td></td>\n"

        # Time scale.
        sNavigation += '<td align="center" class="tmtimenav">'
        sNavigation += self._generateTimeNavigation(sWhere)
        sNavigation += "</td>"

        # Next
        if len(self._aoEntries) > self._cItemsPerPage:
            dParams[WuiDispatcherBase.ksParamPageNo] = self._iPage + 1
            sNavigation += '    <td align="right"><a href="?%s">Next</a></td>\n' % (webutils.encodeUrlParams(dParams),)
        else:
            sNavigation += "      <td></td>\n"

        sNavigation += "    </tr>\n" "  </table>\n" "</div>\n"
        return sNavigation
예제 #15
0
파일: wuibase.py 프로젝트: mcenirm/vbox
    def _actionGenericFormAddPost(self, oDataType, oLogicType, oFormType, sRedirAction, fStrict=True):
        """
        Generic add entry POST request handling from a WuiFormContentBase child.

        oDataType is a ModelDataBase child class.
        oLogicType is a class that implements addEntry.
        oFormType is a WuiFormContentBase child class.
        sRedirAction is what action to redirect to on success.
        """
        oLogic = oLogicType(self._oDb);
        from testmanager.webui.wuicontentbase import WuiFormContentBase;
        return self._actionGenericFormPost(WuiFormContentBase.ksMode_Add, oLogic.addEntry, oDataType, oFormType,
                                           '?' + webutils.encodeUrlParams({self.ksParamAction: sRedirAction}), fStrict=fStrict)
예제 #16
0
    def _actionGenericFormAddPost(self, oDataType, oLogicType, oFormType, sRedirAction, fStrict=True):
        """
        Generic add entry POST request handling from a WuiFormContentBase child.

        oDataType is a ModelDataBase child class.
        oLogicType is a class that implements addEntry.
        oFormType is a WuiFormContentBase child class.
        sRedirAction is what action to redirect to on success.
        """
        oLogic = oLogicType(self._oDb);
        from testmanager.webui.wuicontentbase import WuiFormContentBase;
        return self._actionGenericFormPost(WuiFormContentBase.ksMode_Add, oLogic.addEntry, oDataType, oFormType,
                                           '?' + webutils.encodeUrlParams({self.ksParamAction: sRedirAction}), fStrict=fStrict)
    def showForm(self, dErrors = None, sErrorMsg = None):
        """
        Render the form.
        """
        oForm = WuiHlpForm(self._sId,
                           '?' + webutils.encodeUrlParams({WuiDispatcherBase.ksParamAction: self._sSubmitAction}),
                           dErrors if dErrors is not None else dict(),
                           fReadOnly = self._sMode == self.ksMode_Show);

        self._oData.convertToParamNull();

        # If form cannot be constructed due to some reason we
        # need to show this reason
        try:
            self._populateForm(oForm, self._oData);
            if self._sRedirectTo is not None:
                oForm.addTextHidden(self._oDisp.ksParamRedirectTo, self._sRedirectTo);
        except WuiException as oXcpt:
            sContent = unicode(oXcpt)
        else:
            sContent = oForm.finalize();

        # Add any post form content.
        atPostFormContent = self._generatePostFormContent(self._oData);
        if atPostFormContent:
            for iSection, tSection in enumerate(atPostFormContent):
                (sSectionTitle, sSectionContent) = tSection;
                sContent += u'<div id="postform-%d"  class="tmformpostsection">\n' % (iSection,);
                if sSectionTitle:
                    sContent += '<h3 class="tmformpostheader">%s</h3>\n' % (webutils.escapeElem(sSectionTitle),);
                sContent += u' <div id="postform-%d-content" class="tmformpostcontent">\n' % (iSection,);
                sContent += sSectionContent;
                sContent += u' </div>\n' \
                            u'</div>\n';

        # Add action to the top.
        aoActions = self._generateTopRowFormActions(self._oData);
        if aoActions:
            sActionLinks = '<p>%s</p>' % (' '.join(unicode(oLink) for oLink in aoActions));
            sContent = sActionLinks + sContent;

        # Add error info to the top.
        if sErrorMsg is not None:
            sContent = '<p class="tmerrormsg">' + webutils.escapeElem(sErrorMsg) + '</p>\n' + sContent;

        return (self._sTitle, sContent);
예제 #18
0
    def showForm(self, dErrors = None, sErrorMsg = None):
        """
        Render the form.
        """
        oForm = WuiHlpForm(self._sId,
                           '?' + webutils.encodeUrlParams({WuiDispatcherBase.ksParamAction: self._sSubmitAction}),
                           dErrors if dErrors is not None else dict(),
                           fReadOnly = self._sMode == self.ksMode_Show);

        self._oData.convertToParamNull();

        # If form cannot be constructed due to some reason we
        # need to show this reason
        try:
            self._populateForm(oForm, self._oData);
        except WuiException, oXcpt:
            sContent = unicode(oXcpt)
    def show(self, fShowNavigation=True):
        """
        Displays the list.
        Returns (Title, HTML) on success, raises exception on error.
        """
        assert self._aoActions is not None
        assert self._sAction is not None

        sPageBody = (
            '<script language="JavaScript">\n'
            "function toggle%s(oSource) {\n"
            "    aoCheckboxes = document.getElementsByName('%s');\n"
            "    for(var i in aoCheckboxes)\n"
            "        aoCheckboxes[i].checked = oSource.checked;\n"
            "}\n"
            "</script>\n" % ("" if self._sId is None else self._sId, self._sCheckboxName)
        )
        if fShowNavigation:
            sPageBody += self._generateNavigation("top")
        if len(self._aoEntries) > 0:

            sPageBody += '<form action="?%s" method="post" class="tmlistactionform">\n' % (
                webutils.encodeUrlParams({WuiDispatcherBase.ksParamAction: self._sAction}),
            )
            sPageBody += self._generateTable()

            sPageBody += (
                "  <label>Actions</label>\n"
                '  <select name="%s" id="%s-action-combo" class="tmlistactionform-combo">\n'
                % (webutils.escapeAttr(WuiDispatcherBase.ksParamListAction), webutils.escapeAttr(self._sId))
            )
            for oValue, sText, _ in self._aoActions:
                sPageBody += '    <option value="%s">%s</option>\n' % (
                    webutils.escapeAttr(unicode(oValue)),
                    webutils.escapeElem(sText),
                )
            sPageBody += "  </select>\n"
            sPageBody += '  <input type="submit"></input>\n'
            sPageBody += "</form>\n"
            if fShowNavigation:
                sPageBody += self._generateNavigation("bottom")
        else:
            sPageBody += "<p>No entries.</p>"

        return (self._composeTitle(), sPageBody)
예제 #20
0
    def showForm(self, dErrors=None, sErrorMsg=None):
        """
        Render the form.
        """
        oForm = WuiHlpForm(
            self._sId,
            '?' + webutils.encodeUrlParams(
                {WuiDispatcherBase.ksParamAction: self._sSubmitAction}),
            dErrors if dErrors is not None else dict(),
            fReadOnly=self._sMode == self.ksMode_Show)

        self._oData.convertToParamNull()

        # If form cannot be constructed due to some reason we
        # need to show this reason
        try:
            self._populateForm(oForm, self._oData)
        except WuiException, oXcpt:
            sContent = unicode(oXcpt)
    def __init__(self, sName, sUrlBase, dParams = None, sConfirm = None, sTitle = None,
                 sFragmentId = None, fBracketed = True, sExtraAttrs = ''):
        WuiHtmlBase.__init__(self);
        self.sName          = sName
        self.sUrl           = sUrlBase
        self.sConfirm       = sConfirm;
        self.sTitle         = sTitle;
        self.fBracketed     = fBracketed;
        self.sExtraAttrs    = sExtraAttrs;

        if dParams:
            # Do some massaging of None arguments.
            dParams = dict(dParams);
            for sKey in dParams:
                if dParams[sKey] is None:
                    dParams[sKey] = '';
            self.sUrl += '?' + webutils.encodeUrlParams(dParams);

        if sFragmentId is not None:
            self.sUrl += '#' + sFragmentId;
예제 #22
0
    def flush(self):
        """
        Flush the output.
        """
        self.flushHeader()

        if self._sBodyType == 'form':
            sBody = webutils.encodeUrlParams(self._dParams)
            self._writeWorker(sBody)

            self._dParams = dict()
            self._cchBodyWrittenOut += self._cchCached

        elif self._sBodyType == 'html':
            self._writeWorker(self._sHtmlBody)

            self._sHtmlBody = ''
            self._cchBodyWrittenOut += self._cchCached

        self._cchCached = 0
        return None
예제 #23
0
    def flush(self):
        """
        Flush the output.
        """
        self.flushHeader();

        if self._sBodyType == 'form':
            sBody = webutils.encodeUrlParams(self._dParams);
            self._writeWorker(sBody);

            self._dParams = dict();
            self._cchBodyWrittenOut += self._cchCached;

        elif self._sBodyType == 'html':
            self._writeWorker(self._sHtmlBody);

            self._sHtmlBody = '';
            self._cchBodyWrittenOut += self._cchCached;

        self._cchCached = 0;
        return None;
예제 #24
0
    def show(self, fShowNavigation=True):
        """
        Displays the list.
        Returns (Title, HTML) on success, raises exception on error.
        """
        assert self._aoActions is not None
        assert self._sAction is not None

        sPageBody = '<script language="JavaScript">\n' \
                    'function toggle%s(oSource) {\n' \
                    '    aoCheckboxes = document.getElementsByName(\'%s\');\n' \
                    '    for(var i in aoCheckboxes)\n' \
                    '        aoCheckboxes[i].checked = oSource.checked;\n' \
                    '}\n' \
                    '</script>\n' \
                    % ('' if self._sId is None else self._sId, self._sCheckboxName,)
        if fShowNavigation:
            sPageBody += self._generateNavigation('top')
        if len(self._aoEntries) > 0:

            sPageBody += '<form action="?%s" method="post" class="tmlistactionform">\n' \
                       % (webutils.encodeUrlParams({WuiDispatcherBase.ksParamAction: self._sAction,}),)
            sPageBody += self._generateTable()

            sPageBody += '  <label>Actions</label>\n' \
                         '  <select name="%s" id="%s-action-combo" class="tmlistactionform-combo">\n' \
                       % (webutils.escapeAttr(WuiDispatcherBase.ksParamListAction), webutils.escapeAttr(self._sId),)
            for oValue, sText, _ in self._aoActions:
                sPageBody += '    <option value="%s">%s</option>\n' \
                           % (webutils.escapeAttr(unicode(oValue)), webutils.escapeElem(sText), )
            sPageBody += '  </select>\n'
            sPageBody += '  <input type="submit"></input>\n'
            sPageBody += '</form>\n'
            if fShowNavigation:
                sPageBody += self._generateNavigation('bottom')
        else:
            sPageBody += '<p>No entries.</p>'

        return (self._composeTitle(), sPageBody)
예제 #25
0
    def _recursivelyGenerateEvents(self, oTestResult, sParentName, sLineage, iRow,
                                   iFailure, oTestSet, iDepth):     # pylint: disable=R0914
        """
        Recursively generate event table rows for the result set.

        oTestResult is an object of the type TestResultDataEx.
        """
        # Hack: Replace empty outer test result name with (pretty) command line.
        if iRow == 1:
            sName = '';
            sDisplayName = sParentName;
        else:
            sName = oTestResult.sName if sParentName == '' else '%s, %s' % (sParentName, oTestResult.sName,);
            sDisplayName = webutils.escapeElem(sName);

        # Format error count.
        sErrCnt = '';
        if oTestResult.cErrors > 0:
            sErrCnt = ' (1 error)' if oTestResult.cErrors == 1 else ' (%d errors)' % oTestResult.cErrors;

        # Format bits for adding or editing the failure reason.  Level 0 is handled at the top of the page.
        sChangeReason = '';
        if oTestResult.cErrors > 0 and iDepth > 0:
            dTmp = {
                self._oDisp.ksParamAction: self._oDisp.ksActionTestResultFailureAdd if oTestResult.oReason is None else
                                           self._oDisp.ksActionTestResultFailureEdit,
                TestResultFailureData.ksParam_idTestResult: oTestResult.idTestResult,
            };
            sChangeReason = ' <a href="?%s" class="tmtbl-edit-reason" onclick="addRedirectToAnchorHref(this)">%s</a> ' \
                          % ( webutils.encodeUrlParams(dTmp), WuiContentBase.ksShortEditLinkHtml );

        # Format the include in graph checkboxes.
        sLineage += ':%u' % (oTestResult.idStrName,);
        sResultGraph  = '<input type="checkbox" name="%s" value="%s%s" title="Include result in graph."/>' \
                      % (WuiMain.ksParamReportSubjectIds, ReportGraphModel.ksTypeResult, sLineage,);
        sElapsedGraph = '';
        if oTestResult.tsElapsed is not None:
            sElapsedGraph = '<input type="checkbox" name="%s" value="%s%s" title="Include elapsed time in graph."/>' \
                          % ( WuiMain.ksParamReportSubjectIds, ReportGraphModel.ksTypeElapsed, sLineage);


        if    len(oTestResult.aoChildren) == 0 \
          and len(oTestResult.aoValues) + len(oTestResult.aoMsgs) + len(oTestResult.aoFiles) == 0:
            # Leaf - single row.
            tsEvent = oTestResult.tsCreated;
            if oTestResult.tsElapsed is not None:
                tsEvent += oTestResult.tsElapsed;
            sHtml  = ' <tr class="%s tmtbl-events-leaf tmtbl-events-lvl%s tmstatusrow-%s" id="S%u">\n' \
                     '  <td id="E%u">%s</td>\n' \
                     '  <td>%s</td>\n' \
                     '  <td>%s</td>\n' \
                     '  <td>%s</td>\n' \
                     '  <td colspan="2"%s>%s%s%s</td>\n' \
                     '  <td>%s</td>\n' \
                     ' </tr>\n' \
                   % ( 'tmodd' if iRow & 1 else 'tmeven', iDepth, oTestResult.enmStatus, oTestResult.idTestResult,
                       oTestResult.idTestResult,
                       self._formatEventTimestampHtml(tsEvent, oTestResult.tsCreated, oTestResult.idTestResult, oTestSet),
                       sElapsedGraph,
                       webutils.escapeElem(self.formatIntervalShort(oTestResult.tsElapsed)) if oTestResult.tsElapsed is not None
                                           else '',
                       sDisplayName,
                       ' id="failure-%u"' % (iFailure,) if oTestResult.isFailure() else '',
                       webutils.escapeElem(oTestResult.enmStatus), webutils.escapeElem(sErrCnt),
                       sChangeReason if oTestResult.oReason is None else '',
                       sResultGraph );
            iRow += 1;
        else:
            # Multiple rows.
            sHtml  = ' <tr class="%s tmtbl-events-first tmtbl-events-lvl%s ">\n' \
                     '  <td>%s</td>\n' \
                     '  <td></td>\n' \
                     '  <td></td>\n' \
                     '  <td>%s</td>\n' \
                     '  <td colspan="2">%s</td>\n' \
                     '  <td></td>\n' \
                     ' </tr>\n' \
                   % ( 'tmodd' if iRow & 1 else 'tmeven', iDepth,
                       self._formatEventTimestampHtml(oTestResult.tsCreated, oTestResult.tsCreated,
                                                      oTestResult.idTestResult, oTestSet),
                       sDisplayName,
                       'running' if oTestResult.tsElapsed is None else '', );
            iRow += 1;

            # Depth. Check if our error count is just reflecting the one of our children.
            cErrorsBelow = 0;
            for oChild in oTestResult.aoChildren:
                (sChildHtml, iRow, iFailure) = self._recursivelyGenerateEvents(oChild, sName, sLineage,
                                                                               iRow, iFailure, oTestSet, iDepth + 1);
                sHtml += sChildHtml;
                cErrorsBelow += oChild.cErrors;

            # Messages.
            for oMsg in oTestResult.aoMsgs:
                sHtml += ' <tr class="%s tmtbl-events-message tmtbl-events-lvl%s">\n' \
                         '  <td>%s</td>\n' \
                         '  <td></td>\n' \
                         '  <td></td>\n' \
                         '  <td colspan="3">%s: %s</td>\n' \
                         '  <td></td>\n' \
                         ' </tr>\n' \
                       % ( 'tmodd' if iRow & 1 else 'tmeven', iDepth,
                           self._formatEventTimestampHtml(oMsg.tsCreated, oMsg.tsCreated, oMsg.idTestResultMsg, oTestSet),
                           webutils.escapeElem(oMsg.enmLevel),
                           webutils.escapeElem(oMsg.sMsg), );
                iRow += 1;

            # Values.
            for oValue in oTestResult.aoValues:
                sHtml += ' <tr class="%s tmtbl-events-value tmtbl-events-lvl%s">\n' \
                         '  <td>%s</td>\n' \
                         '  <td></td>\n' \
                         '  <td></td>\n' \
                         '  <td>%s</td>\n' \
                         '  <td class="tmtbl-events-number">%s</td>\n' \
                         '  <td class="tmtbl-events-unit">%s</td>\n' \
                         '  <td><input type="checkbox" name="%s" value="%s%s:%u" title="Include value in graph."></td>\n' \
                         ' </tr>\n' \
                       % ( 'tmodd' if iRow & 1 else 'tmeven', iDepth,
                           self._formatEventTimestampHtml(oValue.tsCreated, oValue.tsCreated, oValue.idTestResultValue, oTestSet),
                           webutils.escapeElem(oValue.sName),
                           utils.formatNumber(oValue.lValue).replace(' ', '&nbsp;'),
                           webutils.escapeElem(oValue.sUnit),
                           WuiMain.ksParamReportSubjectIds, ReportGraphModel.ksTypeValue, sLineage, oValue.idStrName, );
                iRow += 1;

            # Files.
            for oFile in oTestResult.aoFiles:
                if oFile.sMime in [ 'text/plain', ]:
                    aoLinks = [
                        WuiTmLink('%s (%s)' % (oFile.sFile, oFile.sKind), '',
                                  { self._oDisp.ksParamAction:        self._oDisp.ksActionViewLog,
                                    self._oDisp.ksParamLogSetId:      oTestSet.idTestSet,
                                    self._oDisp.ksParamLogFileId:     oFile.idTestResultFile, },
                                  sTitle = oFile.sDescription),
                        WuiTmLink('View Raw', '',
                                  { self._oDisp.ksParamAction:        self._oDisp.ksActionGetFile,
                                    self._oDisp.ksParamGetFileSetId:  oTestSet.idTestSet,
                                    self._oDisp.ksParamGetFileId:     oFile.idTestResultFile,
                                    self._oDisp.ksParamGetFileDownloadIt: False, },
                                  sTitle = oFile.sDescription),
                    ]
                else:
                    aoLinks = [
                        WuiTmLink('%s (%s)' % (oFile.sFile, oFile.sKind), '',
                                  { self._oDisp.ksParamAction:        self._oDisp.ksActionGetFile,
                                    self._oDisp.ksParamGetFileSetId:  oTestSet.idTestSet,
                                    self._oDisp.ksParamGetFileId:     oFile.idTestResultFile,
                                    self._oDisp.ksParamGetFileDownloadIt: False, },
                                  sTitle = oFile.sDescription),
                    ]
                aoLinks.append(WuiTmLink('Download', '',
                                         { self._oDisp.ksParamAction:        self._oDisp.ksActionGetFile,
                                           self._oDisp.ksParamGetFileSetId:  oTestSet.idTestSet,
                                           self._oDisp.ksParamGetFileId:     oFile.idTestResultFile,
                                           self._oDisp.ksParamGetFileDownloadIt: True, },
                                         sTitle = oFile.sDescription));

                sHtml += ' <tr class="%s tmtbl-events-file tmtbl-events-lvl%s">\n' \
                         '  <td>%s</td>\n' \
                         '  <td></td>\n' \
                         '  <td></td>\n' \
                         '  <td>%s</td>\n' \
                         '  <td></td>\n' \
                         '  <td></td>\n' \
                         '  <td></td>\n' \
                         ' </tr>\n' \
                       % ( 'tmodd' if iRow & 1 else 'tmeven', iDepth,
                           self._formatEventTimestampHtml(oFile.tsCreated, oFile.tsCreated, oFile.idTestResultFile, oTestSet),
                           '\n'.join(oLink.toHtml() for oLink in aoLinks),);
                iRow += 1;

            # Done?
            if oTestResult.tsElapsed is not None:
                tsEvent = oTestResult.tsCreated + oTestResult.tsElapsed;
                sHtml += ' <tr class="%s tmtbl-events-final tmtbl-events-lvl%s tmstatusrow-%s" id="E%d">\n' \
                         '  <td>%s</td>\n' \
                         '  <td>%s</td>\n' \
                         '  <td>%s</td>\n' \
                         '  <td>%s</td>\n' \
                         '  <td colspan="2"%s>%s%s%s</td>\n' \
                         '  <td>%s</td>\n' \
                         ' </tr>\n' \
                       % ( 'tmodd' if iRow & 1 else 'tmeven', iDepth, oTestResult.enmStatus, oTestResult.idTestResult,
                           self._formatEventTimestampHtml(tsEvent, tsEvent, oTestResult.idTestResult, oTestSet),
                           sElapsedGraph,
                           webutils.escapeElem(self.formatIntervalShort(oTestResult.tsElapsed)),
                           sDisplayName,
                           ' id="failure-%u"' % (iFailure,) if oTestResult.isFailure() else '',
                           webutils.escapeElem(oTestResult.enmStatus), webutils.escapeElem(sErrCnt),
                           sChangeReason if cErrorsBelow < oTestResult.cErrors and oTestResult.oReason is None else '',
                           sResultGraph);
                iRow += 1;

        # Failure reason.
        if oTestResult.oReason is not None:
            sReasonText = '%s / %s' % ( oTestResult.oReason.oFailureReason.oCategory.sShort,
                                        oTestResult.oReason.oFailureReason.sShort, );
            sCommentHtml = '';
            if oTestResult.oReason.sComment is not None and len(oTestResult.oReason.sComment.strip()) > 0:
                sCommentHtml = '<br>' + webutils.escapeElem(oTestResult.oReason.sComment.strip());
                sCommentHtml = sCommentHtml.replace('\n', '<br>');

            sDetailedReason = ' <a href="?%s" class="tmtbl-show-reason">%s</a>' \
                            % ( webutils.encodeUrlParams({ self._oDisp.ksParamAction:
                                                           self._oDisp.ksActionTestResultFailureDetails,
                                                           TestResultFailureData.ksParam_idTestResult:
                                                           oTestResult.idTestResult,}),
                                WuiContentBase.ksShortDetailsLinkHtml,);

            sHtml += ' <tr class="%s tmtbl-events-reason tmtbl-events-lvl%s">\n' \
                     '  <td>%s</td>\n' \
                     '  <td colspan="2">%s</td>\n' \
                     '  <td colspan="3">%s%s%s%s</td>\n' \
                     '  <td>%s</td>\n' \
                     ' </tr>\n' \
                   % ( 'tmodd' if iRow & 1 else 'tmeven', iDepth,
                        webutils.escapeElem(self.formatTsShort(oTestResult.oReason.tsEffective)),
                        oTestResult.oReason.oAuthor.sUsername,
                        webutils.escapeElem(sReasonText), sDetailedReason, sChangeReason,
                        sCommentHtml,
                       'todo');
            iRow += 1;

        if oTestResult.isFailure():
            iFailure += 1;

        return (sHtml, iRow, iFailure);
예제 #26
0
    def _generateTimeNavigation(self, sWhere):
        """
        Returns HTML for time navigation.

        Note! Views without a need for a timescale just stubs this method.
        """
        _ = sWhere
        sNavigation = ''

        dParams = self._oDisp.getParameters()
        dParams[WuiDispatcherBase.ksParamItemsPerPage] = self._cItemsPerPage
        dParams[WuiDispatcherBase.ksParamPageNo] = self._iPage

        if WuiDispatcherBase.ksParamEffectiveDate in dParams:
            del dParams[WuiDispatcherBase.ksParamEffectiveDate]
        sNavigation += ' [<a href="?%s">Now</a>]' % (
            webutils.encodeUrlParams(dParams), )

        dParams[
            WuiDispatcherBase.ksParamEffectiveDate] = '-0000-00-00 01:00:00.00'
        sNavigation += ' [<a href="?%s">1</a>' % (
            webutils.encodeUrlParams(dParams), )

        dParams[
            WuiDispatcherBase.ksParamEffectiveDate] = '-0000-00-00 02:00:00.00'
        sNavigation += ', <a href="?%s">2</a>' % (
            webutils.encodeUrlParams(dParams), )

        dParams[
            WuiDispatcherBase.ksParamEffectiveDate] = '-0000-00-00 06:00:00.00'
        sNavigation += ', <a href="?%s">6</a>' % (
            webutils.encodeUrlParams(dParams), )

        dParams[
            WuiDispatcherBase.ksParamEffectiveDate] = '-0000-00-00 12:00:00.00'
        sNavigation += ', <a href="?%s">12</a>' % (
            webutils.encodeUrlParams(dParams), )

        dParams[
            WuiDispatcherBase.ksParamEffectiveDate] = '-0000-00-01 00:00:00.00'
        sNavigation += ', or <a href="?%s">24</a> hours ago]' % (
            webutils.encodeUrlParams(dParams), )

        dParams[
            WuiDispatcherBase.ksParamEffectiveDate] = '-0000-00-02 00:00:00.00'
        sNavigation += ' [<a href="?%s">2</a>' % (
            webutils.encodeUrlParams(dParams), )

        dParams[
            WuiDispatcherBase.ksParamEffectiveDate] = '-0000-00-03 00:00:00.00'
        sNavigation += ', <a href="?%s">3</a>' % (
            webutils.encodeUrlParams(dParams), )

        dParams[
            WuiDispatcherBase.ksParamEffectiveDate] = '-0000-00-05 00:00:00.00'
        sNavigation += ', <a href="?%s">5</a>' % (
            webutils.encodeUrlParams(dParams), )

        dParams[
            WuiDispatcherBase.ksParamEffectiveDate] = '-0000-00-07 00:00:00.00'
        sNavigation += ', <a href="?%s">7</a>' % (
            webutils.encodeUrlParams(dParams), )

        dParams[
            WuiDispatcherBase.ksParamEffectiveDate] = '-0000-00-14 00:00:00.00'
        sNavigation += ', <a href="?%s">14</a>' % (
            webutils.encodeUrlParams(dParams), )

        dParams[
            WuiDispatcherBase.ksParamEffectiveDate] = '-0000-00-21 00:00:00.00'
        sNavigation += ', <a href="?%s">21</a>' % (
            webutils.encodeUrlParams(dParams), )

        dParams[
            WuiDispatcherBase.ksParamEffectiveDate] = '-0000-00-28 00:00:00.00'
        sNavigation += ', or <a href="?%s">28</a> days ago]' % (
            webutils.encodeUrlParams(dParams), )

        return sNavigation
예제 #27
0
    def _showChangeLogNavi(self, fMoreEntries, iPageNo, cEntriesPerPage, tsNow,
                           sWhere):
        """
        Returns the HTML for the change log navigator.
        Note! See also _generateNavigation.
        """
        sNavigation = '<div class="tmlistnav-%s">\n' % sWhere
        sNavigation += '  <table class="tmlistnavtab">\n' \
                       '    <tr>\n'
        dParams = self._oDisp.getParameters()
        dParams[
            WuiDispatcherBase.ksParamChangeLogEntriesPerPage] = cEntriesPerPage
        dParams[WuiDispatcherBase.ksParamChangeLogPageNo] = iPageNo
        if tsNow is not None:
            dParams[WuiDispatcherBase.ksParamEffectiveDate] = tsNow

        # Prev and combo box in one cell. Both inside the form for formatting reasons.
        sNavigation += '    <td align="left">\n' \
                       '    <form name="ChangeLogEntriesPerPageForm" method="GET">\n'

        # Prev
        if iPageNo > 0:
            dParams[WuiDispatcherBase.ksParamChangeLogPageNo] = iPageNo - 1
            sNavigation += '<a href="?%s#tmchangelog">Previous</a>\n' \
                         % (webutils.encodeUrlParams(dParams),)
            dParams[WuiDispatcherBase.ksParamChangeLogPageNo] = iPageNo
        else:
            sNavigation += 'Previous\n'

        # Entries per page selector.
        del dParams[WuiDispatcherBase.ksParamChangeLogEntriesPerPage]
        sNavigation += '&nbsp; &nbsp;\n' \
                       '  <select name="%s" onchange="window.location=\'?%s&%s=\' + ' \
                       'this.options[this.selectedIndex].value + \'#tmchangelog\';" ' \
                       'title="Max change log entries per page">\n' \
                     % (WuiDispatcherBase.ksParamChangeLogEntriesPerPage,
                        webutils.encodeUrlParams(dParams),
                        WuiDispatcherBase.ksParamChangeLogEntriesPerPage)
        dParams[
            WuiDispatcherBase.ksParamChangeLogEntriesPerPage] = cEntriesPerPage

        for iEntriesPerPage in [
                2, 4, 8, 16, 32, 64, 128, 256, 384, 512, 768, 1024, 1536, 2048,
                3072, 4096, 8192
        ]:
            sNavigation += '        <option value="%d" %s>%d entries per page</option>\n' \
                         % ( iEntriesPerPage,
                             'selected="selected"' if iEntriesPerPage == cEntriesPerPage else '',
                             iEntriesPerPage )
        sNavigation += '      </select>\n'

        # End of cell (and form).
        sNavigation += '    </form>\n' \
                       '   </td>\n'

        # Next
        if fMoreEntries:
            dParams[WuiDispatcherBase.ksParamChangeLogPageNo] = iPageNo + 1
            sNavigation += '    <td align="right"><a href="?%s#tmchangelog">Next</a></td>\n' \
                         % (webutils.encodeUrlParams(dParams),)
        else:
            sNavigation += '      <td align="right">Next</td>\n'

        sNavigation += '    </tr>\n' \
                       '  </table>\n' \
                       '</div>\n'
        return sNavigation
    def _showChangeLogNavi(self, fMoreEntries, iPageNo, cEntriesPerPage, tsNow, sWhere):
        """
        Returns the HTML for the change log navigator.
        Note! See also _generateNavigation.
        """
        sNavigation = '<div class="tmlistnav-%s">\n' % sWhere
        sNavigation += '  <table class="tmlistnavtab">\n' "    <tr>\n"
        dParams = self._oDisp.getParameters()
        dParams[WuiDispatcherBase.ksParamChangeLogEntriesPerPage] = cEntriesPerPage
        dParams[WuiDispatcherBase.ksParamChangeLogPageNo] = iPageNo
        if tsNow is not None:
            dParams[WuiDispatcherBase.ksParamEffectiveDate] = tsNow

        # Prev and combo box in one cell. Both inside the form for formatting reasons.
        sNavigation += '    <td align="left">\n' '    <form name="ChangeLogEntriesPerPageForm" method="GET">\n'

        # Prev
        if iPageNo > 0:
            dParams[WuiDispatcherBase.ksParamChangeLogPageNo] = iPageNo - 1
            sNavigation += '<a href="?%s#tmchangelog">Previous</a>\n' % (webutils.encodeUrlParams(dParams),)
            dParams[WuiDispatcherBase.ksParamChangeLogPageNo] = iPageNo
        else:
            sNavigation += "Previous\n"

        # Entries per page selector.
        del dParams[WuiDispatcherBase.ksParamChangeLogEntriesPerPage]
        sNavigation += (
            "&nbsp; &nbsp;\n"
            '  <select name="%s" onchange="window.location=\'?%s&%s=\' + '
            "this.options[this.selectedIndex].value + '#tmchangelog';\" "
            'title="Max change log entries per page">\n'
            % (
                WuiDispatcherBase.ksParamChangeLogEntriesPerPage,
                webutils.encodeUrlParams(dParams),
                WuiDispatcherBase.ksParamChangeLogEntriesPerPage,
            )
        )
        dParams[WuiDispatcherBase.ksParamChangeLogEntriesPerPage] = cEntriesPerPage

        for iEntriesPerPage in [2, 4, 8, 16, 32, 64, 128, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096, 8192]:
            sNavigation += '        <option value="%d" %s>%d entries per page</option>\n' % (
                iEntriesPerPage,
                'selected="selected"' if iEntriesPerPage == cEntriesPerPage else "",
                iEntriesPerPage,
            )
        sNavigation += "      </select>\n"

        # End of cell (and form).
        sNavigation += "    </form>\n" "   </td>\n"

        # Next
        if fMoreEntries:
            dParams[WuiDispatcherBase.ksParamChangeLogPageNo] = iPageNo + 1
            sNavigation += '    <td align="right"><a href="?%s#tmchangelog">Next</a></td>\n' % (
                webutils.encodeUrlParams(dParams),
            )
        else:
            sNavigation += '      <td align="right">Next</td>\n'

        sNavigation += "    </tr>\n" "  </table>\n" "</div>\n"
        return sNavigation
예제 #29
0
    def __init__(self, oSrvGlue):
        WuiDispatcherBase.__init__(self, oSrvGlue, self.ksScriptName)

        self._sTemplate = 'template.html'

        # Use short form to avoid hitting the right margin (130) when using lambda.
        d = self._dDispatch
        # pylint: disable=C0103

        #
        # System Log actions.
        #
        d[self.ksActionSystemLogList] = lambda: self._actionGenericListing(
            SystemLogLogic, WuiAdminSystemLogList)

        #
        # User Account actions.
        #
        d[self.ksActionUserList] = lambda: self._actionGenericListing(
            UserAccountLogic, WuiUserAccountList)
        d[self.ksActionUserAdd] = lambda: self._actionGenericFormAdd(
            UserAccountData, WuiUserAccount)
        d[self.ksActionUserEdit] = lambda: self._actionGenericFormEdit(
            UserAccountData, WuiUserAccount, UserAccountData.ksParam_uid)
        d[self.ksActionUserAddPost] = lambda: self._actionGenericFormAddPost(
            UserAccountData, UserAccountLogic, WuiUserAccount, self.
            ksActionUserList)
        d[self.ksActionUserEditPost] = lambda: self._actionGenericFormEditPost(
            UserAccountData, UserAccountLogic, WuiUserAccount, self.
            ksActionUserList)
        d[self.ksActionUserDelPost] = lambda: self._actionGenericDoRemove(
            UserAccountLogic, UserAccountData.ksParam_uid, self.
            ksActionUserList)

        #
        # TestBox actions.
        #
        d[self.ksActionTestBoxList] = lambda: self._actionGenericListing(
            TestBoxLogic, WuiTestBoxList)
        d[self.ksActionTestBoxListPost] = self._actionTestBoxListPost
        d[self.ksActionTestBoxAdd] = lambda: self._actionGenericFormAdd(
            TestBoxData, WuiTestBox)
        d[self.
          ksActionTestBoxAddPost] = lambda: self._actionGenericFormAddPost(
              TestBoxData, TestBoxLogic, WuiTestBox, self.ksActionTestBoxList)
        d[self.ksActionTestBoxDetails] = lambda: self._actionGenericFormDetails(
            TestBoxData, TestBoxLogic, WuiTestBox, 'idTestBox', 'idGenTestBox')
        d[self.ksActionTestBoxEdit] = lambda: self._actionGenericFormEdit(
            TestBoxData, WuiTestBox, TestBoxData.ksParam_idTestBox)
        d[self.
          ksActionTestBoxEditPost] = lambda: self._actionGenericFormEditPost(
              TestBoxData, TestBoxLogic, WuiTestBox, self.ksActionTestBoxList)
        d[self.
          ksActionTestBoxRemovePost] = lambda: self._actionGenericDoRemove(
              TestBoxLogic, TestBoxData.ksParam_idTestBox, self.
              ksActionTestBoxList)
        d[self.ksActionTestBoxesRegenQueues] = self._actionRegenQueuesCommon

        #
        # Test Case actions.
        #
        d[self.ksActionTestCaseList] = lambda: self._actionGenericListing(
            TestCaseLogic, WuiTestCaseList)
        d[self.ksActionTestCaseAdd] = lambda: self._actionGenericFormAdd(
            TestCaseDataEx, WuiTestCase)
        d[self.
          ksActionTestCaseAddPost] = lambda: self._actionGenericFormAddPost(
              TestCaseDataEx, TestCaseLogic, WuiTestCase, self.
              ksActionTestCaseList)
        d[self.ksActionTestCaseClone] = lambda: self._actionGenericFormClone(
            TestCaseDataEx, WuiTestCase, 'idTestCase', 'idGenTestCase')
        d[self.
          ksActionTestCaseDetails] = lambda: self._actionGenericFormDetails(
              TestCaseDataEx, TestCaseLogic, WuiTestCase, 'idTestCase',
              'idGenTestCase')
        d[self.ksActionTestCaseEdit] = lambda: self._actionGenericFormEdit(
            TestCaseDataEx, WuiTestCase, TestCaseDataEx.ksParam_idTestCase)
        d[self.
          ksActionTestCaseEditPost] = lambda: self._actionGenericFormEditPost(
              TestCaseDataEx, TestCaseLogic, WuiTestCase, self.
              ksActionTestCaseList)
        d[self.ksActionTestCaseDoRemove] = lambda: self._actionGenericDoRemove(
            TestCaseLogic, TestCaseData.ksParam_idTestCase, self.
            ksActionTestCaseList)

        #
        # Global Resource actions
        #
        d[self.ksActionGlobalRsrcShowAll] = lambda: self._actionGenericListing(
            GlobalResourceLogic, WuiGlobalResourceList)
        d[self.
          ksActionGlobalRsrcShowAdd] = lambda: self._actionGlobalRsrcShowAddEdit(
              WuiAdmin.ksActionGlobalRsrcAdd)
        d[self.
          ksActionGlobalRsrcShowEdit] = lambda: self._actionGlobalRsrcShowAddEdit(
              WuiAdmin.ksActionGlobalRsrcEdit)
        d[self.ksActionGlobalRsrcAdd] = lambda: self._actionGlobalRsrcAddEdit(
            WuiAdmin.ksActionGlobalRsrcAdd)
        d[self.ksActionGlobalRsrcEdit] = lambda: self._actionGlobalRsrcAddEdit(
            WuiAdmin.ksActionGlobalRsrcEdit)
        d[self.ksActionGlobalRsrcDel] = lambda: self._actionGenericDoDelOld(
            GlobalResourceLogic, GlobalResourceData.ksParam_idGlobalRsrc, self.
            ksActionGlobalRsrcShowAll)

        #
        # Build Source actions
        #
        d[self.ksActionBuildSrcList] = lambda: self._actionGenericListing(
            BuildSourceLogic, WuiAdminBuildSrcList)
        d[self.ksActionBuildSrcAdd] = lambda: self._actionGenericFormAdd(
            BuildSourceData, WuiAdminBuildSrc)
        d[self.
          ksActionBuildSrcAddPost] = lambda: self._actionGenericFormAddPost(
              BuildSourceData, BuildSourceLogic, WuiAdminBuildSrc, self.
              ksActionBuildSrcList)
        d[self.ksActionBuildSrcClone] = lambda: self._actionGenericFormClone(
            BuildSourceData, WuiAdminBuildSrc, 'idBuildSrc')
        d[self.
          ksActionBuildSrcDetails] = lambda: self._actionGenericFormDetails(
              BuildSourceData, BuildSourceLogic, WuiAdminBuildSrc, 'idBuildSrc'
          )
        d[self.ksActionBuildSrcDoRemove] = lambda: self._actionGenericDoRemove(
            BuildSourceLogic, BuildSourceData.ksParam_idBuildSrc, self.
            ksActionBuildSrcList)
        d[self.ksActionBuildSrcEdit] = lambda: self._actionGenericFormEdit(
            BuildSourceData, WuiAdminBuildSrc, BuildSourceData.
            ksParam_idBuildSrc)
        d[self.
          ksActionBuildSrcEditPost] = lambda: self._actionGenericFormEditPost(
              BuildSourceData, BuildSourceLogic, WuiAdminBuildSrc, self.
              ksActionBuildSrcList)

        #
        # Build actions
        #
        d[self.ksActionBuildList] = lambda: self._actionGenericListing(
            BuildLogic, WuiAdminBuildList)
        d[self.ksActionBuildAdd] = lambda: self._actionGenericFormAdd(
            BuildData, WuiAdminBuild)
        d[self.ksActionBuildAddPost] = lambda: self._actionGenericFormAddPost(
            BuildData, BuildLogic, WuiAdminBuild, self.ksActionBuildList)
        d[self.ksActionBuildClone] = lambda: self._actionGenericFormClone(
            BuildData, WuiAdminBuild, 'idBuild')
        d[self.ksActionBuildDetails] = lambda: self._actionGenericFormDetails(
            BuildData, BuildLogic, WuiAdminBuild, 'idBuild')
        d[self.ksActionBuildDoRemove] = lambda: self._actionGenericDoRemove(
            BuildLogic, BuildData.ksParam_idBuild, self.ksActionBuildList)
        d[self.ksActionBuildEdit] = lambda: self._actionGenericFormEdit(
            BuildData, WuiAdminBuild, BuildData.ksParam_idBuild)
        d[self.
          ksActionBuildEditPost] = lambda: self._actionGenericFormEditPost(
              BuildData, BuildLogic, WuiAdminBuild, self.ksActionBuildList)

        #
        # Build Black List actions
        #
        d[self.ksActionBuildBlacklist] = lambda: self._actionGenericListing(
            BuildBlacklistLogic, WuiAdminListOfBlacklistItems)
        d[self.ksActionBuildBlacklistAdd] = lambda: self._actionGenericFormAdd(
            BuildBlacklistData, WuiAdminBuildBlacklist)
        d[self.
          ksActionBuildBlacklistAddPost] = lambda: self._actionGenericFormAddPost(
              BuildBlacklistData, BuildBlacklistLogic, WuiAdminBuildBlacklist,
              self.ksActionBuildBlacklist)
        d[self.
          ksActionBuildBlacklistClone] = lambda: self._actionGenericFormClone(
              BuildBlacklistData, WuiAdminBuildBlacklist, 'idBlacklisting')
        d[self.
          ksActionBuildBlacklistDetails] = lambda: self._actionGenericFormDetails(
              BuildBlacklistData, BuildBlacklistLogic, WuiAdminBuildBlacklist,
              'idBlacklisting')
        d[self.
          ksActionBuildBlacklistDoRemove] = lambda: self._actionGenericDoRemove(
              BuildBlacklistLogic, BuildBlacklistData.ksParam_idBlacklisting,
              self.ksActionBuildBlacklist)
        d[self.
          ksActionBuildBlacklistEdit] = lambda: self._actionGenericFormEdit(
              BuildBlacklistData, WuiAdminBuildBlacklist, BuildBlacklistData.
              ksParam_idBlacklisting)
        d[self.
          ksActionBuildBlacklistEditPost] = lambda: self._actionGenericFormEditPost(
              BuildBlacklistData, BuildBlacklistLogic, WuiAdminBuildBlacklist,
              self.ksActionBuildBlacklist)

        #
        # Failure Category actions
        #
        d[self.
          ksActionFailureCategoryList] = lambda: self._actionGenericListing(
              FailureCategoryLogic, WuiFailureCategoryList)

        d[self.
          ksActionFailureCategoryShowAdd] = lambda: self._actionGenericFormAdd(
              FailureCategoryData, WuiFailureCategory)

        d[self.
          ksActionFailureCategoryShowEdit] = lambda: self._actionGenericFormEditL(
              FailureCategoryLogic, FailureCategoryData.
              ksParam_idFailureCategory, WuiFailureCategory)

        d[self.
          ksActionFailureCategoryAdd] = lambda: self._actionGenericFormAddPost(
              FailureCategoryData, FailureCategoryLogic, WuiFailureCategory,
              self.ksActionFailureCategoryList)

        d[self.
          ksActionFailureCategoryEdit] = lambda: self._actionGenericFormEditPost(
              FailureCategoryData, FailureCategoryLogic, WuiFailureCategory,
              self.ksActionFailureCategoryList)

        d[self.
          ksActionFailureCategoryDel] = lambda: self._actionGenericDoDelOld(
              FailureCategoryLogic, FailureCategoryData.
              ksParam_idFailureCategory, self.ksActionFailureCategoryList)

        #
        # Failure Reason actions
        #
        d[self.ksActionFailureReasonList] = lambda: self._actionGenericListing(
            FailureReasonLogic, WuiAdminFailureReasonList)

        d[self.
          ksActionFailureReasonShowAdd] = lambda: self._actionGenericFormAdd(
              FailureReasonData, WuiAdminFailureReason)

        d[self.
          ksActionFailureReasonShowEdit] = lambda: self._actionGenericFormEditL(
              FailureReasonLogic, FailureReasonData.ksParam_idFailureReason,
              WuiAdminFailureReason)

        d[self.
          ksActionFailureReasonAdd] = lambda: self._actionGenericFormAddPost(
              FailureReasonData, FailureReasonLogic, WuiAdminFailureReason,
              self.ksActionFailureReasonList)

        d[self.
          ksActionFailureReasonEdit] = lambda: self._actionGenericFormEditPost(
              FailureReasonData, FailureReasonLogic, WuiAdminFailureReason,
              self.ksActionFailureReasonList)

        d[self.ksActionFailureReasonDel] = lambda: self._actionGenericDoDelOld(
            FailureReasonLogic, FailureReasonData.ksParam_idFailureReason, self
            .ksActionFailureReasonList)

        #
        # Build Category actions
        #
        d[self.ksActionBuildCategoryList] = lambda: self._actionGenericListing(
            BuildCategoryLogic, WuiAdminBuildCatList)
        d[self.ksActionBuildCategoryAdd] = lambda: self._actionGenericFormAdd(
            BuildCategoryData, WuiAdminBuildCat)
        d[self.
          ksActionBuildCategoryAddPost] = lambda: self._actionGenericFormAddPost(
              BuildCategoryData, BuildCategoryLogic, WuiAdminBuildCat, self.
              ksActionBuildCategoryList)
        d[self.
          ksActionBuildCategoryClone] = lambda: self._actionGenericFormClone(
              BuildCategoryData, WuiAdminBuildCat, 'idBuildCategory')
        d[self.
          ksActionBuildCategoryDetails] = lambda: self._actionGenericFormDetails(
              BuildCategoryData, BuildCategoryLogic, WuiAdminBuildCat,
              'idBuildCategory')
        d[self.
          ksActionBuildCategoryDoRemove] = lambda: self._actionGenericDoRemove(
              BuildCategoryLogic, BuildCategoryData.ksParam_idBuildCategory,
              self.ksActionBuildCategoryList)

        #
        # Test Group actions
        #
        d[self.ksActionTestGroupList] = lambda: self._actionGenericListing(
            TestGroupLogic, WuiTestGroupList)
        d[self.ksActionTestGroupAdd] = lambda: self._actionGenericFormAdd(
            TestGroupDataEx, WuiTestGroup)
        d[self.
          ksActionTestGroupAddPost] = lambda: self._actionGenericFormAddPost(
              TestGroupDataEx, TestGroupLogic, WuiTestGroup, self.
              ksActionTestGroupList)
        d[self.ksActionTestGroupClone] = lambda: self._actionGenericFormClone(
            TestGroupDataEx, WuiTestGroup, 'idTestGroup')
        d[self.
          ksActionTestGroupDetails] = lambda: self._actionGenericFormDetails(
              TestGroupDataEx, TestGroupLogic, WuiTestGroup, 'idTestGroup')
        d[self.ksActionTestGroupEdit] = lambda: self._actionGenericFormEdit(
            TestGroupDataEx, WuiTestGroup, TestGroupDataEx.ksParam_idTestGroup)
        d[self.
          ksActionTestGroupEditPost] = lambda: self._actionGenericFormEditPost(
              TestGroupDataEx, TestGroupLogic, WuiTestGroup, self.
              ksActionTestGroupList)
        d[self.
          ksActionTestGroupDoRemove] = lambda: self._actionGenericDoRemove(
              TestGroupLogic, TestGroupDataEx.ksParam_idTestGroup, self.
              ksActionTestGroupList)
        d[self.ksActionTestCfgRegenQueues] = self._actionRegenQueuesCommon

        #
        # Scheduling Group actions
        #
        d[self.ksActionSchedGroupList] = lambda: self._actionGenericListing(
            SchedGroupLogic, WuiAdminSchedGroupList)
        d[self.ksActionSchedGroupAdd] = lambda: self._actionGenericFormAdd(
            SchedGroupDataEx, WuiSchedGroup)
        d[self.ksActionSchedGroupClone] = lambda: self._actionGenericFormClone(
            SchedGroupDataEx, WuiSchedGroup, 'idSchedGroup')
        d[self.
          ksActionSchedGroupDetails] = lambda: self._actionGenericFormDetails(
              SchedGroupDataEx, SchedGroupLogic, WuiSchedGroup, 'idSchedGroup')
        d[self.ksActionSchedGroupEdit] = lambda: self._actionGenericFormEdit(
            SchedGroupDataEx, WuiSchedGroup, SchedGroupData.
            ksParam_idSchedGroup)
        d[self.
          ksActionSchedGroupAddPost] = lambda: self._actionGenericFormAddPost(
              SchedGroupDataEx, SchedGroupLogic, WuiSchedGroup, self.
              ksActionSchedGroupList)
        d[self.
          ksActionSchedGroupEditPost] = lambda: self._actionGenericFormEditPost(
              SchedGroupDataEx, SchedGroupLogic, WuiSchedGroup, self.
              ksActionSchedGroupList)
        d[self.
          ksActionSchedGroupDoRemove] = lambda: self._actionGenericDoRemove(
              SchedGroupLogic, SchedGroupData.ksParam_idSchedGroup, self.
              ksActionSchedGroupList)

        self._aaoMenus = \
        [
            [
                'Builds',       self._sActionUrlBase + self.ksActionBuildList,
                [
                    [ 'Builds',                 self._sActionUrlBase + self.ksActionBuildList ],
                    [ 'Blacklist',              self._sActionUrlBase + self.ksActionBuildBlacklist ],
                    [ 'Build Sources',          self._sActionUrlBase + self.ksActionBuildSrcList ],
                    [ 'Build Categories',       self._sActionUrlBase + self.ksActionBuildCategoryList ],
                    [ 'New Build',              self._sActionUrlBase + self.ksActionBuildAdd ],
                    [ 'New Blacklisting',       self._sActionUrlBase + self.ksActionBuildBlacklistAdd ],
                    [ 'New Build Source',       self._sActionUrlBase + self.ksActionBuildSrcAdd],
                    [ 'New Build Category',     self._sActionUrlBase + self.ksActionBuildCategoryAdd ],
                ]
            ],
            [
                'Failure Reasons',       self._sActionUrlBase + self.ksActionFailureReasonList,
                [
                    [ 'Failure Categories',     self._sActionUrlBase + self.ksActionFailureCategoryList ],
                    [ 'Failure Reasons',        self._sActionUrlBase + self.ksActionFailureReasonList ],
                    [ 'New Failure Category',   self._sActionUrlBase + self.ksActionFailureCategoryShowAdd ],
                    [ 'New Failure Reason',     self._sActionUrlBase + self.ksActionFailureReasonShowAdd ],
                ]
            ],
            [
                'System',      self._sActionUrlBase + self.ksActionSystemLogList,
                [
                    [ 'System Log',             self._sActionUrlBase + self.ksActionSystemLogList ],
                    [ 'User Accounts',          self._sActionUrlBase + self.ksActionUserList ],
                    [ 'New User',               self._sActionUrlBase + self.ksActionUserAdd ],
                ]
            ],
            [
                'TestBoxes',   self._sActionUrlBase + self.ksActionTestBoxList,
                [
                    [ 'TestBoxes',              self._sActionUrlBase + self.ksActionTestBoxList ],
                    [ 'Scheduling Groups',      self._sActionUrlBase + self.ksActionSchedGroupList ],
                    [ 'New TestBox',            self._sActionUrlBase + self.ksActionTestBoxAdd ],
                    [ 'New Scheduling Group',   self._sActionUrlBase + self.ksActionSchedGroupAdd ],
                    [ 'Regenerate All Scheduling Queues', self._sActionUrlBase + self.ksActionTestBoxesRegenQueues ],
                ]
            ],
            [
                'Test Config', self._sActionUrlBase + self.ksActionTestGroupList,
                [
                    [ 'Test Cases',             self._sActionUrlBase + self.ksActionTestCaseList ],
                    [ 'Test Groups',            self._sActionUrlBase + self.ksActionTestGroupList ],
                    [ 'Global Resources',       self._sActionUrlBase + self.ksActionGlobalRsrcShowAll ],
                    [ 'New Test Case',          self._sActionUrlBase + self.ksActionTestCaseAdd ],
                    [ 'New Test Group',         self._sActionUrlBase + self.ksActionTestGroupAdd ],
                    [ 'New Global Resource',    self._sActionUrlBase + self.ksActionGlobalRsrcShowAdd ],
                    [ 'Regenerate All Scheduling Queues', self._sActionUrlBase + self.ksActionTestCfgRegenQueues ],
                ]
            ],
            [
                '> Test Results', 'index.py?' + webutils.encodeUrlParams(self._dDbgParams), []
            ],
        ]
예제 #30
0
    def __init__(self, oSrvGlue):
        WuiDispatcherBase.__init__(self, oSrvGlue, self.ksScriptName);

        self._sTemplate     = 'template.html';

        # Use short form to avoid hitting the right margin (130) when using lambda.
        d = self._dDispatch;  # pylint: disable=C0103

        #
        # System Log actions.
        #
        d[self.ksActionSystemLogList]           = lambda: self._actionGenericListing(SystemLogLogic, WuiAdminSystemLogList)

        #
        # User Account actions.
        #
        d[self.ksActionUserList]                = lambda: self._actionGenericListing(UserAccountLogic, WuiUserAccountList)
        d[self.ksActionUserAdd]                 = lambda: self._actionGenericFormAdd(UserAccountData, WuiUserAccount)
        d[self.ksActionUserEdit]                = lambda: self._actionGenericFormEdit(UserAccountData, WuiUserAccount,
                                                                                      UserAccountData.ksParam_uid);
        d[self.ksActionUserAddPost]             = lambda: self._actionGenericFormAddPost(UserAccountData, UserAccountLogic,
                                                                                         WuiUserAccount, self.ksActionUserList)
        d[self.ksActionUserEditPost]            = lambda: self._actionGenericFormEditPost(UserAccountData, UserAccountLogic,
                                                                                          WuiUserAccount, self.ksActionUserList)
        d[self.ksActionUserDelPost]             = lambda: self._actionGenericDoRemove(UserAccountLogic,
                                                                                      UserAccountData.ksParam_uid,
                                                                                      self.ksActionUserList)

        #
        # TestBox actions.
        #
        d[self.ksActionTestBoxList]             = lambda: self._actionGenericListing(TestBoxLogic, WuiTestBoxList);
        d[self.ksActionTestBoxListPost]         = self._actionTestBoxListPost;
        d[self.ksActionTestBoxAdd]              = lambda: self._actionGenericFormAdd(TestBoxData, WuiTestBox);
        d[self.ksActionTestBoxAddPost]          = lambda: self._actionGenericFormAddPost(TestBoxData, TestBoxLogic,
                                                                                         WuiTestBox, self.ksActionTestBoxList);
        d[self.ksActionTestBoxDetails]          = lambda: self._actionGenericFormDetails(TestBoxData, TestBoxLogic, WuiTestBox,
                                                                                         'idTestBox', 'idGenTestBox');
        d[self.ksActionTestBoxEdit]             = lambda: self._actionGenericFormEdit(TestBoxData, WuiTestBox,
                                                                                      TestBoxData.ksParam_idTestBox);
        d[self.ksActionTestBoxEditPost]         = lambda: self._actionGenericFormEditPost(TestBoxData, TestBoxLogic,
                                                                                          WuiTestBox, self.ksActionTestBoxList);
        d[self.ksActionTestBoxRemovePost]       = lambda: self._actionGenericDoRemove(TestBoxLogic,
                                                                                      TestBoxData.ksParam_idTestBox,
                                                                                      self.ksActionTestBoxList)
        d[self.ksActionTestBoxesRegenQueues]    = self._actionRegenQueuesCommon;

        #
        # Test Case actions.
        #
        d[self.ksActionTestCaseList]            = lambda: self._actionGenericListing(TestCaseLogic, WuiTestCaseList);
        d[self.ksActionTestCaseAdd]             = lambda: self._actionGenericFormAdd(TestCaseDataEx, WuiTestCase);
        d[self.ksActionTestCaseAddPost]         = lambda: self._actionGenericFormAddPost(TestCaseDataEx, TestCaseLogic,
                                                                                         WuiTestCase, self.ksActionTestCaseList);
        d[self.ksActionTestCaseClone]           = lambda: self._actionGenericFormClone(  TestCaseDataEx, WuiTestCase,
                                                                                         'idTestCase', 'idGenTestCase');
        d[self.ksActionTestCaseDetails]         = lambda: self._actionGenericFormDetails(TestCaseDataEx, TestCaseLogic,
                                                                                         WuiTestCase, 'idTestCase',
                                                                                         'idGenTestCase');
        d[self.ksActionTestCaseEdit]            = lambda: self._actionGenericFormEdit(TestCaseDataEx, WuiTestCase,
                                                                                      TestCaseDataEx.ksParam_idTestCase);
        d[self.ksActionTestCaseEditPost]        = lambda: self._actionGenericFormEditPost(TestCaseDataEx, TestCaseLogic,
                                                                                          WuiTestCase, self.ksActionTestCaseList);
        d[self.ksActionTestCaseDoRemove]        = lambda: self._actionGenericDoRemove(TestCaseLogic,
                                                                                      TestCaseData.ksParam_idTestCase,
                                                                                      self.ksActionTestCaseList);

        #
        # Global Resource actions
        #
        d[self.ksActionGlobalRsrcShowAll]       = lambda: self._actionGenericListing(GlobalResourceLogic, WuiGlobalResourceList)
        d[self.ksActionGlobalRsrcShowAdd]       = lambda: self._actionGlobalRsrcShowAddEdit(WuiAdmin.ksActionGlobalRsrcAdd)
        d[self.ksActionGlobalRsrcShowEdit]      = lambda: self._actionGlobalRsrcShowAddEdit(WuiAdmin.ksActionGlobalRsrcEdit)
        d[self.ksActionGlobalRsrcAdd]           = lambda: self._actionGlobalRsrcAddEdit(WuiAdmin.ksActionGlobalRsrcAdd)
        d[self.ksActionGlobalRsrcEdit]          = lambda: self._actionGlobalRsrcAddEdit(WuiAdmin.ksActionGlobalRsrcEdit)
        d[self.ksActionGlobalRsrcDel]           = lambda: self._actionGenericDoDelOld(GlobalResourceLogic,
                                                                                      GlobalResourceData.ksParam_idGlobalRsrc,
                                                                                      self.ksActionGlobalRsrcShowAll)

        #
        # Build Source actions
        #
        d[self.ksActionBuildSrcList]        = lambda: self._actionGenericListing(BuildSourceLogic, WuiAdminBuildSrcList)
        d[self.ksActionBuildSrcAdd]         = lambda: self._actionGenericFormAdd(BuildSourceData, WuiAdminBuildSrc);
        d[self.ksActionBuildSrcAddPost]     = lambda: self._actionGenericFormAddPost(BuildSourceData, BuildSourceLogic,
                                                                                     WuiAdminBuildSrc, self.ksActionBuildSrcList);
        d[self.ksActionBuildSrcClone]       = lambda: self._actionGenericFormClone(  BuildSourceData, WuiAdminBuildSrc,
                                                                                     'idBuildSrc');
        d[self.ksActionBuildSrcDetails]     = lambda: self._actionGenericFormDetails(BuildSourceData, BuildSourceLogic,
                                                                                     WuiAdminBuildSrc, 'idBuildSrc');
        d[self.ksActionBuildSrcDoRemove]    = lambda: self._actionGenericDoRemove(BuildSourceLogic,
                                                                                  BuildSourceData.ksParam_idBuildSrc,
                                                                                  self.ksActionBuildSrcList);
        d[self.ksActionBuildSrcEdit]        = lambda: self._actionGenericFormEdit(BuildSourceData, WuiAdminBuildSrc,
                                                                                  BuildSourceData.ksParam_idBuildSrc);
        d[self.ksActionBuildSrcEditPost]    = lambda: self._actionGenericFormEditPost(BuildSourceData, BuildSourceLogic,
                                                                                      WuiAdminBuildSrc,
                                                                                      self.ksActionBuildSrcList);


        #
        # Build actions
        #
        d[self.ksActionBuildList]           = lambda: self._actionGenericListing(BuildLogic, WuiAdminBuildList)
        d[self.ksActionBuildAdd]            = lambda: self._actionGenericFormAdd(BuildData, WuiAdminBuild)
        d[self.ksActionBuildAddPost]        = lambda: self._actionGenericFormAddPost(BuildData, BuildLogic, WuiAdminBuild,
                                                                                     self.ksActionBuildList)
        d[self.ksActionBuildClone]          = lambda: self._actionGenericFormClone(  BuildData, WuiAdminBuild, 'idBuild');
        d[self.ksActionBuildDetails]        = lambda: self._actionGenericFormDetails(BuildData, BuildLogic,
                                                                                     WuiAdminBuild, 'idBuild');
        d[self.ksActionBuildDoRemove]       = lambda: self._actionGenericDoRemove(BuildLogic, BuildData.ksParam_idBuild,
                                                                                  self.ksActionBuildList);
        d[self.ksActionBuildEdit]           = lambda: self._actionGenericFormEdit(BuildData, WuiAdminBuild,
                                                                                  BuildData.ksParam_idBuild);
        d[self.ksActionBuildEditPost]       = lambda: self._actionGenericFormEditPost(BuildData, BuildLogic, WuiAdminBuild,
                                                                                      self.ksActionBuildList)

        #
        # Build Black List actions
        #
        d[self.ksActionBuildBlacklist]          = lambda: self._actionGenericListing(BuildBlacklistLogic,
                                                                                     WuiAdminListOfBlacklistItems);
        d[self.ksActionBuildBlacklistAdd]       = lambda: self._actionGenericFormAdd(BuildBlacklistData, WuiAdminBuildBlacklist);
        d[self.ksActionBuildBlacklistAddPost]   = lambda: self._actionGenericFormAddPost(BuildBlacklistData, BuildBlacklistLogic,
                                                                                         WuiAdminBuildBlacklist,
                                                                                         self.ksActionBuildBlacklist);
        d[self.ksActionBuildBlacklistClone]     = lambda: self._actionGenericFormClone(BuildBlacklistData,
                                                                                       WuiAdminBuildBlacklist,
                                                                                       'idBlacklisting');
        d[self.ksActionBuildBlacklistDetails]   = lambda: self._actionGenericFormDetails(BuildBlacklistData,
                                                                                         BuildBlacklistLogic,
                                                                                         WuiAdminBuildBlacklist,
                                                                                         'idBlacklisting');
        d[self.ksActionBuildBlacklistDoRemove]  = lambda: self._actionGenericDoRemove(BuildBlacklistLogic,
                                                                                      BuildBlacklistData.ksParam_idBlacklisting,
                                                                                      self.ksActionBuildBlacklist)
        d[self.ksActionBuildBlacklistEdit]      = lambda: self._actionGenericFormEdit(BuildBlacklistData,
                                                                                      WuiAdminBuildBlacklist,
                                                                                      BuildBlacklistData.ksParam_idBlacklisting);
        d[self.ksActionBuildBlacklistEditPost]  = lambda: self._actionGenericFormEditPost(BuildBlacklistData,
                                                                                          BuildBlacklistLogic,
                                                                                          WuiAdminBuildBlacklist,
                                                                                          self.ksActionBuildBlacklist)


        #
        # Failure Category actions
        #
        d[self.ksActionFailureCategoryList]     = lambda: self._actionGenericListing(
                                                                FailureCategoryLogic,
                                                                WuiFailureCategoryList)

        d[self.ksActionFailureCategoryShowAdd]  = lambda: self._actionGenericFormAdd(
                                                                FailureCategoryData,
                                                                WuiFailureCategory)

        d[self.ksActionFailureCategoryShowEdit] = lambda: self._actionGenericFormEditL(
                                                                FailureCategoryLogic,
                                                                FailureCategoryData.ksParam_idFailureCategory,
                                                                WuiFailureCategory)

        d[self.ksActionFailureCategoryAdd]      = lambda: self._actionGenericFormAddPost(
                                                                FailureCategoryData,
                                                                FailureCategoryLogic,
                                                                WuiFailureCategory,
                                                                self.ksActionFailureCategoryList)

        d[self.ksActionFailureCategoryEdit]     = lambda: self._actionGenericFormEditPost(
                                                                FailureCategoryData,
                                                                FailureCategoryLogic,
                                                                WuiFailureCategory,
                                                                self.ksActionFailureCategoryList)

        d[self.ksActionFailureCategoryDel]      = lambda: self._actionGenericDoDelOld(
                                                                FailureCategoryLogic,
                                                                FailureCategoryData.ksParam_idFailureCategory,
                                                                self.ksActionFailureCategoryList)

        #
        # Failure Reason actions
        #
        d[self.ksActionFailureReasonList]       = lambda: self._actionGenericListing(
                                                                FailureReasonLogic,
                                                                WuiAdminFailureReasonList)

        d[self.ksActionFailureReasonShowAdd]    = lambda: self._actionGenericFormAdd(
                                                                FailureReasonData,
                                                                WuiAdminFailureReason)

        d[self.ksActionFailureReasonShowEdit]   = lambda: self._actionGenericFormEditL(
                                                                FailureReasonLogic,
                                                                FailureReasonData.ksParam_idFailureReason,
                                                                WuiAdminFailureReason)

        d[self.ksActionFailureReasonAdd]        = lambda: self._actionGenericFormAddPost(
                                                                FailureReasonData,
                                                                FailureReasonLogic,
                                                                WuiAdminFailureReason,
                                                                self.ksActionFailureReasonList)

        d[self.ksActionFailureReasonEdit]       = lambda: self._actionGenericFormEditPost(
                                                                FailureReasonData,
                                                                FailureReasonLogic,
                                                                WuiAdminFailureReason,
                                                                self.ksActionFailureReasonList)

        d[self.ksActionFailureReasonDel]        = lambda: self._actionGenericDoDelOld(FailureReasonLogic,
                                                                                      FailureReasonData.ksParam_idFailureReason,
                                                                                      self.ksActionFailureReasonList)

        #
        # Build Category actions
        #
        d[self.ksActionBuildCategoryList]       = lambda: self._actionGenericListing(BuildCategoryLogic, WuiAdminBuildCatList);
        d[self.ksActionBuildCategoryAdd]        = lambda: self._actionGenericFormAdd(BuildCategoryData, WuiAdminBuildCat);
        d[self.ksActionBuildCategoryAddPost]    = lambda: self._actionGenericFormAddPost(BuildCategoryData, BuildCategoryLogic,
                                                                                     WuiAdminBuildCat,
                                                                                     self.ksActionBuildCategoryList);
        d[self.ksActionBuildCategoryClone]      = lambda: self._actionGenericFormClone(  BuildCategoryData, WuiAdminBuildCat,
                                                                                         'idBuildCategory');
        d[self.ksActionBuildCategoryDetails]    = lambda: self._actionGenericFormDetails(BuildCategoryData, BuildCategoryLogic,
                                                                                         WuiAdminBuildCat, 'idBuildCategory');
        d[self.ksActionBuildCategoryDoRemove]   = lambda: self._actionGenericDoRemove(BuildCategoryLogic,
                                                                                  BuildCategoryData.ksParam_idBuildCategory,
                                                                                  self.ksActionBuildCategoryList)

        #
        # Test Group actions
        #
        d[self.ksActionTestGroupList]       = lambda: self._actionGenericListing(TestGroupLogic, WuiTestGroupList);
        d[self.ksActionTestGroupAdd]        = lambda: self._actionGenericFormAdd(TestGroupDataEx, WuiTestGroup);
        d[self.ksActionTestGroupAddPost]    = lambda: self._actionGenericFormAddPost(TestGroupDataEx, TestGroupLogic,
                                                                                     WuiTestGroup, self.ksActionTestGroupList);
        d[self.ksActionTestGroupClone]      = lambda: self._actionGenericFormClone(  TestGroupDataEx, WuiTestGroup,
                                                                                     'idTestGroup');
        d[self.ksActionTestGroupDetails]    = lambda: self._actionGenericFormDetails(TestGroupDataEx, TestGroupLogic,
                                                                                     WuiTestGroup, 'idTestGroup');
        d[self.ksActionTestGroupEdit]       = lambda: self._actionGenericFormEdit(TestGroupDataEx, WuiTestGroup,
                                                                                  TestGroupDataEx.ksParam_idTestGroup);
        d[self.ksActionTestGroupEditPost]   = lambda: self._actionGenericFormEditPost(TestGroupDataEx, TestGroupLogic,
                                                                                      WuiTestGroup, self.ksActionTestGroupList);
        d[self.ksActionTestGroupDoRemove]   = lambda: self._actionGenericDoRemove(TestGroupLogic,
                                                                                  TestGroupDataEx.ksParam_idTestGroup,
                                                                                  self.ksActionTestGroupList)
        d[self.ksActionTestCfgRegenQueues]  = self._actionRegenQueuesCommon;

        #
        # Scheduling Group actions
        #
        d[self.ksActionSchedGroupList]      = lambda: self._actionGenericListing(SchedGroupLogic, WuiAdminSchedGroupList)
        d[self.ksActionSchedGroupAdd]       = lambda: self._actionGenericFormAdd(SchedGroupDataEx, WuiSchedGroup);
        d[self.ksActionSchedGroupClone]     = lambda: self._actionGenericFormClone(  SchedGroupDataEx, WuiSchedGroup,
                                                                                     'idSchedGroup');
        d[self.ksActionSchedGroupDetails]   = lambda: self._actionGenericFormDetails(SchedGroupDataEx, SchedGroupLogic,
                                                                                     WuiSchedGroup, 'idSchedGroup');
        d[self.ksActionSchedGroupEdit]      = lambda: self._actionGenericFormEdit(SchedGroupDataEx, WuiSchedGroup,
                                                                                  SchedGroupData.ksParam_idSchedGroup);
        d[self.ksActionSchedGroupAddPost]   = lambda: self._actionGenericFormAddPost(SchedGroupDataEx, SchedGroupLogic,
                                                                                     WuiSchedGroup, self.ksActionSchedGroupList);
        d[self.ksActionSchedGroupEditPost]  = lambda: self._actionGenericFormEditPost(SchedGroupDataEx, SchedGroupLogic,
                                                                                      WuiSchedGroup, self.ksActionSchedGroupList);
        d[self.ksActionSchedGroupDoRemove]  = lambda: self._actionGenericDoRemove(SchedGroupLogic,
                                                                                  SchedGroupData.ksParam_idSchedGroup,
                                                                                  self.ksActionSchedGroupList)

        self._aaoMenus = \
        [
            [
                'Builds',       self._sActionUrlBase + self.ksActionBuildList,
                [
                    [ 'Builds',                 self._sActionUrlBase + self.ksActionBuildList ],
                    [ 'Blacklist',              self._sActionUrlBase + self.ksActionBuildBlacklist ],
                    [ 'Build Sources',          self._sActionUrlBase + self.ksActionBuildSrcList ],
                    [ 'Build Categories',       self._sActionUrlBase + self.ksActionBuildCategoryList ],
                    [ 'New Build',              self._sActionUrlBase + self.ksActionBuildAdd ],
                    [ 'New Blacklisting',       self._sActionUrlBase + self.ksActionBuildBlacklistAdd ],
                    [ 'New Build Source',       self._sActionUrlBase + self.ksActionBuildSrcAdd],
                    [ 'New Build Category',     self._sActionUrlBase + self.ksActionBuildCategoryAdd ],
                ]
            ],
            [
                'Failure Reasons',       self._sActionUrlBase + self.ksActionFailureReasonList,
                [
                    [ 'Failure Categories',     self._sActionUrlBase + self.ksActionFailureCategoryList ],
                    [ 'Failure Reasons',        self._sActionUrlBase + self.ksActionFailureReasonList ],
                    [ 'New Failure Category',   self._sActionUrlBase + self.ksActionFailureCategoryShowAdd ],
                    [ 'New Failure Reason',     self._sActionUrlBase + self.ksActionFailureReasonShowAdd ],
                ]
            ],
            [
                'System',      self._sActionUrlBase + self.ksActionSystemLogList,
                [
                    [ 'System Log',             self._sActionUrlBase + self.ksActionSystemLogList ],
                    [ 'User Accounts',          self._sActionUrlBase + self.ksActionUserList ],
                    [ 'New User',               self._sActionUrlBase + self.ksActionUserAdd ],
                ]
            ],
            [
                'TestBoxes',   self._sActionUrlBase + self.ksActionTestBoxList,
                [
                    [ 'TestBoxes',              self._sActionUrlBase + self.ksActionTestBoxList ],
                    [ 'Scheduling Groups',      self._sActionUrlBase + self.ksActionSchedGroupList ],
                    [ 'New TestBox',            self._sActionUrlBase + self.ksActionTestBoxAdd ],
                    [ 'New Scheduling Group',   self._sActionUrlBase + self.ksActionSchedGroupAdd ],
                    [ 'Regenerate All Scheduling Queues', self._sActionUrlBase + self.ksActionTestBoxesRegenQueues ],
                ]
            ],
            [
                'Test Config', self._sActionUrlBase + self.ksActionTestGroupList,
                [
                    [ 'Test Cases',             self._sActionUrlBase + self.ksActionTestCaseList ],
                    [ 'Test Groups',            self._sActionUrlBase + self.ksActionTestGroupList ],
                    [ 'Global Resources',       self._sActionUrlBase + self.ksActionGlobalRsrcShowAll ],
                    [ 'New Test Case',          self._sActionUrlBase + self.ksActionTestCaseAdd ],
                    [ 'New Test Group',         self._sActionUrlBase + self.ksActionTestGroupAdd ],
                    [ 'New Global Resource',    self._sActionUrlBase + self.ksActionGlobalRsrcShowAdd ],
                    [ 'Regenerate All Scheduling Queues', self._sActionUrlBase + self.ksActionTestCfgRegenQueues ],
                ]
            ],
            [
                '> Test Results', 'index.py?' + webutils.encodeUrlParams(self._dDbgParams), []
            ],
        ];
예제 #31
0
    def _recursivelyGenerateEvents(self, oTestResult, sParentName, sLineage, iRow,
                                   iFailure, oTestSet, iDepth):     # pylint: disable=R0914
        """
        Recursively generate event table rows for the result set.

        oTestResult is an object of the type TestResultDataEx.
        """
        # Hack: Replace empty outer test result name with (pretty) command line.
        if iRow == 1:
            sName = '';
            sDisplayName = sParentName;
        else:
            sName = oTestResult.sName if sParentName == '' else '%s, %s' % (sParentName, oTestResult.sName,);
            sDisplayName = webutils.escapeElem(sName);

        # Format error count.
        sErrCnt = '';
        if oTestResult.cErrors > 0:
            sErrCnt = ' (1 error)' if oTestResult.cErrors == 1 else ' (%d errors)' % oTestResult.cErrors;

        # Format bits for adding or editing the failure reason.  Level 0 is handled at the top of the page.
        sChangeReason = '';
        if oTestResult.cErrors > 0 and iDepth > 0:
            dTmp = {
                self._oDisp.ksParamAction: self._oDisp.ksActionTestResultFailureAdd if oTestResult.oReason is None else
                                           self._oDisp.ksActionTestResultFailureEdit,
                TestResultFailureData.ksParam_idTestResult: oTestResult.idTestResult,
            };
            sChangeReason = ' <a href="?%s" class="tmtbl-edit-reason" onclick="addRedirectToAnchorHref(this)">%s</a> ' \
                          % ( webutils.encodeUrlParams(dTmp), WuiContentBase.ksShortEditLinkHtml );

        # Format the include in graph checkboxes.
        sLineage += ':%u' % (oTestResult.idStrName,);
        sResultGraph  = '<input type="checkbox" name="%s" value="%s%s" title="Include result in graph."/>' \
                      % (WuiMain.ksParamReportSubjectIds, ReportGraphModel.ksTypeResult, sLineage,);
        sElapsedGraph = '';
        if oTestResult.tsElapsed is not None:
            sElapsedGraph = '<input type="checkbox" name="%s" value="%s%s" title="Include elapsed time in graph."/>' \
                          % ( WuiMain.ksParamReportSubjectIds, ReportGraphModel.ksTypeElapsed, sLineage);


        if    len(oTestResult.aoChildren) == 0 \
          and len(oTestResult.aoValues) + len(oTestResult.aoMsgs) + len(oTestResult.aoFiles) == 0:
            # Leaf - single row.
            tsEvent = oTestResult.tsCreated;
            if oTestResult.tsElapsed is not None:
                tsEvent += oTestResult.tsElapsed;
            sHtml  = ' <tr class="%s tmtbl-events-leaf tmtbl-events-lvl%s tmstatusrow-%s" id="S%u">\n' \
                     '  <td id="E%u">%s</td>\n' \
                     '  <td>%s</td>\n' \
                     '  <td>%s</td>\n' \
                     '  <td>%s</td>\n' \
                     '  <td colspan="2"%s>%s%s%s</td>\n' \
                     '  <td>%s</td>\n' \
                     ' </tr>\n' \
                   % ( 'tmodd' if iRow & 1 else 'tmeven', iDepth, oTestResult.enmStatus, oTestResult.idTestResult,
                       oTestResult.idTestResult,
                       self._formatEventTimestampHtml(tsEvent, oTestResult.tsCreated, oTestResult.idTestResult, oTestSet),
                       sElapsedGraph,
                       webutils.escapeElem(self.formatIntervalShort(oTestResult.tsElapsed)) if oTestResult.tsElapsed is not None
                                           else '',
                       sDisplayName,
                       ' id="failure-%u"' % (iFailure,) if oTestResult.isFailure() else '',
                       webutils.escapeElem(oTestResult.enmStatus), webutils.escapeElem(sErrCnt),
                       sChangeReason if oTestResult.oReason is None else '',
                       sResultGraph );
            iRow += 1;
        else:
            # Multiple rows.
            sHtml  = ' <tr class="%s tmtbl-events-first tmtbl-events-lvl%s ">\n' \
                     '  <td>%s</td>\n' \
                     '  <td></td>\n' \
                     '  <td></td>\n' \
                     '  <td>%s</td>\n' \
                     '  <td colspan="2">%s</td>\n' \
                     '  <td></td>\n' \
                     ' </tr>\n' \
                   % ( 'tmodd' if iRow & 1 else 'tmeven', iDepth,
                       self._formatEventTimestampHtml(oTestResult.tsCreated, oTestResult.tsCreated,
                                                      oTestResult.idTestResult, oTestSet),
                       sDisplayName,
                       'running' if oTestResult.tsElapsed is None else '', );
            iRow += 1;

            # Depth. Check if our error count is just reflecting the one of our children.
            cErrorsBelow = 0;
            for oChild in oTestResult.aoChildren:
                (sChildHtml, iRow, iFailure) = self._recursivelyGenerateEvents(oChild, sName, sLineage,
                                                                               iRow, iFailure, oTestSet, iDepth + 1);
                sHtml += sChildHtml;
                cErrorsBelow += oChild.cErrors;

            # Messages.
            for oMsg in oTestResult.aoMsgs:
                sHtml += ' <tr class="%s tmtbl-events-message tmtbl-events-lvl%s">\n' \
                         '  <td>%s</td>\n' \
                         '  <td></td>\n' \
                         '  <td></td>\n' \
                         '  <td colspan="3">%s: %s</td>\n' \
                         '  <td></td>\n' \
                         ' </tr>\n' \
                       % ( 'tmodd' if iRow & 1 else 'tmeven', iDepth,
                           self._formatEventTimestampHtml(oMsg.tsCreated, oMsg.tsCreated, oMsg.idTestResultMsg, oTestSet),
                           webutils.escapeElem(oMsg.enmLevel),
                           webutils.escapeElem(oMsg.sMsg), );
                iRow += 1;

            # Values.
            for oValue in oTestResult.aoValues:
                sHtml += ' <tr class="%s tmtbl-events-value tmtbl-events-lvl%s">\n' \
                         '  <td>%s</td>\n' \
                         '  <td></td>\n' \
                         '  <td></td>\n' \
                         '  <td>%s</td>\n' \
                         '  <td class="tmtbl-events-number">%s</td>\n' \
                         '  <td class="tmtbl-events-unit">%s</td>\n' \
                         '  <td><input type="checkbox" name="%s" value="%s%s:%u" title="Include value in graph."></td>\n' \
                         ' </tr>\n' \
                       % ( 'tmodd' if iRow & 1 else 'tmeven', iDepth,
                           self._formatEventTimestampHtml(oValue.tsCreated, oValue.tsCreated, oValue.idTestResultValue, oTestSet),
                           webutils.escapeElem(oValue.sName),
                           utils.formatNumber(oValue.lValue).replace(' ', '&nbsp;'),
                           webutils.escapeElem(oValue.sUnit),
                           WuiMain.ksParamReportSubjectIds, ReportGraphModel.ksTypeValue, sLineage, oValue.idStrName, );
                iRow += 1;

            # Files.
            for oFile in oTestResult.aoFiles:
                if oFile.sMime in [ 'text/plain', ]:
                    aoLinks = [
                        WuiTmLink('%s (%s)' % (oFile.sFile, oFile.sKind), '',
                                  { self._oDisp.ksParamAction:        self._oDisp.ksActionViewLog,
                                    self._oDisp.ksParamLogSetId:      oTestSet.idTestSet,
                                    self._oDisp.ksParamLogFileId:     oFile.idTestResultFile, },
                                  sTitle = oFile.sDescription),
                        WuiTmLink('View Raw', '',
                                  { self._oDisp.ksParamAction:        self._oDisp.ksActionGetFile,
                                    self._oDisp.ksParamGetFileSetId:  oTestSet.idTestSet,
                                    self._oDisp.ksParamGetFileId:     oFile.idTestResultFile,
                                    self._oDisp.ksParamGetFileDownloadIt: False, },
                                  sTitle = oFile.sDescription),
                    ]
                else:
                    aoLinks = [
                        WuiTmLink('%s (%s)' % (oFile.sFile, oFile.sKind), '',
                                  { self._oDisp.ksParamAction:        self._oDisp.ksActionGetFile,
                                    self._oDisp.ksParamGetFileSetId:  oTestSet.idTestSet,
                                    self._oDisp.ksParamGetFileId:     oFile.idTestResultFile,
                                    self._oDisp.ksParamGetFileDownloadIt: False, },
                                  sTitle = oFile.sDescription),
                    ]
                aoLinks.append(WuiTmLink('Download', '',
                                         { self._oDisp.ksParamAction:        self._oDisp.ksActionGetFile,
                                           self._oDisp.ksParamGetFileSetId:  oTestSet.idTestSet,
                                           self._oDisp.ksParamGetFileId:     oFile.idTestResultFile,
                                           self._oDisp.ksParamGetFileDownloadIt: True, },
                                         sTitle = oFile.sDescription));

                sHtml += ' <tr class="%s tmtbl-events-file tmtbl-events-lvl%s">\n' \
                         '  <td>%s</td>\n' \
                         '  <td></td>\n' \
                         '  <td></td>\n' \
                         '  <td>%s</td>\n' \
                         '  <td></td>\n' \
                         '  <td></td>\n' \
                         '  <td></td>\n' \
                         ' </tr>\n' \
                       % ( 'tmodd' if iRow & 1 else 'tmeven', iDepth,
                           self._formatEventTimestampHtml(oFile.tsCreated, oFile.tsCreated, oFile.idTestResultFile, oTestSet),
                           '\n'.join(oLink.toHtml() for oLink in aoLinks),);
                iRow += 1;

            # Done?
            if oTestResult.tsElapsed is not None:
                tsEvent = oTestResult.tsCreated + oTestResult.tsElapsed;
                sHtml += ' <tr class="%s tmtbl-events-final tmtbl-events-lvl%s tmstatusrow-%s" id="E%d">\n' \
                         '  <td>%s</td>\n' \
                         '  <td>%s</td>\n' \
                         '  <td>%s</td>\n' \
                         '  <td>%s</td>\n' \
                         '  <td colspan="2"%s>%s%s%s</td>\n' \
                         '  <td>%s</td>\n' \
                         ' </tr>\n' \
                       % ( 'tmodd' if iRow & 1 else 'tmeven', iDepth, oTestResult.enmStatus, oTestResult.idTestResult,
                           self._formatEventTimestampHtml(tsEvent, tsEvent, oTestResult.idTestResult, oTestSet),
                           sElapsedGraph,
                           webutils.escapeElem(self.formatIntervalShort(oTestResult.tsElapsed)),
                           sDisplayName,
                           ' id="failure-%u"' % (iFailure,) if oTestResult.isFailure() else '',
                           webutils.escapeElem(oTestResult.enmStatus), webutils.escapeElem(sErrCnt),
                           sChangeReason if cErrorsBelow < oTestResult.cErrors and oTestResult.oReason is None else '',
                           sResultGraph);
                iRow += 1;

        # Failure reason.
        if oTestResult.oReason is not None:
            sReasonText = '%s / %s' % ( oTestResult.oReason.oFailureReason.oCategory.sShort,
                                        oTestResult.oReason.oFailureReason.sShort, );
            sCommentHtml = '';
            if oTestResult.oReason.sComment is not None and len(oTestResult.oReason.sComment.strip()) > 0:
                sCommentHtml = '<br>' + webutils.escapeElem(oTestResult.oReason.sComment.strip());
                sCommentHtml = sCommentHtml.replace('\n', '<br>');

            sDetailedReason = ' <a href="?%s" class="tmtbl-show-reason">%s</a>' \
                            % ( webutils.encodeUrlParams({ self._oDisp.ksParamAction:
                                                           self._oDisp.ksActionTestResultFailureDetails,
                                                           TestResultFailureData.ksParam_idTestResult:
                                                           oTestResult.idTestResult,}),
                                WuiContentBase.ksShortDetailsLinkHtml,);

            sHtml += ' <tr class="%s tmtbl-events-reason tmtbl-events-lvl%s">\n' \
                     '  <td>%s</td>\n' \
                     '  <td colspan="2">%s</td>\n' \
                     '  <td colspan="3">%s%s%s%s</td>\n' \
                     '  <td>%s</td>\n' \
                     ' </tr>\n' \
                   % ( 'tmodd' if iRow & 1 else 'tmeven', iDepth,
                        webutils.escapeElem(self.formatTsShort(oTestResult.oReason.tsEffective)),
                        oTestResult.oReason.oAuthor.sUsername,
                        webutils.escapeElem(sReasonText), sDetailedReason, sChangeReason,
                        sCommentHtml,
                       'todo');
            iRow += 1;

        if oTestResult.isFailure():
            iFailure += 1;

        return (sHtml, iRow, iFailure);
    def __init__(self, oSrvGlue):
        WuiDispatcherBase.__init__(self, oSrvGlue, self.ksScriptName);

        self._sTemplate     = 'template.html'

        #
        # Populate the action dispatcher dictionary.
        #

        # Use short form to avoid hitting the right margin (130) when using lambda.
        d = self._dDispatch;  # pylint: disable=C0103

        from testmanager.webui.wuitestresult import WuiGroupedResultList;
        #d[self.ksActionResultsUnGrouped]          = lambda: self._actionResultsListing(TestResultLogic, WuiGroupedResultList)
        d[self.ksActionResultsUnGrouped]          = lambda: self._actionGroupedResultsListing(
                                                                TestResultLogic.ksResultsGroupingTypeNone,
                                                                TestResultLogic,
                                                                WuiGroupedResultList)

        d[self.ksActionResultsGroupedByTestGroup] = lambda: self._actionGroupedResultsListing(
                                                                TestResultLogic.ksResultsGroupingTypeTestGroup,
                                                                TestResultLogic,
                                                                WuiGroupedResultList)

        d[self.ksActionResultsGroupedByBuildRev]  = lambda: self._actionGroupedResultsListing(
                                                                TestResultLogic.ksResultsGroupingTypeBuildRev,
                                                                TestResultLogic,
                                                                WuiGroupedResultList)

        d[self.ksActionResultsGroupedByTestBox]   = lambda: self._actionGroupedResultsListing(
                                                                TestResultLogic.ksResultsGroupingTypeTestBox,
                                                                TestResultLogic,
                                                                WuiGroupedResultList)

        d[self.ksActionResultsGroupedByTestCase]   = lambda: self._actionGroupedResultsListing(
                                                                TestResultLogic.ksResultsGroupingTypeTestCase,
                                                                TestResultLogic,
                                                                WuiGroupedResultList)

        d[self.ksActionResultsGroupedBySchedGroup] = lambda: self._actionGroupedResultsListing(
                                                                TestResultLogic.ksResultsGroupingTypeSchedGroup,
                                                                TestResultLogic,
                                                                WuiGroupedResultList)

        d[self.ksActionTestResultDetails]          = self.actionTestResultDetails

        d[self.ksActionViewLog]                 = self.actionViewLog;
        d[self.ksActionGetFile]                 = self.actionGetFile;
        from testmanager.webui.wuireport import WuiReportSummary, WuiReportSuccessRate, WuiReportFailureReasons;
        d[self.ksActionReportSummary]           = lambda: self._actionGenericReport(ReportLazyModel, WuiReportSummary);
        d[self.ksActionReportRate]              = lambda: self._actionGenericReport(ReportLazyModel, WuiReportSuccessRate);
        d[self.ksActionReportFailureReasons]    = lambda: self._actionGenericReport(ReportLazyModel, WuiReportFailureReasons);
        d[self.ksActionGraphWiz]                = self._actionGraphWiz;
        d[self.ksActionVcsHistoryTooltip]       = self._actionVcsHistoryTooltip;


        #
        # Popupate the menus.
        #

        # Additional URL parameters keeping for time navigation.
        sExtraTimeNav = ''
        dCurParams = oSrvGlue.getParameters()
        if dCurParams is not None:
            asActionUrlExtras = [ self.ksParamItemsPerPage, self.ksParamEffectiveDate, self.ksParamEffectivePeriod, ];
            for sExtraParam in asActionUrlExtras:
                if sExtraParam in dCurParams:
                    sExtraTimeNav += '&%s' % webutils.encodeUrlParams({sExtraParam: dCurParams[sExtraParam]})

        # Shorthand to keep within margins.
        sActUrlBase = self._sActionUrlBase;

        self._aaoMenus = \
        [
            [
                'Inbox',            sActUrlBase + 'TODO', ## @todo list of failures that needs categorizing.
                []
            ],
            [
                'Reports',          sActUrlBase + self.ksActionReportSummary,
                [
                    [ 'Summary',                  sActUrlBase + self.ksActionReportSummary ],
                    [ 'Success Rate',             sActUrlBase + self.ksActionReportRate ],
                    [ 'Failure Reasons',          sActUrlBase + self.ksActionReportFailureReasons ],
                ]
            ],
            [
                'Test Results',     sActUrlBase + self.ksActionResultsUnGrouped + sExtraTimeNav,
                [
                    [ 'Ungrouped results',           sActUrlBase + self.ksActionResultsUnGrouped           + sExtraTimeNav ],
                    [ 'Grouped by Scheduling Group', sActUrlBase + self.ksActionResultsGroupedBySchedGroup + sExtraTimeNav ],
                    [ 'Grouped by Test Group',       sActUrlBase + self.ksActionResultsGroupedByTestGroup  + sExtraTimeNav ],
                    [ 'Grouped by TestBox',          sActUrlBase + self.ksActionResultsGroupedByTestBox    + sExtraTimeNav ],
                    [ 'Grouped by Test Case',        sActUrlBase + self.ksActionResultsGroupedByTestCase   + sExtraTimeNav ],
                    [ 'Grouped by Revision',         sActUrlBase + self.ksActionResultsGroupedByBuildRev   + sExtraTimeNav ],
                ]
            ],
            [
                '> Admin', 'admin.py?' + webutils.encodeUrlParams(self._dDbgParams), []
            ],
        ];
    def _generateTimeSelector(self, dParams, sPreamble, sPostamble):
        """
        Generate HTML code for time selector.
        """

        if WuiDispatcherBase.ksParamEffectiveDate in dParams:
            tsEffective = dParams[WuiDispatcherBase.ksParamEffectiveDate]
            del dParams[WuiDispatcherBase.ksParamEffectiveDate]
        else:
            tsEffective = ''

        # Forget about page No when changing a period
        if WuiDispatcherBase.ksParamPageNo in dParams:
            del dParams[WuiDispatcherBase.ksParamPageNo]


        sHtmlTimeSelector  = '<form name="TimeForm" method="GET">\n'
        sHtmlTimeSelector += sPreamble;
        sHtmlTimeSelector += '\n  <select name="%s" onchange="window.location=' % WuiDispatcherBase.ksParamEffectiveDate
        sHtmlTimeSelector += '\'?%s&%s=\' + ' % (webutils.encodeUrlParams(dParams), WuiDispatcherBase.ksParamEffectiveDate)
        sHtmlTimeSelector += 'this.options[this.selectedIndex].value;" title="Effective date">\n'

        aoWayBackPoints = [
            ('+0000-00-00 00:00:00.00', 'Now', ' title="Present Day. Present Time."'), # lain :)

            ('-0000-00-00 01:00:00.00', 'One hour ago', ''),
            ('-0000-00-00 02:00:00.00', 'Two hours ago', ''),
            ('-0000-00-00 03:00:00.00', 'Three hours ago', ''),

            ('-0000-00-01 00:00:00.00', 'One day ago', ''),
            ('-0000-00-02 00:00:00.00', 'Two days ago', ''),
            ('-0000-00-03 00:00:00.00', 'Three days ago', ''),

            ('-0000-00-07 00:00:00.00', 'One week ago', ''),
            ('-0000-00-14 00:00:00.00', 'Two weeks ago', ''),
            ('-0000-00-21 00:00:00.00', 'Three weeks ago', ''),

            ('-0000-01-00 00:00:00.00', 'One month ago', ''),
            ('-0000-02-00 00:00:00.00', 'Two months ago', ''),
            ('-0000-03-00 00:00:00.00', 'Three months ago', ''),
            ('-0000-04-00 00:00:00.00', 'Four months ago', ''),
            ('-0000-05-00 00:00:00.00', 'Five months ago', ''),
            ('-0000-06-00 00:00:00.00', 'Half a year ago', ''),

            ('-0001-00-00 00:00:00.00', 'One year ago', ''),
        ]
        fSelected = False;
        for sTimestamp, sWayBackPointCaption, sExtraAttrs in aoWayBackPoints:
            if sTimestamp == tsEffective:
                fSelected = True;
            sHtmlTimeSelector += '    <option value="%s"%s%s>%s</option>\n' \
                              % (webutils.quoteUrl(sTimestamp),
                                 ' selected="selected"' if sTimestamp == tsEffective else '',
                                 sExtraAttrs, sWayBackPointCaption)
        if not fSelected and tsEffective != '':
            sHtmlTimeSelector += '    <option value="%s" selected>%s</option>\n' \
                              % (webutils.quoteUrl(tsEffective), tsEffective)

        sHtmlTimeSelector += '  </select>\n';
        sHtmlTimeSelector += sPostamble;
        sHtmlTimeSelector += '\n</form>\n'

        return sHtmlTimeSelector
    def _generateNavigation(self, cbFile):
        """Generate the HTML for the log navigation."""

        dParams = {
            WuiMain.ksParamAction:          WuiMain.ksActionViewLog,
            WuiMain.ksParamLogSetId:        self._oTestSet.idTestSet,
            WuiMain.ksParamLogFileId:       self._oLogFile.idTestResultFile,
            WuiMain.ksParamLogChunkSize:    self._cbChunk,
            WuiMain.ksParamLogChunkNo:      self._iChunk,
        };

        #
        # The page walker.
        #
        dParams2 = dict(dParams);
        del dParams2[WuiMain.ksParamLogChunkNo];
        sHrefFmt        = '<a href="?%s&%s=%%s" title="%%s">%%s</a>' \
                        % (webutils.encodeUrlParams(dParams2).replace('%', '%%'), WuiMain.ksParamLogChunkNo,);
        sHtmlWalker = self.genericPageWalker(self._iChunk, (cbFile + self._cbChunk - 1) / self._cbChunk,
                                             sHrefFmt, 11, 0, 'chunk');

        #
        # The chunk size selector.
        #

        dParams2 = dict(dParams);
        del dParams2[WuiMain.ksParamLogChunkSize];
        sHtmlSize  = '<form name="ChunkSizeForm" method="GET">\n' \
                     '  Max <select name="%s" onchange="window.location=\'?%s&%s=\' + ' \
                     'this.options[this.selectedIndex].value;" title="Max items per page">\n' \
                   % ( WuiMain.ksParamLogChunkSize, webutils.encodeUrlParams(dParams2), WuiMain.ksParamLogChunkSize,);

        for cbChunk in [ 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152,
                         4194304, 8388608, 16777216 ]:
            sHtmlSize += '    <option value="%d" %s>%d bytes</option>\n' \
                       % (cbChunk, 'selected="selected"' if cbChunk == self._cbChunk else '', cbChunk);
        sHtmlSize += '  </select> per page\n' \
                     '</form>\n'

        #
        # Download links.
        #
        oRawLink      = WuiTmLink('View Raw', '',
                                  { WuiMain.ksParamAction:            WuiMain.ksActionGetFile,
                                    WuiMain.ksParamGetFileSetId:      self._oTestSet.idTestSet,
                                    WuiMain.ksParamGetFileId:         self._oLogFile.idTestResultFile,
                                    WuiMain.ksParamGetFileDownloadIt: False,
                                  },
                                  sTitle = '%u MiB' % ((cbFile + 1048576 - 1) / 1048576,) );
        oDownloadLink = WuiTmLink('Download Log', '',
                                  { WuiMain.ksParamAction:            WuiMain.ksActionGetFile,
                                    WuiMain.ksParamGetFileSetId:      self._oTestSet.idTestSet,
                                    WuiMain.ksParamGetFileId:         self._oLogFile.idTestResultFile,
                                    WuiMain.ksParamGetFileDownloadIt: True,
                                  },
                                  sTitle = '%u MiB' % ((cbFile + 1048576 - 1) / 1048576,) );
        oTestSetLink  = WuiTmLink('Test Set', '',
                                  { WuiMain.ksParamAction:            WuiMain.ksActionTestResultDetails,
                                    TestSetData.ksParam_idTestSet:    self._oTestSet.idTestSet,
                                  });


        #
        # Combine the elements and return.
        #
        return '<div class="tmlogviewernavi">\n' \
               ' <table width=100%>\n' \
               '  <tr>\n' \
               '   <td width=20%>\n' \
               '    ' + oTestSetLink.toHtml() + '\n' \
               '    ' + oRawLink.toHtml() + '\n' \
               '    ' + oDownloadLink.toHtml() + '\n' \
               '   </td>\n' \
               '   <td width=60% align=center>' + sHtmlWalker + '</td>' \
               '   <td width=20% align=right>' + sHtmlSize + '</td>\n' \
               '  </tr>\n' \
               ' </table>\n' \
               '</div>\n';
예제 #35
0
    def _generateNavigation(self, cbFile):
        """Generate the HTML for the log navigation."""

        dParams = {
            WuiMain.ksParamAction: WuiMain.ksActionViewLog,
            WuiMain.ksParamLogSetId: self._oTestSet.idTestSet,
            WuiMain.ksParamLogFileId: self._oLogFile.idTestResultFile,
            WuiMain.ksParamLogChunkSize: self._cbChunk,
            WuiMain.ksParamLogChunkNo: self._iChunk,
        }

        #
        # The page walker.
        #
        dParams2 = dict(dParams)
        del dParams2[WuiMain.ksParamLogChunkNo]
        sHrefFmt        = '<a href="?%s&%s=%%s" title="%%s">%%s</a>' \
                        % (webutils.encodeUrlParams(dParams2).replace('%', '%%'), WuiMain.ksParamLogChunkNo,)
        sHtmlWalker = self.genericPageWalker(
            self._iChunk, (cbFile + self._cbChunk - 1) // self._cbChunk,
            sHrefFmt, 11, 0, 'chunk')

        #
        # The chunk size selector.
        #

        dParams2 = dict(dParams)
        del dParams2[WuiMain.ksParamLogChunkSize]
        sHtmlSize  = '<form name="ChunkSizeForm" method="GET">\n' \
                     '  Max <select name="%s" onchange="window.location=\'?%s&%s=\' + ' \
                     'this.options[this.selectedIndex].value;" title="Max items per page">\n' \
                   % ( WuiMain.ksParamLogChunkSize, webutils.encodeUrlParams(dParams2), WuiMain.ksParamLogChunkSize,)

        for cbChunk in [
                256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072,
                262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216
        ]:
            sHtmlSize += '    <option value="%d" %s>%d bytes</option>\n' \
                       % (cbChunk, 'selected="selected"' if cbChunk == self._cbChunk else '', cbChunk)
        sHtmlSize += '  </select> per page\n' \
                     '</form>\n'

        #
        # Download links.
        #
        oRawLink = WuiTmLink(
            'View Raw',
            '', {
                WuiMain.ksParamAction: WuiMain.ksActionGetFile,
                WuiMain.ksParamGetFileSetId: self._oTestSet.idTestSet,
                WuiMain.ksParamGetFileId: self._oLogFile.idTestResultFile,
                WuiMain.ksParamGetFileDownloadIt: False,
            },
            sTitle='%u MiB' % ((cbFile + 1048576 - 1) // 1048576, ))
        oDownloadLink = WuiTmLink(
            'Download Log',
            '', {
                WuiMain.ksParamAction: WuiMain.ksActionGetFile,
                WuiMain.ksParamGetFileSetId: self._oTestSet.idTestSet,
                WuiMain.ksParamGetFileId: self._oLogFile.idTestResultFile,
                WuiMain.ksParamGetFileDownloadIt: True,
            },
            sTitle='%u MiB' % ((cbFile + 1048576 - 1) // 1048576, ))
        oTestSetLink = WuiTmLink(
            'Test Set', '', {
                WuiMain.ksParamAction: WuiMain.ksActionTestResultDetails,
                TestSetData.ksParam_idTestSet: self._oTestSet.idTestSet,
            })

        #
        # Combine the elements and return.
        #
        return '<div class="tmlogviewernavi">\n' \
               ' <table width=100%>\n' \
               '  <tr>\n' \
               '   <td width=20%>\n' \
               '    ' + oTestSetLink.toHtml() + '\n' \
               '    ' + oRawLink.toHtml() + '\n' \
               '    ' + oDownloadLink.toHtml() + '\n' \
               '   </td>\n' \
               '   <td width=60% align=center>' + sHtmlWalker + '</td>' \
               '   <td width=20% align=right>' + sHtmlSize + '</td>\n' \
               '  </tr>\n' \
               ' </table>\n' \
               '</div>\n'
    def _generateTimeNavigation(self, sWhere):
        """
        Returns HTML for time navigation.

        Note! Views without a need for a timescale just stubs this method.
        """
        _ = sWhere
        sNavigation = ""

        dParams = self._oDisp.getParameters()
        dParams[WuiDispatcherBase.ksParamItemsPerPage] = self._cItemsPerPage
        dParams[WuiDispatcherBase.ksParamPageNo] = self._iPage

        if WuiDispatcherBase.ksParamEffectiveDate in dParams:
            del dParams[WuiDispatcherBase.ksParamEffectiveDate]
        sNavigation += ' [<a href="?%s">Now</a>]' % (webutils.encodeUrlParams(dParams),)

        dParams[WuiDispatcherBase.ksParamEffectiveDate] = "-0000-00-00 01:00:00.00"
        sNavigation += ' [<a href="?%s">1</a>' % (webutils.encodeUrlParams(dParams),)

        dParams[WuiDispatcherBase.ksParamEffectiveDate] = "-0000-00-00 02:00:00.00"
        sNavigation += ', <a href="?%s">2</a>' % (webutils.encodeUrlParams(dParams),)

        dParams[WuiDispatcherBase.ksParamEffectiveDate] = "-0000-00-00 06:00:00.00"
        sNavigation += ', <a href="?%s">6</a>' % (webutils.encodeUrlParams(dParams),)

        dParams[WuiDispatcherBase.ksParamEffectiveDate] = "-0000-00-00 12:00:00.00"
        sNavigation += ', <a href="?%s">12</a>' % (webutils.encodeUrlParams(dParams),)

        dParams[WuiDispatcherBase.ksParamEffectiveDate] = "-0000-00-01 00:00:00.00"
        sNavigation += ', or <a href="?%s">24</a> hours ago]' % (webutils.encodeUrlParams(dParams),)

        dParams[WuiDispatcherBase.ksParamEffectiveDate] = "-0000-00-02 00:00:00.00"
        sNavigation += ' [<a href="?%s">2</a>' % (webutils.encodeUrlParams(dParams),)

        dParams[WuiDispatcherBase.ksParamEffectiveDate] = "-0000-00-03 00:00:00.00"
        sNavigation += ', <a href="?%s">3</a>' % (webutils.encodeUrlParams(dParams),)

        dParams[WuiDispatcherBase.ksParamEffectiveDate] = "-0000-00-05 00:00:00.00"
        sNavigation += ', <a href="?%s">5</a>' % (webutils.encodeUrlParams(dParams),)

        dParams[WuiDispatcherBase.ksParamEffectiveDate] = "-0000-00-07 00:00:00.00"
        sNavigation += ', <a href="?%s">7</a>' % (webutils.encodeUrlParams(dParams),)

        dParams[WuiDispatcherBase.ksParamEffectiveDate] = "-0000-00-14 00:00:00.00"
        sNavigation += ', <a href="?%s">14</a>' % (webutils.encodeUrlParams(dParams),)

        dParams[WuiDispatcherBase.ksParamEffectiveDate] = "-0000-00-21 00:00:00.00"
        sNavigation += ', <a href="?%s">21</a>' % (webutils.encodeUrlParams(dParams),)

        dParams[WuiDispatcherBase.ksParamEffectiveDate] = "-0000-00-28 00:00:00.00"
        sNavigation += ', or <a href="?%s">28</a> days ago]' % (webutils.encodeUrlParams(dParams),)

        return sNavigation