blob: 565dc9a39c062a385d86f84c9c82358977dc73a7 [file] [log] [blame]
Michael Landoed64b5e2017-06-09 03:19:04 +03001'use strict';
2import {Activity} from "../models/activity";
3import {IAppConfigurtaion, IApi} from "../models/app-config";
4
5// Define an interface of the object you want to use, providing it's properties
6export interface IActivityLogService {
7 getActivityLogService(type:string, id:string):ng.IPromise<Array<Activity>>;
8}
9
10export 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}