UNPKG

sos-user-info

Version:

Sos Component User Info

58 lines 2.93 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; var http_1 = require('@angular/http'); require('rxjs/add/operator/map'); var Observable_1 = require('rxjs/Observable'); var core_1 = require('@angular/core'); var DataService = (function () { function DataService(http) { var _this = this; this.GetAll = function () { return _this._http.get(_this.actionUrl) .map(function (response) { return response.json(); }); }; this.GetSingle = function (id) { return _this._http.get(_this.actionUrl + id) .map(function (response) { return response.json(); }); }; this.Add = function (itemName) { var toAdd = JSON.stringify({ ItemName: itemName }); return _this._http.post(_this.actionUrl, toAdd, { headers: _this.headers }) .map(function (response) { return response.json(); }); }; this.Update = function (id, itemToUpdate) { return _this._http.put(_this.actionUrl + id, JSON.stringify(itemToUpdate), { headers: _this.headers }) .map(function (response) { return response.json(); }); }; this.Delete = function (id) { return _this._http.delete(_this.actionUrl + id); }; this._http = http; this.actionUrl = "http://192.168.1.7/ApiAngular/ApiAngular/" + 'GetAll'; this.headers = new http_1.Headers(); this.headers.append('Content-Type', 'application/json'); this.headers.append('Accept', 'application/json'); } DataService.prototype.handleError = function (error) { console.error(error); return Observable_1.Observable.throw(error.json().error || 'Server error'); }; DataService = __decorate([ __param(0, core_1.Inject(http_1.Http)), __metadata('design:paramtypes', [http_1.Http]) ], DataService); return DataService; }()); exports.DataService = DataService; //# sourceMappingURL=DataService.js.map