Matteo Scandolo | f2c3ed6 | 2016-12-15 14:32:50 -0800 | [diff] [blame] | 1 | import {AppConfig} from '../../config/app.config'; |
| 2 | |
| 3 | interface IModeldefField { |
| 4 | name: string; |
| 5 | type: string; |
| 6 | } |
| 7 | |
| 8 | export interface IModeldef { |
| 9 | fields: IModeldefField[]; |
| 10 | relations: string[]; |
| 11 | name: string; |
| 12 | } |
| 13 | |
| 14 | export interface IModeldefsService { |
| 15 | get(): Promise<IModeldef[]>; |
| 16 | } |
| 17 | |
| 18 | export class ModeldefsService { |
| 19 | constructor( |
| 20 | private $http: angular.IHttpService, |
| 21 | private $q: angular.IQService, |
| 22 | ) { |
| 23 | } |
| 24 | |
| 25 | public get(): Promise<any> { |
| 26 | const d = this.$q.defer(); |
| 27 | this.$http.get(`${AppConfig.apiEndpoint}/utility/modeldefs/`) |
| 28 | .then((res) => { |
| 29 | d.resolve(res.data); |
| 30 | }) |
| 31 | .catch(e => { |
| 32 | d.reject(e); |
| 33 | }); |
| 34 | return d.promise; |
| 35 | } |
| 36 | } |