@hestia-earth/ui-components 0.0.22 → 0.0.23

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.
@@ -1371,12 +1371,27 @@
1371
1371
  var HE_ORCHESTRATOR_BASE_URL = new i0.InjectionToken('HE_ORCHESTRATOR_BASE_URL');
1372
1372
  var gitUrl = function () { return gitHome + "/hestia-engine-models/-/blob/" + gitBranch(); };
1373
1373
  var rawUrl = function () { return gitRawBaseUrl + "/hestia-engine-models/-/raw/" + gitBranch(); };
1374
- var findConfigModels = function (_b, modelId, modelKey) {
1375
- var models = _b.models;
1376
- return models.flat().filter(function (_b) {
1374
+ var findModels = function (models, termId) { return models.filter(function (_b) {
1375
+ var term = _b.term;
1376
+ return term === termId;
1377
+ }); };
1378
+ /**
1379
+ * Find models from the orchestrator configuration.
1380
+ *
1381
+ * @param config The orchestrator configuration content.
1382
+ * @param termId The `@id` of the Term.
1383
+ * @param model The `@id` of the model.
1384
+ * @param models Optional - list of models from `model-links.json` to default when orchestrator does not contain config.
1385
+ * @returns List of models from orchestrator or models if set.
1386
+ */
1387
+ var findConfigModels = function (config, termId, model, models) {
1388
+ if (models === void 0) { models = []; }
1389
+ var configModels = config.models.flat()
1390
+ .filter(function (_b) {
1377
1391
  var value = _b.value, key = _b.key;
1378
- return modelId.startsWith(value) && (!modelKey || key === modelKey);
1392
+ return termId === value && (!model || key === model);
1379
1393
  });
1394
+ return configModels.length ? configModels : findModels(models, termId);
1380
1395
  };
1381
1396
  var pathToApiDocsPath = function (model, term) { return [
1382
1397
  baseUrl(),
@@ -5263,7 +5278,16 @@
5263
5278
  var _d$1, _e;
5264
5279
  var get$3 = require('lodash.get');
5265
5280
  var orderBy$5 = require('lodash.orderby');
5266
- var reduceValues = function (values, termId) { return values.length ? values.reduce(function (p, v) { return p + propertyValue$1(v.value, termId); }, 0) : undefined; };
5281
+ var reduceValues = function (values, termId) {
5282
+ var propertyValues = values
5283
+ .map(function (_d) {
5284
+ var value = _d.value;
5285
+ return propertyValue$1(value, termId);
5286
+ })
5287
+ // propertyValue may return null if the value is null or undefined, therefore remove them from total
5288
+ .filter(function (v) { return v !== null; });
5289
+ return propertyValues.length ? propertyValues.reduce(function (p, v) { return p + v; }, 0) : undefined;
5290
+ };
5267
5291
  var logSubValue = function (logs, key, prop) { return logs[key][prop] ? (Array.isArray(logs[key][prop]) ?
5268
5292
  logs[key][prop].map(function (value) { return ({ key: prop, value: value }); }) :
5269
5293
  { key: prop, value: logs[key][prop] }) : undefined; };
@@ -5325,7 +5349,7 @@
5325
5349
  }
5326
5350
  NodeLogsModelsComponent.prototype.ngOnInit = function () {
5327
5351
  return __awaiter(this, void 0, void 0, function () {
5328
- var _d, models, _e, originalValues, recalculatedValues, type, _f;
5352
+ var _d, models, _e, allModels, originalValues, recalculatedValues, type, _f;
5329
5353
  var _this = this;
5330
5354
  return __generator(this, function (_g) {
5331
5355
  switch (_g.label) {
@@ -5356,6 +5380,9 @@
5356
5380
  }, {})).toPromise()];
5357
5381
  case 3:
5358
5382
  _e.methodsById = _g.sent();
5383
+ return [4 /*yield*/, this.hestiaEngineService.models()];
5384
+ case 4:
5385
+ allModels = _g.sent();
5359
5386
  originalValues = (this.originalValues || []).filter(function (value) { return !value.deleted; });
5360
5387
  recalculatedValues = (this.recalculatedValues || []).filter(function (value) { return !value.deleted; });
5361
5388
  type = originalValues.length ?
@@ -5365,14 +5392,14 @@
5365
5392
  undefined;
5366
5393
  _f = this;
5367
5394
  return [4 /*yield*/, this.fetchAllTerms()];
5368
- case 4:
5395
+ case 5:
5369
5396
  _f.allTerms = _g.sent();
5370
5397
  this.allBlankNodes = this.allTerms.flatMap(function (term) {
5371
5398
  var termLogs = get$3(_this.logs, term['@id'], {});
5372
5399
  var original = originalValues.filter(function (v) { return term['@id'] === v.term['@id']; });
5373
5400
  var recalculated = recalculatedValues.filter(function (v) { return term['@id'] === v.term['@id']; });
5374
5401
  var hasData = !!original.length || !!recalculated.length || Object.keys(termLogs).length > 0;
5375
- var configModels = utils.unique(__spreadArray(__spreadArray([], __read(findConfigModels(_this.config, term['@id'], _this.nodeKey).map(function (_d) {
5402
+ var configModels = utils.unique(__spreadArray(__spreadArray([], __read(findConfigModels(_this.config, term['@id'], _this.nodeKey, allModels).map(function (_d) {
5376
5403
  var model = _d.model;
5377
5404
  return model;
5378
5405
  }))), __read(Object.keys(termLogs).filter(function (key) { return !isBackgroundNoInput(termLogs, key); })))).filter(function (key) { return !(key in termLogs) || (!termLogs[key].isKey && !termLogs[key].input && !termLogs[key].property); });
@@ -5827,7 +5854,7 @@
5827
5854
  }] } });
5828
5855
 
5829
5856
  var ignoreKeys = [
5830
- '@type', 'added', 'updated', 'addedVersion', 'updatedVersion'
5857
+ '@type', 'type', 'added', 'updated', 'addedVersion', 'updatedVersion'
5831
5858
  ];
5832
5859
  var CyclesCompletenessComponent = /** @class */ (function () {
5833
5860
  function CyclesCompletenessComponent() {
@@ -6501,7 +6528,7 @@
6501
6528
  "The " + paths[0].path + " are invalid";
6502
6529
  },
6503
6530
  _f['may be between 0 and 100'] = function () { return 'percentages should be between 0 and 100, not 0 and 1. This may be an error.'; },
6504
- _f['may not all be set to false'] = function () { return "You may have forgotten to fill in the data completeness assessment.\n For information on how to fill it in, please see the " + schemaLink('Cycle#dataCompleteness', 'schema') + "."; },
6531
+ _f['may not all be set to false'] = function () { return "Every value in the data completeness assessment is " + code('false') + ". You may have forgotten to fill it in.\n For information on how to fill it in, please see the " + schemaLink('Cycle#dataCompleteness', 'schema') + "."; },
6505
6532
  _f['may not be empty'] = function () { return 'if this value signifies no data, Hestia only accepts "-" or empty for no data'; },
6506
6533
  _f['may not be 0'] = function (_f, errorCount) {
6507
6534
  var dataPath = _f.dataPath;
@@ -6581,6 +6608,10 @@
6581
6608
  var params = _f.params;
6582
6609
  return "If the amount produced is zero, the revenue of " + (errorCount === 1 ? code(params === null || params === void 0 ? void 0 : params.term.name) : 'that product') + " must also be zero.";
6583
6610
  },
6611
+ _f['should add a source'] = function (_f) {
6612
+ var params = _f.params;
6613
+ return "We recommend adding a Source to all data items.\n This can be done by adding the " + code(params === null || params === void 0 ? void 0 : params.current) + " field.\n Sources can also be specified for each data item (i.e., each Input, Emission, Product, Practice, Measurement, or Infrastructure).";
6614
+ },
6584
6615
  _f);
6585
6616
  var formatCustomErrorMessage = function (message, error, errorCount) {
6586
6617
  if (errorCount === void 0) { errorCount = 1; }
@@ -8588,10 +8619,17 @@
8588
8619
  enumerable: false,
8589
8620
  configurable: true
8590
8621
  });
8622
+ Object.defineProperty(ImpactAssessmentsProductsLogsComponent.prototype, "filteredType", {
8623
+ get: function () {
8624
+ return this.filterTermTypes.map(termTypeLabel).join(' & ');
8625
+ },
8626
+ enumerable: false,
8627
+ configurable: true
8628
+ });
8591
8629
  return ImpactAssessmentsProductsLogsComponent;
8592
8630
  }());
8593
8631
  ImpactAssessmentsProductsLogsComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ImpactAssessmentsProductsLogsComponent, deps: [{ token: HeSearchService }, { token: HeNodeService }], target: i0__namespace.ɵɵFactoryTarget.Component });
8594
- ImpactAssessmentsProductsLogsComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: ImpactAssessmentsProductsLogsComponent, selector: "he-impact-assessments-products-logs", inputs: { impactAssessment: "impactAssessment", key: "key", filterTermTypes: "filterTermTypes", originalValues: "originalValues", recalculatedValues: "recalculatedValues" }, ngImport: i0__namespace, template: "<he-node-logs-models *ngIf=\"!loading; else loader\"\n [logsUrl]=\"logsUrl\"\n [nodeType]=\"NodeType.ImpactAssessment\"\n [nodeKey]=\"key\"\n [originalValues]=\"originalValues\"\n [recalculatedValues]=\"recalculatedValues\"\n [terms]=\"emissions\"\n [logs]=\"logs\"\n filteredType=\"Emission\"\n></he-node-logs-models>\n\n<ng-template #loader>\n <div class=\"has-text-center py-3\">\n <fa-icon icon=\"spinner\" [pulse]=\"true\" size=\"lg\"></fa-icon>\n </div>\n</ng-template>\n", styles: [""], components: [{ type: NodeLogsModelsComponent, selector: "he-node-logs-models", inputs: ["nodeType", "nodeKey", "logsUrl", "originalValues", "recalculatedValues", "terms", "logs", "filteredType"] }, { type: i1__namespace.FaIconComponent, selector: "fa-icon", inputs: ["classes", "icon", "title", "spin", "pulse", "mask", "styles", "flip", "size", "pull", "border", "inverse", "symbol", "rotate", "fixedWidth", "transform", "a11yRole"] }], directives: [{ type: i6__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
8632
+ ImpactAssessmentsProductsLogsComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: ImpactAssessmentsProductsLogsComponent, selector: "he-impact-assessments-products-logs", inputs: { impactAssessment: "impactAssessment", key: "key", filterTermTypes: "filterTermTypes", originalValues: "originalValues", recalculatedValues: "recalculatedValues" }, ngImport: i0__namespace, template: "<he-node-logs-models *ngIf=\"!loading; else loader\"\n [logsUrl]=\"logsUrl\"\n [nodeType]=\"NodeType.ImpactAssessment\"\n [nodeKey]=\"key\"\n [originalValues]=\"originalValues\"\n [recalculatedValues]=\"recalculatedValues\"\n [terms]=\"emissions\"\n [logs]=\"logs\"\n [filteredType]=\"filteredType\"\n></he-node-logs-models>\n\n<ng-template #loader>\n <div class=\"has-text-center py-3\">\n <fa-icon icon=\"spinner\" [pulse]=\"true\" size=\"lg\"></fa-icon>\n </div>\n</ng-template>\n", styles: [""], components: [{ type: NodeLogsModelsComponent, selector: "he-node-logs-models", inputs: ["nodeType", "nodeKey", "logsUrl", "originalValues", "recalculatedValues", "terms", "logs", "filteredType"] }, { type: i1__namespace.FaIconComponent, selector: "fa-icon", inputs: ["classes", "icon", "title", "spin", "pulse", "mask", "styles", "flip", "size", "pull", "border", "inverse", "symbol", "rotate", "fixedWidth", "transform", "a11yRole"] }], directives: [{ type: i6__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
8595
8633
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ImpactAssessmentsProductsLogsComponent, decorators: [{
8596
8634
  type: i0.Component,
8597
8635
  args: [{