diff --git a/server/routes/browser/api.py b/server/routes/browser/api.py
index 3e00e6b5bf..d9544ad942 100644
--- a/server/routes/browser/api.py
+++ b/server/routes/browser/api.py
@@ -12,17 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Knowledge Graph related handlers."""
-
-import json
-
import flask
-from flask import request
-from flask import Response
+from flask import jsonify
from server.lib import fetch
from server.lib.cache import cache
from server.routes import TIMEOUT
-import server.services.datacommons as dc
bp = flask.Blueprint('api_browser', __name__, url_prefix='/api/browser')
@@ -30,11 +25,21 @@
@bp.route('/provenance')
@cache.cached(timeout=TIMEOUT, query_string=True)
def provenance():
- """Returns all the provenance information."""
+ """Return provenance name for all available data sources."""
prov_resp = fetch.property_values(['Provenance'], 'typeOf', False)
- url_resp = fetch.property_values(prov_resp['Provenance'], "url", True)
+ prov_dcids = prov_resp.get('Provenance', [])
+
+ if not prov_dcids:
+ return jsonify({})
+
+ properties_to_fetch = ['name']
+ prop_resp = fetch.multiple_property_values(prov_dcids, properties_to_fetch,
+ True)
+
result = {}
- for dcid, urls in url_resp.items():
- if len(urls) > 0:
- result[dcid] = urls[0]
- return result
+ for dcid, props in prop_resp.items():
+ names = props.get('name', [])
+
+ result[dcid] = {'name': names[0] if names else dcid}
+
+ return jsonify(result)
diff --git a/server/tests/test_data/webdriver_recordings.tar.gz b/server/tests/test_data/webdriver_recordings.tar.gz
index 97711069f6..122b07744d 100644
Binary files a/server/tests/test_data/webdriver_recordings.tar.gz and b/server/tests/test_data/webdriver_recordings.tar.gz differ
diff --git a/server/webdriver/shared_tests/browser_test.py b/server/webdriver/shared_tests/browser_test.py
index 7a8fd26af1..1c415f3534 100644
--- a/server/webdriver/shared_tests/browser_test.py
+++ b/server/webdriver/shared_tests/browser_test.py
@@ -100,7 +100,7 @@ def test_page_serve_ca_population(self):
value='//*[@id="node-content"]/div[1]/div/table/tbody/tr[3]/td')
self.assertEqual(type_of_row[0].text, 'typeOf')
self.assertEqual(type_of_row[1].text, 'StatisticalVariable')
- self.assertEqual(type_of_row[2].text, 'datacommons.org')
+ self.assertEqual(type_of_row[2].text, 'HumanReadableStatVars')
# Assert observation charts loaded.
self.assertGreater(
diff --git a/static/css/table.scss b/static/css/table.scss
index f4dd36b652..a341a910b8 100644
--- a/static/css/table.scss
+++ b/static/css/table.scss
@@ -36,8 +36,7 @@ $border-radius: 3px;
}
.node-table .property-column,
-.node-table tr > td:last-of-type,
-.node-table tr > th:last-of-type {
+.node-table .provenance-column {
width: 25%;
}
diff --git a/static/js/browser/app.tsx b/static/js/browser/app.tsx
index a9a99b3fe7..d5ebd912f0 100644
--- a/static/js/browser/app.tsx
+++ b/static/js/browser/app.tsx
@@ -49,7 +49,7 @@ interface BrowserPagePropType {
}
interface BrowserPageStateType {
- provDomain: { [key: string]: URL };
+ provenanceNames: { [key: string]: string };
dataFetched: boolean;
}
@@ -101,7 +101,7 @@ export class BrowserPage extends React.Component<
super(props);
this.state = {
dataFetched: false,
- provDomain: {},
+ provenanceNames: {},
};
}
@@ -163,7 +163,7 @@ export class BrowserPage extends React.Component<
{outArcHeader}
@@ -186,7 +186,7 @@ export class BrowserPage extends React.Component<
)}
{this.props.pageDisplayType === PageDisplayType.PLACE_STAT_VAR && (
@@ -222,18 +222,14 @@ export class BrowserPage extends React.Component<
.get("/api/browser/provenance")
.then((resp) => {
const provenance = resp.data;
- const provDomain = {};
+ const provenanceNames = {};
for (const provId in provenance) {
- const url = provenance[provId];
- try {
- provDomain[provId] = new URL(url).host;
- } catch (err) {
- console.log("Invalid url in prov: " + url);
- }
+ const provenanceName = provenance[provId].name;
+ provenanceNames[provId] = provenanceName;
}
this.setState({
dataFetched: true,
- provDomain,
+ provenanceNames,
});
})
.catch((e) => {
diff --git a/static/js/browser/arc_table_row.tsx b/static/js/browser/arc_table_row.tsx
index e8e780818b..82a2beec92 100644
--- a/static/js/browser/arc_table_row.tsx
+++ b/static/js/browser/arc_table_row.tsx
@@ -32,14 +32,16 @@ const NUM_VALUES_UNEXPANDED = 5;
interface ArcTableRowPropType {
propertyLabel: string;
values: Array;
- // If provenanceId and src are skipped, ensure that table only has 2-columns.
+ // If provenanceId and provenanceName are skipped, ensure that table only has 2-columns.
provenanceId?: string;
- src?: URL;
+ provenanceName?: string;
// If set to true, will not add a link to the property node.
noPropLink?: boolean;
// Index of the property label; the same property can be listed multiple times
// in an arc table. This index differentiates them.
propIndex?: number;
+ // If set to true, will hide the provenance column entirely.
+ hideProvenanceColumn?: boolean;
}
interface ArcTableRowStateType {
@@ -137,17 +139,18 @@ export class ArcTableRow extends React.Component<
})}
- {this.props.provenanceId && this.props.src ? (
-
- {this.props.provenanceId && (
-
- {this.props.src}
-
- )}
- |
- ) : (
- |
- )}
+ {!this.props.hideProvenanceColumn &&
+ (this.props.provenanceId && this.props.provenanceName ? (
+
+ {this.props.provenanceId && (
+
+ {this.props.provenanceName}
+
+ )}
+ |
+ ) : (
+ |
+ ))}
);
}
diff --git a/static/js/browser/in_arc_section.tsx b/static/js/browser/in_arc_section.tsx
index 8b9ab9e1dc..4711a5ea03 100644
--- a/static/js/browser/in_arc_section.tsx
+++ b/static/js/browser/in_arc_section.tsx
@@ -33,7 +33,7 @@ const LOADING_CONTAINER_ID = "browser-in-arc-section";
interface InArcSectionsPropType {
nodeName: string;
dcid: string;
- provDomain: { [key: string]: URL };
+ provenanceNames: { [key: string]: string };
}
interface InArcSectionStateType {
data: { [parentType: string]: { [property: string]: Array } };
@@ -78,7 +78,7 @@ export class InArcSection extends React.Component<
parentType={parentType}
property={predicate}
arcValues={arcsByPredicate[predicate]}
- provDomain={this.props.provDomain}
+ provenanceNames={this.props.provenanceNames}
key={parentType + predicate}
/>
);
diff --git a/static/js/browser/in_arc_subsection.tsx b/static/js/browser/in_arc_subsection.tsx
index 6ead4456a9..403abb20fd 100644
--- a/static/js/browser/in_arc_subsection.tsx
+++ b/static/js/browser/in_arc_subsection.tsx
@@ -29,7 +29,7 @@ interface InArcSubsectionPropType {
parentType: string;
property: string;
arcValues: Array;
- provDomain: { [key: string]: URL };
+ provenanceNames: { [key: string]: string };
}
export class InArcSubsection extends React.Component {
@@ -73,10 +73,11 @@ export class InArcSubsection extends React.Component {
propertyLabel={this.props.property}
values={[{ dcid: arcValue.dcid, text: valueText }]}
provenanceId={arcValue.provenanceId}
- src={
- this.props.provDomain[arcValue.provenanceId]
- ? this.props.provDomain[arcValue.provenanceId]
- : null
+ provenanceName={
+ this.props.provenanceNames[arcValue.provenanceId] || null
+ }
+ hideProvenanceColumn={
+ this.props.parentType === "Provenance"
}
/>
);
diff --git a/static/js/browser/out_arc_section.tsx b/static/js/browser/out_arc_section.tsx
index 8e2a791f7e..23791fff64 100644
--- a/static/js/browser/out_arc_section.tsx
+++ b/static/js/browser/out_arc_section.tsx
@@ -67,7 +67,7 @@ export function shouldIgnoreProperty(property: string): boolean {
interface OutArcSectionPropType {
dcid: string;
- provDomain: { [key: string]: URL };
+ provenanceNames: { [key: string]: string };
nodeTypes: string[];
showAllProperties: boolean;
}
@@ -121,6 +121,7 @@ export class OutArcSection extends React.Component<
}
const predicates = Object.keys(this.state.data);
predicates.sort(this.predicateComparator);
+ const isProvenanceNode = this.props.nodeTypes.includes("Provenance");
return (
@@ -128,14 +129,17 @@ export class OutArcSection extends React.Component<
| Property |
Value |
- Provenance |
+ {!isProvenanceNode && (
+ Provenance |
+ )}
{predicates.map((predicate) => {
const valuesByProvenance = this.state.data[predicate];
@@ -147,12 +151,11 @@ export class OutArcSection extends React.Component<
propertyLabel={predicate}
values={valuesByProvenance[provenanceId]}
provenanceId={provenanceId}
- src={
- this.props.provDomain[provenanceId]
- ? this.props.provDomain[provenanceId]
- : null
+ provenanceName={
+ this.props.provenanceNames[provenanceId] || null
}
propIndex={index}
+ hideProvenanceColumn={isProvenanceNode}
/>
);
}