Skip to content
Snippets Groups Projects
Commit b6bee8c7 authored by Clayton, Brandon Scott's avatar Clayton, Brandon Scott
Browse files

Merge branch 'disagg' into 'main'

Update to new Response

See merge request !15
parents c72917f1 48a4757d
No related branches found
No related tags found
1 merge request!15Update to new Response
Pipeline #115724 passed
...@@ -13,7 +13,7 @@ import * as deagg from '../assets/deagg.json'; ...@@ -13,7 +13,7 @@ import * as deagg from '../assets/deagg.json';
export class AppComponent implements AfterViewInit { export class AppComponent implements AfterViewInit {
title = 'Disaggregation'; title = 'Disaggregation';
data = deagg.response.pop() as any as nshmpHaz.disaggService.DisaggResponseData; data = deagg.response as nshmpHaz.disaggService.DisaggResponseData;
@ViewChild('example') @ViewChild('example')
el: ElementRef<HTMLElement>; el: ElementRef<HTMLElement>;
......
This diff is collapsed.
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
"version": "0.0.1", "version": "0.0.1",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@ghsc/nshmp-utils": "^4.0.1", "@ghsc/nshmp-utils": "^4.0.3",
"d3": "^3.5.17" "d3": "^3.5.17"
}, },
"devDependencies": { "devDependencies": {
...@@ -121,9 +121,9 @@ ...@@ -121,9 +121,9 @@
} }
}, },
"node_modules/@ghsc/nshmp-utils": { "node_modules/@ghsc/nshmp-utils": {
"version": "4.0.1", "version": "4.0.3",
"resolved": "https://code.usgs.gov/api/v4/projects/1414/packages/npm/@ghsc/nshmp-utils/-/@ghsc/nshmp-utils-4.0.1.tgz", "resolved": "https://code.usgs.gov/api/v4/projects/1414/packages/npm/@ghsc/nshmp-utils/-/@ghsc/nshmp-utils-4.0.3.tgz",
"integrity": "sha1-yObd029c9M3GhSlnGvVaDWfQJgo=", "integrity": "sha1-jnoLpvst5DJVjmwkG8ReMtoOb/c=",
"dependencies": { "dependencies": {
"@mapbox/geojson-extent": "^1.0.0", "@mapbox/geojson-extent": "^1.0.0",
"change-case": "^4.1.2", "change-case": "^4.1.2",
...@@ -2108,9 +2108,9 @@ ...@@ -2108,9 +2108,9 @@
} }
}, },
"@ghsc/nshmp-utils": { "@ghsc/nshmp-utils": {
"version": "4.0.1", "version": "4.0.3",
"resolved": "https://code.usgs.gov/api/v4/projects/1414/packages/npm/@ghsc/nshmp-utils/-/@ghsc/nshmp-utils-4.0.1.tgz", "resolved": "https://code.usgs.gov/api/v4/projects/1414/packages/npm/@ghsc/nshmp-utils/-/@ghsc/nshmp-utils-4.0.3.tgz",
"integrity": "sha1-yObd029c9M3GhSlnGvVaDWfQJgo=", "integrity": "sha1-jnoLpvst5DJVjmwkG8ReMtoOb/c=",
"requires": { "requires": {
"@mapbox/geojson-extent": "^1.0.0", "@mapbox/geojson-extent": "^1.0.0",
"change-case": "^4.1.2", "change-case": "^4.1.2",
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
"typescript": "^4.0.2" "typescript": "^4.0.2"
}, },
"dependencies": { "dependencies": {
"@ghsc/nshmp-utils": "^4.0.1", "@ghsc/nshmp-utils": "^4.0.3",
"d3": "^3.5.17" "d3": "^3.5.17"
}, },
"husky": { "husky": {
......
...@@ -8,13 +8,12 @@ var Disaggregation = require('./Disaggregation'), ...@@ -8,13 +8,12 @@ var Disaggregation = require('./Disaggregation'),
// Default values to be used by constructor // Default values to be used by constructor
var _DEFAULTS = { var _DEFAULTS = {
metadata: { metadata: {
imt: { value: 'Unknown' },
rlabel: 'Distance', rlabel: 'Distance',
mlabel: 'Magnitude', mlabel: 'Magnitude',
εlabel: 'Contribution', εlabel: 'Contribution',
εbins: [], εbins: [],
}, },
data: [], disaggs: [],
}; };
var _DEAGG_ID = 0; var _DEAGG_ID = 0;
...@@ -36,29 +35,34 @@ var DisaggResponse = function (params) { ...@@ -36,29 +35,34 @@ var DisaggResponse = function (params) {
* *
*/ */
_initialize = function (params) { _initialize = function (params) {
var attributes, deaggs, metadata; var attributes, metadata, imt;
params = Util.extend({}, _DEFAULTS, { id: 'deagg-response-' + _DEAGG_ID++ }, params); params = Util.extend({}, _DEFAULTS, { id: 'disagg-response-' + _DEAGG_ID++ }, params);
metadata = params.metadata; metadata = params.metadata;
deaggs = params.data.map(function (deagg) { var disaggs = [];
return Disaggregation( params.disaggs.forEach(function (disagg) {
Util.extend( imt = disagg.imt;
{ disagg.data.forEach(function (data) {
metadata: metadata, var disagg = Disaggregation(
}, Util.extend(
deagg {
) metadata,
); },
data
)
);
disaggs.push(disagg);
});
}); });
attributes = { attributes = {
imt: metadata.imt.value, imt: imt.value,
rlabel: metadata.rlabel, rlabel: metadata.rlabel,
mlabel: metadata.mlabel, mlabel: metadata.mlabel,
εlabel: metadata.εlabel, εlabel: metadata.εlabel,
εbins: metadata.εbins, εbins: metadata.εbins,
disaggregations: Collection(deaggs), disaggregations: Collection(disaggs),
}; };
// Should not have listeners yet, but silent anyway to short-circuit check // Should not have listeners yet, but silent anyway to short-circuit check
...@@ -66,10 +70,10 @@ var DisaggResponse = function (params) { ...@@ -66,10 +70,10 @@ var DisaggResponse = function (params) {
}; };
_this.destroy = Util.compose(function () { _this.destroy = Util.compose(function () {
var deaggs; var disaggs;
deaggs = _this.get('disaggregations'); disaggs = _this.get('disaggregations');
deaggs.destroy(); disaggs.destroy();
_initialize = null; _initialize = null;
_this = null; _this = null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment