var app = app || {}; var authInfo = { address: 'Address', user: 'User', loggedIn: true } var sessionInfo = { requestTime: 60000, requestTimeMin: 5000, requestTimeMax: -1 } var messages = [], oldMessages = []; databaseIcons = new Image(); // main() // Runs once document in ready/loaded. // Initializes static/global vars and event listeners. // ---------- $(function (){ getSessionInfo(); // Specify icons source file. databaseIcons.src = './images/databaseIcon1.png'; $(window).resize(function() { var aspectRatio = $('#canvas').width() / $('#canvas').height(); var svg = $('#canvas').find('svg'); var newWidth = svg.parent().width(); svg.attr('width', newWidth); svg.attr('height', newWidth / aspectRatio); }); // Modal form submission and handling: // ---------- $('#Connect').submit(function(e){ e.preventDefault(); $('#formPassClass').removeClass('has-error'); $('#formUserClass').removeClass('has-error'); $('#formAddrClass').removeClass('has-error'); $('#connectSubmit').addClass('disabled'); $('#connectSubmit').disabled = true; $.post('/connect', $('#Connect').serialize()).done(function(data){ switch (data){ case 'valid': $('#formPassClass').removeClass('has-error'); $('#formUserClass').removeClass('has-error'); $('#formAddrClass').removeClass('has-error'); $('#inputAddress').val(""); $('#inputUsername').val(""); $('#inputPassword').val(""); authInfo.loggedIn = true; $("#connectFormModal").modal('hide'); app.WatcherView.update(); break; case 'invalid': $('#formAddrClass').addClass('has-error'); $('#formUserClass').addClass('has-error'); $('#formPassClass').addClass('has-error'); $('#inputPassword').val(""); break; default: console.log(data); break; } $('#connectSubmit').removeClass('disabled'); $('#connectSubmit').disabled = false; }); return false; }); // Log-out listener. // ---------- $('#logoutButton').click(function(e){ e.preventDefault(); $.post('/disconnect', function(data){ if(data == 'success'){ app.Watcher.clear(); $("#canvas").html(''); authInfo.loggedIn = false; $("#loginBar").css("visibility", "hidden"); } getSessionInfo(); }); }); // Initialize serverModal reset listener. // ---------- $('#serverModal').on('hidden.bs.modal', function () { $('#serverModalTableBody').html(''); }); // Ask p4 server for updated server data while logged in. (10000 = 10s) app.WatcherView.update(); setInterval(function() { if(authInfo.loggedIn){ app.WatcherView.update(); } }, 30000); }) // Aux functions: // ---------- function logText(data){ // Create timestamp. var now = new Date(); time = [now.getHours(), now.getMinutes(), now.getSeconds()]; for ( var i = 1; i < 3; i++ ) { if ( time[i] < 10 ) { time[i] = '0' + time[i]; } } // Format message and push to messages[]; appends to END of array var newMessage = '[' + time.join(':') + '] ' + data + '<br />'; messages.push(newMessage); var html = ''; // Test for necessary shift() if($('#loggerP').height() > ($('#logger').height() - 20)){ oldMessages.push(messages.shift()); } for(var i = 0; i < messages.length; i++){ html += messages[i]; } // Logging window disabled. //$('#loggerP').html(html); } function updateP4Targets(newAddress, newUsername){ authInfo.user = newUsername; authInfo.address = newAddress; $('#p4TargetUser').html(authInfo.user + (authInfo.user !== '' ? '<b class = \'caret\'></b>' : '')); $('#p4TargetHost').html(authInfo.address); if(authInfo.user !== "" && authInfo.address !== ""){ $("#loginBar").css("visibility", "visible"); }else{ $("#loginBar").css("visibility", "hidden"); } } function getSessionInfo(){ $.get('/sessionInfo', function(data){ updateP4Targets(data.address, data.username); }); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#6 | 8378 | Joe Robinson |
- Server modal working. - Simplified backbone data fetching. - Log out of perforce now and not just empty session. - TODO: - Prettier/different icons for each server type. - Modal image and parent/child list. |
||
#5 | 8373 | Joe Robinson |
- Moved to d3 to handle image drawing (SVG). - Proper sessions (logging in/out) implemented. - TODO: Fix server modal style/formatting & populate with data. |
||
#4 | 8371 | Joe Robinson |
Implemented cookies/sessions (still need logout functionality). Cleaned up logging window; delete older messages so new ones do not break the page. |
||
#3 | 8367 | Joe Robinson |
Improve backbone data retrieval functionality (for building canvas nodes). Connect/login modal working almost as desired. Draw basic things on canvas. Preliminary implementation of Redis DB/cookie saving. |
||
#2 | 8362 | Joe Robinson |
Basic backbone functionality. Removed user routes. |
||
#1 | 8356 | Joe Robinson |
Refactored files, old service version can be deleted. Improved base service structure. |