From da554151f8e99819caa70bc2d1c87ef19dba761e Mon Sep 17 00:00:00 2001 From: Siarhei Nekhviadovich Date: Tue, 26 Nov 2024 22:59:08 +0100 Subject: [PATCH 1/2] Visualize dimensions for Semantic Models --- .../dimension_details/dimension_details.html | 37 ++++++++++++++++ .../dimension_details/dimension_details.js | 44 +++++++++++++++++++ src/app/components/index.js | 1 + src/app/docs/semantic_model.html | 9 ++++ 4 files changed, 91 insertions(+) create mode 100644 src/app/components/dimension_details/dimension_details.html create mode 100644 src/app/components/dimension_details/dimension_details.js diff --git a/src/app/components/dimension_details/dimension_details.html b/src/app/components/dimension_details/dimension_details.html new file mode 100644 index 00000000..8b64829d --- /dev/null +++ b/src/app/components/dimension_details/dimension_details.html @@ -0,0 +1,37 @@ +
+
+
+ Dimension information is not available for this seed +
+
+ + + + + + + + + + + + + + + +
dimensionTypeDescription
+
+ {{ get_dim_name(dimension.name) }} +
+
+ {{ dimension.type }}

+
+ {{ dimension.description }}

+
+
+
+
diff --git a/src/app/components/dimension_details/dimension_details.js b/src/app/components/dimension_details/dimension_details.js new file mode 100644 index 00000000..acda3876 --- /dev/null +++ b/src/app/components/dimension_details/dimension_details.js @@ -0,0 +1,44 @@ +'use strict'; + +const template = require('./dimension_details.html'); + +const _ = require('underscore'); + +angular + .module('dbt') + .directive('dimensionDetails', ['project', function (projectService) { + return { + scope: { + model: '=', + }, + templateUrl: template, + link: function (scope) { + + console.log(scope); + + scope.getState = function (node) { + return 'dbt.' + node.resource_type; + } + + scope.get_dim_name = function (dim_name) { + return projectService.caseColumn(dim_name); + } + + + var dimensions = _.chain(scope.model.dimensions) + .values() + .sortBy('name') + .value(); + + // re-number dimensions because index comes from the catalog, and index may not always be present + // this prevents errors with the view's `track by dimension.index` + _.each(dimensions, function (col, i) { + col.index = i; + }); + + scope.dimensions = dimensions; + + } + } + }]); + diff --git a/src/app/components/index.js b/src/app/components/index.js index 2d01c094..a53696d3 100644 --- a/src/app/components/index.js +++ b/src/app/components/index.js @@ -6,6 +6,7 @@ require('./model_tree/model_tree_line.js'); require('./search/search.js'); require('./table_details/table_details.js'); require('./column_details/column_details.js'); +require('./dimension_details/dimension_details.js'); require('./code_block/code_block.js'); require('./macro_arguments/'); require('./references/'); diff --git a/src/app/docs/semantic_model.html b/src/app/docs/semantic_model.html index 13e52ded..a4c12a4e 100644 --- a/src/app/docs/semantic_model.html +++ b/src/app/docs/semantic_model.html @@ -83,6 +83,15 @@
Entities
+ +
+
+
+
Dimensions
+ + +
+
From 15b2813d72f6b146243474506d806173c6b0b93f Mon Sep 17 00:00:00 2001 From: Siarhei Nekhviadovich Date: Tue, 26 Nov 2024 23:07:04 +0100 Subject: [PATCH 2/2] Docs update --- .changes/unreleased/Docs-20241126-230636.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Docs-20241126-230636.yaml diff --git a/.changes/unreleased/Docs-20241126-230636.yaml b/.changes/unreleased/Docs-20241126-230636.yaml new file mode 100644 index 00000000..7c11760f --- /dev/null +++ b/.changes/unreleased/Docs-20241126-230636.yaml @@ -0,0 +1,6 @@ +kind: Docs +body: Add dimensions list to the Semantic Model docs +time: 2024-11-26T23:06:36.7899668+01:00 +custom: + Author: SOVALINUX + Issue: "434"