Skip to content
This repository has been archived by the owner on Apr 10, 2018. It is now read-only.

Commit

Permalink
Condensed "current usage" stats down to 1 view
Browse files Browse the repository at this point in the history
  • Loading branch information
ilumos committed Jan 29, 2014
1 parent d0f8a52 commit f69b5f3
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 91 deletions.
6 changes: 3 additions & 3 deletions public/css/lanager.css
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,16 @@ span.shout-timestamp {
}

/* -------------------------------------------------------------------
STATES - USAGE
STATES - CURRENT USAGE
-------------------------------------------------------------------
*/

/* snug logo size */
table.state-usage td.column-application {
table.states-current-usage td.column-application {
width: 184px;
}
/* easy to read user count */
table.state-usage td.column-user-count {
table.states-current-usage td.column-user-count {
font-size: 200%;
font-weight: bold;
padding: 0px 30px;
Expand Down
11 changes: 11 additions & 0 deletions src/Zeropingheroes/LanagerCore/Models/Server.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace Zeropingheroes\LanagerCore\Models;

use SteamBrowserProtocol;

class Server extends BaseModel {

Expand All @@ -23,6 +24,16 @@ public function getFullAddress()
if( $this->address )
{
return $this->address;
// Todo: add support for default application ports
}
}

public function getUrl()
{
if( ! empty($this->application->steam_app_id) )
{
return SteamBrowserProtocol::connectToServer($this->getFullAddress());
}
// Todo: add support for non-steam app connection URLs
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,8 @@ public function getCurrentApplicationUsage()
foreach($usage as $item)
{
$applications[] = array(
'id' => $item['application']->id,
'name' => $item['application']->name,
'steam_app_id' => $item['application']->steam_app_id,
'logo' => $item['application']->getLogo(),
'users' => $item['users'],
'application' => $item['application'],
'users' => $item['users'],
);
}

Expand Down Expand Up @@ -120,18 +117,17 @@ public function getCurrentServerUsage()
foreach($states as $state)
{
$usage[$state->server_id]['server'] = $state->server;
$usage[$state->server_id]['application'] = $state->application;
$usage[$state->server_id]['users'][] = $state->user;
}

// Build clean array of servers
foreach($usage as $item)
{
$servers[] = array(
'id' => $item['server']->id,
'address' => $item['server']->address,
'port' => $item['server']->port,
'application' => $item['server']->application,
'users' => $item['users'],
'server' => $item['server'],
'application' => $item['application'],
'users' => $item['users'],
);
}

Expand Down
8 changes: 4 additions & 4 deletions src/controllers/StateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public function __construct(StateRepositoryInterface $states)
public function currentApplicationUsage()
{
$applications = $this->states->getCurrentApplicationUsage();
return View::make('lanager-core::state.application.usage')
return View::make('lanager-core::state.usage')
->with('title','Games Currently Being Played')
->with('applications',$applications);
->with('itemsInUse',$applications);
}

/**
Expand All @@ -33,9 +33,9 @@ public function currentApplicationUsage()
public function currentServerUsage()
{
$servers = $this->states->getCurrentServerUsage();
return View::make('lanager-core::state.server.usage')
return View::make('lanager-core::state.usage')
->with('title','Game Servers Currently Being Used')
->with('servers',$servers);
->with('itemsInUse',$servers);
}

}
35 changes: 0 additions & 35 deletions src/views/State/application/usage.blade.php

This file was deleted.

39 changes: 0 additions & 39 deletions src/views/State/server/usage.blade.php

This file was deleted.

50 changes: 50 additions & 0 deletions src/views/State/usage.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
@extends('lanager-core::layouts.default')
@section('content')
<h2>{{{ $title }}}</h2>
@if(count($itemsInUse))

{{ Table::open(array('class' => 'states-current-usage')) }}

<?php
$i = 0;
$totalUsers = 0;
foreach ( $itemsInUse as $itemInUse )
{
$users = array();
foreach ( $itemInUse['users'] as $user )
{
$users[] = link_to_route('user.show', $user->username, $user->id);
}
$rows[$i]['application'] = '<a href="'.SteamBrowserProtocol::viewAppInStore($itemInUse['application']->steam_app_id).'"><img src="'.$itemInUse['application']->getLogo().'" alt="Game Logo" title="'.$itemInUse['application']->name.'"></a>';
$rows[$i]['user-count'] = count($users);
if( isset($itemInUse['server']) )
{
if( $itemInUse['server']->getUrl() )
{
$rows[$i]['address'] = '<a href="'.$itemInUse['server']->getUrl().'" title="Connect to server">'.$itemInUse['server']->getFullAddress().'</a>';
}
else
{
$rows[$i]['address'] = $itemInUse['server']->getFullAddress();
}
}
$rows[$i]['users'] = implode(', ', $users);
$i++;
}
?>
{{ Table::body($rows) }}

{{ Table::close() }}

@else
<p>No usage to show!</p>
@endif
@endsection

0 comments on commit f69b5f3

Please sign in to comment.