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

Fix/no duped sources #87

Merged
merged 4 commits into from
May 5, 2020
Merged
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
10,023 changes: 10,023 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"devDependencies": {
"angular": "^1.7.9",
"angular-highlightjs": "^0.7.1",
"angular-loader": "~1.5.0",
"angular-marked": "^1.2.2",
"angular-route": "^1.5.0",
Expand All @@ -20,17 +19,17 @@
"dagre": "^0.7.4",
"deepmerge": "^2.1.1",
"file-loader": "^1.1.11",
"highlightjs-line-numbers.js": "^2.3.0",
"html-loader": "^0.5.5",
"html-webpack-inline-source-plugin": "^0.0.10",
"html-webpack-inline-svg-plugin": "^1.2.4",
"html-webpack-plugin": "^3.2.0",
"html5-boilerplate": "^5.3.0",
"inline-source": "^6.1.5",
"jquery": "^3.4.0",
"jquery": "~3.4.0",
"md5": "^2.2.1",
"ngtemplate-loader": "^2.0.1",
"node-sass": "^4.9.2",
"prism-themes": "^1.4.0",
"sass-loader": "^7.0.3",
"style-loader": "^0.21.0",
"svg-url-loader": "^2.3.2",
Expand All @@ -45,5 +44,7 @@
"test": "echo 'Error: no test specified' && exit 1",
"start": "webpack-dev-server"
},
"dependencies": {}
"dependencies": {
"prismjs": "^1.20.0"
}
}
19 changes: 19 additions & 0 deletions src/app/components/code_block/code_block.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
pre, code {
background-color: transparent !important;
}

pre.code {
border: none !important;
overflow-y: visible !important;
overflow-x: scroll !important;
padding-bottom: 10px;
}

pre.code code {
font-family: Monaco, monospace !important;
font-weight: 400 !important;
}

.line-numbers-rows {
border: none !important;
}
4 changes: 1 addition & 3 deletions src/app/components/code_block/code_block.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ <h6>Code</h6>
</li>
</ul>
<div style="margin-top: 1px">
<pre
class="source-code highlight sql"
ng-bind-html="source"></pre>
<pre class='code line-numbers'><code class="source-code highlight language-sql" ng-bind-html="highlighted"></code></pre>
</div>
</div>
</div>
35 changes: 23 additions & 12 deletions src/app/components/code_block/code_block.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
'use strict';

const template = require('./code_block.html');
const $ = require('jquery');

const css = require("./code_block.css")

angular
.module('dbt')
.directive('codeBlock', ['code', function(codeService) {
.directive('codeBlock', ['code', '$timeout', function(codeService, $timeout) {
return {
scope: {
versions: '=',
default: '<',
},
restrict: 'E',
templateUrl: template,
link: function(scope) {
link: function(scope, element) {
scope.selected_version = scope.default;
scope.raw_source = null;
scope.source = null;

function updateTo(name) {
scope.raw_source = scope.versions[name];
scope.source = codeService.highlightSql(scope.raw_source);
}

scope.setSelected = function(name) {
scope.selected_version = name;
updateTo(name);
scope.source = scope.versions[name] || '';

const sql = scope.source.trim();
scope.highlighted = codeService.highlight(sql);

$timeout(function() {
Prism.highlightAll();
})
}

scope.titleCase = function(name) {
Expand All @@ -33,7 +37,7 @@ angular

scope.copied = false;
scope.copy_to_clipboard = function() {
codeService.copy_to_clipboard(scope.raw_source)
codeService.copy_to_clipboard(scope.source)
scope.copied = true;
setTimeout(function() {
scope.$apply(function() {
Expand All @@ -44,9 +48,16 @@ angular

scope.$watch('versions', function(nv, ov) {
if (nv) {
scope.setSelected(scope.default);
if (scope.default) {
scope.setSelected(scope.default);
} else {
var opts = Object.keys(scope.versions);
if (opts.length > 0) {
scope.setSelected(opts[0]);
}
}
}
})
}, true)
}
}
}]);
25 changes: 1 addition & 24 deletions src/app/docs/analysis.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,30 +57,7 @@ <h6>Description</h6>
<section class="section">
<div class="section-target" id="sql"></div>
<div class="section-content">
<h6>SQL</h6>
<div class="panel">
<div class="panel-body">
<ul class="nav nav-tabs">
<li ng-class="{active: !view_compiled_sql}"><a ng-click="view_compiled_sql=false">Source</a></li>
<li ng-class="{active: view_compiled_sql}"><a ng-click="view_compiled_sql=true">Compiled</a></li>
<li class='nav-pull-right'></li>
<li>
<a class='unselectable'
ng-click="copy_to_clipboard(view_compiled_sql ? model.injected_sql : model.raw_sql)">{{ copied ? 'copied' : 'copy to clipboard' }}</a>
</li>
</ul>
<div style="margin-top: 1px" ng-show="!view_compiled_sql">
<pre
class="source-code highlight sql"
ng-bind-html="highlighted.source"></pre>
</div>
<div style="margin-top: 1px" ng-show="view_compiled_sql">
<pre
class="source-code highlight sql"
ng-bind-html="highlighted.compiled"></pre>
</div>
</div>
</div>
<code-block versions="versions" default="default_version"></code-block>
</div>
</section>
</div>
Expand Down
32 changes: 8 additions & 24 deletions src/app/docs/analysis.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
'use strict';

const angular = require('angular');
const hljs = require('highlight.js/lib/highlight.js');
const $ = require("jquery");

hljs.initHighlightingOnLoad();
hljs.initLineNumbersOnLoad();

require("./styles.css");

const _ = require('underscore');

angular
.module('dbt')
.controller('AnalysisCtrl', ['$scope', '$state', 'project', 'code', '$transitions', '$anchorScroll', '$location',
Expand All @@ -20,27 +12,19 @@ angular
$scope.project = projectService;
$scope.codeService = codeService;

$scope.highlighted = {
source: '',
compiled: '',
}

$scope.copied = false;
$scope.copy_to_clipboard = function(sql) {
codeService.copy_to_clipboard(sql)
$scope.copied = true;
setTimeout(function() {
$scope.$apply(function() {
$scope.copied = false;
})
}, 1000);
$scope.default_version = 'Source';
$scope.versions = {
'Source': '',
'Compiled': '',
}

$scope.model = {};
projectService.ready(function(project) {
$scope.model = project.nodes[$scope.model_uid];

$scope.highlighted.source = codeService.highlightSql($scope.model.raw_sql);
$scope.highlighted.compiled = codeService.highlightSql($scope.model.injected_sql || default_compiled);
$scope.versions = {
'Source': $scope.model.raw_sql,
'Compiled': $scope.model.injected_sql
}
})
}]);
8 changes: 1 addition & 7 deletions src/app/docs/macro.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
'use strict';

const angular = require('angular');
const hljs = require('highlight.js/lib/highlight.js');
const $ = require("jquery");

hljs.initHighlightingOnLoad();
hljs.initLineNumbersOnLoad();
const _ = require('underscore');

require("./styles.css");

const _ = require('underscore');

angular
.module('dbt')
.controller('MacroCtrl', ['$scope', '$state', 'project', 'code', '$transitions', '$anchorScroll', '$location',
Expand Down
29 changes: 3 additions & 26 deletions src/app/docs/model.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h1>
<li ui-sref-active='active'><a ui-sref="dbt.model({'#': 'details'})">Details</a></li>
<li ui-sref-active='active'><a ui-sref="dbt.model({'#': 'description'})">Description</a></li>
<li ui-sref-active='active'><a ui-sref="dbt.model({'#': 'columns'})">Columns</a></li>
<li ui-sref-active='active'><a ui-sref="dbt.model({'#': 'sql'})">SQL</a></li>
<li ui-sref-active='active'><a ui-sref="dbt.model({'#': 'code'})">SQL</a></li>
</ul>
</div>
</div>
Expand Down Expand Up @@ -69,32 +69,9 @@ <h6>Columns</h6>
</section>

<section class="section">
<div class="section-target" id="sql"></div>
<div class="section-target" id="code"></div>
<div class="section-content">
<h6>SQL</h6>
<div class="panel">
<div class="panel-body">
<ul class="nav nav-tabs">
<li ng-class="{active: !view_compiled_sql}"><a ng-click="view_compiled_sql=false">Source</a></li>
<li ng-class="{active: view_compiled_sql}"><a ng-click="view_compiled_sql=true">Compiled</a></li>
<li class='nav-pull-right'></li>
<li>
<a class='unselectable'
ng-click="copy_to_clipboard(view_compiled_sql ? model.injected_sql : model.raw_sql)">{{ copied ? 'copied' : 'copy to clipboard' }}</a>
</li>
</ul>
<div style="margin-top: 1px" ng-show="!view_compiled_sql">
<pre
class="source-code highlight sql"
ng-bind-html="highlighted.source"></pre>
</div>
<div style="margin-top: 1px" ng-show="view_compiled_sql">
<pre
class="source-code highlight sql"
ng-bind-html="highlighted.compiled"></pre>
</div>
</div>
</div>
<code-block versions="versions" default="default_version"></code-block>
</div>
</section>
</div>
Expand Down
22 changes: 5 additions & 17 deletions src/app/docs/model.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
'use strict';

const angular = require('angular');
const $ = require("jquery");
const hljs = require('highlight.js/lib/highlight.js');
hljs.initHighlightingOnLoad();
hljs.initLineNumbersOnLoad();

require("./styles.css");

const _ = require('underscore');

angular
.module('dbt')
.controller('ModelCtrl', ['$scope', '$state', 'project', 'code', '$anchorScroll', '$location',
Expand All @@ -20,10 +13,7 @@ angular
$scope.project = projectService;
$scope.codeService = codeService;

$scope.highlighted = {
source: '',
compiled: ''
}
$scope.versions = {}

$scope.copied = false;
$scope.copy_to_clipboard = function(sql) {
Expand All @@ -41,12 +31,10 @@ angular
$scope.model = project.nodes[$scope.model_uid];

var default_compiled = '\n-- compiled SQL not found for this model\n';
$scope.highlighted.source = codeService.highlightSql($scope.model.raw_sql);
$scope.highlighted.compiled = codeService.highlightSql($scope.model.injected_sql || default_compiled);

$(".source-code").each(function(i, el) {
hljs.lineNumbersBlock(el);
});
$scope.versions = {
'Source': $scope.model.raw_sql,
'Compiled': $scope.model.injected_sql || default_compiled
}

setTimeout(function() {
$anchorScroll();
Expand Down
24 changes: 3 additions & 21 deletions src/app/docs/seed.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h1>
<li ui-sref-active='active'><a ui-sref="dbt.seed({'#': 'details'})">Details</a></li>
<li ui-sref-active='active'><a ui-sref="dbt.seed({'#': 'description'})">Description</a></li>
<li ui-sref-active='active'><a ui-sref="dbt.seed({'#': 'columns'})">Columns</a></li>
<li ui-sref-active='active'><a ui-sref="dbt.seed({'#': 'sql'})">SQL</a></li>
<li ui-sref-active='active'><a ui-sref="dbt.seed({'#': 'code'})">SQL</a></li>
</ul>
</div>
</div>
Expand Down Expand Up @@ -68,27 +68,9 @@ <h6>Columns</h6>
</section>

<section class="section">
<div class="section-target" id="sql"></div>
<div class="section-target" id="code"></div>
<div class="section-content">
<h6>SQL</h6>
<div class="panel">
<div class="panel-body">
<div class='row'>
<div class='col-md-6'>
<h4>Example SQL</h4>
</div>
<div class='col-md-6 text-right'>
<a class='unselectable'
ng-click="copy_to_clipboard(sample_sql)">{{ copied ? 'copied' : 'copy to clipboard' }}</a>
</div>
</div>
<div style="margin-top: 1px">
<pre
class="source-code highlight sql"
ng-bind-html="highlighted.source"></pre>
</div>
</div>
</div>
<code-block versions="versions" default="default_version"></code-block>
</div>
</section>
</div>
Expand Down
Loading