pdnsmanager/frontend/src/app/services/record-edit/record-edit.service.ts
2018-02-09 16:58:04 +01:00

35 lines
972 B
TypeScript

import {Injectable} from '@angular/core';
import {HttpService} from 'app/services/http/http.service';
import {DomainNameAnswer} from 'app/interfaces/domain-name-answer';
@Injectable()
export class RecordEditService {
constructor(private httpService: HttpService) {}
/**
* Gets the name of the domain
*
* @param id Id of the domain for which the name should be retrieved
*
* @returns A Promise for a DomainNameAnswer
*/
getDomainName(id: number): Promise<DomainNameAnswer> {
return new Promise((resolve, reject) => {
const body = {
action: 'getDomainName',
domain: id
};
this.httpService.post<DomainNameAnswer>('api/edit-master.php', body)
.then((answer: DomainNameAnswer) => {
resolve(answer);
}, (err) => {
reject(err);
});
});
}
}