From 0f141dee4e486d9b99935ea30e52c455060d190c Mon Sep 17 00:00:00 2001 From: Maximbndrnk Date: Wed, 7 Nov 2018 09:52:47 +0200 Subject: [PATCH 01/47] add basic files and adjustments to proj regarding the task --- .../streama/controllers/profile-ctrl.js | 21 ++++++++++++++++++ .../streama/services/api-service.js | 10 ++++++++- .../streama/ProfileController.groovy | 22 +++++++++++++++++++ grails-app/domain/streama/Profile.groovy | 13 +++++++++++ grails-app/domain/streama/User.groovy | 2 +- .../domain/streama/ViewingStatus.groovy | 1 + .../streama/ProfileControllerSpec.groovy | 22 +++++++++++++++++++ src/test/groovy/streama/ProfileSpec.groovy | 22 +++++++++++++++++++ 8 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 grails-app/controllers/streama/ProfileController.groovy create mode 100644 grails-app/domain/streama/Profile.groovy create mode 100644 src/test/groovy/streama/ProfileControllerSpec.groovy create mode 100644 src/test/groovy/streama/ProfileSpec.groovy diff --git a/grails-app/assets/javascripts/streama/controllers/profile-ctrl.js b/grails-app/assets/javascripts/streama/controllers/profile-ctrl.js index c1b563a03..c8b3f4056 100644 --- a/grails-app/assets/javascripts/streama/controllers/profile-ctrl.js +++ b/grails-app/assets/javascripts/streama/controllers/profile-ctrl.js @@ -65,4 +65,25 @@ angular.module('streama').controller('profileCtrl', function ($scope, apiService }); }; + $scope.addNewSubProfile = function() { + var sub = { + profile_name: 'sub1', + profile_language: 'ENG', + isKid: true + }; + + apiService.profile.save(sub) + .success(function () { + console.log('Succss func'); + alertify.success('Succss func.'); + $scope.loading = false; + + }) + .error(function (data) { + alertify.error(data.message); + $scope.loading = false; + }); + + } + }); diff --git a/grails-app/assets/javascripts/streama/services/api-service.js b/grails-app/assets/javascripts/streama/services/api-service.js index b64f44678..017d60b23 100644 --- a/grails-app/assets/javascripts/streama/services/api-service.js +++ b/grails-app/assets/javascripts/streama/services/api-service.js @@ -336,6 +336,14 @@ angular.module('streama').factory('apiService', function ($http, $rootScope, con triggerPlayerAction: function (params) { return $http.get('websocket/triggerPlayerAction.json', {params: params}); } - } + }, + + profile: { + save: function (params) { + console.log('api-serv'); + return $http.post('profile/save', params) + } + } + }; }); diff --git a/grails-app/controllers/streama/ProfileController.groovy b/grails-app/controllers/streama/ProfileController.groovy new file mode 100644 index 000000000..a86e9b488 --- /dev/null +++ b/grails-app/controllers/streama/ProfileController.groovy @@ -0,0 +1,22 @@ +package streama + +import grails.plugin.springsecurity.annotation.Secured +import grails.rest.* +import grails.converters.* + +import static org.springframework.http.HttpStatus.* +@Secured(['IS_AUTHENTICATED_REMEMBERED']) +class ProfileController { + static responseFormats = ['json', 'xml'] + + static allowedMethods = [save: "POST", delete: "DELETE"] + + def index() { } + + def save(Profile profileInstance) { + System.out.println('Save Subprofile') + System.out.println(profileInstance) + profileInstance.save() + respond profileInstance, [status: CREATED] + } +} diff --git a/grails-app/domain/streama/Profile.groovy b/grails-app/domain/streama/Profile.groovy new file mode 100644 index 000000000..5f838e3ec --- /dev/null +++ b/grails-app/domain/streama/Profile.groovy @@ -0,0 +1,13 @@ +package streama + +class Profile { + + String profile_name + String profile_language + Boolean isKid + + static belongsTo = [user: User] + + static constraints = { + } +} diff --git a/grails-app/domain/streama/User.groovy b/grails-app/domain/streama/User.groovy index 39ef9c5bf..1e3f44c9e 100644 --- a/grails-app/domain/streama/User.groovy +++ b/grails-app/domain/streama/User.groovy @@ -27,7 +27,7 @@ class User { static transients = ['springSecurityService'] - static hasMany = [favoriteGenres: Genre] + static hasMany = [favoriteGenres: Genre, profiles: Profile] static constraints = { username blank: false, unique: true diff --git a/grails-app/domain/streama/ViewingStatus.groovy b/grails-app/domain/streama/ViewingStatus.groovy index 11b1902b1..0fa487804 100644 --- a/grails-app/domain/streama/ViewingStatus.groovy +++ b/grails-app/domain/streama/ViewingStatus.groovy @@ -14,6 +14,7 @@ class ViewingStatus { Integer currentPlayTime Integer runtime Boolean completed = false + Profile profile static mapping = { cache true diff --git a/src/test/groovy/streama/ProfileControllerSpec.groovy b/src/test/groovy/streama/ProfileControllerSpec.groovy new file mode 100644 index 000000000..21b8930e9 --- /dev/null +++ b/src/test/groovy/streama/ProfileControllerSpec.groovy @@ -0,0 +1,22 @@ +package streama + +import grails.test.mixin.TestFor +import spock.lang.Specification + +/** + * See the API for {@link grails.test.mixin.web.ControllerUnitTestMixin} for usage instructions + */ +@TestFor(ProfileController) +class ProfileControllerSpec extends Specification { + + def setup() { + } + + def cleanup() { + } + + void "test something"() { + expect:"fix me" + true == false + } +} diff --git a/src/test/groovy/streama/ProfileSpec.groovy b/src/test/groovy/streama/ProfileSpec.groovy new file mode 100644 index 000000000..9781f40e1 --- /dev/null +++ b/src/test/groovy/streama/ProfileSpec.groovy @@ -0,0 +1,22 @@ +package streama + +import grails.test.mixin.TestFor +import spock.lang.Specification + +/** + * See the API for {@link grails.test.mixin.domain.DomainClassUnitTestMixin} for usage instructions + */ +@TestFor(Profile) +class ProfileSpec extends Specification { + + def setup() { + } + + def cleanup() { + } + + void "test something"() { + expect:"fix me" + true == false + } +} From c40b16ec29ecbd47a5591dd589c43168615f8e28 Mon Sep 17 00:00:00 2001 From: Maximbndrnk Date: Wed, 7 Nov 2018 11:04:20 +0200 Subject: [PATCH 02/47] add user id to profile table, delete some logs --- .../assets/javascripts/streama/services/api-service.js | 1 - grails-app/controllers/streama/ProfileController.groovy | 7 ++++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/grails-app/assets/javascripts/streama/services/api-service.js b/grails-app/assets/javascripts/streama/services/api-service.js index 017d60b23..a236bceac 100644 --- a/grails-app/assets/javascripts/streama/services/api-service.js +++ b/grails-app/assets/javascripts/streama/services/api-service.js @@ -340,7 +340,6 @@ angular.module('streama').factory('apiService', function ($http, $rootScope, con profile: { save: function (params) { - console.log('api-serv'); return $http.post('profile/save', params) } } diff --git a/grails-app/controllers/streama/ProfileController.groovy b/grails-app/controllers/streama/ProfileController.groovy index a86e9b488..7304df8e4 100644 --- a/grails-app/controllers/streama/ProfileController.groovy +++ b/grails-app/controllers/streama/ProfileController.groovy @@ -10,12 +10,13 @@ class ProfileController { static responseFormats = ['json', 'xml'] static allowedMethods = [save: "POST", delete: "DELETE"] - + + def springSecurityService + def index() { } def save(Profile profileInstance) { - System.out.println('Save Subprofile') - System.out.println(profileInstance) + profileInstance.user = springSecurityService.getCurrentUser() profileInstance.save() respond profileInstance, [status: CREATED] } From dd004c0f3e9520c96e6903011a35cc27d212e423 Mon Sep 17 00:00:00 2001 From: Maximbndrnk Date: Wed, 7 Nov 2018 12:40:53 +0200 Subject: [PATCH 03/47] add get all profiles endpoint to api --- .../assets/javascripts/streama/services/api-service.js | 3 +++ grails-app/controllers/streama/ProfileController.groovy | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/grails-app/assets/javascripts/streama/services/api-service.js b/grails-app/assets/javascripts/streama/services/api-service.js index a236bceac..ba5228b9b 100644 --- a/grails-app/assets/javascripts/streama/services/api-service.js +++ b/grails-app/assets/javascripts/streama/services/api-service.js @@ -341,6 +341,9 @@ angular.module('streama').factory('apiService', function ($http, $rootScope, con profile: { save: function (params) { return $http.post('profile/save', params) + }, + getUserProfiles: function () { + return $http.get('profile/getUserProfiles.json') } } diff --git a/grails-app/controllers/streama/ProfileController.groovy b/grails-app/controllers/streama/ProfileController.groovy index 7304df8e4..d2ecf766c 100644 --- a/grails-app/controllers/streama/ProfileController.groovy +++ b/grails-app/controllers/streama/ProfileController.groovy @@ -9,7 +9,7 @@ import static org.springframework.http.HttpStatus.* class ProfileController { static responseFormats = ['json', 'xml'] - static allowedMethods = [save: "POST", delete: "DELETE"] + static allowedMethods = [save: "POST", delete: "DELETE", getUserProfiles: "GET"] def springSecurityService @@ -20,4 +20,9 @@ class ProfileController { profileInstance.save() respond profileInstance, [status: CREATED] } + + def getUserProfiles() { + def result = Profile.findAllByUser(springSecurityService.getCurrentUser()) + respond(result, [status: OK]) + } } From 99d3c3f045a0753e5dae9f38dd89d39419992a96 Mon Sep 17 00:00:00 2001 From: Maximbndrnk Date: Wed, 7 Nov 2018 14:17:24 +0200 Subject: [PATCH 04/47] add markup for creating profile --- .../streama/templates/profile.tpl.htm | 36 +++++++++++++++++-- .../javascripts/streama/translations/EN_us.js | 2 +- grails-app/assets/stylesheets/_btn.scss | 5 +++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/grails-app/assets/javascripts/streama/templates/profile.tpl.htm b/grails-app/assets/javascripts/streama/templates/profile.tpl.htm index d951f43af..28aeae1b3 100644 --- a/grails-app/assets/javascripts/streama/templates/profile.tpl.htm +++ b/grails-app/assets/javascripts/streama/templates/profile.tpl.htm @@ -1,7 +1,9 @@
- + +

@@ -79,13 +81,43 @@

+ +
+ - +
+

Create new profile

+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
diff --git a/grails-app/assets/javascripts/streama/translations/EN_us.js b/grails-app/assets/javascripts/streama/translations/EN_us.js index f12cc15ac..5b40efdb4 100644 --- a/grails-app/assets/javascripts/streama/translations/EN_us.js +++ b/grails-app/assets/javascripts/streama/translations/EN_us.js @@ -53,7 +53,7 @@ angular.module('streama.translations').config(function ($translateProvider) { ADMIN: 'Admin', HELP: 'Help', HELP_FAQ: 'HELP / FAQ', - PROFILE_SETTINGS: 'Profile Settings', + PROFILE_SETTINGS: 'User Settings', LOGOUT: 'Logout', CHANGE_PASSWORD: 'Change Password', LANGUAGE_en: 'English', diff --git a/grails-app/assets/stylesheets/_btn.scss b/grails-app/assets/stylesheets/_btn.scss index 21a603643..c1dec1be3 100644 --- a/grails-app/assets/stylesheets/_btn.scss +++ b/grails-app/assets/stylesheets/_btn.scss @@ -117,3 +117,8 @@ .color-danger{ color: $danger; } + + +.margin-bottom-for-btn { + margin-bottom: 10px; +} From 32b422a19754e7598e38d20adfac073d7b3061fe Mon Sep 17 00:00:00 2001 From: Maximbndrnk Date: Wed, 7 Nov 2018 15:09:38 +0200 Subject: [PATCH 05/47] add markup to view all subprofiles --- .../streama/templates/profile.tpl.htm | 24 +++++++++++++- grails-app/assets/stylesheets/_profile.scss | 33 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/grails-app/assets/javascripts/streama/templates/profile.tpl.htm b/grails-app/assets/javascripts/streama/templates/profile.tpl.htm index 28aeae1b3..8a73e69c0 100644 --- a/grails-app/assets/javascripts/streama/templates/profile.tpl.htm +++ b/grails-app/assets/javascripts/streama/templates/profile.tpl.htm @@ -2,7 +2,7 @@
+ ng-if="!changePasswordIsActive">Create new profile

@@ -87,6 +87,28 @@

+
+

Available profiles

+ + + + + + + + + + + + + + + + + +
Profile Name
Is Kid
Language
Edit
{{subp.profile_name}}
{{subp.isKid ? 'Yes' : 'No'}}
{{subp.profile_language}}
+
+

Create new profile

diff --git a/grails-app/assets/stylesheets/_profile.scss b/grails-app/assets/stylesheets/_profile.scss index 46e8bfde2..a497d1089 100644 --- a/grails-app/assets/stylesheets/_profile.scss +++ b/grails-app/assets/stylesheets/_profile.scss @@ -45,4 +45,37 @@ } +.subprofiles-table { + width: 100%; + thead { + border-bottom: 1px solid white; + } + + tr{ + height: 30px; + } + + td,th{ + min-width: 25%; + max-width: 25%; + div { + display: flex; + justify-content: center; + width: 100%; + + button { + height: 25px; + padding: 0 10px; + } + } + + padding: 3px 0; + } + + tbody { + tr:hover { + background-color: #6a6a6a; + } + } +} From c27c688ee86d9978e032d2373d67411809b29bab Mon Sep 17 00:00:00 2001 From: Maximbndrnk Date: Wed, 7 Nov 2018 16:39:46 +0200 Subject: [PATCH 06/47] add edit profile feature --- .../streama/controllers/profile-ctrl.js | 70 +++++++++++---- .../streama/services/api-service.js | 6 ++ .../streama/templates/profile.tpl.htm | 2 +- .../streama/ProfileController.groovy | 85 +++++++++++++++---- 4 files changed, 130 insertions(+), 33 deletions(-) diff --git a/grails-app/assets/javascripts/streama/controllers/profile-ctrl.js b/grails-app/assets/javascripts/streama/controllers/profile-ctrl.js index c8b3f4056..68222a7ac 100644 --- a/grails-app/assets/javascripts/streama/controllers/profile-ctrl.js +++ b/grails-app/assets/javascripts/streama/controllers/profile-ctrl.js @@ -6,16 +6,26 @@ angular.module('streama').controller('profileCtrl', function ($scope, apiService $scope.passwordData = {}; $scope.passwordsInvalid = true; $scope.languages = true; - - + $scope.profile = { + profile_name: '', + profile_language: 'en', + isKid: false + }; + $scope.existingProfiles = []; + $scope.isCreatingNewProfile = false; + apiService.profile.getUserProfiles() + .success(function (data) { + $scope.existingProfiles = data; + console.log('Profiles list:', $scope.existingProfiles); + }); apiService.theMovieDb.availableGenres().success(function (data) { $scope.availableGenres = data; $scope.loading = false; }); $scope.toggleSelectGenre = function (genre) { - $scope.user.favoriteGenres = _.xorBy($scope.user.favoriteGenres, [genre], 'apiId'); - $scope.profileForm.$setDirty(); + $scope.user.favoriteGenres = _.xorBy($scope.user.favoriteGenres, [genre], 'apiId'); + $scope.profileForm.$setDirty(); }; $scope.isGenreSelected = function (genre) { @@ -41,9 +51,9 @@ angular.module('streama').controller('profileCtrl', function ($scope, apiService }; $scope.validatePasswords = function () { - if($scope.passwordData.newPassword != $scope.passwordData.repeatPassword || $scope.passwordData.newPassword.length < 6){ + if ($scope.passwordData.newPassword != $scope.passwordData.repeatPassword || $scope.passwordData.newPassword.length < 6) { $scope.passwordsInvalid = true; - }else{ + } else { $scope.passwordsInvalid = false; } }; @@ -65,25 +75,55 @@ angular.module('streama').controller('profileCtrl', function ($scope, apiService }); }; - $scope.addNewSubProfile = function() { - var sub = { - profile_name: 'sub1', - profile_language: 'ENG', - isKid: true - }; + $scope.toggleCreateSubProfile = function () { + $scope.isCreatingNewProfile = !$scope.isCreatingNewProfile; + }; - apiService.profile.save(sub) + $scope.addNewSubProfile = function () { + if (!$scope.profile.profile_name) { + return; + } + if ($scope.profile.id) { + apiService.profile.update($scope.profile) + .success(function () { + alertify.success('Profile Updated!'); + $scope.getAllProfiles(); + $scope.loading = false; + $scope.isCreatingNewProfile = false; + }) + .error(function (data) { + alertify.error(data.message); + $scope.loading = false; + }); + return; + } + apiService.profile.save($scope.profile) .success(function () { - console.log('Succss func'); - alertify.success('Succss func.'); + alertify.success('Profile created!'); + $scope.getAllProfiles(); + $scope.loading = false; + $scope.isCreatingNewProfile = false; + }) + .error(function (data) { + alertify.error(data.message); $scope.loading = false; + }); + }; + $scope.getAllProfiles = function () { + apiService.profile.getUserProfiles() + .success(function (data) { + $scope.existingProfiles = data; }) .error(function (data) { alertify.error(data.message); $scope.loading = false; }); + }; + $scope.editSubProfile = function (profile) { + $scope.profile = profile; + $scope.toggleCreateSubProfile(); } }); diff --git a/grails-app/assets/javascripts/streama/services/api-service.js b/grails-app/assets/javascripts/streama/services/api-service.js index ba5228b9b..ea7f0d541 100644 --- a/grails-app/assets/javascripts/streama/services/api-service.js +++ b/grails-app/assets/javascripts/streama/services/api-service.js @@ -341,6 +341,12 @@ angular.module('streama').factory('apiService', function ($http, $rootScope, con profile: { save: function (params) { return $http.post('profile/save', params) + }, + update: function (params) { + return $http.put('profile/update.json', params) + }, + delete: function (params) { + return $http.delete('profile/delete.json', params) }, getUserProfiles: function () { return $http.get('profile/getUserProfiles.json') diff --git a/grails-app/assets/javascripts/streama/templates/profile.tpl.htm b/grails-app/assets/javascripts/streama/templates/profile.tpl.htm index 8a73e69c0..25209481b 100644 --- a/grails-app/assets/javascripts/streama/templates/profile.tpl.htm +++ b/grails-app/assets/javascripts/streama/templates/profile.tpl.htm @@ -139,7 +139,7 @@

Create new profile

- + diff --git a/grails-app/controllers/streama/ProfileController.groovy b/grails-app/controllers/streama/ProfileController.groovy index d2ecf766c..5fc08590c 100644 --- a/grails-app/controllers/streama/ProfileController.groovy +++ b/grails-app/controllers/streama/ProfileController.groovy @@ -1,28 +1,79 @@ package streama - import grails.plugin.springsecurity.annotation.Secured -import grails.rest.* -import grails.converters.* - import static org.springframework.http.HttpStatus.* +import grails.transaction.Transactional @Secured(['IS_AUTHENTICATED_REMEMBERED']) +@Transactional(readOnly = true) class ProfileController { - static responseFormats = ['json', 'xml'] - static allowedMethods = [save: "POST", delete: "DELETE", getUserProfiles: "GET"] + static responseFormats = ['json', 'xml'] + static allowedMethods = [save: "POST", update: "PUT", delete: "DELETE"] + def springSecurityService + + def index(Integer max) { + params.max = Math.min(max ?: 10, 100) + respond Profile.list(params), model:[profileCount: Profile.count()] + } + + def show(Profile profile) { + respond profile + } + + @Transactional + def save(Profile profile) { + if (profile == null) { + transactionStatus.setRollbackOnly() + render status: NOT_FOUND + return + } + + if (profile.hasErrors()) { + transactionStatus.setRollbackOnly() + respond profile.errors, view:'create' + return + } + + profile.save flush:true + + respond profile, [status: CREATED, view:"show"] + } + + @Transactional + def update(Profile profile) { + if (profile == null) { + transactionStatus.setRollbackOnly() + render status: NOT_FOUND + return + } + + if (profile.hasErrors()) { + transactionStatus.setRollbackOnly() + respond profile.errors, view:'edit' + return + } + + profile.save flush:true + + respond profile, [status: OK, view:"show"] + } + + @Transactional + def delete(Profile profile) { - def springSecurityService + if (profile == null) { + transactionStatus.setRollbackOnly() + render status: NOT_FOUND + return + } - def index() { } + profile.delete flush:true - def save(Profile profileInstance) { - profileInstance.user = springSecurityService.getCurrentUser() - profileInstance.save() - respond profileInstance, [status: CREATED] - } + render status: NO_CONTENT + } - def getUserProfiles() { - def result = Profile.findAllByUser(springSecurityService.getCurrentUser()) - respond(result, [status: OK]) - } + @Transactional + def getUserProfiles() { + def result = Profile.findAllByUser(springSecurityService.getCurrentUser()) + respond(result, [status: OK]) + } } From d548753ce8aaf6b3db36e7a8059f073697fb34e5 Mon Sep 17 00:00:00 2001 From: Maximbndrnk Date: Wed, 7 Nov 2018 16:41:22 +0200 Subject: [PATCH 07/47] add color helper class to proj --- src/main/groovy/streama/ColorHelper.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/main/groovy/streama/ColorHelper.java diff --git a/src/main/groovy/streama/ColorHelper.java b/src/main/groovy/streama/ColorHelper.java new file mode 100644 index 000000000..38a5077f2 --- /dev/null +++ b/src/main/groovy/streama/ColorHelper.java @@ -0,0 +1,19 @@ +package streama; +import java.awt.Color; +import java.util.Random; + +class ColorHelper { + + private final static String toHexString(Color colour) throws NullPointerException { + String hexColour = Integer.toHexString(colour.getRGB() & 0xffffff); + if (hexColour.length() < 6) { + hexColour = "000000".substring(0, 6 - hexColour.length()) + hexColour; + } + return "#" + hexColour; + } + + public static String generateHexColorDarker() { + Color color = Color.getHSBColor(new Random().nextFloat(), new Random().nextFloat(), new Random().nextFloat()); + return toHexString(color.darker()); + } +} From bcb522a30730e6874e78031145098f66e9bd5d83 Mon Sep 17 00:00:00 2001 From: Maximbndrnk Date: Thu, 8 Nov 2018 09:29:59 +0200 Subject: [PATCH 08/47] add new page and files for manage subprofiles --- .../streama/controllers/subProfiles-ctrl.js | 20 +++++++++++++++++++ .../javascripts/streama/streama.routes.js | 5 +++++ .../streama/templates/sub-profiles.tpl.htm | 3 +++ .../assets/stylesheets/_subprofiles.scss | 0 grails-app/assets/stylesheets/style.scss | 1 + grails-app/views/templates/_header.gsp | 1 + 6 files changed, 30 insertions(+) create mode 100644 grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js create mode 100644 grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm create mode 100644 grails-app/assets/stylesheets/_subprofiles.scss diff --git a/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js b/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js new file mode 100644 index 000000000..a045bedde --- /dev/null +++ b/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js @@ -0,0 +1,20 @@ +'use strict'; + +angular.module('streama').controller('subProfilesCtrl', + function ($scope, apiService, $rootScope, userService) { + + $scope.profile = { + profile_name: '', + profile_language: 'en', + isKid: false + }; + $scope.existingProfiles = []; + $scope.loading = true; + + apiService.profile.getUserProfiles() + .success(function (data) { + $scope.existingProfiles = data; + console.log('Profiles list:', $scope.existingProfiles); + }); + + }); diff --git a/grails-app/assets/javascripts/streama/streama.routes.js b/grails-app/assets/javascripts/streama/streama.routes.js index 3e6f06a35..dc4ade5c2 100644 --- a/grails-app/assets/javascripts/streama/streama.routes.js +++ b/grails-app/assets/javascripts/streama/streama.routes.js @@ -24,6 +24,11 @@ angular.module('streama').config(function ($stateProvider) { currentUser: resolveCurrentUser } }) + .state('sub-profiles', { + url: '/sub-profiles', + templateUrl: '/streama/sub-profiles.htm', + controller: 'subProfilesCtrl' + }) .state('profile', { url: '/profile', diff --git a/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm b/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm new file mode 100644 index 000000000..afea7e68a --- /dev/null +++ b/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm @@ -0,0 +1,3 @@ +
+ Hello! +
diff --git a/grails-app/assets/stylesheets/_subprofiles.scss b/grails-app/assets/stylesheets/_subprofiles.scss new file mode 100644 index 000000000..e69de29bb diff --git a/grails-app/assets/stylesheets/style.scss b/grails-app/assets/stylesheets/style.scss index c00d21871..e592480db 100644 --- a/grails-app/assets/stylesheets/style.scss +++ b/grails-app/assets/stylesheets/style.scss @@ -21,3 +21,4 @@ @import "genre"; @import "media"; +@import "subprofiles"; diff --git a/grails-app/views/templates/_header.gsp b/grails-app/views/templates/_header.gsp index e18b0e5ea..6c9bc8edd 100644 --- a/grails-app/views/templates/_header.gsp +++ b/grails-app/views/templates/_header.gsp @@ -67,6 +67,7 @@ uib-dropdown-menu role="menu" aria-labelledby="single-button">
  • {{'HELP_FAQ' | translate}}
  • {{'PROFILE_SETTINGS' | translate}}
  • +
  • Manage profiles
  • {{'LOGOUT' | translate}}
  • From 7790cd4e927c75c8687f32ea1a529eb7bfe8bc82 Mon Sep 17 00:00:00 2001 From: Maximbndrnk Date: Thu, 8 Nov 2018 12:55:00 +0200 Subject: [PATCH 09/47] add new basic markup for subprofiles page --- .../assets/images/streama-profile-smiley.png | Bin 0 -> 6955 bytes .../streama/controllers/subProfiles-ctrl.js | 16 ++ .../streama/templates/sub-profiles.tpl.htm | 63 ++++++- .../assets/stylesheets/_subprofiles.scss | 177 ++++++++++++++++++ 4 files changed, 254 insertions(+), 2 deletions(-) create mode 100644 grails-app/assets/images/streama-profile-smiley.png diff --git a/grails-app/assets/images/streama-profile-smiley.png b/grails-app/assets/images/streama-profile-smiley.png new file mode 100644 index 0000000000000000000000000000000000000000..10009496d513d0b6de2d1423c99f76dad75fe1d7 GIT binary patch literal 6955 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 I%`W0U09(?YuK)l5 literal 0 HcmV?d00001 diff --git a/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js b/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js index a045bedde..78206a2a7 100644 --- a/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js +++ b/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js @@ -8,8 +8,11 @@ angular.module('streama').controller('subProfilesCtrl', profile_language: 'en', isKid: false }; + $scope.mycolor = '002300'; $scope.existingProfiles = []; $scope.loading = true; + $scope.isManageProfiles = true; + $scope.isEditOrCreateProfile = false; apiService.profile.getUserProfiles() .success(function (data) { @@ -17,4 +20,17 @@ angular.module('streama').controller('subProfilesCtrl', console.log('Profiles list:', $scope.existingProfiles); }); + + $scope.toggleManageProfiles = function(){ + $scope.isManageProfiles = !$scope.isManageProfiles; + }; + + $scope.editProfile = function(profile){ + $scope.isEditOrCreateProfile = !$scope.isEditOrCreateProfile; + + }; + + $scope.createProfile = function(){ + $scope.isEditOrCreateProfile = !$scope.isEditOrCreateProfile; + }; }); diff --git a/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm b/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm index afea7e68a..3d5e0213c 100644 --- a/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm +++ b/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm @@ -1,3 +1,62 @@ -
    - Hello! +
    +
    +

    Who's watching?

    + +
    + +
    +
    + +
    +

    {{subp.profile_name}}

    +
    + +
    +
    +

    +

    +
    +

    Add Profile

    +
    + +
    + + +
    + + +
    +

    Manage profiles:

    + +
    + +
    +
    + +
    +
    +

    Edit

    +

    {{subp.profile_name}}

    +
    + +
    +
    +

    +

    +
    +

    Add Profile

    +
    + +
    + + +
    + + + +
    + + + + +
    +
    diff --git a/grails-app/assets/stylesheets/_subprofiles.scss b/grails-app/assets/stylesheets/_subprofiles.scss index e69de29bb..85807d772 100644 --- a/grails-app/assets/stylesheets/_subprofiles.scss +++ b/grails-app/assets/stylesheets/_subprofiles.scss @@ -0,0 +1,177 @@ +$grey-text: #a6a6a6; +$light-gray: lighten($grey-text, 40%); +$avatar-width: 130px; +$background-color: #25292B; + +.sub-profile-page-container { + width: 100%; + height: calc(100vh - 84px); + display: flex; + align-items: center; + justify-content: center; +} + +.profiles-container { + max-width: 62%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +} + +.who-watching-header { + font-size: 32px; + color: white; +} + +.manage-profiles-btn { + text-transform: uppercase; + color: $grey-text; + border: 1px solid $grey-text; + height: 40px; + font-size: 15px; + letter-spacing: 1.5px; + background-color: transparent; + + &:hover { + color: $light-gray; + border: 1px solid $light-gray; + cursor: pointer; + } + +} + +.done-btn { + @extend .manage-profiles-btn; + color: $background-color; + background-color: white; + font-weight: bold; + + &:hover { + background-color: #2898c5; + border: 1px solid #2898c5; + color: $background-color; + } +} + +.select-profile-container { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: center; + margin: 10px 0; +} + +.item-profile-container { + width: $avatar-width; + display: flex; + flex-direction: column; + margin: 0 5px; + + .avatar { + box-sizing: border-box; + min-width: 100%; + border: 3px solid transparent; + display: flex; + align-items: center; + justify-content: center; + height: $avatar-width; + img { + z-index: 100; + width: $avatar-width; + } + + p.add { + font-size: 40px; + font-weight: 600; + } + } + + + + .profile-name { + margin-top: 10px; + color: $grey-text; + font-size: 13px; + min-width: 100%; + text-align: center; + } + + &:hover { + cursor: pointer; + .avatar { + border: 3px solid $light-gray; + } + + .profile-name { + color: $light-gray; + } + + } +} + +.add-profile { + @extend .item-profile-container; + &:hover{ + .avatar { + background-color: $light-gray !important; + p.add{ + color: $background-color !important; + } + } + + } +} + + +.item-editable-container { + @extend .item-profile-container; + position: relative; + + &:hover { + .grey-editable-avatar { + border: 3px solid $light-gray; + opacity: .8; + } + + .edit-label-container { + p { + display: flex; + color: $light-gray; + } + } + + } + + .grey-editable-avatar { + z-index: 200; + box-sizing: border-box; + border: 3px solid transparent; + display: flex; + align-items: center; + justify-content: center; + width: $avatar-width; + height: $avatar-width; + position: absolute; + background-color: #000; + opacity: .4; + } + + .edit-label-container { + z-index: 400; + position: absolute; + display: flex; + align-items: center; + width: $avatar-width; + height: $avatar-width; + justify-content: center; + p { + color: $grey-text; + display: none; + text-transform: uppercase; + font-size: 18px; + font-weight: bold; + letter-spacing: 1.5px; + } + } +} From d6f844903bc25408ee19a301b99d69bebade3e79 Mon Sep 17 00:00:00 2001 From: Maximbndrnk Date: Thu, 8 Nov 2018 15:53:40 +0200 Subject: [PATCH 10/47] add all functionality of CRUD to manage profiles page --- .../streama/controllers/subProfiles-ctrl.js | 86 +++++++++++++++++-- .../streama/services/api-service.js | 4 +- .../streama/templates/sub-profiles.tpl.htm | 39 +++++++-- .../assets/stylesheets/_subprofiles.scss | 67 ++++++++++++++- .../streama/ProfileController.groovy | 2 +- 5 files changed, 179 insertions(+), 19 deletions(-) diff --git a/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js b/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js index 78206a2a7..6d7cc92f2 100644 --- a/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js +++ b/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js @@ -9,10 +9,12 @@ angular.module('streama').controller('subProfilesCtrl', isKid: false }; $scope.mycolor = '002300'; + $scope.currentSelectedColor = 'ba1c56'; $scope.existingProfiles = []; $scope.loading = true; - $scope.isManageProfiles = true; - $scope.isEditOrCreateProfile = false; + $scope.isManageProfiles = false; + $scope.isEditProfile = false; + $scope.isCreateProfile = false; apiService.profile.getUserProfiles() .success(function (data) { @@ -25,12 +27,84 @@ angular.module('streama').controller('subProfilesCtrl', $scope.isManageProfiles = !$scope.isManageProfiles; }; - $scope.editProfile = function(profile){ - $scope.isEditOrCreateProfile = !$scope.isEditOrCreateProfile; + $scope.goToEditProfile = function(profile){ + $scope.isEditProfile = !$scope.isEditProfile; + $scope.profile = profile; + }; + + $scope.goToCreateProfile = function(){ + $scope.isCreateProfile = !$scope.isCreateProfile; + $scope.profile = { + profile_name: '', + profile_language: 'en', + isKid: false + } + }; + + $scope.deleteProfile = function(){ + if($scope.existingProfiles.length == 1){ + alertify.error("You must have at least ONE profile!"); + return; + } + if(!$scope.profile.id){ + return; + } + apiService.profile.delete($scope.profile.id) + .success(function () { + alertify.success('Profile Deleted!'); + $scope.getAllProfiles(); + $scope.loading = false; + $scope.refreshStates(); + }) + .error(function (data) { + alertify.error(data.message); + $scope.loading = false; + }); + }; + + $scope.refreshStates = function(){ + $scope.isEditProfile = false; + $scope.isCreateProfile = false; + }; + $scope.saveProfile = function(){ + if (!$scope.profile.profile_name) { + return; + } + if ($scope.profile.id) { + apiService.profile.update($scope.profile) + .success(function () { + alertify.success('Profile Updated!'); + $scope.getAllProfiles(); + $scope.loading = false; + }) + .error(function (data) { + alertify.error(data.message); + $scope.loading = false; + }); + return; + } + apiService.profile.save($scope.profile) + .success(function () { + alertify.success('Profile Created!'); + $scope.getAllProfiles(); + $scope.loading = false; + }) + .error(function (data) { + alertify.error(data.message); + $scope.loading = false; + }); }; - $scope.createProfile = function(){ - $scope.isEditOrCreateProfile = !$scope.isEditOrCreateProfile; + $scope.getAllProfiles = function () { + apiService.profile.getUserProfiles() + .success(function (data) { + $scope.existingProfiles = data; + $scope.refreshStates(); + }) + .error(function (data) { + alertify.error(data.message); + $scope.loading = false; + }); }; }); diff --git a/grails-app/assets/javascripts/streama/services/api-service.js b/grails-app/assets/javascripts/streama/services/api-service.js index ea7f0d541..0e69ac6e2 100644 --- a/grails-app/assets/javascripts/streama/services/api-service.js +++ b/grails-app/assets/javascripts/streama/services/api-service.js @@ -345,8 +345,8 @@ angular.module('streama').factory('apiService', function ($http, $rootScope, con update: function (params) { return $http.put('profile/update.json', params) }, - delete: function (params) { - return $http.delete('profile/delete.json', params) + delete: function (id) { + return $http.delete('profile/delete.json', {params: {id: id}}) }, getUserProfiles: function () { return $http.get('profile/getUserProfiles.json') diff --git a/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm b/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm index 3d5e0213c..6fc9601f9 100644 --- a/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm +++ b/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm @@ -1,5 +1,5 @@
    -
    +

    Who's watching?

    @@ -11,7 +11,7 @@

    {{subp.profile_name}}

    -
    +

    +

    @@ -24,12 +24,12 @@
    -
    +

    Manage profiles:

    -
    +
    @@ -38,7 +38,7 @@

    {{subp.profile_name}}

    -
    +

    +

    @@ -52,11 +52,34 @@ -
    +
    +

    {{isEditProfile ? "Edit Profile" : "Create Profile"}}

    +
    +
    +
    + +
    +
    + + +
    + +

    Kid?

    +
    + - - + +
    + +
    + + + +
    diff --git a/grails-app/assets/stylesheets/_subprofiles.scss b/grails-app/assets/stylesheets/_subprofiles.scss index 85807d772..fb51dc36d 100644 --- a/grails-app/assets/stylesheets/_subprofiles.scss +++ b/grails-app/assets/stylesheets/_subprofiles.scss @@ -1,7 +1,9 @@ $grey-text: #a6a6a6; +$border-color: rgba(166, 166, 166, 0.3); $light-gray: lighten($grey-text, 40%); $avatar-width: 130px; $background-color: #25292B; +$logo-color:#b0ddef; .sub-profile-page-container { width: 100%; @@ -32,6 +34,7 @@ $background-color: #25292B; font-size: 15px; letter-spacing: 1.5px; background-color: transparent; + padding: 0 20px; &:hover { color: $light-gray; @@ -48,8 +51,8 @@ $background-color: #25292B; font-weight: bold; &:hover { - background-color: #2898c5; - border: 1px solid #2898c5; + background-color: $logo-color; + border: 1px solid $logo-color; color: $background-color; } } @@ -82,6 +85,7 @@ $background-color: #25292B; } p.add { + color: $grey-text; font-size: 40px; font-weight: 600; } @@ -175,3 +179,62 @@ $background-color: #25292B; } } } + + +.btns-container { + display: flex; + justify-content: flex-start; + button { + margin-right: 10px; + } +} + +.form-container { + width: 100%; + display: flex; + flex-direction: column; + justify-content: flex-start; + align-items: center; + margin: 20px 0; + padding: 15px 0; + border-bottom: 1px solid $border-color; + border-top: 1px solid $border-color; + + >* { + margin-bottom: 10px; + } + + .choose-avatar-color { + width: 100%; + display: flex; + justify-content: flex-start; + align-items: center; + .form-avatar { + width: $avatar-width; + display: flex; + justify-content: center; + align-items: center; + height: $avatar-width; + + img { + z-index: 100; + max-width: $avatar-width; + } + } + } +} + +.is-kid-container { + display: flex; + align-items: center; + width: 100%; + input { + margin: 0 15px 0 0; + } + + p { + margin: 0; + font-size: 18px; + } +} + diff --git a/grails-app/controllers/streama/ProfileController.groovy b/grails-app/controllers/streama/ProfileController.groovy index 5fc08590c..417793120 100644 --- a/grails-app/controllers/streama/ProfileController.groovy +++ b/grails-app/controllers/streama/ProfileController.groovy @@ -32,7 +32,7 @@ class ProfileController { respond profile.errors, view:'create' return } - + profile.user = springSecurityService.getCurrentUser() profile.save flush:true respond profile, [status: CREATED, view:"show"] From 10bd8f9293fc3bd4fa40ff17dc550dd71ea50d07 Mon Sep 17 00:00:00 2001 From: Maximbndrnk Date: Thu, 8 Nov 2018 16:01:56 +0200 Subject: [PATCH 11/47] revert profile page to the starting look, delete random color class --- .../streama/controllers/profile-ctrl.js | 69 ++----------------- .../streama/templates/profile.tpl.htm | 56 +-------------- src/main/groovy/streama/ColorHelper.java | 19 ----- 3 files changed, 5 insertions(+), 139 deletions(-) delete mode 100644 src/main/groovy/streama/ColorHelper.java diff --git a/grails-app/assets/javascripts/streama/controllers/profile-ctrl.js b/grails-app/assets/javascripts/streama/controllers/profile-ctrl.js index 68222a7ac..65156422d 100644 --- a/grails-app/assets/javascripts/streama/controllers/profile-ctrl.js +++ b/grails-app/assets/javascripts/streama/controllers/profile-ctrl.js @@ -6,18 +6,8 @@ angular.module('streama').controller('profileCtrl', function ($scope, apiService $scope.passwordData = {}; $scope.passwordsInvalid = true; $scope.languages = true; - $scope.profile = { - profile_name: '', - profile_language: 'en', - isKid: false - }; - $scope.existingProfiles = []; - $scope.isCreatingNewProfile = false; - apiService.profile.getUserProfiles() - .success(function (data) { - $scope.existingProfiles = data; - console.log('Profiles list:', $scope.existingProfiles); - }); + + apiService.theMovieDb.availableGenres().success(function (data) { $scope.availableGenres = data; $scope.loading = false; @@ -51,9 +41,9 @@ angular.module('streama').controller('profileCtrl', function ($scope, apiService }; $scope.validatePasswords = function () { - if ($scope.passwordData.newPassword != $scope.passwordData.repeatPassword || $scope.passwordData.newPassword.length < 6) { + if($scope.passwordData.newPassword != $scope.passwordData.repeatPassword || $scope.passwordData.newPassword.length < 6){ $scope.passwordsInvalid = true; - } else { + }else{ $scope.passwordsInvalid = false; } }; @@ -75,55 +65,4 @@ angular.module('streama').controller('profileCtrl', function ($scope, apiService }); }; - $scope.toggleCreateSubProfile = function () { - $scope.isCreatingNewProfile = !$scope.isCreatingNewProfile; - }; - - $scope.addNewSubProfile = function () { - if (!$scope.profile.profile_name) { - return; - } - if ($scope.profile.id) { - apiService.profile.update($scope.profile) - .success(function () { - alertify.success('Profile Updated!'); - $scope.getAllProfiles(); - $scope.loading = false; - $scope.isCreatingNewProfile = false; - }) - .error(function (data) { - alertify.error(data.message); - $scope.loading = false; - }); - return; - } - apiService.profile.save($scope.profile) - .success(function () { - alertify.success('Profile created!'); - $scope.getAllProfiles(); - $scope.loading = false; - $scope.isCreatingNewProfile = false; - }) - .error(function (data) { - alertify.error(data.message); - $scope.loading = false; - }); - }; - - $scope.getAllProfiles = function () { - apiService.profile.getUserProfiles() - .success(function (data) { - $scope.existingProfiles = data; - }) - .error(function (data) { - alertify.error(data.message); - $scope.loading = false; - }); - }; - - $scope.editSubProfile = function (profile) { - $scope.profile = profile; - $scope.toggleCreateSubProfile(); - } - }); diff --git a/grails-app/assets/javascripts/streama/templates/profile.tpl.htm b/grails-app/assets/javascripts/streama/templates/profile.tpl.htm index 25209481b..a13c85045 100644 --- a/grails-app/assets/javascripts/streama/templates/profile.tpl.htm +++ b/grails-app/assets/javascripts/streama/templates/profile.tpl.htm @@ -1,8 +1,6 @@
    -

    @@ -81,65 +79,13 @@

    - -
    - - -
    -

    Available profiles

    - - - - - - - - - - - - - - - - - -
    Profile Name
    Is Kid
    Language
    Edit
    {{subp.profile_name}}
    {{subp.isKid ? 'Yes' : 'No'}}
    {{subp.profile_language}}
    -
    - -
    -

    Create new profile

    -
    -
    - -
    -
    - -
    -
    + -
    -
    - -
    -
    - -
    -
    -
    -
    - -
    -
    - -
    -
    -
    diff --git a/src/main/groovy/streama/ColorHelper.java b/src/main/groovy/streama/ColorHelper.java deleted file mode 100644 index 38a5077f2..000000000 --- a/src/main/groovy/streama/ColorHelper.java +++ /dev/null @@ -1,19 +0,0 @@ -package streama; -import java.awt.Color; -import java.util.Random; - -class ColorHelper { - - private final static String toHexString(Color colour) throws NullPointerException { - String hexColour = Integer.toHexString(colour.getRGB() & 0xffffff); - if (hexColour.length() < 6) { - hexColour = "000000".substring(0, 6 - hexColour.length()) + hexColour; - } - return "#" + hexColour; - } - - public static String generateHexColorDarker() { - Color color = Color.getHSBColor(new Random().nextFloat(), new Random().nextFloat(), new Random().nextFloat()); - return toHexString(color.darker()); - } -} From 0047138616fb1d479a8f5605aa47109c936cdf86 Mon Sep 17 00:00:00 2001 From: Maximbndrnk Date: Thu, 8 Nov 2018 17:42:54 +0200 Subject: [PATCH 12/47] add select color for avatar in profile --- .../streama/controllers/subProfiles-ctrl.js | 16 ++++++--- .../streama/templates/sub-profiles.tpl.htm | 15 +++++--- .../assets/stylesheets/_subprofiles.scss | 35 ++++++++++++++----- grails-app/domain/streama/Profile.groovy | 1 + 4 files changed, 50 insertions(+), 17 deletions(-) diff --git a/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js b/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js index 6d7cc92f2..649e032a5 100644 --- a/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js +++ b/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js @@ -6,23 +6,31 @@ angular.module('streama').controller('subProfilesCtrl', $scope.profile = { profile_name: '', profile_language: 'en', - isKid: false + isKid: false, + avatar_color: '0b74b2' }; - $scope.mycolor = '002300'; - $scope.currentSelectedColor = 'ba1c56'; + $scope.standartColor = '0b74b2'; $scope.existingProfiles = []; $scope.loading = true; $scope.isManageProfiles = false; $scope.isEditProfile = false; $scope.isCreateProfile = false; + $scope.avaliabeColors = [ + '0b74b2','ba1c56','099166','d1b805','c03da7', + '488f16','d36e10','4b4b4b','3a328b','b81f1f' + ]; + apiService.profile.getUserProfiles() .success(function (data) { $scope.existingProfiles = data; - console.log('Profiles list:', $scope.existingProfiles); }); + $scope.setProfileColor = function(color){ + $scope.profile.avatar_color = color; + }; + $scope.toggleManageProfiles = function(){ $scope.isManageProfiles = !$scope.isManageProfiles; }; diff --git a/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm b/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm index 6fc9601f9..6419fd784 100644 --- a/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm +++ b/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm @@ -5,7 +5,7 @@
    -
    +

    {{subp.profile_name}}

    @@ -30,7 +30,7 @@
    -
    +
    @@ -57,9 +57,15 @@
    -
    +
    +
    +
    +
    @@ -68,7 +74,8 @@

    Kid?

    - +
    diff --git a/grails-app/assets/stylesheets/_subprofiles.scss b/grails-app/assets/stylesheets/_subprofiles.scss index fb51dc36d..8c572e55d 100644 --- a/grails-app/assets/stylesheets/_subprofiles.scss +++ b/grails-app/assets/stylesheets/_subprofiles.scss @@ -3,7 +3,8 @@ $border-color: rgba(166, 166, 166, 0.3); $light-gray: lighten($grey-text, 40%); $avatar-width: 130px; $background-color: #25292B; -$logo-color:#b0ddef; +$logo-color: #b0ddef; +$color-box-size: 30px; .sub-profile-page-container { width: 100%; @@ -45,7 +46,7 @@ $logo-color:#b0ddef; } .done-btn { - @extend .manage-profiles-btn; + @extend .manage-profiles-btn; color: $background-color; background-color: white; font-weight: bold; @@ -91,8 +92,6 @@ $logo-color:#b0ddef; } } - - .profile-name { margin-top: 10px; color: $grey-text; @@ -116,10 +115,10 @@ $logo-color:#b0ddef; .add-profile { @extend .item-profile-container; - &:hover{ + &:hover { .avatar { background-color: $light-gray !important; - p.add{ + p.add { color: $background-color !important; } } @@ -127,7 +126,6 @@ $logo-color:#b0ddef; } } - .item-editable-container { @extend .item-profile-container; position: relative; @@ -180,7 +178,6 @@ $logo-color:#b0ddef; } } - .btns-container { display: flex; justify-content: flex-start; @@ -200,7 +197,7 @@ $logo-color:#b0ddef; border-bottom: 1px solid $border-color; border-top: 1px solid $border-color; - >* { + > * { margin-bottom: 10px; } @@ -221,6 +218,26 @@ $logo-color:#b0ddef; max-width: $avatar-width; } } + .colors-container { + display: flex; + flex-wrap: wrap; + justify-content: center; + align-items: center; + width: 200px; + height: $avatar-width; + + .single-color { + width: $color-box-size; + height: $color-box-size; + margin: 3px; + + &:hover { + cursor: pointer; + } + + + } + } } } diff --git a/grails-app/domain/streama/Profile.groovy b/grails-app/domain/streama/Profile.groovy index 5f838e3ec..a32459d53 100644 --- a/grails-app/domain/streama/Profile.groovy +++ b/grails-app/domain/streama/Profile.groovy @@ -5,6 +5,7 @@ class Profile { String profile_name String profile_language Boolean isKid + String avatar_color static belongsTo = [user: User] From 08c8747ea05daa3d978f12ca1173d866744a911c Mon Sep 17 00:00:00 2001 From: Maximbndrnk Date: Fri, 9 Nov 2018 12:46:15 +0200 Subject: [PATCH 13/47] add basic profile when create user in admin section --- .../streama/controllers/modal-user-ctrl.js | 18 ++++++++++++++++-- .../streama/ProfileController.groovy | 4 +++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/grails-app/assets/javascripts/streama/controllers/modal-user-ctrl.js b/grails-app/assets/javascripts/streama/controllers/modal-user-ctrl.js index 4945f2c06..b059c08dc 100644 --- a/grails-app/assets/javascripts/streama/controllers/modal-user-ctrl.js +++ b/grails-app/assets/javascripts/streama/controllers/modal-user-ctrl.js @@ -97,8 +97,22 @@ angular.module('streama').controller('modalUserCtrl', [ apiService.user.saveAndCreateUser(dateObj) .success(function (data) { - $uibModalInstance.close(data); - $scope.loading = false; + var basicProfile = { + profile_name: data.username, + profile_language: data.language, + isKid: false, + user: data + }; + apiService.profile.save(basicProfile) + .success(function () { + alertify.success('Profile Created!'); + $uibModalInstance.close(data); + $scope.loading = false; + }) + .error(function (data) { + alertify.error(data.message); + $scope.loading = false; + }); }) .error(function () { $scope.loading = false; diff --git a/grails-app/controllers/streama/ProfileController.groovy b/grails-app/controllers/streama/ProfileController.groovy index 417793120..cc0d6858e 100644 --- a/grails-app/controllers/streama/ProfileController.groovy +++ b/grails-app/controllers/streama/ProfileController.groovy @@ -32,7 +32,9 @@ class ProfileController { respond profile.errors, view:'create' return } - profile.user = springSecurityService.getCurrentUser() + if(!profile.user){ + profile.user = springSecurityService.getCurrentUser() + } profile.save flush:true respond profile, [status: CREATED, view:"show"] From 03e715f18a09ce7522e6b27b56c04d9cc36b1317 Mon Sep 17 00:00:00 2001 From: Maximbndrnk Date: Fri, 9 Nov 2018 12:53:49 +0200 Subject: [PATCH 14/47] add basic profile when invite user via email --- .../streama/controllers/modal-user-ctrl.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/grails-app/assets/javascripts/streama/controllers/modal-user-ctrl.js b/grails-app/assets/javascripts/streama/controllers/modal-user-ctrl.js index b059c08dc..7ccfea447 100644 --- a/grails-app/assets/javascripts/streama/controllers/modal-user-ctrl.js +++ b/grails-app/assets/javascripts/streama/controllers/modal-user-ctrl.js @@ -75,8 +75,22 @@ angular.module('streama').controller('modalUserCtrl', [ apiService.user.saveAndInviteUser(dateObj) .success(function (data) { - $uibModalInstance.close(data); - $scope.loading = false; + var basicProfile = { + profile_name: data.username, + profile_language: data.language, + isKid: false, + user: data + }; + apiService.profile.save(basicProfile) + .success(function () { + alertify.success('Profile Created!'); + $uibModalInstance.close(data); + $scope.loading = false; + }) + .error(function (data) { + alertify.error(data.message); + $scope.loading = false; + }); }) .error(function (response) { $scope.loading = false; From a1f0e22599b66ba4a437b1884c1ee14c0dd0b646 Mon Sep 17 00:00:00 2001 From: Maximbndrnk Date: Fri, 9 Nov 2018 16:40:33 +0200 Subject: [PATCH 15/47] save current profile to local storage, add click handler to select profile --- .../streama/controllers/subProfiles-ctrl.js | 6 ++++- .../streama/templates/sub-profiles.tpl.htm | 23 +++++++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js b/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js index 649e032a5..6e6d6e02c 100644 --- a/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js +++ b/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('streama').controller('subProfilesCtrl', - function ($scope, apiService, $rootScope, userService) { + function ($scope, apiService, $rootScope, userService, localStorageService,$state) { $scope.profile = { profile_name: '', @@ -26,6 +26,10 @@ angular.module('streama').controller('subProfilesCtrl', $scope.existingProfiles = data; }); + $scope.setCurrentProfile = function(profile) { + localStorageService.set('currentProfile', profile); + $state.go('dash'); + }; $scope.setProfileColor = function(color){ $scope.profile.avatar_color = color; diff --git a/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm b/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm index 6419fd784..3e88d8105 100644 --- a/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm +++ b/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm @@ -3,8 +3,7 @@

    Who's watching?

    - -
    +
    @@ -17,8 +16,16 @@

    Add Profile

    -
    +
    +
    +
    +

    +

    +
    +

    Add Profile

    +
    +
    +
    @@ -28,7 +35,6 @@

    Manage profiles:

    -
    @@ -44,7 +50,14 @@

    Add Profile

    - +
    +
    +
    +
    +

    +

    +
    +

    Add Profile

    +
    From bd8d985577143bd7a41f3ce5701337a7dca6b796 Mon Sep 17 00:00:00 2001 From: Maximbndrnk Date: Fri, 9 Nov 2018 17:29:44 +0200 Subject: [PATCH 16/47] add profile id to the viewing status record --- grails-app/assets/javascripts/streama/streama.interceptor.js | 5 +++-- .../controllers/streama/ViewingStatusController.groovy | 3 +++ grails-app/services/streama/ViewingStatusService.groovy | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/grails-app/assets/javascripts/streama/streama.interceptor.js b/grails-app/assets/javascripts/streama/streama.interceptor.js index 09078743f..0ac53335e 100644 --- a/grails-app/assets/javascripts/streama/streama.interceptor.js +++ b/grails-app/assets/javascripts/streama/streama.interceptor.js @@ -6,13 +6,14 @@ angular.module('streama').config(function ($httpProvider) { }); -angular.module('streama').factory('httpInterceptor', function ($rootScope, $q) { +angular.module('streama').factory('httpInterceptor', function ($rootScope, $q, localStorageService) { return { request: function (config) { config.params = config.params || {}; if(config.params.socketSessionId){ config.params.browserSocketUUID = $rootScope.browserSocketUUID; } + config.headers.profileId = localStorageService.get('currentProfile').id || 0; return config || $q.when(config); }, response: function (response) { @@ -35,4 +36,4 @@ angular.module('streama').factory('httpInterceptor', function ($rootScope, $q) { return $q.reject(response); } }; -}); \ No newline at end of file +}); diff --git a/grails-app/controllers/streama/ViewingStatusController.groovy b/grails-app/controllers/streama/ViewingStatusController.groovy index ebb8d5fab..fe9d12b4b 100644 --- a/grails-app/controllers/streama/ViewingStatusController.groovy +++ b/grails-app/controllers/streama/ViewingStatusController.groovy @@ -22,6 +22,9 @@ class ViewingStatusController { @Transactional def save() { def result = [:] + Long profileId = request.getHeader('profileId')?.toLong() + Profile profile = Profile.findById(profileId) + params['profile'] = profile try{ result = viewingStatusService.createNew(params) }catch(e){ diff --git a/grails-app/services/streama/ViewingStatusService.groovy b/grails-app/services/streama/ViewingStatusService.groovy index bd64ba733..c67948812 100644 --- a/grails-app/services/streama/ViewingStatusService.groovy +++ b/grails-app/services/streama/ViewingStatusService.groovy @@ -26,7 +26,7 @@ class ViewingStatusService { }.get() if(!viewingStatus){ - viewingStatus = new ViewingStatus(tvShow: video?.show, user: currentUser, video: video) + viewingStatus = new ViewingStatus(tvShow: video?.show, user: currentUser, video: video, profile: params.profile) } viewingStatus.video = video From 532b7438d565bbec44361d75e538f798e4422108 Mon Sep 17 00:00:00 2001 From: Maximbndrnk Date: Mon, 12 Nov 2018 10:52:14 +0200 Subject: [PATCH 17/47] select video for current profile and user for dashboard --- grails-app/controllers/streama/DashController.groovy | 4 +++- grails-app/services/streama/VideoService.groovy | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/grails-app/controllers/streama/DashController.groovy b/grails-app/controllers/streama/DashController.groovy index 530de0a30..bf58e00d6 100644 --- a/grails-app/controllers/streama/DashController.groovy +++ b/grails-app/controllers/streama/DashController.groovy @@ -11,8 +11,10 @@ class DashController { def listContinueWatching(){ User currentUser = springSecurityService.currentUser + Long profileId = request.getHeader('profileId')?.toLong() + Profile profile = Profile.findById(profileId) - List viewingStatusList = videoService.listContinueWatching(currentUser) + List viewingStatusList = videoService.listContinueWatching(currentUser, profile) return [viewingStatusList: viewingStatusList] } diff --git a/grails-app/services/streama/VideoService.groovy b/grails-app/services/streama/VideoService.groovy index 78ca2bd99..704f68db3 100644 --- a/grails-app/services/streama/VideoService.groovy +++ b/grails-app/services/streama/VideoService.groovy @@ -23,9 +23,10 @@ class VideoService { } - public static List listContinueWatching(User currentUser) { + public static List listContinueWatching(User currentUser, Profile profile) { List continueWatching = ViewingStatus.withCriteria { eq("user", currentUser) + eq("profile", profile) video { isNotEmpty("files") ne("deleted", true) From 075e9eab9733d1c97c04f5796e88895c8bd887b1 Mon Sep 17 00:00:00 2001 From: Maximbndrnk Date: Mon, 12 Nov 2018 11:52:34 +0200 Subject: [PATCH 18/47] check if profile exists on local storage --- .../javascripts/streama/controllers/dash-ctrl.js | 13 +++++++++++-- .../javascripts/streama/streama.interceptor.js | 4 +++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/grails-app/assets/javascripts/streama/controllers/dash-ctrl.js b/grails-app/assets/javascripts/streama/controllers/dash-ctrl.js index b757a0751..d4d81611d 100644 --- a/grails-app/assets/javascripts/streama/controllers/dash-ctrl.js +++ b/grails-app/assets/javascripts/streama/controllers/dash-ctrl.js @@ -13,8 +13,17 @@ angular.module('streama').controller('dashCtrl', $scope.$on('changedGenre', onChangedGenre); - - init(); + if(!localStorageService.get('currentProfile')){ + apiService.profile.getUserProfiles().success(function(data) { + localStorageService.set('currentProfile', data[0]); + init(); + } + ).error(function (data) { + alertify.error(data.message); + }); + } else { + init(); + } function init() { diff --git a/grails-app/assets/javascripts/streama/streama.interceptor.js b/grails-app/assets/javascripts/streama/streama.interceptor.js index 0ac53335e..38733a26a 100644 --- a/grails-app/assets/javascripts/streama/streama.interceptor.js +++ b/grails-app/assets/javascripts/streama/streama.interceptor.js @@ -13,7 +13,9 @@ angular.module('streama').factory('httpInterceptor', function ($rootScope, $q, l if(config.params.socketSessionId){ config.params.browserSocketUUID = $rootScope.browserSocketUUID; } - config.headers.profileId = localStorageService.get('currentProfile').id || 0; + if (localStorageService.get('currentProfile')){ + config.headers.profileId = localStorageService.get('currentProfile').id || 0; + } return config || $q.when(config); }, response: function (response) { From 97702db3929f9ab1a3d9de702d72006ac4060ea2 Mon Sep 17 00:00:00 2001 From: Maximbndrnk Date: Mon, 12 Nov 2018 14:53:10 +0200 Subject: [PATCH 19/47] setup list in header with list of available profiles --- .../streama/controllers/subProfiles-ctrl.js | 1 + .../assets/javascripts/streama/streama.run.js | 17 +++++++++++ .../assets/stylesheets/_subprofiles.scss | 29 +++++++++++++++++++ grails-app/views/templates/_header.gsp | 14 +++++++-- 4 files changed, 58 insertions(+), 3 deletions(-) diff --git a/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js b/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js index 6e6d6e02c..e01adbae4 100644 --- a/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js +++ b/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js @@ -28,6 +28,7 @@ angular.module('streama').controller('subProfilesCtrl', $scope.setCurrentProfile = function(profile) { localStorageService.set('currentProfile', profile); + $rootScope.currentProfile = profile; $state.go('dash'); }; diff --git a/grails-app/assets/javascripts/streama/streama.run.js b/grails-app/assets/javascripts/streama/streama.run.js index 8d4958fb2..bc8e5b6d0 100644 --- a/grails-app/assets/javascripts/streama/streama.run.js +++ b/grails-app/assets/javascripts/streama/streama.run.js @@ -3,6 +3,23 @@ angular.module('streama').run(function ($window, $rootScope, $state, localStorag userService.setCurrentUser(data); }); + apiService.profile.getUserProfiles().success(function(data) { + $rootScope.usersProfiles = data; + if(!localStorageService.get('currentProfile')){ + localStorageService.set('currentProfile', data[0]); + $rootScope.currentProfile = data[0]; + } + } + ).error(function (data) { + console.warn(data.message); + }); + + $rootScope.setCurrentSubProfile = function(profile) { + $rootScope.currentProfile = profile; + localStorageService.set('currentProfile', profile) + $state.go('dash',{},{reload:true}); + }; + $rootScope.baseData = {}; $rootScope.isCurrentState = function (stateName) { return ($state.current.name == stateName); diff --git a/grails-app/assets/stylesheets/_subprofiles.scss b/grails-app/assets/stylesheets/_subprofiles.scss index 8c572e55d..c584931ca 100644 --- a/grails-app/assets/stylesheets/_subprofiles.scss +++ b/grails-app/assets/stylesheets/_subprofiles.scss @@ -255,3 +255,32 @@ $color-box-size: 30px; } } +.avatar-in-header { + width: 30px; + height: 30px; + box-sizing: border-box; + display: flex; + align-items: center; + justify-content: center; + + img { + z-index: 100; + width: 30px; + } +} + +.header-btn { + display: flex; + align-items: center; + justify-content: center; + background-color: transparent; + border-color: transparent; + * { + margin: 0 4px !important; + } + + &:hover, &:focus { + background-color: rgba(255,255,255, 0.12); + border-color: transparent; + } +} diff --git a/grails-app/views/templates/_header.gsp b/grails-app/views/templates/_header.gsp index 6c9bc8edd..ae2ee3139 100644 --- a/grails-app/views/templates/_header.gsp +++ b/grails-app/views/templates/_header.gsp @@ -59,15 +59,23 @@
  • - From b4defd9c0b3a1e84bcb26f965187044e2c57933e Mon Sep 17 00:00:00 2001 From: Maximbndrnk Date: Mon, 12 Nov 2018 15:24:08 +0200 Subject: [PATCH 20/47] add new profile to each user when user will upgrade streama with profile feature --- grails-app/init/streama/BootStrap.groovy | 1 + .../services/streama/MigrationService.groovy | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/grails-app/init/streama/BootStrap.groovy b/grails-app/init/streama/BootStrap.groovy index aa376205e..f247ff183 100644 --- a/grails-app/init/streama/BootStrap.groovy +++ b/grails-app/init/streama/BootStrap.groovy @@ -21,6 +21,7 @@ class BootStrap { migrationService.urlvalidationFix() migrationService.updateBaseUrlHelp() migrationService.migrateMergedSeasonEpisode() + migrationService.setupBasicSubProfiles() } def destroy = { } diff --git a/grails-app/services/streama/MigrationService.groovy b/grails-app/services/streama/MigrationService.groovy index f52db264e..de6f860fb 100644 --- a/grails-app/services/streama/MigrationService.groovy +++ b/grails-app/services/streama/MigrationService.groovy @@ -152,4 +152,24 @@ class MigrationService { episode.save(flush: true) } } + + def setupBasicSubProfiles() { + List users = User.getAll() + + users.each { + User u = it + List profiles = Profile.findAllByUser(u) + if(profiles.size() == 0) { + Profile p = new Profile( + user: u, + profile_name: u.username, + profile_language: u.language, + isKid: false + ) + p.save() + } + } + } + + } From 238944d8b67490d767f7df79bbb2bfe79bbb6b9a Mon Sep 17 00:00:00 2001 From: Maximbndrnk Date: Thu, 15 Nov 2018 09:46:31 +0200 Subject: [PATCH 21/47] add improvements to mob api according to new features of mob app --- .../controllers/streama/ViewingStatusController.groovy | 1 + .../controllers/streama/api/v1/PlayerController.groovy | 4 ++++ grails-app/services/streama/PlayerService.groovy | 1 + .../streama/marshallers/PlayerMarshallerService.groovy | 8 +++++++- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/grails-app/controllers/streama/ViewingStatusController.groovy b/grails-app/controllers/streama/ViewingStatusController.groovy index fe9d12b4b..5e22a8aa5 100644 --- a/grails-app/controllers/streama/ViewingStatusController.groovy +++ b/grails-app/controllers/streama/ViewingStatusController.groovy @@ -25,6 +25,7 @@ class ViewingStatusController { Long profileId = request.getHeader('profileId')?.toLong() Profile profile = Profile.findById(profileId) params['profile'] = profile + log.debug("profile: ${profile}") try{ result = viewingStatusService.createNew(params) }catch(e){ diff --git a/grails-app/controllers/streama/api/v1/PlayerController.groovy b/grails-app/controllers/streama/api/v1/PlayerController.groovy index bfb0a8106..8326222a2 100644 --- a/grails-app/controllers/streama/api/v1/PlayerController.groovy +++ b/grails-app/controllers/streama/api/v1/PlayerController.groovy @@ -2,6 +2,7 @@ package streama.api.v1 import grails.converters.JSON import grails.transaction.NotTransactional +import streama.Profile import streama.Video class PlayerController { @@ -23,6 +24,9 @@ class PlayerController { @NotTransactional def updateViewingStatus(){ + Long profileId = request.getHeader('profileId')?.toLong() + Profile profile = Profile.findById(profileId) + params['profile'] = profile def result = playerService.updateViewingStatus(params) if(result.error){ render status: result.statusCode diff --git a/grails-app/services/streama/PlayerService.groovy b/grails-app/services/streama/PlayerService.groovy index ab51e9849..74fabe79a 100644 --- a/grails-app/services/streama/PlayerService.groovy +++ b/grails-app/services/streama/PlayerService.groovy @@ -34,6 +34,7 @@ class PlayerService { viewingStatus.currentPlayTime = currentTime viewingStatus.runtime = runtime viewingStatus.user = currentUser + viewingStatus.profile = params.profile viewingStatus.validate() diff --git a/grails-app/services/streama/marshallers/PlayerMarshallerService.groovy b/grails-app/services/streama/marshallers/PlayerMarshallerService.groovy index c3c61803e..7f78fa002 100644 --- a/grails-app/services/streama/marshallers/PlayerMarshallerService.groovy +++ b/grails-app/services/streama/marshallers/PlayerMarshallerService.groovy @@ -2,10 +2,12 @@ package streama.marshallers import grails.converters.JSON import grails.transaction.Transactional +import org.grails.web.util.WebUtils import streama.Episode import streama.File import streama.GenericVideo import streama.Movie +import streama.Profile import streama.Video import streama.ViewingStatus @@ -19,6 +21,10 @@ class PlayerMarshallerService { cfg.registerObjectMarshaller(Video) { Video video -> def returnArray = [:] + def request = WebUtils.retrieveGrailsWebRequest()?.getCurrentRequest() + def profileId = request.getHeader("profileId") + Profile profile = Profile.findById(profileId) + returnArray['id'] = video.id returnArray['dateCreated'] = video.dateCreated returnArray['lastUpdated'] = video.lastUpdated @@ -35,7 +41,7 @@ class PlayerMarshallerService { returnArray['hasFiles'] = video.hasFiles() - returnArray['viewedStatus'] = ViewingStatus.findByVideoAndUser(video, springSecurityService.currentUser) + returnArray['viewedStatus'] = ViewingStatus.findByVideoAndUserAndProfile(video, springSecurityService.currentUser, profile) returnArray['outro_start'] = video.outro_start ? video.outro_start * 60 : null //convert to seconds if (video instanceof Episode) { From dfe6e0b7d00dfbcf772ed7871cb90ffa41fc8384 Mon Sep 17 00:00:00 2001 From: Maximbndrnk Date: Thu, 15 Nov 2018 10:46:25 +0200 Subject: [PATCH 22/47] add profile to viewingStatus table if profile == null, bootstrap --- grails-app/init/streama/BootStrap.groovy | 1 + .../services/streama/MigrationService.groovy | 40 ++++++++++++++----- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/grails-app/init/streama/BootStrap.groovy b/grails-app/init/streama/BootStrap.groovy index f247ff183..77dfefba5 100644 --- a/grails-app/init/streama/BootStrap.groovy +++ b/grails-app/init/streama/BootStrap.groovy @@ -22,6 +22,7 @@ class BootStrap { migrationService.updateBaseUrlHelp() migrationService.migrateMergedSeasonEpisode() migrationService.setupBasicSubProfiles() + migrationService.addProfilesToViewingStatusRecords() } def destroy = { } diff --git a/grails-app/services/streama/MigrationService.groovy b/grails-app/services/streama/MigrationService.groovy index de6f860fb..f915b613a 100644 --- a/grails-app/services/streama/MigrationService.groovy +++ b/grails-app/services/streama/MigrationService.groovy @@ -157,16 +157,36 @@ class MigrationService { List users = User.getAll() users.each { - User u = it - List profiles = Profile.findAllByUser(u) - if(profiles.size() == 0) { - Profile p = new Profile( - user: u, - profile_name: u.username, - profile_language: u.language, - isKid: false - ) - p.save() + User user = it + List profiles = Profile.findAllByUser(user) + if(profiles.size() > 0) { + return + } + Profile p = new Profile( + user: user, + profile_name: user.username, + profile_language: user.language, + isKid: false + ) + p.save() + } + } + + def addProfilesToViewingStatusRecords() { + List users = User.getAll() + + users.each { User user -> + List views = ViewingStatus.findAllByUser(user) + if(views.size() == 0) { + return + } + + views.each { ViewingStatus vs -> + if(vs.profile){ + return + } + vs.profile = Profile.findByUser(user) + vs.save() } } } From 1ff6a936cf1e28adb7a5097bb7056b2295e0af96 Mon Sep 17 00:00:00 2001 From: Maximbndrnk Date: Thu, 15 Nov 2018 16:44:25 +0200 Subject: [PATCH 23/47] fix errors: create profile service, remove long ng-if statements --- .../streama/controllers/dash-ctrl.js | 22 +++++++------- .../streama/controllers/subProfiles-ctrl.js | 29 ++++++++++--------- .../streama/services/profile-service.js | 28 ++++++++++++++++++ .../assets/javascripts/streama/streama.run.js | 24 +++++---------- .../streama/templates/sub-profiles.tpl.htm | 10 +++---- .../streama/ViewingStatusController.groovy | 1 - 6 files changed, 66 insertions(+), 48 deletions(-) create mode 100644 grails-app/assets/javascripts/streama/services/profile-service.js diff --git a/grails-app/assets/javascripts/streama/controllers/dash-ctrl.js b/grails-app/assets/javascripts/streama/controllers/dash-ctrl.js index d4d81611d..e84720822 100644 --- a/grails-app/assets/javascripts/streama/controllers/dash-ctrl.js +++ b/grails-app/assets/javascripts/streama/controllers/dash-ctrl.js @@ -13,18 +13,7 @@ angular.module('streama').controller('dashCtrl', $scope.$on('changedGenre', onChangedGenre); - if(!localStorageService.get('currentProfile')){ - apiService.profile.getUserProfiles().success(function(data) { - localStorageService.set('currentProfile', data[0]); - init(); - } - ).error(function (data) { - alertify.error(data.message); - }); - } else { - init(); - } - + init(); function init() { if ($rootScope.currentUser.isAdmin) { @@ -35,6 +24,15 @@ angular.module('streama').controller('dashCtrl', modalService.mediaDetailModal({mediaId: $stateParams.mediaModal, mediaType: $stateParams.mediaType, isApiMovie: false}); } + if(!localStorageService.get('currentProfile')){ + apiService.profile.getUserProfiles().success(function(data) { + localStorageService.set('currentProfile', data[0]); + } + ).error(function (data) { + alertify.error(data.message); + }); + } + vm.movie = mediaListService.init(apiService.dash.listMovies, {sort: 'title', order: 'ASC'}, currentUser.data); vm.tvShow = mediaListService.init(apiService.dash.listShows, {sort: 'name', order: 'ASC'}, currentUser.data); vm.genericVideo = mediaListService.init(apiService.dash.listGenericVideos, {sort: 'title', order: 'ASC'}, currentUser.data); diff --git a/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js b/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js index e01adbae4..610162333 100644 --- a/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js +++ b/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('streama').controller('subProfilesCtrl', - function ($scope, apiService, $rootScope, userService, localStorageService,$state) { + function ($scope, apiService, $rootScope, userService, localStorageService, $state, profileService) { $scope.profile = { profile_name: '', @@ -9,28 +9,23 @@ angular.module('streama').controller('subProfilesCtrl', isKid: false, avatar_color: '0b74b2' }; - $scope.standartColor = '0b74b2'; + $scope.standardColor = '0b74b2'; $scope.existingProfiles = []; $scope.loading = true; $scope.isManageProfiles = false; $scope.isEditProfile = false; $scope.isCreateProfile = false; - $scope.avaliabeColors = [ + $scope.availableColors = [ '0b74b2','ba1c56','099166','d1b805','c03da7', '488f16','d36e10','4b4b4b','3a328b','b81f1f' ]; - - apiService.profile.getUserProfiles() - .success(function (data) { + profileService.getUserProfiles().success( + function(data) { $scope.existingProfiles = data; - }); - - $scope.setCurrentProfile = function(profile) { - localStorageService.set('currentProfile', profile); - $rootScope.currentProfile = profile; - $state.go('dash'); - }; + } + ); + $scope.setCurrentProfile = profileService.setCurrentProfile; $scope.setProfileColor = function(color){ $scope.profile.avatar_color = color; @@ -120,4 +115,12 @@ angular.module('streama').controller('subProfilesCtrl', $scope.loading = false; }); }; + + $scope.showPreviewProfiles = function() { + return !$scope.isManageProfiles && !($scope.isEditProfile || $scope.isCreateProfile); + }; + + $scope.showEditProfiles = function() { + return $scope.isManageProfiles && !($scope.isEditProfile || $scope.isCreateProfile); + } }); diff --git a/grails-app/assets/javascripts/streama/services/profile-service.js b/grails-app/assets/javascripts/streama/services/profile-service.js new file mode 100644 index 000000000..faab20036 --- /dev/null +++ b/grails-app/assets/javascripts/streama/services/profile-service.js @@ -0,0 +1,28 @@ +'use strict'; + +angular.module('streama').factory('profileService', function (localStorageService, apiService, $state, $rootScope) { + + function setCurrentProfile(profile) { + localStorageService.set('currentProfile', profile); + $rootScope.currentProfile = profile; + $state.go('dash', {}, {reload: true}); + } + + function getCurrentProfile() { + if (localStorageService.get('currentProfile')) { + return localStorageService.get('currentProfile'); + } + return null; + } + + function getUserProfiles() { + return apiService.profile.getUserProfiles(); + } + + return { + setCurrentProfile: setCurrentProfile, + getCurrentProfile: getCurrentProfile, + getUserProfiles: getUserProfiles + }; + +}); diff --git a/grails-app/assets/javascripts/streama/streama.run.js b/grails-app/assets/javascripts/streama/streama.run.js index bc8e5b6d0..1309d20e3 100644 --- a/grails-app/assets/javascripts/streama/streama.run.js +++ b/grails-app/assets/javascripts/streama/streama.run.js @@ -1,24 +1,14 @@ -angular.module('streama').run(function ($window, $rootScope, $state, localStorageService, apiService, modalService, userService) { +angular.module('streama').run(function ($window, $rootScope, $state, localStorageService, apiService, modalService, userService, profileService) { apiService.currentUser().success(function (data) { userService.setCurrentUser(data); }); - apiService.profile.getUserProfiles().success(function(data) { - $rootScope.usersProfiles = data; - if(!localStorageService.get('currentProfile')){ - localStorageService.set('currentProfile', data[0]); - $rootScope.currentProfile = data[0]; - } - } - ).error(function (data) { - console.warn(data.message); - }); - - $rootScope.setCurrentSubProfile = function(profile) { - $rootScope.currentProfile = profile; - localStorageService.set('currentProfile', profile) - $state.go('dash',{},{reload:true}); - }; + profileService.getUserProfiles().success( + function(data) { + $rootScope.usersProfiles = data; + $rootScope.currentProfile = profileService.getCurrentProfile() || $rootScope.usersProfiles[0]; + }); + $rootScope.setCurrentSubProfile = profileService.setCurrentProfile; $rootScope.baseData = {}; $rootScope.isCurrentState = function (stateName) { diff --git a/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm b/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm index 3e88d8105..dbbfb0809 100644 --- a/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm +++ b/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm @@ -1,10 +1,10 @@
    -
    +

    Who's watching?

    -
    +

    {{subp.profile_name}}

    @@ -31,12 +31,12 @@
    -
    +

    Manage profiles:

    -
    +
    @@ -75,7 +75,7 @@
    diff --git a/grails-app/controllers/streama/ViewingStatusController.groovy b/grails-app/controllers/streama/ViewingStatusController.groovy index 5e22a8aa5..fe9d12b4b 100644 --- a/grails-app/controllers/streama/ViewingStatusController.groovy +++ b/grails-app/controllers/streama/ViewingStatusController.groovy @@ -25,7 +25,6 @@ class ViewingStatusController { Long profileId = request.getHeader('profileId')?.toLong() Profile profile = Profile.findById(profileId) params['profile'] = profile - log.debug("profile: ${profile}") try{ result = viewingStatusService.createNew(params) }catch(e){ From 121ebc7615f5f3fe489e47aa73b6a738ff992b73 Mon Sep 17 00:00:00 2001 From: Maximbndrnk Date: Thu, 15 Nov 2018 17:13:37 +0200 Subject: [PATCH 24/47] fix errors: some styles corrections --- .../streama/templates/sub-profiles.tpl.htm | 2 +- grails-app/assets/stylesheets/_btn.scss | 16 +- grails-app/assets/stylesheets/_main.scss | 14 + .../assets/stylesheets/_subprofiles.scss | 396 ++++++++---------- grails-app/assets/stylesheets/_variables.scss | 4 + grails-app/views/templates/_header.gsp | 2 +- 6 files changed, 215 insertions(+), 219 deletions(-) diff --git a/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm b/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm index dbbfb0809..f8a366044 100644 --- a/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm +++ b/grails-app/assets/javascripts/streama/templates/sub-profiles.tpl.htm @@ -70,7 +70,7 @@
    -
    +
    diff --git a/grails-app/assets/stylesheets/_btn.scss b/grails-app/assets/stylesheets/_btn.scss index c1dec1be3..7df52e07f 100644 --- a/grails-app/assets/stylesheets/_btn.scss +++ b/grails-app/assets/stylesheets/_btn.scss @@ -119,6 +119,18 @@ } -.margin-bottom-for-btn { - margin-bottom: 10px; +.header-btn { + display: flex; + align-items: center; + justify-content: center; + background-color: transparent; + border-color: transparent; + p { + margin: 0 4px; + } + + &:hover, &:focus { + background-color: rgba(255,255,255, 0.12); + border-color: transparent; + } } diff --git a/grails-app/assets/stylesheets/_main.scss b/grails-app/assets/stylesheets/_main.scss index 91cd7789c..4c41f0d64 100644 --- a/grails-app/assets/stylesheets/_main.scss +++ b/grails-app/assets/stylesheets/_main.scss @@ -82,6 +82,20 @@ header.main{ } } } + + .avatar-in-header { + width: 30px; + height: 30px; + box-sizing: border-box; + display: flex; + align-items: center; + justify-content: center; + + img { + z-index: 100; + width: 30px; + } + } } diff --git a/grails-app/assets/stylesheets/_subprofiles.scss b/grails-app/assets/stylesheets/_subprofiles.scss index c584931ca..a45eb799b 100644 --- a/grails-app/assets/stylesheets/_subprofiles.scss +++ b/grails-app/assets/stylesheets/_subprofiles.scss @@ -1,10 +1,6 @@ -$grey-text: #a6a6a6; $border-color: rgba(166, 166, 166, 0.3); -$light-gray: lighten($grey-text, 40%); $avatar-width: 130px; $background-color: #25292B; -$logo-color: #b0ddef; -$color-box-size: 30px; .sub-profile-page-container { width: 100%; @@ -12,275 +8,245 @@ $color-box-size: 30px; display: flex; align-items: center; justify-content: center; -} - -.profiles-container { - max-width: 62%; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; -} - -.who-watching-header { - font-size: 32px; - color: white; -} -.manage-profiles-btn { - text-transform: uppercase; - color: $grey-text; - border: 1px solid $grey-text; - height: 40px; - font-size: 15px; - letter-spacing: 1.5px; - background-color: transparent; - padding: 0 20px; - - &:hover { - color: $light-gray; - border: 1px solid $light-gray; - cursor: pointer; + .profiles-container { + max-width: 62%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; } -} + .who-watching-header { + font-size: 32px; + color: white; + } -.done-btn { - @extend .manage-profiles-btn; - color: $background-color; - background-color: white; - font-weight: bold; + .manage-profiles-btn { + text-transform: uppercase; + color: $grey-text; + border: 1px solid $grey-text; + height: 40px; + font-size: 15px; + letter-spacing: 1.5px; + background-color: transparent; + padding: 0 20px; + + &:hover { + color: $light-gray; + border: 1px solid $light-gray; + cursor: pointer; + } - &:hover { - background-color: $logo-color; - border: 1px solid $logo-color; - color: $background-color; } -} -.select-profile-container { - display: flex; - flex-wrap: wrap; - align-items: center; - justify-content: center; - margin: 10px 0; -} + .done-btn { + @extend .manage-profiles-btn; + color: $background-color; + background-color: white; + font-weight: bold; -.item-profile-container { - width: $avatar-width; - display: flex; - flex-direction: column; - margin: 0 5px; + &:hover { + background-color: $logo-color; + border: 1px solid $logo-color; + color: $background-color; + } + } - .avatar { - box-sizing: border-box; - min-width: 100%; - border: 3px solid transparent; + .select-profile-container { display: flex; + flex-wrap: wrap; align-items: center; justify-content: center; - height: $avatar-width; - img { - z-index: 100; - width: $avatar-width; - } - - p.add { - color: $grey-text; - font-size: 40px; - font-weight: 600; - } + margin: 10px 0; } - .profile-name { - margin-top: 10px; - color: $grey-text; - font-size: 13px; - min-width: 100%; - text-align: center; - } + .item-profile-container { + width: $avatar-width; + display: flex; + flex-direction: column; + margin: 0 5px; - &:hover { - cursor: pointer; .avatar { - border: 3px solid $light-gray; + box-sizing: border-box; + min-width: 100%; + border: 3px solid transparent; + display: flex; + align-items: center; + justify-content: center; + height: $avatar-width; + img { + z-index: 100; + width: $avatar-width; + } + + p.add { + color: $grey-text; + font-size: 40px; + font-weight: 600; + } } .profile-name { - color: $light-gray; + margin-top: 10px; + color: $grey-text; + font-size: 13px; + min-width: 100%; + text-align: center; } - } -} + &:hover { + cursor: pointer; + .avatar { + border: 3px solid $light-gray; + } -.add-profile { - @extend .item-profile-container; - &:hover { - .avatar { - background-color: $light-gray !important; - p.add { - color: $background-color !important; + .profile-name { + color: $light-gray; } + } + } + .add-profile { + @extend .item-profile-container; + &:hover { + .avatar { + background-color: $light-gray !important; + p.add { + color: $background-color !important; + } + } + + } } -} -.item-editable-container { - @extend .item-profile-container; - position: relative; + .item-editable-container { + @extend .item-profile-container; + position: relative; + + &:hover { + .grey-editable-avatar { + border: 3px solid $light-gray; + opacity: .8; + } + + .edit-label-container { + p { + display: flex; + color: $light-gray; + } + } + + } - &:hover { .grey-editable-avatar { - border: 3px solid $light-gray; - opacity: .8; + z-index: 200; + box-sizing: border-box; + border: 3px solid transparent; + display: flex; + align-items: center; + justify-content: center; + width: $avatar-width; + height: $avatar-width; + position: absolute; + background-color: #000; + opacity: .4; } .edit-label-container { + z-index: 400; + position: absolute; + display: flex; + align-items: center; + width: $avatar-width; + height: $avatar-width; + justify-content: center; p { - display: flex; - color: $light-gray; + color: $grey-text; + display: none; + text-transform: uppercase; + font-size: 18px; + font-weight: bold; + letter-spacing: 1.5px; } } - } - .grey-editable-avatar { - z-index: 200; - box-sizing: border-box; - border: 3px solid transparent; + .btns-container { display: flex; - align-items: center; - justify-content: center; - width: $avatar-width; - height: $avatar-width; - position: absolute; - background-color: #000; - opacity: .4; - } - - .edit-label-container { - z-index: 400; - position: absolute; - display: flex; - align-items: center; - width: $avatar-width; - height: $avatar-width; - justify-content: center; - p { - color: $grey-text; - display: none; - text-transform: uppercase; - font-size: 18px; - font-weight: bold; - letter-spacing: 1.5px; + justify-content: flex-start; + button { + margin-right: 10px; } } -} - -.btns-container { - display: flex; - justify-content: flex-start; - button { - margin-right: 10px; - } -} - -.form-container { - width: 100%; - display: flex; - flex-direction: column; - justify-content: flex-start; - align-items: center; - margin: 20px 0; - padding: 15px 0; - border-bottom: 1px solid $border-color; - border-top: 1px solid $border-color; - > * { - margin-bottom: 10px; - } - - .choose-avatar-color { + .form-container { width: 100%; display: flex; + flex-direction: column; justify-content: flex-start; align-items: center; - .form-avatar { - width: $avatar-width; - display: flex; - justify-content: center; - align-items: center; - height: $avatar-width; + margin: 20px 0; + padding: 15px 0; + border-bottom: 1px solid $border-color; + border-top: 1px solid $border-color; - img { - z-index: 100; - max-width: $avatar-width; - } + > * { + margin-bottom: 10px; } - .colors-container { + + .choose-avatar-color { + width: 100%; display: flex; - flex-wrap: wrap; - justify-content: center; + justify-content: flex-start; align-items: center; - width: 200px; - height: $avatar-width; - - .single-color { - width: $color-box-size; - height: $color-box-size; - margin: 3px; + .form-avatar { + width: $avatar-width; + display: flex; + justify-content: center; + align-items: center; + height: $avatar-width; - &:hover { - cursor: pointer; + img { + z-index: 100; + max-width: $avatar-width; } - - } - } - } -} + .colors-container { + display: flex; + flex-wrap: wrap; + justify-content: center; + align-items: center; + width: 200px; + height: $avatar-width; -.is-kid-container { - display: flex; - align-items: center; - width: 100%; - input { - margin: 0 15px 0 0; - } + .single-color { + width: $color-box-size; + height: $color-box-size; + margin: 3px; - p { - margin: 0; - font-size: 18px; - } -} + &:hover { + cursor: pointer; + } -.avatar-in-header { - width: 30px; - height: 30px; - box-sizing: border-box; - display: flex; - align-items: center; - justify-content: center; - img { - z-index: 100; - width: 30px; + } + } + } } -} -.header-btn { - display: flex; - align-items: center; - justify-content: center; - background-color: transparent; - border-color: transparent; - * { - margin: 0 4px !important; - } + .is-kid-container { + display: flex; + align-items: center; + width: 100%; + input { + margin: 0 15px 0 0; + } - &:hover, &:focus { - background-color: rgba(255,255,255, 0.12); - border-color: transparent; + p { + margin: 0; + font-size: 18px; + } } } diff --git a/grails-app/assets/stylesheets/_variables.scss b/grails-app/assets/stylesheets/_variables.scss index d60d00c1c..41a1d4512 100644 --- a/grails-app/assets/stylesheets/_variables.scss +++ b/grails-app/assets/stylesheets/_variables.scss @@ -3,3 +3,7 @@ $secondary: darken($primary, 45%); $grey-blue: #414c50; $success: #05946F; $danger: #CE2F39; +$grey-text: #a6a6a6; +$light-gray: lighten($grey-text, 40%); +$logo-color: #b0ddef; +$color-box-size: 30px; diff --git a/grails-app/views/templates/_header.gsp b/grails-app/views/templates/_header.gsp index ae2ee3139..98746b504 100644 --- a/grails-app/views/templates/_header.gsp +++ b/grails-app/views/templates/_header.gsp @@ -64,7 +64,7 @@
    - {{$root.currentProfile.profile_name || $root.currentUser.fullName || $root.currentUser.username}} +

    {{$root.currentProfile.profile_name || $root.currentUser.fullName || $root.currentUser.username}}

    From 1bfaddf711f9faaf88157fa53b734ea0fcac5ad8 Mon Sep 17 00:00:00 2001 From: dularion Date: Thu, 29 Nov 2018 20:01:00 +0100 Subject: [PATCH 44/47] refactor: extract loadAndInitProfiles as method in streama.run.js --- .../assets/javascripts/streama/streama.run.js | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/grails-app/assets/javascripts/streama/streama.run.js b/grails-app/assets/javascripts/streama/streama.run.js index 172355e96..75d855cb4 100644 --- a/grails-app/assets/javascripts/streama/streama.run.js +++ b/grails-app/assets/javascripts/streama/streama.run.js @@ -1,15 +1,12 @@ -angular.module('streama').run(function ($window, $rootScope, $state, localStorageService, apiService, modalService, userService, profileService, $translate) { +angular.module('streama') + .run(function ($window, $rootScope, $state, localStorageService, apiService, modalService, + userService, profileService, $translate) { + apiService.currentUser().success(function (data) { userService.setCurrentUser(data); }); - profileService.getUserProfiles().success( - function(data) { - $rootScope.usersProfiles = data; - $rootScope.currentProfile = profileService.getCurrentProfile() || $rootScope.usersProfiles[0]; - $translate.use(_.get($rootScope, 'currentProfile.profileLanguage') || _.get($rootScope, 'currentUser.language') || 'en') - }); - $rootScope.setCurrentSubProfile = profileService.setCurrentProfile; + loadAndInitProfiles(); $rootScope.baseData = {}; $rootScope.isCurrentState = function (stateName) { @@ -61,4 +58,15 @@ angular.module('streama').run(function ($window, $rootScope, $state, localStorag localStorageService.set('originUrl', location.href); } }); + + + function loadAndInitProfiles() { + profileService.getUserProfiles().success( + function(data) { + $rootScope.usersProfiles = data; + $rootScope.currentProfile = profileService.getCurrentProfile() || $rootScope.usersProfiles[0]; + $translate.use(_.get($rootScope, 'currentProfile.profileLanguage') || _.get($rootScope, 'currentUser.language') || 'en') + }); + $rootScope.setCurrentSubProfile = profileService.setCurrentProfile; + } }); From 4b1d34e818f9060fdfd29042d8516f1472778c66 Mon Sep 17 00:00:00 2001 From: dularion Date: Thu, 29 Nov 2018 20:03:54 +0100 Subject: [PATCH 45/47] refactor: consolidate duplicate code in subProfiles#saveProfile --- .../streama/controllers/subProfiles-ctrl.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js b/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js index 086790b91..fe274bfcc 100644 --- a/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js +++ b/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js @@ -84,22 +84,15 @@ angular.module('streama').controller('subProfilesCtrl', if (!$scope.profile.profileName) { return; } + var saveProfileEndpoint; if ($scope.profile.id) { - apiService.profile.update($scope.profile) - .success(function () { - alertify.success('Profile Updated!'); - $scope.getAllProfiles(); - $scope.loading = false; - }) - .error(function (data) { - alertify.error(data.message); - $scope.loading = false; - }); - return; + saveProfileEndpoint = apiService.profile.update; + }else { + saveProfileEndpoint = apiService.profile.save; } - apiService.profile.save($scope.profile) + saveProfileEndpoint($scope.profile) .success(function () { - alertify.success('Profile Created!'); + alertify.success($scope.profile.id ? 'Profile Updated!' : 'Profile Created!'); $scope.getAllProfiles(); $scope.loading = false; }) From bfdf0bb93e6f3db4b3b1f01543c90c4ed50eaecc Mon Sep 17 00:00:00 2001 From: dularion Date: Thu, 29 Nov 2018 20:05:29 +0100 Subject: [PATCH 46/47] add broadcast for any profiles changes so that the profile selector reinits --- .../assets/javascripts/streama/controllers/subProfiles-ctrl.js | 1 + grails-app/assets/javascripts/streama/streama.run.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js b/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js index fe274bfcc..ad116d3fe 100644 --- a/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js +++ b/grails-app/assets/javascripts/streama/controllers/subProfiles-ctrl.js @@ -95,6 +95,7 @@ angular.module('streama').controller('subProfilesCtrl', alertify.success($scope.profile.id ? 'Profile Updated!' : 'Profile Created!'); $scope.getAllProfiles(); $scope.loading = false; + $rootScope.$broadcast('streama.profiles.onChange'); }) .error(function (data) { alertify.error(data.message); diff --git a/grails-app/assets/javascripts/streama/streama.run.js b/grails-app/assets/javascripts/streama/streama.run.js index 75d855cb4..18113ba76 100644 --- a/grails-app/assets/javascripts/streama/streama.run.js +++ b/grails-app/assets/javascripts/streama/streama.run.js @@ -40,6 +40,8 @@ angular.module('streama') } }; + $rootScope.$on('streama.profiles.onChange', loadAndInitProfiles); + $rootScope.changeGenre = function (genre) { $rootScope.toggleGenreMenu(true); From f33967ba64149e366ce1c2ff0a030236df6ed14b Mon Sep 17 00:00:00 2001 From: dularion Date: Thu, 29 Nov 2018 20:23:53 +0100 Subject: [PATCH 47/47] add Genre restriction based on Child Profiles --- .../controllers/streama/DashController.groovy | 37 +++++++++++++++++-- grails-app/domain/streama/User.groovy | 13 +++++++ .../services/streama/VideoService.groovy | 25 +++++++++---- 3 files changed, 64 insertions(+), 11 deletions(-) diff --git a/grails-app/controllers/streama/DashController.groovy b/grails-app/controllers/streama/DashController.groovy index bf58e00d6..44f1855b1 100644 --- a/grails-app/controllers/streama/DashController.groovy +++ b/grails-app/controllers/streama/DashController.groovy @@ -81,14 +81,18 @@ class DashController { def listGenericVideos(){ - def genreId = params.long('genreId') + List genreIds = params.list('genreId')*.toLong() ?: [] + Profile currentProfile = User.getProfileFromRequest() + if(currentProfile?.isChild){ + genreIds += Genre.findAllByNameInList(['Kids', 'Family'])*.id + } def genericVideoQuery = GenericVideo.where { deleted != true isNotEmpty("files") - if(genreId){ + if(genreIds){ genre{ - id == genreId + id in genreIds } } } @@ -131,8 +135,33 @@ class DashController { } def listNewReleases(){ + List genreIds + Profile currentProfile = User.getProfileFromRequest() + if(currentProfile?.isChild){ + genreIds = Genre.findAllByNameInList(['Kids', 'Family'])*.id + } + List newReleasesList = NotificationQueue.where{ + type == 'newRelease' + + if(genreIds){ + or{ + tvShow{ + genre{ + 'in'('id', genreIds) + } + } + movie{ + genre{ + 'in'('id', genreIds) + } + } + } + } + }.list() + newReleasesList = newReleasesList.sort { new Random(System.nanoTime()) } + JSON.use('dashMovies'){ - respond NotificationQueue.findAllByType('newRelease').sort{new Random(System.nanoTime())} + respond newReleasesList } } diff --git a/grails-app/domain/streama/User.groovy b/grails-app/domain/streama/User.groovy index 1e3f44c9e..836c3ba9e 100644 --- a/grails-app/domain/streama/User.groovy +++ b/grails-app/domain/streama/User.groovy @@ -1,5 +1,7 @@ package streama +import org.grails.web.util.WebUtils + import static java.util.UUID.randomUUID class User { @@ -68,4 +70,15 @@ class User { protected void encodePassword() { password = springSecurityService?.passwordEncoder ? springSecurityService.encodePassword(password) : password } + + static Profile getProfileFromRequest(){ + def request = WebUtils.retrieveGrailsWebRequest()?.getCurrentRequest() + if(!request){ + return + } + def profileId = request.getHeader("profileId") + def currentProfile = Profile.get(profileId) + + return currentProfile + } } diff --git a/grails-app/services/streama/VideoService.groovy b/grails-app/services/streama/VideoService.groovy index 704f68db3..328a589f2 100644 --- a/grails-app/services/streama/VideoService.groovy +++ b/grails-app/services/streama/VideoService.groovy @@ -2,6 +2,7 @@ package streama import grails.transaction.Transactional import grails.web.servlet.mvc.GrailsParameterMap +import org.grails.web.util.WebUtils import java.nio.file.Files import java.nio.file.Paths @@ -108,12 +109,17 @@ class VideoService { def listMovies(GrailsParameterMap params, Map options){ - def max = params.int('max', 50) - def offset = params.int('offset', 0) - def sort = params.sort - def order = params.order - def genreId = params.long('genreId') - def genreList = params.list('genre')*.toLong() + Profile currentProfile = User.getProfileFromRequest() + Integer max = params.int('max', 50) + Integer offset = params.int('offset', 0) + String sort = params.sort + String order = params.order + Long genreId = params.long('genreId') + List genreList = params.list('genre')*.toLong() ?: [] + + if(currentProfile?.isChild){ + genreList += Genre.findAllByNameInList(['Kids', 'Family'])*.id + } def movieQuery = Movie.where { deleted != true @@ -145,12 +151,17 @@ class VideoService { def listShows(GrailsParameterMap params, Map options){ + Profile currentProfile = User.getProfileFromRequest() def max = params.int('max', 50) def offset = params.int('offset', 0) def sort = params.sort def order = params.order def genreId = params.long('genreId') - def genreList = params.list('genre')*.toLong() + def genreList = params.list('genre')*.toLong() ?: [] + + if(currentProfile?.isChild){ + genreList += Genre.findAllByNameInList(['Kids', 'Family'])*.id + } def tvShowQuery = TvShow.where{ def tv1 = TvShow