'use strict' ; import { inject , parentView , View , EventAPI } from '../../index' ; import { IEventData , IEventsResult } from 'teambition' ; let projectId ; @ parentView ( 'TabsView' ) @ inject ( [ 'EventAPI' ] ) export class PanelEventView extends View { public eventGroup : { [ index ] : IEventData [ ] ; } ; public counter : number ; private EventAPI : EventAPI ; public onInit ( ) { projectId = this . $state . params . _id ; return this . fetchEvents ( ) ; } public openEvent ( eventId ) { if ( ! eventId ) { return ; } window . location . hash = `/detail/event/${ eventId }` ; } private fetchEvents ( ) { let now = new Date ( ) . toISOString ( ) ; return this . EventAPI . fetch ( projectId , now ) . then ( ( eventGroup ) => { if ( ! eventGroup || ! eventGroup . data ) { return ; } this . eventGroup = eventGroup . data ; this . counter = eventGroup . counter ; } ) ; } } angular . module ( 'teambition' ) . controller ( 'PanelEventView' , PanelEventView ) ;