Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
cards
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Curtis Adam
cards
Commits
d190e334
Commit
d190e334
authored
Jun 13, 2019
by
Curtis Adam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hide notification settings in the frontend if they got disabled by the server
parent
e84cfc1f
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
96 additions
and
57 deletions
+96
-57
imports/api/bonus.js
imports/api/bonus.js
+3
-2
imports/api/settings.js
imports/api/settings.js
+11
-0
imports/api/webPushSubscriptions.js
imports/api/webPushSubscriptions.js
+2
-6
imports/startup/client/registerhelper.js
imports/startup/client/registerhelper.js
+17
-0
imports/ui/admin/settings/settings.js
imports/ui/admin/settings/settings.js
+3
-2
imports/ui/cardset/index/bonus/bonus.html
imports/ui/cardset/index/bonus/bonus.html
+7
-3
imports/ui/cardset/index/bonus/modal/removeUser.html
imports/ui/cardset/index/bonus/modal/removeUser.html
+8
-4
imports/ui/profile/view/settings.html
imports/ui/profile/view/settings.html
+33
-23
imports/ui/profile/view/settings.js
imports/ui/profile/view/settings.js
+9
-2
server/leitner.js
server/leitner.js
+3
-15
No files found.
imports/api/bonus.js
View file @
d190e334
import
{
Cardsets
}
from
"
./cardsets
"
;
import
{
Meteor
}
from
"
meteor/meteor
"
;
import
{
Workload
}
from
"
./learned
"
;
import
{
ServerSettings
}
from
"
./settings
"
;
export
let
Bonus
=
class
Bonus
{
static
isInBonus
(
cardset_id
,
user_id
=
undefined
)
{
...
...
@@ -33,14 +34,14 @@ export let Bonus = class Bonus {
static
getNotificationStatus
(
user
,
isCSVExport
=
false
)
{
let
notifications
=
""
;
if
(
user
.
mailNotification
)
{
if
(
ServerSettings
.
isMailEnabled
()
&&
user
.
mailNotification
)
{
if
(
isCSVExport
)
{
notifications
+=
TAPi18n
.
__
(
'
leitnerProgress.notification.mail
'
,
{},
"
de
"
);
}
else
{
notifications
+=
"
<i class='fa fa-envelope'>
"
+
TAPi18n
.
__
(
'
leitnerProgress.notification.mail
'
)
+
"
</i>
"
;
}
}
if
(
user
.
webNotification
)
{
if
(
ServerSettings
.
isPushEnabled
()
&&
user
.
webNotification
)
{
if
(
notifications
!==
""
)
{
notifications
+=
"
&
"
;
}
...
...
imports/api/settings.js
View file @
d190e334
import
{
Meteor
}
from
"
meteor/meteor
"
;
import
{
AdminSettings
}
from
"
./adminSettings
"
;
export
const
Categories
=
new
TAPi18n
.
Collection
(
"
settings
"
);
...
...
@@ -7,3 +8,13 @@ if (Meteor.isServer) {
return
Categories
.
find
();
});
}
export
let
ServerSettings
=
class
ServerSettings
{
static
isMailEnabled
()
{
return
AdminSettings
.
findOne
({
name
:
"
mailSettings
"
}).
enabled
;
}
static
isPushEnabled
()
{
return
AdminSettings
.
findOne
({
name
:
"
pushSettings
"
}).
enabled
;
}
};
imports/api/webPushSubscriptions.js
View file @
d190e334
import
{
Meteor
}
from
"
meteor/meteor
"
;
import
{
Mongo
}
from
"
meteor/mongo
"
;
import
webPush
from
'
web-push
'
;
import
{
AdminSettings
}
from
"
./adminS
ettings
"
;
import
{
ServerSettings
}
from
"
./s
ettings
"
;
export
const
WebPushSubscriptions
=
new
Mongo
.
Collection
(
"
webPushSubscriptions
"
);
...
...
@@ -13,7 +13,7 @@ export let WebPushNotifications = class WebPushNotifications {
* Meteor-method addWebPushSubscription.
*/
static
subscribeForPushNotification
()
{
if
(
thi
s
.
isPushEnabled
())
{
if
(
ServerSetting
s
.
isPushEnabled
())
{
try
{
if
(
navigator
.
serviceWorker
!==
undefined
)
{
navigator
.
serviceWorker
.
getRegistration
()
...
...
@@ -48,10 +48,6 @@ export let WebPushNotifications = class WebPushNotifications {
}
}
}
static
isPushEnabled
()
{
return
AdminSettings
.
findOne
({
name
:
"
pushSettings
"
}).
enabled
;
}
};
Meteor
.
methods
({
...
...
imports/startup/client/registerhelper.js
View file @
d190e334
...
...
@@ -29,6 +29,7 @@ import {MainNavigation} from "../../api/mainNavigation";
import
{
BarfyStarsConfig
}
from
"
../../api/barfyStars.js
"
;
import
{
Utilities
}
from
"
../../api/utilities
"
;
import
{
TranscriptBonus
}
from
"
../../api/transcriptBonus
"
;
import
{
ServerSettings
}
from
"
../../api/settings
"
;
Meteor
.
subscribe
(
"
collegesCourses
"
);
...
...
@@ -196,6 +197,22 @@ Template.registerHelper('getNavigationName', function (name = undefined) {
}
});
Template
.
registerHelper
(
'
isNotificationEnabled
'
,
function
()
{
return
ServerSettings
.
isPushEnabled
()
||
ServerSettings
.
isMailEnabled
();
});
Template
.
registerHelper
(
'
isNotificationEnabled
'
,
function
()
{
return
ServerSettings
.
isPushEnabled
()
||
ServerSettings
.
isMailEnabled
();
});
Template
.
registerHelper
(
'
isMailEnabled
'
,
function
()
{
return
ServerSettings
.
isMailEnabled
();
});
Template
.
registerHelper
(
'
isPushEnabled
'
,
function
()
{
return
ServerSettings
.
isPushEnabled
();
});
Template
.
registerHelper
(
'
isPublicRoute
'
,
function
()
{
return
Route
.
isPublic
();
});
...
...
imports/ui/admin/settings/settings.js
View file @
d190e334
import
{
Meteor
}
from
"
meteor/meteor
"
;
import
{
AdminSettings
}
from
"
../../../api/adminSettings.js
"
;
import
"
./settings.html
"
;
import
{
ServerSettings
}
from
"
../../../api/settings
"
;
Template
.
admin_settings
.
events
({
'
click #enableWordcloudPomodoro
'
:
function
()
{
...
...
@@ -73,10 +74,10 @@ Template.admin_settings.helpers({
return
AdminSettings
.
findOne
({
name
:
"
wordcloudPomodoroSettings
"
}).
enabled
;
},
isMailEnabled
:
function
()
{
return
AdminSettings
.
findOne
({
name
:
"
mailSettings
"
}).
enabled
;
return
ServerSettings
.
isMailEnabled
()
;
},
isPushEnabled
:
function
()
{
return
AdminSettings
.
findOne
({
name
:
"
pushSettings
"
}).
enabled
;
return
ServerSettings
.
isPushEnabled
()
;
},
getNotificationTargetText
:
function
()
{
let
user
=
Meteor
.
users
.
findOne
({
_id
:
AdminSettings
.
findOne
({
name
:
"
testNotifications
"
}).
target
});
...
...
imports/ui/cardset/index/bonus/bonus.html
View file @
d190e334
...
...
@@ -33,8 +33,10 @@
<th>
{{_ "panel-body.givenname"}}
</th>
<th>
{{_ "panel-body.email"}}
</th>
<th>
{{_ "confirmLearn-form.notification"}}
</th>
{{#if isNotificationEnabled}}
<th>
{{_ "confirmLearn-form.notification"}}
</th>
{{/if}}
<th>
{{_ "leitnerProgress.box" number=1}} [{{this.learningInterval.[0]}}]
</th>
<th>
{{_ "leitnerProgress.box" number=2}} [{{this.learningInterval.[1]}}]
...
...
@@ -54,7 +56,9 @@
<td>
{{this.birthname}}
</td>
<td>
{{this.givenname}}
</td>
<td><a
href=
"mailto:{{this.email}}"
>
{{this.email}}
</a></td>
<td>
{{{getNotificationStatus this}}}
</td>
{{#if isNotificationEnabled}}
<td>
{{{getNotificationStatus this}}}
</td>
{{/if}}
<td>
{{this.box1}}
</td>
<td>
{{this.box2}}
</td>
<td>
{{this.box3}}
</td>
...
...
imports/ui/cardset/index/bonus/modal/removeUser.html
View file @
d190e334
...
...
@@ -20,7 +20,9 @@
<th>
{{_ "panel-body.birthname"}}
</th>
<th>
{{_ "panel-body.givenname"}}
</th>
<th>
{{_ "panel-body.email"}}
</th>
<th>
{{_ "confirmLearn-form.notification"}}
</th>
{{#if isNotificationEnabled}}
<th>
{{_ "confirmLearn-form.notification"}}
</th>
{{/if}}
<th>
{{_ "leitnerProgress.box" number=1}}
</th>
<th>
{{_ "leitnerProgress.box" number=2}}
</th>
<th>
{{_ "leitnerProgress.box" number=3}}
</th>
...
...
@@ -38,9 +40,11 @@
<td>
{{this.email}}
</td>
<td>
{{{getNotificationStatus this}}}
</td>
{{#if isNotificationEnabled}}
<td>
{{{getNotificationStatus this}}}
</td>
{{/if}}
<td>
{{this.box1}}
</td>
...
...
imports/ui/profile/view/settings.html
View file @
d190e334
...
...
@@ -74,30 +74,40 @@
<span
id=
"errorGivenName"
class=
"help-block name"
></span>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-md-4 control-label"
>
{{_ "confirmLearn-form.notification"}}
</label>
<form>
<fieldset>
<div
class=
"col-md-9 form-group notifications-form-group"
>
<div
class=
"col-sm-6"
style=
"{{#if isSocialLogin}}display: none;{{/if}}"
>
<label
class=
"checkbox-inline"
for=
"mailNotificationCheckbox"
>
<input
type=
"checkbox"
name=
"notification"
id=
"mailNotificationCheckbox"
{{
getMailNotifications
}}
>
{{_ "confirmLearn-form.mailNotificationCheckbox"}}
</label>
</div>
<div
class=
"col-sm-6"
>
<label
class=
"checkbox-inline"
for=
"webNotificationCheckbox"
>
<input
type=
"checkbox"
name=
"notification"
id=
"webNotificationCheckbox"
{{
getWebNotifications
}}
>
{{_ "confirmLearn-form.webNotificationCheckbox"}}
</label>
{{#if isNotificationEnabled}}
<div
class=
"form-group"
>
<label
class=
"col-md-4 control-label"
>
{{_ "confirmLearn-form.notification"}}
</label>
<form>
<fieldset>
<div
class=
"col-md-9 form-group notifications-form-group"
>
{{#if isMailEnabled}}
<div
class=
"col-sm-6"
style=
"{{#if isSocialLogin}}display: none;{{/if}}"
>
<label
class=
"checkbox-inline"
for=
"mailNotificationCheckbox"
>
<input
type=
"checkbox"
name=
"notification"
id=
"mailNotificationCheckbox"
{{
getMailNotifications
}}
>
{{_ "confirmLearn-form.mailNotificationCheckbox"}}
</label>
</div>
{{/if}}
{{#if isPushEnabled}}
<div
class=
"col-sm-6"
>
<label
class=
"checkbox-inline"
for=
"webNotificationCheckbox"
>
<input
type=
"checkbox"
name=
"notification"
id=
"webNotificationCheckbox"
{{
getWebNotifications
}}
>
{{_ "confirmLearn-form.webNotificationCheckbox"}}
</label>
</div>
{{/if}}
</div>
</div>
</fieldset>
</form>
</div>
</fieldset>
</form>
</div>
{{else}}
<br>
{{/if}}
<button
id=
"profileCancel"
type=
"button"
class=
"btn btn-default btn-raised profileSave"
data-id=
"disabled"
>
{{_
...
...
imports/ui/profile/view/settings.js
View file @
d190e334
...
...
@@ -6,6 +6,7 @@ import {Session} from "meteor/session";
import
{
ColorThemes
}
from
"
../../../api/theme
"
;
import
{
BertAlertVisuals
}
from
"
../../../api/bertAlertVisuals
"
;
import
"
./settings.html
"
;
import
{
ServerSettings
}
from
"
../../../api/settings
"
;
/*
* ############################################################################
...
...
@@ -229,8 +230,14 @@ Template.profileSettings.events({
// Name validation
let
user_id
=
Meteor
.
userId
();
if
(
validEmail
&&
validBirthName
&&
validGivenName
)
{
let
mailNotification
=
document
.
getElementById
(
'
mailNotificationCheckbox
'
).
checked
;
let
webNotification
=
document
.
getElementById
(
'
webNotificationCheckbox
'
).
checked
;
let
mailNotification
=
Meteor
.
user
().
mailNotification
;
if
(
ServerSettings
.
isMailEnabled
())
{
mailNotification
=
document
.
getElementById
(
'
mailNotificationCheckbox
'
).
checked
;
}
let
webNotification
=
Meteor
.
user
().
webNotification
;
if
(
ServerSettings
.
isPushEnabled
())
{
webNotification
=
document
.
getElementById
(
'
webNotificationCheckbox
'
).
checked
;
}
$
(
'
#inputEmailValidation
'
).
val
(
''
);
$
(
'
#inputEmailValidationForm
'
).
addClass
(
"
hidden
"
);
Session
.
set
(
"
profileSettingsSave
"
,
true
);
...
...
server/leitner.js
View file @
d190e334
...
...
@@ -4,20 +4,8 @@ import {Cardsets} from "../imports/api/cardsets";
import
{
MailNotifier
}
from
"
./sendmail.js
"
;
import
{
WebNotifier
}
from
"
./sendwebpush.js
"
;
import
{
Bonus
}
from
"
../imports/api/bonus
"
;
import
{
AdminSettings
}
from
"
../imports/api/adminSettings.js
"
;
import
{
LeitnerUtilities
}
from
"
../imports/api/leitner
"
;
import
{
WebPushSubscriptions
}
from
"
../imports/api/webPushSubscriptions
"
;
/** Function checks if mail notifications are globally disabled by the admin
* @returns {boolean} - Mail notifications are globally enabled / disabled
* */
function
mailsEnabled
()
{
if
(
!
Meteor
.
isServer
)
{
throw
new
Meteor
.
Error
(
"
not-authorized
"
);
}
else
{
return
AdminSettings
.
findOne
({
name
:
"
mailSettings
"
}).
enabled
;
}
}
import
{
ServerSettings
}
from
"
../imports/api/settings
"
;
/** Function gets called when the learning-phase ended and excludes the cardset from the leitner algorithm
* @param {Object} cardset - The cardset from the active learning-phase
...
...
@@ -132,7 +120,7 @@ Meteor.methods({
},
prepareMail
:
function
(
cardset
,
user
,
isReset
=
false
,
isNewcomer
=
false
)
{
if
(
Meteor
.
isServer
)
{
if
(
user
.
mailNotification
&&
mails
Enabled
()
&&
!
isNewcomer
&&
Roles
.
userIsInRole
(
user
.
_id
,
[
'
admin
'
,
'
editor
'
,
'
university
'
,
'
lecturer
'
,
'
pro
'
])
&&
!
Roles
.
userIsInRole
(
user
.
_id
,
[
'
blocked
'
,
'
firstLogin
'
]))
{
if
(
user
.
mailNotification
&&
ServerSettings
.
isMail
Enabled
()
&&
!
isNewcomer
&&
Roles
.
userIsInRole
(
user
.
_id
,
[
'
admin
'
,
'
editor
'
,
'
university
'
,
'
lecturer
'
,
'
pro
'
])
&&
!
Roles
.
userIsInRole
(
user
.
_id
,
[
'
blocked
'
,
'
firstLogin
'
]))
{
try
{
if
(
isReset
)
{
if
(
Meteor
.
settings
.
debug
.
leitner
)
{
...
...
@@ -153,7 +141,7 @@ Meteor.methods({
},
prepareWebpush
:
function
(
cardset
,
user
,
isNewcomer
=
false
)
{
if
(
Meteor
.
isServer
)
{
if
(
WebPushSubscription
s
.
isPushEnabled
()
&&
(
Bonus
.
isInBonus
(
cardset
.
_id
,
user
.
_id
)
||
user
.
webNotification
)
&&
!
isNewcomer
)
{
if
(
ServerSetting
s
.
isPushEnabled
()
&&
(
Bonus
.
isInBonus
(
cardset
.
_id
,
user
.
_id
)
||
user
.
webNotification
)
&&
!
isNewcomer
)
{
try
{
let
web
=
new
WebNotifier
();
if
(
Meteor
.
settings
.
debug
.
leitner
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment