@@ -38,4 +38,66 @@ $(document).ready(function() {
3838
3939 $here . append ( '<li>' + name + ' <span class="status ' + clas + '">' + text + '</span></li>' ) } ) ;
4040 } ;
41+
42+ $ . getJSON ( 'https://api.github.com/repos/Turistforeningen/status/issues?state=all' ) . done ( message ) ;
43+
44+ var $incidents = $ ( '#incidents' ) ;
45+
46+ function message ( issues ) {
47+ issues . forEach ( function ( issue ) {
48+ var status_text = {
49+ operational : 'løst' ,
50+ investigating : 'undersøker' ,
51+ 'major outage' : 'driftsavbrudd' ,
52+ 'degraded performance' : 'degradert ytelse' ,
53+ } ;
54+
55+ var status = issue . labels . reduce ( function ( status , label ) {
56+ if ( / ^ s t a t u s : / . test ( label . name ) ) {
57+ return label . name . replace ( 'status:' , '' ) ;
58+ } else {
59+ return status ;
60+ }
61+ } , 'operational' ) ;
62+
63+ var systems = issue . labels . filter ( function ( label ) {
64+ return / ^ s y s t e m : / . test ( label . name ) ;
65+ } ) . map ( function ( label ) {
66+ return label . name . replace ( 'system:' , '' )
67+ } ) ;
68+
69+ console . log ( status ) ;
70+ console . log ( systems ) ;
71+
72+ var html = '<div class="incident">\n' ;
73+ html += '<span class="date">' + issue . created_at + '</span>\n' ;
74+
75+ // status
76+ if ( issue . state == 'closed' ) {
77+ html += '<span class="label operational float-right">løst</span>' ;
78+ } else {
79+ html += '<span class="label ' + status + ' float-right">' ;
80+ html += status_text [ status ] ;
81+ html += '</span>\n' ;
82+ }
83+
84+ // systems
85+ for ( var i = 0 ; i < systems . length ; i ++ ) {
86+ html += '<span class="label system float-right">' + systems [ i ] + '</span>' ;
87+ }
88+
89+ html += '<hr>\n' ;
90+ html += '<span class="title">' + issue . title + '</span>\n' ;
91+ html += '<p>' + issue . body + '</p>\n' ;
92+
93+ if ( issue . state == 'closed' ) {
94+ html += '<p><em>Oppdatert ' + issue . closed_at + '<br/>' ;
95+ html += 'Systemet er tilbake i normal drift.</p>' ;
96+ }
97+
98+ html += '</div>' ;
99+
100+ $incidents . append ( html ) ;
101+ } ) ;
102+ } ;
41103} ) ;
0 commit comments