Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
open-source
MetaGer
Commits
84c3b6db
Commit
84c3b6db
authored
Mar 16, 2021
by
Dominik Hebeler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added countdown to next change
parent
8ac8ff15
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
4 deletions
+19
-4
app/Http/Controllers/KeyController.php
app/Http/Controllers/KeyController.php
+6
-0
app/Models/Key.php
app/Models/Key.php
+3
-2
resources/lang/de/key.php
resources/lang/de/key.php
+1
-0
resources/lang/en/key.php
resources/lang/en/key.php
+1
-0
resources/views/key.blade.php
resources/views/key.blade.php
+8
-2
No files found.
app/Http/Controllers/KeyController.php
View file @
84c3b6db
...
...
@@ -17,10 +17,16 @@ class KeyController extends Controller
public
function
index
(
\
App\Models\Key
$key
,
Request
$request
)
{
$cookieLink
=
LaravelLocalization
::
getLocalizedURL
(
LaravelLocalization
::
getCurrentLocale
(),
route
(
'loadSettings'
,
Cookie
::
get
()));
$key
->
canChange
();
$changedAt
=
$key
->
keyinfo
->
KeyChangedAt
;
if
(
!
empty
(
$changedAt
)){
$changedAt
=
new
Carbon
(
$changedAt
);
}
return
view
(
'key'
)
->
with
(
'title'
,
trans
(
'titles.key'
))
->
with
(
'keystatus'
,
$key
->
getStatus
())
->
with
(
'cookie'
,
$key
->
key
)
->
with
(
'changedAt'
,
$changedAt
)
->
with
(
'cookieLink'
,
$cookieLink
);
}
...
...
app/Models/Key.php
View file @
84c3b6db
...
...
@@ -11,7 +11,8 @@ class Key
public
$key
;
public
$status
;
# Null If Key invalid | false if valid but has no adFreeSearches | true if valid and has adFreeSearches
private
$keyserver
=
"https://key.metager.de/"
;
private
$keyinfo
;
public
$keyinfo
;
const
CHANGE_EVERY
=
1
*
24
*
60
*
60
;
public
function
__construct
(
$key
,
$status
=
null
)
{
...
...
@@ -200,7 +201,7 @@ class Key
if
(
!
empty
(
$this
->
keyinfo
->
KeyChangedAt
)){
// "2021-03-09T09:19:44.000Z"
$keyChangedAt
=
Carbon
::
createFromTimeString
(
$this
->
keyinfo
->
KeyChangedAt
,
'Europe/London'
);
if
(
$keyChangedAt
->
diffInSeconds
(
Carbon
::
now
())
>
(
2
*
24
*
60
*
60
)
){
if
(
$keyChangedAt
->
diffInSeconds
(
Carbon
::
now
())
>
self
::
CHANGE_EVERY
){
return
true
;
}
else
{
return
false
;
...
...
resources/lang/de/key.php
View file @
84c3b6db
...
...
@@ -16,5 +16,6 @@ return [
'backLink'
=>
'Zurück zur letzten Seite'
,
'custom.h3'
=>
'Wunsch-Schlüssel'
,
'custom.p1'
=>
'Mitglieder des SUMA-EV haben die Möglichkeit, sich einen eigenen Schlüssel auszusuchen.'
,
'custom.p2'
=>
'Der nächste Wechsel Ihres Schlüssels ist in :nextchange möglich.'
,
'custom.a1'
=>
'Wunsch Schlüssel einrichten'
];
resources/lang/en/key.php
View file @
84c3b6db
...
...
@@ -16,5 +16,6 @@ return [
"backLink"
=>
"Back to the last page"
,
"custom.h3"
=>
"Favorite Key"
,
"custom.p1"
=>
"Members of the SUMA-EV have the opportunity to choose their own key."
,
'custom.p2'
=>
'The next change of your key is possible in :nextchange.'
,
"custom.a1"
=>
"Set up the favorite key"
];
resources/views/key.blade.php
View file @
84c3b6db
...
...
@@ -40,13 +40,19 @@
</
ol
>
@
endif
</
div
>
@
if
(
app
(
'App\Models\Key'
)
->
canChange
())
<
div
class
=
"section"
>
<
h3
>@
lang
(
'key.custom.h3'
)
</
h3
>
<
p
>@
lang
(
'key.custom.p1'
)
</
p
>
@
if
(
app
(
'App\Models\Key'
)
->
canChange
())
<
a
class
=
"btn btn-default"
href
=
"{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route('changeKeyOne')) }}"
>@
lang
(
'key.custom.a1'
)
</
a
>
@
elseif
(
!
empty
(
$changedAt
))
<
p
>@
lang
(
'key.custom.p2'
,
[
'nextchange'
=>
trim
(
str_replace
(
" später"
,
""
,
$changedAt
->
addSeconds
(
\
App\Models\Key
::
CHANGE_EVERY
)
->
longRelativeDiffForHumans
(
Carbon
::
now
(
"Europe/London"
),
2
)))
])
</
p
>
@
endif
</
div
>
@
endif
<
div
class
=
"section"
>
@
if
(
isset
(
$keystatus
)
&&
$keystatus
===
false
)
<
p
class
=
"error"
>@
lang
(
'key.empty'
)
</
p
>
...
...
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