Skip to content

Commit

Permalink
Alpha build
Browse files Browse the repository at this point in the history
  • Loading branch information
saekort committed Jul 10, 2015
1 parent 6298b42 commit abf2b66
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 29 deletions.
15 changes: 12 additions & 3 deletions db/db_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jul 08, 2015 at 01:33 PM
-- Generation Time: Jul 10, 2015 at 04:31 PM
-- Server version: 5.6.17
-- PHP Version: 5.5.12

Expand Down Expand Up @@ -166,7 +166,13 @@ INSERT INTO `j_author_scenario` (`scenario_id`, `author_id`) VALUES

INSERT INTO `j_scenario_person` (`scenario_id`, `person_id`, `pfs`, `core`, `pfs_gm`, `core_gm`) VALUES
(1, 1, NULL, NULL, NULL, NULL),
(2, 2, NULL, NULL, NULL, NULL);
(2, 2, NULL, NULL, NULL, NULL),
(4, 7, NULL, NULL, NULL, NULL),
(3, 7, NULL, NULL, NULL, NULL),
(11, 7, NULL, NULL, NULL, NULL),
(15, 1, NULL, NULL, NULL, NULL),
(21, 1, NULL, NULL, NULL, NULL),
(19, 1, NULL, NULL, NULL, NULL);

--
-- Dumping data for table `j_scenario_subtier`
Expand Down Expand Up @@ -368,7 +374,10 @@ INSERT INTO `people` (`id`, `name`, `pfsnumber`, `created_on`, `updated_on`, `de
(3, 'Rik', NULL, '0000-00-00 00:00:00', '0000-00-00 00:00:00', NULL),
(4, 'Kwinten', NULL, '0000-00-00 00:00:00', '0000-00-00 00:00:00', NULL),
(5, 'Maite', NULL, '0000-00-00 00:00:00', '0000-00-00 00:00:00', NULL),
(6, 'Willeke', 123251, '0000-00-00 00:00:00', '0000-00-00 00:00:00', NULL);
(6, 'Willeke', 123251, '0000-00-00 00:00:00', '0000-00-00 00:00:00', NULL),
(7, 'Test', 1, '0000-00-00 00:00:00', '0000-00-00 00:00:00', NULL),
(8, 'Testzoon', 2, '0000-00-00 00:00:00', '0000-00-00 00:00:00', NULL),
(9, 'Bob test', 3, '0000-00-00 00:00:00', '0000-00-00 00:00:00', NULL);

--
-- Dumping data for table `scenarios`
Expand Down
13 changes: 6 additions & 7 deletions src/client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="favicon.ico">


<title>PFS Sessiontracker</title>

<link rel="stylesheet" href="./css/bootstrap.css">
Expand Down Expand Up @@ -36,9 +35,9 @@
<div class="col-sm-4">
<div class="form-group has-feedback">
<label class="control-label">Search players</label>
<input id="playersearch" class="search form-control" ng-model="vm.filters.playersearch" typeahead="person for person in vm.getPeople($viewValue)" ng-model-options="{debounce: 300}" placeholder="Search"><i class="glyphicon glyphicon-search form-control-feedback" style="color: grey;"></i> <button ng-click="vm.addPlayer()">Add</button>
<input id="playersearch" class="search form-control" ng-model="vm.filters.playersearch" typeahead="person for person in vm.getPeople($viewValue)" typeahead-min-length="1" placeholder="Search"><i class="glyphicon glyphicon-search form-control-feedback" style="color: grey;"></i> <button ng-click="vm.addPlayer()">Add</button>
</div>
<div>Filtering: <span ng-repeat="person in vm.people"><span class="filter_player label label-default">{{person.name}} ({{person.pfsnumber}}) <a href="" role="button" ng-click="vm.removePlayer($index)">X</a></span>&nbsp;</span>
<div ng-show="vm.people.length > 0">Filtering: <span ng-repeat="person in vm.people"><span class="filter_player label label-default">{{person.name}} ({{person.pfsnumber}}) <a href="" role="button" ng-click="vm.removePlayer($index)">X</a></span>&nbsp;</span>
</div>
</div>
</div>
Expand All @@ -62,10 +61,9 @@ <h2>Filters</h2>
on-handle-up="vm.getScenarios()"></div>
</div>
<div class="form-group filter">
<strong>Season</strong>
<div class="checkbox" ng-repeat="season in vm.filters.seasons">
<label for="season-{{season.key}}" title="{{ season.name }}"><input id="season-{{season.key}}" type="checkbox" name="season" ng-model="season.checked" value="{{season.key}}" ng-click="vm.getScenarios()">
{{ season.name }}</label>
<strong class="col-sm-12">Season</strong><br>
<div class="checkbox col-sm-6" ng-repeat="season in vm.filters.seasons">
<label for="season-{{season.key}}" title="{{ season.name }}"><input id="season-{{season.key}}" type="checkbox" name="season" ng-model="season.checked" value="{{season.key}}" ng-click="vm.getScenarios()">{{ season.name }}</label>
</div>
</div>
<div class="form-group filter" ng-hide="1==1">
Expand All @@ -79,6 +77,7 @@ <h2>Filters</h2>
</div>
<div class="form-group filter">
<strong>Other:</strong>
<br>
<div class="checkbox">
<label class="checkbox"><input type="checkbox" ng-model="vm.filters.evergreen" value="" ng-click="vm.getScenarios()"><span class="glyphicon glyphicon-leaf evergreen"></span> Only evergreens</label>
</div>
Expand Down
14 changes: 2 additions & 12 deletions src/client/scripts/controllers/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
vm.pagination.currentPage = 1;
vm.pagination.pageSize = 20;

vm.getPeople();
vm.getScenarios();
}

Expand Down Expand Up @@ -101,7 +100,7 @@
}
}

vm.$http.get('http://localhost/pfs-scenariotracker/src/server_ci3/index.php/api/v1/scenarios' + '?' + query).
vm.$http.get('http://pfs.campaigncodex.com/api/v1/scenarios' + '?' + query).
success(function(data, status, headers, config) {
// Assign scenarios
vm.scenarios = data.scenarios;
Expand All @@ -128,7 +127,7 @@
{
var vm = this;

return vm.$http.get('http://localhost/pfs-scenariotracker/src/server_ci3/index.php/api/v1/people').then(
return vm.$http.get('http://pfs.campaigncodex.com/api/v1/people?search=' + search).then(
function(response){
return response.data.map(function(item)
{
Expand Down Expand Up @@ -181,15 +180,6 @@
focus('playersearch');
});
}
else
{
vm.$http.get('http://localhost/pfs-scenariotracker/src/server_ci3/index.php/api/v1/person/name/' + name).then(function(response) {
vm.people.push(response.data[0]);
vm.filters.playersearch = '';
vm.getScenarios();
focus('playersearch');
});
}
}
}

Expand Down
38 changes: 32 additions & 6 deletions src/server_ci3/application/controllers/api/v1.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,25 @@ function __construct()

function scenarios_get()
{


/**
* THIS WORKS!
SELECT *
FROM `scenarios`
WHERE `scenarios`.`id` NOT IN(
SELECT `scenarios`.`id`
FROM `scenarios`
LEFT OUTER JOIN `j_scenario_person`
`players_j_scenario_person` ON `scenarios`.`id` = `players_j_scenario_person`.`scenario_id`
WHERE
`players_j_scenario_person`.`person_id` IN(1, 2, 3, 4, 5)
)
*/

// Set a limit, could be expanded later on
$limit = 20;

Expand Down Expand Up @@ -84,10 +103,12 @@ function scenarios_get()
// Filter: Players
if($this->get('player'))
{
foreach($this->get('player') as $pfsnumber)
{
$scenarios->where_related('players', 'id IS NULL', NULL);
}
$pfsnumbers = array();

$subq_players = new Scenario();
$subq_players->select('id')->where_in_related_players('pfsnumber', $this->get('player'));

$scenarios->where_not_in_subquery('id', $subq_players);
}

// Pagination
Expand All @@ -111,8 +132,6 @@ function scenarios_get()
}

$scenarios->get();
// echo $scenarios->check_last_query();
// exit;
}

$i++;
Expand Down Expand Up @@ -187,7 +206,14 @@ function scenario_get()

function people_get()
{
if(!$this->get('search'))
{
$this->response(NULL, 400);
}

$people = new Person();
$people->or_like('name', $this->get('search'));
$people->or_like('pfsnumber', $this->get('search'));
$people->get();

if($people->exists())
Expand Down
2 changes: 1 addition & 1 deletion src/server_ci3/application/models/Scenario.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Scenario extends DataMapper {
'join_table' => 'j_scenario_person'
)
);

/* Relationship Examples
* For normal relationships, simply add the model name to the array:
* $has_one = array('user'); // Scenario has one User
Expand Down

0 comments on commit abf2b66

Please sign in to comment.