-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #192 from EverythingMe/feature_markdown_widget
Feature: text box widget that supports markdown
- Loading branch information
Showing
11 changed files
with
213 additions
and
116 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,13 @@ | ||
from playhouse.migrate import Migrator | ||
from redash import db | ||
from redash import models | ||
|
||
|
||
if __name__ == '__main__': | ||
db.connect_db() | ||
migrator = Migrator(db.database) | ||
with db.database.transaction(): | ||
migrator.add_column(models.Widget, models.Widget.text, 'text') | ||
migrator.set_nullable(models.Widget, models.Widget.visualization, True) | ||
|
||
db.close_db(None) |
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
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 |
---|---|---|
@@ -1,61 +1,67 @@ | ||
var durationHumanize = function (duration) { | ||
var humanized = ""; | ||
if (duration == undefined) { | ||
humanized = "-"; | ||
} else if (duration < 60) { | ||
humanized = Math.round(duration) + "s"; | ||
} else if (duration > 3600*24) { | ||
var days = Math.round(parseFloat(duration) / 60.0 / 60.0 / 24.0); | ||
humanized = days + "days"; | ||
} else if (duration >= 3600) { | ||
var hours = Math.round(parseFloat(duration) / 60.0 / 60.0); | ||
humanized = hours + "h"; | ||
} else { | ||
var minutes = Math.round(parseFloat(duration) / 60.0); | ||
humanized = minutes + "m"; | ||
} | ||
return humanized; | ||
var humanized = ""; | ||
if (duration == undefined) { | ||
humanized = "-"; | ||
} else if (duration < 60) { | ||
humanized = Math.round(duration) + "s"; | ||
} else if (duration > 3600 * 24) { | ||
var days = Math.round(parseFloat(duration) / 60.0 / 60.0 / 24.0); | ||
humanized = days + "days"; | ||
} else if (duration >= 3600) { | ||
var hours = Math.round(parseFloat(duration) / 60.0 / 60.0); | ||
humanized = hours + "h"; | ||
} else { | ||
var minutes = Math.round(parseFloat(duration) / 60.0); | ||
humanized = minutes + "m"; | ||
} | ||
return humanized; | ||
} | ||
|
||
angular.module('redash.filters', []). | ||
filter('durationHumanize', function () { | ||
return durationHumanize; | ||
}) | ||
filter('durationHumanize', function () { | ||
return durationHumanize; | ||
}) | ||
|
||
.filter('refreshRateHumanize', function () { | ||
return function (ttl) { | ||
if (ttl==-1) { | ||
return "Never"; | ||
} else { | ||
return "Every " + durationHumanize(ttl); | ||
} | ||
} | ||
}) | ||
.filter('refreshRateHumanize', function () { | ||
return function (ttl) { | ||
if (ttl == -1) { | ||
return "Never"; | ||
} else { | ||
return "Every " + durationHumanize(ttl); | ||
} | ||
} | ||
}) | ||
|
||
.filter('toHuman', function() { | ||
return function(text) { | ||
return text.replace(/_/g, ' ').replace(/(?:^|\s)\S/g, function (a) { | ||
return a.toUpperCase(); | ||
}); | ||
} | ||
}) | ||
.filter('toHuman', function () { | ||
return function (text) { | ||
return text.replace(/_/g, ' ').replace(/(?:^|\s)\S/g, function (a) { | ||
return a.toUpperCase(); | ||
}); | ||
} | ||
}) | ||
|
||
.filter('colWidth', function () { | ||
return function (widgetWidth) { | ||
if (widgetWidth == 1) { | ||
return 6; | ||
} | ||
return 12; | ||
} | ||
}) | ||
|
||
.filter('colWidth', function () { | ||
return function (widgetWidth) { | ||
if (widgetWidth == 1) { | ||
return 6; | ||
} | ||
return 12; | ||
} | ||
}) | ||
|
||
.filter('capitalize', function () { | ||
return function (text) { | ||
if (text) { | ||
return text[0].toUpperCase() + text.slice(1).toLowerCase(); | ||
} else { | ||
return null; | ||
} | ||
|
||
} | ||
}); | ||
.filter('capitalize', function () { | ||
return function (text) { | ||
if (text) { | ||
return _.str.capitalize(text); | ||
} else { | ||
return null; | ||
} | ||
|
||
} | ||
}) | ||
|
||
.filter('markdown', ['$sce', function($sce) { | ||
return function(text) { | ||
return $sce.trustAsHtml(marked(text)); | ||
} | ||
}]); |
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
Oops, something went wrong.