@@ -20,18 +20,18 @@ angular
20
20
return {
21
21
sort : function ( type , reason , kind , name , message ) {
22
22
var msg = `${ name } : ${ message } ` ;
23
- var tier1 = `${ kind } ${ reason } ` ;
23
+ // var tier1 = `${kind} ${reason}`;
24
24
cachedEvents [ kind ] = cachedEvents [ kind ] || { } ;
25
25
cachedEvents [ kind ] [ reason ] = cachedEvents [ kind ] [ reason ] || { } ;
26
26
cachedEvents [ kind ] [ reason ] [ type ] = cachedEvents [ kind ] [ reason ] [ type ] || [ ] ;
27
27
if ( ! _ . contains ( cachedEvents [ kind ] [ reason ] [ type ] , msg ) ) {
28
28
cachedEvents [ kind ] [ reason ] [ type ] . unshift ( msg ) ;
29
29
// no need to keep excessive records...
30
30
}
31
- // if we want to limit...
32
- // if(cachedEvents[kind][reason][type].length > 15 ) {
33
- // cachedEvents[kind][reason][type].length = 15 ;
34
- // }
31
+ // // if we want to limit...
32
+ if ( cachedEvents [ kind ] [ reason ] [ type ] . length > 6 ) {
33
+ cachedEvents [ kind ] [ reason ] [ type ] . length = 6 ;
34
+ }
35
35
// cachedEvents[tier1] = cachedEvents[tier1] || {};
36
36
// cachedEvents[tier1][type] = cachedEvents[tier1][type] || [];
37
37
// if(!_.contains(cachedEvents[tier1][type], msg)) {
@@ -52,25 +52,27 @@ angular
52
52
var save = function ( data ) {
53
53
window [ storageType ] . setItem ( cachedUserActionsKey , JSON . stringify ( data ) ) ;
54
54
} ;
55
- var cachedProcessedEvents ;
55
+ var cachedProcessedEvents = { } ;
56
56
var getTypeIndex = function ( type ) {
57
57
// TODO: verify these are correct
58
58
var indexes = {
59
59
// Applications
60
60
DeploymentConfig : 0 ,
61
61
ReplicationController : 0 ,
62
+ ReplicaSet : 0 ,
62
63
Deployment : 0 ,
63
64
StatefulSet : 0 ,
64
65
Pod : 0 ,
65
66
Service : 0 ,
66
67
Route : 0 ,
67
68
HorizontalPodAutoscaler : 0 ,
68
69
// Builds
70
+ BuildConfig : 1 ,
69
71
Build : 1 ,
70
72
Pipeline : 1 ,
71
73
ImageStream : 1 ,
72
74
// Storage
73
- PVC : 2
75
+ PersistentVolumeClaim : 2
74
76
} ;
75
77
var index = indexes [ type ] ;
76
78
if ( typeof index !== 'number' ) {
@@ -80,6 +82,10 @@ angular
80
82
}
81
83
return indexes [ type ] ;
82
84
} ;
85
+ var isImportantEvent = function ( event ) {
86
+ console . log ( 'isImportantEvent' ) ;
87
+ return true ;
88
+ } ;
83
89
// TRELLO for adding build events:
84
90
// https://trello.com/c/YiK7d5gs/1149-3-create-events-for-started-completed-failed-builds-builds
85
91
// - TODO: white list proactively filter in, if we didnt discuss,
@@ -101,14 +107,18 @@ angular
101
107
if ( ! data ) {
102
108
return [ ] ; // TODO: fix mo' betta
103
109
} ;
104
- cachedProcessedEvents = _ . reduce ( data . by ( 'metadata.name' ) , function ( result , event ) {
110
+ console . log ( 'process' , _ . keys ( data . by ( 'metadata.name' ) ) . length ) ;
111
+ console . log ( 'cache' , cachedProcessedEvents ) ;
112
+ _ . each ( data . by ( 'metadata.name' ) , function ( event ) {
105
113
var namespace = event . involvedObject . namespace ;
114
+ var type = event . type ;
115
+ // TODO: type, reason, kind....
106
116
var name = event . involvedObject . name ;
107
117
var uid = event . metadata . uid ;
108
118
var kind = event . involvedObject . kind ;
109
119
var index = getTypeIndex ( kind ) ;
110
- // there are 3 arrays in the result, each has a specific use :
111
- result [ namespace ] = result [ namespace ] || [ {
120
+ // there are 3 arrays for each namespace, matching the current menu structure :
121
+ cachedProcessedEvents [ namespace ] = cachedProcessedEvents [ namespace ] || [ {
112
122
heading : 'Applications' ,
113
123
// Applications: Deployments, Pods, StatefulSets, Services, Routes
114
124
notifications : [ ]
@@ -121,21 +131,26 @@ angular
121
131
// Storage: PVC
122
132
notifications : [ ]
123
133
} ] ;
124
- // make the notification object:
125
- result [ namespace ] [ index ] . notifications . push ( {
134
+ if ( ! cachedProcessedEvents [ namespace ] [ index ] ) {
135
+ console . warn ( 'missing, add to index list!' , cachedProcessedEvents , namespace , index ) ;
136
+ }
137
+ if ( ! isImportantEvent ( event ) ) {
138
+ return ;
139
+ }
140
+ cachedProcessedEvents [ namespace ] [ index ] . notifications . push ( {
126
141
unread : ! _ . get ( cachedUserActions , [ namespace , uid , 'read' ] ) ,
127
142
message : event . message ,
128
143
timestamp : event . lastTimestamp ,
129
144
metadata : event . metadata ,
130
145
involvedObject : event . involvedObject ,
131
146
status : event . type ,
147
+ reason : event . reason ,
132
148
actions : null
133
149
} ) ;
134
150
// console.log('[', event.type, '>', event.reason, event.involvedObject.kind,']', '(', event.involvedObject.name, ')');
135
151
// console.log(' ', event.message);
136
152
eventTypeOrganizer . sort ( event . type , event . reason , event . involvedObject . kind , event . involvedObject . name , event . message ) ;
137
- return result ;
138
- } , { } ) ;
153
+ } ) ;
139
154
return cachedProcessedEvents ;
140
155
} ;
141
156
0 commit comments