Skip to content

Commit

Permalink
Fixes add button
Browse files Browse the repository at this point in the history
Resolves #31
  • Loading branch information
NejcZdovc committed Apr 16, 2021
1 parent 0a3e18e commit e38d648
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 14 deletions.
46 changes: 36 additions & 10 deletions superset/static/blotout.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,48 @@
function parentPost() {
const parentPost = () => {
parent.postMessage({
type: "iframeUrl",
data: window.location.href,
handler: 'load'
}, "*")
}

const modifyElements = () => {
// Add + button to source database and table pages
if (window.location.pathname === '/databaseview/list/' ||
window.location.pathname === '/tablemodelview/list/') {
document.querySelectorAll('header nav .navbar-right .btn-primary')[0].style.display = 'inline-block'
let modifyTimer
const modifyCheck = (func) => {
const result = func()
if (!result) {
modifyTimer = setInterval(func, 500)
} else {
clearInterval(modifyTimer)
}
}

// remove reset password button from user page
if (window.location.pathname === '/users/userinfo/' ||
window.location.pathname.startsWith('/users/show/')) {
document.querySelector('.panel-body .well .btn-primary').style.display = 'none'
const modifyElements = () => {
switch (window.location.pathname) {
case '/databaseview/list/':
case '/tablemodelview/list/': {
// Add + button to source database and table pages
modifyCheck(() => {
const elements = document.querySelectorAll('header nav .navbar-right .btn-primary')
if (elements.length === 0) {
return false
}
elements[0].style.display = 'inline-block'
return true
})
break
}
case '/users/userinfo/':
case '/users/show/': {
// remove reset password button from user page
modifyCheck(() => {
const elements = document.querySelectorAll('.panel-body .well .btn-primary')
if (elements.length === 0) {
return false
}
elements[0].style.display = 'none'
return true
})
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions superset/templates/superset/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
{{ super() }}
<link rel="icon" type="image/png" href="/static/assets/images/favicon.png">
{{ css_bundle("theme") }}
<link media="all" rel="stylesheet" href="/static/blotout.css" />
<link media="all" rel="stylesheet" href="/static/blotout.css?v=1" />
{% endblock %}

{% block head_js %}
{{ super() }}
<script src="/static/blotout.js"></script>
<script src="/static/blotout.js?v=1"></script>
{{ js_bundle("theme") }}
{% endblock %}

Expand Down
4 changes: 2 additions & 2 deletions superset/templates/superset/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@
{{ css_bundle(entry) }}
{% endif %}

<link media="all" rel="stylesheet" href="/static/blotout.css" />
<link media="all" rel="stylesheet" href="/static/blotout.css?v=1" />
{% endblock %}

{{ js_bundle("theme") }}
<script src="/static/blotout.js"></script>
<script src="/static/blotout.js?v=1"></script>

<input
type="hidden"
Expand Down

0 comments on commit e38d648

Please sign in to comment.