Store in GIT
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
"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 core_1 = require("@angular/core");
|
||||
var data_service_1 = require("./../../services/data.service");
|
||||
var IntervalObservable_1 = require("rxjs/observable/IntervalObservable");
|
||||
var plane_class_1 = require("./../../classes/plane.class");
|
||||
var router_1 = require("@angular/router");
|
||||
var PlaneComponent = (function () {
|
||||
function PlaneComponent(route, data) {
|
||||
this.route = route;
|
||||
this.data = data;
|
||||
this.loading = true;
|
||||
this.error = false;
|
||||
this.name = "Loading";
|
||||
this.id = 0;
|
||||
this.plane = new plane_class_1.Plane(0, "Loading", "Loading", "Loading", "Loading");
|
||||
}
|
||||
PlaneComponent.prototype.getPlane = function (id) {
|
||||
var _this = this;
|
||||
this.data.load().then(function () {
|
||||
_this.data
|
||||
.plane(id)
|
||||
.subscribe(function (b) {
|
||||
var status = b.status_code;
|
||||
if (status != 200 && b.data.length != 1) {
|
||||
_this.loading = false;
|
||||
_this.error = true;
|
||||
}
|
||||
else {
|
||||
_this.plane = plane_class_1.Plane.toPlane(b.data[0]);
|
||||
_this.name = _this.plane.name;
|
||||
_this.loading = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
PlaneComponent.prototype.ngOnInit = function () {
|
||||
var _this = this;
|
||||
this.id = this.route.snapshot.params['id'];
|
||||
this.getPlane(this.id);
|
||||
this.subscription = IntervalObservable_1.IntervalObservable.create(5000).subscribe(function () {
|
||||
console.log("Reloading data...");
|
||||
_this.getPlane(_this.id);
|
||||
});
|
||||
};
|
||||
PlaneComponent.prototype.ngOnDestroy = function () {
|
||||
this.subscription.unsubscribe();
|
||||
};
|
||||
return PlaneComponent;
|
||||
}());
|
||||
PlaneComponent = __decorate([
|
||||
core_1.Component({
|
||||
selector: 'app-plane',
|
||||
templateUrl: './plane.component.html',
|
||||
styleUrls: ['./plane.component.css']
|
||||
}),
|
||||
__metadata("design:paramtypes", [router_1.ActivatedRoute, data_service_1.DataService])
|
||||
], PlaneComponent);
|
||||
exports.PlaneComponent = PlaneComponent;
|
||||
//# sourceMappingURL=plane.component.js.map
|
||||
Reference in New Issue
Block a user