-
Notifications
You must be signed in to change notification settings - Fork 987
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Application now ignores settings for storage & API-Key in config.groo…
…vy. These values can now be adjusted in the user-interface. If the values are empty at first, the user gehts redirected to the settings page when trying to access the dashboard.
- Loading branch information
dularion
committed
Jul 31, 2015
1 parent
3cdf99b
commit 68cf2fb
Showing
21 changed files
with
350 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
grails-app/assets/javascripts/controllers/admin-settings-ctrl.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
'use strict'; | ||
|
||
streamaApp.controller('adminSettingsCtrl', ['$scope', 'apiService', '$sce', function ($scope, apiService, $sce) { | ||
|
||
$scope.loading = true; | ||
|
||
apiService.settings.list().success(function (data) { | ||
$scope.settings = data; | ||
|
||
_.forEach(data, function (setting) { | ||
setting.description = $sce.trustAsHtml(Autolinker.link(setting.description, { newWindow: "true" } )); | ||
}); | ||
$scope.loading = false; | ||
}); | ||
|
||
$scope.updateMultipleSettings = function (settings) { | ||
settings.invalid = false; | ||
|
||
apiService.settings.updateMultiple(settings) | ||
.success(function () { | ||
window.location.reload(); | ||
}) | ||
.error(function () { | ||
alertify.error('There was an error saving your settings. Please refer to the server-log.'); | ||
}); | ||
}; | ||
|
||
|
||
$scope.validateSettings = function (settings) { | ||
$scope.changeValue(settings); | ||
$scope.loading = true; | ||
|
||
apiService.settings.validateSettings(settings) | ||
.success(function (data) { | ||
alertify.success(data.message); | ||
settings.valid = true; | ||
$scope.loading = false; | ||
}) | ||
.error(function (data) { | ||
alertify.error(data.message); | ||
settings.invalid = true; | ||
$scope.loading = false; | ||
}); | ||
}; | ||
|
||
$scope.changeValue = function (settings) { | ||
settings.valid = undefined; | ||
settings.invalid = undefined; | ||
settings.dirty = settings.value; | ||
}; | ||
|
||
|
||
$scope.anySettingsInvalid = function () { | ||
return _.find($scope.settings, function (setting) { | ||
return setting.invalid || (setting.dirty && !setting.valid) || !setting.value; | ||
}); | ||
}; | ||
|
||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,28 @@ | ||
'use strict'; | ||
|
||
streamaApp.controller('dashCtrl', ['$scope', 'apiService', function ($scope, apiService) { | ||
streamaApp.controller('dashCtrl', ['$scope', 'apiService', '$state', function ($scope, apiService, $state) { | ||
$scope.loading = true; | ||
|
||
apiService.video.dash() | ||
.success(function (data) { | ||
$scope.episodes = data.firstEpisodes; | ||
$scope.continueWatching = data.continueWatching; | ||
$scope.movies = data.movies; | ||
$scope.loading = false; | ||
}) | ||
.error(function () { | ||
alertify('A server error occured.'); | ||
$scope.loading = false; | ||
}); | ||
|
||
}]); | ||
apiService.settings.list().success(function (data) { | ||
var TheMovieDbAPI = _.find(data, {settingsKey: 'TheMovieDB API key'}); | ||
|
||
if(!TheMovieDbAPI.value){ | ||
alertify.alert('You need to fill out some required base-settings. You will be redirected to the settings page now.', function () { | ||
$state.go('admin.settings'); | ||
}); | ||
}else{ | ||
apiService.video.dash() | ||
.success(function (data) { | ||
$scope.episodes = data.firstEpisodes; | ||
$scope.continueWatching = data.continueWatching; | ||
$scope.movies = data.movies; | ||
$scope.loading = false; | ||
}) | ||
.error(function () { | ||
alertify('A server error occured.'); | ||
$scope.loading = false; | ||
}); | ||
} | ||
}); | ||
|
||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
grails-app/assets/javascripts/streama-app/templates/admin-settings.tpl.htm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<h1> | ||
Settings | ||
|
||
<div class="spinner" ng-show="loading"> | ||
<div class="bounce1"></div> | ||
<div class="bounce2"></div> | ||
<div class="bounce3"></div> | ||
</div> | ||
</h1> | ||
|
||
|
||
|
||
<hr/> | ||
|
||
<form name="settings-form" class="settings-form"> | ||
<div class="form-group row-slim" ng-repeat="setting in settings"> | ||
<div class="col-sm-3"> | ||
<label class="control-label">{{setting.settingsKey}}</label> | ||
</div> | ||
<div class="col-sm-7" ng-class="{'has-error has-feedback': setting.invalid, 'has-success has-feedback': setting.valid}"> | ||
<input required type="text" class="form-control" ng-model="setting.value" placeholder="{{setting.settingsKey}}" ng-change="changeValue(setting)"> | ||
|
||
<span class="glyphicon ion-close form-control-feedback" ng-show="setting.invalid" aria-hidden="true"></span> | ||
<span class="glyphicon ion-checkmark form-control-feedback" ng-show="setting.valid" aria-hidden="true"></span> | ||
|
||
</div> | ||
<div class="col-sm-2"> | ||
<button type="button" class="btn btn-success btn-block" ng-click="validateSettings(setting)" ng-show="!setting.valid && setting.dirty">validate</button> | ||
</div> | ||
<div class="col-sm-7 col-sm-offset-3"> | ||
<p class="settings-description" ng-bind-html="setting.description"></p> | ||
</div> | ||
</div> | ||
</form> | ||
|
||
|
||
<hr/> | ||
|
||
<button class="btn btn-primary" ng-click="updateMultipleSettings(settings)" ng-disabled="anySettingsInvalid()">Save Settings</button> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.settings-form{ | ||
@include clearfix; | ||
|
||
.settings-description{ | ||
margin-top: 7px; | ||
opacity: 0.8; | ||
margin-bottom: 30px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ | |
@import "player-controls"; | ||
@import "invite"; | ||
@import "modal"; | ||
@import "settings"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ class UrlMappings { | |
} | ||
|
||
"/"(view:"/index") | ||
"/setSettings"(view:'/setSettings') | ||
|
||
"500"(view:'/error') | ||
} | ||
} |
Oops, something went wrong.