Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Cesium
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Rolf Allard van Hagen
Cesium
Commits
b390a3cf
Commit
b390a3cf
authored
6 years ago
by
Benoit Lavenier
Browse files
Options
Downloads
Patches
Plain Diff
small code refactoring
parent
1ad68b35
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
www/plugins/es/js/services/notification-services.js
+41
-31
41 additions, 31 deletions
www/plugins/es/js/services/notification-services.js
with
41 additions
and
31 deletions
www/plugins/es/js/services/notification-services.js
+
41
−
31
View file @
b390a3cf
...
@@ -108,16 +108,17 @@ angular.module('cesium.es.notification.services', ['cesium.platform', 'cesium.es
...
@@ -108,16 +108,17 @@ angular.module('cesium.es.notification.services', ['cesium.platform', 'cesium.es
});
});
}
}
function
getWallet
EventsAs
Notifications
(
options
)
{
function
getWalletNotifications
(
options
)
{
options
=
options
||
{};
options
=
options
||
{};
var
wallet
=
options
.
wallet
||
csWallet
;
var
wallet
=
options
.
wallet
||
csWallet
;
if
(
!
wallet
.
data
.
events
||!
wallet
.
data
.
events
.
length
)
return
[];
return
new
Promise
(
function
(
resolve
)
{
if
(
!
wallet
.
data
||
!
wallet
.
data
.
events
||!
wallet
.
data
.
events
.
length
)
return
resolve
([]);
// Add some wallet events as notifications
// Add some wallet events as notifications
var
time
=
csHttp
.
date
.
now
()
-
filterTranslations
.
MEDIAN_TIME_OFFSET
;
var
time
=
csHttp
.
date
.
now
()
-
filterTranslations
.
MEDIAN_TIME_OFFSET
;
return
(
wallet
.
data
.
events
||
[]).
reduce
(
function
(
res
,
event
)
{
var
result
=
(
wallet
.
data
.
events
||
[]).
reduce
(
function
(
res
,
event
)
{
if
(
event
.
type
!=
"
warn
"
)
return
res
;
// Skip NOT warn
events
if
(
event
.
type
!=
"
warn
"
&&
event
.
type
!=
"
error
"
)
return
res
;
// Keep only warn and error
events
var
notification
=
new
EsNotification
({},
function
(
self
)
{
var
notification
=
new
EsNotification
({},
function
(
self
)
{
if
(
!
self
.
read
)
{
if
(
!
self
.
read
)
{
self
.
read
=
true
;
self
.
read
=
true
;
...
@@ -136,6 +137,10 @@ angular.module('cesium.es.notification.services', ['cesium.platform', 'cesium.es
...
@@ -136,6 +137,10 @@ angular.module('cesium.es.notification.services', ['cesium.platform', 'cesium.es
notification
.
messageParams
=
event
.
messageParams
;
notification
.
messageParams
=
event
.
messageParams
;
return
res
.
concat
(
notification
);
return
res
.
concat
(
notification
);
},
[]);
},
[]);
resolve
(
result
);
});
}
}
// Load user notifications
// Load user notifications
...
@@ -146,7 +151,6 @@ angular.module('cesium.es.notification.services', ['cesium.platform', 'cesium.es
...
@@ -146,7 +151,6 @@ angular.module('cesium.es.notification.services', ['cesium.platform', 'cesium.es
}
}
options
.
from
=
options
.
from
||
0
;
options
.
from
=
options
.
from
||
0
;
options
.
size
=
options
.
size
||
constants
.
DEFAULT_LOAD_SIZE
;
options
.
size
=
options
.
size
||
constants
.
DEFAULT_LOAD_SIZE
;
var
wallet
=
options
.
wallet
||
csWallet
;
var
request
=
{
var
request
=
{
query
:
createFilterQuery
(
options
.
pubkey
,
options
),
query
:
createFilterQuery
(
options
.
pubkey
,
options
),
sort
:
[
sort
:
[
...
@@ -157,18 +161,24 @@ angular.module('cesium.es.notification.services', ['cesium.platform', 'cesium.es
...
@@ -157,18 +161,24 @@ angular.module('cesium.es.notification.services', ['cesium.platform', 'cesium.es
_source
:
fields
.
commons
_source
:
fields
.
commons
};
};
return
that
.
raw
.
postSearch
(
request
)
return
$q
.
all
([
.
then
(
function
(
res
)
{
// Get wallet events (as notifications)
// Get wallet events (as notifications)
var
walletEvents
=
getWalletEventsAsNotifications
(
options
);
getWalletNotifications
(
options
),
// Load notification from ES node
that
.
raw
.
postSearch
(
request
)
]).
then
(
function
(
res
)
{
var
walletNotifs
=
res
[
0
]
||
[];
res
=
res
[
1
];
if
(
!
res
.
hits
||
!
res
.
hits
.
total
)
return
wallet
Event
s
;
if
(
!
res
.
hits
||
!
res
.
hits
.
total
)
return
wallet
Notif
s
;
var
notifications
=
res
.
hits
.
hits
.
reduce
(
function
(
res
,
hit
)
{
var
notifications
=
res
.
hits
.
hits
.
reduce
(
function
(
res
,
hit
)
{
var
item
=
new
EsNotification
(
hit
.
_source
,
markNotificationAsRead
);
var
item
=
new
EsNotification
(
hit
.
_source
,
markNotificationAsRead
);
item
.
id
=
hit
.
_id
;
item
.
id
=
hit
.
_id
;
return
res
.
concat
(
item
);
return
res
.
concat
(
item
);
},
wallet
Events
||
[]
);
},
wallet
Notifs
);
return
csWot
.
extendAll
(
notifications
);
return
csWot
.
extendAll
(
notifications
);
});
});
...
...
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