Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visualize dimensions for Semantic Models #535

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/Docs-20241126-230636.yaml
Original file line number Diff line number Diff line change
@@ -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"
37 changes: 37 additions & 0 deletions src/app/components/dimension_details/dimension_details.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<div class="panel">
<div class="panel-body">
<div ng-if="_.isEmpty(model.dimensions)">
Dimension information is not available for this seed
</div>
<div class="table-responsive"
style="max-height: 800px; overflow-y: scroll;"
ng-if="!_.isEmpty(model.dimensions)">
<table class="table table-borderless table-hover">
<thead>
<tr>
<th style="background-color: white; position: sticky; top: 0; z-index: 1;">dimension</th>
<th style="background-color: white; position: sticky; top: 0; z-index: 1;">Type</th>
<th style="background-color: white; position: sticky; top: 0; z-index: 1;">Description</th>
</tr>
</thead>
<tbody>
<tr
ng-repeat="dimension in dimensions track by dimension.index"
class="column-row">
<td>
<div>
<span class='text-dark'>{{ get_dim_name(dimension.name) }}</span>
</div>
</td>
<td>
<span class='text-dark'>{{ dimension.type }}</p>
</td>
<td>
<span class='text-dark'>{{ dimension.description }}</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
44 changes: 44 additions & 0 deletions src/app/components/dimension_details/dimension_details.js
Original file line number Diff line number Diff line change
@@ -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;

}
}
}]);

1 change: 1 addition & 0 deletions src/app/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/');
9 changes: 9 additions & 0 deletions src/app/docs/semantic_model.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ <h6>Entities</h6>
</div>
</div>
</section>

<section class="section" ng-show = "semantic_model.dimensions.length != 0">
<div class="section-target" id="dimensions"></div>
<div class="section-content">
<h6>Dimensions</h6>

<dimension-details model="semantic_model" />
</div>
</section>

<section class="section" ng-show = "parentsLength != 0">
<div class="section-target" id="depends_on"></div>
Expand Down