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