Пример #1
0
 protected function initContent()
 {
     $request = $this->getContext()->getRequest();
     $resultsID = $request->getInt('item');
     $this->setTitle('Run result');
     $this->setRobots('noindex,nofollow');
     $this->bodyScripts[] = swarmpath('js/result.js');
     $error = $this->getAction()->getError();
     $data = $this->getAction()->getData();
     $html = '';
     if ($error) {
         $html .= html_tag('div', array('class' => 'alert alert-error'), $error['info']);
         return $html;
     }
     $this->setSubTitle('#' . $data['info']['id']);
     if ($data['job']) {
         $html = '<p><em>' . html_tag_open('a', array('href' => $data['job']['url'], 'title' => 'Back to Job #' . $data['job']['id'])) . '&laquo Back to Job #' . $data['job']['id'] . '</a>' . '</em></p>';
     } else {
         $html = '<p><em>Run #' . $data['info']['runID'] . ' has been deleted. Job info unavailable.</em></p>';
     }
     if ($data['otherRuns']) {
         $html .= '<table class="table table-bordered swarm-results"><thead>' . JobPage::getUaHtmlHeader($data['otherRuns']['userAgents']) . '</thead><tbody>' . JobPage::getUaRunsHtmlRows($data['otherRuns']['runs'], $data['otherRuns']['userAgents']) . '</tbody></table>';
     }
     $html .= '<h3>Information</h3>' . '<table class="table table-striped">' . '<tbody>' . '<tr><th>Run</th><td>' . ($data['job'] ? html_tag('a', array('href' => $data['job']['url']), 'Job #' . $data['job']['id']) . ' / ' : '') . 'Run #' . htmlspecialchars($data['info']['runID']) . '</td></tr>' . '<tr><th>Client</th><td>' . html_tag('a', array('href' => $data['client']['viewUrl']), 'Client #' . $data['info']['clientID']) . ' / ' . htmlspecialchars($data['client']['name']) . '</td></tr>' . '<tr><th>UA ID</th><td>' . '<code>' . htmlspecialchars($data['client']['uaID']) . '</code>' . '<tr><th>User-Agent</th><td>' . '<tt>' . htmlspecialchars($data['client']['uaRaw']) . '</tt>' . '</td></tr>' . '<tr><th>Run time</th><td>' . (isset($data['info']['runTime']) ? number_format(intval($data['info']['runTime'])) . 's' : '?') . '</td></tr>' . '<tr><th>Status</th><td>' . htmlspecialchars($data['info']['status']) . '</td></tr>' . '<tr><th>Started</th><td>' . self::getPrettyDateHtml($data['info'], 'started') . '</td></tr>' . (isset($data['info']['savedLocalFormatted']) ? '<tr><th>Saved</th><td>' . self::getPrettyDateHtml($data['info'], 'saved') . '</td></tr>' : '') . '</tbody></table>';
     $html .= '<h3>Results</h3>' . '<p class="swarm-toollinks">' . html_tag('a', array('href' => swarmpath('index.php') . '?' . http_build_query(array('action' => 'result', 'item' => $data['info']['id'], 'raw' => '')), 'target' => '_blank', 'class' => 'swarm-popuplink'), 'Open in new window') . '</p>' . html_tag('iframe', array('src' => swarmpath('index.php') . '?' . http_build_query(array('action' => 'result', 'item' => $data['info']['id'], 'raw' => '')), 'width' => '100%', 'class' => 'swarm-result-frame'));
     return $html;
 }
Пример #2
0
function loadBrowsers($name, $mobile) {
  global $found, $browser, $version, $os;

  $result = mysql_queryf("SELECT useragents.engine as engine, useragents.name as name, (SELECT COUNT(*) FROM clients WHERE useragent_id=useragents.id AND updated > DATE_SUB(NOW(), INTERVAL 1 minute)) as clients, (engine=%s AND %s REGEXP version) as found FROM useragents WHERE active=1 AND mobile=%s ORDER BY engine, name;", $browser, $version, $mobile);

  $engine = "";

  echo "<div class='browsers'><h3>$name</h3>";

  while ( $row = mysql_fetch_array($result) ) {
    if ( $row[3] ) {
      $found = 1;
    }

    if ( $row[0] != $engine ) {
      echo '<br style="clear:both;"/>';
    }
    $num = preg_replace("/\w+ /", "", $row[1]);
    ?>
		<div class="browser<?php echo $row[0] != $engine ? " clear" : "";?><?php echo $row[3] ? " you" : "";?>">
			<img src="<?php echo swarmpath( "images/{$row[0]}.sm.png" ); ?>" class="browser-icon <?php echo $row[0]; ?>" alt="<?php echo $row[1]; ?>" title="<?php echo $row[1]; ?>"/>
			<span class="browser-name"><?php echo $num; ?></span>
			<?php if ( intval($row[2]) > 0 ) {
				echo '<span class="active">' . $row[2] . '</span>';
			}?>
		</div>
  <?php $engine = $row[0];
	}

  echo '</div>';
}
Пример #3
0
 protected function initContent()
 {
     $request = $this->getContext()->getRequest();
     $resultsID = $request->getInt('item');
     $this->setTitle('Run result');
     $this->setRobots('noindex,nofollow');
     $this->bodyScripts[] = swarmpath('js/result.js');
     $error = $this->getAction()->getError();
     $data = $this->getAction()->getData();
     $html = '';
     if ($error) {
         $html .= html_tag('div', array('class' => 'alert alert-error'), $error['info']);
         return $html;
     }
     $this->setSubTitle('#' . $data['resultInfo']['id']);
     if ($data['job']) {
         $html = '<p><em>' . html_tag_open('a', array('href' => $data['job']['url'], 'title' => 'Back to Job #' . $data['job']['id'])) . '&laquo Back to Job #' . $data['job']['id'] . '</a>' . '</em></p>';
     } else {
         $html = '<p><em>Run #' . $data['resultInfo']['runID'] . ' has been deleted. Job info unavailable.</em></p>';
     }
     if ($data['otherRuns']) {
         $html .= '<table class="table table-bordered swarm-results"><thead>' . JobPage::getUaHtmlHeader($data['otherRuns']['userAgents']) . '</thead><tbody>' . JobPage::getUaRunsHtmlRows($data['otherRuns']['runs'], $data['otherRuns']['userAgents']) . '</tbody></table>';
     }
     $html .= '<h3>Information</h3>' . '<table class="table table-striped">' . '<colgroup><col class="span2"/><col/></colgroup>' . '<tbody>' . '<tr><th>Run</th><td>' . ($data['job'] ? html_tag('a', array('href' => $data['job']['url']), 'Job #' . $data['job']['id']) . ' / ' : '') . 'Run #' . htmlspecialchars($data['resultInfo']['runID']) . '</td></tr>' . '<tr><th>Client</th><td>' . html_tag('a', array('href' => $data['client']['userUrl']), $data['client']['userName']) . ' / Client #' . htmlspecialchars($data['resultInfo']['clientID']) . '</td></tr>' . ($data['client']['deviceName'] !== null ? '<tr><th>Device name</th><td>' . $data['client']['deviceName'] . ' / ' . html_tag('a', array('target' => '_blank', 'href' => 'http://wiki.blinkbox.local/wiki/index.php?profile=default&search=' . htmlspecialchars($data['client']['deviceName'])), 'search for ' . $data['client']['deviceName'] . ' on blinkbox wiki') . '</td></tr>' : '') . '<tr><th>User-Agent</th><td>' . '<code>' . htmlspecialchars($data['client']['uaID']) . '</code><br/>' . 'Raw: <br><code>' . htmlspecialchars($data['client']['userAgent']) . '</code><br/>' . html_tag('a', array('target' => '_blank', 'href' => 'http://wiki.blinkbox.local/wiki/index.php?profile=default&search=' . htmlspecialchars($data['client']['userAgent'])), 'search for this user agent on blinkbox wiki') . '</td></tr>' . '<tr><th>Run time</th><td>' . (isset($data['resultInfo']['runTime']) ? number_format(intval($data['resultInfo']['runTime'])) . 's' : '?') . '</td></tr>' . '<tr><th>Status</th><td>' . htmlspecialchars($data['resultInfo']['status']) . '</td></tr>' . '<tr><th>Total</th><td>' . htmlspecialchars($data['resultInfo']['total']) . '</td></tr>' . '<tr><th>Fail</th><td>' . htmlspecialchars($data['resultInfo']['fail']) . '</td></tr>' . '<tr><th>Error</th><td>' . htmlspecialchars($data['resultInfo']['error']) . '</td></tr>' . '<tr><th>Started</th><td>' . self::getPrettyDateHtml($data['resultInfo'], 'started') . '</td></tr>' . (isset($data['resultInfo']['savedLocalFormatted']) ? '<tr><th>Saved</th><td>' . self::getPrettyDateHtml($data['resultInfo'], 'saved') . '</td></tr>' : '') . '<tr><th>Results size</th><td>' . 'compressed: ' . self::formatBytes($data['resultInfo']['reportHtmlCompressedSize']) . ' / uncompressed: ' . self::formatBytes($data['resultInfo']['reportHtmlSize']) . ' / ratio: ' . $data['resultInfo']['reportHtmlCompressionRatio'] . '%' . '</td></tr>' . '</tbody></table>';
     $html .= '<h3>Results</h3>' . '<p class="swarm-toollinks">' . html_tag('a', array('href' => swarmpath('index.php') . '?' . http_build_query(array('action' => 'result', 'item' => $data['resultInfo']['id'], 'raw' => '')), 'target' => '_blank', 'class' => 'swarm-popuplink'), 'Open in new window') . '</p>' . html_tag('iframe', array('src' => swarmpath('index.php') . '?' . http_build_query(array('action' => 'result', 'item' => $data['resultInfo']['id'], 'raw' => '')), 'width' => '100%', 'class' => 'swarm-result-frame'));
     return $html;
 }
Пример #4
0
 protected function initContent()
 {
     $context = $this->getContext();
     $conf = $context->getConf();
     $request = $context->getRequest();
     $browserInfo = $context->getBrowserInfo();
     $siteNameHtml = htmlspecialchars($conf->web->title);
     $this->setTitle('Home');
     $this->setRawDisplayTitle('<div style="text-align: center;">' . $siteNameHtml . '</div>');
     $html = '<div class="row">' . '<div class="span7">' . '<h3>Distributed Continuous Integration for JavaScript</h3>' . '<blockquote><p>' . str_replace('$1', $siteNameHtml, $conf->customMsg->homeIntro_html) . '</p></blockquote>' . '</div>';
     $html .= '<div class="span5"><div class="well">';
     if (!$conf->client->requireRunToken) {
         if ($browserInfo->isInSwarmUaIndex()) {
             $auth = $context->getAuth();
             $suggestedClientName = $auth ? $auth->project->id : '';
             $html .= '<p>Your browser is in our index, run some tests!</p>' . '<form action="' . swarmpath('') . '" method="get" class="form-horizontal swarm-form-join">' . '<input type="hidden" name="action" value="run">' . '<div class="input-append">' . '<input type="text" name="item" placeholder="Enter name.." value="' . htmlspecialchars($suggestedClientName) . '" required pattern="' . htmlspecialchars(Client::getNameValidationRegex()) . '">' . '<input type="submit" value="Join the swarm" class="btn btn-primary">' . '</div>' . '</form>';
         } else {
             $uaData = $browserInfo->getUaData();
             unset($uaData->displayInfo);
             $html .= '<div class="alert alert-info">' . '<h4 class="alert-heading">Your browser is not needed by this swarm.</h4>' . '<p>Please join with one the below browsers.</p></div>' . '<p>If you feel that this may be an error, please report it to the TestSwarm ' . ' <a href="https://github.com/jquery/testswarm/issues">Issue Tracker</a>,' . ' including the following 2 codes:' . '<br><strong><a href="https://github.com/tobie/ua-parser">ua-parser</a>:</strong> <code>' . htmlspecialchars(print_r($uaData, true)) . '</code><br><strong><a href="https://en.wikipedia.org/wiki/User_agent" title="Read about User agent on Wikipedia!">User-Agent</a> string:</strong> <code>' . htmlspecialchars($browserInfo->getRawUA()) . '</code></p>';
         }
     } else {
         $html .= '<div class="alert">' . '<h4 class="alert-heading">Join access restricted</h4>' . '<p>Public joining of the swarm has been disabled.</p>' . '<button type="button" class="btn btn-large disabled" disabled><s>Join the swarm</s></button>' . '</div>';
     }
     $html .= '</div></div>';
     $html .= '</div>';
     $html .= $this->getBrowsersOnlineHtml();
     return $html;
 }
Пример #5
0
 /** @return bool: Whether the current user was found in the swarm */
 public function getBrowsersOnlineHtml()
 {
     $conf = $this->getContext()->getConf();
     $db = $this->getContext()->getDB();
     $browserInfo = $this->getContext()->getBrowserInfo();
     $data = $this->getAction()->getData();
     $html = '';
     $itemsPerRow = 6;
     $browsersHtml = '<h2>Browsers</h2>';
     $browserItemCount = 0;
     foreach ($data["userAgents"] as $uaID => $userAgent) {
         if (!in_array($uaID, $conf->browserSets->default)) {
             continue;
         }
         $isCurr = $uaID == $browserInfo->getSwarmUaID();
         $item = '' . '<div class="span2">' . '<div class="well well-small swarm-browseronline' . ($isCurr ? " alert-info" : "") . '">' . html_tag("img", array("src" => swarmpath("img/" . $userAgent["data"]["displayicon"] . ".sm.png"), "class" => "swarm-browsericon", "alt" => "", "title" => $userAgent["data"]["displaytitle"])) . '<br>' . html_tag("span", array("class" => "badge swarm-browsername"), $userAgent["data"]["displaytitle"]) . '<br>' . html_tag("span", array("class" => "swarm-onlineclients " . ($userAgent["stats"]["onlineClients"] > 0 ? "badge" : ($userAgent['stats']['pendingRuns'] > 0 ? 'badge badge-important' : 'badge')), "title" => $userAgent["stats"]["onlineClients"] . ' clients online'), $userAgent["stats"]["onlineClients"]) . html_tag("span", array("class" => "swarm-pendingruns " . ($userAgent["stats"]["pendingRuns"] > 0 ? $userAgent["stats"]["onlineClients"] > 0 ? "label label-info" : "label label-warning" : "label label-success")), $userAgent["stats"]["pendingRuns"] . ' pending runs') . ($userAgent["stats"]["pendingReRuns"] > 0 ? '<br>' . html_tag("span", array("class" => "swarm-pendingreruns " . ($userAgent["stats"]["onlineClients"] > 0 ? "label label-info" : "label label-warning")), $userAgent["stats"]["pendingReRuns"] . ' pending re-runs') : "") . '</div>' . '</div>';
         // Properly close and start new rows
         if ($browserItemCount % $itemsPerRow === 0) {
             $browsersHtml .= '<div class="row">';
         }
         $browserItemCount += 1;
         $browsersHtml .= $item;
         if ($browserItemCount % $itemsPerRow === 0) {
             $browsersHtml .= '</div><!--/.row -->';
         }
     }
     // Close un-even items rows
     if ($browserItemCount % $itemsPerRow !== 0) {
         $browsersHtml .= '</div><!--/.row -->';
     }
     $html .= $browsersHtml;
     return $html;
 }
Пример #6
0
 protected function initContent()
 {
     $request = $this->getContext()->getRequest();
     $auth = $this->getContext()->getAuth();
     $this->setTitle("Job status");
     $this->setRobots("noindex,nofollow");
     $this->bodyScripts[] = swarmpath("js/job.js");
     $error = $this->getAction()->getError();
     $data = $this->getAction()->getData();
     $html = '';
     if ($error) {
         $html .= html_tag('div', array('class' => 'alert alert-error'), $error['info']);
     }
     if (!isset($data["info"])) {
         return $html;
     }
     $this->setSubTitle('#' . $data["info"]["id"]);
     $project = $data['info']['project'];
     $isOwner = $auth && $auth->project->id === $project['id'];
     $html .= '<h2>' . $data["info"]["nameHtml"] . '</h2>' . '<p><em>Submitted by ' . html_tag('a', array('href' => $project['viewUrl']), $project['display_title']) . ' ' . self::getPrettyDateHtml($data["info"], 'created') . '</em>.</p>';
     if ($isOwner) {
         $html .= '<script>SWARM.jobInfo = ' . json_encode($data["info"]) . ';</script>';
         $action_bar = '<div class="form-actions swarm-item-actions">' . ' <button class="swarm-reset-runs-failed btn btn-info">Reset failed runs</button>' . ' <button class="swarm-reset-runs btn btn-info">Reset all runs</button>' . ' <button class="swarm-delete-job btn btn-danger">Delete job</button>' . '</div>' . '<div class="swarm-wipejob-error alert alert-error" style="display: none;"></div>';
     } else {
         $action_bar = '';
     }
     $html .= $action_bar;
     $html .= '<table class="table table-bordered swarm-results swarm-results-unbound-auth"><thead>' . self::getUaHtmlHeader($data['userAgents']) . '</thead><tbody>' . self::getUaRunsHtmlRows($data['runs'], $data['userAgents'], $isOwner) . '</tbody></table>';
     $html .= $action_bar;
     return $html;
 }
Пример #7
0
 public static function getUaHtmlHeader($userAgents)
 {
     $html = '<tr><th>&nbsp;</th>';
     foreach ($userAgents as $userAgent) {
         $html .= '<th><img src="' . swarmpath('img/' . $userAgent['displayicon']) . '.sm.png" class="swarm-browsericon ' . '" alt="' . htmlspecialchars($userAgent['displaytitle']) . '" title="' . htmlspecialchars($userAgent['displaytitle']) . '"><br>' . htmlspecialchars(preg_replace('/\\w+ /', '', $userAgent['displaytitle'])) . '</th>';
     }
     $html .= '</tr>';
     return $html;
 }
Пример #8
0
 protected function initContent()
 {
     $this->setTitle("Scores");
     $scores = $this->getAction()->getData();
     $html = '<blockquote><p>All users with a score greater than zero.' . ' The score is the number of tests run by that user\'s clients.</p></blockquote>' . '<table class="table table-striped">' . '<thead><tr><th class="span1">#</th><th>User</th><th class="span2">Score</th></tr></thead>' . '<tbody>';
     foreach ($scores as $item) {
         $html .= '<tr><td class="num">' . htmlspecialchars(number_format($item["position"])) . '</td>' . '<td><a href="' . htmlspecialchars(swarmpath("user/{$item["userName"]}")) . '">' . htmlspecialchars($item["userName"]) . '</a></td>' . '<td class="num">' . htmlspecialchars(number_format($item["score"])) . '</td></tr>';
     }
     $html .= '</tbody></table>';
     return $html;
 }
Пример #9
0
 protected function initContent()
 {
     $this->setTitle("Projects");
     $projects = $this->getAction()->getData();
     $html = '<blockquote><p>Below is an overview of all registered projects,' . ' sorted alphabetically by name.</p></blockquote>' . '<table class="table table-striped">' . '<thead><tr><th>Project name</th><th class="span2">Jobs</th><th class="span4">Creation date</th></tr></thead>' . '<tbody>';
     foreach ($projects as $project) {
         $html .= '<tr>' . '<td><a href="' . htmlspecialchars(swarmpath("user/{$project["name"]}")) . '">' . htmlspecialchars($project["name"]) . '</a></td>' . '<td class="num">' . htmlspecialchars(number_format($project["jobCount"])) . '</td>' . '<td class="num"><span title="' . htmlspecialchars($project["createdISO"]) . '" class="pretty">' . htmlspecialchars($project["createdLocalFormatted"]) . '</span></td>' . '</tr>';
     }
     $html .= '</tbody></table>';
     return $html;
 }
Пример #10
0
 protected function initContent()
 {
     $this->setTitle('Projects');
     $projects = $this->getAction()->getData();
     $html = '<blockquote><p>Below is an overview of all registered projects,' . ' sorted alphabetically by name.</p></blockquote>' . '<table class="table table-striped">' . '<thead><tr>' . '<th>Project name</th>' . '<th class="span2">Jobs</th>' . '<th class="span2">Most recent job</th>' . '<th class="span4">Creation date</th>' . '</tr></thead>' . '<tbody>';
     foreach ($projects as $project) {
         $html .= '<tr>' . '<td><a href="' . htmlspecialchars(swarmpath("user/{$project['name']}")) . '">' . htmlspecialchars($project['name']) . '</a></td>' . '<td class="num">' . htmlspecialchars(number_format($project['jobCount'])) . '</td>' . '<td><a href="' . htmlspecialchars(swarmpath("job/{$project['jobLatest']}")) . '">Job #' . htmlspecialchars($project['jobLatest']) . '</a></td>' . '<td class="num">' . self::getPrettyDateHtml($project, 'created') . '</td>' . '</tr>';
     }
     $html .= '</tbody></table>';
     return $html;
 }
Пример #11
0
 protected function initContent()
 {
     $request = $this->getContext()->getRequest();
     $this->setTitle("Signup");
     $html = '<form action="' . swarmpath("signup") . '" method="post">' . '<fieldset>' . '<legend>Signup</legend>';
     $error = $this->getAction()->getError();
     if ($request->wasPosted() && $error) {
         $html .= html_tag('div', array('class' => 'alert alert-error'), $error['info']);
     }
     $html .= '<p>Create an account. If you already have an account you may <a href="' . swarmpath("login") . '">login here</a>.</p>' . '<label>Username: <input type="text" name="username" maxlength="255"></label><br>' . '<label>Password: <input type="password" name="password"></label><br>' . '<input type="submit" value="Signup" class="btn btn-primary">' . '</fieldset></form>';
     return $html;
 }
Пример #12
0
 protected function initContent()
 {
     $request = $this->getContext()->getRequest();
     $this->setTitle("Login");
     $html = '<form action="' . swarmpath("login") . '" method="post" class="form-horizontal">' . '<fieldset>' . '<legend>Login</legend>';
     $error = $this->getAction()->getError();
     if ($request->wasPosted() && $error) {
         $html .= html_tag('div', array('class' => 'alert alert-error'), $error['info']);
     }
     $html .= '<div class="well">' . '<p>Login using your TestSwarm username and password.' . ' If you don\'t have one you may <a href="' . swarmpath("signup") . '">Signup Here</a>.</p>' . '<div class="control-group">' . '<label class="control-label" for="form-username">Username</label>' . '<div class="controls">' . '<input id="form-password" type="text" name="username" value="' . htmlspecialchars($request->getVal("username")) . '">' . '</div>' . '</div><div class="control-group">' . '<label class="control-label" for="form-password">Password</label>' . '<div class="controls">' . '<input type="password" name="password">' . '</div>' . '</div>' . '</div><div class="form-actions">' . '<input id="form-password" type="submit" value="Login" class="btn btn-primary">' . '</div>';
     $html .= '</fieldset></form>';
     return $html;
 }
Пример #13
0
 protected function initContent()
 {
     $request = $this->getContext()->getRequest();
     $this->setTitle("Login");
     $html = '<form action="' . swarmpath("login") . '" method="post" class="form-horizontal">' . '<fieldset>' . '<legend>Login</legend>';
     $error = $this->getAction()->getError();
     if ($request->wasPosted() && $error) {
         $html .= html_tag('div', array('class' => 'alert alert-error'), $error['info']);
     }
     $html .= '<div class="well">' . '<p>Login for projects. Projects can only be created by swarm operators.</p>' . '<div class="control-group">' . '<label class="control-label" for="form-projectID">Project ID</label>' . '<div class="controls">' . '<input type="text" name="projectID" required id="form-projectID" value="' . htmlspecialchars($request->getVal("projectID")) . '">' . '</div>' . '</div><div class="control-group">' . '<label class="control-label" for="form-projectPassword">Project password</label>' . '<div class="controls">' . '<input type="password" name="projectPassword" required id="form-projectPassword">' . '</div>' . '</div>' . '</div><div class="form-actions">' . '<input type="submit" value="Login" class="btn btn-primary">' . '</div>';
     $html .= '</fieldset></form>';
     return $html;
 }
Пример #14
0
 protected function initContent()
 {
     $request = $this->getContext()->getRequest();
     $this->setTitle("Job status");
     $this->setRobots("noindex,nofollow");
     $this->bodyScripts[] = swarmpath("js/job.js");
     $error = $this->getAction()->getError();
     $data = $this->getAction()->getData();
     $html = '';
     if ($error) {
         $html .= html_tag('div', array('class' => 'alert alert-error'), $error['info']);
     }
     if (!isset($data["jobInfo"])) {
         return $html;
     }
     $this->setSubTitle('#' . $data["jobInfo"]["id"]);
     $html .= '<h2>' . $data["jobInfo"]["name"] . '</h2>' . '<p><em>Submitted by ' . html_tag("a", array("href" => swarmpath("user/{$data["jobInfo"]["ownerName"]}")), $data["jobInfo"]["ownerName"]) . ' on ' . htmlspecialchars(date("Y-m-d H:i:s", gmstrtotime($data["jobInfo"]["creationTimestamp"]))) . ' (UTC)' . '</em>.</p>';
     if ($request->getSessionData("auth") === "yes" && $data["jobInfo"]["ownerName"] == $request->getSessionData("username")) {
         $html .= '<script>SWARM.jobInfo = ' . json_encode($data["jobInfo"]) . ';</script>' . '<div class="form-actions">' . ' <button id="swarm-job-delete" class="btn btn-danger">Delete job</button>' . ' <button id="swarm-job-reset" class="btn btn-info">Reset job</button>' . '</div>' . '<div class="alert alert-error" id="swarm-wipejob-error" style="display: none;"></div>';
     }
     $html .= '<table class="table table-bordered swarm-results"><thead><tr><th>&nbsp;</th>';
     // Header with user agents
     foreach ($data["userAgents"] as $userAgent) {
         $html .= '<th><img src="' . swarmpath("img/" . $userAgent["displayicon"]) . '.sm.png" class="swarm-browsericon ' . '" alt="' . htmlspecialchars($userAgent["displaytitle"]) . '" title="' . htmlspecialchars($userAgent["displaytitle"]) . '"><br>' . htmlspecialchars(preg_replace("/\\w+ /", "", $userAgent["displaytitle"])) . '</th>';
     }
     $html .= '</tr></thead><tbody>';
     foreach ($data["runs"] as $run) {
         $html .= '<tr><th><a href="' . htmlspecialchars($run["info"]["url"]) . '">' . $run["info"]["name"] . '</a></th>';
         // Looping over $data["userAgents"] instead of $run["uaRuns"],
         // to avoid shifts in the table (github.com/jquery/testswarm/issues/13)
         foreach ($data["userAgents"] as $uaID => $uaInfo) {
             if (isset($run["uaRuns"][$uaID])) {
                 $uaRun = $run["uaRuns"][$uaID];
                 $html .= html_tag_open("td", array("class" => "swarm-status swarm-status-" . $uaRun["runStatus"], "data-job-id" => $data["jobInfo"]["id"], "data-run-id" => $run["info"]["id"], "data-run-status" => $uaRun["runStatus"], "data-useragent-id" => $uaID, "data-client-id" => isset($uaRun["clientID"]) ? $uaRun["clientID"] : ""));
                 if (isset($uaRun["runResultsUrl"]) && $uaRun["runResultsLabel"]) {
                     $html .= html_tag_open('a', array("rel" => "nofollow", "href" => $uaRun["runResultsUrl"])) . $uaRun["runResultsLabel"] . '<i class="icon-list-alt pull-right" title="' . htmlspecialchars("Open run results for {$data["userAgents"][$uaID]["displaytitle"]}") . '"></i>' . '</a>';
                 } else {
                     $html .= UserPage::getStatusIconHtml($uaRun["runStatus"]);
                 }
                 $html .= '</td>';
             } else {
                 // This run isn't schedules to be ran in this UA
                 $html .= '<td class="swarm-status swarm-status-notscheduled"></td>';
             }
         }
     }
     $html .= '</tbody></table>';
     return $html;
 }
Пример #15
0
 protected function initContent()
 {
     $this->setTitle("User");
     $html = "";
     $error = $this->getAction()->getError();
     $data = $this->getAction()->getData();
     if ($error) {
         $html .= html_tag("div", array("class" => "alert alert-error"), $error["info"]);
         return $html;
     }
     $this->setSubTitle($data["userName"]);
     if (count($data["activeClients"])) {
         $html .= '<h2>Active clients</h2><div class="row">';
         foreach ($data["activeClients"] as $activeClient) {
             if ($activeClient["uaData"]) {
                 $diplayicon = $activeClient["uaData"]["displayicon"];
                 $label = $activeClient["uaData"]["displaytitle"];
             } else {
                 $diplayicon = "unknown";
                 $label = "Unrecognized [{$activeClient["uaID"]}]";
             }
             $html .= '<div class="span4"><div class="well">' . '<img class="pull-right" src="' . swarmpath("img/{$diplayicon}.sm.png") . '" alt="">' . '<strong class="label">' . htmlspecialchars($label) . '</strong>' . '<p>' . '<small>Platform: ' . htmlspecialchars($activeClient["uaBrowscap"]["Platform"]) . '</small>' . '<br>' . '<small>Connected ' . self::getPrettyDateHtml($activeClient, 'connected') . '</small>' . '<br>' . '<small>Last ping ' . self::getPrettyDateHtml($activeClient, 'pinged') . '</small>' . '</p>' . '</div></div>';
         }
         $html .= '</div>';
     }
     if (count($data["recentJobs"])) {
         $html .= '<h2>Recent jobs</h2><table class="table table-bordered swarm-results">';
         // Build table header
         $html .= '<thead><tr><td></td>';
         foreach ($data["uasInJobs"] as $uaID => $uaData) {
             $html .= '<th>' . '<img src="' . swarmpath("img/{$uaData["displayicon"]}.sm.png") . '" class="swarm-browsericon' . '" alt="' . htmlspecialchars($uaData["displaytitle"]) . '" title="' . htmlspecialchars($uaData["displaytitle"]) . '"><br>' . htmlspecialchars(preg_replace("/\\w+ /", "", $uaData["displaytitle"])) . '</th>';
         }
         $html .= '</tr></thead><tbody>';
         foreach ($data["recentJobs"] as $job) {
             $html .= '<tr><th><a href="' . htmlspecialchars($job["url"]) . '">' . htmlspecialchars(strip_tags($job["name"])) . "</a></th>\n";
             foreach ($data["uasInJobs"] as $uaID => $uaData) {
                 $html .= isset($job["uaSummary"][$uaID]) ? '<td class="swarm-status swarm-status-' . $job["uaSummary"][$uaID] . '">' . self::getStatusIconHtml($job["uaSummary"][$uaID]) . '</td>' : '<td class="swarm-status swarm-status-notscheduled"></td>';
             }
             $html .= '</tr>';
         }
         $html .= '</tbody></table>';
     }
     if ($html == '') {
         return '<div class="alert alert-info">No active useragents or jobs.</div>';
     }
     return $html;
 }
Пример #16
0
 protected function initContent()
 {
     $this->setTitle('Projects');
     $projects = $this->getAction()->getData();
     $html = '<blockquote><p>Below is an overview of all registered projects,' . ' sorted alphabetically by name.</p></blockquote>' . '<table class="table table-striped">' . '<thead><tr>' . '<th>Project name</th>' . '<th class="span4">Latest job</th>' . '</tr></thead>' . '<tbody>';
     foreach ($projects as $project) {
         $job = $project['job'];
         $html .= '<tr>' . '<td><a href="' . htmlspecialchars(swarmpath("project/{$project['id']}")) . '">' . htmlspecialchars($project['displayTitle']) . '</a></td>';
         if (!$job) {
             $html .= '<td>N/A</td>';
         } else {
             $html .= '<td class="swarm-status-cell swarm-jobstatus-cell"><div class="swarm-status swarm-status-' . $job['summary'] . '">' . JobPage::getStatusIconHtml($job['summary']) . html_tag('a', array('href' => $job['info']['viewUrl'], 'title' => $job['info']['nameText']), 'Job #' . $job['info']['id']) . '</div></td>';
         }
         $html .= '</tr>';
     }
     $html .= '</tbody></table>';
     return $html;
 }
Пример #17
0
 protected function initContent()
 {
     $request = $this->getContext()->getRequest();
     $this->setTitle('Log out');
     $html = '';
     $data = $this->getAction()->getData();
     $error = $this->getAction()->getError();
     if (!$error && $data['status'] == 'logged-out') {
         $this->setTitle('Logged out!');
         $html .= html_tag('div', array('class' => 'alert alert-success'), 'Thanks for running TestSwarm. You are now signed out.');
         // Don't show form in case of success.
         return $html;
     }
     if ($request->wasPosted() && $error) {
         $html .= html_tag('div', array('class' => 'alert alert-error'), $error['info']);
     }
     $html .= '<form action="' . swarmpath('logout') . '" method="post" class="form-horizontal">' . '<fieldset>' . '<legend>Log out</legend>' . '<div class="form-actions">' . '<p>Please submit the following protected form to proceed to log out.</p>' . '<input type="submit" value="Logout" class="btn btn-primary">' . self::getLogoutFormFieldsHtml($this->getContext()) . '</div>' . '</fieldset>' . '</form>';
     return $html;
 }
Пример #18
0
 protected function initContent()
 {
     $browserInfo = $this->getContext()->getBrowserInfo();
     $conf = $this->getContext()->getConf();
     $request = $this->getContext()->getRequest();
     $this->setTitle('Test runner');
     $runToken = null;
     if ($conf->client->requireRunToken) {
         $runToken = $request->getVal("run_token");
         if (!$runToken) {
             return '<div class="alert alert-error">This swarm has restricted access to join the swarm.</div>';
         }
     }
     $this->bodyScripts[] = swarmpath("js/run.js?" . time());
     $client = Client::newFromContext($this->getContext(), $runToken);
     $html = '<script>' . 'SWARM.client_id = ' . json_encode($client->getClientRow()->id) . ';' . 'SWARM.run_token = ' . json_encode($runToken) . ';' . '</script>';
     $html .= '<div class="row">' . '<div class="span2">' . $browserInfo->getIconHtml() . '</div>' . '<div class="span7">' . '<h2>' . htmlspecialchars($client->getClientRow()->name) . '</h2>' . '<p><strong>Status:</strong> <span id="msg"></span></p>' . '</div>' . '</div>' . '<div class="well">' . '<h3>History</h3>' . '<ul id="history"></ul>' . '</div>' . '<div id="iframes"></div>';
     return $html;
 }
Пример #19
0
 protected function initContent()
 {
     $browserInfo = $this->getContext()->getBrowserInfo();
     $conf = $this->getContext()->getConf();
     $request = $this->getContext()->getRequest();
     $uaItem = $browserInfo->getSwarmUaItem();
     $runToken = null;
     if ($conf->client->requireRunToken) {
         $runToken = $request->getVal("run_token");
         if (!$runToken) {
             throw new SwarmException("This swarm has restricted access to join the swarm.");
         }
     }
     $this->setTitle("Test runner");
     $this->displayPageTitle = false;
     $this->displayNavBar = false;
     $this->useContainerCssClass = true;
     if ($browserInfo->getSwarmUaItem()->id === "PS3") {
         $this->bodyScripts[] = swarmpath("js/base64encoder.js");
     }
     $this->bodyScripts[] = swarmpath("js/run.js?" . time());
     $client = null;
     // Try to get the client id from the cookie.
     $clientId = $this->getClientIdFromCookie();
     if (isset($clientId)) {
         // If client id is present then try to reuse it.
         // This might throw an exception if client id doesn't exist on the database, the user agent doesn't match or the ip address doesn't match the database record.
         try {
             $client = Client::newFromContext($this->getContext(), $runToken, $clientId, true);
         } catch (Exception $e) {
         }
     }
     // $client is not set if restoring client id failed or cookie is not present.
     if (!isset($client)) {
         $client = Client::newFromContext($this->getContext(), $runToken);
         $clientId = $client->getClientRow()->id;
         $this->saveClientIdInCookie($clientId);
     }
     $html = '<script>' . 'SWARM.client_id = ' . json_encode($clientId) . ';' . 'SWARM.run_token = ' . json_encode($runToken) . ';' . 'SWARM.decode_html = ' . json_encode(isMaple()) . ';' . '</script>';
     $html .= '<div class="row">' . '<div class="span2">' . '<div class="well pagination-centered thumbnail">' . '<img src="' . swarmpath("img/{$uaItem->displayicon}.sm.png") . '" class="swarm-browsericon ' . '" alt="' . htmlspecialchars($uaItem->displaytitle) . '" title="' . htmlspecialchars($uaItem->displaytitle) . '">' . '<span class="label">' . htmlspecialchars($uaItem->displaytitle) . '</span>' . '<br/>' . '<span class="label label-info" id="deviceName"></span>' . '</div>' . '</div>' . '<div class="span7">' . '<h2>' . htmlspecialchars($client->getUserRow()->name) . '</h2>' . '<p><strong>Status:</strong> <span id="msg"></span></p>' . '</div>' . '</div>' . '<div id="iframes"></div>' . '<div class="well">' . '<h3>History</h3>' . '<ul id="history"></ul>' . '</div>';
     return $html;
 }
Пример #20
0
 protected function initContent()
 {
     $browserInfo = $this->getContext()->getBrowserInfo();
     $conf = $this->getContext()->getConf();
     $request = $this->getContext()->getRequest();
     $uaItem = $browserInfo->getSwarmUaItem();
     $runToken = null;
     if ($conf->client->requireRunToken) {
         $runToken = $request->getVal("run_token");
         if (!$runToken) {
             throw new SwarmException("This swarm has restricted access to join the swarm.");
         }
     }
     $this->setTitle("Test runner");
     $this->bodyScripts[] = swarmpath("js/run.js?" . time());
     $client = Client::newFromContext($this->getContext(), $runToken);
     $html = '<script>' . 'SWARM.client_id = ' . json_encode($client->getClientRow()->id) . ';' . 'SWARM.run_token = ' . json_encode($runToken) . ';' . '</script>';
     $html .= '<div class="row">' . '<div class="span2">' . '<div class="well pagination-centered thumbnail">' . '<img src="' . swarmpath("img/{$uaItem->displayicon}.sm.png") . '" class="swarm-browsericon ' . '" alt="' . htmlspecialchars($uaItem->displaytitle) . '" title="' . htmlspecialchars($uaItem->displaytitle) . '">' . '<span class="label">' . htmlspecialchars($uaItem->displaytitle) . '</span>' . '</div>' . '</div>' . '<div class="span7">' . '<h2>' . htmlspecialchars($client->getUserRow()->name) . '</h2>' . '<p><strong>Status:</strong> <span id="msg"></span></p>' . '</div>' . '</div>' . '<div class="well">' . '<h3>History</h3>' . '<ul id="history"></ul>' . '</div>' . '<div id="iframes"></div>';
     return $html;
 }
Пример #21
0
 protected function initContent()
 {
     $request = $this->getContext()->getRequest();
     $this->setTitle('Log out');
     $html = '';
     $data = $this->getAction()->getData();
     $error = $this->getAction()->getError();
     if (!$error) {
         $this->setTitle('Logged out!');
         $html .= html_tag('div', array('class' => 'alert alert-success'), 'You are now logged out.');
         // Return early, we don't need to show the <form> in case of success.
         return $html;
     }
     // If we weren't logged in in the first place, there is no error.
     // If there is an error now it means we're on a POST request to Logout
     // and the tokens were invalid. Likely a case of a malice or stale state (someone having
     // a tab open for a month with absolute no other activity and the token no longer being
     // valid when they finally click "Logout").
     // Show the user the error and allow them user to manually confirm the log out.
     $auth = $this->getContext()->getAuth();
     $html .= html_tag('div', array('class' => 'alert alert-error'), $error['info']) . '<form action="' . swarmpath('logout') . '" method="post" class="form-horizontal">' . '<fieldset>' . '<legend>Log out</legend>' . '<div class="form-actions">' . '<p>Please submit the following protected form to proceed to log out.</p>' . '<input type="submit" value="Logout" class="btn btn-primary">' . '<input type="hidden" name="authID" value="' . htmlspecialchars($auth->project->id) . '">' . '<input type="hidden" name="authToken" value="' . htmlspecialchars($auth->sessionToken) . '">' . '</div>' . '</fieldset>' . '</form>';
     return $html;
 }
Пример #22
0
    protected function getAddjobFormHtml()
    {
        $conf = $this->getContext()->getConf();
        $request = $this->getContext()->getRequest();
        $swarmUaIndex = BrowserInfo::getSwarmUAIndex();
        $addjobPageUrl = htmlspecialchars(swarmpath("adddevboxjob"));
        $userName = $request->getSessionData("username") && $request->getSessionData("auth") == "yes" ? htmlspecialchars($request->getSessionData("username")) : "";
        // fields to be taken from the querystring:
        $jobName = $request->getVal('jobName');
        $runMax = $request->getVal('runMax') ?: 3;
        $runNames = $request->getArray('runNames');
        $runUrls = $request->getArray('runUrls');
        $selectedBrowsers = $request->getArray('browsers');
        if ($runNames && !$runUrls || !$runNames && $runUrls || $runNames && $runUrls && count($runNames) != count($runUrls)) {
            throw new SwarmException("runNames and runUrls must have the same number of elements in the array");
            return;
        }
        $formHtml = <<<HTML
\t\t\t
<form action="{$addjobPageUrl}" method="post" class="form-horizontal">
\t<div class="row">
\t\t<div class="span6">
HTML;
        $formHtml .= $this->getBrowsers($conf, $swarmUaIndex, $selectedBrowsers);
        $formHtml .= <<<HTML
\t\t</div>
\t\t<div class="span6">
\t\t\t
HTML;
        $formHtml .= <<<HTML

\t\t\t<fieldset>
\t\t\t\t<legend>Runs <i class="icon-question-sign po" data-title="Runs" data-content='Each job consists of several runs. Every run has a name and a url to where that test suite can be ran. All the test suites should probably have the same common code base or some other grouping characteristic, where each run is part of the larger test suite. As example, for a QUnit test suite the <code>filter</code> url parameter can be used to only run one of the "modules" so every run would be the name of that module and the URL to the testsuite with <code>?filter=modulename</code> appended to it.'></i></legend>

\t\t\t\t<label class="control-label" for="button-TickRuns">Ticked runs: &nbsp;</label>

\t\t\t\t<div class="btn-group" data-toggle="buttons-radio" id="button-TickRuns">
\t\t\t\t\t<button class="btn all" type="button">all</button>
\t\t\t\t\t<button class="btn none" type="button">none</button>
\t\t\t\t\t<button class="btn same" type="button">same as last time</button>
\t\t\t\t\t<i class="icon-question-sign po" data-title="Same as last time" data-content='Restores runMax, browserSets and runNames fields from the cookie. runMax value is put into the form field. browserSets are ticked. Runs from the cookie are matched against runs in the html form value.'></i>
\t\t\t\t</div>
\t\t\t\t<div id="runs-container" class="well">
HTML;
        if ($runNames && count($runNames) > 0) {
            for ($i = 0; $i < count($runNames); $i++) {
                $formHtml .= $this->getRun($i + 1, $runNames[$i], $runUrls[$i]);
            }
        } else {
            for ($i = 0; $i < 3; $i++) {
                $formHtml .= $this->getRun($i + 1, $runNames[$i], $runUrls[$i]);
            }
        }
        $formHtml .= <<<HTML
\t\t\t\t</div>
\t\t\t</fieldset>
\t\t\t
\t\t\t<button class="btn" id="btnOtherInformation" type="button">Other information</button>
\t\t\t
\t\t\t<div class="well hide" id="otherInformation">
\t\t\t\t<fieldset>
\t\t\t\t\t<legend>Other information</legend>

\t\t\t\t\t<div class="control-group">
\t\t\t\t\t\t<label class="control-label" for="form-authUsername">User name:</label>
\t\t\t\t\t\t<div class="controls">
\t\t\t\t\t\t\t<input type="text" value="{$userName}" id="form-authUsername" disabled="disabled">
\t\t\t\t\t\t</div>
\t\t\t\t\t</div>
\t\t\t\t\t<div class="control-group">
\t\t\t\t\t\t<label class="control-label" for="form-runMax">Run max:</label>
\t\t\t\t\t\t<div class="controls">
\t\t\t\t\t\t\t<input type="number" size="5" name="runMax" id="form-runMax" value="{$runMax}" min="1" max="99">
\t\t\t\t\t\t\t<i class="icon-question-sign po" data-title="Run max" data-content='This is the maximum number of times a run is ran in a user agent. If a run passes
\t\t\t\t\t\t\twithout failures then it is only ran once. If it does not pass, TestSwarm will re-try the run
\t\t\t\t\t\t\t(up to "Run max" times) for that useragent to avoid error pollution due to time-outs, slow
\t\t\t\t\t\t\tcomputers or other unrelated conditions that can cause the server to not receive a success report.'></i>
\t\t\t\t\t\t</div>
\t\t\t\t\t</div>
\t\t\t\t</fieldset>
\t\t\t\t<input type="hidden" name="jobName" id="form-jobName" maxlength="255" value="{$jobName}">
\t\t\t</div>
\t\t</div>
\t</div>
\t
\t<div class="form-actions">
\t\t<input type="submit" value="Create job" class="btn btn-primary btn-large">
\t</div>
</form>
HTML;
        return $formHtml;
    }
Пример #23
0
				mysql_queryf("DELETE FROM run_client WHERE run_id in (select id from runs where job_id=%u);", $job_id);
				mysql_queryf("DELETE FROM run_useragent WHERE run_id in (select id from runs where job_id=%u);", $job_id);
				mysql_queryf("DELETE FROM runs WHERE job_id=%u;", $job_id);
				mysql_queryf("DELETE FROM jobs WHERE id=%u;", $job_id);
			} else {
				mysql_queryf("UPDATE jobs SET status=0, updated=NOW() WHERE id=%u;", $job_id);
				mysql_queryf("UPDATE runs SET status=0, updated=NOW() WHERE job_id=%u;", $job_id);
			}
		}

		while ( $row = mysql_fetch_row($results) ) {
			$run_id = $row[0];

			mysql_queryf("DELETE FROM run_client WHERE run_id=%u;", $run_id);

			if ( $type == "delete" ) {
				mysql_queryf("DELETE FROM run_useragent WHERE run_id=%u;", $run_id);
			} else {
				mysql_queryf("UPDATE run_useragent SET runs=0, completed=0, status=0, updated=NOW() WHERE run_id=%u;", $run_id);
			}
		}

		if ( $type == "delete" ) {
			header("Location: " . swarmpath( "user/{$_SESSION["username"]}/" ) );
		} else {
		header("Location: " . swarmpath( "job/{$job_id}/" ) );
		}
	}

	exit();
Пример #24
0
 public function doAction()
 {
     $db = $this->getContext()->getDB();
     $request = $this->getContext()->getRequest();
     $userName = $request->getVal("item");
     if (!$userName) {
         $this->setError("missing-parameters");
         return;
     }
     $userID = $db->getOne(str_queryf("SELECT id FROM users WHERE name = %s;", $userName));
     $userID = intval($userID);
     if (!$userID) {
         $this->setError("invalid-input", "User does not exist");
         return;
     }
     $uaIndex = BrowserInfo::getSwarmUAIndex();
     // Active clients
     $activeClients = array();
     $clientRows = $db->getRows(str_queryf("SELECT\n\t\t\t\tuseragent_id,\n\t\t\t\tuseragent,\n\t\t\t\tcreated\n\t\t\tFROM\n\t\t\t\tclients\n\t\t\tWHERE user_id = %u\n\t\t\tAND   updated > %s\n\t\t\tORDER BY created DESC;", $userID, swarmdb_dateformat(strtotime("1 minutes ago"))));
     if ($clientRows) {
         foreach ($clientRows as $clientRow) {
             $bi = BrowserInfo::newFromContext($this->getContext(), $clientRow->useragent);
             $activeClient = array("uaID" => $clientRow->useragent_id, "uaRaw" => $bi->getRawUA(), "uaData" => $bi->getSwarmUaItem(), "uaBrowscap" => $bi->getBrowscap());
             self::addTimestampsTo($activeClient, $clientRow->created, "connected");
             $activeClients[] = $activeClient;
         }
     }
     // Recent jobs
     $recentJobs = array();
     // List of all user agents used in recent jobs
     // This is as helper allow creating proper gaps when iterating
     // over jobs.
     $userAgents = array();
     $jobRows = $db->getRows(str_queryf("SELECT\n\t\t\t\tid,\n\t\t\t\tname\n\t\t\tFROM\n\t\t\t\tjobs\n\t\t\tWHERE jobs.user_id = %u\n\t\t\tORDER BY jobs.created DESC\n\t\t\tLIMIT 15;", $userID));
     if ($jobRows) {
         $uaRunStatusStrength = array_flip(array("passed", "new", "progress", "failed", "timedout", "error"));
         foreach ($jobRows as $jobRow) {
             $jobID = intval($jobRow->id);
             $jobActionContext = $this->getContext()->createDerivedRequestContext(array("action" => "job", "item" => $jobID), "GET");
             $jobAction = JobAction::newFromContext($jobActionContext);
             $jobAction->doAction();
             if ($jobAction->getError()) {
                 $this->setError($jobAction->getError());
                 return;
             }
             $jobActionData = $jobAction->getData();
             // Add user agents array of this job to the overal user agents list.
             // php array+ automatically fixes clashing keys. The values are always the same
             // so it doesn't matter whether or not it overwrites.
             $userAgents += $jobActionData["userAgents"];
             // The summerized status for each user agent run
             // of this job. e.g. if all are new except one,
             // then it will be on "progress", if all are complete
             // then the worst failure is put in the summary
             $uaSummary = array();
             $uaNotNew = array();
             $uaHasIncomplete = array();
             $uaStrongestStatus = array();
             foreach ($jobActionData["runs"] as $run) {
                 foreach ($run["uaRuns"] as $uaID => $uaRun) {
                     if ($uaRun["runStatus"] !== "new" && !in_array($uaID, $uaNotNew)) {
                         $uaNotNew[] = $uaID;
                     }
                     if ($uaRun["runStatus"] === "new" || $uaRun["runStatus"] === "progress") {
                         if (!in_array($uaID, $uaHasIncomplete)) {
                             $uaHasIncomplete[] = $uaID;
                         }
                     }
                     if (!isset($uaStrongestStatus[$uaID]) || $uaRunStatusStrength[$uaRun["runStatus"]] > $uaRunStatusStrength[$uaStrongestStatus[$uaID]]) {
                         $uaStrongestStatus[$uaID] = $uaRun["runStatus"];
                     }
                     $uaSummary[$uaID] = !in_array($uaID, $uaNotNew) ? "new" : (in_array($uaID, $uaHasIncomplete) ? "progress" : $uaStrongestStatus[$uaID]);
                 }
             }
             $recentJobs[] = array("id" => $jobID, "name" => $jobRow->name, "url" => swarmpath("job/{$jobID}", "fullurl"), "uaSummary" => $uaSummary);
         }
     }
     natcaseksort($userAgents);
     $this->setData(array("userName" => $userName, "activeClients" => $activeClients, "recentJobs" => $recentJobs, "uasInJobs" => $userAgents));
 }
Пример #25
0
    /**
     * Be careful to never throw exceptions from here if we're already
     * on the Error500Page. e.g. if content of FooPage is empty, this throws
     * an exception but then index.php instantiates a new page (Error500Page),
     * which does have content. So any exception thrown from here (either directly
     * or indirectly from an Action class), should either be caught or made sure
     * that it doesn't occurr for a Error500Page).
     */
    public function output()
    {
        $this->execute();
        if (!$this->getContent()) {
            throw new SwarmException("Page `content` must not be empty.");
        }
        if (!$this->getTitle()) {
            throw new SwarmException("Page `title` must not be empty.");
        }
        if (headers_sent($filename, $linenum)) {
            throw new SwarmException("Headers already sent in `{$filename}` on line {$linenum}.");
        }
        header("Content-Type: text/html; charset=utf-8");
        $request = $this->getContext()->getRequest();
        // ProjectsAction could throw an exception, which needs to be caught here,
        // since Error500Page (exception handler) also uses Page::output() eventually.
        // @todo: Find a cleaner way to deal with exceptions in the final page out,
        // because page output is also used on the Error500Page.
        $projects = array();
        if (!isset($this->exceptionObj)) {
            try {
                $projectsActionContext = $this->getContext()->createDerivedRequestContext(array("action" => "projects", "sort" => "name", "sort_oder" => "asc"));
                $projectsAction = ProjectsAction::newFromContext($projectsActionContext);
                $projectsAction->doAction();
                $projects = $projectsAction->getData();
            } catch (Exception $e) {
                $pageObj = Error500Page::newFromContext($this->getContext());
                $pageObj->setExceptionObj($e);
                $pageObj->output();
                exit;
            }
        }
        ?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<?php 
        foreach ($this->metaTags as $metaTag) {
            echo "\t" . html_tag("meta", $metaTag) . "\n";
        }
        $subTitleSuffix = $this->getSubTitle() ? ": {$this->getSubTitle()}" : "";
        $htmlTitle = $this->getTitle() . $subTitleSuffix . " - " . $this->getContext()->getConf()->web->title;
        $displayTitleHtml = $this->getDisplayTitleHtml();
        ?>
	<title><?php 
        echo htmlentities($htmlTitle);
        ?>
</title>
	<link rel="stylesheet" href="<?php 
        echo swarmpath("css/bootstrap.min.css");
        ?>
">
	<link rel="stylesheet" href="<?php 
        echo swarmpath("css/testswarm.css");
        ?>
">
	<script src="<?php 
        echo swarmpath("js/jquery.js");
        ?>
"></script>
	<script src="<?php 
        echo swarmpath("js/bootstrap-dropdown.js");
        ?>
"></script>
	<script>window.SWARM = <?php 
        $infoAction = InfoAction::newFromContext($this->getContext());
        $infoAction->doAction();
        echo json_encode($infoAction->getData());
        ?>
;</script><?php 
        foreach ($this->styleSheets as $styleSheet) {
            echo "\n\t" . html_tag("link", array("rel" => "stylesheet", "href" => $styleSheet));
        }
        foreach ($this->headScripts as $headScript) {
            echo "\n\t" . html_tag("script", array("src" => $headScript));
        }
        ?>
</head>
<body>
	<div class="navbar navbar-fixed-top">
		<div class="navbar-inner">
			<div class="container">
				<a class="brand" href="<?php 
        echo swarmpath("");
        ?>
"><?php 
        echo htmlspecialchars($this->getContext()->getConf()->web->title);
        ?>
</a>
				<div class="nav-collapse">
					<ul class="nav">
						<li><a href="<?php 
        echo swarmpath("");
        ?>
">Home</a></li>
						<li class="dropdown" id="swarm-projectsmenu">
							<a href="<?php 
        echo swarmpath("projects");
        ?>
" class="dropdown-toggle" data-toggle="dropdown" data-target="#swarm-projectsmenu">
								Projects
								<b class="caret"></b>
							</a>
							<ul class="dropdown-menu">
								<li><a href="<?php 
        echo swarmpath("projects");
        ?>
">All projects</a></li>
								<li class="divider"></li>
								<li class="nav-header">Projects</li>
<?php 
        foreach ($projects as $project) {
            ?>
								<li><a href="<?php 
            echo htmlspecialchars(swarmpath("user/{$project["name"]}"));
            ?>
"><?php 
            echo htmlspecialchars($project["name"]);
            ?>
</a></li>
<?php 
        }
        ?>
							</ul>
						</li>
						<li><a href="<?php 
        echo swarmpath("scores");
        ?>
">Scores</a></li>
						<li><a href="<?php 
        echo swarmpath("about");
        ?>
">About</a></li>
					</ul>
					<ul class="nav pull-right">
<?php 
        if ($request->getSessionData("username") && $request->getSessionData("auth") == "yes") {
            $username = htmlspecialchars($request->getSessionData("username"));
            ?>
						<li><a href="<?php 
            echo swarmpath("user/{$username}");
            ?>
">Hello, <?php 
            echo $username;
            ?>
!</a></li>
						<li><a href="<?php 
            echo swarmpath("run/{$username}");
            ?>
">Join the Swarm</a></li>
						<li><a href="<?php 
            echo swarmpath("logout");
            ?>
">Logout</a></li>
<?php 
        } else {
            ?>
						<li><a href="<?php 
            echo swarmpath("login");
            ?>
">Login</a></li>
						<li><a href="<?php 
            echo swarmpath("signup");
            ?>
">Signup</a></li>
<?php 
        }
        ?>
					</ul>
				</div><!--/.nav-collapse -->
			</div>
		</div>
	</div>

	<div class="container">
		<div class="hero-unit">
			<h1><?php 
        echo $displayTitleHtml;
        ?>
</h1>
		</div>
<?php 
        echo $this->getContent();
        ?>

		<hr>
		<footer class="swarm-page-footer">
			<p>Powered by <a href="//github.com/jquery/testswarm">TestSwarm</a>:
			<a href="//github.com/jquery/testswarm">Source Code</a>
			| <a href="//github.com/jquery/testswarm/issues">Issue Tracker</a>
			| <a href="//github.com/jquery/testswarm/wiki">About</a>
			| <a href="//twitter.com/testswarm">Twitter</a>
			</p>
		</footer>
	</div>
	<script src="<?php 
        echo swarmpath("js/pretty.js");
        ?>
"></script>
	<script src="<?php 
        echo swarmpath("js/testswarm.js");
        ?>
"></script><?php 
        foreach ($this->bodyScripts as $bodyScript) {
            echo "\n\t" . html_tag("script", array("src" => $bodyScript));
        }
        if ($this->getContext()->getConf()->debug->dbLogQueries) {
            $queryLog = $this->getContext()->getDB()->getQueryLog();
            $queryLogHtml = '<hr><h3>Database query log</h3><div class="well"><ul class="unstyled">';
            foreach ($queryLog as $i => $queryInfo) {
                if ($i !== 0) {
                    $queryLogHtml .= '<hr>';
                }
                $queryLogHtml .= '<li>' . '<pre>' . htmlspecialchars($queryInfo["sql"]) . '</pre>' . '<table class="table table-bordered table-condensed"><tbody><tr>' . '<td>Caller: <code>' . htmlspecialchars($queryInfo["caller"]) . '</code></td>' . '<td>Num rows: <code>' . htmlspecialchars($queryInfo["numRows"]) . '</code></td>' . '<td>Insert ID: <code>' . htmlspecialchars($queryInfo["insertId"]) . '</code></td>' . '<td>Affected rows: <code>' . htmlspecialchars($queryInfo["affectedRows"]) . '</code></td>' . '<td>Query time: <code>' . htmlspecialchars(substr($queryInfo["queryTime"], 0, 8)) . '</code></td>' . '</tr></table>' . '</li>';
            }
            $queryLogHtml .= '</ul>';
            echo $queryLogHtml;
        }
        ?>
</body>
</html>
<?php 
        // End of Page::output
    }
Пример #26
0
    /**
     * Small messages
     */
    public function outputMini($title, $message = null)
    {
        ?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
	<meta charset="UTF-8">
	<title><?php 
        echo htmlspecialchars($title . ' - ' . $this->getContext()->getConf()->web->title);
        ?>
</title>
	<link rel="stylesheet" href="<?php 
        echo swarmpath('external/bootstrap/css/bootstrap.css');
        ?>
">
	<link rel="stylesheet" href="<?php 
        echo swarmpath('css/testswarm.css');
        ?>
">
</head>
<body>
<div class="hero-unit">
	<h1><?php 
        echo htmlspecialchars($title);
        ?>
</h1>
<?php 
        if ($message) {
            ?>
	<p><?php 
            echo htmlspecialchars($message);
            ?>
</p>
<?php 
        }
        ?>
</div>
</body>
</html>
<?php 
    }
Пример #27
0
<?php
	$title = "Distributed Continuous Integration for JavaScript";
	$scripts = '<script type="text/javascript" src="' . swarmpath( "js/jquery.js" ) . '"></script>';
Пример #28
0
    /**
     * @actionParam int item: Runresults ID.
     */
    public function doAction()
    {
        $context = $this->getContext();
        $db = $context->getDB();
        $conf = $context->getConf();
        $request = $context->getRequest();
        $item = $request->getInt('item');
        $row = $db->getRow(str_queryf('SELECT
				id,
				run_id,
				client_id,
				status,
				updated,
				created,
        result_url,
        build_url
			FROM runresults
			WHERE id = %u;', $item));
        if (!$row) {
            $this->setError('invalid-input', 'Runresults ID not found.');
            return;
        }
        $data = array();
        $data['result_url'] = $row->result_url;
        $data['build_url'] = $row->build_url;
        // A job can be deleted without nuking the runresults,
        // this is by design so results stay permanently accessible
        // under a simple url.
        // If the job is no longer in existance, properties
        // 'otherRuns' and 'job' will be set to null.
        $runRow = $db->getRow(str_queryf('SELECT
				id,
				url,
				name,
				job_id
			FROM runs
			WHERE id = %u;', $row->run_id));
        if (!$runRow) {
            $data['otherRuns'] = null;
            $data['job'] = null;
        } else {
            $data['otherRuns'] = JobAction::getDataFromRunRows($context, array($runRow));
            $jobID = intval($runRow->job_id);
            $data['job'] = array('id' => $jobID, 'url' => swarmpath("job/{$jobID}", "fullurl"));
        }
        $clientRow = $db->getRow(str_queryf('SELECT
				id,
				name,
				useragent_id,
				useragent
			FROM clients
			WHERE id = %u;', $row->client_id));
        $data['info'] = array('id' => intval($row->id), 'runID' => intval($row->run_id), 'clientID' => intval($row->client_id), 'status' => self::getStatus($row->status));
        $data['client'] = array('id' => $clientRow->id, 'name' => $clientRow->name, 'uaID' => $clientRow->useragent_id, 'uaRaw' => $clientRow->useragent, 'viewUrl' => swarmpath('client/' . $clientRow->id));
        // If still busy or if the client was lost, then the last update time is irrelevant
        // Alternatively this could test if $row->updated == $row->created, which would effectively
        // do the same.
        if ($row->status == self::$STATE_BUSY || $row->status == self::$STATE_LOST) {
            $data['info']['runTime'] = null;
        } else {
            $data['info']['runTime'] = gmstrtotime($row->updated) - gmstrtotime($row->created);
            self::addTimestampsTo($data['info'], $row->updated, 'saved');
        }
        self::addTimestampsTo($data['info'], $row->created, 'started');
        $this->setData($data);
    }
Пример #29
0
    protected function getAddjobFormHtml()
    {
        $conf = $this->getContext()->getConf();
        $request = $this->getContext()->getRequest();
        $swarmUaIndex = BrowserInfo::getSwarmUAIndex();
        $addjobPageUrl = htmlspecialchars(swarmpath("addjob"));
        $userName = $request->getSessionData("username") && $request->getSessionData("auth") == "yes" ? htmlspecialchars($request->getSessionData("username")) : "";
        $formHtml = <<<HTML
<form action="{$addjobPageUrl}" method="post" class="form-horizontal">

\t<fieldset>
\t\t<legend>Authentication</legend>

\t\t<div class="control-group">
\t\t\t<label class="control-label" for="form-authUsername">User name:</label>
\t\t\t<div class="controls">
\t\t\t\t<input type="text" name="authUsername" value="{$userName}" id="form-authUsername">
\t\t\t</div>
\t\t</div>
\t\t<div class="control-group">
\t\t\t<label class="control-label" for="form-authToken">Auth token:</label>
\t\t\t<div class="controls">
\t\t\t\t<input type="text" name="authToken" id="form-authToken" class="input-xlarge">
\t\t\t</div>
\t\t</div>
\t</fieldset>

\t<fieldset>
\t\t<legend>Job information</legend>

\t\t<div class="control-group">
\t\t\t<label class="control-label" for="form-jobName">Job name:</label>
\t\t\t<div class="controls">
\t\t\t\t<input type="text" name="jobName" id="form-jobName" class="input-xlarge" maxlength="255">
\t\t\t\t<span class="help-inline">HTML, up to 255 characters</span>
\t\t\t</div>
\t\t</div>
\t\t<div class="control-group">
\t\t\t<label class="control-label" for="form-runMax">Run max:</label>
\t\t\t<div class="controls">
\t\t\t\t<input type="number" size="5" name="runMax" id="form-runMax" value="2" min="1" max="99">
\t\t\t\t<p class="help-block">This is the maximum number of times a run is ran in a user agent. If a run passes
\t\t\t\twithout failures then it is only ran once. If it does not pass, TestSwarm will re-try the run
\t\t\t\t(up to "Run max" times) for that useragent to avoid error pollution due to time-outs, slow
\t\t\t\tcomputers or other unrelated conditions that can cause the server to not receive a success report.</p>
\t\t\t</div>
\t\t</div>
\t</fieldset>

\t<fieldset>
\t\t<legend>Browsers</legend>

\t\t<p>Choose which groups of user agents this job should be ran in. Some of the groups may
\t\toverlap each other, TestSwarm will detect and remove duplicate entries in the resulting set.</p>

HTML;
        foreach ($conf->browserSets as $set => $browsers) {
            $set = htmlspecialchars($set);
            $browsersHtml = '';
            $last = count($browsers) - 1;
            foreach ($browsers as $i => $browser) {
                if ($i !== 0) {
                    $browsersHtml .= $i === $last ? '<br> and ' : ',<br>';
                } else {
                    $browsersHtml .= '<br>';
                }
                $browsersHtml .= htmlspecialchars($swarmUaIndex->{$browser}->displaytitle);
            }
            $formHtml .= <<<HTML
\t\t<div class="control-group">
\t\t\t<label class="checkbox" for="form-browserset-{$set}">
\t\t\t\t<input type="checkbox" name="browserSets[]" value="{$set}" id="form-browserset-{$set}">
\t\t\t\t<strong>{$set}</strong>: {$browsersHtml}.
\t\t\t</label>
\t\t</div>
HTML;
        }
        $formHtml .= <<<HTML
\t</fieldset>

\t<fieldset>
\t\t<legend>Runs</legend>

\t\t<p>Each job consists of several runs. Every run has a name and a url to where that test suite can be ran. All the test suites should probably have the same common code base or some other grouping characteristic, where each run is part of the larger test suite. As example, for a QUnit test suite the <code>filter</code> url parameter can be used to only run one of the "modules" so every run would be the name of that module and the URL to the testsuite with <code>?filter=modulename</code> appended to it.</p>

\t\t<div id="runs-container" class="well">
\t\t\t<fieldset>
\t\t\t\t<legend>Run 1</legend>

\t\t\t\t<label for="form-runNames1">Run name:</label>
\t\t\t\t<input type="text" name="runNames[]" id="form-runNames1" maxlength="255">
\t\t\t\t<br>
\t\t\t\t<label for="form-runUrls1">Run URL:</label>
\t\t\t\t<input type="text" name="runUrls[]" placeholder="http://" class="input-xlarge"id="form-runUrls1">
\t\t\t</fieldset>
\t\t\t<fieldset>
\t\t\t\t<legend>Run 2</legend>

\t\t\t\t<label for="form-runNames2">Run name:</label>
\t\t\t\t<input type="text" name="runNames[]" id="form-runNames2" maxlength="255">
\t\t\t\t<br>
\t\t\t\t<label for="form-runUrls2">Run URL:</label>
\t\t\t\t<input type="text" name="runUrls[]" placeholder="http://" class="input-xlarge"id="form-runUrls2">
\t\t\t</fieldset>
\t\t\t<fieldset>
\t\t\t\t<legend>Run 3</legend>

\t\t\t\t<label for="form-runNames3">Run name:</label>
\t\t\t\t<input type="text" name="runNames[]" id="form-runNames3" maxlength="255">
\t\t\t\t<br>
\t\t\t\t<label for="form-runUrls3">Run URL:</label>
\t\t\t\t<input type="text" name="runUrls[]" placeholder="http://" class="input-xlarge"id="form-runUrls3">
\t\t\t</fieldset>
\t\t</div>
\t</fieldset>

\t<div class="form-actions">
\t\t<input type="submit" value="Create job" class="btn btn-primary btn-large">
\t</div>
</form>
HTML;
        return $formHtml;
    }
Пример #30
0
<form action="" method="post">
	<fieldset>
		<legend>Signup</legend>
		<?php echo $error; ?>
		<p>Signup to use TestSwarm. If you already have an account you may <a href="<?php echo swarmpath( "login/" ); ?>">Login Here</a>.</p>
		<label>Username: <input type="text" name="username"/></label><br/>
		<label>Password: <input type="password" name="password"/></label><br/>
		<label>Email: <input type="text" name="email"/></label><br/>
		<label>Request Auth Code:<br/>
		If you run an Open Source project and wish to submit jobs to be run on TestSwarm please provide a URL and description of the project below. Your auth code will be emailed to you, pending approval.<br/><textarea cols="40" rows="6" name="request"></textarea></label><br/>
		<input type="submit" value="Signup"/>
	</fieldset>
</form>