Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Package Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
HUB Terra
SMS
Frontend
Commits
d98f5363
Verified
Commit
d98f5363
authored
3 years ago
by
Marc Hanisch
Browse files
Options
Downloads
Patches
Plain Diff
sorts with the help of the DateComparator
parent
9a791e1f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!104
Load and save Generic Device Actions
,
!93
Actions UI for devices
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pages/devices/_deviceId/actions.vue
+10
-16
10 additions, 16 deletions
pages/devices/_deviceId/actions.vue
with
10 additions
and
16 deletions
pages/devices/_deviceId/actions.vue
+
10
−
16
View file @
d98f5363
...
...
@@ -389,6 +389,7 @@ import { Contact } from '@/models/Contact'
import
{
DeviceProperty
}
from
'
@/models/DeviceProperty
'
import
{
IAction
}
from
'
@/models/Action
'
import
{
GenericAction
}
from
'
@/models/GenericAction
'
import
{
DateComparator
,
isDateCompareable
}
from
'
@/modelUtils/Compareables
'
const
toUtcDate
=
(
dt
:
DateTime
)
=>
{
return
dt
.
toUTC
().
toFormat
(
'
yyyy-MM-dd TT
'
)
...
...
@@ -621,28 +622,21 @@ export default class DeviceActionsPage extends Vue {
deviceMountAction1
,
deviceUnmountAction1
]
// Todo: sort all actions by date descending
await
Promise
.
all
([
this
.
fetchGenericActions
()])
// sort the actions descending
// sort the actions
const
comparator
=
new
DateComparator
()
this
.
actions
.
sort
((
i
:
IAction
,
j
:
IAction
):
number
=>
{
if
(
!
(
'
beginDate
'
in
i
)
&&
!
(
'
beginDate
'
in
j
))
{
return
0
if
(
isDateCompareable
(
i
)
&&
isDateCompareable
(
j
))
{
// multiply result with -1 to get descending order
return
comparator
.
compare
(
i
,
j
)
*
-
1
}
if
((
'
beginDate
'
in
i
)
&&
(
'
beginDate
'
in
j
))
{
if
((
i
as
IAction
&
{
beginDate
:
DateTime
}).
beginDate
<
(
j
as
IAction
&
{
beginDate
:
DateTime
}).
beginDate
)
{
return
1
}
if
((
i
as
IAction
&
{
beginDate
:
DateTime
}).
beginDate
>
(
j
as
IAction
&
{
beginDate
:
DateTime
}).
beginDate
)
{
return
-
1
}
return
0
if
(
isDateCompareable
(
i
))
{
return
1
}
if
(
!
(
'
beginDate
'
in
i
)
&&
(
'
beginDate
'
in
j
))
{
if
(
isDateCompareable
(
j
))
{
return
-
1
}
if
((
'
beginDate
'
in
i
)
&&
!
(
'
beginDate
'
in
j
))
{
return
1
}
return
0
})
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment