Skip to content

Update project for work with newer version of the bot #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion app/data/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
"auth_service": "google",
"username": "YOUR_USERNAME",
"password": "YOUR_PASSWORD",
"location": "52.39037297896968,4.828920364379883",
"location": "",
"favorite_locations":[
{"name": "Default", "coords": "52.39037297896968,4.828920364379883"}
],
"gmapkey": "GOOGLE_MAPS_API_KEY",
"encrypt_location": "",
"telegram_token": "",
"discord_token": "",
"tasks": [
{
"type": "HandleSoftBan"
Expand Down
20 changes: 10 additions & 10 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,27 @@
your browser</a> to improve your experience.</p>
<![endif]-->
<div ng-controller="MainCtrl">
<!-- Add your site or application content here -->
<div class="header">
<div class="navbar navbar-default" role="navigation">
<div class="container">
<div class="navbar-header">

<button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
<button type="button" class="navbar-toggle collapsed"
data-toggle="collapse"
data-target="#js-navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>

<a class="navbar-brand" href="#/">botConfig</a>
</div>

<div class="collapse navbar-collapse" id="js-navbar-collapse">

<ul class="nav navbar-nav">
<li ng-class="{ active: isActive('/')}">
<a href="#/">General config</a>
<a href="#/">Auth config</a>
</li>
<li ng-class="{ active: isActive('/general-config')}">
<a href="#/general-config">General config</a>
</li>
<li ng-class="{ active: isActive('/task-config')}">
<a href="#/task-config">Task config</a>
Expand Down Expand Up @@ -83,12 +82,14 @@
</div>
<div ng-view></div>
</div>

<div class="footer">
Made with love and much <a href="https://paypal.me/SanderBrand" target="_blank">coffee</a> by <a
href="https://github.com/brantje" target="_blank">brantje</a>.<br/>
For issues, please refer to the <a href="https://github.com/PokemonGoF/botConfig" target="_blank">Github</a>
</div>
</div>

<script src="//maps.google.com/maps/api/js?key=AIzaSyBDP41ob3NvNKuN7prVMuJnGLc46M-HiVs&libraries=placeses,visualization,drawing,geometry,places"></script>
<!-- build:js(.) scripts/vendor.js -->
<!-- bower:js -->
Expand All @@ -101,16 +102,17 @@
<script src="bower_components/angular-local-storage/dist/angular-local-storage.js"></script>
<script src="bower_components/jquery-ui/jquery-ui.js"></script>
<script src="bower_components/angular-ui-sortable/sortable.js"></script>
<script src="bower_components/ngmap/build/scripts/ng-map.js"></script>
<!-- endbower -->
<!-- endbuild -->

<!-- build:js({.tmp,app}) scripts/scripts.js -->
<script src="scripts/app.js"></script>
<script src="scripts/directives/ng-map.js"></script>
<script src="scripts/controllers/main.js"></script>
<script src="scripts/controllers/auth.js"></script>
<script src="scripts/controllers/general.js"></script>


<script src="scripts/controllers/tasks/transferpokemon.js"></script>
<script src="scripts/controllers/tasks/evolve.js"></script>
<script src="scripts/controllers/tasks/capture.js"></script>
Expand All @@ -120,8 +122,6 @@
<script src="scripts/controllers/tasks/movetofort.js"></script>
<script src="scripts/controllers/tasks/followspiral.js"></script>



<script src="scripts/services/dataservice.js"></script>
<script src="scripts/directives/pokemonselect.js"></script>
<script src="scripts/directives/configtextarea.js"></script>
Expand Down
6 changes: 5 additions & 1 deletion app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ angular
]).config(function($routeProvider, $locationProvider) {
$routeProvider
.when('/', {
templateUrl: './views/auth_config.html',
controller: 'AuthCtrl as vm'
})
.when('/general-config', {
templateUrl: './views/general_config.html',
controller: 'GeneralCtrl'
})
Expand Down Expand Up @@ -52,4 +56,4 @@ angular
});
}).run(function(editableOptions) {
editableOptions.theme = 'bs3';
});
});
85 changes: 85 additions & 0 deletions app/scripts/controllers/auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
(function() {
'use strict';

angular.module('botConfApp')
.controller('AuthCtrl', AuthCtrl);

AuthCtrl.$inject = ['$scope', 'NgMap'];

/**
* @ngdoc function
* @name botConfApp.controller:AuthCtrl
* @description
* # AuthCtrl
* Controller of the botConfApp
*/
function AuthCtrl($scope, NgMap) {
var vm = this;

vm.updateActiveLocationCoords = updateActiveLocationCoords;
vm.updateActiveLocationName = updateActiveLocationName;
vm.setActiveLocation = setActiveLocation;
vm.addLocation = addLocation;
vm.removeLocation = removeLocation;

init();

function init() {
NgMap.getMap().then(function(map) {
vm.map = map;
});
vm.setActiveLocation(0);
}

function updateMap(coords) {
vm.mapLocation = coords;
};

function updateLocation(location) {
$scope.config.location = location;
};

function updateActiveLocationCoords(e) {
var coords;

if (typeof e === 'number') {
if (e === vm.activeLocation) {
coords = $scope.config.favorite_locations[e].coords;
}
} else {
coords = e.latLng.lat() + ',' + e.latLng.lng();
}
$scope.config.favorite_locations[vm.activeLocation].coords = coords;
updateMap(coords);
};

function updateActiveLocationName(i) {
if (i === vm.activeLocation) {
updateLocation($scope.config.favorite_locations[i].name);
}
};

function setActiveLocation(i) {
var location = $scope.config.favorite_locations[i];

vm.activeLocation = i;
updateMap(location.coords);
updateLocation(location.name);
}

function addLocation() {
$scope.config.favorite_locations.push({
"name": "New location",
"coords": "52.39037297896968,4.828920364379883"
});
vm.setActiveLocation($scope.config.favorite_locations.length - 1);
}

function removeLocation(i) {
if ($scope.config.favorite_locations.length > 1) {
$scope.config.favorite_locations.splice(i, 1);
vm.setActiveLocation($scope.config.favorite_locations.length - 1);
}
}
}
})();
33 changes: 9 additions & 24 deletions app/scripts/controllers/general.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,19 @@
(function() {
'use strict';

/**
* @ngdoc function
* @name botConfApp.controller:GeneralctrlCtrl
* @name botConfApp.controller:GeneralCtrl
* @description
* # GeneralctrlCtrl
* # GeneralCtrl
* Controller of the botConfApp
*/
angular.module('botConfApp')
.controller('GeneralCtrl',['$scope', 'NgMap', function ($scope, NgMap) {
$scope.marker = null;
$scope.map_options = {
center: [-117.38061189651489,
33.93955043249883]
};
.controller('GeneralCtrl', GeneralCtrl);

GeneralCtrl.$inject = ['$scope'];

$scope.marker = {};
$scope.placeMarker = function (event) {
$scope.marker = {lat: event.latLng.lat(), lng: event.latLng.lng()};
$scope.setCoords(event);
};

$scope.setCoords = function (event) {
if(event.latLng){
$scope.config.location = event.latLng.lat() + ',' + event.latLng.lng();
}
};

NgMap.getMap().then(function (map) {
$scope.map = map;
});
}]);
function GeneralCtrl($scope) {
var vm = this;
};
})();
125 changes: 125 additions & 0 deletions app/views/auth_config.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<div class="row">
<div class="col-xs-12 col-md-6">
<h4>Auth info</h4>
<table class="table table-responsive">
<tr>
<td>Auth type</td>
<td>
<select ng-model="config.auth_service">
<option value="ptc">PTC</option>
<option value="google">Google</option>
</select>
</td>
</tr>
<tr>
<td>Username</td>
<td>
<input type="text" class="form-control" ng-model="config.username">
</td>
</tr>
<tr>
<td>Password</td>
<td>
<input type="password" class="form-control" ng-model="config.password">
</td>
</tr>
<tr>
<td>Google Maps api key</td>
<td>
<input type="text" class="form-control" ng-model="config.gmapkey">
<small>
Get one
<a href="https://console.developers.google.com/flows/enableapi?apiid=maps_backend,geocoding_backend,directions_backend,distance_matrix_backend,elevation_backend,places_backend&keyType=CLIENT_SIDE&reusekey=true"
target="_blank">
here
</a>
</small>
</td>
</tr>
<tr>
<td>Current start location</td>
<td>
<input type="text"
class="form-control"
disabled
ng-model="config.location">
</td>
</tr>
<tr>
<td>Encrypt location</td>
<td>
<input type="text"
class="form-control"
ng-model="config.encrypt_location">
</td>
</tr>
<tr>
<td>Telegram Token</td>
<td>
<input type="text"
class="form-control"
ng-model="config.telegram_token">
</td>
</tr>
<tr>
<td>Discord Token</td>
<td>
<input type="text"
class="form-control"
ng-model="config.discord_token">
</td>
</tr>
</table>
</div>
<div class="col-xs-12 col-md-6">
<h4>
Favorite locations
<small>
<a class="btn" ng-click="vm.addLocation()">
<span class="glyphicon glyphicon-plus-sign"></span> Add location
</a>
</small>
</h4>
<p>
Click on the map to set your location
</p>
<ng-map zoom="13"
center="{{ vm.mapLocation }}"
on-click="vm.updateActiveLocationCoords(event)">
<marker position="{{ vm.mapLocation }}"
draggable="true"
on-dragend="vm.updateActiveLocationCoords(event)"
animation="Animation.DROP"></marker>
</ng-map>
<table class="table table-responsive table-striped">
<thead>
<td>Active</td>
<td>Name</td>
<td>Location</td>
<td></td>
</thead>
<tr ng-repeat="location in config.favorite_locations">
<td>
<input type="checkbox"
ng-click="vm.setActiveLocation($index)"
ng-checked="$index === vm.activeLocation">
</td>
<td>
<input type="text"
class="form-control"
ng-model="location.name"
ng-change="vm.updateActiveLocationName($index)">
</td>
<td>
<input type="text"
class="form-control"
ng-model="location.coords"
ng-change="vm.updateActiveLocationCoords($index)">
</td>
<td>
<span class="glyphicon glyphicon-minus-sign"
ng-click="vm.removeLocation($index)"></span>
</tr>
</table>
</div>
</div>
Loading