From 5f135408db0ad148c816ef28db7f87538668b670 Mon Sep 17 00:00:00 2001 From: Joachim Date: Thu, 13 Sep 2018 20:20:48 +0200 Subject: [PATCH] Made sure championship visibility can be toggled too. --- .gitignore | 2 + js/controllers/championships.js | 3 + js/services.js | 15 ++++ partials/championship-overview.html | 4 +- partials/championships.html | 122 ++++++++++++++++------------ server/config.php | 4 + server/phpinfo.php | 6 ++ 7 files changed, 102 insertions(+), 54 deletions(-) create mode 100644 .gitignore create mode 100644 server/phpinfo.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c38fa4e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea +*.iml diff --git a/js/controllers/championships.js b/js/controllers/championships.js index 2aabdde..4186f7c 100644 --- a/js/controllers/championships.js +++ b/js/controllers/championships.js @@ -31,6 +31,9 @@ angular.module('bananaraceApp.controllers').controller('ChampionshipsCtrl', ['$s }); }; + $scope.togglePublishResultsForChampionship = function(championship) { + ChampionshipService.togglePublishResultsForChampionship(championship); + } $scope.addChampionship = function(newchampionship) { console.log("adding: "+newchampionship); ChampionshipService.addChampionship(newchampionship). diff --git a/js/services.js b/js/services.js index 9f56b4a..b0aea07 100644 --- a/js/services.js +++ b/js/services.js @@ -21,6 +21,20 @@ appServices.service('ChampionshipService', function ($http) { name: newchampionship.name }); }; + + this.togglePublishResultsForChampionship = function (championship) { + console.log('toggling publish results for championship' + championship.idchampionship); + $http.post('server/config.php', { + action: 'togglePublishResultsForChampionship', + idchampionship: championship.idchampionship + }).success(function (data, status, headers, config) { + if (championship.publishresults === 'f') { + championship.publishresults = 't'; + } else if (championship.publishresults === 't') { + championship.publishresults = 'f'; + } + }); + }; }); appServices.service('PouleService', function ($http) { @@ -357,6 +371,7 @@ appServices.service('MainService', function ($http, $cookies) { }); }; + //load the current config this.refreshConfig(); }); diff --git a/partials/championship-overview.html b/partials/championship-overview.html index 6910389..67515f0 100644 --- a/partials/championship-overview.html +++ b/partials/championship-overview.html @@ -45,7 +45,7 @@
-
@@ -53,7 +53,7 @@
-
diff --git a/partials/championships.html b/partials/championships.html index d51e2f3..ac415ca 100644 --- a/partials/championships.html +++ b/partials/championships.html @@ -1,61 +1,79 @@
-
-
-
-

Voeg kampioenschap toe

-
-
-
- Naam - - +
+
+
+

Voeg kampioenschap toe

+
+
+
+ Naam + + -
-
-
-
-
-
-
-

Kampioenschappen

-
-
- - - - - - -
NaamActies
{{championship.name}} - Bekijk poules - Bekijk teams - Overzicht - -
-
-
-
- +
+
+
+

Kampioenschappen

+
+
+ + + + + + + + + +
NaamActies
{{championship.name}} + Bekijk + poules + Bekijk + teams + Overzicht + + +
+
+
+
+ +
+
+
+
diff --git a/server/config.php b/server/config.php index 570847e..fc13acb 100644 --- a/server/config.php +++ b/server/config.php @@ -19,6 +19,10 @@ if ($action == 'setActiveIdRace') { $idrace = $post['idrace']; $togglepublishresults = pg_prepare($dbconn, "togglepublishresults", "update race set publishresults = not publishresults where idrace = $1"); $togglepublishresults = pg_execute($dbconn, "togglepublishresults", array($idrace)); +} else if ($action == 'togglePublishResultsForChampionship') { + $idchampionship = $post['idchampionship']; + $togglepublishresults = pg_prepare($dbconn, "togglepublishresults", "update championship set publishresults = not publishresults where idchampionship = $1"); + $togglepublishresults = pg_execute($dbconn, "togglepublishresults", array($idchampionship)); } else if ($action == 'getConfig') { $getconfig = pg_prepare($dbconn, "getconfig", "select activerace activeidrace, tier, poule, idchampionship from config inner join race on activerace = idrace"); $getconfig = pg_execute($dbconn, "getconfig", array()); diff --git a/server/phpinfo.php b/server/phpinfo.php new file mode 100644 index 0000000..a4d275d --- /dev/null +++ b/server/phpinfo.php @@ -0,0 +1,6 @@ +