| <?php |
| /******************************************************************************* |
| * Copyright (c) 2013 Eclipse Foundation and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Denis Roy (Eclipse Foundation)- initial API and implementation |
| *******************************************************************************/ |
| |
| # Build HIPP Control UI |
| require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/classes/projects/projectList.class.php"); |
| require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/classes/projects/hipp.class.php"); |
| $ProjectList = new ProjectList(); |
| $ProjectList->selectCommitterProjectList($Friend->getUID()); |
| |
| $hudsonString = ""; |
| $jqString = ""; |
| if($ProjectList->getCount() > 0) { |
| for($i = 0; $i < $ProjectList->getCount(); $i++) { |
| $Project = $ProjectList->getItemAt($i); |
| $Hipp = new Hipp(); |
| $Hipp->selectHipp($Project->getProjectID()); |
| |
| $hippurl = "https://hudson.eclipse.org/" . $Project->getProjectShortName(); |
| $hudsonString .= "<li><a href='$hippurl'>" . $Project->getName() . "</a>:   "; |
| |
| if($Hipp->getID() > 0) { |
| $hudsonString .= "<span id='" . $Project->getProjectShortName() . "_state' class='" . $Hipp->getState() . "'>" . $Hipp->getState() . "</span>   <span id='" . $Project->getProjectShortName() . "_instance'>"; |
| |
| # Examine Service status to determine control knobs to place |
| if($Hipp->getState() == "running") { |
| # Add STOP button |
| $hudsonString .= "<img id='" . $Project->getProjectShortName() . "_stop' class='control_icon' src='//dev.eclipse.org/small_icons/actions/process-stop.png' alt='Stop' title='Stop' />  "; |
| addJQControlButton("stop", $Project->getProjectID(), $Project->getProjectShortName()); |
| |
| # Add RESTART button |
| $hudsonString .= "<img id='" . $Project->getProjectShortName() . "_restart' class='control_icon' src='//dev.eclipse.org/small_icons/actions/view-refresh.png' alt='Restart' title='Restart' />  "; |
| addJQControlButton("restart", $Project->getProjectID(), $Project->getProjectShortName()); |
| |
| } |
| if($Hipp->getState() == "stopped") { |
| # Add START button |
| $hudsonString .= "<img id='" . $Project->getProjectShortName() . "_start' class='control_icon' src='images/icon_start.png' alt='Start' title='Start' />  "; |
| addJQControlButton("start", $Project->getProjectID(), $Project->getProjectShortName()); |
| } |
| $hudsonString .= "</span>"; |
| } |
| else { |
| $hudsonString .= "No HIPP instance found for this project. <a href='https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Community&component=Hudson&short_desc=HIPP%20for%20" . $Project->getProjectShortName() . "'>Request one.</a>"; |
| } |
| $hudsonString .= "</li>"; |
| } |
| # Extras |
| $hudsonString .= "<li><a href='https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Community&component=Hudson&short_desc=HIPP%20Help'>Request Webmaster support for a HIPP instance</a>"; |
| $hudsonString .= $spacer . "<a href='http://wiki.eclipse.org/Hudson'>Hudson and HIPP docs</a></li>"; |
| |
| } |
| else { |
| $hudsonString .= "<li><a href='https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Community&component=Hudson&short_desc=HIPP%20for%20MyProject'>Request a HIPP instance</a>"; |
| $hudsonString .= $spacer . "<a href='http://wiki.eclipse.org/Hudson'>About Hudson and HIPP</a></li>"; |
| } |
| |
| |
| # Typical toggle stuff |
| $showView = "none"; |
| $showToggle = "Show Committer tools."; |
| $hideToggle = "Hide Committer tools."; |
| $details = $showToggle; |
| if(!preg_match("/.*myaccount.php/", $_SERVER['PHP_SELF'])) { |
| $showView = "inline"; |
| $details = $hideToggle; |
| } |
| # Expand this module by default |
| if(preg_match("/.*myaccount.php/", $_SERVER['PHP_SELF'])) { |
| $showView = "inline"; |
| $details = $hideToggle; |
| } |
| |
| # Load up jQuery |
| $App->setjQueryVersion("2.0.0"); |
| echo $App->getjQuery(); |
| |
| ?> |
| <br /> |
| <div class="section"> |
| <p><a href="#" onclick="fnToggle();"><img class="section_icon" src="//dev.eclipse.org/large_icons/apps/system-users.png" alt="Icon_committer" /><label id="changelabel" class='visibility_toggle'><?= $details ?></label></a></p> |
| <div id="committertools" style="display:<?= $showView ?>;"> |
| <h3>Development Tools</h6> |
| <ul> |
| <li><a href="https://bugs.eclipse.org/">Bugzilla</a><?= $spacer ?><a href="http://git.eclipse.org/c/">Git</a><?= $spacer ?><a href="http://git.eclipse.org/r/">Gerrit code review</a></li> |
| <li><a href="https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Community&component=Git">Request Webmaster Support</a></li> |
| </ul> |
| <h3>Committer Tools</h6> |
| <ul> |
| <li><a href="https://projects.eclipse.org/">PMI - Project management infrastructure</a><?= $spacer ?><a href="https://dev.eclipse.org/ipzilla/">IPZilla</a></li> |
| <li><a href="../committers/bugs/bugz_manager.php">Bugzilla Manager: components, targets, milestones</a></li> |
| <li><a href="https://dev.eclipse.org/mailman/listinfo/eclipse.org-committers">Committer mailing list</a></li> |
| <li><a href="../committers/committertools/stats.php">Download stats</a><?= $spacer ?><a href="../committers/webstats/webstats.php">Website stats</a></li> |
| <li><a href="https://dev.eclipse.org/committers/help/status.php">Eclipse infras status</a><?= $spacer ?><a href="../committers/committertools/ip_test.php">IP address / DNS test tool</a></li> |
| </ul> |
| <div class="hudson"> |
| <img src="images/icon_hudson.png" alt="Hudson" /> |
| <h3>Hudson HIPP Control</h3> |
| </div> |
| <div> |
| <ul> |
| <?= $hudsonString ?> |
| </ul> |
| </div> |
| </div> |
| </div> |
| <script> |
| $(document).ready(function() { |
| <?= $jqString ?> |
| }); |
| |
| function fnToggle() { |
| if(document.getElementById('committertools').style.display == "none") { |
| document.getElementById('committertools').style.display = "inline"; |
| document.getElementById('changelabel').innerHTML = '<?= $hideToggle ?>'; |
| } |
| else { |
| document.getElementById('committertools').style.display = "none"; |
| document.getElementById('changelabel').innerHTML = '<?= $showToggle ?>'; |
| } |
| } |
| </script> |
| <?php |
| /** |
| * |
| * @param String $_cntl (start, stop, restart) |
| * @param String $_project_id |
| * @param String $_project_short_name |
| * @author droy |
| * @since 2013-11-08 |
| */ |
| function addJQControlButton($_cntl, $_project_id, $_project_short_name) { |
| global $jqString; |
| $jqString .= '$("#' . $_project_short_name . '_' . $_cntl . '").click(function() {'; |
| |
| # Clear "state" |
| $jqString .= '$("#' . $_project_short_name . '_state").html("");'; |
| |
| # Post to hipp control |
| $jqString .= '$.post( "control_hipp/index.php", { action: "' . $_cntl . '", project: "' . $_project_id . '" })'; |
| $jqString .= '.done(function( data ) {'; |
| $jqString .= 'var output = data; var regexp = /^token:/; if (regexp.test(data)) {'; |
| |
| # We got a token back. Success, now check up on it. |
| $jqString .= 'var token=data.split(":");'; |
| $jqString .= 'output="<img class=\"spinner\" src=\"../images/spinner.gif\" />";'; |
| |
| $jqString .= 'var timer, delay = 5000;'; |
| $jqString .= 'timer = setInterval(function(){'; |
| $jqString .= '$.post( "control_hipp/index.php", { action: "check", token: token[1] })'; |
| $jqString .= '.done(function(html){'; |
| $jqString .= '$("#' . $_project_short_name . '_instance").html(html);'; |
| $jqString .= '})'; |
| $jqString .= '},delay);'; |
| $jqString .= '}'; |
| $jqString .= '$("#' . $_project_short_name . '_instance").html(output);'; |
| $jqString .= '});'; |
| $jqString .= '});'; |
| } |
| ?> |