Subversion Repositories DevTools

Rev

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

<%@LANGUAGE="VBSCRIPT"%>
<%
'=====================================================
'   form_release_replication.asp
'=====================================================
%>
<%
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 canDelete
'------------ Constants Declaration -----------

Const LIMG_NDEL          = "<img src='icons/i_remove.gif' width='16' height='16' hspace='2' border='0' align='absmiddle'>"
Const LIMG_NDEL_DISABLED = "<img src='icons/i_remove_dis.gif' width='16' height='16' hspace='2' border='0' align='absmiddle' class='lessOpacity'>"

'------------ Variable Init -------------------
canDelete = canActionControlInProject("AdminView")
'------------ Variable Init -------------------
parRtagId = Request("rtag_id")
objPMod.PersistInQryString("rtag_id")
'--------------------------------------------------------------------------------------------------------------------------
'  PV_ID_ListHTML
'
'  DESCRIPTION
'     Constructs the HTML to render the rows of package names, and other information
'
Function PV_ID_ListHTML
   Dim rsQry
   Dim html_string
   Dim sQry

   sQry = _
        "WITH aa as (" &_
        "    SELECT * from blat_projects where proj_id = (select PROJ_ID from RELEASE_TAGS where rtag_id = :RTAG_ID)" &_
        " )" &_
        " SELECT" &_
        "    bs.*," &_
        "    br.rtag_id, br.br_enabled, br.br_exclude," &_
        "    nvl2(br.BLAT_ID, 1, 0) AS inRelease," &_
        "    nvl2(aa.BLAT_ID, 1, 0) AS inProject" &_
        " FROM" &_
        "    blat_servers bs," &_
        "    blat_releases br," &_
        "    aa" &_
        " WHERE" &_
        "    bs.BLAT_ID = br.BLAT_ID (+)" &_
        "    AND br.rtag_id(+) = :RTAG_ID" &_
        "    AND bs.BLAT_ID = aa.BLAT_ID (+)" &_
        "    AND (aa.BLAT_ID is NOT NULL OR br.BLAT_ID is NOT NULL OR bs.BLAT_FULL = 'Y')" &_
        " ORDER BY" &_
        "    upper(blat_display_name) ASC"


   OraDatabase.Parameters.Add "RTAG_ID", DB_RTAG_ID, ORAPARM_INPUT, ORATYPE_NUMBER
   Set rsQry = OraDatabase.DbCreateDynaset( sQry, cint(0) )
   OraDatabase.Parameters.Remove "RTAG_ID"

   '--- Render rows ---
   Do While (NOT rsQry.BOF) AND (NOT rsQry.EOF)
      Dim btnText, btnClass, btnDisable, isaRelease, replicationMode

      isaRelease = rsQry("inRelease") > 0

      replicationMode = "Unknown"
      If rsQry("blat_full") = "Y" Then
          replicationMode = "Repository"
      ElseIf  rsQry("inProject") > 0 Then
          replicationMode = "Project"
      ElseIf  rsQry("inRelease") > 0 Then
          replicationMode = "Release"
      End If

      ' BEGIN ROW
      html_string = html_string & "<tr data-server_id=""" & rsQry("BLAT_ID") & """>"

      ' Server Active
      Dim activeChecked
      activeChecked = IIF(rsQry("BLAT_ENABLE") = "Y", "checked", "" )
      html_string = html_string & "<td nowrap class='body_row'><input type='checkbox' disabled "& activeChecked &" ></td>"

      ' Server Name
      html_string = html_string & "<td nowrap class='body_row'>" & rsQry("BLAT_DISPLAY_NAME") & "</td>"

      ' Project Active
      activeChecked = IIF(rsQry("BR_ENABLED") = "Y", "checked", "" )
      btnText = "Operation not available"
      btnClass = ""
      btnDisable = "disabled"
      If canDelete AND isaRelease Then
         btnText = "Toggle Replication State"
         btnClass = "class=btn_enable"
         btnDisable = ""
      End If

      html_string = html_string & "<td nowrap class='body_row' title='" & btnText & "'><input " & btnClass & " type='checkbox' " &btnDisable & " "& activeChecked &" ></td>"

     ' Replication Mode
      html_string = html_string & "<td nowrap class='body_row'>" & replicationMode & "</td>"

     ' Delete Operation
     Dim DelUserImage : DelUserImage = LIMG_NDEL_DISABLED
     btnText = "Operation not available"
     btnClass = ""
     If canDelete AND isaRelease Then
         DelUserImage = LIMG_NDEL
         btnText = "Remove this replica"
         btnClass = "class=btn_delete"
     End If

     html_string = html_string & "<td nowrap valign='top' " & btnClass & " title='" & btnText & "'>" & DelUserImage & "</td>"

      ' END ROW
      html_string = html_string & "</tr>"

      rsQry.MoveNext

      ' ROW SEPERATOR
      'If (NOT rsQry.BOF) AND (NOT rsQry.EOF) Then
         html_string = html_string & "<tr><td colspan='8' class=body_line></td></tr>"
      'End If
   Loop

   ' destroy objects
   rsQry.Close()
   Set rsQry = nothing

   ' return result
   PV_ID_ListHTML = html_string
End Function
'----------------------------------------------------
'   Insert scripts into the header section of the generated document
Sub InsertUserScripts
 %>
<script language="javascript">
$(document).ready(function () {

    //  Add operation to all the delete buttons
    $('.btn_delete').on('click', function(){
        var el = $(this);
        var trel = el.closest("tr");
        var rtag_id = <%=DB_RTAG_ID%>;
        var server_id = trel.data("server_id");

        var colData = new Array();
        trel.each(function(){
            $(this).find('td').each(function(){
                colData.push($(this));
            })
        });
        var replicaName = colData[1].text();

        vixConfirm("Remove replication to '"+replicaName+"' of this release", 
            {
                deferred : true,  
            }).done(function(){
                $.ajax({
                    type : 'POST',
                    url : '_json_Replication.asp',
                    data : {Opr : 'RemoveRelease', server_id : server_id, user_id : <%=objAccessControl.UserId%>, rtag_id : rtag_id },
                    dataType : 'json',
                }).fail(function( jqXHR, textStatus, errorThrown ){
                    vixAlert('Ajax Error. Unexpected result.<p>' + errorThrown);
                }).done(function( data, textStatus, jqXHR ){
                    if (typeof data.result === undefined){
                        vixAlert('Ajax Error. Unexpected result');
                    } else if (data.result != 0){
                        vixAlert('Error Deleting item.<p>' + data.emsgDetails);
                    } else {
                        // Process individual items to show that an action has been taken
                        //
                        colData[1].addClass("strike");
                        colData[0].empty();
                        colData[2].empty();
                        colData[3].empty();
                    }
                });
            });
    });

    //  Add operation to all the enable buttons
    $('.btn_enable').on('click', function(e){
        var el = $(this);
        var trel = el.closest("tr");
        var rtag_id = <%=DB_RTAG_ID%>;
        var server_id = trel.data("server_id");
        var state =  $(this).prop("checked");
        var stateChanged = false;

        var colData = new Array();
        trel.each(function(){
            $(this).find('td').each(function(){
                colData.push($(this));
            })
        });
        var replicaName = colData[1].text();
        var stateText = state ? 'Enable' : 'Disable'; 

        vixConfirm(stateText + " replication to '"+replicaName+"' of this release", 
             {
                 deferred : true,
             }).done(function(){
                $.ajax({
                    type : 'POST',
                    url : '_json_Replication.asp',
                    data : {Opr : 'EnableRelease', server_id : server_id, user_id : <%=objAccessControl.UserId%>, rtag_id : rtag_id, new_state : state ? 'Y' : 'N' },
                    dataType : 'json',
                }).fail(function( jqXHR, textStatus, errorThrown ){
                    vixAlert('Ajax Error. Unexpected result.<p>' + errorThrown);
                }).done(function( data, textStatus, jqXHR ){
                    if (typeof data.result === undefined){
                        vixAlert('Ajax Error. Unexpected result');
                    } else if (data.result != 0){
                        vixAlert('Error setting state.<p>' + data.emsgDetails);
                    } else {
                        stateChanged = true;
                    }
                }).always(function(){
                    if ( !stateChanged ) {
                        el.prop("checked", !state);
                    }
                });
            }).fail(function(){
                el.prop("checked", !state);
            });
        });

});
</script>
<%
End Sub
%>
<%
'------------ RUN BEFORE PAGE RENDER ----------
'
'----------------------------------------------------
Sub LeftPanelContent
End Sub
'----------------------------------------------------
Sub MainPanelContent
%>
   <table class="embedded_table" style="margin-bottom:20px">
      <tr>
         <td>
            <!-- Box Title -->
            <div class="form_ttl nowrap" align="left">
                 Release Replication Details
            </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"-->
                    <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
                    <table width="100%"  border="0" cellspacing="2" cellpadding="0">
                        <tr>
                           <td width="1%" valign="top" nowrap background="images/bg_table_col.gif" class="body_col">Active<%=Quick_Help("activeReplica")%></td>
                           <td width="1%" valign="top" nowrap background="images/bg_table_col.gif" class="body_col">Replica</td>
                           <td width="1%" valign="top" nowrap background="images/bg_table_col.gif" class="body_col">Enabled<%=Quick_Help("enabledRelease")%></td>
                           <td width="1%" valign="top" nowrap background="images/bg_table_col.gif" class="body_col">Relication Mode</td>
                           <td width="1%" valign="top" nowrap background="images/bg_table_col.gif" class="body_col">Opr</td>
                        </tr>
                        <%=PV_ID_ListHTML()%>
                  </table>
                  <table class="full_table">
                     <tr>
                        <td align="right" nowrap valign="bottom" class="abtnItem" title="Add New Replication Targets">
                        <%If canDelete Then%>
                           <a href="javascript:;" onClick="MM_openVixIFrame('wAddReleaseReplica.asp?rtag_id=<%=DB_RTAG_ID%>','Add Release Replication')">
                              <img src="icons/btn_add.gif" width="13" height="13" align="absmiddle" border="0" hspace="3" >
                              Add Release Replica
                           </a>
                        <%Else%>
                             <img src="icons/btn_add_dis.gif" width="13" height="13" align="absmiddle" border="0" hspace="3">
                              Add Release Replica
                        <%End If%>
                        </td>
                     </tr>
                  </table>
               </div>
            </div>
         </td>
      </tr>
   </table>
<%
End Sub
%>
<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.activeReplica   = stdTip(200, 'Active Replica', 'This package replica has been marked as active.');
      formTips.tips.enabledRelease  = stdTip(200, 'Enabled Release','Replication of this release has been enabled. This will only ' +
                                            'be effective if the replica is active');
      </script>
      <%Call InsertUserScripts%>
   </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"></td>
         </tr>
      </table>
      <!-- FOOTER -->
      <!--#include file="_footer.asp"-->
   </body>
</html>