1 namespace app.services {
2 export class APIEndPoint {
4 private $resource: ng.resource.IResourceService;
5 private $http: ng.IHttpService;
7 constructor($resource: ng.resource.IResourceService, $http: ng.IHttpService) {
8 this.$resource = $resource;
12 private resource(endPoint: string, data: any) {
14 * setting custom action
16 var customAction: ng.resource.IActionDescriptor = {
21 var execute: ng.resource.IActionDescriptor = {
23 //transformRequest: data,
24 headers: {'Content-Type':undefined, enctype:'multipart/form-data'}
27 return <declares.IResponseResource> this.$resource(endPoint, {}, { execute: execute});
30 public getOptionControlFile(command: string): ng.resource.IResource<declares.IResponse> {
31 var endPoint = '/api/v1/optionControlFile/' + command;
32 return <declares.IResponseOption>this.resource(endPoint, {}).get();
35 public getFiles(fileId: string): ng.resource.IResource<declares.IResponse> {
36 var endPoint = '/api/v1/workspace';
39 endPoint += '/' + fileId;
41 return <declares.IResponseFileInfo>this.resource(endPoint,{}).get();
44 public getDirectories(): ng.resource.IResource<declares.IResponse> {
45 var endPoint = '/api/v1/all/workspace/directory';
47 return this.resource(endPoint,{}).get();
50 public getTags(): ng.resource.IResource<declares.IResponse> {
51 var endPoint = '/api/v1/tagList';
52 return this.resource(endPoint, {}).get();
55 public getCommands(): ng.resource.IResource<declares.IResponse> {
56 var endPoint = '/api/v1/commandList';
57 return this.resource(endPoint, {}).get();
60 public execute(data: any): ng.IHttpPromise<{}> {
61 var endPoint = '/api/v1/execution';
62 var fd = new FormData()
63 fd.append('data', data);
64 return this.$http.post(endPoint,
67 headers: {'Content-Type': undefined },
68 transformRequest: angular.identity
72 public debug(): ng.IHttpPromise<string> {
73 var endPoint = '/api/v1/debug';
74 return this.$http.get(endPoint);
76 public help(command:string): ng.IHttpPromise<string> {
77 var endPoint = '/api/v1/help/' + command;
78 return this.$http.get(endPoint);