aodb/app/window-list/list/window-list.ts
Martin Donnelly afe73b5baa upload
2016-12-22 00:00:06 +00:00

45 lines
1.6 KiB
TypeScript

import {controller, directive} from '../../infrastructure/Dectorators/Components';
import {Mod} from '../window-list.mod';
import {ISignalrService} from '../../core/service/signalRService';
export interface IFlightWindow {
Name: string;
}
@controller(Mod, 'windowListController', ['signalrService', '$rootScope', '$http', '$state', '$window', 'api'])
export class Controller {
public loading: boolean;
public currentWindow:string;
public windows: Array<IFlightWindow>;
constructor( private signalrService: ISignalrService,
private $rootScope: ng.IScope,
private $http: ng.IHttpService,
private $state: ng.ui.IStateService,
private $window: ng.IWindowService,
private api: any) {
this.currentWindow = $window.sessionStorage.getItem('chroma:current-filter');
this.$http.get(api.getWindows).success((response: Array<IFlightWindow>) => {
this.windows = response.reverse();
});
}
public goToWindow(window: IFlightWindow): void {
this.signalrService.start($, this.signalRCallback, this.$rootScope);
this.$state.go('chroma.flight-list', { filter: window.Name });
}
public signalRCallback(event: string, scope: any, message: any) {
scope.$broadcast(event, {message: message});
}
}
@directive(Mod, 'chromaWindowList')
export class Directive implements ng.IDirective {
controller: string = Controller.$componentName;
controllerAs: string = 'vm';
templateUrl: string = 'app/window-list/list/window-list.tpl.html';
restring: string = 'E';
replace: boolean = false;
scope: any = true;
}