blob: d5a5541586b2f0062bbccfd3a8fe271244500350 [file] [log] [blame]
Matteo Scandolof2c3ed62016-12-15 14:32:50 -08001import {AppConfig} from '../../config/app.config';
Matteo Scandolocb466ed2017-01-04 17:16:24 -08002import {IXosModelDefsField} from '../../core/services/helpers/config.helpers';
Matteo Scandolof2c3ed62016-12-15 14:32:50 -08003
4export interface IModeldef {
Matteo Scandolocb466ed2017-01-04 17:16:24 -08005 fields: IXosModelDefsField[];
6 relations?: string[];
Matteo Scandolof2c3ed62016-12-15 14:32:50 -08007 name: string;
8}
9
10export interface IModeldefsService {
11 get(): Promise<IModeldef[]>;
12}
13
14export 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}