Subversion Repositories DevTools

Rev

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

<%@LANGUAGE="VBSCRIPT"%>
<%
Option explicit
Response.Expires = 0   ' always load the page, dont store
%>
<%
'=====================================================
'               Import Issues
'=====================================================
%>
<!--#include file="common/conf.asp"-->
<!--#include file="common/globals.asp"-->
<!--#include file="common/qstr.asp"-->
<!--#include file="common/common_subs.asp"-->
<!--#include file="common/common_dbedit.asp"-->
<!--#include file="common/formating.asp"-->
<!--#include file="common/_popup_window_common.asp"-->
<%
' Set rfile parameter. This is a return page after Login
Call objPMod.StoreParameter ( "rfile", "fixed_issues.asp" )
'------------ ACCESS CONTROL ------------------
%>
<!--#include file="_access_control_login.asp"-->
<!--#include file="_access_control_general.asp"-->
<!--#include file="_access_control_project.asp"-->
<%
'------------ Variable Definition -------------
Dim parPv_id
Dim parFRiss_id
Dim parFRiss_num
Dim parFRpkey
Dim parIStates
'------------ Constants Declaration -----------
Const LENUM_ALL = "ALL"
'------------ Variable Init -------------------
parPv_id = Request("pv_id")
parRtag_id = Request("rtag_id")
parFRiss_id = Request("FRiss_id")
parFRiss_num = Request("FRiss_num")
parIStates = Request("istates")
parFRpkey = Request("FRpkey")

'-- CONDITIONS --------------------------------
If (parFRiss_num = "") Then parFRiss_num = LENUM_ALL

If (parFRpkey = "") Then
  parFRpkey = GetDefaultProjectKey(Request("rtag_id"))
  if parFRpkey="" OR IsNull(parFRpkey) Then parFRpkey = LENUM_ALL
End If

%>
<script type="text/javascript" src="scripts/json2.js"></script>
<script language="JavaScript" src="scripts/remote_scripting.js"></script>
<script type="text/javascript" charset="utf-8">
////////////////////////////////////////////////
//  Global script variables
var currentIssueIndex = 0;
var pageSize = 15;
var totalIssues = -1;

///////////////////////////////////////////////
//  Function:    ajaxOpr
//  Description: Perform an ajax operation
//
function ajaxOpr(args, callback)
{
    xmlHttp=GetXmlHttpObject(function(){ ajaxOprCallback(callback);});
    if (xmlHttp==null)
    {
      alert ("Your browser does not support AJAX!");
      return;
    }

    var url = "_json_jiraIssues.asp?" + args;

    // Show spinner
    var el = document.getElementById("keyListLoader");
    if (el)
    {
        el.style.display = 'inline';
    }

    // Use async request, otherwise the spinner will not work
    xmlHttp.open("GET",url,true);  // `false` makes the request synchronous
    xmlHttp.send(null);
}
///////////////////////////////////////////////
//  Function:    ajaxOprCallback
//  Description: Perform an Ajax operation generic error handling
//  Args       : callback - Function to process json results
//                          Json has been decoded and is a javascript object
//                          Handle errors for the user
//
function ajaxOprCallback(callback)
{
    //readyState of 4 or 'complete' represents that data has been returned
    if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
    {
        // Hide spinner
        var el = document.getElementById("keyListLoader");
        if (el) {
            el.style.display = 'none';
        }

        // alert("Got to getAllProjectKeysDone"+ xmlHttp.responseText);
        if (xmlHttp.status !== 200) {
            alert("Internal AJAX error: " + xmlHttp.status);
        }
        else
        {
            // Gather the results from the callback
            var str = xmlHttp.responseText;
            try {
                var myJson = JSON.parse(str);
                //alert("ajaxOprCallback:" + str);
                if (myJson.result != 0) {
                    alert("AJAX request error: " + myJson.emsgSummary);
                }
                else {
                    callback(myJson);
                }
            }
            catch(e) {
            }
        }
    }
}

///////////////////////////////////////////////
// Function: getAllProjectKeys
//           Populate a dropdown box of all project keys
//           This may take some time so its not done during
//           the page load. Only on user request
function getAllProjectKeys()
{
    var el = document.getElementById("keyList")
    if (el)
    {
        ajaxOpr('Opr=getAllKeys', getAllProjectKeysDone);
    }
}
///////////////////////////////////////////////
//  Function:       getAllProjectKeysDone   
//  Description:    Populate the keyList with a selection list
//
function getAllProjectKeysDone(myJson)
{
    if (typeof myJson.keyList != "undefined")
    {
        var el = document.getElementById("keyList");
        if (el)
        {
            var data;
            data = document.createElement("span");
            data.innerHTML=myJson.keyList;
            var a = el.parentNode.replaceChild(data, el);

            // Insert nice class information
            el = document.getElementById("keyListSelect");
            if (el)
            {
                el.className = el.className + " form_item";
                el.onchange = useProjectKey;
            }
        }

        parent.resizeIframe();
    }
}
////////////////////////////////////////
//  Function:       useProjectKey
//  Description:    Update the Project Key from the Selection box
//
function useProjectKey()
{
    var el = document.getElementById("keyListSelect");
    var pk = document.getElementById("FRpkey");
    if (el && pk)
    {
        pk.value = el.value;
    }
}
///////////////////////////////////////////////
//  Function:    findNewIssues, firstPage, nextPage, previousPage, lastPage
//  Description: Navigate through the pages
//
function findNewIssues()
{
    currentIssueIndex = 0;
    totalIssues = -1;
    findIssues();
}
function firstPage()
{
    currentIssueIndex = 0;
    findIssues();
}
function nextPage()
{
    currentIssueIndex += pageSize;
    if (totalIssues > 0 && currentIssueIndex > totalIssues)
    {
        currentIssueIndex = totalIssues - pageSize; 
    }
    findIssues();
}
function previousPage()
{
    currentIssueIndex -= pageSize;
    if (currentIssueIndex < 0)
    {
        currentIssueIndex = 0;
    }
    findIssues();
}
function lastPage()
{
    if (totalIssues > 0)
    {
        currentIssueIndex = totalIssues - pageSize; 
    }
    findIssues();
}

///////////////////////////////////////////////
//  Function:    findIssues
//  Description: Find issues that match the users search criteria
//               Will populate the page via AJAX
//
function findIssues()
{
    // Ensure that the user is not about to discard any required work
    if (checkOutstanding()) {
        return;
    }
    var is = document.getElementById("FRiss_num");
    var pk = document.getElementById("FRpkey");
    var cm = document.getElementById("checkMaster");
    if (cm) cm.checked = false;
    if (is && pk)
    {
        ajaxOpr('Opr=getIssues&Project=' + pk.value
                + '&Issue=' + is.value 
                + "&StartAt=" + currentIssueIndex 
                + "&Count=" + pageSize
                + '&pv_id=' + <%=parPv_id%> ,
                findIssueDone);
    }
}
///////////////////////////////////////////////
//  Function:    findIssueDone
//  Description: Called when Issue list has been collected
//               Will be called if there has been an error
//
function findIssueDone(myJson)
{
    //  Save total issues on the page
    totalIssues = myJson.issueCount;

    // Delete existing table entries
    // Retain the header and foot - these have IDs
    var table = document.getElementById("issueTable");
    var rowCount = table.rows.length;
    for (var i = rowCount - 1; i >= 0 ; i--)
    {
        if (! table.rows[i].id)
        {
            table.deleteRow(i);
        }
    }

    //  Create entries that look like these:
    //  <td><input type="checkbox" name="iss_id" value='dummyValue'></td>
    //  <td nowrap class="form_item"><a href="dummyValue" target="_blank">key/a></td>
    //  <td class="form_item">State</td>
    //  <td class="form_item">Summary</td>

    for (var id in myJson.issues)
    {
        var obj = myJson.issues[id];
        var row = table.insertRow(table.rows.length - 1);
        var cell1 = row.insertCell(0);
        var cell2 = row.insertCell(1);
        var cell3 = row.insertCell(2);
        var cell4 = row.insertCell(3);

        var x = document.createElement("INPUT");
        x.setAttribute('type', 'checkbox');
        x.setAttribute('name', obj.key);
        x.setAttribute('value', obj.key);
        if (obj.inuse)
        {
            x.disabled=true;
            x.checked=true;
        }
        cell1.appendChild(x);

        cell2.className = 'form_item';
        cell2.style.whiteSpace="nowrap";
        var t = document.createTextNode(obj.key);
        x = document.createElement("A");
        x.href = obj.url;
        x.target = "_blank";
        x.appendChild(t);
        cell2.appendChild(x);

        cell3.className = 'form_item';
        cell3.innerHTML = obj.status;

        cell4.className = 'form_item';
        cell4.innerHTML = obj.summary;
    }

    // Create the footer information
    // ie: Found 70860 records, showing 1 - 15
    var footer = document.getElementById("issueFooterCell");
    if (footer)
    {
        footer.innerHTML="Found "+ 
                          myJson.issueCount +
                          " records. Showing " + 
                          myJson.startAt + " - " + 
                          (myJson.startAt + myJson.issues.length);
    }

    parent.resizeIframe();
}
///////////////////////////////////////////////
//  Function:    checkAll
//  Description: check all tick boxes in the table
//
function checkAll(state)
{
    var table = document.getElementById("issueTable");
    var rowCount = table.rows.length;
    for (var i = rowCount - 1; i >= 0 ; i--)
    {
        if (! table.rows[i].id)
        {
            var cell = table.rows[i].cells[0].children[0];
            if (! cell.disabled)
            {
                cell.checked = state;
            }
        }
    }
}
///////////////////////////////////////////////
//  Function:       disableChecked
//  Description:    Disable all items that are checked 
//                  Used after items have been inserted
//
function disableChecked()
{
    var table = document.getElementById("issueTable");
    var rowCount = table.rows.length;
    for (var i = rowCount - 1; i >= 1 ; i--)
    {
        if (! table.rows[i].id)
        {
            var cell = table.rows[i].cells[0].children[0];
            if (cell.checked)
            {
                cell.disabled = true;
            }
        }
    }
}
///////////////////////////////////////////////
//  Function:       checkOutstanding
//  Description:    Check if user has checked items that have not yet been actioned
//                  Generate alert if so
//  Returns:        False - OK to proceed
//
function checkOutstanding()
{
    var table = document.getElementById("issueTable");
    var rowCount = table.rows.length;
    var found = 0
    for (var i = rowCount - 1; i >= 1 ; i--)
    {
        if (! table.rows[i].id)
        {
            var cell = table.rows[i].cells[0].children[0];
            if (cell.checked && ! cell.disabled)
            {
                found++;
            }
        }
    }
    if (found)
    {
        if (confirm("Issues have been selected but not actioned. Do you want to discard selection?") == true ) {
            found = 0
        }
    }
    return found != 0;
}

///////////////////////////////////////////////
//  Function:    addIssues
//  Description: Scan for checked buttons and add issues to package-version
//
function addIssues()
{
    // Create an array of issues to be added
    var table = document.getElementById("issueTable");
    var rowCount = table.rows.length;
    var list = [];
    for (var i = 1; i < rowCount; i++)
    {
        if (! table.rows[i].id)
        {
            var cell = table.rows[i].cells[0].children[0];
            if (cell && cell.type === "checkbox" && ! cell.disabled && cell.checked)
            {
                list.push(cell.value);
            }
        }
    }
    if (list.length > 0)
    {
    //  Call backend AJAX script to do the hardwork

    ajaxOpr('Opr=insertIssues&pv_id=' + <%=parPv_id%>
            + '&Issue=' + list.join(","), function(myJson){
                disableChecked();
            });
    }
}
///////////////////////////////////////////////
//  Function:    closePage
//  Description: close this page, unless there is workk to be done
//
function closePage()
{
    if (checkOutstanding()) {
        return;
    }
    window.parent.location.reload(false);
}
///////////////////////////////////////////////
//  Function:       Window Onload
//  Description:    Init the page, in a browser independent manner
//
if (window.addEventListener) { // W3C standard
  window.addEventListener('load', initPage, false);
} else if (window.attachEvent) { // Microsoft
  window.attachEvent('onload', initPage);
}
function initPage(){
    // Hide spinner
    var el = document.getElementById("keyListLoader");
    if (el) {
        el.style.display = 'none';
    }

    <% If parFRpkey <> LENUM_ALL Then %>
    // Populate the display
    findNewIssues();
    <%End If %>
};
</script>
<%
'------------------------------------------------------------------------------------------------------------------------------------
Function GetDefaultProjectKey(artag_id)
   Dim rsProjId
   If artag_id <> "" Then
       Set rsProjId = OraDatabase.DbCreateDynaset( _
            "SELECT PRJ.JIRA_KEY FROM RELEASE_TAGS RLT, PROJECTS PRJ WHERE RLT.RTAG_ID ="& artag_id &" AND RLT.PROJ_ID = PRJ.PROJ_ID", cint(0))
       GetDefaultProjectKey = rsProjId("jira_key")
       Set rsProjId = Nothing
   Else
        GetDefaultProjectKey = ""
   End If

End Function
'------------------------------------------------------------------------------------------------------------------------------------
%>
<%
'-------------- Main Line ---------------
%>
<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" type="text/css">
<link rel="stylesheet" href="images/navigation.css" type="text/css">
<script language="JavaScript" src="images/common.js"></script>
<!--#include file="_jquery_includes.asp"-->
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" onload="self.focus();">
<form name="importform">
    <!-- First button is the default button. Control its operation -->
    <input type="hidden" name="dummy" value="dummy" onclick="findNewIssues(); return false;"/>
    <table border="0" cellspacing="0" cellpadding="2" >
    <!-- Form Body -->
    <tr height="1%">
      <td nowrap class="wform_ttl" background="images/bg_admin_dark.gif">
        <table border="0" cellspacing="5" cellpadding="0">
            <tr>
              <td align="left" class="wform_ttl">Issue&nbsp;Number</td>
              <td nowrap><input name="FRiss_num" type="text" class="form_item" id="FRiss_num" value="<%=parFRiss_num%>" size="30" > <span class="form_wtxt_link">Example: ALL, 123, or a list</span></td>
            </tr>
            <tr>
              <td align="left" class="wform_ttl">Project&nbsp;Key</td>
              <td nowrap><input name="FRpkey" type="text" class="form_item" id="FRpkey" value="<%=parFRpkey%>" size="30" > <span class="form_wtxt_link">Example: ALL, SLSCM </span></td>
              <td><button id="keyList" class="form_item" onclick="getAllProjectKeys(); return false;">Get&nbsp;All&nbsp;Project&nbsp;Keys</button>
            </tr>
            <tr>
              <td align="left" class="wform_ttl">Jira</td>
              <td><span class="form_item">
                <a href="<%= Application("JIRA_URL") %>" target="_blank"><%= Application("JIRA_URL") %></a>
              </span></td>
            </tr>
        </table>
      </tr>
    <!-- Find, Import and Close Buttons -->
    <tr height="1%">
        <td background="images/lbox_bg_blue.gif" >
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
            <td width="1">&nbsp;
            <td>
                <input type="submit" name="btn" value="Find &raquo;" class="form_btn_comp" onclick="findNewIssues(); return false;">
            </td>
                <td align="center">
                <img id="keyListLoader" valign="middle" src="images/ajax-loader-bar.gif">
            </td>
            <td align="right">
                <input type="submit" name="btn" value="Import" class="form_btn_comp" onclick="addIssues(); return false;">
                <input type="reset"  name="btn" value="Close"  class="form_btn_comp" onclick="closePage(); return false;">
            </td>
        </table>
        </tr>
    <!-- Table of issues wrapper -->
    <tr height="100%"  valign="top">
        <td>
            <table id="issueTable" width="100%" border="0" cellspacing="1" cellpadding="2">
                <tr id="issueheader">
                    <td width="1%" background="images/bg_form_lightbluedark.gif"><input id="checkMaster" type="checkbox" onclick="checkAll(this.checked);"></td>
                    <td width="1%" nowrap background="images/bg_form_lightbluedark.gif" class="form_field">Issue Key</td>
                    <td width="1%" nowrap background="images/bg_form_lightbluedark.gif" class="form_field">State</td>
                    <td width="100%" nowrap background="images/bg_form_lightbluedark.gif" class="form_field">Summary</td>
                </tr>
<%
//              <tr>
//                  <td><input type="checkbox" name="FRiss_id" value='dummyValue'></td>
//                  <td nowrap class="form_item"><a href="dummyValue" target="_blank">dummyValue</a></td>
//                  <td class="form_item">dummyValueState</td>
//                  <td class="form_item">dummyValueSummary</td>
//              </tr>
%>
                <tr id="issuefooter">
                <!-- Number of issues found -->
                    <td background="images/bg_form_lightbluedark.gif">&nbsp;</td>
                    <td id="issueFooterCell" colspan="3" nowrap background="images/bg_form_lightbluedark.gif" class="form_step">Issue List not yet populated</td>
                </tr>
            </table>
        <!-- Next and Previous Buttons -->
        <tr height="1%">
            <td>
            <table width="100%" border="0" cellspacing="1" cellpadding="2">
              <tr>
                <td align="center">
                <a id="first" href="javascript:;" onClick="firstPage();" class="txt_linked">&lt;first</a>
                &nbsp;
                <a id="prev" href="javascript:;" onClick="previousPage();" class="txt_linked">&lt;previous</a>
                &nbsp;&nbsp;
                <a id="next" href="javascript:;" onClick="nextPage();" class="txt_linked">next &gt;</a>
                &nbsp;
                <a id="last" href="javascript:;" onClick="lastPage();" class="txt_linked">last &gt;</a>
              </tr>
            </table>
            </td>
            </tr>
        <!-- Bottom Line -->
        <tr height="1%">
        <tr>
            <td>
                <img src="images/lbox_bg_blue.gif" width="100%" height="5">
            </td>
        </tr>
    </table>
    <input name="pv_id" type="hidden" value="<%=parPv_id%>">
    <input name="rtag_id" type="hidden" value="<%=parRtag_id%>">
    <input name="action" type="hidden" value="true">
</form>
</body>
</html>
<!-- DESTRUCTOR ------->
<!--#include file="common/destructor.asp"-->