Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
277 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
// Variables | ||
@mainBkg: #fff; | ||
@secondBkg: #ddd; | ||
@lineColor: #333; | ||
@border1: #333; | ||
@border2: #aaa; | ||
@arrowheadColor: #333333; | ||
|
||
// Flowchart variables | ||
@nodeBkg: @mainBkg; | ||
@nodeBorder: #333; | ||
@clusterBkg: @secondBkg; | ||
@clusterBorder: @border2; | ||
@defaultLinkColor: @lineColor; | ||
@titleColor: #333; | ||
@edgeLabelBackground: #e8e8e8; | ||
|
||
|
||
// Flowchart | ||
.label { | ||
font-family: "Roboto"; | ||
color: #333; | ||
} | ||
|
||
.node rect, | ||
.node circle, | ||
.node ellipse, | ||
.node polygon { | ||
fill: @mainBkg; | ||
stroke: @nodeBorder; | ||
stroke-width: 1px; | ||
} | ||
|
||
.node.clickable { | ||
cursor: pointer; | ||
} | ||
|
||
.arrowheadPath { | ||
fill: @arrowheadColor; | ||
} | ||
|
||
.edgePath .path { | ||
stroke: @lineColor; | ||
stroke-width: 1.5px; | ||
} | ||
|
||
.edgeLabel { | ||
background-color: @edgeLabelBackground; | ||
} | ||
|
||
.cluster rect { | ||
fill: @secondBkg !important; | ||
stroke: @clusterBorder !important; | ||
stroke-width: 1px !important; | ||
} | ||
|
||
.cluster text { | ||
fill: @titleColor; | ||
} | ||
|
||
div.mermaidTooltip { | ||
position: absolute; | ||
text-align: center; | ||
max-width: 200px; | ||
padding: 2px; | ||
font-family: "Roboto"; | ||
font-size: 12px; | ||
background: @secondBkg; | ||
border: 1px solid @border2; | ||
border-radius: 2px; | ||
pointer-events: none; | ||
z-index: 100; | ||
} | ||
|
||
// Class | ||
g.classGroup text { | ||
fill: @nodeBorder; | ||
stroke: none; | ||
font-family: "Roboto"; | ||
font-size: 10px; | ||
} | ||
|
||
g.classGroup rect { | ||
fill: @nodeBkg; | ||
stroke: @nodeBorder; | ||
} | ||
|
||
g.classGroup line { | ||
stroke: @nodeBorder; | ||
stroke-width: 1; | ||
} | ||
|
||
.classLabel .box { | ||
stroke: none; | ||
stroke-width: 0; | ||
fill: @nodeBkg; | ||
opacity: 0.5; | ||
} | ||
|
||
.classLabel .label { | ||
fill: @nodeBorder; | ||
font-size: 10px; | ||
} | ||
|
||
.relation { | ||
stroke: @nodeBorder; | ||
stroke-width: 1; | ||
fill: none; | ||
} | ||
|
||
.composition { | ||
fill: @nodeBorder; | ||
stroke: @nodeBorder; | ||
stroke-width: 1; | ||
} | ||
|
||
#compositionStart { | ||
.composition; | ||
} | ||
|
||
#compositionEnd { | ||
.composition; | ||
} | ||
|
||
.aggregation { | ||
fill: @nodeBkg; | ||
stroke: @nodeBorder; | ||
stroke-width: 1; | ||
} | ||
|
||
#aggregationStart { | ||
.aggregation; | ||
} | ||
|
||
#aggregationEnd { | ||
.aggregation; | ||
} | ||
|
||
#dependencyStart { | ||
.composition; | ||
} | ||
|
||
#dependencyEnd { | ||
.composition; | ||
} | ||
|
||
#extensionStart { | ||
.composition; | ||
} | ||
|
||
#extensionEnd { | ||
.composition; | ||
} | ||
|
||
// Custom | ||
.mermaid-container { | ||
height: 100%; | ||
overflow: hidden; | ||
} | ||
|
||
.mermaid { | ||
height: 100%; | ||
svg { | ||
height: 100%; | ||
} | ||
h6 { | ||
font-size: 125%; | ||
margin: 0 0 6px 0; | ||
} | ||
span { | ||
float: right; | ||
margin-left: 6px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package controllers.schema | ||
|
||
import controllers.BaseController | ||
import services.connection.ConnectionSettingsService | ||
import services.schema.{MermaidChartService, SchemaService} | ||
import util.ApplicationContext | ||
|
||
import util.FutureUtils.defaultContext | ||
|
||
@javax.inject.Singleton | ||
class SchemaController @javax.inject.Inject() (override val ctx: ApplicationContext) extends BaseController { | ||
def chart(id: String) = withSession("detail." + id) { implicit request => | ||
val conn = ConnectionSettingsService.connFor(id).getOrElse(throw new IllegalStateException(s"Invalid connection [$id]")) | ||
SchemaService.getSchemaWithDetails(Some(request.identity), conn).map { schema => | ||
val chartData = MermaidChartService.chartFor(schema) | ||
Ok(views.html.schema.mermaid(request.identity, id, conn.name, chartData)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package services.schema | ||
|
||
import models.schema.Schema | ||
|
||
object MermaidChartService { | ||
def chartFor(s: Schema) = { | ||
val ret = new StringBuilder("graph TD\n") | ||
def addLine(l: String) = ret.append(" " + l + "\n") | ||
s.tables.foreach { t => | ||
val cols = t.columns.map(c => s"""<div><span>${c.columnType}</span>${c.name}</div>""").mkString | ||
addLine(s"""${t.name}["<h6>fa:fa-folder-o ${t.name}</h6>$cols"]""") | ||
} | ||
s.tables.foreach { t => | ||
t.foreignKeys.foreach { fk => | ||
addLine(s"""${t.name} --> ${fk.targetTable}""") | ||
} | ||
} | ||
ret.toString | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
@(user: models.user.User, connectionId: String, connectionName: String, chartData: String)( | ||
implicit request: Request[AnyContent], session: Session, flash: Flash, messages: Messages | ||
)@layout.simple( | ||
user = Some(user), | ||
title = connectionName + " Schema", | ||
mainDivClass = "mermaid-container", | ||
scripts = Seq( | ||
routes.Assets.versioned("vendor/mermaid/mermaid.min.js").url, | ||
routes.Assets.versioned("vendor/mermaid/svg-pan-zoom.min.js").url | ||
), | ||
stylesheets = Seq(routes.Assets.versioned("stylesheets/mermaid.min.css").url) | ||
) { | ||
<div class="mermaid">@Html(chartData)</div> | ||
<script> | ||
$(document).ready(function() { | ||
mermaid.flowchartConfig = { | ||
width: "100%" | ||
}; | ||
mermaid.initialize({ | ||
theme: null, | ||
themeCSS: "", | ||
flowchart: { | ||
//curve: 'basis' | ||
} | ||
}); | ||
setTimeout(function() { | ||
svgPanZoom(".mermaid svg"); | ||
}, 2000) | ||
|
||
}); | ||
</script> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters