Subversion Repositories DevTools

Rev

Rev 6706 | Rev 6876 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<%@LANGUAGE="VBSCRIPT"%>
<%
'=====================================================
'|                                                   |
'|          Edit/View Build Configuration            |
'|                                                   |
'=====================================================
%>
<%
Option explicit
' Good idea to set when using redirect
Response.Expires = 0   ' always load the page, dont store
%>
<!--#include file="common/conf.asp"-->
<!--#include file="common/globals.asp"-->
<!--#include file="common/formating.asp"-->
<!--#include file="common/qstr.asp"-->
<!--#include file="common/common_subs.asp"-->
<!--#include file="common/_form_window_common.asp"-->
<!--#include file="_action_buttons.asp"-->
<!--#include file="class/classActionButtonControl.asp"-->
<% '------------ ACCESS CONTROL ------------------ %>
<!--#include file="_access_control_login.asp"-->
<!--#include file="_access_control_general.asp"-->
<!--#include file="_access_control_action_project.asp"-->
<%
'------------ Variable Definition -------------
Dim parRtagId
Dim pkgCount : pkgCount= 0
Dim pkgTestCount : pkgTestCount= 0
Dim testCount: testCount = 0
'------------ Constants Declaration -----------
'------------ Variable Init -------------------
parRtagId = Request("rtag_id")
objPMod.PersistInQryString("rtag_id")
'----------------------------------------------
%>
<%
'------------ RUN BEFORE PAGE RENDER ----------
'
'   Generate table data as JSON
'   Could generate via AJAX call too, but for the amount of data in the table
'
Sub GenerateData
    Dim rsQry

    OraDatabase.Parameters.Add "RTAG_ID", parRtagId, ORAPARM_INPUT, ORATYPE_NUMBER
    Set rsQry = OraDatabase.DbCreateDynaset( GetQuery("release_stats.sql"), 0 )
        OraDatabase.Parameters.Remove "RTAG_ID"

    Response.Write "<script type=""text/javascript"" charset=""utf-8"">" + vbCRLF
    Response.Write "var dataSet = [" + vbCRLF

    Do While (NOT rsQry.BOF) AND (NOT rsQry.EOF)
        pkgCount = pkgCount + 1
        Dim tcount : tcount = NiceInt(rsQry("test_count"), 0)
        If tcount > 0 Then
            pkgTestCount = pkgTestCount + 1
            testCount = testCount + tcount 
        End If

        Dim vrefStr, prefStr, crefStr
        Dim buildId, buildTime, lastBuild, codeLines, isDeployable, viewName, isSdk

        buildId = rsQry("build_id")
        crefStr = "unit_test_log.asp?pv_id=" & rsQry("pv_id") & "&rtag_id=" & parRtagId 
        prefStr = "view_by_version.asp?pkg_id=" & rsQry("pkg_id")  & "&listby=1"
        vrefStr = "dependencies.asp?pv_id=" & rsQry("pv_id") & "&rtag_id=" & parRtagId
        buildTime = rsQry("build_time")
        If isNull(buildTime) Then buildTime = ""
        lastBuild = rsQry("lastBuild")
        If isNull(lastBuild) Then lastBuild = ""
        codeLines = rsQry("code_lines")
        If isNull(codeLines) Then codeLines = ""
        isDeployable = rsQry("is_deployable")
        If isNull(isDeployable) Then isDeployable = "N"
        viewName = rsQry("view_name")
        isSdk = rsQry("isSdk") 
        If IsNull(buildId) Then tcount = ""

        Response.Write "["
        Response.Write """<a href=" + prefStr + ">" + rsQry("pkg_name") + "</a>"""
        Response.Write ",""<a href=" + vrefStr + ">" + rsQry("pkg_version") + "</a>"""
        Response.Write ",""<a href=" + crefStr + ">" & tcount & "</a>"""
        Response.Write ",""" + codeLines + """"
        Response.Write ",""" + buildTime + """"
        Response.Write ",""" + lastBuild + """"
        Response.Write ",""" + isDeployable + """"
        Response.Write ",""" + viewName + """"
        Response.Write ",""" + isSdk + """"
        Response.Write "],"  + vbCRLF
    rsQry.MoveNext
    Loop
    Response.Write "]"  + vbCRLF
    Response.Write "</script>"  + vbCRLF
    rsQry.close
    Set rsQry = nothing
End Sub

'----------------------------------------------------
Sub LeftPanelContent
%>
<fieldset class="body_rowg fset">
    <legend>Display</legend>
    <input id="noScroll" type="checkbox" name="noScroll" value="1"> No Scroll
    <br><input id="noGroups" type="checkbox" name="noGroups" value="1"> No Groups
    <br><input id="noCots" type="checkbox" name="noCots" value="1"> Ignore Cots
    <br><input id="noDeploy" type="checkbox" name="noDeploy" value="1"> Ignore Deployable
    <br><input id="noSdk" type="checkbox" name="noSdk" value="1"> Ignore SDKs
</fieldset>
<fieldset class="body_rowg fset">
    <legend>Export</legend>
    <input id="noDetails" type="checkbox" name="noDetails" value="1">  Summary Only
    <br><input id="btnExport"  name="btn" type="submit" class="form_btn" value="Test Counts as CSV"><%=Quick_Help("h_export")%>
</fieldset>
<%
End Sub

Sub MainPanelContent
%>
   <table class="embedded_table" style="margin-bottom:20px">
      <tr>
         <td>
            <!-- Box Title -->
            <div class="form_ttl nowrap" align="left">
                 Package Unit Tests
            </div>
         </td>
      </tr>
      <tr>
         <td>
            <!-- Box Content -->
            <div class="rounded_box">
               <div style="background-color: white;border-left: white solid 10px;border-right: white solid 10px;">
                    <!-- MESSAGE +++++++++++++++++++++++++++++++++++++++++++++++++++ -->
                    <!--#include file="messages/_msg_inline.asp"-->
                    <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
                    <div id="packageStatsHolder">
                    <table id="packageStats" width="100%" class="embedded_table">
                        <thead class="envGroup">
                           <tr class="body_col envGroup">
                              <td valign="top" nowrap>Package</td>
                              <td valign="top" nowrap>Version</td>
                              <td valign="top" nowrap>Unit<br>Tests</td>
                              <td valign="top" nowrap>Lines<br>of Code</td>
                              <td valign="top" nowrap>Build<br>Duration</td>
                              <td valign="top" nowrap>Build Date</td>
                              <td valign="top" nowrap>Deployable</td>
                              <td valign="top" nowrap>View Name</td>
                              <td valign="top" nowrap>SDK</td>
                           </tr>
                        </thead>
                  </table>
                  </div>
                  <table width="100%" class="embedded_table">
                  <tr class="body_col envGroup"><th colspan=5>Summary</th></tr>
                  <tr class="body_rowg"><td colspan=4>Total Packages</td><td id="pkgCount"></td></tr>
                  <tr class="body_rowg"><td colspan=4>Total Packages with Tests</td><td id="pkgTestCount"></td></tr>
                  <tr class="body_rowg"><td colspan=4>Total Unit Tests</td><td id="testCount"></td></tr>
                  <tr class="body_rowg"><td colspan=4>Total Lines of Code</td><td id="tloc"></td></tr>
                  </table>
               </div>
            </div>
         </td>
      </tr>
   </table>
<%
End Sub
%>
<NOSCRIPT LANGUAGE="VBScript" RUNAT=SERVER SRC="common/VarDump.vbs"></NOSCRIPT> 
<html>
   <head>
      <title>Release Manager</title>
      <link rel="shortcut icon" href="<%=FavIcon%>"/>
      <meta http-equiv="Pragma" content="no-cache">
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
      <link rel="stylesheet" href="images/release_manager_style.css?ver=<%=VixVerNum%>" type="text/css">
      <link rel="stylesheet" href="images/navigation.css?ver=<%=VixVerNum%>" type="text/css">
      <script language="JavaScript" src="images/common.js?ver=<%=VixVerNum%>"></script>
      <!-- DROPDOWN MENUS -->
      <%bJqueryDataTables = TRUE%>
      <!--#include file="_jquery_includes.asp"-->
      <!--#include file="_menu_def.asp"-->
      <script language="JavaScript1.2" src="images/popup_menu.js?ver=<%=VixVerNum%>"></script>
      <script language="JavaScript" src="images/tipster.js?ver=<%=VixVerNum%>"></script>
      <script language="JavaScript" src="images/_help_tips.js?ver=<%=VixVerNum%>"></script>
      <script language="JavaScript" type="text/JavaScript">
      formTips.tips.h_export       = stdTip(300, 'Export Test Count', 'Unit test counts will be copied to the users clipboard is CSV format.' +
                                                                  '<p>The data is to be integrated into other reports.' 
                                                                  );
      </script>
      <%Call GenerateData%>
      <style type="text/css">
          table.dataTable tbody tr.baseGroup{background:#dad7c8;}
          table.dataTable tbody tr.baseGroup td{border-bottom:1pt solid black;;border-top:1pt solid black;}
          table.dataTable tbody tr td.header{color:black;font-weight:bold;}
          table.dataTable tbody tr td.info{color:gray;font-weight:normal;}
      </style>
      <script type="text/javascript" charset="utf-8">

          // Helper object to contain unit tests stats
        function groupStats() {
            this.total = 0;
            this.withTests = 0;
            this.testCount = 0;
            this.loc = 0;
        };

        var pkgStats = {
            // Ref to the current table
            table : null ,

            // A copy of the original table body
            html : null,

            // Display package groups
            noGroup : false,

            // Counters for all and for each groups
            info : null,
            groupinfo : null,

            // Part of config - with groups
            withGroups : [
                    { "visible": false, "targets": [6,7,8] },
                    { "className" : 'nowrap', targets: [1,2,3,4,5] },
                    { "orderData" : [7,0], targets : 0 },
                    { "orderData" : [7,1], targets : 1 },
                    { "orderData" : [7,2], targets : 2 },
                    { "orderData" : [7,3], targets : 3 },
                    { "orderData" : [7,4], targets : 4 },
                    { "orderData" : [7,5], targets : 5 },
                    { "orderData" : [7,0], targets : 7 },
                ],

            // Part of config - with out groups
            withNoGroups : [
                    { "visible": false, "targets": [6,7,8] },
                    { "className" : 'nowrap', targets: [1,2,3,4,5] },
                ],

            // Basic table config
            tableConfig : {
                //  Vix Usage
                //  Used so that the internal functions can access the rest of the pkgStats data
                //  Will be filled in with a function to return the data
                parentRef : null,

                // Standard config
                //    scrollY and columnDefs will be provided before table is created
                dom:            "lfrti",
                scrollY:        "65vh",
                scrollCollapse: true,
                paging:         false,
                language : { info: "Showing _TOTAL_ entries" },
                columnDefs: null,
                order: [[0,'asc']],
                drawCallback: function ( settings ) {
                    var api = this.api();
                    var parentRef = api.init().parentRef();
                    if (parentRef.noGroup) {
                        return;
                    }

                    var groupinfo = parentRef.groupinfo;
                    $('#noGroups').prop('checked', false)
                    var rows = api.rows( { page: 'current' }).nodes();
                    var last=null;
                    api.column(7, {page:'current'} ).data().each( function ( group, i ) {
                        if ( last !== group ) {
                            last = group;
                            var gdata = groupinfo[group];
                            var gtext = new Array();
                            gtext.push('Packages: ' + gdata.total + '.');
                            gtext.push('With Tests: ' + gdata.withTests + '.');
                            gtext.push('Unit Tests: ' + gdata.testCount + '.');
                            gtext.push('LoC: ' + gdata.loc + '.');
                            $(rows).eq( i ).before(
                                '<tr class="baseGroup"><td class="header" colspan="2">'+group+ '</td><td class="info nowrap" colspan="4">'+gtext.join(' ') + '</td></tr>'
                            );
                        }
                    });
                    parentRef.setHeight();
                }
            },

            // Create a basic DataTable
            //  Then populate it
            createPkgStatsTable : function(){
                 // Save or restore the original HTML of the table
                 if ( !this.html ) {
                     this.html = $('#packageStatsHolder').html();
                 } else {
                     //  Basically need to kill of the multi column ordering, but I can't do it programatically
                     //  Destroy / rebuild the table
                     //  The destoy() function in the 1.10.8 crashes when used with 'false'
                     //  Using 'true' removes the html of the table - so we save it and put it back
                     this.table.destroy(true);
                     $('#packageStatsHolder').html(this.html);
                 }

                 this.noGroup = $('#noGroups').get(0).checked;
                 this.tableConfig.columnDefs = this.noGroup ? this.withNoGroups : this.withGroups;
                 this.tableConfig.scrollY = $('#noScroll').get(0).checked ? '' : '65vh';

                 var that = this;
                 var tableConfig = Object.assign({}, this.tableConfig);
                 tableConfig.parentRef = function(){return that;};
                 this.table = $('#packageStats').DataTable(tableConfig);
                 this.insertAllData();
            },

            //
            //  Filter data and insert into the table
            insertAllData : function () {
                var noDeploy = $('#noDeploy').get(0).checked; 
                var noCots   = $('#noCots').get(0).checked;
                var noSdk    = $('#noSdk').get(0).checked;

                var ii;
                this.table.clear();
                this.info = new groupStats();
                this.groupinfo = {};

                for (ii = 0; ii < dataSet.length; ii++) {
                    if ( noCots ) {
                        var vdata = $(dataSet[ii][1]).text();
                        if ( vdata.match(/.cots$/) || vdata.match(/.tool$/) ) {
                            continue;
                        }
                    }

                    if ( noDeploy ) {
                        var dData = dataSet[ii][6];
                        if ( dData == 'Y' ) {
                            continue;
                        }
                    }

                    if ( noSdk ) {
                        var dData = dataSet[ii][8];
                        if ( dData == 'Y' ) {
                            continue;
                        }
                    }

                    var group = dataSet[ii][7];
                    var gdata = this.groupinfo[group];
                    if ( !gdata ) {
                        this.groupinfo[group] = new groupStats();
                        gdata = this.groupinfo[group];
                    }
                    
                    this.table.row.add( dataSet[ii]);
                    this.info.total ++;
                    gdata.total++;
                    var count = parseInt($(dataSet[ii][2]).text());
                    var loc = parseInt(dataSet[ii][3]);
                    if ( !isNaN(count) && count > 0 ) {
                        this.info.withTests++;
                        gdata.withTests++;
                        this.info.testCount += count;
                        gdata.testCount += count;
                    }
                    if ( !isNaN(loc) && loc > 0 ) {
                        this.info.loc += loc;
                        gdata.loc += loc;
                    }
                }
                this.table.draw();

                $('#pkgCount').text(this.info.total);
                $('#pkgTestCount').text(this.info.withTests);
                $('#testCount').text(this.info.testCount);
                $('#tloc').text(this.info.loc);
            },

            setHeight : function () {
                 var noScroll = $('#noScroll').get(0).checked;
                 if ( noScroll ) {
                     var ScrollBody = $('#packageStats').closest('.dataTables_scrollBody');
                     // work on Datatables 1.10.12 ++, but not on 1.10.8, although lots else works better
                     ScrollBody.css('max-height', "100%");
                     ScrollBody.css('height', "100%");
                 }
            },

        };

        $(document).ready(function() {

        // Instantiate the table
        pkgStats.createPkgStatsTable();

        // Enable / Disable full table display
        // Use / Don't use base View groups
        $('#noScroll,#noGroups').click(function(e){
            pkgStats.createPkgStatsTable();
        });

        // Hide / Show the the COTS packages
        // Hide / Show the the Deployed packages
        // Hide / Show the packages from SDKs
        $('#noCots,#noDeploy,#noSdk').click(function(e){
            pkgStats.insertAllData();
        });

        // Copy multi-line data to the users clipboard
        function copyToClipboard(string) {
            var $temp = $("<textarea>");
            $("body").append($temp);
            $temp.val(string).select();
            document.execCommand("copy");
            $temp.remove();
        };

        // Export Data
        $('#btnExport').click(function(event){
            vixEtableData =  $(this).closest('table');
            var menu = '<div class="rex_clm" >&nbsp;Select Operation</div>';
            menu += '<div class="mmItem" onClick="statNewWin();">Show&nbsp;in&nbsp;New&nbsp;Window</div>';
            menu += '<div class="mmItem" onClick="statDialog();">Show in Dialog</div>';
            menu += '<div class="mmItem" onClick="statDownLoad();">Download File</div>';
            menu += '<div class="mmItem" onClick="statClip();">Copy to Clipboard</div>';
            showmenu(event,menu);
            event.stopImmediatePropagation();
            event.stopPropagation();
            return false;
        });
    });


    // Show Stats in a new window
    function statNewWin() {
        var title = "CSV Stats";
        var data = getData();
        var generator = PopupCenter('', title, 800, 400);
        generator.document.write('<html><head><title>'+title+'</title>');
        generator.document.write('</head><body >');
        generator.document.write('<textArea style="width:100%; height:100%;" wrap="off" >');
        generator.document.write(data.join('\r\n'));
        generator.document.write('</textArea>');
        generator.document.write('</body></html>');
        generator.document.close();
    };

    // Show Stats in a new dialog
    function statDialog() {
        var title = "CSV Stats";
        var data = getData();
        var newDiv = $(document.createElement('div'));
        $(newDiv).html(data.join('<br>'));
        $(newDiv).dialog({width: 800, height: 400, modal:true, position: { my: "top", at: "top+100", of: window }, title: title});
    };

    // Show Stats in a new dialog
    function statDownLoad() {
        filename = 'data.csv';
        var data = getData().join('\r\n');
        var blob = new Blob(['\ufeff'+data], { type: 'text/csv;charset=utf-8;' });
        if (navigator.msSaveBlob) { // IE 10+
            navigator.msSaveBlob(blob, options.filename);
        } else {
            var link = document.createElement("a");
            var url = URL.createObjectURL(blob);
            var isSafari = navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1;
            if (isSafari) //if Safari open in new window to save file with random filename.
                link.setAttribute("target", "_blank");
            link.setAttribute("href", url);
            link.setAttribute("download", filename);
            link.style = "visibility:hidden";
            document.body.appendChild(link);
            link.click();
            document.body.removeChild(link);
        }
    };

    // Copy to Clipboard
    function statClip(){
        var lines = getData(); 
        vixTextToClipBoard(lines.join('\r\n'),{note:'CSV Data copied to clipboard'});
    };

    // Get the data in CSV form
    function getData(){
        var csv = [];
        var csvHdr = [];
        var lines = [];
        var linesHdr = '';
        var date = new Date();
        var tstamp = (date.getFullYear() * 10000) + ((date.getMonth() + 1) * 100) + date.getDate()
        var noDetails = $('#noDetails').get(0).checked;

        function createHeader() {
            //  Insert DateStamp as YYMMDD
            csv.push(tstamp);
            csvHdr.push('Date');

            //  Insert Release ID
            csv.push(<%=DB_RTAG_ID%>);
            csvHdr.push('RtagId');
            csv.push("<%=DB_PROJ_NAME%>");
            csvHdr.push('Project Name');
            csv.push("<%=DB_RTAG_NAME%>");
            csvHdr.push('Release Name');
        }

        function addInfo(info) {
            csv.push(info.total);
            csvHdr.push('Total Packages');
            csv.push(info.withTests);
            csvHdr.push('Packages with Tests');
            csv.push(info.testCount);
            csvHdr.push('Total Unit Tests');
            csv.push(info.loc);
            csvHdr.push('Total Lines of Code');
        }

        function saveCsv() {
            if ( csv.length ) {
                lines.push(csv.join(","));
                csv = [];

                var nextLineHdr = csvHdr.join(",");
                if ( nextLineHdr.length > linesHdr.length ) {
                    linesHdr = nextLineHdr 
                }
                
                lines.push();
                csvHdr = [];
            }
        }

        // Generate a CSV representation of the data in the table
        // Support two forms - grouped and un grouped
        //
        if (pkgStats.noGroup) {
            // Ungrouped - all packages
            createHeader();
            csv.push('ALL');
            csvHdr.push('Group');
            addInfo(pkgStats.info);
            if ( !noDetails )
            {
                pkgStats.table.rows().every(function(rowIdx, tableLoop, rowLoop) {
                    var data = this.data();
                    csv.push($(data[0]).text(), $(data[2]).text(), data[3] );
                    csvHdr.push('Package','Tests','LoC');
                });
            }
            saveCsv();
        } else {
            // Grouped by package
            var lastGroup = null;
            pkgStats.table.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
                var data = this.data();
                var group = data[7];
                if ( group != lastGroup ) {
                    lastGroup = group;
                    saveCsv();
                    createHeader();
                    csv.push(group);
                    csvHdr.push('Group');
                    addInfo(pkgStats.groupinfo[group]);
                }
                if ( !noDetails )
                {
                    csv.push($(data[0]).text(), $(data[2]).text(), data[3]);
                    csvHdr.push('Package','Tests','LoC');
                }
            });
            saveCsv();
        }
        lines.unshift(linesHdr);
        return lines;
    };

  </script>

   </head>
   <body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0">
      <!-- HEADER -->
      <!--#include file="_header.asp"-->
      <!-- BODY ---->
      <table class="full_table">
         <tr>
            <td width="146px" class="panel_bg" valign="top">
                <%Call LeftPanelContent%>
            </td>
            <td width="90%" rowspan="2" align="center" valign="top" bgcolor="#EEEFEF">
                <%Call MainPanelContent%>
            </td>
         </tr>
         <tr>
            <td class="panel_bg" valign="bottom" align="center" height="350">
                <img src="images/release_stats.png" vspace="20" hspace="30"></td>
         </tr>
      </table>
      <!-- FOOTER -->
      <!--#include file="_footer.asp"-->
   </body>
</html>