@hestia-earth/ui-components 0.41.40 → 0.41.41
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.
|
@@ -6,7 +6,7 @@ import { FormsModule, NG_VALUE_ACCESSOR, UntypedFormBuilder, Validators, Reactiv
|
|
|
6
6
|
import { NgClass, DecimalPipe, NgTemplateOutlet, KeyValuePipe, DOCUMENT, PlatformLocation, NgStyle, UpperCasePipe, JsonPipe, DatePipe, AsyncPipe, formatDate as formatDate$1 } from '@angular/common';
|
|
7
7
|
import * as i1$1 from '@ng-bootstrap/ng-bootstrap';
|
|
8
8
|
import { NgbTooltip, NgbDropdown, NgbDropdownMenu, NgbDropdownToggle, NgbActiveModal, NgbHighlight, NgbModal, NgbDropdownItem, NgbTypeahead, NgbPopover, NgbTooltipModule, NgbDropdownModule, NgbPopoverModule } from '@ng-bootstrap/ng-bootstrap';
|
|
9
|
-
import { ReplaySubject, of, mergeMap, shareReplay, delay, map, catchError, distinctUntilChanged, timer, take, first, Subject, combineLatest, filter, tap, pipe, fromEvent, startWith, merge, skip, switchMap, EMPTY, throttleTime, animationFrameScheduler, debounceTime, lastValueFrom, skipUntil, zip, mergeAll,
|
|
9
|
+
import { ReplaySubject, of, mergeMap, shareReplay, delay, map, catchError, distinctUntilChanged, timer, take, first, Subject, combineLatest, filter, tap, pipe, fromEvent, startWith, merge, skip, switchMap, EMPTY, throttleTime, animationFrameScheduler, debounceTime, lastValueFrom, skipUntil, zip, mergeAll, reduce, forkJoin, from, firstValueFrom, toArray, distinct, groupBy } from 'rxjs';
|
|
10
10
|
import { HttpClient } from '@angular/common/http';
|
|
11
11
|
import get from 'lodash.get';
|
|
12
12
|
import { SCHEMA_VERSION, SchemaType, NodeType, TermTermType, productTermTermType, nestedSearchableKeys, SiteSiteType, EmissionMethodTier, isExpandable, sortKeysByType, isTypeNode, BlankNodesKey, impactAssessmentTermTermType, measurementTermTermType, emissionTermTermType, inputTermTermType, CycleFunctionalUnit, NonBlankNodesKey, jsonldPath, isTypeValid, isTypeBlankNode, typeToSchemaType, infrastructureTermTermType, managementTermTermType } from '@hestia-earth/schema';
|
|
@@ -7012,6 +7012,15 @@ class RelatedNodeResult {
|
|
|
7012
7012
|
this.results = [];
|
|
7013
7013
|
}
|
|
7014
7014
|
}
|
|
7015
|
+
const findIndicatorIndexFromLog = (indicators, log) => (indicators || []).findIndex(v => v.term['@id'] === log.blankNodeTermId && v.value === log.value);
|
|
7016
|
+
const keysFromLog = (impactAssessment, log) => {
|
|
7017
|
+
const emission = findIndicatorIndexFromLog(impactAssessment.emissionsResourceUse, log);
|
|
7018
|
+
const isEmission = emission >= 0;
|
|
7019
|
+
const impact = isEmission ? -1 : findIndicatorIndexFromLog(impactAssessment.impacts, log);
|
|
7020
|
+
const contributionKey = isEmission ? 'emissionsResourceUse' : 'impacts';
|
|
7021
|
+
const contributionIndex = (isEmission ? emission : impact).toString();
|
|
7022
|
+
return { contributionKey, contributionIndex };
|
|
7023
|
+
};
|
|
7015
7024
|
class HeNodeService {
|
|
7016
7025
|
constructor() {
|
|
7017
7026
|
this.http = inject(HttpClient);
|
|
@@ -7066,41 +7075,20 @@ class HeNodeService {
|
|
|
7066
7075
|
modelId: data.model,
|
|
7067
7076
|
impactTermId: data['key/term'] || data.term || data.indicator,
|
|
7068
7077
|
blankNodeTermId: data.node,
|
|
7069
|
-
coefficient: +data.coefficient
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
};
|
|
7084
|
-
logs.forEach(log => {
|
|
7085
|
-
emissionsResourceUse.forEach((entry, index) => {
|
|
7086
|
-
if (entry.term?.['@id'] === log.blankNodeTermId) {
|
|
7087
|
-
const key = index.toString();
|
|
7088
|
-
result.emissionsResourceUse[key] = result.emissionsResourceUse[key] || {};
|
|
7089
|
-
result.emissionsResourceUse[key][log.impactTermId] =
|
|
7090
|
-
result.emissionsResourceUse[key][log.impactTermId] || {};
|
|
7091
|
-
result.emissionsResourceUse[key][log.impactTermId][log.modelId] = toPrecision((entry.value || 0) * log.coefficient, 5);
|
|
7092
|
-
}
|
|
7093
|
-
});
|
|
7094
|
-
impacts.forEach((entry, index) => {
|
|
7095
|
-
if (entry.term?.['@id'] === log.blankNodeTermId) {
|
|
7096
|
-
const key = index.toString();
|
|
7097
|
-
result.impacts[key] = result.impacts[key] || {};
|
|
7098
|
-
result.impacts[key][log.impactTermId] = result.impacts[key][log.impactTermId] || {};
|
|
7099
|
-
result.impacts[key][log.impactTermId][log.modelId] = toPrecision((entry.value || 0) * log.coefficient, 5);
|
|
7100
|
-
}
|
|
7101
|
-
});
|
|
7102
|
-
});
|
|
7103
|
-
return result;
|
|
7078
|
+
coefficient: +data.coefficient,
|
|
7079
|
+
value: +data.value
|
|
7080
|
+
})), filter(log => !!log.impactTermId && !!log.blankNodeTermId && !isNaN(log.coefficient)),
|
|
7081
|
+
// match each `emissionsResourceUse`/`impacts` with the logs with the id and value
|
|
7082
|
+
reduce((prev, log) => {
|
|
7083
|
+
const { contributionKey, contributionIndex } = keysFromLog(impactAssessment, log);
|
|
7084
|
+
prev[contributionKey][contributionIndex] = prev[contributionKey][contributionIndex] || {};
|
|
7085
|
+
prev[contributionKey][contributionIndex][log.impactTermId] =
|
|
7086
|
+
prev[contributionKey][contributionIndex][log.impactTermId] || {};
|
|
7087
|
+
prev[contributionKey][contributionIndex][log.impactTermId][log.modelId] = toPrecision((log.value || 0) * log.coefficient, 5);
|
|
7088
|
+
return prev;
|
|
7089
|
+
}, {
|
|
7090
|
+
emissionsResourceUse: {},
|
|
7091
|
+
impacts: {}
|
|
7104
7092
|
}));
|
|
7105
7093
|
}
|
|
7106
7094
|
getErrorLog$({ dataState, aggregated, ...node }) {
|
|
@@ -14198,9 +14186,7 @@ class ImpactAssessmentsIndicatorBreakdownChartComponent {
|
|
|
14198
14186
|
.getContributions$(impactAssessment)
|
|
14199
14187
|
.pipe(map(contributions => parseContributions(impactAssessment, contributions)))
|
|
14200
14188
|
});
|
|
14201
|
-
this.logs = computed(() => (this.logsResource.value() ?? [])
|
|
14202
|
-
.filter(({ impactTermId, modelId }) => impactTermId === this.selectedTermId() && (!this.selectedMethodId() || modelId === this.selectedMethodId()))
|
|
14203
|
-
.sort((a, b) => b.value - a.value), ...(ngDevMode ? [{ debugName: "logs" }] : []));
|
|
14189
|
+
this.logs = computed(() => (this.logsResource.value() ?? []).filter(({ impactTermId, modelId }) => impactTermId === this.selectedTermId() && (!this.selectedMethodId() || modelId === this.selectedMethodId())), ...(ngDevMode ? [{ debugName: "logs" }] : []));
|
|
14204
14190
|
this.nonZeroLogs = computed(() => groupLogsById(this.logs()).filter(log => log.value !== 0), ...(ngDevMode ? [{ debugName: "nonZeroLogs" }] : []));
|
|
14205
14191
|
this.emissions = toSignal(this.searchService
|
|
14206
14192
|
.search$({
|
|
@@ -14248,7 +14234,7 @@ class ImpactAssessmentsIndicatorBreakdownChartComponent {
|
|
|
14248
14234
|
}, {}), ...(ngDevMode ? [{ debugName: "groupedValues" }] : []));
|
|
14249
14235
|
this.chartData = computed(() => {
|
|
14250
14236
|
const groupedValues = this.groupedValues();
|
|
14251
|
-
return Object.keys(groupedValues).length === 1
|
|
14237
|
+
return (Object.keys(groupedValues).length === 1
|
|
14252
14238
|
? this.values().map(value => ({
|
|
14253
14239
|
label: value.name,
|
|
14254
14240
|
count: value.value,
|
|
@@ -14263,7 +14249,7 @@ class ImpactAssessmentsIndicatorBreakdownChartComponent {
|
|
|
14263
14249
|
count: value.value,
|
|
14264
14250
|
backgroundColor: value.color
|
|
14265
14251
|
}))
|
|
14266
|
-
}));
|
|
14252
|
+
}))).sort((a, b) => b.count - a.count);
|
|
14267
14253
|
}, ...(ngDevMode ? [{ debugName: "chartData" }] : []));
|
|
14268
14254
|
this.chartTooltipFn = ({ includedItems, index }) => {
|
|
14269
14255
|
const { label, count: value } = this.chartData()[index] || { count: undefined };
|