Subversion Repositories DevTools

Rev

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

<%
'===============================================================
'                    Version Browser
'===============================================================
%>
<!--#include file="class/classSortHelper.asp"-->
<%
'------------ Variable Definition -------------
Dim parFLpkg_version, parFLuser_name
Dim imgLock, fieldRelease_Date, fieldReleased_By, fieldDownloadFullReleaseNotes
Dim rsVB
Dim rowColor, imgPointer
Dim URLstring
Dim pvidName
Dim idxName
Dim filterInUse
Dim hideRipple
Dim rippleFilter
Dim DestroyPackage
Dim CanDestroyProjectPackage
Dim CanDestroyPackage
'------------ Constants Declaration -----------
Const IMGBG_ROW_HI = "background='images/bg_row_hi.gif'"
Const IMGBG_ROW = "bgcolor='#FFFFFF'"
Const IMG_PONTER = "<img src='images/i_pointer.gif' width='6' height='11' hspace='3'>"
Const IMG_OFFICIAL = "<img src='images/i_locked.gif' width='7' height='10' hspace='5' vspace='2' title='Package has been Released'>"
Const IMG_PENDING = "<img src='icons/i_pending.gif' width='7' height='10' hspace='5' vspace='2' title='Package pending autobuild'>"
Const IMG_NOT_OFFICIAL = "<img src='images/spacer.gif' width='7' height='10' hspace='5' vspace='2' title='Package not yet released'>"
Const IMG_DOWNLOAD = "<img src='images/i_download_small.gif' alt='Download full release notes.' width='16' height='16' hspace='2' border='0'>"
'------------ Variable Init -------------------
If Request("filter_reset") <> "" Then 
    parFLpkg_version = "*"
    parFLuser_name   = "*"
    filterInUse = FALSE
Else
    parFLpkg_version = RequestDefault( "FLpkg_version", "*" )
    parFLuser_name   = RequestDefault( "FLuser_name","*" )
    filterInUse = Is_Filter_In_Use ( "FLpkg_version, FLuser_name" )
End If

If Request("hideRipple") = "True" Then 
    hideRipple = True
    rippleFilter = "AND PV.BUILD_TYPE != 'Y'"
Else
    hideRipple = False
    rippleFilter = ""
End If

'----------------------------------------------
%>
<%
'-----------------------------------------------------------------------------------------------------------------------------------
Function Get_All_Versions ( nPkg_id )
    Get_All_Versions = _
    " SELECT DISTINCT PV.PV_ID," &_
    "   PV.PKG_VERSION," &_
    "   PV.DLOCKED," &_
    "   PV.MODIFIED_STAMP," &_
    "   USR.FULL_NAME," &_
    "   usr.user_name," &_
    "   USR.USER_EMAIL," &_
    "   PV.COMMENTS," &_
    "   PV.PKG_LABEL," &_
    "   PV.IS_PATCH," &_
    "   PV.RELEASE_NOTES_INFO," &_
    "   PV.BUILD_TYPE," &_
    "   pv.CREATOR_ID," &_
    "   pv.OWNER_ID," &_
    "   NVL2(rc.rtag_id,1,0) as inuse," &_
    "   trunc(SYSDATE - pv.CREATED_STAMP + 0.5) as age" &_
    " FROM PACKAGE_VERSIONS PV," &_
    "      USERS USR,"&_
    "      RELEASE_CONTENT rc" &_
    " WHERE PV.MODIFIER_ID = USR.USER_ID(+) " &_
    "   AND PV.PKG_ID = :PKG_ID" &_
    "   AND pv.pv_id = rc.pv_id(+)" &_
    "    /*-- Manual Filter --*/" &_
    "    "& Construct_Filter ( parFLpkg_version, "pv.pkg_version" ) &_
    "    "& Construct_Filter ( parFLuser_name, "usr.user_name" ) &_
    "    "& rippleFilter &_
    "    /*------------------*/"
    
    Get_All_Versions = Replace( Get_All_Versions, ":PKG_ID", nPkg_id)
End Function
'-----------------------------------------------------------------------------------------------------------------------------------
Function Construct_Filter ( sPar_val, sCol_name )
    Select Case sPar_val
    Case Empty
        Construct_Filter = "AND "& sCol_name &" IS NULL"
        
    Case "*"
        Construct_Filter = ""
        
    Case Else
        If InStr( sPar_val, "*") > 0 Then
            ' Asterisk found in string. Use LIKE
            Construct_Filter = "AND "& sCol_name &" LIKE '"& Replace( sPar_val, "*", "%" ) &"'"
        Else
            ' No asterisk. Use =
            Construct_Filter = "AND "& sCol_name &" = '"& sPar_val &"'"
        End If
        
    End Select
    
End Function
'-----------------------------------------------------------------------------------------------------------------------------------
Function Is_Filter_In_Use ( sFilters )
    Dim filters, filterName
    Is_Filter_In_Use = FALSE
    
    filters = Split( Replace( sFilters, " ", "" ), "," )
    
    For Each filterName In filters
        If Request( filterName ) <> "*" Then 
            Is_Filter_In_Use = TRUE
            Exit For
        End If
    Next
    
End Function
'-----------------------------------------------------------------------------------------------------------------------------------
Function Set_Row_Style ( sLink, pvid )
    Set_Row_Style = "onMouseOver='this.style.cursor=""pointer""' onClick='selectVersion("""& sLink &""",event)' "
End Function
'-----------------------------------------------------------------------------------------------------------------------------------
%>
<!--#include file="_jquery_includes.asp"-->
<script language="JavaScript" type="text/JavaScript">
function useThisVersion (pkgName, pkgVersion, rtagId, oldPvid, newPvid) {
    console.log("useThisVersion:", pkgName, pkgVersion);
    debugger;
    //alert ("Use this version");
    $( "#dialog-confirm" ).dialog({
      position: { my: "top", at: "top+100", of: window },
      modal: true,
      draggable: true,
      resizable: true,
      dialogClass: "rounded_box",
      height:250,
      width:350,
      buttons: {
        "Direct": function() {
          window.opener.document.location="_new_version.asp?OLDpv_id=" + oldPvid + "&rtag_id=" + rtagId + "&pv_id=" + newPvid
          self.close();
          $( this ).dialog( "close" );
        },
        "Pending": function() {
          window.opener.document.location="_new_version.asp?OLDpv_id=" + oldPvid + "&rtag_id=" + rtagId + "&pv_id=" + newPvid + '&iMode=pending';
          self.close();
          $( this ).dialog( "close" );
        },
        Cancel: function() {
          $( this ).dialog( "close" );
        }
      },
      open: function() {
          $(this).siblings('.ui-dialog-buttonpane').find('button:eq(2)').focus(); 
      }
    });

    return false;
}

//  This function is invoked when the user clicks within a row
//  The click will re-load and reposition the version history to the selected version
//  The problem is that the 'Destroy Version' interacts with this.
//  Also the mailto operation interacts with this
//  Solution: The DestroyVersion is an image within a 'td'. 
//            If the 'td' has a class of nogo, then don't navigate
function selectVersion(href,event)
{
    if (! ($(event.target).closest('td').hasClass('nogo') || $(event.target).closest('span').hasClass('mailto')) ) {
        location.href = href;
    }
}

//  Encode data into URL
function encodeData(data) {
    return Object.keys(data).map(function(key) {
        return [key, data[key]].map(encodeURIComponent).join("=");
    }).join("&");
} 

// Destroy a package version
function DestroyVersion(pvid, idx) {
    var data = {
        pv_id       : pvid,
        bfile       : "<%=ScriptName%>",
        rtag_id     : "<%=parRtag_id%>",
        FLuser_name : "<%=parFLuser_name%>",
        FLpkg_version : "<%=parFLpkg_version%>",
        rfile       : "<%=parRfile%>",
        pkg_id      : "<%=parPkg_id%>",
        OLDpv_id    : "<%=parOLDpv_id%>",
        index       : idx 
         
    };
    MM_openVixIFrame('_destroy_package.asp?' + encodeData(data), 'Destroy Package Version')
}

//  Scroll to package
//  Order of preference
//      index   - location of last package deleted
//      index-1 - Near last pakage deleted
//      pvid    - PVID being viewed
//      oldPVID - PVID Deleted
function scrollToPvId() {
    var oldpvid = Number('<%=parOLDpv_id%>');
    var pvid    = Number('<%=parPv_id%>'); 
    var idx     = Number('<%=parIndex%>');
    var els;

    if (idx > 0) {
        els = document.getElementById('IDX_' + idx.toString() );
        if (!els) {
            idx = idx -1;
            els = document.getElementById('IDX_' + idx.toString() );
        }
    }

    if (!els) els = document.getElementById('PVID_' + pvid.toString() );
    if (!els)els = document.getElementById('PVID_' + oldpvid.toString() );
    if (els) els.scrollIntoView();
}

//  Set the height of the two areas in the History Window
//  Note: Divs may not always be available.
function setLayerHeight () {
    try {
        var h = screen.height;
        MM_findObj("LayerVersions").style.height = (h-300)/2 +"px";
        MM_findObj("LayerDetails").style.height = (h-300)/2 +"px";
    } catch(e) {
    }
}   

//# sourceURL=_version_browser_1.asp
</script>

      <!--------------- ACTION BUTTONS -------------------------->
      <div  style="width:100vw;">
      <form name="filter" method="get" action="<%=scriptName%>">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="1" valign="middle" background="images/bg_action_norm.gif"><img src="images/spacer.gif" width="5" height="35"></td>
          <td width="100%" valign="middle" background="images/bg_action_norm.gif"><%
          Dim bEnableUse : bEnableUse = FALSE
          If Request("rtag_id") = ""  OR  _
             Request("pv_id") = "" OR _
             parOLDpv_id = ParPv_id OR _
             bIsPatch OR _
             (NOT bCanInsertPkg) OR _
             (NOT objAccessControl.UserLogedIn) OR _
             (NOT releaseIsWritable(ReleaseMode))  _
          Then
                bEnableUse = FALSE
          Else
                bEnableUse = TRUE
          End If

          If bEnableUse Then
          %>
          <div id='dialog-confirm' title="Confirm version change" style="display:none">
          <p>Replace the current version of package <%=sPkg_Name%> with Version <%=sPkg_Version%>.
          <p>The new version may be added directly into the release or the change may be made pending. 
          </div>
          <%
            Response.write "<a href=';' onClick='return useThisVersion("""& sPkg_Name &""","""& sPkg_Version & """,""" & parRtag_id & ""","""& parOLDpv_id & """,""" & parPv_id & """);'><img src='images/abtn_use_this_version.gif' title='Use this version in project release.' width='107' height='25' hspace='1' border='0'></a>"
          Else
            Response.write "<img src='images/abtn_use_this_version_off.gif' width='108' height='26' hspace='1' border='0'>"
          End If
          
          Response.write "<img src='images/spacer.gif' width='25' height='25'>"
          If filterInUse Then
            Response.write "<input type='image' name='btn' src='images/abtn_filter_on.gif' width='25' height='25' border='0' title='Apply filter. (Filter is in use!)'>"
          Else
            Response.write "<input type='image' name='btn' src='images/abtn_filter.gif' width='25' height='25' border='0' title='Apply filter'>"
          End If
          Response.write "<span class=pointer  onClick=""location.href='"& scriptName &"?"& Persists_Query_String( "filter_reset=true" ) &"'""><img src='images/abtn_remove_filter.gif' title='Remove filter' width='25' height='25' hspace='2' border='0'></a>"

          Response.write "<img src='images/spacer.gif' width='25' height='25'>"
          Response.write "<span class=pointer onClick=""location.href='"& scriptName &"?"& Persists_Query_String( "hideRipple=" & not hideRipple ) &"'"">"
              If hideRipple Then
                Response.write "<img src='images/RippleSquareOff.gif' width='25' height='25' border='0' title='Rippled Versions Hidden. Toggle'>"
              Else
                Response.write "<img src='images/RippleSquare.gif' width='25' height='25' border='0' title='Rippled Versions Shown. Toggle'>"
              End If
          Response.write "</span>"

          %></td>
          <td width="1" class=pointer valign="middle" background="images/bg_action_norm.gif" onClick="window.opener.document.location='dependencies.asp?pv_id=<%=parPv_id%>';self.close();"><img src="images/abtn_open.gif" width="46" height="25" hspace="5" border="0" alt="Open In Parent Window."></td>
          <td width="1" class=pointer valign="middle" background="images/bg_action_norm.gif" onClick="self.close();"><img src="images/abtn_close.gif" width="46" height="25" hspace="5" border="0" alt="Close this window."></td>
        </tr>
      </table>
      <!--------------------- CAPTION ---------------------------->
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td class="lbox_ttl_b" background="images/bg_action_dark.gif" align="center"><%=sPkg_Name%></td>
        </tr>
      </table>
      <!------------------ VERSION LIST -------------------------->
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td background="images/bg_action_norm.gif"> 
            <div id="LayerVersions" style="height: 350px; width:100vw; overflow: auto;" name="LayerVersions"> 
              <table width="100%" border="0" cellspacing="1" cellpadding="2">
                <tr>
                  <td width="1" nowrap background="images/bg_action_dark.gif"><img src="images/spacer.gif" width="15" height="10"></td>
                  <td width="1" nowrap background="images/bg_action_dark.gif">&nbsp;</td>
                  <td width="1" valign="top" nowrap background="images/bg_action_dark.gif" class="form_field">Version&nbsp;&nbsp;<br><input name="FLpkg_version" type="text" class="form_ifilter" value="<%=parFLpkg_version%>" size="15"></td>
                  <td width="1" valign="top" nowrap background="images/bg_action_dark.gif" class="form_field">Last Mod. Date&nbsp;&nbsp;</td>
                  <td width="100%" valign="top" nowrap background="images/bg_action_dark.gif" class="form_field">Reason for this version</td>
                  <td width="1" valign="top" nowrap background="images/bg_action_dark.gif" class="form_field">Last Modified&nbsp;&nbsp;<br><input name="FLuser_name" type="text" class="form_ifilter" value="<%=parFLuser_name%>" size="15"></td>
                  <td width="1" nowrap background="images/bg_action_dark.gif"></td>
                  <td width="1" nowrap background="images/bg_action_dark.gif"></td>
                </tr>
                <%
                Dim aVersions, lastRow, i, objSortHelper, idx
                
                Set rsVB = OraDatabase.DbCreateDynaset( Get_All_Versions ( parPkg_id ), cint(0))
                
                ' Descending order
                If rsVB.RecordCount > 0 Then
                aVersions = rsVB.GetRows()
                lastRow = UBound( aVersions, 2 )
                
                Set objSortHelper = New SortHelper
                
                
                ' Sort versions
                Call objSortHelper.VersionSort( aVersions, 0, lastRow, rsVB.FieldIndex("pkg_version") )
                
                CanDestroyProjectPackage = canShowControlInProject ( "DestroyPackage" )
                
                ' Descending order
                idx = 0
                For i = lastRow To 0 Step -1
                    idx = idx + 1

                %>
                <%  ' Highlight row case
                    rowColor = IMGBG_ROW
                    imgPointer = ""
                    If CStr( aVersions( rsVB.FieldIndex("pv_id"), i ) ) = parPv_id Then 
                        rowColor = IMGBG_ROW_HI
                        imgPointer = IMG_PONTER
                    End If
                    
                    ' Official/Unofficial case
                    imgLock = IMG_NOT_OFFICIAL
                    'fieldRelease_Date = ""
                    'fieldReleased_By = ""
                    If (aVersions( rsVB.FieldIndex("dlocked"), i ) = "Y")  Then
                        imgLock = IMG_OFFICIAL
                    ElseIf (aVersions( rsVB.FieldIndex("dlocked"), i ) = "A") Then 
                        imgLock = IMG_PENDING
                    End If
                    
                    fieldRelease_Date = DisplayShortDateTime ( aVersions( rsVB.FieldIndex("modified_stamp"), i ) )
                    fieldReleased_By = emailField(enum_imgUser & aVersions( rsVB.FieldIndex("full_name"), i ), aVersions( rsVB.FieldIndex("user_email"), i ))
                    
                    ' Full Release Notes availability
                    fieldDownloadFullReleaseNotes = ""
                    If NOT IsNull( aVersions( rsVB.FieldIndex("release_notes_info"), i ) ) OR ( InStr( aVersions( rsVB.FieldIndex("release_notes_info"), i ), "MGS:") < 1)  Then
                        fieldDownloadFullReleaseNotes = "<a href='"& HTTP_PKG_ARCHIVE & aVersions( rsVB.FieldIndex("release_notes_info"), i ) &"' target='_blank'><img src='images/i_download_small.gif' alt='Download full release notes.' width='16' height='16' hspace='2' border='0'></a>"
                    End If
                    
                    pvidName = "PVID_"& aVersions( rsVB.FieldIndex("pv_id"), i )
                    idxName = "IDX_" & idx
                    If aVersions( rsVB.FieldIndex("is_patch"), i ) = "Y" Then
                        URLstring = "_wform_versions_history_release_notes.asp?"& Persists_Query_String_Trim( "pv_id="& aVersions( rsVB.FieldIndex("pv_id"), i ), "index" )
                    Else
                        URLstring = scriptName &"?"& Persists_Query_String_Trim( "pv_id="& aVersions( rsVB.FieldIndex("pv_id"), i ), "index" )
                    End If
                    
                    ' User can try to delete package iff
                    '   Have suffiecient access (unusual)
                    '   They created it or own it
                    '   The version is not in use by any release (allow to be in pending or WIP)
                    '   [Not at the moment] The package was created less than xxxx days ago
                    '   Is not locked or [Not at the moment] Approved for Autobuild
                    CanDestroyPackage = CanDestroyProjectPackage
                    If NOT CanDestroyPackage Then
                        If (objAccessControl.UserId = aVersions( rsVB.FieldIndex("CREATOR_ID"), i )) OR (objAccessControl.UserId = aVersions( rsVB.FieldIndex("OWNER_ID"), i ))Then
                            If aVersions( rsVB.FieldIndex("inuse"), i ) = 0 Then
                                'If aVersions( rsVB.FieldIndex("age") , i ) < 1000 Then
                                    If aVersions( rsVB.FieldIndex("dlocked"), i ) <> "Y" Then
                                        'If aVersions( rsVB.FieldIndex("dlocked"), i ) <> "A" Then
                                            CanDestroyPackage = true
                                        'End If
                                    End If
                                'End If
                            End If
                        End If
                    End If
                    
                    ' Set destroy package action
                    If CanDestroyPackage Then
                        DestroyPackage = "<span "&_
                                         " title='Destroy this version of the package.' "&_
                                         " onClick=DestroyVersion("& aVersions( rsVB.FieldIndex("pv_id"), i ) &"," & idx  &")>" &_
                                         " <img src='icons/i_destroy_package_sml.gif' width='15' height='15' border='0' ><span>"
                    Else
                        DestroyPackage = ""
                    End If
                %>
                <tr id="<%=idxName%>" <%=Set_Row_Style ( URLstring, CStr( aVersions( rsVB.FieldIndex("pv_id"), i ) ) )%>> 
                  <td align="right" background="images/bg_action_dark.gif"><%=imgPointer%><span id="<%=pvidName%>"></span></td>
                  <td align="center" valign="top" <%=rowColor%>><%=imgLock%></td>
                  <td valign="top" nowrap <%=rowColor%>><a href="<%=URLstring%>" class="txt_linked"><%=aVersions( rsVB.FieldIndex("pkg_version"), i )%></a></td>
                  <td valign="top" nowrap <%=rowColor%> class="form_item"><%=fieldRelease_Date%></td>
                  <td valign="top" <%=rowColor%> class="form_item"><%=NewLine_To_BR ( To_HTML( aVersions( rsVB.FieldIndex("comments"), i ) ) )%></td>
                  <td valign="top" nowrap <%=rowColor%> class="form_item"><%=fieldReleased_By%></td>
                  <td align="center" valign="top" <%=rowColor%>><%=fieldDownloadFullReleaseNotes%></td>
                  <td align="center" valign="top" class="nogo" <%=rowColor%>><%=DestroyPackage%></td>
                </tr>
                <%
                Next
                End If
                %>
              </table>
            </div></td>
        </tr>
      </table> 
      <input type="hidden" name="rtag_id" value="<%=parRtag_id%>">
      <input type="hidden" name="pkg_id" value="<%=parPkg_id%>">
      <input type="hidden" name="rfile" value="<%=parRfile%>">
      <input type="hidden" name="OLDpv_id" value="<%=parOLDpv_id%>">
      <input type="hidden" name="pv_id" value="<%=parPv_id%>">
      <input type="hidden" name="filter_reset" value="">
      </form>
      </div>