Subversion Repositories DevTools

Rev

Rev 5375 | Rev 5590 | Go to most recent revision | 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
%>
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;
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
        }
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
}
222
 
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;
257
 
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
    }
269
 
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>
275
 
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);
284
 
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);
295
 
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);
304
 
305
        cell3.className = 'form_item';
306
        cell3.innerHTML = obj.status;
307
 
308
        cell4.className = 'form_item';
309
        cell4.innerHTML = obj.summary;
310
    }
311
 
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
}
395
 
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
420
 
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
    }
454
 
455
    <% If parFRpkey <> LENUM_ALL Then %>
456
    // Populate the display
457
    findNewIssues();
458
    <%End If %>
459
};
460
</script>
461
<%
462
'------------------------------------------------------------------------------------------------------------------------------------
463
Function GetDefaultProjectKey(artag_id)
464
   Dim rsProjId
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
 
474
End Function
475
'------------------------------------------------------------------------------------------------------------------------------------
476
%>
477
<%
478
'-------------- Main Line ---------------
479
%>
480
<html>
481
<head>
482
<title>Release Manager</title>
483
<link rel="shortcut icon" href="<%=FavIcon%>"/>
484
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
485
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
486
<link rel="stylesheet" href="images/release_manager_style.css" type="text/css">
487
<link rel="stylesheet" href="images/navigation.css" type="text/css">
488
<script language="JavaScript" src="images/common.js"></script>
489
</head>
490
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" onload="self.focus();">
491
<form name="importform">
492
    <!-- First button is the default button. Control its operation -->
493
    <input type="hidden" name="dummy" value="dummy" onclick="findNewIssues(); return false;"/>
494
    <table width="100%" height="100%" border="0" cellspacing="0" cellpadding="2">
495
    <!-- Form Body -->
496
    <tr height="1%">
497
      <td nowrap class="wform_ttl" background="images/bg_admin_dark.gif">
498
        <table border="0" cellspacing="5" cellpadding="0">
499
            <tr>
500
              <td align="left" class="wform_ttl">Issue&nbsp;Number</td>
501
              <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>
502
            </tr>
503
            <tr>
504
              <td align="left" class="wform_ttl">Project&nbsp;Key</td>
505
              <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>
506
              <td><button id="keyList" class="form_item" onclick="getAllProjectKeys(); return false;">Get All Project Keys</button>
507
            </tr>
508
            <tr>
509
              <td align="left" class="wform_ttl">Jira</td>
510
              <td><span class="form_item">
5375 dpurdie 511
                <a href="<%= Application("JIRA_URL") %>" target="_blank"><%= Application("JIRA_URL") %></a>
5357 dpurdie 512
              </span></td>
513
            </tr>
514
        </table>
515
      </tr>
516
    <!-- Find, Import and Close Buttons -->
517
    <tr height="1%">
518
        <td background="images/lbox_bg_blue.gif" >
519
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
520
            <tr>
521
            <td width="1">&nbsp;
522
            <td>
523
                <input type="submit" name="btn" value="Find &raquo;" class="form_btn_comp" onclick="findNewIssues(); return false;">
524
            </td>
525
                <td align="center">
526
                <img id="keyListLoader" valign="middle" src="images/ajax-loader-bar.gif">
527
            </td>
528
            <td align="right">
529
                <input type="submit" name="btn" value="Import" class="form_btn_comp" onclick="addIssues(); return false;">
530
                <input type="reset"  name="btn" value="Close"  class="form_btn_comp" onclick="closePage(); return false;">
531
            </td>
532
        </table>
533
        </tr>
534
    <!-- Table of issues wrapper -->
535
    <tr height="100%"  valign="top">
536
        <td>
537
            <table id="issueTable" width="100%" border="0" cellspacing="1" cellpadding="2">
538
                <tr id="issueheader">
539
                    <td width="1%" background="images/bg_form_lightbluedark.gif"><input id="checkMaster" type="checkbox" onclick="checkAll(this.checked);"></td>
540
                    <td width="1%" nowrap background="images/bg_form_lightbluedark.gif" class="form_field">Issue Key</td>
541
                    <td width="1%" nowrap background="images/bg_form_lightbluedark.gif" class="form_field">State</td>
542
                    <td width="100%" nowrap background="images/bg_form_lightbluedark.gif" class="form_field">Summary</td>
543
                </tr>
544
<%
545
//              <tr>
546
//                  <td><input type="checkbox" name="FRiss_id" value='dummyValue'></td>
547
//                  <td nowrap class="form_item"><a href="dummyValue" target="_blank">dummyValue</a></td>
548
//                  <td class="form_item">dummyValueState</td>
549
//                  <td class="form_item">dummyValueSummary</td>
550
//              </tr>
551
%>
552
                <tr id="issuefooter">
553
                <!-- Number of issues found -->
554
                    <td background="images/bg_form_lightbluedark.gif">&nbsp;</td>
555
                    <td id="issueFooterCell" colspan="3" nowrap background="images/bg_form_lightbluedark.gif" class="form_step">Issue List not yet populated</td>
556
                </tr>
557
            </table>
558
        <!-- Next and Previous Buttons -->
559
        <tr height="1%">
560
            <td>
561
            <table width="100%" border="0" cellspacing="1" cellpadding="2">
562
              <tr>
563
                <td align="center">
564
                <a id="first" href="javascript:;" onClick="firstPage();" class="txt_linked">&lt;first</a>
565
                &nbsp;
566
                <a id="prev" href="javascript:;" onClick="previousPage();" class="txt_linked">&lt;previous</a>
567
                &nbsp;&nbsp;
568
                <a id="next" href="javascript:;" onClick="nextPage();" class="txt_linked">next &gt;</a>
569
                &nbsp;
570
                <a id="last" href="javascript:;" onClick="lastPage();" class="txt_linked">last &gt;</a>
571
              </tr>
572
            </table>
573
            </td>
574
            </tr>
575
        <!-- Bottom Line -->
576
        <tr height="1%">
577
        <tr>
578
            <td>
579
                <img src="images/lbox_bg_blue.gif" width="100%" height="5">
580
            </td>
581
        </tr>
582
    </table>
583
    <input name="pv_id" type="hidden" value="<%=parPv_id%>">
584
    <input name="rtag_id" type="hidden" value="<%=parRtag_id%>">
585
    <input name="action" type="hidden" value="true">
586
</form>
587
</body>
588
</html>
589
<!-- DESTRUCTOR ------->
590
<!--#include file="common/destructor.asp"-->