Subversion Repositories DevTools

Rev

Rev 7246 | Rev 7287 | 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
%>
<%
'=====================================================
'   _wform_build_package.asp
'=====================================================
%>
<!--#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/_popup_window_common.asp"-->
<!--#include file="common/daemon_instructions.asp"-->
<%
'------------ ACCESS CONTROL ------------------
%>
<!--#include file="_access_control_login_optional.asp"-->
<!--#include file="_access_control_general.asp"-->
<!--#include file="_access_control_project.asp"-->
<%
'------------ Variable Definition -------------
Dim sMessage, sMessageType
Dim rsTemp, TotalBuildTime, BuildTime
Dim bLongBuild
'------------ Constants Declaration -----------
'------------ Variable Init -------------------
sMessage = NULL
sMessageType = 3
'----------------------------------------------
'--- Before Render
'   Estimate the complete ripple time of this package
'   Provide a warning if the complete ripple time is long

        OraDatabase.Parameters.Add "RTAG_ID", Request("rtag_id"),   ORAPARM_INPUT, ORATYPE_NUMBER
        OraDatabase.Parameters.Add "PV_ID",   Request("pv_id"),     ORAPARM_INPUT, ORATYPE_NUMBER
        Set rsTemp = OraDatabase.DbCreateDynaset( GetQuery("CalcRippleTime.sql"), cint(0))
        OraDatabase.Parameters.Remove "PV_ID"
        OraDatabase.Parameters.Remove "RTAG_ID"
        If rsTemp.RecordCount > 0 Then 
            TotalBuildTime = NiceCLng (rsTemp("Total_BuildTime"), 0)
            BuildTime = NiceCLng (rsTemp("BuildTime"), 0)
                        If TotalBuildTime > 2 * 60 * 60 Then
                bLongBuild = TRUE
            End If
        End If
        rsTemp.Close()
        Set rsTemp = nothing

'------------------------------------------------------------------------------------------------------------------------------------------
' Add a line of text to the System Message
'
Sub sMessageAdd(eLevel, text)
    If NOT isNull(sMessage) Then
        sMessage = sMessage & "<br>"
    End If
    sMessage = sMessage & text

    If eLevel < sMessageType  Then
        sMessageType = eLevel
    End If
End Sub
'------------------------------------------------------------------------------------------------------------------------------------------
'Call sMessageAdd(1,"Just a Test")
%>
<script src="jquery/jquery-ui-timepicker-addon.js?ver=<%=VixVerNum%>"></script>
<link rel="stylesheet" href="jquery/jquery-ui-timepicker-addon.css?ver=<%=VixVerNum%>" type="text/css">
<script type="text/javascript" charset="utf-8">
//  This function will be called by vixDialog() when the dialoag has been loaded
//  Intended use: Init the javascript items
function buildPkgInit () {
    var myDateTimePicker = null;
//console.log('buildPkgInit');
//debugger;
    showHideDatePicker();

    $('#cancel').click(function(){
        closeIFrame();
    });

    $('#release').click(function(){
        var data = getScheduledTime();
//console.log("Scheduled Date:", data);
//debugger;
        displayError();
        if ( data && data.delta <=0 ) {
            displayError('Scheduled time is now in the past');
            return false;
        }

        $("#progressBar").css('visibility', 'visible');
        window.location.href = '_make_approved.asp?' + jQuery.param({
          pv_id : '<%=Request("pv_id")%>',
          rtag_id : '<%=Request("rtag_id")%>',
          rfile : '<%=RequestDefault("rfile", "dependencies.asp")%>',
          sched : data ? data.txt : null
        }) ;
    }).focus();

    function displayError(txt, detail) {
        if ( txt ) {
            if ( detail ) {
                txt += ": " + detail;
            }
            $('#errorPane').removeClass('display-none').html(txt);
        } else {
            $('#errorPane').addClass('display-none').html('');
        }
    }

    $('#schedule').change(showHideDatePicker);

    function showHideDatePicker()
    {
        var radio_button_val = $("input[name='sched']:checked").val();
        if ( radio_button_val === 'sched' ) {
            $('#showdate').removeClass('display-none');
            myDateTimePicker = $('#datetime').datetimepicker(
            {
                timeFormat: "HH:mm z",
                //dateFormat: "D dd-M-yy",
                controlType: 'select',
                closeText: 'Done',
                oneLine: true,
                timeInput: true,
                showTimezone : true,
                constrainInput: true,
                showOn: 'both',
                buttonImageOnly : true,
                buttonImage: "images/cal.gif",
                buttonText: "Select Date and Time",
                minDate : 0,
                maxDate : 3,
                onClose : function(p1,p2){
                     //console.log("Close", p1 );
                    },
                onSelect : function(p1,p2){
                     //console.log("Select", p1 );
                     getScheduledTime();
                    },
                });

            //  Set default time to be midnight - Perth Time (UTC+8)
                        var midnight = new Date();
            midnight.setUTCHours(24-8,0,0,0); 
            myDateTimePicker.datetimepicker('setDate', midnight);
            getScheduledTime();

        } else {
            $('#datetime').datepicker( "destroy" );
            $('#showdate').addClass('display-none');
            myDateTimePicker = null;
        }
    }

    function getScheduledTime() {
        if ( myDateTimePicker ) {
            // Convert to Perth timezime 8 hours ahead of GMT
            // Then pick the essential bits out of the structure
            var myTZO = 480;
            tpDate = new Date(myDateTimePicker.datetimepicker('getDate'));
            //var perthTime=new Date(tpDate.getTime() + (60000*(tpDate.getTimezoneOffset() + myTZO)));
            var perthTime=new Date(tpDate.getTime() + (60000* myTZO));
            //console.log('new', perthTime);
            var txt = perthTime.toISOString().substr(0, 19).replace('T', ' ');

            // Calculate distance ino the future for display purposes
            var now = new Date();
            var delta = 60 * Math.trunc((tpDate / 1000 / 60) - (now / 1000 / 60));

            var seconds = delta;
            var days = Math.floor(seconds / (3600*24));
            seconds  -= days*3600*24;
            var hrs   = Math.floor(seconds / 3600);
            seconds  -= hrs*3600;
            var mnts = Math.floor(seconds / 60);
            seconds  -= mnts*60;
            var result = days +"d "+hrs+"h "+mnts+"m";


            $('#otime').text(txt);
            $('#ofuture').text(result);
            return {txt: txt, delta: delta};
        }
    }
}
</script>
<div class='Panel tight' style="width:100%">
   <div class=PanelPad>
       <!-- MESSAGE ++++++++++++++++++++++++++++++++++++++++++++++ -->
       <%Call Messenger ( sMessage , sMessageType, "100%" )%>
       <!-- MESSAGE +++++++++++++++++++++++++++++++++++++++++++++++++++ -->
       <!--#include file="messages/_msg_inline.asp"-->
   </div>
   <div class='textPanel PanelPad'>
       <img class=PanelCell src="images/i_warning.gif" style="margin:0 7px 20px 0;">
       <span class=PanelCell>Approve this package for autobuild
                <p>Estimated build duration: <%=IIF(BuildTime > 0, NiceDuration(BuildTime), "Unknown")%>
                        <br>Estimated duration of complete ripple: <%=IIF(TotalBuildTime, NiceDuration(TotalBuildTime), "Unknown")%>
           </span>
   </div>
<%If bLongBuild Then%>
   <div class='textPanel PanelPad informPanel'>
       <img class=PanelCell src="images/s_critical.gif">
           <span class=PanelCell>This package will cause a significant ripple.<br>Consider scheduling it for a time to minimise dev impact.</span>
   </div>
<%End If%>
    <div id=showdate class=display-none>
       <div class='textPanel PanelPad' id=datetime></div>
       <div>Perth Time: <span id=otime></span></div>
       <div>In: <span id=ofuture></span></div>
    </div>
   <div class='PanelSep'></div>
   <div class='buttonPanelWhite' id=schedule>
           <div class=nowrap>
                        <input name=sched type=radio value='sched' <%=IIF(bLongBuild, "checked","")%>>Schedule
                        <input name=sched type=radio value='now'   <%=IIF(bLongBuild, "","checked")%>>Include immediately
                        <span style='margin-left:4em'></span>
                        <button id=release>Release</button>
                        <button id=cancel>Cancel</button>
           </div>
   </div>
        <div id='progressBar' class='vixSpinner' style='visibility:hidden;'></div>
   <div id=errorPane class='display-none errorPanel PanelPadTop'></div>
</div>
<!-- DESTRUCTOR ------->
<!--#include file="common/destructor.asp"-->