Subversion Repositories DevTools

Rev

Rev 6676 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5357 dpurdie 1
<%@LANGUAGE="VBSCRIPT"%>
2
<%
3
Option explicit
4
Response.Expires = 0   ' always load the page, dont store
5
%>
6
<%
7
'=====================================================
8
'               Import Issues
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
31
Dim parFRpkey
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")
41
parFRpkey = Request("FRpkey")
42
 
43
'-- CONDITIONS --------------------------------
44
If (parFRiss_num = "") Then parFRiss_num = LENUM_ALL
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
 
51
%>
6676 dpurdie 52
<script type="text/javascript" src="scripts/json2.js?ver=<%=VixVerNum%>"></script>
6579 dpurdie 53
<script language="JavaScript" src="scripts/remote_scripting.js?ver=<%=VixVerNum%>"></script>
5357 dpurdie 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;
60
 
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
    }
73
 
74
    var url = "_json_jiraIssues.asp?" + args;
75
 
76
    // Show spinner
77
    var el = document.getElementById("keyListLoader");
78
    if (el)
79
    {
80
        el.style.display = 'inline';
81
    }
82
 
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
        }
104
 
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
}
128
 
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);
157
 
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
        }
5590 dpurdie 166
 
167
        parent.resizeIframe();
5357 dpurdie 168
    }
169
}
170
////////////////////////////////////////
171
//  Function:       useProjectKey
172
//  Description:    Update the Project Key from the Selection box
173
//
174
function useProjectKey()
175
{
176
    var el = document.getElementById("keyListSelect");
177
    var pk = document.getElementById("FRpkey");
178
    if (el && pk)
179
    {
180
        pk.value = el.value;
181
    }
182
}
183
///////////////////////////////////////////////
184
//  Function:    findNewIssues, firstPage, nextPage, previousPage, lastPage
185
//  Description: Navigate through the pages
186
//
187
function findNewIssues()
188
{
189
    currentIssueIndex = 0;
190
    totalIssues = -1;
191
    findIssues();
192
}
193
function firstPage()
194
{
195
    currentIssueIndex = 0;
196
    findIssues();
197
}
198
function nextPage()
199
{
200
    currentIssueIndex += pageSize;
201
    if (totalIssues > 0 && currentIssueIndex > totalIssues)
202
    {
203
        currentIssueIndex = totalIssues - pageSize; 
204
    }
205
    findIssues();
206
}
207
function previousPage()
208
{
209
    currentIssueIndex -= pageSize;
210
    if (currentIssueIndex < 0)
211
    {
212
        currentIssueIndex = 0;
213
    }
214
    findIssues();
215
}
216
function lastPage()
217
{
218
    if (totalIssues > 0)
219
    {
220
        currentIssueIndex = totalIssues - pageSize; 
221
    }
222
    findIssues();
223
}
224
 
225
///////////////////////////////////////////////
226
//  Function:    findIssues
227
//  Description: Find issues that match the users search criteria
228
//               Will populate the page via AJAX
229
//
230
function findIssues()
231
{
232
    // Ensure that the user is not about to discard any required work
233
    if (checkOutstanding()) {
234
        return;
235
    }
236
    var is = document.getElementById("FRiss_num");
237
    var pk = document.getElementById("FRpkey");
238
    var cm = document.getElementById("checkMaster");
239
    if (cm) cm.checked = false;
240
    if (is && pk)
241
    {
242
        ajaxOpr('Opr=getIssues&Project=' + pk.value
243
                + '&Issue=' + is.value 
244
                + "&StartAt=" + currentIssueIndex 
245
                + "&Count=" + pageSize
246
                + '&pv_id=' + <%=parPv_id%> ,
247
                findIssueDone);
248
    }
249
}
250
///////////////////////////////////////////////
251
//  Function:    findIssueDone
252
//  Description: Called when Issue list has been collected
253
//               Will be called if there has been an error
254
//
255
function findIssueDone(myJson)
256
{
257
    //  Save total issues on the page
258
    totalIssues = myJson.issueCount;
259
 
260
    // Delete existing table entries
261
    // Retain the header and foot - these have IDs
262
    var table = document.getElementById("issueTable");
263
    var rowCount = table.rows.length;
264
    for (var i = rowCount - 1; i >= 0 ; i--)
265
    {
266
        if (! table.rows[i].id)
267
        {
268
            table.deleteRow(i);
269
        }
270
    }
271
 
272
    //  Create entries that look like these:
273
    //  <td><input type="checkbox" name="iss_id" value='dummyValue'></td>
274
    //  <td nowrap class="form_item"><a href="dummyValue" target="_blank">key/a></td>
275
    //  <td class="form_item">State</td>
276
    //  <td class="form_item">Summary</td>
277
 
278
    for (var id in myJson.issues)
279
    {
280
        var obj = myJson.issues[id];
281
        var row = table.insertRow(table.rows.length - 1);
282
        var cell1 = row.insertCell(0);
283
        var cell2 = row.insertCell(1);
284
        var cell3 = row.insertCell(2);
285
        var cell4 = row.insertCell(3);
286
 
287
        var x = document.createElement("INPUT");
288
        x.setAttribute('type', 'checkbox');
289
        x.setAttribute('name', obj.key);
290
        x.setAttribute('value', obj.key);
291
        if (obj.inuse)
292
        {
293
            x.disabled=true;
294
            x.checked=true;
295
        }
296
        cell1.appendChild(x);
297
 
298
        cell2.className = 'form_item';
299
        cell2.style.whiteSpace="nowrap";
300
        var t = document.createTextNode(obj.key);
301
        x = document.createElement("A");
302
        x.href = obj.url;
303
        x.target = "_blank";
304
        x.appendChild(t);
305
        cell2.appendChild(x);
306
 
307
        cell3.className = 'form_item';
308
        cell3.innerHTML = obj.status;
309
 
310
        cell4.className = 'form_item';
311
        cell4.innerHTML = obj.summary;
312
    }
313
 
314
    // Create the footer information
315
    // ie: Found 70860 records, showing 1 - 15
316
    var footer = document.getElementById("issueFooterCell");
317
    if (footer)
318
    {
319
        footer.innerHTML="Found "+ 
320
                          myJson.issueCount +
321
                          " records. Showing " + 
322
                          myJson.startAt + " - " + 
323
                          (myJson.startAt + myJson.issues.length);
324
    }
5590 dpurdie 325
 
326
    parent.resizeIframe();
5357 dpurdie 327
}
328
///////////////////////////////////////////////
329
//  Function:    checkAll
330
//  Description: check all tick boxes in the table
331
//
332
function checkAll(state)
333
{
334
    var table = document.getElementById("issueTable");
335
    var rowCount = table.rows.length;
336
    for (var i = rowCount - 1; i >= 0 ; i--)
337
    {
338
        if (! table.rows[i].id)
339
        {
340
            var cell = table.rows[i].cells[0].children[0];
341
            if (! cell.disabled)
342
            {
343
                cell.checked = state;
344
            }
345
        }
346
    }
347
}
348
///////////////////////////////////////////////
349
//  Function:       disableChecked
350
//  Description:    Disable all items that are checked 
351
//                  Used after items have been inserted
352
//
353
function disableChecked()
354
{
355
    var table = document.getElementById("issueTable");
356
    var rowCount = table.rows.length;
357
    for (var i = rowCount - 1; i >= 1 ; i--)
358
    {
359
        if (! table.rows[i].id)
360
        {
361
            var cell = table.rows[i].cells[0].children[0];
362
            if (cell.checked)
363
            {
364
                cell.disabled = true;
365
            }
366
        }
367
    }
368
}
369
///////////////////////////////////////////////
370
//  Function:       checkOutstanding
371
//  Description:    Check if user has checked items that have not yet been actioned
372
//                  Generate alert if so
373
//  Returns:        False - OK to proceed
374
//
375
function checkOutstanding()
376
{
377
    var table = document.getElementById("issueTable");
378
    var rowCount = table.rows.length;
379
    var found = 0
380
    for (var i = rowCount - 1; i >= 1 ; i--)
381
    {
382
        if (! table.rows[i].id)
383
        {
384
            var cell = table.rows[i].cells[0].children[0];
385
            if (cell.checked && ! cell.disabled)
386
            {
387
                found++;
388
            }
389
        }
390
    }
391
    if (found)
392
    {
393
        if (confirm("Issues have been selected but not actioned. Do you want to discard selection?") == true ) {
394
            found = 0
395
        }
396
    }
397
    return found != 0;
398
}
399
 
400
///////////////////////////////////////////////
401
//  Function:    addIssues
402
//  Description: Scan for checked buttons and add issues to package-version
403
//
404
function addIssues()
405
{
406
    // Create an array of issues to be added
407
    var table = document.getElementById("issueTable");
408
    var rowCount = table.rows.length;
409
    var list = [];
410
    for (var i = 1; i < rowCount; i++)
411
    {
412
        if (! table.rows[i].id)
413
        {
414
            var cell = table.rows[i].cells[0].children[0];
415
            if (cell && cell.type === "checkbox" && ! cell.disabled && cell.checked)
416
            {
417
                list.push(cell.value);
418
            }
419
        }
420
    }
421
    if (list.length > 0)
422
    {
423
    //  Call backend AJAX script to do the hardwork
424
 
425
    ajaxOpr('Opr=insertIssues&pv_id=' + <%=parPv_id%>
426
            + '&Issue=' + list.join(","), function(myJson){
427
                disableChecked();
428
            });
429
    }
430
}
431
///////////////////////////////////////////////
432
//  Function:    closePage
433
//  Description: close this page, unless there is workk to be done
434
//
435
function closePage()
436
{
437
    if (checkOutstanding()) {
438
        return;
439
    }
5590 dpurdie 440
    window.parent.location.reload(false);
5357 dpurdie 441
}
442
///////////////////////////////////////////////
443
//  Function:       Window Onload
444
//  Description:    Init the page, in a browser independent manner
445
//
446
if (window.addEventListener) { // W3C standard
447
  window.addEventListener('load', initPage, false);
448
} else if (window.attachEvent) { // Microsoft
449
  window.attachEvent('onload', initPage);
450
}
451
function initPage(){
452
    // Hide spinner
453
    var el = document.getElementById("keyListLoader");
454
    if (el) {
455
        el.style.display = 'none';
456
    }
457
 
458
    <% If parFRpkey <> LENUM_ALL Then %>
459
    // Populate the display
460
    findNewIssues();
461
    <%End If %>
462
};
463
</script>
464
<%
465
'------------------------------------------------------------------------------------------------------------------------------------
466
Function GetDefaultProjectKey(artag_id)
467
   Dim rsProjId
468
   If artag_id <> "" Then
469
       Set rsProjId = OraDatabase.DbCreateDynaset( _
470
            "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))
471
       GetDefaultProjectKey = rsProjId("jira_key")
472
       Set rsProjId = Nothing
473
   Else
474
        GetDefaultProjectKey = ""
475
   End If
476
 
477
End Function
478
'------------------------------------------------------------------------------------------------------------------------------------
479
%>
480
<%
481
'-------------- Main Line ---------------
482
%>
483
<html>
484
<head>
485
<title>Release Manager</title>
486
<link rel="shortcut icon" href="<%=FavIcon%>"/>
487
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
488
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
6579 dpurdie 489
<link rel="stylesheet" href="images/release_manager_style.css?ver=<%=VixVerNum%>" type="text/css">
490
<link rel="stylesheet" href="images/navigation.css?ver=<%=VixVerNum%>" type="text/css">
491
<script language="JavaScript" src="images/common.js?ver=<%=VixVerNum%>"></script>
5590 dpurdie 492
<!--#include file="_jquery_includes.asp"-->
5357 dpurdie 493
</head>
494
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" onload="self.focus();">
495
<form name="importform">
496
    <!-- First button is the default button. Control its operation -->
497
    <input type="hidden" name="dummy" value="dummy" onclick="findNewIssues(); return false;"/>
5590 dpurdie 498
    <table border="0" cellspacing="0" cellpadding="2" >
5357 dpurdie 499
    <!-- Form Body -->
500
    <tr height="1%">
501
      <td nowrap class="wform_ttl" background="images/bg_admin_dark.gif">
502
        <table border="0" cellspacing="5" cellpadding="0">
503
            <tr>
504
              <td align="left" class="wform_ttl">Issue&nbsp;Number</td>
505
              <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>
506
            </tr>
507
            <tr>
508
              <td align="left" class="wform_ttl">Project&nbsp;Key</td>
509
              <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>
5892 dpurdie 510
              <td><button type="button" id="keyList" class="form_item" onclick="getAllProjectKeys(); return false;">Get&nbsp;All&nbsp;Project&nbsp;Keys</button>
5357 dpurdie 511
            </tr>
512
            <tr>
513
              <td align="left" class="wform_ttl">Jira</td>
514
              <td><span class="form_item">
5375 dpurdie 515
                <a href="<%= Application("JIRA_URL") %>" target="_blank"><%= Application("JIRA_URL") %></a>
5357 dpurdie 516
              </span></td>
517
            </tr>
518
        </table>
519
      </tr>
520
    <!-- Find, Import and Close Buttons -->
521
    <tr height="1%">
522
        <td background="images/lbox_bg_blue.gif" >
523
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
524
            <tr>
525
            <td width="1">&nbsp;
526
            <td>
527
                <input type="submit" name="btn" value="Find &raquo;" class="form_btn_comp" onclick="findNewIssues(); return false;">
528
            </td>
529
                <td align="center">
530
                <img id="keyListLoader" valign="middle" src="images/ajax-loader-bar.gif">
531
            </td>
532
            <td align="right">
533
                <input type="submit" name="btn" value="Import" class="form_btn_comp" onclick="addIssues(); return false;">
534
                <input type="reset"  name="btn" value="Close"  class="form_btn_comp" onclick="closePage(); return false;">
535
            </td>
536
        </table>
537
        </tr>
538
    <!-- Table of issues wrapper -->
539
    <tr height="100%"  valign="top">
540
        <td>
541
            <table id="issueTable" width="100%" border="0" cellspacing="1" cellpadding="2">
542
                <tr id="issueheader">
543
                    <td width="1%" background="images/bg_form_lightbluedark.gif"><input id="checkMaster" type="checkbox" onclick="checkAll(this.checked);"></td>
544
                    <td width="1%" nowrap background="images/bg_form_lightbluedark.gif" class="form_field">Issue Key</td>
545
                    <td width="1%" nowrap background="images/bg_form_lightbluedark.gif" class="form_field">State</td>
546
                    <td width="100%" nowrap background="images/bg_form_lightbluedark.gif" class="form_field">Summary</td>
547
                </tr>
548
<%
549
//              <tr>
550
//                  <td><input type="checkbox" name="FRiss_id" value='dummyValue'></td>
551
//                  <td nowrap class="form_item"><a href="dummyValue" target="_blank">dummyValue</a></td>
552
//                  <td class="form_item">dummyValueState</td>
553
//                  <td class="form_item">dummyValueSummary</td>
554
//              </tr>
555
%>
556
                <tr id="issuefooter">
557
                <!-- Number of issues found -->
558
                    <td background="images/bg_form_lightbluedark.gif">&nbsp;</td>
559
                    <td id="issueFooterCell" colspan="3" nowrap background="images/bg_form_lightbluedark.gif" class="form_step">Issue List not yet populated</td>
560
                </tr>
561
            </table>
562
        <!-- Next and Previous Buttons -->
563
        <tr height="1%">
564
            <td>
565
            <table width="100%" border="0" cellspacing="1" cellpadding="2">
566
              <tr>
567
                <td align="center">
6827 dpurdie 568
                <a id="first" onClick="firstPage();" class="txt_linked pointer">&lt;first</span>&nbsp;
569
                <a id="prev"  onClick="previousPage();" class="txt_linked pointer">&lt;previous</span>&nbsp;&nbsp;
570
                <a id="next"  onClick="nextPage();" class="txt_linked pointer">next &gt;</span>&nbsp;
571
                <a id="last"  onClick="lastPage();" class="txt_linked pointer">last &gt;</span>
5357 dpurdie 572
              </tr>
573
            </table>
574
            </td>
575
            </tr>
576
        <!-- Bottom Line -->
577
        <tr height="1%">
578
        <tr>
579
            <td>
580
                <img src="images/lbox_bg_blue.gif" width="100%" height="5">
581
            </td>
582
        </tr>
583
    </table>
584
    <input name="pv_id" type="hidden" value="<%=parPv_id%>">
585
    <input name="rtag_id" type="hidden" value="<%=parRtag_id%>">
586
    <input name="action" type="hidden" value="true">
587
</form>
588
</body>
589
</html>
590
<!-- DESTRUCTOR ------->
591
<!--#include file="common/destructor.asp"-->