52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import Dectorators = require('../../infrastructure/Dectorators/Components');
|
|
import Core = require('../core.mod');
|
|
|
|
export interface IFlightListRequest {
|
|
Flights: Array<IFlightDetail>;
|
|
RequestId: string;
|
|
}
|
|
|
|
export interface IFlightDetail {
|
|
Id: string;
|
|
PhysFlightId: string;
|
|
Type: string;
|
|
Number: string;
|
|
Operator: string;
|
|
AircraftType: string;
|
|
Registration: string;
|
|
Location: string;
|
|
Scheduled: string;
|
|
Estimated: string;
|
|
Actual: string;
|
|
Terminal: string;
|
|
Stand: string;
|
|
FlightConcat: string;
|
|
}
|
|
|
|
export interface IFlightService {
|
|
getFilter(filter: string, broadcast: boolean): ng.IPromise<IFlightListRequest>;
|
|
}
|
|
|
|
@Dectorators.factory(Core.Mod, 'flightService', ['$http', '$q', '$rootScope', 'api'])
|
|
export class FlightService implements IFlightService {
|
|
|
|
constructor(private $http: ng.IHttpService,
|
|
private $q: ng.IQService,
|
|
private $rootScope: ng.IScope,
|
|
private api: any) {
|
|
}
|
|
|
|
public getFilter(filter: string, broadcast: boolean): ng.IPromise<IFlightListRequest> {
|
|
let def: ng.IDeferred<IFlightListRequest> = this.$q.defer();
|
|
|
|
this.$http.get(this.api.flightList + '?window=' + filter).success((data: any, status) => {
|
|
def.resolve(data);
|
|
if (broadcast) {
|
|
this.$rootScope.$broadcast('scroll.refreshComplete');
|
|
}
|
|
});
|
|
|
|
return def.promise;
|
|
}
|
|
}
|