@hestia-earth/ui-components 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/hestia-earth-ui-components.umd.js +46 -28
- package/bundles/hestia-earth-ui-components.umd.js.map +1 -1
- package/cycles/cycles-practices-timeline/cycles-practices-timeline.component.d.ts +2 -1
- package/esm2015/cycles/cycles-practices-timeline/cycles-practices-timeline.component.js +4 -2
- package/esm2015/impact-assessments/impact-assessments-indicator-breakdown-chart/impact-assessments-indicator-breakdown-chart.component.js +38 -21
- package/esm2015/sites/sites-maps/sites-maps.component.js +6 -5
- package/fesm2015/hestia-earth-ui-components.js +44 -25
- package/fesm2015/hestia-earth-ui-components.js.map +1 -1
- package/package.json +1 -1
|
@@ -6603,6 +6603,7 @@
|
|
|
6603
6603
|
function CyclesPracticesTimelineComponent(el) {
|
|
6604
6604
|
this.el = el;
|
|
6605
6605
|
this.now = new Date();
|
|
6606
|
+
this.TermTermType = schema.TermTermType;
|
|
6606
6607
|
}
|
|
6607
6608
|
Object.defineProperty(CyclesPracticesTimelineComponent.prototype, "practices", {
|
|
6608
6609
|
get: function () {
|
|
@@ -6628,7 +6629,7 @@
|
|
|
6628
6629
|
return CyclesPracticesTimelineComponent;
|
|
6629
6630
|
}());
|
|
6630
6631
|
CyclesPracticesTimelineComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: CyclesPracticesTimelineComponent, deps: [{ token: i0__namespace.ElementRef }], target: i0__namespace.ɵɵFactoryTarget.Component });
|
|
6631
|
-
CyclesPracticesTimelineComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: CyclesPracticesTimelineComponent, selector: "he-cycles-practices-timeline", inputs: { cycle: "cycle" }, ngImport: i0__namespace, template: "<ul class=\"content pl-4 ml-4 pb-4\">\n <li class=\"is-relative m-0\"\n *ngFor=\"let practice of practices | sortBy:['startDate','endDate']:['asc','asc']; trackBy: trackByPractice\"\n >\n <div class=\"is-relative\"\n [style.width]=\"lineWidth + 'px'\"\n >\n <span *ngIf=\"practice.startDate
|
|
6632
|
+
CyclesPracticesTimelineComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: CyclesPracticesTimelineComponent, selector: "he-cycles-practices-timeline", inputs: { cycle: "cycle" }, ngImport: i0__namespace, template: "<ul class=\"content pl-4 ml-4 pb-4\">\n <li class=\"is-relative m-0\"\n *ngFor=\"let practice of practices | sortBy:['startDate','endDate']:['asc','asc']; trackBy: trackByPractice\"\n >\n <div class=\"is-relative\"\n [style.width]=\"lineWidth + 'px'\"\n >\n <span *ngIf=\"practice.startDate\">{{practice.startDate | date:'YYYY-MM-dd'}}</span>\n <span *ngIf=\"!practice.startDate\">\n <ng-container *ngIf=\"practice.term?.termType === TermTermType.operation\">No date</ng-container>\n </span>\n <span class=\"px-1\"\n [class.is-invisible]=\"!practice.startDate || !practice.endDate\"\n >-</span>\n <span\n [class.is-invisible]=\"!practice.endDate\"\n >{{(practice.endDate || now) | date:'YYYY-MM-dd'}}</span>\n <span class=\"pl-4\">{{practice.term.name}}</span>\n <he-blank-node-state class=\"ml-1\"\n [node]=\"practice\"\n key=\"value\"\n ></he-blank-node-state>\n </div>\n </li>\n</ul>\n", styles: ["ul{max-height:400px;overflow-y:auto}ul li{width:4px;padding-top:20px;background:#485fc7}ul li:after{content:\"\";position:absolute;left:50%;bottom:2px;transform:translate(-50%);width:20px;height:20px;border-radius:50%;background:inherit}ul li>div{width:600px;margin-left:24px}ul li>div>span{display:inline-block}ul li>div>span:nth-child(1),ul li>div>span:nth-child(3){width:94px}\n"], components: [{ type: BlankNodeStateComponent, selector: "he-blank-node-state", inputs: ["nodeType", "dataKey", "key", "node", "state"] }], directives: [{ type: i2__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "sortBy": SortByPipe, "date": i2__namespace.DatePipe } });
|
|
6632
6633
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: CyclesPracticesTimelineComponent, decorators: [{
|
|
6633
6634
|
type: i0.Component,
|
|
6634
6635
|
args: [{
|
|
@@ -8118,17 +8119,19 @@
|
|
|
8118
8119
|
});
|
|
8119
8120
|
};
|
|
8120
8121
|
SitesMapsComponent.prototype.centerMarker = function (marker) {
|
|
8122
|
+
var _this = this;
|
|
8121
8123
|
var center = marker.getPosition();
|
|
8122
8124
|
this.center = center ? { lat: center.lat(), lng: center.lng() } : defaultCenter;
|
|
8125
|
+
setTimeout(function () {
|
|
8126
|
+
_this.map.googleMap.setCenter(_this.center);
|
|
8127
|
+
});
|
|
8123
8128
|
};
|
|
8124
8129
|
SitesMapsComponent.prototype.centerPolygons = function (polygons) {
|
|
8125
8130
|
try {
|
|
8126
|
-
return polygons.length ? this.map.googleMap.fitBounds(polygonBounds(polygons)) : null;
|
|
8131
|
+
return (polygons === null || polygons === void 0 ? void 0 : polygons.length) ? this.map.googleMap.fitBounds(polygonBounds(polygons)) : null;
|
|
8127
8132
|
}
|
|
8128
8133
|
catch (err) {
|
|
8129
|
-
|
|
8130
|
-
this.map.googleMap.fitBounds(polygonBounds(polygons[0]));
|
|
8131
|
-
}
|
|
8134
|
+
return (polygons === null || polygons === void 0 ? void 0 : polygons.length) ? this.map.googleMap.fitBounds(polygonBounds(polygons[0])) : null;
|
|
8132
8135
|
}
|
|
8133
8136
|
};
|
|
8134
8137
|
SitesMapsComponent.prototype.addSiteMarkers = function (sites) {
|
|
@@ -9027,8 +9030,9 @@
|
|
|
9027
9030
|
}] });
|
|
9028
9031
|
|
|
9029
9032
|
var parseLog = function (data) { return ({
|
|
9030
|
-
|
|
9031
|
-
|
|
9033
|
+
modelId: data.model,
|
|
9034
|
+
impactTermId: data['key/term'] || data.term || data.indicator,
|
|
9035
|
+
emissionsResourceUseTermId: data.node,
|
|
9032
9036
|
coefficient: +data.coefficient,
|
|
9033
9037
|
value: +data.value * +data.coefficient
|
|
9034
9038
|
}); };
|
|
@@ -9036,23 +9040,31 @@
|
|
|
9036
9040
|
schema.TermTermType.emission,
|
|
9037
9041
|
schema.TermTermType.characterisedIndicator
|
|
9038
9042
|
];
|
|
9039
|
-
var toCsv = function (logs) { return __spreadArray([
|
|
9043
|
+
var toCsv = function (logs, impact) { return __spreadArray([
|
|
9040
9044
|
[
|
|
9041
|
-
'Model',
|
|
9042
9045
|
'Impact',
|
|
9046
|
+
'Impact Unit',
|
|
9047
|
+
'Method',
|
|
9048
|
+
'Emission',
|
|
9043
9049
|
'Value',
|
|
9044
9050
|
'Inputs',
|
|
9045
|
-
'Inputs value'
|
|
9051
|
+
'Inputs value',
|
|
9052
|
+
'Functional Unit'
|
|
9046
9053
|
].join(',')
|
|
9047
9054
|
], __read(logs
|
|
9048
|
-
.sort(function (a, b) { return a.
|
|
9055
|
+
.sort(function (a, b) { return a.impactTermId.localeCompare(b.impactTermId); })
|
|
9049
9056
|
.flatMap(function (_d) {
|
|
9050
|
-
var
|
|
9057
|
+
var impactTermId = _d.impactTermId, impactTermUnits = _d.impactTermUnits, modelId = _d.modelId, emissionsResourceUseTermId = _d.emissionsResourceUseTermId, value = _d.value, inputs = _d.inputs;
|
|
9051
9058
|
return __spreadArray([
|
|
9052
|
-
[
|
|
9053
|
-
], __read((inputs.map(function (v) { return [
|
|
9059
|
+
[impactTermId, impactTermUnits, modelId, emissionsResourceUseTermId, value, '', '']
|
|
9060
|
+
], __read((inputs.map(function (v) { return [impactTermId, impactTermUnits, modelId, emissionsResourceUseTermId, '', v.name, v.value]; }))));
|
|
9054
9061
|
})
|
|
9055
|
-
.map(function (v) {
|
|
9062
|
+
.map(function (v) {
|
|
9063
|
+
var _a;
|
|
9064
|
+
return __spreadArray(__spreadArray([], __read(v)), [
|
|
9065
|
+
(_a = impact.product) === null || _a === void 0 ? void 0 : _a.units
|
|
9066
|
+
]).join(',');
|
|
9067
|
+
}))).join('\n'); };
|
|
9056
9068
|
var ImpactAssessmentsIndicatorBreakdownChartComponent = /** @class */ (function () {
|
|
9057
9069
|
function ImpactAssessmentsIndicatorBreakdownChartComponent(ngZone, domSanitizer, searchService, nodeService) {
|
|
9058
9070
|
this.ngZone = ngZone;
|
|
@@ -9068,7 +9080,7 @@
|
|
|
9068
9080
|
}
|
|
9069
9081
|
ImpactAssessmentsIndicatorBreakdownChartComponent.prototype.ngOnInit = function () {
|
|
9070
9082
|
return __awaiter(this, void 0, void 0, function () {
|
|
9071
|
-
var _d,
|
|
9083
|
+
var _d, results;
|
|
9072
9084
|
var _this = this;
|
|
9073
9085
|
return __generator(this, function (_e) {
|
|
9074
9086
|
switch (_e.label) {
|
|
@@ -9084,18 +9096,24 @@
|
|
|
9084
9096
|
}), operators.map(function (_d) {
|
|
9085
9097
|
var data = _d.data;
|
|
9086
9098
|
return parseMessage(data.message);
|
|
9087
|
-
}), operators.filter(function (message) { return 'node' in message; }), operators.map(parseLog), operators.filter(function (log) { return !!log.
|
|
9099
|
+
}), operators.filter(function (message) { return 'node' in message; }), operators.map(parseLog), operators.filter(function (log) { return !!log.impactTermId && !!log.emissionsResourceUseTermId && !isNaN(log.value) && log.value > 0; }), operators.groupBy(function (log) { return [log.impactTermId, log.emissionsResourceUseTermId].join('/'); }), operators.mergeMap(function (group) { return group.pipe(operators.toArray()); }), operators.map(function (values) {
|
|
9100
|
+
var _a, _b;
|
|
9088
9101
|
var log = values[0];
|
|
9089
9102
|
var total = values.reduce(function (prev, curr) { return prev + curr.value; }, 0);
|
|
9090
|
-
var
|
|
9091
|
-
.filter(function (v) {
|
|
9103
|
+
var emissions = (_this.impactAssessment.emissionsResourceUse || [])
|
|
9104
|
+
.filter(function (v) { return v.term['@id'] === log.emissionsResourceUseTermId; });
|
|
9105
|
+
var inputs = emissions
|
|
9106
|
+
.filter(function (v) { var _a; return (_a = v.inputs) === null || _a === void 0 ? void 0 : _a.length; })
|
|
9092
9107
|
.map(function (v) { return ({ name: v.inputs.map(function (i) { return i['@id']; }).join(';'), value: v.value * log.coefficient }); });
|
|
9093
9108
|
var inputsValue = inputs.reduce(function (prev, curr) { return prev + curr.value; }, 0);
|
|
9094
|
-
|
|
9095
|
-
|
|
9109
|
+
var impacts = (_this.impactAssessment.impacts || [])
|
|
9110
|
+
.filter(function (v) { return v.term['@id'] === log.impactTermId; });
|
|
9111
|
+
// logs might exist but impact was not added => skip logs
|
|
9112
|
+
return impacts.length ? Object.assign(Object.assign({}, log), { impactTermUnits: (_b = (_a = impacts === null || impacts === void 0 ? void 0 : impacts[0]) === null || _a === void 0 ? void 0 : _a.term) === null || _b === void 0 ? void 0 : _b.units, value: total, inputs: inputs, inputsValue: inputsValue }) : null;
|
|
9113
|
+
}), operators.filter(function (log) { return !!log; }), operators.toArray()).toPromise()];
|
|
9096
9114
|
case 1:
|
|
9097
9115
|
_d.logs = (_e.sent());
|
|
9098
|
-
this.csvContent = this.domSanitizer.bypassSecurityTrustResourceUrl("data:text/html;charset=utf-8," + encodeURIComponent(toCsv(this.logs)));
|
|
9116
|
+
this.csvContent = this.domSanitizer.bypassSecurityTrustResourceUrl("data:text/html;charset=utf-8," + encodeURIComponent(toCsv(this.logs, this.impactAssessment)));
|
|
9099
9117
|
return [4 /*yield*/, this.searchService.search({
|
|
9100
9118
|
fields: ['@type', '@id', 'name'],
|
|
9101
9119
|
limit: 1000,
|
|
@@ -9110,8 +9128,8 @@
|
|
|
9110
9128
|
}
|
|
9111
9129
|
})];
|
|
9112
9130
|
case 2:
|
|
9113
|
-
|
|
9114
|
-
this.emissions =
|
|
9131
|
+
results = (_e.sent()).results;
|
|
9132
|
+
this.emissions = results;
|
|
9115
9133
|
this.loading = false;
|
|
9116
9134
|
this.selectedTerm = this.terms[0];
|
|
9117
9135
|
this.updateChart();
|
|
@@ -9132,16 +9150,16 @@
|
|
|
9132
9150
|
var _a, _b, _c;
|
|
9133
9151
|
var logs = this.logs
|
|
9134
9152
|
.filter(function (_d) {
|
|
9135
|
-
var
|
|
9136
|
-
return
|
|
9153
|
+
var impactTermId = _d.impactTermId;
|
|
9154
|
+
return impactTermId === _this.selectedTerm['@id'];
|
|
9137
9155
|
})
|
|
9138
9156
|
.sort(function (a, b) { return b.value - a.value; });
|
|
9139
9157
|
this.noData = logs.length === 0;
|
|
9140
9158
|
var total = logs.reduce(function (prev, curr) { return prev + curr.value; }, 0);
|
|
9141
9159
|
var labels = logs.map(function (_d) {
|
|
9142
|
-
var
|
|
9160
|
+
var emissionsResourceUseTermId = _d.emissionsResourceUseTermId;
|
|
9143
9161
|
var _a;
|
|
9144
|
-
return ((_a = _this.emissions.find(function (v) { return v['@id'] ===
|
|
9162
|
+
return ((_a = _this.emissions.find(function (v) { return v['@id'] === emissionsResourceUseTermId; })) === null || _a === void 0 ? void 0 : _a.name) || emissionsResourceUseTermId;
|
|
9145
9163
|
});
|
|
9146
9164
|
// display the breakdown by input
|
|
9147
9165
|
// const inputs = logs.flatMap(v => v.inputs.map(i => i.name));
|