Skip to content

Commit

Permalink
(#135) adds report node type
Browse files Browse the repository at this point in the history
  • Loading branch information
drewbanin committed Sep 15, 2020
1 parent 05bda78 commit 15d08f9
Show file tree
Hide file tree
Showing 19 changed files with 227 additions and 47 deletions.
11 changes: 11 additions & 0 deletions src/app/components/model_tree/model_tree.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@
<br />
</div>

<div ng-show="tree.reports.length > 0">
<strong>Reports</strong>
<ul style="display: block">
<model-tree-line
item="item"
resource-type="report"
ng-repeat="item in tree.reports"></model-tree-line>
</ul>
<br />
</div>

<strong>Projects</strong>
<ul>
<model-tree-line
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/references/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="panel">
<div class="panel-body" ng-if="!has_references">
No resources reference this macro
No resources reference this {{ node.resource_type }}
</div>
<div class="panel-body" ng-if="has_references">
<ul class="nav nav-tabs">
Expand Down
3 changes: 3 additions & 0 deletions src/app/components/references/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ angular
return {
scope: {
references: '=',
node: '=',
},
restrict: 'E',
templateUrl: template,
Expand Down Expand Up @@ -38,6 +39,8 @@ angular
return 'Analyses';
} else if (type == 'macro') {
return 'Macros';
} else if (type == 'report') {
return 'Reports';
} else {
return 'Nodes';
}
Expand Down
3 changes: 2 additions & 1 deletion src/app/components/table_details/table_details.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ angular
return {
scope: {
model: '=',
extras: '='
extras: '=',
showDefaults: '<',
},
templateUrl: template,
link: function(scope) {
Expand Down
9 changes: 0 additions & 9 deletions src/app/docs/analysis.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ <h1>
<div class="app-frame app-pad-h">
<ul class="nav nav-tabs">
<li ui-sref-active='active'><a ui-sref="dbt.analysis({'#': 'description'})">Description</a></li>
<li ui-sref-active='active' ng-show = "referencesLength != 0"><a ui-sref="dbt.analysis({'#': 'referenced_by'})">Referenced By</a></li>
<li ui-sref-active='active' ng-show = "parentsLength != 0"><a ui-sref="dbt.analysis({'#': 'depends_on'})">Depends On</a></li>
<li ui-sref-active='active'><a ui-sref="dbt.analysis({'#': 'sql'})">SQL</a></li>
</ul>
Expand All @@ -56,14 +55,6 @@ <h6>Description</h6>
</div>
</section>

<section class="section" ng-show = "referencesLength != 0">
<div class="section-target" id="referenced_by"></div>
<div class="section-content">
<h6>Referenced By</h6>
<reference-list references="references" />
</div>
</section>

<section class="section" ng-show = "parentsLength != 0">
<div class="section-target" id="depends_on"></div>
<div class="section-content">
Expand Down
1 change: 1 addition & 0 deletions src/app/docs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ require('./snapshot');
require('./test');
require('./macro');
require('./analysis');
require('./report');
4 changes: 2 additions & 2 deletions src/app/docs/macro.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ <h6>Arguments</h6>
<div class="section-target" id="referenced_by"></div>
<div class="section-content">
<h6>Referenced By</h6>
<reference-list references="references" />
<reference-list references="references" node="macro" />
</div>
</section>

<section class="section" ng-show = "parentsLength != 0">
<div class="section-target" id="depends_on"></div>
<div class="section-content">
<h6>Depends On</h6>
<reference-list references="parents" />
<reference-list references="parents" node="macro" />
</div>
</section>

Expand Down
4 changes: 2 additions & 2 deletions src/app/docs/model.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ <h6>Columns</h6>
<div class="section-target" id="referenced_by"></div>
<div class="section-content">
<h6>Referenced By</h6>
<reference-list references="references" />
<reference-list references="references" node="model" />
</div>
</section>

<section class="section" ng-show = "parentsLength != 0">
<div class="section-target" id="depends_on"></div>
<div class="section-content">
<h6>Depends On</h6>
<reference-list references="parents" />
<reference-list references="parents" node="model" />
</div>
</section>

Expand Down
79 changes: 79 additions & 0 deletions src/app/docs/report.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<style>
/* TODO */
.section-target {
top: -8em;
}

.noflex {
flex: 0 0 160px !important;
}

.highlight {
color: #24292e;
background-color: white;
}

</style>

<div class='app-scroll'>
<div class="app-links app-sticky">
<div class="app-title">
<div class="app-frame app-pad app-flush-bottom">

<h1>
<span class="break">{{ report.name }}</span>
<small>report</small>

<div class='pull-right' ng-show="report.url">
<a class='btn text-white btn-primary btn-sm' ng-href="{{ report.url }}" target="_blank">View this report</a>
</div>

<div class='clearfix'></div>
</h1>

</div>
</div>
<div class="app-frame app-pad-h">
<ul class="nav nav-tabs">
<li ui-sref-active='active'><a ui-sref="dbt.report({'#': 'details'})">Details</a></li>
<li ui-sref-active='active'><a ui-sref="dbt.report({'#': 'description'})">Description</a></li>
<li ui-sref-active='active' ng-show = "parentsLength != 0"><a ui-sref="dbt.report({'#': 'depends_on'})">Depends On</a></li>
</ul>
</div>
</div>
<div class="app-details">
<div class="app-frame app-pad">

<section class="section">
<div class="section-target" id="details"></div>
<table-details model="report" extras="extra_table_fields" show-defaults="false" />
</section>

<section class="section">
<div class="section-target" id="description"></div>
<div class="section-content">
<h6>Description</h6>
<div class="panel">
<div class="panel-body">
<div ng-show="report.url" class='margin'>
View this report at <a ng-href="{{ report.url }}" target="_blank">{{ report.url }}</a>
</div>

<div ng-if="report.description" class="model-markdown" marked="report.description"></div>
<div ng-if="!report.description">This {{ report.resource_type }} is not currently documented</div>
</div>
</div>
</div>
</section>

<section class="section" ng-show = "parentsLength != 0">
<div class="section-target" id="depends_on"></div>
<div class="section-content">
<h6>Depends On</h6>
<reference-list references="parents" node="report" />
</div>
</section>

</div>
</div>
</div>
41 changes: 41 additions & 0 deletions src/app/docs/report.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
'use strict';

const angular = require('angular');
const dag_utils = require('./dag_utils')
require("./styles.css");

angular
.module('dbt')
.controller('ReportCtrl', ['$scope', '$state', 'project', 'code', '$anchorScroll', '$location',
function($scope, $state, projectService, codeService, $anchorScroll, $location) {

$scope.model_uid = $state.params.unique_id;
$scope.project = projectService;

$scope.codeService = codeService;
$scope.extra_table_fields = [];
$scope.versions = {};

$scope.report = {};
projectService.ready(function(project) {
let report = project.nodes[$scope.model_uid];
$scope.report = report;
$scope.parents = dag_utils.getParents(project, report);
$scope.parentsLength = $scope.parents.length;

$scope.extra_table_fields = [
{
name: "Maturity",
value: $scope.report.maturity
},
{
name: "Owner",
value: $scope.report.owner.name
},
{
name: "Owner email",
value: $scope.report.owner.email
},
]
})
}]);
4 changes: 2 additions & 2 deletions src/app/docs/seed.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ <h6>Columns</h6>
<div class="section-target" id="referenced_by"></div>
<div class="section-content">
<h6>Referenced By</h6>
<reference-list references="references" />
<reference-list references="references" node="model" />
</div>
</section>

<section class="section" ng-show = "parentsLength != 0">
<div class="section-target" id="depends_on"></div>
<div class="section-content">
<h6>Depends On</h6>
<reference-list references="parents" />
<reference-list references="parents" node="model" />
</div>
</section>

Expand Down
4 changes: 2 additions & 2 deletions src/app/docs/snapshot.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ <h6>Columns</h6>
<div class="section-target" id="referenced_by"></div>
<div class="section-content">
<h6>Referenced By</h6>
<reference-list references="references" />
<reference-list references="references" node="model" />
</div>
</section>

<section class="section" ng-show = "parentsLength != 0">
<div class="section-target" id="depends_on"></div>
<div class="section-content">
<h6>Depends On</h6>
<reference-list references="parents" />
<reference-list references="parents" node="model" />
</div>
</section>

Expand Down
11 changes: 1 addition & 10 deletions src/app/docs/source.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ <h1>
<li ui-sref-active='active'><a ui-sref="dbt.source({'#': 'description'})">Description</a></li>
<li ui-sref-active='active'><a ui-sref="dbt.source({'#': 'columns'})">Columns</a></li>
<li ui-sref-active='active' ng-show = "referencesLength != 0"><a ui-sref="dbt.source({'#': 'referenced_by'})">Referenced By</a></li>
<li ui-sref-active='active' ng-show = "parentsLength != 0"><a ui-sref="dbt.source({'#': 'depends_on'})">Depends On</a></li>
<li ui-sref-active='active'><a ui-sref="dbt.source({'#': 'code'})">SQL</a></li>
</ul>
</div>
Expand Down Expand Up @@ -67,15 +66,7 @@ <h6>Columns</h6>
<div class="section-target" id="referenced_by"></div>
<div class="section-content">
<h6>Referenced By</h6>
<reference-list references="references" />
</div>
</section>

<section class="section" ng-show = "parentsLength != 0">
<div class="section-target" id="depends_on"></div>
<div class="section-content">
<h6>Depends On</h6>
<reference-list references="parents" />
<reference-list references="references" node="model" />
</div>
</section>

Expand Down
11 changes: 1 addition & 10 deletions src/app/docs/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ <h1>
<div class="app-frame app-pad-h">
<ul class="nav nav-tabs">
<li ui-sref-active='active'><a ui-sref="dbt.test({'#': 'description'})">Description</a></li>
<li ui-sref-active='active' ng-show = "referencesLength != 0"><a ui-sref="dbt.test({'#': 'referenced_by'})">Referenced By</a></li>
<li ui-sref-active='active' ng-show = "parentsLength != 0"><a ui-sref="dbt.test({'#': 'depends_on'})">Depends On</a></li>
<li ui-sref-active='active'><a ui-sref="dbt.test({'#': 'code'})">SQL</a></li>
</ul>
Expand All @@ -49,19 +48,11 @@ <h6>Description</h6>
</div>
</section>

<section class="section" ng-show = "referencesLength != 0">
<div class="section-target" id="referenced_by"></div>
<div class="section-content">
<h6>Referenced By</h6>
<reference-list references="references" />
</div>
</section>

<section class="section" ng-show = "parentsLength != 0">
<div class="section-target" id="depends_on"></div>
<div class="section-content">
<h6>Depends On</h6>
<reference-list references="parents" />
<reference-list references="parents" node="model" />
</div>
</section>

Expand Down
13 changes: 11 additions & 2 deletions src/app/index.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const templates = {
test: require('./docs/test.html'),
analysis: require('./docs/analysis.html'),
macro: require('./docs/macro.html'),
report: require('./docs/report.html'),
}

angular
Expand Down Expand Up @@ -83,7 +84,7 @@ angular
},
})
.state('dbt.analysis', {
url: 'analysis/:unique_id?section',
url: 'analysis/:unique_id?section&' + graph_params,
controller: 'AnalysisCtrl',
templateUrl: templates.analysis,
params: {
Expand All @@ -99,7 +100,7 @@ angular
},
})
.state('dbt.source_list', {
url: 'source_list/:source?' + graph_params,
url: 'source_list/:source?section&' + graph_params,
controller: 'SourceListCtrl',
templateUrl: templates.source_list,
params: {
Expand All @@ -114,4 +115,12 @@ angular
unique_id: {type: 'string'}
},
})
.state('dbt.report', {
url: 'report/:unique_id?section&' + graph_params,
controller: 'ReportCtrl',
templateUrl: templates.report,
params: {
unique_id: {type: 'string'}
},
})
}])
1 change: 1 addition & 0 deletions src/app/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ angular
$scope.tree.database = tree.database;
$scope.tree.project = tree.project;
$scope.tree.sources = tree.sources;
$scope.tree.reports = tree.reports;

setTimeout(function() {
scrollToSelectedModel($scope.model_uid);
Expand Down
8 changes: 7 additions & 1 deletion src/app/services/graph.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ angular
'background-color': '#5fb825',
}
},
{
selector: 'node[resource_type="report"]',
style: {
'background-color': '#ff694b',
}
},
{
selector: 'node[selected=1]',
style: {
Expand Down Expand Up @@ -323,7 +329,7 @@ angular


_.each(_.filter(service.manifest.nodes, function(node) {
var is_graph_type = _.includes(['model', 'seed', 'source', 'snapshot', 'analysis'], node.resource_type);
var is_graph_type = _.includes(['model', 'seed', 'source', 'snapshot', 'analysis', 'report'], node.resource_type);
var is_data_test = node.resource_type == 'test' && _.includes(node.tags, 'data');
return is_graph_type || is_data_test;
}), function(node) {
Expand Down
Loading

0 comments on commit 15d08f9

Please sign in to comment.