Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 1 | 'use strict'; |
| 2 | import {Activity} from "../models/activity"; |
| 3 | import {IAppConfigurtaion, IApi} from "../models/app-config"; |
| 4 | |
| 5 | // Define an interface of the object you want to use, providing it's properties |
| 6 | export interface IActivityLogService { |
| 7 | getActivityLogService(type:string, id:string):ng.IPromise<Array<Activity>>; |
| 8 | } |
| 9 | |
| 10 | export class ActivityLogService implements IActivityLogService { |
| 11 | |
| 12 | |
| 13 | static '$inject' = ['$http', '$q', 'sdcConfig']; |
| 14 | private api:IApi; |
| 15 | |
| 16 | constructor(private $http:ng.IHttpService, private $q:ng.IQService, sdcConfig:IAppConfigurtaion) { |
| 17 | this.api = sdcConfig.api; |
| 18 | } |
| 19 | |
| 20 | getActivityLogService = (type:string, id:string):ng.IPromise<Array<Activity>> => { |
| 21 | let defer = this.$q.defer<any>(); |
| 22 | this.$http.get(this.api.root + this.api.GET_activity_log.replace(':type', type).replace(':id', id)) |
| 23 | .then((activityLog:any) => { |
| 24 | defer.resolve(activityLog.data); |
| 25 | }); |
| 26 | return defer.promise; |
| 27 | } |
| 28 | } |