Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
119 ghuddy 1
<%@LANGUAGE="VBSCRIPT"%>
2
<%
3
Option explicit
129 ghuddy 4
Response.Expires = 0   ' always load the page, dont store
119 ghuddy 5
%>
6
<%
7
'=====================================================
129 ghuddy 8
'               Import Issues
119 ghuddy 9
'=====================================================
10
%>
11
<!--#include file="common/conf.asp"-->
12
<!--#include file="common/globals.asp"-->
13
<!--#include file="common/qstr.asp"-->
14
<!--#include file="common/common_subs.asp"-->
15
<!--#include file="common/common_dbedit.asp"-->
16
<!--#include file="common/formating.asp"-->
17
<!--#include file="common/_popup_window_common.asp"-->
18
<%
19
' Set rfile parameter. This is a return page after Login
20
Call objPMod.StoreParameter ( "rfile", "fixed_issues.asp" )
21
'------------ ACCESS CONTROL ------------------
22
%>
23
<!--#include file="_access_control_login.asp"-->
24
<!--#include file="_access_control_general.asp"-->
25
<!--#include file="_access_control_project.asp"-->
26
<%
27
'------------ Variable Definition -------------
28
Dim parPv_id
29
Dim parFRiss_id
30
Dim parFRiss_num
171 brianf 31
Dim parFRpkey
119 ghuddy 32
Dim parIStates
33
'------------ Constants Declaration -----------
34
Const LENUM_ALL = "ALL"
35
'------------ Variable Init -------------------
36
parPv_id = Request("pv_id")
37
parRtag_id = Request("rtag_id")
38
parFRiss_id = Request("FRiss_id")
39
parFRiss_num = Request("FRiss_num")
40
parIStates = Request("istates")
171 brianf 41
parFRpkey = Request("FRpkey")
119 ghuddy 42
 
43
'-- CONDITIONS --------------------------------
44
If (parFRiss_num = "") Then parFRiss_num = LENUM_ALL
171 brianf 45
 
46
If (parFRpkey = "") Then
47
  parFRpkey = GetDefaultProjectKey(Request("rtag_id"))
48
  if parFRpkey="" OR IsNull(parFRpkey) Then parFRpkey = LENUM_ALL
49
End If
50
 
119 ghuddy 51
%>
4237 dpurdie 52
<script type="text/javascript" src="scripts/json2.js"></script>
53
<script language="JavaScript" src="scripts/remote_scripting.js"></script>
54
<script type="text/javascript" charset="utf-8">
55
////////////////////////////////////////////////
56
//  Global script variables
57
var currentIssueIndex = 0;
58
var pageSize = 15;
59
var totalIssues = -1;
119 ghuddy 60
 
4237 dpurdie 61
///////////////////////////////////////////////
62
//  Function:    ajaxOpr
63
//  Description: Perform an ajax operation
64
//
65
function ajaxOpr(args, callback)
66
{
67
    xmlHttp=GetXmlHttpObject(function(){ ajaxOprCallback(callback);});
68
    if (xmlHttp==null)
69
    {
70
      alert ("Your browser does not support AJAX!");
71
      return;
72
    }
129 ghuddy 73
 
4237 dpurdie 74
    var url = "_json_jiraIssues.asp?" + args;
129 ghuddy 75
 
4237 dpurdie 76
    // Show spinner
77
    var el = document.getElementById("keyListLoader");
78
    if (el)
79
    {
80
        el.style.display = 'inline';
81
    }
129 ghuddy 82
 
4237 dpurdie 83
    // Use async request, otherwise the spinner will not work
84
    xmlHttp.open("GET",url,true);  // `false` makes the request synchronous
85
    xmlHttp.send(null);
86
}
87
///////////////////////////////////////////////
88
//  Function:    ajaxOprCallback
89
//  Description: Perform an Ajax operation generic error handling
90
//  Args       : callback - Function to process json results
91
//                          Json has been decoded and is a javascript object
92
//                          Handle errors for the user
93
//
94
function ajaxOprCallback(callback)
95
{
96
    //readyState of 4 or 'complete' represents that data has been returned
97
    if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
98
    {
99
        // Hide spinner
100
        var el = document.getElementById("keyListLoader");
101
        if (el) {
102
            el.style.display = 'none';
103
        }
129 ghuddy 104
 
4237 dpurdie 105
        // alert("Got to getAllProjectKeysDone"+ xmlHttp.responseText);
106
        if (xmlHttp.status !== 200) {
107
            alert("Internal AJAX error: " + xmlHttp.status);
108
        }
109
        else
110
        {
111
            // Gather the results from the callback
112
            var str = xmlHttp.responseText;
113
            try {
114
                var myJson = JSON.parse(str);
115
                //alert("ajaxOprCallback:" + str);
116
                if (myJson.result != 0) {
117
                    alert("AJAX request error: " + myJson.emsgSummary);
118
                }
119
                else {
120
                    callback(myJson);
121
                }
122
            }
123
            catch(e) {
124
            }
125
        }
126
    }
127
}
129 ghuddy 128
 
4237 dpurdie 129
///////////////////////////////////////////////
130
// Function: getAllProjectKeys
131
//           Populate a dropdown box of all project keys
132
//           This may take some time so its not done during
133
//           the page load. Only on user request
134
function getAllProjectKeys()
135
{
136
    var el = document.getElementById("keyList")
137
    if (el)
138
    {
139
        ajaxOpr('Opr=getAllKeys', getAllProjectKeysDone);
140
    }
141
}
142
///////////////////////////////////////////////
143
//  Function:       getAllProjectKeysDone   
144
//  Description:    Populate the keyList with a selection list
145
//
146
function getAllProjectKeysDone(myJson)
147
{
148
    if (typeof myJson.keyList != "undefined")
149
    {
150
        var el = document.getElementById("keyList");
151
        if (el)
152
        {
153
            var data;
154
            data = document.createElement("span");
155
            data.innerHTML=myJson.keyList;
156
            var a = el.parentNode.replaceChild(data, el);
129 ghuddy 157
 
4237 dpurdie 158
            // Insert nice class information
159
            el = document.getElementById("keyListSelect");
160
            if (el)
161
            {
162
                el.className = el.className + " form_item";
163
                el.onchange = useProjectKey;
164
            }
165
        }
166
    }
167
}
168
////////////////////////////////////////
169
//  Function:       useProjectKey
170
//  Description:    Update the Project Key from the Selection box
171
//
172
function useProjectKey()
173
{
174
    var el = document.getElementById("keyListSelect");
175
    var pk = document.getElementById("FRpkey");
176
    if (el && pk)
177
    {
178
        pk.value = el.value;
179
    }
180
}
181
///////////////////////////////////////////////
182
//  Function:    findNewIssues, firstPage, nextPage, previousPage, lastPage
183
//  Description: Navigate through the pages
184
//
185
function findNewIssues()
186
{
187
    currentIssueIndex = 0;
188
    totalIssues = -1;
189
    findIssues();
190
}
191
function firstPage()
192
{
193
    currentIssueIndex = 0;
194
    findIssues();
195
}
196
function nextPage()
197
{
198
    currentIssueIndex += pageSize;
199
    if (totalIssues > 0 && currentIssueIndex > totalIssues)
200
    {
201
        currentIssueIndex = totalIssues - pageSize; 
202
    }
203
    findIssues();
204
}
205
function previousPage()
206
{
207
    currentIssueIndex -= pageSize;
208
    if (currentIssueIndex < 0)
209
    {
210
        currentIssueIndex = 0;
211
    }
212
    findIssues();
213
}
214
function lastPage()
215
{
216
    if (totalIssues > 0)
217
    {
218
        currentIssueIndex = totalIssues - pageSize; 
219
    }
220
    findIssues();
221
}
129 ghuddy 222
 
4237 dpurdie 223
///////////////////////////////////////////////
224
//  Function:    findIssues
225
//  Description: Find issues that match the users search criteria
226
//               Will populate the page via AJAX
227
//
228
function findIssues()
229
{
230
    // Ensure that the user is not about to discard any required work
231
    if (checkOutstanding()) {
232
        return;
233
    }
234
    var is = document.getElementById("FRiss_num");
235
    var pk = document.getElementById("FRpkey");
236
    var cm = document.getElementById("checkMaster");
237
    if (cm) cm.checked = false;
238
    if (is && pk)
239
    {
240
        ajaxOpr('Opr=getIssues&Project=' + pk.value
241
                + '&Issue=' + is.value 
242
                + "&StartAt=" + currentIssueIndex 
243
                + "&Count=" + pageSize
244
                + '&pv_id=' + <%=parPv_id%> ,
245
                findIssueDone);
246
    }
247
}
248
///////////////////////////////////////////////
249
//  Function:    findIssueDone
250
//  Description: Called when Issue list has been collected
251
//               Will be called if there has been an error
252
//
253
function findIssueDone(myJson)
254
{
255
    //  Save total issues on the page
256
    totalIssues = myJson.issueCount;
3975 dpurdie 257
 
4237 dpurdie 258
    // Delete existing table entries
259
    // Retain the header and foot - these have IDs
260
    var table = document.getElementById("issueTable");
261
    var rowCount = table.rows.length;
262
    for (var i = rowCount - 1; i >= 0 ; i--)
263
    {
264
        if (! table.rows[i].id)
265
        {
266
            table.deleteRow(i);
267
        }
268
    }
129 ghuddy 269
 
4237 dpurdie 270
    //  Create entries that look like these:
271
    //  <td><input type="checkbox" name="iss_id" value='dummyValue'></td>
272
    //  <td nowrap class="form_item"><a href="dummyValue" target="_blank">key/a></td>
273
    //  <td class="form_item">State</td>
274
    //  <td class="form_item">Summary</td>
129 ghuddy 275
 
4237 dpurdie 276
    for (var id in myJson.issues)
277
    {
278
        var obj = myJson.issues[id];
279
        var row = table.insertRow(table.rows.length - 1);
280
        var cell1 = row.insertCell(0);
281
        var cell2 = row.insertCell(1);
282
        var cell3 = row.insertCell(2);
283
        var cell4 = row.insertCell(3);
119 ghuddy 284
 
4237 dpurdie 285
        var x = document.createElement("INPUT");
286
        x.setAttribute('type', 'checkbox');
287
        x.setAttribute('name', obj.key);
288
        x.setAttribute('value', obj.key);
289
        if (obj.inuse)
290
        {
291
            x.disabled=true;
292
            x.checked=true;
293
        }
294
        cell1.appendChild(x);
129 ghuddy 295
 
4237 dpurdie 296
        cell2.className = 'form_item';
297
        cell2.style.whiteSpace="nowrap";
298
        var t = document.createTextNode(obj.key);
299
        x = document.createElement("A");
300
        x.href = obj.url;
301
        x.target = "_blank";
302
        x.appendChild(t);
303
        cell2.appendChild(x);
129 ghuddy 304
 
4237 dpurdie 305
        cell3.className = 'form_item';
306
        cell3.innerHTML = obj.status;
129 ghuddy 307
 
4237 dpurdie 308
        cell4.className = 'form_item';
309
        cell4.innerHTML = obj.summary;
310
    }
119 ghuddy 311
 
4237 dpurdie 312
    // Create the footer information
313
    // ie: Found 70860 records, showing 1 - 15
314
    var footer = document.getElementById("issueFooterCell");
315
    if (footer)
316
    {
317
        footer.innerHTML="Found "+ 
318
                          myJson.issueCount +
319
                          " records. Showing " + 
320
                          myJson.startAt + " - " + 
321
                          (myJson.startAt + myJson.issues.length);
322
    }
323
}
324
///////////////////////////////////////////////
325
//  Function:    checkAll
326
//  Description: check all tick boxes in the table
327
//
328
function checkAll(state)
329
{
330
    var table = document.getElementById("issueTable");
331
    var rowCount = table.rows.length;
332
    for (var i = rowCount - 1; i >= 0 ; i--)
333
    {
334
        if (! table.rows[i].id)
335
        {
336
            var cell = table.rows[i].cells[0].children[0];
337
            if (! cell.disabled)
338
            {
339
                cell.checked = state;
340
            }
341
        }
342
    }
343
}
344
///////////////////////////////////////////////
345
//  Function:       disableChecked
346
//  Description:    Disable all items that are checked 
347
//                  Used after items have been inserted
348
//
349
function disableChecked()
350
{
351
    var table = document.getElementById("issueTable");
352
    var rowCount = table.rows.length;
353
    for (var i = rowCount - 1; i >= 1 ; i--)
354
    {
355
        if (! table.rows[i].id)
356
        {
357
            var cell = table.rows[i].cells[0].children[0];
358
            if (cell.checked)
359
            {
360
                cell.disabled = true;
361
            }
362
        }
363
    }
364
}
365
///////////////////////////////////////////////
366
//  Function:       checkOutstanding
367
//  Description:    Check if user has checked items that have not yet been actioned
368
//                  Generate alert if so
369
//  Returns:        False - OK to proceed
370
//
371
function checkOutstanding()
372
{
373
    var table = document.getElementById("issueTable");
374
    var rowCount = table.rows.length;
375
    var found = 0
376
    for (var i = rowCount - 1; i >= 1 ; i--)
377
    {
378
        if (! table.rows[i].id)
379
        {
380
            var cell = table.rows[i].cells[0].children[0];
381
            if (cell.checked && ! cell.disabled)
382
            {
383
                found++;
384
            }
385
        }
386
    }
387
    if (found)
388
    {
389
        if (confirm("Issues have been selected but not actioned. Do you want to discard selection?") == true ) {
390
            found = 0
391
        }
392
    }
393
    return found != 0;
394
}
129 ghuddy 395
 
4237 dpurdie 396
///////////////////////////////////////////////
397
//  Function:    addIssues
398
//  Description: Scan for checked buttons and add issues to package-version
399
//
400
function addIssues()
401
{
402
    // Create an array of issues to be added
403
    var table = document.getElementById("issueTable");
404
    var rowCount = table.rows.length;
405
    var list = [];
406
    for (var i = 1; i < rowCount; i++)
407
    {
408
        if (! table.rows[i].id)
409
        {
410
            var cell = table.rows[i].cells[0].children[0];
411
            if (cell && cell.type === "checkbox" && ! cell.disabled && cell.checked)
412
            {
413
                list.push(cell.value);
414
            }
415
        }
416
    }
417
    if (list.length > 0)
418
    {
419
    //  Call backend AJAX script to do the hardwork
129 ghuddy 420
 
4237 dpurdie 421
    ajaxOpr('Opr=insertIssues&pv_id=' + <%=parPv_id%>
422
            + '&Issue=' + list.join(","), function(myJson){
423
                window.opener.document.location='fixed_issues.asp?pv_id=<%=parPv_id%>&rtag_id=<%=parRtag_id%>';
424
                disableChecked();
425
            });
426
    }
427
}
428
///////////////////////////////////////////////
429
//  Function:    closePage
430
//  Description: close this page, unless there is workk to be done
431
//
432
function closePage()
433
{
434
    if (checkOutstanding()) {
435
        return;
436
    }
437
    self.close();
438
}
439
///////////////////////////////////////////////
440
//  Function:       Window Onload
441
//  Description:    Init the page, in a browser independent manner
442
//
443
if (window.addEventListener) { // W3C standard
444
  window.addEventListener('load', initPage, false);
445
} else if (window.attachEvent) { // Microsoft
446
  window.attachEvent('onload', initPage);
447
}
448
function initPage(){
449
    // Hide spinner
450
    var el = document.getElementById("keyListLoader");
451
    if (el) {
452
        el.style.display = 'none';
453
    }
129 ghuddy 454
 
4237 dpurdie 455
    <% If parFRpkey <> LENUM_ALL Then %>
456
    // Populate the display
457
    findNewIssues();
458
    <%End If %>
459
};
460
</script>
461
<%
119 ghuddy 462
'------------------------------------------------------------------------------------------------------------------------------------
171 brianf 463
Function GetDefaultProjectKey(artag_id)
464
   Dim rsProjId
4981 dpurdie 465
   If artag_id <> "" Then
466
       Set rsProjId = OraDatabase.DbCreateDynaset( _
467
            "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))
468
       GetDefaultProjectKey = rsProjId("jira_key")
469
       Set rsProjId = Nothing
470
   Else
471
        GetDefaultProjectKey = ""
472
   End If
473
 
171 brianf 474
End Function
475
'------------------------------------------------------------------------------------------------------------------------------------
119 ghuddy 476
%>
477
<%
478
'-------------- Main Line ---------------
479
%>
480
<html>
481
<head>
482
<title>Release Manager</title>
483
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
484
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
485
<link rel="stylesheet" href="images/release_manager_style.css" type="text/css">
486
<link rel="stylesheet" href="images/navigation.css" type="text/css">
487
<script language="JavaScript" src="images/common.js"></script>
488
</head>
489
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" onload="self.focus();">
4237 dpurdie 490
<form name="importform">
491
    <!-- First button is the default button. Control its operation -->
492
    <input type="hidden" name="dummy" value="dummy" onclick="findNewIssues(); return false;"/>
4235 dpurdie 493
    <table width="100%" height="100%" border="0" cellspacing="0" cellpadding="2">
494
    <!-- Form Body -->
495
    <tr height="1%">
496
      <td nowrap class="wform_ttl" background="images/bg_admin_dark.gif">
497
        <table border="0" cellspacing="5" cellpadding="0">
498
            <tr>
499
              <td align="left" class="wform_ttl">Issue&nbsp;Number</td>
500
              <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>
501
            </tr>
502
            <tr>
503
              <td align="left" class="wform_ttl">Project&nbsp;Key</td>
504
              <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>
4237 dpurdie 505
              <td><button id="keyList" class="form_item" onclick="getAllProjectKeys(); return false;">Get All Project Keys</button>
4235 dpurdie 506
            </tr>
507
            <tr>
4237 dpurdie 508
              <td align="left" class="wform_ttl">Jira</td>
509
              <td><span class="form_item">
510
                <a href="<%=JIRA_URL%>" target="_blank"><%=JIRA_URL%></a>
511
              </span></td>
4235 dpurdie 512
            </tr>
513
        </table>
514
      </tr>
4236 dpurdie 515
    <!-- Find, Import and Close Buttons -->
4235 dpurdie 516
    <tr height="1%">
517
        <td background="images/lbox_bg_blue.gif" >
518
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
519
            <tr>
4236 dpurdie 520
            <td width="1">&nbsp;
521
            <td>
4237 dpurdie 522
                <input type="submit" name="btn" value="Find &raquo;" class="form_btn_comp" onclick="findNewIssues(); return false;">
523
            </td>
524
                <td align="center">
525
                <img id="keyListLoader" valign="middle" src="images/ajax-loader-bar.gif">
526
            </td>
4235 dpurdie 527
            <td align="right">
4237 dpurdie 528
                <input type="submit" name="btn" value="Import" class="form_btn_comp" onclick="addIssues(); return false;">
529
                <input type="reset"  name="btn" value="Close"  class="form_btn_comp" onclick="closePage(); return false;">
129 ghuddy 530
            </td>
119 ghuddy 531
        </table>
4235 dpurdie 532
        </tr>
533
    <!-- Table of issues wrapper -->
4236 dpurdie 534
    <tr height="100%"  valign="top">
4235 dpurdie 535
        <td>
4237 dpurdie 536
            <table id="issueTable" width="100%" border="0" cellspacing="1" cellpadding="2">
537
                <tr id="issueheader">
538
                    <td width="1%" background="images/bg_form_lightbluedark.gif"><input id="checkMaster" type="checkbox" onclick="checkAll(this.checked);"></td>
4235 dpurdie 539
                    <td width="1%" nowrap background="images/bg_form_lightbluedark.gif" class="form_field">Issue Key</td>
540
                    <td width="1%" nowrap background="images/bg_form_lightbluedark.gif" class="form_field">State</td>
541
                    <td width="100%" nowrap background="images/bg_form_lightbluedark.gif" class="form_field">Summary</td>
4237 dpurdie 542
                </tr>
543
<%
544
//              <tr>
545
//                  <td><input type="checkbox" name="FRiss_id" value='dummyValue'></td>
546
//                  <td nowrap class="form_item"><a href="dummyValue" target="_blank">dummyValue</a></td>
547
//                  <td class="form_item">dummyValueState</td>
548
//                  <td class="form_item">dummyValueSummary</td>
549
//              </tr>
550
%>
551
                <tr id="issuefooter">
4235 dpurdie 552
                <!-- Number of issues found -->
553
                    <td background="images/bg_form_lightbluedark.gif">&nbsp;</td>
4237 dpurdie 554
                    <td id="issueFooterCell" colspan="3" nowrap background="images/bg_form_lightbluedark.gif" class="form_step">Issue List not yet populated</td>
555
                </tr>
4235 dpurdie 556
            </table>
557
        <!-- Next and Previous Buttons -->
4236 dpurdie 558
        <tr height="1%">
4235 dpurdie 559
            <td>
560
            <table width="100%" border="0" cellspacing="1" cellpadding="2">
561
              <tr>
562
                <td align="center">
4237 dpurdie 563
                <a id="first" href="javascript:;" onClick="firstPage();" class="txt_linked">&lt;first</a>
564
                &nbsp;
565
                <a id="prev" href="javascript:;" onClick="previousPage();" class="txt_linked">&lt;previous</a>
566
                &nbsp;&nbsp;
567
                <a id="next" href="javascript:;" onClick="nextPage();" class="txt_linked">next &gt;</a>
568
                &nbsp;
569
                <a id="last" href="javascript:;" onClick="lastPage();" class="txt_linked">last &gt;</a>
4235 dpurdie 570
              </tr>
571
            </table>
572
            </td>
573
            </tr>
574
        <!-- Bottom Line -->
4236 dpurdie 575
        <tr height="1%">
4235 dpurdie 576
        <tr>
577
            <td>
578
                <img src="images/lbox_bg_blue.gif" width="100%" height="5">
579
            </td>
580
        </tr>
581
    </table>
582
    <input name="pv_id" type="hidden" value="<%=parPv_id%>">
583
    <input name="rtag_id" type="hidden" value="<%=parRtag_id%>">
584
    <input name="action" type="hidden" value="true">
119 ghuddy 585
</form>
586
</body>
587
</html>
588
<!-- DESTRUCTOR ------->
129 ghuddy 589
<!--#include file="common/destructor.asp"-->