Compare commits

...

2391 Commits

Author SHA1 Message Date
Torkel Ödegaard
9540e12e2e Updated version to 2.0.1 to work around rpm and deb versioning scheme does not support regular semver prerelease naming standard, it seems like 2.0.0-beta3 is newer than 2.0.0 for rpm and deb packages. 2015-04-20 13:21:42 +02:00
Torkel Ödegaard
9766106686 Added link to rpm GPG key 2015-04-20 12:38:49 +02:00
Torkel Ödegaard
3d8beb918b Docs updates and update to tar package 2015-04-20 12:33:32 +02:00
Torkel Ödegaard
123ea331e6 Updated build.go to create latest packages correctly 2015-04-20 12:10:54 +02:00
Torkel Ödegaard
b5a77d4f4a Updated version to 2.0.0 and updated changelog 2015-04-20 11:54:36 +02:00
Torkel Ödegaard
9852972db8 Merge remote-tracking branch 'origin/nopzor1200-patch-1' 2015-04-20 11:47:36 +02:00
Torkel Ödegaard
b286ed6bb8 Small UI polish to playlist creation view 2015-04-20 11:47:09 +02:00
Torkel Odegaard
b56a084810 Updated nodejs version in appveyor ci build spec file 2015-04-20 09:19:19 +02:00
Torkel Odegaard
c9a28ddd38 Windows build: updates to build stuff to create better windows packages 2015-04-20 08:10:23 +02:00
Torkel Odegaard
bb7ee1c5a3 Panel title: switched from context-menu cursor to pointer, context-menu does not work on windows in chrome and firefox, but works on other platforms :( 2015-04-20 07:29:25 +02:00
nopzor1200
1772e15b46 Update index.md 2015-04-19 23:24:35 -04:00
nopzor1200
360efdf71f Update whats-new-in-v2.md 2015-04-19 23:18:33 -04:00
nopzor1200
56d1e6834a Update timerange.md 2015-04-19 22:03:18 -04:00
nopzor1200
f1e267498e Update timerange.md 2015-04-19 22:02:44 -04:00
nopzor1200
4ba6bf8e27 Update playlist.md 2015-04-19 21:46:22 -04:00
nopzor1200
101c44f22d Update playlist.md 2015-04-19 21:37:34 -04:00
nopzor1200
7f967524b9 Update index.md 2015-04-19 21:27:37 -04:00
Torkel Odegaard
01e171373c Updated appvayor file again 2015-04-19 21:31:42 +02:00
Torkel Odegaard
229a4a8aab appveyor, install mingw 2015-04-19 20:59:14 +02:00
Torkel Odegaard
f6feb455a9 Updated to appveyor ci spec file 2015-04-19 20:45:18 +02:00
Torkel Odegaard
fbf4eac257 Added appveyor, trying to test if a windows CI build will be possible 2015-04-19 20:38:24 +02:00
nopzor1200
48b5d235d8 Update index.md 2015-04-19 14:25:10 -04:00
Torkel Odegaard
ebdbbbc000 Updated building on windows instructions in the docs 2015-04-19 09:44:14 +02:00
Torkel Odegaard
1edb13d715 Fixed gofmt formating 2015-04-19 09:29:08 +02:00
Torkel Ödegaard
aa8beda4ec Merge pull request #1800 from alienth/allowsignup
Add allow_sign_up setting for auth.google/github.
2015-04-19 09:16:48 +02:00
Torkel Odegaard
7178dcad35 Windows: Fixed runtime issue with file logging config that casued errors on startup 2015-04-19 09:14:50 +02:00
Jason Harvey
ddaac50a25 Add allow_sign_up override for auth.google/github. 2015-04-16 13:43:18 -08:00
Torkel Ödegaard
a446286869 Fixed issue with unsaved changes srv being triggerd by starring / unstarring a dashboard, Fixes #1795 2015-04-16 17:21:03 +02:00
Torkel Ödegaard
c54f0fe58b Merge pull request #1783 from williamjoy/master
oauth google: read api_url from config file
2015-04-16 08:15:31 +02:00
Torkel Ödegaard
7c8166cad2 updated build script 2015-04-15 15:41:56 +02:00
Torkel Ödegaard
3db2aaada6 Bumped version to rc1 2015-04-15 15:17:19 +02:00
Torkel Ödegaard
649d40ed66 Data source proxy: Fixed issue with using data source proxy when grafana is behind nginx suburl, Fixes #1784 2015-04-15 15:13:52 +02:00
Torkel Ödegaard
d71b626114 Graph Panel: Legend in table mode now aligns, graph area is reduced depending on how many series, Fixes #1786, Fixes #1749 2015-04-15 14:53:20 +02:00
Torkel Ödegaard
fc47fb8f64 Backend auth: remember cookie is needed for oauth logins as well 2015-04-15 13:38:38 +02:00
Torkel Ödegaard
10e5e5c400 fixed godep dependency 2015-04-15 13:31:30 +02:00
Torkel Ödegaard
942e8fdba8 Support for unicode / international characters in dashboard title (improved slugify), Fixes #1734, Fixes #827 2015-04-15 12:36:02 +02:00
Torkel Ödegaard
6ba8854854 Readded link in top header, Fixes #1756 2015-04-15 12:17:31 +02:00
William Wei
b7c0d99cdf get google api url from config file
instead of using https://www.googleapis.com/oauth2/v1/userinfo in
code.
2015-04-15 18:11:54 +08:00
Lichun Wei
bc4584d9fe Merge pull request #1 from grafana/master
sync from upstream
2015-04-15 18:04:52 +08:00
Torkel Ödegaard
53b1d6a5b2 Row editor: increased width of title field, Fixes #1755 2015-04-15 10:52:09 +02:00
Torkel Ödegaard
836e4b4911 Dashboard snapshot: Should not require login to view snapshot, Fixes #1780 2015-04-15 10:39:03 +02:00
Torkel Ödegaard
e9afd30b47 Updated changelog with, Github OAuth: Now works with Github for Enterprise, thanks @williamjoy 2015-04-15 10:31:56 +02:00
Torkel Ödegaard
aefbcb7049 Merge pull request #1782 from williamjoy/master
#1781 try fix oauth with github enterprise - add config of api_url
2015-04-15 10:21:09 +02:00
William Wei
4fd2622e55 grafana/grafana#1781 add oauth api url as config
read github api from config file instead of using public github:
http://api.github.com/user

this would be useful when you are using github enterprise edition
2015-04-15 14:18:10 +08:00
William Wei
d048e39cde grafana/grafana#1781 add oauth api url as config 2015-04-15 14:03:28 +08:00
Torkel Ödegaard
140f1307b4 Small fix to singlestat panel and unit selector 2015-04-14 17:13:39 +02:00
Torkel Ödegaard
9d10b5ab52 Updated docker docs 2015-04-14 16:53:54 +02:00
Torkel Ödegaard
edb39a072e Updated rpm install docs page with yum repo info 2015-04-14 16:49:42 +02:00
Torkel Ödegaard
d66d989308 Updated debian install instructions with apt repo 2015-04-14 16:28:57 +02:00
Torkel Ödegaard
05c3b96202 Updated install docs page 2015-04-14 14:06:53 +02:00
Torkel Ödegaard
e9c7264fd9 Docs updates 2015-04-13 14:12:03 +02:00
Torkel Ödegaard
0b1c1bb8b4 updated package version 2015-04-13 14:06:33 +02:00
Torkel Ödegaard
47a18bba99 Fixed defaults.ini, missing allowed_domains key, #1729 2015-04-13 14:04:52 +02:00
Torkel Ödegaard
7ffdb488c1 Updated opentsdb docs article with info on adding the data source 2015-04-13 11:49:12 +02:00
Torkel Ödegaard
2c1188f664 Updated influxdb docs page with info on how to add a datasource 2015-04-13 11:35:43 +02:00
Torkel Ödegaard
60ab08ed1b Updated Graphite docs page with instruction on how to add a graphite data source 2015-04-13 09:37:07 +02:00
Torkel Ödegaard
2bb85d216e Fixed fixed decimal option bug, when fixed decimal value was set to zero, Fixes #1764 2015-04-13 09:05:42 +02:00
Torkel Ödegaard
7be8fb8432 Updated install docs 2015-04-13 08:14:13 +02:00
Torkel Ödegaard
a4ef1e22d6 Updated docs 2015-04-13 07:55:07 +02:00
Torkel Ödegaard
3335041d39 Trying to split install docs into seperate pages 2015-04-13 07:34:55 +02:00
Torkel Ödegaard
19e881513b updated changelog 2015-04-12 21:34:37 +02:00
Torkel Ödegaard
41777c01f1 Updated config docs 2015-04-12 21:31:35 +02:00
Torkel Ödegaard
6b26c8d46f updated to install docs 2015-04-12 21:28:01 +02:00
Torkel Ödegaard
d4339ae9d2 Updated packaging post install 2015-04-12 16:23:43 +02:00
Torkel Ödegaard
bdc4d14036 Updated postinstall scripts 2015-04-12 16:19:44 +02:00
Torkel Ödegaard
ed82f6c681 Added upgrade step that moves sqlite3 database to new location, #1758 2015-04-12 15:58:08 +02:00
Torkel Ödegaard
d4e6ae2804 Fixed issue in rpm init.d script 2015-04-12 15:52:51 +02:00
Torkel Ödegaard
a60bf642e1 Updated build.go 2015-04-12 09:51:56 +02:00
Torkel Ödegaard
be8a72c35b Updated rpm post install script, #1758 2015-04-12 09:49:28 +02:00
Torkel Ödegaard
cc14705404 Update changelog 2015-04-12 09:42:27 +02:00
Torkel Ödegaard
6de584aafc Updated to config file finding, and added homepath command line option 2015-04-12 09:15:49 +02:00
Torkel Ödegaard
cc427b1307 Merge branch 'master' into packaging_refactoring 2015-04-10 17:45:01 +02:00
Torkel Ödegaard
00cdb5e36a Merge pull request #1738 from mtanda/suppress_redrawing_by_tooltip
Suppress redrawing when Shared Crosshair is disabled
2015-04-10 17:44:39 +02:00
Torkel Ödegaard
437cd50039 Merge pull request #1740 from craftytrickster/master
When performing a metric find query, the InfluxDb9 datasource needs a qu...
2015-04-10 17:41:56 +02:00
Torkel Ödegaard
61add0ecc6 Merge pull request #1742 from mattttt/patch-1
Typo fix in help_modal.html
2015-04-10 17:41:21 +02:00
Torkel Ödegaard
8accb8865a restart on upgrade default to false 2015-04-10 17:36:25 +02:00
Torkel Ödegaard
c44248440e Updated to rpm package 2015-04-10 17:32:40 +02:00
Torkel Ödegaard
d32c03ed11 Rpm working again, systemd working on centos 7 2015-04-10 16:20:01 +02:00
Torkel Ödegaard
3e49609099 started work on new rpm package 2015-04-10 11:35:14 +02:00
Torkel Ödegaard
c47f4bc97c systemd service is working on debian jessie 2015-04-10 11:26:03 +02:00
Torkel Ödegaard
8ee7d5c2d5 Deb package is starting to work 2015-04-10 11:05:56 +02:00
Torkel Ödegaard
2020fedfdb Fixed issue with overriding default config values via command line 2015-04-10 10:58:32 +02:00
Matt
40b2535728 Typo fix in help_modal.html
Fixed typo in header (Keyboard shutcuts -. Keyboard shortcuts)
2015-04-09 16:18:15 -04:00
David Raifaizen
2d016c5a3f When performing a metric find query, the InfluxDb9 datasource needs a query type in order to return results succesfully. This parameter is not available when called from the templateValuesSrv, which is causing an error 2015-04-09 12:05:18 -04:00
Mitsuhiro Tanda
ba3bb57926 suppress all graph redrawing when shared tooltip is enabled 2015-04-10 00:34:23 +09:00
Torkel Ödegaard
4c6d7630cd more work on refining config loading, and packaging 2015-04-09 17:18:04 +02:00
Torkel Ödegaard
d1767144a8 Reworking configuration loading and overriding 2015-04-09 12:16:59 +02:00
Torkel Ödegaard
a991cda233 Began work on refactoring reading config values 2015-04-08 20:31:42 +02:00
Torkel Ödegaard
9c2040aa9b More deb & rpm work, systemd testing 2015-04-08 16:58:05 +02:00
Torkel Ödegaard
96ee1c17a3 Worked on new deb & rpm packaging and init.d scripts 2015-04-08 14:10:04 +02:00
Torkel Ödegaard
6911572fa1 Panel image rendering: now works under self-signed https cert, Fixes #1726 2015-04-08 09:06:01 +02:00
Torkel Ödegaard
059db533d5 HTTP API: grafana /render calls nows with api keys, Fixes #1649 2015-04-08 08:59:12 +02:00
Torkel Ödegaard
f28af4f369 OpenTSDB: another improvement to OpenTSDB query -> query result matching 2015-04-07 21:47:06 +02:00
Torkel Ödegaard
1bd238191c OpenTSDB: better matching for query -> query result series 2015-04-07 21:42:21 +02:00
Torkel Ödegaard
c07d48d930 A big refactoring for how sessions are handled, Api calls that authenticate with api key will no longer create a new session 2015-04-07 19:21:14 +02:00
Torkel Ödegaard
00a713c42e Updated configuration docs with cert_key and cert_file info, Closes #1722 2015-04-07 16:48:30 +02:00
Torkel Ödegaard
01c97e69dd Updated influxdb 0.9 datasource config view to mention incomplete state of data source 2015-04-07 13:56:35 +02:00
Torkel Ödegaard
646298f5c5 Handle errors when loading dashboard with template variables that query data sources that cannot be found 2015-04-07 13:48:26 +02:00
Torkel Ödegaard
8f73328e25 Fixed datasource proxy and session timeout issue for OpenTSDB, #1667 2015-04-07 09:53:59 +02:00
Torkel Ödegaard
b5112aeee2 Data source proxy, and session timeout fix for influxdb, #1667 2015-04-07 09:50:03 +02:00
Torkel Ödegaard
22adf0d06e Datasource proxy & session timeout fix (casued 401 Unauthorized error after a while), Fixes #1667 2015-04-07 09:25:00 +02:00
Torkel Ödegaard
382f7066d9 Fixed importing dashboards from graphite web issue 2015-04-06 14:46:06 +02:00
Torkel Ödegaard
08c19692ea Updated configuration docs 2015-04-06 14:19:18 +02:00
Torkel Ödegaard
eb575685aa OAuth: Specify allowed email address domains for google or and github oauth logins, Closes #1660 2015-04-06 14:16:22 +02:00
Torkel Ödegaard
7a95451288 Fixed graph tooltip lingering when changing dashboard using keyboard, Fixes #1700 2015-04-06 11:42:50 +02:00
Torkel Ödegaard
538ec7c0a0 Unsaved changes: Do not show for snapshots, scripted and file based dashboards, Fixes #1707 2015-04-06 11:22:35 +02:00
Torkel Ödegaard
ea800dd838 Added login to organization users table, Fixes #1683 2015-04-04 10:14:51 +02:00
Torkel Ödegaard
b8c378f2f0 Updated golang/x/oauth2 dependency, #1710 2015-04-04 09:50:25 +02:00
Torkel Ödegaard
e86bedddb2 Updated gitignore file 2015-04-02 15:37:22 +02:00
Torkel Ödegaard
1e1a6df480 Playlist: fixed issue where dashboard title was not visible when playing playlist 2015-04-02 15:37:03 +02:00
Torkel Ödegaard
7aa1ab855e Row editor fix: fixed issue when opening row editor when dashboard settings view is opened, Fixes #1688 2015-04-02 10:05:33 +02:00
Torkel Ödegaard
776f15055a Fixed grafana version in dash settings footer, Fixes #1699 2015-04-02 09:50:57 +02:00
Torkel Ödegaard
b291b18a87 Unsaved changes improvements: ignore row collapse state, ignore graph legend sort order, Closes #1702 2015-04-02 09:44:16 +02:00
Torkel Ödegaard
e6492f7db9 Share modal: Override UI theme via URL param for Share link, rendered panel, or embedded panel, Closes #1701 2015-04-02 09:21:38 +02:00
Torkel Ödegaard
3b737999d6 Unsaved changes: Do not show for users with role , Fixes #1703 2015-04-02 08:08:22 +02:00
Torkel Ödegaard
00fa7f5e86 Removed unusued config, updated sample config with session config 2015-04-02 07:51:16 +02:00
Torkel Ödegaard
fde5ba85a0 Docs: Updated configuration docs with port 80 tips 2015-04-01 17:24:24 +02:00
Torkel Ödegaard
a96e4a343c Only create admin user specified in config file when there are no users in the database, Fixes #1680 2015-04-01 16:05:42 +02:00
Torkel Ödegaard
36110d0977 Updated migration docs 2015-04-01 15:56:39 +02:00
Torkel Ödegaard
1f330d7753 Basic auth: Fixed issue when using basic auth proxy infront of Grafana, Fixes #1673 2015-04-01 15:23:26 +02:00
Torkel Ödegaard
cf877e6567 added postgres and redis session options 2015-04-01 09:45:42 +02:00
Torkel Ödegaard
c3fa68ade8 Data source proxy: Fixed issue with Gzip enabled and data source proxy, Fixes #1675 2015-04-01 09:00:17 +02:00
Torkel Ödegaard
5422d13607 Postgres fix update 2015-04-01 08:26:02 +02:00
Torkel Ödegaard
d8f614ed98 Merge pull request #1665 from mattrobenolt/bool
Let xorm convert `False` into the right type
2015-04-01 08:25:20 +02:00
Torkel Ödegaard
4ca125da41 Delete snapshot fix: the action is now shows confirmation directly in the modal (not opening a new tab with api call as in beta1), Fixes #1682 2015-04-01 08:24:03 +02:00
Torkel Ödegaard
3c2bfbfc1c Search: Dashboard results should be sorted alphabetically, Fixes #1685 2015-03-31 22:06:19 +02:00
Torkel Ödegaard
03e336ba9e Fixed minor issue doing snapshot from home (root) dashboard 2015-03-31 21:48:54 +02:00
Torkel Ödegaard
76ea0f432a updated master version to beta2 2015-03-31 19:20:34 +02:00
Torkel Ödegaard
7eb45e1799 MySQL session: fixed problem using mysql as session store, Fixes #1681 2015-03-31 19:18:41 +02:00
Torkel Ödegaard
4af1dcd54f Updated defaults.ini, reverted change in previous commit 2015-03-31 17:42:51 +02:00
Torkel Ödegaard
463c519954 Dashlist panel: added fresh panel when changing limit, Fixes #1677 2015-03-31 17:30:27 +02:00
Torkel Ödegaard
1d0a3660bd Fixed issue with updating default data source, it required page reload to take effect, should not be required, now fixed, Fixes #1671 2015-03-31 14:31:47 +02:00
Torkel Ödegaard
b83367063e Small improvement to dashboard loading error handling 2015-03-31 14:03:01 +02:00
Torkel Ödegaard
aa724fc11e Remove datasource names in panels from snapshots 2015-03-31 10:48:14 +02:00
Matt Robenolt
cedb11ebab Let xorm convert False into the right type 2015-03-30 18:11:39 -07:00
Torkel Ödegaard
ffe389af4a Updated to whats new guide 2015-03-30 19:18:15 +02:00
Torkel Ödegaard
b313637848 updated confiuration docs 2015-03-30 17:39:16 +02:00
Torkel Ödegaard
2eeae21777 Updated whats new docs guide 2015-03-30 17:35:38 +02:00
Torkel Ödegaard
2af9dfebea Merge pull request #1657 from lfrancke/patch-1
Update index.md
2015-03-30 17:04:28 +02:00
Lars Francke
dade6fc191 Update index.md
Fixes two typos and a minor inconsistency
2015-03-30 16:55:37 +02:00
Torkel Ödegaard
fb0629a913 Bumbped version to 2.0.0-beta1 2015-03-30 15:45:02 +02:00
Torkel Ödegaard
060d0b777b Updated install docs and changelog 2015-03-30 12:31:12 +02:00
Torkel Ödegaard
dc03ca8879 Opening search closes fullscreen edit or fullscreen view 2015-03-30 12:25:17 +02:00
Torkel Ödegaard
de51aeab7b updates to whats new doc, and building from source, also small fix for panel snapshot, single panelsnapshot should expand panel span to 12 2015-03-30 11:08:46 +02:00
Torkel Ödegaard
b46f8bad6d Added check for allow_user_org_create, updated admin docs 2015-03-30 10:12:24 +02:00
Torkel Ödegaard
8982dc5ed3 Update getting started 2015-03-30 09:38:40 +02:00
Torkel Ödegaard
2d2462fe63 Updated configuration docs 2015-03-30 09:22:58 +02:00
Torkel Ödegaard
b1fedca46e Merge pull request #1656 from nopzor1200/patch-5
Update gettingstarted.md
2015-03-30 08:39:38 +02:00
Torkel Ödegaard
929187a934 Merge pull request #1655 from nopzor1200/patch-4
Update admin.md
2015-03-30 08:38:58 +02:00
Torkel Ödegaard
7f34462f9a Merge pull request #1654 from nopzor1200/patch-3
Update influxdb.md
2015-03-30 08:38:14 +02:00
nopzor1200
2c54937104 Update gettingstarted.md
fleshed out 'getting started' text
2015-03-29 16:39:08 -04:00
Torkel Ödegaard
472b8c6e8d Fixed link in docs 2015-03-29 21:27:48 +02:00
Torkel Ödegaard
8e33c2c4d3 Mini work on InfluxDB 0.9 datasource, still needs a lot of work 2015-03-29 20:47:34 +02:00
Torkel Ödegaard
c42d09b267 Enabled snapshot sharing of single panels, enabled sharing of snapshot dashboards (but you cannot snapshot a snapshot 2015-03-29 15:01:27 +02:00
Torkel Ödegaard
0f791c9fa8 Refactoring of share modal 2015-03-29 14:30:03 +02:00
Torkel Ödegaard
ceb079a7ea removed old docs, need to update export & import docs, and playlist docs 2015-03-29 13:46:37 +02:00
Torkel Ödegaard
ce99e7b294 Updated gitignore and added config.js 2015-03-29 13:41:01 +02:00
Torkel Ödegaard
a20c276c84 Updated readme 2015-03-29 13:39:51 +02:00
Torkel Ödegaard
2186b09ed7 Removed travis file, circle ci is the primary CI service 2015-03-29 13:34:58 +02:00
Torkel Ödegaard
38db91c7be Fixed failing go unit test 2015-03-29 13:33:34 +02:00
Torkel Ödegaard
902f5d895a Updated readme 2015-03-29 13:30:03 +02:00
Torkel Ödegaard
6d565cb355 Merge branch 'patch-3' of https://github.com/mattrobenolt/grafana 2015-03-29 13:08:28 +02:00
Torkel Ödegaard
6a9256bb00 Bumped version to prebeta3 2015-03-29 13:07:40 +02:00
Torkel Ödegaard
b48b2ac656 Updated grunt tasks for the src -> public directory change 2015-03-29 13:06:53 +02:00
Torkel Ödegaard
fde11be279 Renamed src directory to public 2015-03-29 12:57:28 +02:00
Torkel Ödegaard
adb5d6da84 Merge branch develop (Grafana 2.0 branch) into master 2015-03-29 12:52:07 +02:00
Matt Robenolt
92d869e85c typo: sqllite -> sqlite 2015-03-28 16:26:51 -07:00
nopzor1200
e8e83bdbce Update admin.md 2015-03-28 18:40:25 -04:00
nopzor1200
bb8f8fccca Update influxdb.md
clarified some language, split into influx 0.9 and influx 0.8 since they are now two separate datasources/queryeditors
2015-03-28 17:30:36 -04:00
Torkel Ödegaard
1824caa5ea Updated snapshot share icon size 2015-03-28 21:04:38 +01:00
Torkel Ödegaard
dfac87db05 Removed unused function from kbn.js 2015-03-28 18:04:22 +01:00
Torkel Ödegaard
15c8a5e351 Merge pull request #1651 from nopzor1200/patch-1
Updates to migration doc
2015-03-28 18:02:13 +01:00
Torkel Ödegaard
8e9a0eddf5 Custom snapshot topnav header, new custom dashboard snapshot icon, #1623 2015-03-28 17:53:52 +01:00
nopzor1200
1200dd4b75 Update migrating_to2.md 2015-03-28 11:57:00 -04:00
nopzor1200
f969fce4d4 Update migrating_to2.md
minor tweaks
2015-03-28 00:39:13 -04:00
nopzor1200
45419195aa Update migrating_to2.md
some suggested updates
2015-03-28 00:30:39 -04:00
Torkel Ödegaard
80c771c945 Added googla analytics id setting 2015-03-27 17:13:44 +01:00
Torkel Ödegaard
6bd2736116 added transparent panel option 2015-03-27 14:39:03 +01:00
Torkel Ödegaard
f7b4f331f3 Updating docs 2015-03-27 14:23:23 +01:00
Torkel Ödegaard
c01efad997 Updated config (minor description change) 2015-03-27 11:26:20 +01:00
Torkel Ödegaard
1d64ba3b5d Small style update to submenu (template variables, annotation menu) 2015-03-27 08:39:08 +01:00
Torkel Ödegaard
e646ae8be4 updated whats new doc 2015-03-27 07:39:06 +01:00
Torkel Ödegaard
d3db49ae3e Fixed snapshot sharing issue 2015-03-27 06:47:58 +01:00
Torkel Ödegaard
7be7aeb70a Fixed sql migration issue with dashboard snapshots 2015-03-26 21:20:44 +01:00
Torkel Ödegaard
541cd2e430 Dashboard snapshot: more work on snapshot deletion, and saving external reference, #1623 2015-03-26 20:59:41 +01:00
Torkel Ödegaard
4322f29f34 Dashboard snapshot: added delete key which can be used to delete snapshots, #1623 2015-03-26 20:34:58 +01:00
Torkel Ödegaard
7d0ae23c0e small docs update 2015-03-26 19:31:43 +01:00
Torkel Ödegaard
0122a9ab18 Updated whats new doc 2015-03-26 18:03:37 +01:00
Torkel Ödegaard
165647184d Updated docs: whats new in 2.0, added sharing reference docs page, #1571 2015-03-26 17:55:07 +01:00
Torkel Ödegaard
2ca86b6085 Changed log base 16 to log base 32, #452 2015-03-26 17:44:36 +01:00
Torkel Ödegaard
b04c50537d Progress on InfluxDB 0.9 support, but will take a break, it is impossible to work on this, cannot get any queries that use tags to work with InfluxDB 0.9rc15, just empty response, #1525 2015-03-26 13:51:43 +01:00
Torkel Ödegaard
fcac4c057c updated xorm, go-sqlite3 dependencies 2015-03-26 12:41:43 +01:00
Torkel Ödegaard
71aa2ef2c2 Changed reporting interval to 24 hour (1 hour was just for testing) 2015-03-26 12:20:24 +01:00
Torkel Ödegaard
03aa997673 merged with master and fixed ES issue 2015-03-26 12:14:37 +01:00
Torkel Ödegaard
df4a00f8ef Merge remote-tracking branch 'origin/master' into develop 2015-03-26 12:09:02 +01:00
Torkel Ödegaard
f343a46ca4 Singlestat panel: Fixed error handling, when query fail do not show last value, Fixes #1647 2015-03-26 12:05:08 +01:00
Torkel Ödegaard
b1f85dc8f1 Added expire option to dashboard snapshots, #1623 2015-03-26 12:00:52 +01:00
Torkel Ödegaard
722d74a41b Removed unused animate.min.css 2015-03-25 21:27:57 +01:00
Torkel Ödegaard
86a9fe6024 Removed unused bootstrap css 2015-03-25 21:11:21 +01:00
Torkel Ödegaard
68701c5cf9 More refinements to info text on share snapshot dialog, #1623 2015-03-25 20:55:41 +01:00
Torkel Ödegaard
f4280ca517 More refinements of dashboard snapshot dialog, #1623 2015-03-25 20:36:48 +01:00
Torkel Ödegaard
afeb65b3bf Snapshot sharing fix 2015-03-25 17:18:43 +01:00
Torkel Ödegaard
d9e56b678a Fixed intendation issue 2015-03-25 16:35:14 +01:00
Torkel Ödegaard
aa60edd9fe Fixed issue with external snapshot publish 2015-03-25 16:30:03 +01:00
Torkel Ödegaard
c4b8a9853e updated grunt-jscs dependency 2015-03-25 16:06:13 +01:00
Torkel Ödegaard
e640c51f84 Merge pull request #1639 from tuexss/patch-1
readme cleanup
2015-03-25 16:00:06 +01:00
Torkel Ödegaard
b37e100058 Merge pull request #1640 from tuexss/tuexss-https
http->https for latest version
2015-03-25 15:59:20 +01:00
Torkel Ödegaard
cb3593e472 Lots of small fixes, role viewer hides save icon and some actions in
config dropdown. Snapshot dashboard hides save, star, config menu icons.
Can now embedd panel from snapshotted dashboard.
2015-03-25 15:48:56 +01:00
Torkel Ödegaard
2e6d28027a Removed snapshot from dashboard settings dropdown, its only reached through the share menu 2015-03-25 14:19:14 +01:00
Torkel Ödegaard
9c5e116d09 Fixed small file nameing issue in build script 2015-03-25 14:14:45 +01:00
Torkel Ödegaard
10618637e2 Fixed bug in sql migration, closes #1643 2015-03-25 13:53:58 +01:00
Torkel Ödegaard
4e97df06a3 Removed ghost panel 2015-03-25 13:43:52 +01:00
Torkel Ödegaard
abe529b5be Merge pull request #1641 from tuexss/tuexss-https-1
http -> https for external links
2015-03-25 12:32:04 +01:00
Torkel Ödegaard
e31a3a64e1 OpenTSDB: Alias patterns (reference tag values), syntax is: or [[tag_tagname]], Closes #1344, match opentsdb response to query, Fixes #1601 2015-03-25 12:27:33 +01:00
tuexss
152b01064a http -> https for external links 2015-03-25 12:17:22 +01:00
tuexss
f235b516dc http->https for latest version 2015-03-25 12:14:26 +01:00
tuexss
1f6d5bfd53 readme cleanup 2015-03-25 12:03:20 +01:00
Torkel Ödegaard
da833cbc58 Small progress on influxdb 0.9 query editor, #1525 2015-03-25 11:07:12 +01:00
Torkel Ödegaard
9268ecf3e9 Some refinements to dashboard snapshots 2015-03-25 09:04:38 +01:00
Torkel Ödegaard
c8687560d6 Merge pull request #1636 from mattrobenolt/patch-2
Fix more Cache-Control headers
2015-03-25 07:22:22 +01:00
Matt Robenolt
5286f0856d Fix more Cache-Control headers
`max-age` is always with an `=`, not a `:`.
2015-03-24 17:30:26 -07:00
Torkel Ödegaard
789363b0ad Added ghost panel that shows up empty rows, this panel will show add panel buttons to more quickly/easier get to add a panel, #1635 2015-03-24 21:10:44 +01:00
Torkel Ödegaard
e6918c4b99 Merge branch 'develop' into ghost-panel 2015-03-24 19:53:56 +01:00
Torkel Ödegaard
f9cf673f81 removed accidental code, should have been part of ghost-panel branch commit 2015-03-24 19:49:51 +01:00
Torkel Ödegaard
cc71b1f07d Ghost panel test 2015-03-24 19:42:39 +01:00
Torkel Ödegaard
7919d79347 Another cache header fix 2015-03-24 17:16:13 +01:00
Torkel Ödegaard
22b78aa037 Merge pull request #1632 from swehner/limit-search-results
Limit ElasticSearch to return only title and tags for dashboard search
2015-03-24 17:04:35 +01:00
Torkel Ödegaard
a5c3855233 Added dashboard snapshot metrics 2015-03-24 16:49:12 +01:00
Torkel Ödegaard
ddd3df26b1 Fixed docs spelling issue, #1634 2015-03-24 15:52:22 +01:00
Torkel Ödegaard
c27db7a347 Small updates to share dashboard snapshot feature 2015-03-24 15:46:17 +01:00
Stefan Wehner
527e802b05 Limit ElasticSearch return to title and tags 2015-03-24 11:37:26 +01:00
Torkel Ödegaard
d758729633 Merge pull request #1629 from mattrobenolt/patch-1
Fix format of Cache-Control header
2015-03-24 11:13:55 +01:00
Matt Robenolt
3e9adeefbc Fix format of Cache-Control header 2015-03-23 21:58:29 -07:00
Torkel Ödegaard
5f0e7cd52a Added custom cache control headers for static content 2015-03-23 18:28:59 -04:00
Torkel Ödegaard
98c0209976 Dashboard snapshot: cleanup snapshot data after snapshot, #1623 2015-03-23 17:34:41 -04:00
Torkel Ödegaard
6f2a8e27b8 Dashboard Snapshot: added dashboard snapshot to changelog, #1623 2015-03-23 15:36:18 -04:00
Torkel Ödegaard
41820ccb05 Dashboard Snapshot sharing: singlestat panel now works, #1623 2015-03-23 15:32:38 -04:00
Torkel Ödegaard
4d13a5bffb Fixed failing style check 2015-03-23 14:00:03 -04:00
Torkel Ödegaard
7614ddb318 Updated design for snapshot sharing dialog, #1596 2015-03-23 13:58:30 -04:00
Torkel Ödegaard
a5fac17f2b Added public snapshot test, hosted on snapshots.raintank.io 2015-03-23 07:32:03 -04:00
Torkel Ödegaard
49a0ea53c7 Merge branch 'develop' of github.com:grafana/grafana into dashboard_snapshot_poc
Conflicts:
	src/app/features/dashboard/partials/shareDashboard.html
2015-03-22 22:04:13 -04:00
Torkel Ödegaard
44bc2b2d56 Updated conf description, metrics interval 2015-03-22 16:30:28 -04:00
Torkel Ödegaard
a26436f59b Server metrics fix 2015-03-22 16:13:16 -04:00
Torkel Ödegaard
1e4c62a70d updated server reporting 2015-03-22 15:45:13 -04:00
Torkel Ödegaard
526f3e1a31 Fixed failing unit test 2015-03-22 15:27:05 -04:00
Torkel Ödegaard
c67291da33 Updated 2015-03-22 15:25:21 -04:00
Torkel Ödegaard
9c9ebb4987 Updated server stats 2015-03-22 15:24:35 -04:00
Torkel Ödegaard
d987532262 Added server metrics 2015-03-22 15:14:00 -04:00
Torkel Ödegaard
7d4293f849 removed cli commands, need to be mobed to a seperate binary using http api, #1570 2015-03-22 06:48:53 -04:00
Torkel Ödegaard
9bae19a7ec Small fix to logarithmic scale 2015-03-21 15:34:26 -04:00
Torkel Ödegaard
bf898138b7 Small update to drilldown link editor 2015-03-21 12:09:04 -04:00
Torkel Ödegaard
245c6dbff0 Share Panel: The share modal now has an embed option, gives you an iframe that you can use to embedd a single graph on another web site, #1622 2015-03-21 12:09:04 -04:00
Torkel Ödegaard
f48f5428e5 Adding snapshot storage and route, #1623 2015-03-21 10:56:26 -04:00
Torkel Ödegaard
964f0861d6 more work on dashboard snapshots 2015-03-21 08:53:16 -04:00
Torkel Ödegaard
a76758255f Merge branch 'develop' into dashboard_snapshot_poc 2015-03-21 07:29:40 -04:00
Torkel Ödegaard
7db3703275 Share Panel: The share modal now has an embed option, gives you an iframe that you can use to embedd a single graph on another web site, #1622 2015-03-20 22:01:39 -04:00
Torkel Ödegaard
306358e73c Merge pull request #1621 from raintank/1619
fixes #1619 Secure PhantomJS Png rendering
2015-03-20 19:30:58 -04:00
Torkel Ödegaard
2bd2605ae9 Added poc of dashboard snapshot, sharable dashboard with data embedded 2015-03-20 19:16:59 -04:00
Anthony Woods
7010df0fe8 fixes #1619 Secure PhantomJS Png rendering
removes auth hack to allow phantomjs to query pages as a user
without auth.  Instead we pass phantomjs the session cookie,
which it then includes in the request.
2015-03-21 07:14:13 +08:00
Torkel Ödegaard
36a948965b Graph: added log base 16 and log base 1024 scales, #452 2015-03-20 18:12:12 -04:00
Torkel Ödegaard
5d6583ef7b Fixed small issue in share modal introdiced in recent commit 2015-03-20 15:07:38 -04:00
Torkel Ödegaard
a8363f02b8 Small changes to log scale handling, #452 2015-03-19 15:16:47 -04:00
Torkel Ödegaard
94c3a07115 Fixed small issue when using 'Save As', dashboard version was not reset 2015-03-19 10:32:47 -04:00
Torkel Ödegaard
30047e6a9f Updated macaron and ini package 2015-03-19 10:17:16 -04:00
Torkel Ödegaard
c1d6fcd18d Fixed full screen edit css issue where part of the dashboard became visible 2015-03-18 19:57:54 -04:00
Torkel Ödegaard
94415e2b60 Fix for panel height in fullscreen mode 2015-03-18 19:42:18 -04:00
Torkel Ödegaard
d81d0c8c44 Graph: Adds logarithmic scale option (log base 10), Closes #452 2015-03-18 18:51:29 -04:00
Torkel Ödegaard
eb8b9c4ac3 Increase api_key.key varchar to 255 length 2015-03-18 13:20:15 -04:00
Torkel Ödegaard
080847ec4d Change: shared tooltip is now enabled by default in graph panel 2015-03-18 12:47:45 -04:00
Torkel Ödegaard
bb5eeee82e fixed small issue with share modal 2015-03-17 17:34:00 -04:00
Anthony Woods
422324723a Merge pull request #1609 from raintank/1606
gofmt. remove extra whitespace
2015-03-18 00:55:06 +08:00
Anthony Woods
12e033976b Merge remote-tracking branch 'upstream/develop' into 1606 2015-03-17 23:43:40 +08:00
Anthony Woods
fc5839d8f1 gofmt. remove extra whitespace 2015-03-17 23:42:16 +08:00
Anthony Woods
32071445af Merge pull request #1607 from raintank/1606
fixes #1606 emit orgCreated event when new org created
2015-03-17 23:37:24 +08:00
Anthony Woods
bce62c49d0 fixes #1606 2015-03-17 23:10:49 +08:00
Anthony Woods
7235bd19ea Merge branch '1606' of github.com:raintank/grafana into 1606 2015-03-17 23:10:33 +08:00
Anthony Woods
6a09a7c398 fixes #1606 emit OrgCreated event when new org created. 2015-03-17 23:09:43 +08:00
Anthony Woods
068ccf1c0f fixes 1606 emit OrgCreated event when new org created. 2015-03-17 23:07:08 +08:00
Torkel Ödegaard
2a1434ce49 Merge pull request #1594 from eheydrick/docs-spelling
correct spelling
2015-03-17 09:46:38 -04:00
Torkel Ödegaard
3fe54894a5 Merge branch 'develop' of github.com:grafana/grafana into develop 2015-03-14 15:29:59 -04:00
Torkel Ödegaard
2fec2c2fa0 Templating: Dashboard will now wait to load until all template variables that have refresh on load set or are initialized via url to be fully loaded and so all variables are in valid state before panels start issuing metric requests. Closes #1255 2015-03-14 15:29:41 -04:00
Torkel Ödegaard
ea4dbeaeb9 Merge pull request #1593 from jwilder/jw-docs
Add docs for building the docs locally
2015-03-14 15:36:29 +01:00
Torkel Ödegaard
d705ee70f0 Refactoring out http settings to its own partial 2015-03-13 18:42:46 +01:00
Torkel Ödegaard
448717a757 Fixed small issue when changing data source from metrics panel 2015-03-13 17:58:58 +01:00
Torkel Ödegaard
4b3224702c Fixed asset revving issue with css files 2015-03-13 11:11:31 +01:00
Torkel Ödegaard
ab307ec7f3 Fixed css issue with title headers 2015-03-13 10:20:39 +01:00
Torkel Ödegaard
3dc9f792e6 Fixed unstar issue 2015-03-13 09:52:59 +01:00
Torkel Ödegaard
9faa1fadcb Updated docs 2015-03-13 09:46:53 +01:00
Torkel Ödegaard
cb04b7f4e2 Fixed issue with legend values when all values are negative and some are null, #1468 2015-03-13 09:27:08 +01:00
Torkel Ödegaard
de94b48d77 Merge pull request #1597 from jwilder/jw-graph
Update graph docs for v2
2015-03-13 08:32:36 +01:00
Jason Wilder
aca83479be Update graph docs for v2
Still needs metric tab for each datasource and time range details.
2015-03-12 17:20:48 -06:00
Eric Heydrick
d5564b476f correct spelling 2015-03-12 15:03:59 -07:00
Jason Wilder
3693f36e59 Add docs for building the docs locally 2015-03-12 14:47:49 -06:00
Torkel Ödegaard
17063df3cc Changed default org name form 'main' to 'Main Org.' 2015-03-12 19:43:52 +01:00
Torkel Ödegaard
f417d9aa19 Merge pull request #1592 from jwilder/jw-fixes
Anonymous access fixes
2015-03-12 19:41:20 +01:00
Torkel Ödegaard
b91b47fc46 Graph & Singlestat: Users can now set decimal precision for legend and tooltips (override auto precision), Closes #1253 2015-03-12 19:36:50 +01:00
Jason Wilder
13206fbb69 Fix default anonymous org name 2015-03-12 11:51:54 -06:00
Jason Wilder
d3d896dccd Log more descriptive error when anonymous org is not found
Was logging:

  [middleware.go:78 func·004()] [E] Anonymous access organization error%!(EXTRA <nil>)
2015-03-12 11:49:05 -06:00
Torkel Ödegaard
e78b358643 Fixed annotations enabled check from annotationsSrv, Closes #1590 2015-03-12 15:50:39 +01:00
Torkel Ödegaard
b757048544 reduced dashboard title font-weight 2015-03-12 15:45:34 +01:00
Torkel Ödegaard
ebe41fca53 Moved dashboard title into dashboard search button 2015-03-12 15:10:27 +01:00
Torkel Ödegaard
96ad3a04d4 Removed 'Back to dashboard' top nav button, now have close button on the edit box below panel 2015-03-12 14:03:09 +01:00
Torkel Ödegaard
43ba5842bb Began work on doc for migrating from v1 to v2, new features in v2 overview guide, #1571 2015-03-12 10:52:29 +01:00
Torkel Ödegaard
b8979a7253 Merge branch 'docs-1.x' into develop 2015-03-11 20:57:22 +01:00
Torkel Ödegaard
813b851c10 fixed issue in cla docs 2015-03-11 20:56:03 +01:00
Torkel Ödegaard
c1d7bef768 added cert_key and cert_file to defaults.ini 2015-03-11 19:44:31 +01:00
Torkel Ödegaard
434a237764 Added ENV variable info to the configuration docs 2015-03-11 19:32:06 +01:00
Torkel Ödegaard
945cb3254c Updated config docs with oauth setup and config instructions 2015-03-11 18:13:48 +01:00
Torkel Ödegaard
9c2edba12b Working on config docs for grafana 2.0 2015-03-11 17:54:06 +01:00
Torkel Ödegaard
477e035f2e Fixed anonymous access mode, Closes #1586 2015-03-11 17:34:11 +01:00
Torkel Ödegaard
f3d4d2782f Simplified single org settings, now auto_assign_org, and auto_assign_org_role, new [users] config section, Closes #1585 2015-03-11 16:19:29 +01:00
Torkel Ödegaard
4f03a86414 Began work on configuration docs for Grafana 2.0, #1571 2015-03-11 15:13:52 +01:00
Torkel Ödegaard
6336edbc18 Merge branch 'docs-1.x' into develop 2015-03-11 10:47:09 +01:00
Torkel Ödegaard
1f550be949 updated docs system 2015-03-11 10:46:48 +01:00
Torkel Ödegaard
5f5bb8541b Updated docs 2015-03-11 10:32:12 +01:00
Torkel Ödegaard
70ce5d0a32 Updated install docs 2015-03-10 17:54:07 +01:00
Torkel Ödegaard
5f22e7da1f Restored steps to build setup phase, installing sqlite3, speeds up builds so much in dev 2015-03-10 17:34:28 +01:00
Torkel Ödegaard
2c28f8cdca Began work on grafana 2.0 install instructions 2015-03-10 17:25:11 +01:00
Torkel Ödegaard
4244ed33c8 Merge branch 'docs-1.x' into develop 2015-03-10 16:58:31 +01:00
Torkel Ödegaard
0c62ab0683 updated docs 2015-03-10 16:27:16 +01:00
Torkel Ödegaard
aaa98e13b6 updated docs 2015-03-10 16:17:50 +01:00
Torkel Ödegaard
0ff99dddb9 Updated docs 2015-03-10 14:41:19 +01:00
Torkel Ödegaard
2b22d11923 Updated version to prebeta2 2015-03-10 13:55:08 +01:00
Torkel Ödegaard
fa2e074b94 Fixed drilldown link issue, Fixes #1579 2015-03-10 13:52:53 +01:00
Torkel Ödegaard
e75acce6ed updated package.json upgrade of grunt contrib uglify 2015-03-10 13:46:50 +01:00
Torkel Ödegaard
390589fae2 Merge pull request #1580 from bbinet/fix-uglify-compress-issue
fix uglify TypeError
2015-03-10 13:40:25 +01:00
Bruno Binet
ae41fa3011 fix uglify TypeError
This patch fix the following uglify error:
TypeError: Cannot assign to read only property 'warnings' of true
Or we can upgrade grunt-contrib-uglify to latest v0.8.0 version which
should also fix the issue.

This issue has been reported on grunt-contrib-uglify bug tracker:
https://github.com/gruntjs/grunt-contrib-uglify/issues/298
2015-03-10 11:27:17 +01:00
Torkel Ödegaard
b693c7515c fixed issue in Dockerfile 2015-03-10 09:08:24 +01:00
Torkel Ödegaard
3119d15de5 Fixed issue in Dockerfile and docs VERSION file 2015-03-10 09:06:27 +01:00
Torkel Ödegaard
b99e7ed97e Updated docs version and updated build from source instructions 2015-03-10 09:03:05 +01:00
Torkel Ödegaard
f32c34c726 Merge branch 'master' into develop
Conflicts:
	.gitignore
2015-03-10 08:57:14 +01:00
Torkel Ödegaard
15cb1d8980 Added grafana 1.x docs to main repo 2015-03-10 08:56:03 +01:00
Torkel Ödegaard
99259d246b Fixed CLA in new docs 2015-03-10 08:51:26 +01:00
Torkel Ödegaard
8c7076c04a fixed doc image link 2015-03-10 08:20:50 +01:00
Torkel Ödegaard
81bae9a844 Updated docs 2015-03-09 21:58:01 +01:00
Torkel Ödegaard
d7ce7271fe Updated docs 2015-03-09 20:20:44 +01:00
Torkel Ödegaard
5ab64987eb Switching to mkdocs for documentation, and docs that are inside the main repo, adding existing docs, #1571 2015-03-09 17:12:59 +01:00
Torkel Ödegaard
dc46148ab6 Migrated from wercker to circle CI 2015-03-07 20:30:06 +01:00
Torkel Ödegaard
1b1bbcecec Added go vet step to circle.yml 2015-03-07 19:51:19 +01:00
Torkel Ödegaard
ebad9cb502 Fixed gofmt formating, updated precommit hook 2015-03-07 16:37:19 +01:00
Torkel Ödegaard
d8005af8ee updated circle with fmt formating test 2015-03-07 16:23:22 +01:00
Torkel Ödegaard
ba3ba0aca7 Removed docker as service from circle.yml 2015-03-07 15:58:35 +01:00
Torkel Ödegaard
880893914a Removed deploy step from circle, will go in another repo 2015-03-07 15:24:52 +01:00
Torkel Ödegaard
07a21e921d Updated circle.yml added package step 2015-03-07 14:04:12 +01:00
Torkel Ödegaard
2193f222c5 Fixed bug in build container build script 2015-03-07 13:58:28 +01:00
Torkel Ödegaard
f36ea13cb2 Added saving buildcontainer to cache directory 2015-03-07 13:55:12 +01:00
Torkel Ödegaard
595a1fe852 Added back test step to circle.yml 2015-03-07 13:53:10 +01:00
Torkel Ödegaard
3334e6bf61 Fixed bug in circle.yml 2015-03-07 13:48:02 +01:00
Torkel Ödegaard
0a82b75f2a Adding caching of buildcontainer 2015-03-07 13:46:27 +01:00
Torkel Ödegaard
5b563e3841 Updated circle.yml 2015-03-07 13:28:03 +01:00
Torkel Ödegaard
3a98ce775a Updated docker build script 2015-03-07 13:27:02 +01:00
Torkel Ödegaard
8c27a10612 Updated circle.yml 2015-03-07 13:23:57 +01:00
Torkel Ödegaard
e3ce8048ad Added deploy step that runs build in centos6 container 2015-03-07 13:22:52 +01:00
Torkel Ödegaard
0d367d4b54 Updated circle.yml 2015-03-07 13:07:22 +01:00
Torkel Ödegaard
028ae7053b Updated circle.yml added npm install and grunt test step 2015-03-07 12:55:26 +01:00
Torkel Ödegaard
3f3b14130b Updated circle 2015-03-07 12:52:31 +01:00
Torkel Ödegaard
820051d40b Updated circle.yml 2015-03-07 12:46:17 +01:00
Torkel Ödegaard
97499aaa75 Updated circle.yml 2015-03-07 12:43:17 +01:00
Torkel Ödegaard
cc89bc02f4 Working on trying to get CI builds on centos6 to solve GLIBC issue, #1568 2015-03-07 12:40:19 +01:00
Torkel Ödegaard
4cbcee7e15 Updated init.d script with chkconfig comment lines, now works on centos5 2015-03-06 11:21:41 +01:00
Torkel Ödegaard
ab47c2c734 Fixed influxdb 0.9 data source, renamed clone dashboard to Save As... 2015-03-06 10:01:18 +01:00
Torkel Ödegaard
3e6ec19fd4 Fixed bug in CloneDashboardCtrl 2015-03-06 08:23:36 +01:00
Torkel Ödegaard
5719e437ef Merge pull request #1556 from jwilder/jw-export
Add dashboards:export CLI command
2015-03-06 07:59:44 +01:00
Torkel Ödegaard
dba7062fbc Some more polish to confirm dialogs 2015-03-05 21:02:25 +01:00
Torkel Ödegaard
6786ffffac Small update to submenu (annotation/templating) css, #1554 2015-03-05 20:45:14 +01:00
Torkel Ödegaard
16320d66f2 Updated build file 2015-03-05 20:11:34 +01:00
Torkel Ödegaard
ec6dd35098 Fixed path to ZeroClipboard flash file 2015-03-05 20:10:05 +01:00
Torkel Ödegaard
f5f4689e7c Worked on styling for confirm dialogs, #1554 2015-03-05 20:04:54 +01:00
Torkel Ödegaard
259d330822 Began work on modal css polish, #1554 2015-03-05 18:01:41 +01:00
Torkel Ödegaard
79be106711 Fixed javascript style check error 2015-03-05 16:53:08 +01:00
Torkel Ödegaard
5ccd3e2f84 Updated share panel/dash look, added copy to clipboard button (using ZeroClipboard lib), #1554 2015-03-05 16:52:32 +01:00
Torkel Ödegaard
4f8d22796a Merge remote-tracking branch 'origin/master' into develop 2015-03-05 12:26:08 +01:00
Torkel Ödegaard
5be5ee9b1b Fixed panel error handling issue 2015-03-05 12:25:48 +01:00
Torkel Ödegaard
679f2aa262 removed console logging, left by mistake in last commit 2015-03-05 12:19:52 +01:00
Torkel Ödegaard
58034c24ce Merge remote-tracking branch 'origin/master' into develop 2015-03-05 11:17:39 +01:00
Torkel Ödegaard
1ac9b50f21 Increased limit before graph date axis switches to showing date and hour, Fixes #1558 2015-03-05 11:16:48 +01:00
Torkel Ödegaard
af9dc4c277 Fixed issue with OpenTSDB editor and checkboxes, Fixes #1559 2015-03-05 11:00:47 +01:00
Torkel Ödegaard
f817a8ca3c Merge remote-tracking branch 'origin/master' into develop
Conflicts:
	src/app/directives/grafanaPanel.js
	src/app/features/dashboard/dashboardCtrl.js
2015-03-05 10:45:27 +01:00
Torkel Ödegaard
97e5a04621 Fixed memory leak in bootstrap Typeahead code, Fixes #1497 2015-03-05 10:42:46 +01:00
Torkel Ödegaard
30294740bd Updated build script, changed deb and rpm config path to /etc/grafana, #1476 2015-03-04 16:23:30 +01:00
Torkel Ödegaard
6bf4edade1 Updated build.go to get better version/build names 2015-03-04 14:48:21 +01:00
Torkel Ödegaard
de1e762528 Fixed issue using mysql as session store, Closes #1557 2015-03-04 10:34:26 +01:00
Torkel Ödegaard
d043ee9407 Fixed js concat issue 2015-03-04 10:04:59 +01:00
Torkel Ödegaard
14766ad38e Updated wercker, moved s3sync to deploy step 2015-03-04 09:12:32 +01:00
Torkel Ödegaard
dfcf68f21d Moved npm install before test 2015-03-04 07:20:36 +01:00
Jason Wilder
433070a135 Add dashboards:export CLI command
Allows exporting all dashboards to a --dir or filtering dashboards
by title.  If no --dir is specified, a single dashboard must be
found and it will be sent to stdout which can be piped to a file.

Fixes #1498
2015-03-03 23:16:14 -07:00
Torkel Ödegaard
d89c77af54 Small changes to build scripts 2015-03-04 07:09:59 +01:00
Torkel Ödegaard
2d7d70b90f removed old todo file 2015-03-03 21:36:51 +01:00
Torkel Ödegaard
5dc905e35d Updated wercker file 2015-03-03 21:11:37 +01:00
Torkel Ödegaard
660d44b6ad Fixed form issue with firefox and IE, Closes #1551 2015-03-03 20:47:35 +01:00
Torkel Ödegaard
d3d39b3e17 s3 sync working finally 2015-03-03 20:35:42 +01:00
Torkel Ödegaard
3fd2f87b15 another wercker failure, trying this 2015-03-03 20:32:37 +01:00
Torkel Ödegaard
9e7a0f8d83 Updated wercker again 2015-03-03 20:26:39 +01:00
Torkel Ödegaard
6703f0514d Another attemp at s3 sync 2015-03-03 20:17:13 +01:00
Torkel Ödegaard
02f4eb53dd Updated wercker s3 step 2015-03-03 20:12:11 +01:00
Torkel Ödegaard
04597b3f54 Updated wercker test step 2015-03-03 20:08:20 +01:00
Torkel Ödegaard
4379f58213 Fixed intendation in wercker file 2015-03-03 19:59:53 +01:00
Torkel Ödegaard
2906d643a5 Testing s3sync from wercker build 2015-03-03 19:58:57 +01:00
Torkel Ödegaard
bec9504cd8 Updated wercker file again 2015-03-03 19:17:24 +01:00
Torkel Ödegaard
7a8889e7f5 Added rpm tools to wercker pre build step 2015-03-03 19:00:22 +01:00
Torkel Ödegaard
8054f6a2d1 Updated build and wercker, again 2015-03-03 18:11:16 +01:00
Torkel Ödegaard
f2595917c6 updated wercker build, trying to install ruby and fpm in wercker step 2015-03-03 18:00:58 +01:00
Torkel Ödegaard
55b40aeb65 updated build.go 2015-03-03 17:58:13 +01:00
Torkel Ödegaard
4f2bca08f1 Updated wercker file again... 2015-03-03 17:56:55 +01:00
Torkel Ödegaard
48d83a4dc4 Updated wercker file 2015-03-03 17:56:08 +01:00
Torkel Ödegaard
2362f9574e Updated wercker file 2015-03-03 17:50:33 +01:00
Torkel Ödegaard
8ba9b8d7bd added custom wercker box 2015-03-03 17:47:26 +01:00
Torkel Ödegaard
c6d4b5cc86 Working on build steps 2015-03-03 17:42:50 +01:00
Torkel Ödegaard
0db55b6194 Work on deb and rpm packages, both seem to work now, #1476 2015-03-03 17:14:58 +01:00
Torkel Ödegaard
59da4a0b3b Updates to build and wercker file 2015-03-03 12:09:15 +01:00
Torkel Ödegaard
9192acf250 Fixed js style errors 2015-03-03 10:20:52 +01:00
Torkel Ödegaard
7e0f1a57af Progress on deb and rpm packaging, renamed config files, added file logging, #1476 2015-03-03 10:18:37 +01:00
Torkel Ödegaard
f5cd3d853d Small update to confirm dialog 2015-03-03 08:03:21 +01:00
Torkel Ödegaard
04d25dc58a Dashboard: When saving a dashboard and another user has made changes inbetween, the user is promted with a warning if he really wants to overwrite the other's changes, Closes #718 2015-03-02 22:24:01 +01:00
Torkel Ödegaard
56c83cefe9 Fixed so that scripted dashboards and json file based dashboards works as in 1.x, Closes #1548 2015-03-02 18:26:43 +01:00
Torkel Ödegaard
6850a4d25d Progress on deb and rpm packaging, init.d script etc, #1476 2015-03-02 17:21:52 +01:00
Torkel Ödegaard
ad2065afc7 Began work on deb and rpm packaging, #1476 2015-03-02 15:50:03 +01:00
Torkel Ödegaard
9710771f16 Added basic auth to data source edit/create, add support for basic auth in data source proxy code, Closes #1510 2015-03-02 09:58:35 +01:00
Torkel Ödegaard
ea1164322b Small fixes 2015-03-02 08:33:06 +01:00
Torkel Ödegaard
bee501da4a Added different time period override to singlestat panel, added option to hide panel time override info, Closes #171 2015-03-01 12:06:05 +01:00
Torkel Ödegaard
57b5b4c376 Worked on relative time and timeshift overrides for singlestat, still an issue for how to visualize the time override 2015-03-01 11:48:09 +01:00
Torkel Ödegaard
2c3d3d0fe3 Refactoring out common panel metric and query code to a panelHelper service 2015-03-01 11:03:41 +01:00
Torkel Ödegaard
d0d995da09 Inital work on SQL metric/annotation data source, #1542 2015-02-28 17:27:30 +01:00
Torkel Ödegaard
a3fe1efa2b Merge branch 'css-tweaks' into develop, #1465 2015-02-28 16:41:24 +01:00
Torkel Ödegaard
e84d0dd6b3 Light theme tweaks after merge with bulletfactorys light theme fixes 2015-02-28 16:41:02 +01:00
Torkel Ödegaard
0f3bf488f2 Merge branch 'develop' into css-tweaks 2015-02-28 15:48:37 +01:00
Torkel Ödegaard
04ca85fe89 Moved dashboard theme option from the dashboard to a persisted user setting, #1458 2015-02-28 14:30:08 +01:00
Torkel Ödegaard
962b316bcf Some clean up and polish of data source edit view 2015-02-28 14:00:04 +01:00
Torkel Ödegaard
ae3b9617b6 Fixed dataproxy test 2015-02-28 12:34:51 +01:00
Torkel Ödegaard
3c554953a2 Changed default OpenTSDB downsample aggregator from sum to avg 2015-02-28 12:33:20 +01:00
Torkel Ödegaard
0b1044b46f Fixed plugins go test 2015-02-28 11:38:44 +01:00
Torkel Ödegaard
ba56535fa6 Merge branch 'light-theme-tweaks' of github.com:bulletfactory/grafana into css-tweaks
Conflicts:
	src/css/less/sidemenu.less
2015-02-28 11:37:38 +01:00
Torkel Ödegaard
2e0e8ba705 Fixed solo panel test 2015-02-28 11:15:21 +01:00
Torkel Ödegaard
c283f0996d Fixed solo panel view (used for png rendering) 2015-02-28 11:07:22 +01:00
Torkel Ödegaard
232f980c72 More work on restoring features after moving to plugin model for datasources, no annotations work again #1276 #1472 2015-02-28 10:52:25 +01:00
Torkel Ödegaard
4a72c37fc1 Fixes to edit view switching, and to templateValuesSrv 2015-02-28 10:29:17 +01:00
Torkel Ödegaard
dcfad7d61b Fixed playlist functionallity, broken after recent changes 2015-02-28 10:04:19 +01:00
Torkel Ödegaard
9e892bddf0 More work on restoring features after moving to plugin model for datasources, #1276 #1472 2015-02-28 09:46:37 +01:00
Torkel Ödegaard
109dd3240a Work on new datasource plugin model, #1276 #1472 2015-02-28 08:25:13 +01:00
Torkel Ödegaard
c198242292 A lot of work on backend plugin model for frontend components, right now for data sources, will enable dropin plugins for data sources and panels, #1472 2015-02-27 22:29:00 +01:00
Torkel Ödegaard
5bd5713a52 Began work on plugin system 2015-02-27 13:45:00 +01:00
Trent White
5c39a3d004 Reversed button cleanup for light theme 2015-02-26 17:57:32 -05:00
Trent White
4e607876ea further cleanup of styles to make sidebar more readable for light theme. This tweaked link colors, dropdown colors and table tweaks for things like Add API to make them feel a little more organized through shades of gray. 2015-02-26 15:22:15 -05:00
Torkel Ödegaard
011fdf7ab6 fixed bug in datasource schema migration 2015-02-26 19:36:11 +01:00
Trent White
708ddf5387 CSS tweaks to link styles for sidebar, nav bar, search pane. Also the nav bar height seemed off from the sidebar, so made that consistent. Variables were created when colors were hard-coded for both dark and light. This meant that both variables.light.less and variables.dark.less were updated. 2015-02-26 12:37:35 -05:00
Torkel Ödegaard
c75aa23092 New implementation for API Keys that only stores hashed api keys, and the client key is base64 decoded json web token with the unhashed key, Closes #1440 2015-02-26 17:23:28 +01:00
Torkel Ödegaard
6a2a6afc1d Merge branch 'develop' into apikey_hashed
Conflicts:
	pkg/api/apikey.go
	pkg/services/sqlstore/migrations.go
2015-02-26 15:48:54 +01:00
Torkel Ödegaard
7c241fd617 Added permissions section to admin > edit user view, an admin can now make another user admin, Closes #1517 2015-02-26 15:43:48 +01:00
Torkel Ödegaard
c14a90a3d0 A lot of work on new organization selection and sidenav dropdown, #1506 2015-02-26 13:01:34 +01:00
Torkel Ödegaard
528f54153c More work on experimental InfluxDB 0.9 support 2015-02-26 08:55:49 +01:00
Torkel Ödegaard
ae7f18f981 Made a copy of influxdb datasource named influxdb_08 so the main influxdb data source can be modified to support InfluxDB 0.9, made some initial experiments to get queries to work, but a lot more work is needed, #1525 2015-02-25 18:43:44 +01:00
Torkel Ödegaard
f5f07bd552 Fixed signout links from sidenav 2015-02-25 16:52:57 +01:00
Torkel Ödegaard
bbbd3320ef Created seperate admin sidenav #1506 2015-02-25 16:01:37 +01:00
Torkel Ödegaard
32450640e2 Moved clone dashboard above delete in dashboard settings dropdown 2015-02-25 14:32:57 +01:00
Torkel Ödegaard
3f96afba73 Merge branch 'fixDashboardDelete' of https://github.com/raintank/grafana into raintank-fixDashboardDelete
Conflicts:
	pkg/services/sqlstore/dashboard.go
2015-02-25 14:31:44 +01:00
Torkel Ödegaard
9e789e6d82 More work on organization / admin nav, views, #1506 2015-02-25 14:27:34 +01:00
Torkel Ödegaard
e1d078f2c1 Final frontend changes for account -> org rename 2015-02-25 08:07:52 +01:00
Torkel Ödegaard
563d5e3ad8 All migrations work in sqlite3, mysql and postgres 2015-02-25 07:57:51 +01:00
Torkel Ödegaard
16fd256225 Added missing common.go 2015-02-24 19:10:41 +01:00
Torkel Ödegaard
f3f79792ab account -> org table migration is starting to work, need to test mysql and postgres 2015-02-24 18:32:29 +01:00
Torkel Ödegaard
ed68a4bb9a More work on SQL migrations 2015-02-24 17:59:21 +01:00
Torkel Ödegaard
02a89c752b Progress on database schema migration for account -> org refactor 2015-02-24 11:46:34 +01:00
Anthony Woods
b9b63f695d fixes #1518 fix table name used in dashboard delete. 2015-02-24 08:56:10 +00:00
Torkel Ödegaard
7293ee0894 Changed default OpenTSDB downsample aggregator to avg, #1438 2015-02-24 09:54:02 +01:00
Torkel Ödegaard
da41d99aa7 Fixed sql integration test 2015-02-23 20:48:43 +01:00
Torkel Ödegaard
26e4809e2e Big Backend Refatoring: Renamed Account -> Org 2015-02-23 20:07:49 +01:00
Torkel Ödegaard
e9e2fa2927 Started Account -> Organization rename 2015-02-23 18:29:01 +01:00
Torkel Ödegaard
5b2715515f Began work on Account -> Organization rethink, #1506 2015-02-23 16:40:04 +01:00
Torkel Ödegaard
a8c90e2365 Small update to commands 2015-02-23 14:20:24 +01:00
Torkel Ödegaard
f66968ae02 Merge remote-tracking branch 'origin/master' into develop 2015-02-23 13:05:46 +01:00
Torkel Ödegaard
a5fd40ed80 OpenTSDB: Fixed issue with auto interval variable going below 1s, Fixes #1325 2015-02-23 13:04:32 +01:00
Torkel Ödegaard
8cc4dae00b Merge remote-tracking branch 'origin/master' into develop 2015-02-23 12:57:12 +01:00
Torkel Ödegaard
2c5f19253c Added margin between opentsdb queries 2015-02-23 12:56:40 +01:00
Torkel Ödegaard
09f2950256 Merge remote-tracking branch 'origin/master' into develop
Conflicts:
	src/app/features/opentsdb/datasource.js
2015-02-23 12:50:58 +01:00
Torkel Ödegaard
65307c463a Refactoring opentsdb editor view, merging #1438, made Downsampling enabled by default 2015-02-23 12:48:07 +01:00
Torkel Ödegaard
2ae0ef94de Merge branch 'tsdb_downsample' of https://github.com/frogmaster/grafana into frogmaster-tsdb_downsample 2015-02-23 11:45:30 +01:00
Torkel Ödegaard
138e720695 Increased max user list to 1000 for user admin page, need to paging, but will have to wait a few days 2015-02-23 11:30:58 +01:00
Torkel Ödegaard
12e28c1895 added missing file 2015-02-23 11:24:45 +01:00
Torkel Ödegaard
1a106e5c38 Added change password ability to admin > edit user view, #1446 2015-02-23 11:24:22 +01:00
Torkel Ödegaard
15c52cacfb Import views are now consolidated into one view, and found through one navigation (dashboard search -> Import, Closes #1511 2015-02-23 10:50:50 +01:00
Torkel Ödegaard
4a93d205bb Moved dashboard import and json import to same view, found via dashboard search dropdown, #1511 2015-02-23 10:13:16 +01:00
Torkel Ödegaard
a146a24c06 Fixed small issue in search and showing Home dashboard when filtering by tag 2015-02-23 09:54:26 +01:00
Torkel Ödegaard
6347b9b0d7 Merge remote-tracking branch 'origin/develop' into develop 2015-02-22 08:45:44 +01:00
Torkel Ödegaard
fea6b970e5 Some prep work for using today as relative time, #1186 2015-02-22 08:44:37 +01:00
Torkel Ödegaard
afeaa9fecd Merge pull request #1507 from ryan-williams/typos
typo fixes, .gitignore tweak
2015-02-22 08:31:24 +01:00
Torkel Ödegaard
7e82626b17 Fixed bug with custom time range not being initialized correctly, Fixes #1427 2015-02-22 08:25:44 +01:00
Torkel Ödegaard
9b9aab27ca Graphs now update/refresh when you edit annotations, Fixes #1430 2015-02-22 08:09:58 +01:00
Torkel Ödegaard
31e5271921 Fixed number formating issue when InfluxDB return MAX float64, Fixes #1402 2015-02-22 07:44:40 +01:00
Torkel Ödegaard
8c977e37a9 Merge remote-tracking branch 'origin/master' into develop
Conflicts:
	README.md
2015-02-21 21:22:09 +01:00
Torkel Ödegaard
9c8134f8bc Dashboard: Fixed memory leak when switching dashboards, Fixes #1497 2015-02-21 21:19:51 +01:00
Ryan Williams
36ec15be8f fix some scripted-dashboard-comment typos 2015-02-20 19:51:23 +00:00
Ryan Williams
c29bf31f2b add intellij files to gitignore 2015-02-20 19:51:21 +00:00
Torkel Ödegaard
5b1727bcba Graph & Singlestat: Support for additional units, Fahrenheit (°F) and Celsius (°C), Humidity (%H), kW, watt-hour (Wh), kilowatt-hour (kWh), velocities (m/s, km/h, mpg, knot), Closes #1366 2015-02-20 14:45:00 +01:00
Torkel Ödegaard
7a14054057 Graph: Shared tooltip improvement, can now support metrics of different resolution/intervals, Closes #978, Fixes #1499 2015-02-20 14:07:24 +01:00
Torkel Ödegaard
481a4b0f1b Small fix to unsavedChangesSrv, did not handle new template variable correctly 2015-02-20 12:25:54 +01:00
Torkel Ödegaard
fe34c8f2e0 Worked on submenu row (templating, annotations), removed templating and annotation feature toggles, the submenu row will be visible as soon as there are any template vars or annotations, #1503 2015-02-20 12:20:10 +01:00
Torkel Ödegaard
923e18b2b9 Small design change for the submenu (templating, annotations), #1503 2015-02-20 11:27:57 +01:00
Torkel Ödegaard
596dfc304d Added guard for template variables missing query field, Fixes #1501 2015-02-20 10:45:23 +01:00
Torkel Ödegaard
47c6c6e1b7 Added change password feature, Closes #1455 2015-02-19 16:09:49 +01:00
Torkel Ödegaard
afc52f57a2 small fix to confirm modal 2015-02-19 10:42:13 +01:00
Torkel Ödegaard
0786977bcf Fixed css issue with sidebar 2015-02-19 10:15:24 +01:00
Torkel Ödegaard
181542249d Fixed failing influxdb-datasource test 2015-02-18 16:09:17 +01:00
Torkel Ödegaard
0d165e67c9 Fixed issue with influxdb, broken in recent commit today 2015-02-18 15:22:45 +01:00
Torkel Ödegaard
978b12b0dc Close dashboard edit views when clicking on dashboard title, added some tooltips to dashboard top nav 2015-02-18 15:17:31 +01:00
Torkel Ödegaard
2ca849c0c4 Changed docker image to debian:jessie 2015-02-18 14:43:58 +01:00
Torkel Ödegaard
3991d9dc06 Added error handling to dashboard imports, #1493 2015-02-18 14:18:54 +01:00
Torkel Ödegaard
60ae4afe87 Refresh frontend datasourceSrv after datasource update, no longer need to reload the page to use a newly added or updated datasource, #1493 2015-02-18 14:06:44 +01:00
Torkel Ödegaard
4ed54f6aa9 Force full reload when switching account, temp fix for refreshing frontend datasource, settings, and user account role 2015-02-18 13:18:29 +01:00
Torkel Ödegaard
17004ce3ae Fixed issue with login by username and uppercase letters in username, #1484 2015-02-18 13:00:39 +01:00
Torkel Ödegaard
596ce18aeb Worked on clone dashboard feature, #1488 2015-02-18 10:44:44 +01:00
Torkel Ödegaard
5c9ef9d9da Added form validation and css class for invalid timespans, #1494 2015-02-18 09:20:46 +01:00
Torkel Ödegaard
ad13fd0542 Added validation for correct timespans when using panel timeshift or relative time override, Fixes #1494 2015-02-18 09:08:12 +01:00
Torkel Ödegaard
26eb6e559e Removed use of absolute urls in dashboard search and dashlist, root_url option is now not required, it is required if you use oauth or proxy grafana under suburl, #1483 2015-02-17 18:43:37 +01:00
Torkel Ödegaard
946afccbb5 Fixed dashboard search dropdown issue where it closes dashboard settings view if open, also fixed so that clicking outside dashboard search will close it, Fixes #1489 2015-02-17 18:20:47 +01:00
Torkel Ödegaard
ea8307f79e Added influxdb docker block, and fixed issue when adding data source 2015-02-17 11:44:58 +01:00
Torkel Ödegaard
83d798dbad Small update to grafana.ini describe server options 2015-02-16 08:12:07 +01:00
Torkel Ödegaard
7f5f6763ea Fixed icon for ascending sort order in table legend, #1483 2015-02-16 07:52:16 +01:00
Torkel Ödegaard
8828db4fce Fixed issue with date range form validation, Closes #1485 2015-02-16 07:46:47 +01:00
Torkel Ödegaard
56d8fe4a22 Small changes to CLI commands PR 2015-02-16 07:40:21 +01:00
Jason Wilder
b6428b08d0 CLI: Fix config flag being ignored
Passing --config had no effect when passed.  It will now be applied as
the last config file and before any env var overrrides.
2015-02-15 15:06:02 -07:00
Jason Wilder
9223c95481 CLI: Order commands alphabetically 2015-02-15 14:01:48 -07:00
Jason Wilder
a3925e8aa0 CLI: Use console logger for dashbard:import command
More consistent w/ other commands and separates stdout/stderr
2015-02-15 13:51:41 -07:00
Jason Wilder
7c8fa067a2 CLI: Conver account flag to required arg
Follows the same convention as other commands.
2015-02-15 13:48:36 -07:00
Jason Wilder
f2e9ec63df CLI: Renamed import-json to dashboard:import
More consistent w/ other command names.
2015-02-15 13:45:25 -07:00
Jason Wilder
b97361b193 CLI: Add datasource:delete command 2015-02-15 13:36:10 -07:00
Jason Wilder
22652889b2 CLI: Add datasource:create command
Allows creating a datasource from the command line
2015-02-15 13:36:10 -07:00
Jason Wilder
04a970eda2 CLI: Use 8 char min col size instead of 20 2015-02-15 13:36:10 -07:00
Jason Wilder
f443b7087c CLI: Add datasource:info command
Describes the full datasource details given an account and
datasource name.
2015-02-15 13:36:10 -07:00
Jason Wilder
9cb1170361 CLI: Move duplicated config flag to global flag 2015-02-15 13:36:10 -07:00
Jason Wilder
dda760b9b5 CLI: Add datasource list command
Lists all the datasources for an account via the CLI
2015-02-15 13:36:10 -07:00
Jason Wilder
ca4124940a CLI: Remove redundant Cmd prefix from commands 2015-02-15 13:36:10 -07:00
Jason Wilder
90cd10e034 CLI: Add account:delete command 2015-02-15 13:36:10 -07:00
Jason Wilder
c1d4acc01e CLI: Use colorized console output
This extracts some of the colored logging functionality into some
convenience functions to log directly to the console (stdout) w/o
the usual logging prefixes and flags.  It's intended for console
messages when using grafana commands.
2015-02-15 13:36:10 -07:00
Jason Wilder
81531a29eb CLI: Add account:create command
Creates a new account attached to the default admin account for now.
2015-02-15 13:36:10 -07:00
Jason Wilder
7d4c319fcb CLI: Default logging output to stderr instead of stdout
Makes it possible to separate console output from logging output so
command output can be piped to a file cleanly.
2015-02-15 13:36:10 -07:00
Jason Wilder
ca37b24455 CLI: Add account list command 2015-02-15 13:36:10 -07:00
Torkel Ödegaard
f6c07fdabd Rewrote and redesign how the data source edit views look and work so they conform better to how account views look, removed tabs and put top nav items to add data source etc, made list, edit and new seperate url routes, #1483 2015-02-14 10:04:34 +01:00
Torkel Ödegaard
ed0fabd9de Fixed css issue with sidenav not extending to bottom of page when dashboard requires scrolling, #1483 2015-02-14 09:05:35 +01:00
Torkel Ödegaard
0767992662 fixed z-index pos for panel-menu compared to dashboard search dropdown, #1483 2015-02-14 08:40:15 +01:00
Torkel Ödegaard
a88187023d Added a sql integration test for api keys 2015-02-13 15:55:32 +01:00
Torkel Ödegaard
57dc12ee17 Merge pull request #1482 from raintank/issue_1481
fixes #1481.  correctly escape api_key.key column name
2015-02-13 15:47:12 +01:00
woodsaj
c9e5da48a4 Merge branch 'issue_1481' of github.com:raintank/grafana into issue_1481 2015-02-13 22:00:57 +08:00
woodsaj
7d69885e06 fixes #1481. correctly escape api_key.key column name
'key' is a reserved word in mysql. So when building a query,
the api-key.key column name needs to be escaped
2015-02-13 22:00:03 +08:00
woodsaj
55ba8ad0c4 fix issue 1481. correctly escape api_key.key column name
'key' is a reserved word in mysql. So when building a query,
the api-key.key column name needs to be escaped
2015-02-13 21:52:56 +08:00
Torkel Ödegaard
6263ec1d38 Fixed some playlist issues, error when adding duplicates 2015-02-13 14:36:16 +01:00
Torkel Ödegaard
1d86d4b94f Updated docker build, added test container script, added docker readme 2015-02-13 14:18:37 +01:00
Torkel Ödegaard
8aef2c13ec Worked on playlist mode, hides dashboard controls and dashboard search button, added prev, stop, next icon buttons 2015-02-13 09:31:40 +01:00
Torkel Ödegaard
8722ee8ad6 Worked on playlist update for Grafana 2.0, added dashboard search to playliststart view, #1460 2015-02-13 08:47:44 +01:00
Torkel Ödegaard
1a44036148 Fixed req.Host in datasource proxy, Fixes #1478 2015-02-13 07:26:33 +01:00
Torkel Ödegaard
e65a6cc063 added an inital admin settings view, very basic right now only displays all config options in grafana.ini 2015-02-12 15:46:14 +01:00
Torkel Ödegaard
29607d8951 Updated readme again 2015-02-12 13:45:53 +01:00
Torkel Ödegaard
366a9f71ad Updated readme build instructions 2015-02-12 13:44:22 +01:00
Torkel Ödegaard
79f798f67b Configuration file options can now be overriden using environment variables using GF_<SectionName>_<KeyName> syntax, if Section name contains dots in config they are replaced with underscores, and the section name and keyname needs to be all upper case, #1473 2015-02-12 13:31:41 +01:00
Torkel Ödegaard
2c16b0f0f3 added unit test for loading configuration file 2015-02-12 11:55:55 +01:00
Torkel Ödegaard
4df6668416 Merge branch 'develop' of github.com:grafana/grafana into develop 2015-02-12 10:34:52 +01:00
Torkel Ödegaard
0140a00884 Added two columns to user table, email_verified and theme, no used right now but will probably shortly 2015-02-12 10:32:22 +01:00
Torkel Ödegaard
2a31f16b76 Merge pull request #1467 from jwilder/jw-fixes
Small fixes to getting up and running
2015-02-12 02:26:54 +01:00
Jason Wilder
793eda7640 Assign new dashboard ID when importing dashboard via command-line 2015-02-11 15:20:36 -07:00
Jason Wilder
8230279932 Assign new ID to when importing dashboard via frontend
Fixes a panic: interface conversion: interface is string, not float64
when importing a dashboard that has a non-float ID.
2015-02-11 15:20:18 -07:00
Jason Wilder
a6df991b76 Update README.md w/ known working build tool versions 2015-02-11 14:55:26 -07:00
Jason Wilder
9cc0be0fc2 Add grafana binary to .gitignore
Running "go build" defaults to building a binary named
grafana in the root dir.
2015-02-11 14:55:26 -07:00
Torkel Ödegaard
0d0d802526 Removed data folder stuff, should not be in repo 2015-02-11 21:21:21 +01:00
Torkel Ödegaard
71f09ddd94 Added delete user action to user admin api, and made it work in UI, Closes #1466, #1446 2015-02-11 16:47:22 +01:00
Torkel Ödegaard
17f1224a5d Fixed light theme condition, Fixes #1462 2015-02-11 15:32:19 +01:00
Torkel Ödegaard
441e2ad2f3 Updated dockerfile and moved to docker/production folder 2015-02-11 13:53:42 +01:00
Torkel Ödegaard
39a6bf9784 Updated readme with info about the Grafana 2.0 develop branch 2015-02-10 19:38:55 +01:00
Torkel Ödegaard
8d130421c4 Updated readme with default admin user info 2015-02-10 17:10:07 +01:00
Torkel Ödegaard
add4adeec9 Fixed links to user admin views, and backend html routes for user admin edit/create urls, Closes #1451 2015-02-10 16:26:23 +01:00
Torkel Ödegaard
e165e2af95 Worked on user admin features, can now create and edit users as a grafana admin user, #1446 2015-02-10 15:36:51 +01:00
Torkel Ödegaard
088ad881e0 Updated phantomjs panel rendering code 2015-02-10 11:13:35 +01:00
Torkel Ödegaard
c5afcd8e09 Fixed issue with datasource proxying, it required account admin role when it should not 2015-02-10 10:19:43 +01:00
Torkel Ödegaard
5c795e9a50 Updated readme with docker info, updated build task 2015-02-09 16:18:30 +01:00
Torkel Ödegaard
cd8f938cab Fixed issue with sidenav toggle on non dashboard pages 2015-02-09 16:02:42 +01:00
Torkel Ödegaard
2de6f3434c Fixed default '@timestamp' time field for elasticsearch annotations, Fixes #1444 2015-02-09 13:34:12 +01:00
Torkel Ödegaard
5269422f7c Began work on hashing api keys 2015-02-09 13:30:04 +01:00
Torkel Ödegaard
c9f06e1da1 Fixed failing events test and issue with dashboard list panel 2015-02-08 11:24:03 +01:00
woodsaj
c4fe9d50bf correctly handle event being a ptr
Events are passed in as PTRs, so we need to de-reference when getting the type and value.
2015-02-08 18:13:32 +08:00
Torkel Ödegaard
2c5828528f Updates to account and admin views 2015-02-08 10:23:35 +01:00
Torkel Ödegaard
b1a95cacff Small css changes 2015-02-08 09:38:05 +01:00
Torkel Ödegaard
20b64d9b7e PanelSrv fix, now panel rerenders after column span change 2015-02-08 09:02:03 +01:00
Torkel Ödegaard
ab55412264 Refactoring of grafana (root scope view model), into contextSrv, made sidemenu always hide after login 2015-02-08 09:00:58 +01:00
Torkel Ödegaard
f82cb3aefe Various css updates 2015-02-07 22:00:33 +01:00
Torkel Ödegaard
48e5a82e7f Reduced height of search view 2015-02-07 20:43:20 +01:00
Torkel Ödegaard
727fc9d3a6 Updated search result view, removed delete link, added delete action from dashboard cogs dropdown 2015-02-07 20:25:53 +01:00
Torkel Ödegaard
51c640d409 Updated search result padding 2015-02-07 16:19:02 +01:00
Torkel Ödegaard
7ab83bf47f Updated position of search 2015-02-07 16:16:17 +01:00
Torkel Ödegaard
9818f81c5f Completed search makover 2015-02-07 16:12:29 +01:00
Torkel Ödegaard
8f4e440179 Working on new search box design 2015-02-07 15:40:31 +01:00
Torkel Ödegaard
83bf68ecad Added border for inverse button 2015-02-07 14:10:51 +01:00
Torkel Ödegaard
23bbc5160e Fixed validation for adding api keys, added unique index for api key name + account_id 2015-02-07 13:11:39 +01:00
Torkel Ödegaard
ed6d50d6ba Updated to profile page design 2015-02-07 13:04:24 +01:00
Torkel Ödegaard
b3a1bb2017 Sub nav for account page, some css changes 2015-02-07 12:28:47 +01:00
Teet Talviste
a0a4b04007 fix identation 2015-02-06 21:15:14 +02:00
Teet Talviste
ddfb36b511 satisfy travis: fix curly brace space 2015-02-06 21:07:31 +02:00
Teet Talviste
28f7806d19 fix some linting problems 2015-02-06 18:42:12 +02:00
Teet Talviste
72f6dc1e0c enable sending calculated interval to opentsdb downsample 2015-02-06 18:42:12 +02:00
Torkel Ödegaard
9a45a25e17 Removed inner black border for dashboard button 2015-02-06 17:24:19 +01:00
Torkel Ödegaard
9cadf0aa97 Updated phantomjs render script and wercker link in readme 2015-02-06 14:22:56 +01:00
Torkel Ödegaard
397dfc54cd Fixed bug in png rendering when having changed public url 2015-02-06 14:17:40 +01:00
Torkel Ödegaard
eeba128f8a Fixed release tar/zip keeping execution mode on phantomjs 2015-02-06 13:58:25 +01:00
Torkel Ödegaard
396b687e4b Added docker file for docker registry distribution 2015-02-06 11:40:04 +01:00
Torkel Ödegaard
cbe72ba9f4 Updated wercker file 2015-02-06 10:19:40 +01:00
Torkel Ödegaard
85c1c97ea2 Updated readme 2015-02-06 09:10:52 +01:00
Torkel Ödegaard
503e04d375 Updated readme 2015-02-06 08:54:43 +01:00
Torkel Ödegaard
4e5d5cd1a9 updated readme 2015-02-06 08:52:16 +01:00
Torkel Ödegaard
9cdd9e6d5f updated readme 2015-02-06 08:40:12 +01:00
Torkel Ödegaard
f8a10fa7af Updated account and profile pages, very temporary solution, do not like it at all 2015-02-06 08:21:00 +01:00
Torkel Ödegaard
e3764ad951 Fixed failing dashboard sql test 2015-02-05 15:53:15 +01:00
Torkel Ödegaard
edb7722ad6 Updated wercker file again 2015-02-05 15:29:06 +01:00
Torkel Ödegaard
39ee394068 updated wercker file to change package dir 2015-02-05 15:28:17 +01:00
Torkel Ödegaard
f4e26bba3f Removed unused node package 2015-02-05 12:39:47 +01:00
Torkel Ödegaard
102c896046 Updated build and wercker file for new repo structure 2015-02-05 12:27:58 +01:00
Torkel Ödegaard
e5fbbe96fd fixed error handling, and error logging for panel rendering 2015-02-05 12:23:24 +01:00
Torkel Ödegaard
8e1b753664 Added limit to dashboard list panel and search 2015-02-05 11:10:56 +01:00
Torkel Ödegaard
b6d5f49c0f Merge branch 'master' of github.com:torkelo/grafana-private into develop 2015-02-05 10:56:59 +01:00
Torkel Ödegaard
2cc9515fd6 Added missing mega bytes unit format to unit selection, #999 2015-02-05 10:56:39 +01:00
Torkel Ödegaard
0f63c04beb Fixed bug in user creation and admin role 2015-02-05 10:50:18 +01:00
Torkel Ödegaard
861e45aedf Merge remote-tracking branch 'origin/pro' 2015-02-05 10:37:41 +01:00
Torkel Ödegaard
10820f31c2 Changed go package path 2015-02-05 10:37:13 +01:00
Torkel Ödegaard
3ab7b5c3f7 Merge branch 'master' of /home/torkel/dev/go/src/github.com/torkelo/backend
Conflicts:
	.gitignore
	LICENSE.md
	README.md
2015-02-05 10:10:39 +01:00
Torkel Ödegaard
076905d14e Added isStarred to search result hit, very inefficient loading right now but can be cached later on 2015-02-05 09:49:00 +01:00
Torkel Ödegaard
d5471c153a Worked on dashlist panel, can now do searched 2015-02-05 09:48:14 +01:00
Torkel Ödegaard
69e7279cff fixed unit test failing on build server 2015-02-04 18:25:15 +01:00
Torkel Ödegaard
9e58921b23 Updated godeps file 2015-02-04 18:06:37 +01:00
Torkel Ödegaard
7fa6527ca8 Updated godeps file 2015-02-04 18:06:30 +01:00
Torkel Ödegaard
2fa8096569 Updated frontend 2015-02-04 17:21:57 +01:00
Torkel Ödegaard
ff47eccf4b Fixed javascript style checker issue 2015-02-04 17:21:42 +01:00
Torkel Ödegaard
5a6c04e3b0 frontend fixes 2015-02-04 17:20:38 +01:00
Torkel Ödegaard
896e6d4662 Merge branch 'notifications' 2015-02-04 17:15:16 +01:00
Torkel Ödegaard
d8db5189c1 More work on events, still have to convert pascal case event type name to rabbitmq dot notation, but after that should be done 2015-02-04 17:15:05 +01:00
Torkel Ödegaard
525179eb85 Added on wire event format 2015-02-04 16:57:20 +01:00
Torkel Ödegaard
dace35d31d Missed setting account name 2015-02-04 15:41:40 +01:00
Torkel Ödegaard
3752379106 Worked on event system, needs a little more work 2015-02-04 15:37:26 +01:00
Torkel Ödegaard
048b26a0fd Updated home dashboard 2015-02-04 11:50:40 +01:00
Torkel Ödegaard
07ec00641f update home dashboard 2015-02-04 11:50:22 +01:00
Torkel Ödegaard
60541a455f Worked on search filter flag IsStarred, and updated frontend with new dashboard list panel 2015-02-04 11:35:59 +01:00
Torkel Ödegaard
882ee4d49f A start on a dashboard list panel, can now list starred dashboards 2015-02-04 11:35:19 +01:00
Torkel Ödegaard
f0b13153ac fixed bug in frontend 2015-02-04 08:20:24 +01:00
Torkel Ödegaard
df51be02bf Fixed loading path for home dashboard 2015-02-04 08:20:00 +01:00
Torkel Ödegaard
96798ac70c Updated 2015-02-04 07:01:15 +01:00
Torkel Ödegaard
a28e4de3bd added fade transition for logo icon to hamburger 2015-02-04 07:01:03 +01:00
Torkel Ödegaard
ac73e78b3a Fixed unit test in frontedn 2015-02-03 22:18:38 +01:00
Torkel Ödegaard
613e209af3 Fixed solo panel unit test 2015-02-03 22:18:16 +01:00
Torkel Ödegaard
1ac3355b03 updated frontend with style changes 2015-02-03 22:06:07 +01:00
Torkel Ödegaard
5e4b026668 Css work applying new styles for topmenu dashboard button and logo/menu icon 2015-02-03 22:05:53 +01:00
Torkel Ödegaard
9d5979c01d Moved dashboards dir and started work on new panel for dashboard lists 2015-02-03 20:50:52 +01:00
woodsaj
a712f1a231 Add inital implementation of Notification events.
If notifications are enabled in the config, Adds a eventHandler
accepting Notification{} payloads to the internal Bus.  The
eventHandler then marshals the payload into json and sends it
to a rabbitmq topic exchange using the
Notification.Priority+Noticiation.EventType as the routing key.
eg.  INFO.account.created

Currently, notifications are only being emitted for
INFO.account.created
INFO.account.updated
INFO.user.created
INFO.user.updated
2015-02-03 23:57:42 +08:00
Torkel Ödegaard
42a5aefb23 Worked on home dashboard 2015-02-03 15:04:35 +01:00
Torkel Ödegaard
bc673fd969 Worked on loading a home dashboard through backend 2015-02-03 15:04:18 +01:00
Torkel Ödegaard
a127f2d572 Fixed png rendering 2015-02-03 13:45:52 +01:00
Torkel Ödegaard
16acdfc7c3 Merge branch 'master' of github.com:torkelo/grafana-private into pro 2015-02-03 13:36:25 +01:00
Torkel Ödegaard
858d7be8cf Migrated from ngmin to ngAnnotate 2015-02-03 13:36:04 +01:00
Torkel Ödegaard
1ca4ecc241 Updated grunt-jscs dependency version 2015-02-03 13:05:14 +01:00
Torkel Ödegaard
bd470abcf0 fontend styles updated 2015-02-03 10:46:52 +01:00
Torkel Ödegaard
dfef4727b6 Updated to sidemenu style 2015-02-03 10:46:33 +01:00
Torkel Ödegaard
3e5223b98d Merge branch 'master' of github.com:torkelo/grafana-private into pro 2015-02-03 09:43:21 +01:00
Torkel Ödegaard
0fe83d5198 minor css tweaks 2015-02-03 09:43:07 +01:00
Torkel Ödegaard
6b6b97c8d8 Minor bug fix for rememeber refresh interval after zooming two or more times, Fixes #1408 2015-02-03 09:27:00 +01:00
Torkel Ödegaard
5c3e366192 Fixed wrong icon class in annotations, broken after recent upgrade of font-awesome, Fixes #1416 2015-02-03 09:18:00 +01:00
Torkel Ödegaard
68a6a1bc15 Updated frontend, fix for paths to partials 2015-02-02 22:15:45 +01:00
Torkel Ödegaard
7fef460fa2 Fix for paths to partials 2015-02-02 22:15:15 +01:00
Torkel Ödegaard
4b7d802a9d Frontend updated with a big panel refactoring 2015-02-02 21:59:24 +01:00
Torkel Ödegaard
04ec222462 Big refactoring of the way panels are loaded and how they are built using directives, this way feel cleaner and allowed for placing the panel edit box outside the panel-container 2015-02-02 21:59:04 +01:00
Torkel Ödegaard
97758380e0 Worked on stars in search results 2015-02-02 17:17:57 +01:00
Torkel Ödegaard
b67f4dc390 Added stars to search results 2015-02-02 17:17:30 +01:00
Torkel Ödegaard
ad3d15e28d Worked on dashboard starring and unstarring, renamed favorite model to star 2015-02-02 11:32:32 +01:00
Torkel Ödegaard
1e3970c6e5 Worked on dashoard starring and unstarring, added dashboardMeta model 2015-02-02 11:32:00 +01:00
Torkel Ödegaard
706481b1a3 Updated frontend, fixed dashboard share feature 2015-02-02 09:46:03 +01:00
Torkel Ödegaard
66d9c4f1af Fixed share dashboard feature, sharing temp feature is currently removed 2015-02-02 09:45:45 +01:00
Torkel Ödegaard
cd17278c64 Updated frontend, a lot of markup, css fixes, restoring features 2015-02-02 09:00:04 +01:00
Torkel Ödegaard
f424abf87c more markup fixes 2015-02-02 08:59:38 +01:00
Torkel Ödegaard
8a5c91021d Various css and markup fixes for changed css classes 2015-02-02 08:34:54 +01:00
Torkel Ödegaard
ddc32d3cad updated frontend 2015-02-01 20:24:41 +01:00
Torkel Ödegaard
26535e163f fixing broken things in the markup for changed css classes 2015-02-01 20:23:52 +01:00
Torkel Ödegaard
cefdd86634 Minor css changes to graph panel & full edito mode 2015-02-01 19:59:53 +01:00
Torkel Ödegaard
56aa8ae6e0 more design work 2015-02-01 19:13:33 +01:00
Torkel Ödegaard
aa613bc767 updated frontend 2015-02-01 15:46:24 +01:00
Torkel Ödegaard
d272b0f56d Merge branch 'new_top_menu_design' into pro
Conflicts:
	src/app/partials/sidemenu.html
2015-02-01 15:46:08 +01:00
Torkel Ödegaard
6bc524dff8 progress on new design 2015-02-01 15:45:11 +01:00
Torkel Ödegaard
496e5bdad9 More progress on new design 2015-02-01 11:56:01 +01:00
Torkel Ödegaard
f00e5936c9 New design work 2015-01-31 18:00:26 +01:00
Torkel Ödegaard
6ea35fce66 Updated frontend 2015-01-30 15:10:43 +01:00
Torkel Ödegaard
3da90e09d5 Fixed logout link 2015-01-30 15:10:22 +01:00
Torkel Ödegaard
20c6925470 Fixed sub url setting bug 2015-01-30 14:21:32 +01:00
Torkel Ödegaard
465c72d98e More work on topnav and gf-box redesign 2015-01-30 14:12:16 +01:00
Torkel Ödegaard
59ade61687 dashboard-edit-view -> gf-box and new box design 2015-01-30 12:57:14 +01:00
Torkel Ödegaard
1ddc2e68bf Further progress on new design 2015-01-30 11:34:54 +01:00
Torkel Ödegaard
fcba5a6eeb More progress on new design 2015-01-30 10:25:10 +01:00
Torkel Ödegaard
2f7770b165 Work on new top nav design 2015-01-30 09:47:16 +01:00
Torkel Ödegaard
04d03f73b3 Added disable user sign up feature 2015-01-29 15:46:54 +01:00
Torkel Ödegaard
740709da04 Added disable user sign up feature 2015-01-29 15:46:36 +01:00
Torkel Ödegaard
2feab76a6f Merge branch 'pro' into temp_test 2015-01-29 15:08:53 +01:00
Torkel Ödegaard
d95c5e6674 Basic import of json dashboards is working, needs more work to handle updates, and continous watching, #22 2015-01-29 14:33:50 +01:00
Torkel Ödegaard
1d6413bfae More work on backend for user favorites 2015-01-29 12:10:34 +01:00
Torkel Ödegaard
3b5c813be7 worked on user frontend state, state like favorites, etc 2015-01-29 12:10:14 +01:00
Torkel Ödegaard
e02e60171e Began work on user favorites backend support & storage 2015-01-28 15:29:36 +01:00
Torkel Ödegaard
b25bf363b3 updated frontend, fixed new dashboard button 2015-01-28 14:31:09 +01:00
Torkel Ödegaard
9d0982f2f7 Merge branch 'master' of github.com:torkelo/grafana-private into pro
Conflicts:
	src/app/directives/dashEditLink.js
2015-01-28 14:30:16 +01:00
Torkel Ödegaard
25316cbe0e Fixed broken feature: new dashboard button 2015-01-28 14:25:35 +01:00
Torkel Ödegaard
cf5595bd64 mini fix for submenuEnabled being undefined, when initiating a dashboard with empty model 2015-01-28 14:24:11 +01:00
Torkel Ödegaard
12f2ca9262 updated build file 2015-01-28 13:10:09 +01:00
Torkel Ödegaard
5631d52f50 Added admin settings view 2015-01-28 11:39:35 +01:00
Torkel Ödegaard
a7a8ea3077 added admin settings view 2015-01-28 11:39:22 +01:00
Torkel Ödegaard
1cff564483 Fontend handling of account role to hide user actions and links that the user does not have access to 2015-01-28 11:33:50 +01:00
Torkel Ödegaard
c75e669204 Hide sidemenu links that the user does not have access to 2015-01-28 11:33:12 +01:00
Torkel Ödegaard
1758412a76 Settings fix 2015-01-28 10:54:14 +01:00
Torkel Ödegaard
aa261bbe23 Login: only enabled oauth options are shown on login page 2015-01-28 10:26:13 +01:00
Torkel Ödegaard
017eab8dcd Login: only enabled oauth options are now shown on login page 2015-01-28 10:25:53 +01:00
Torkel Ödegaard
7e26d7a4bf Fix to dashboard loading and error handling 2015-01-28 09:58:24 +01:00
Torkel Ödegaard
c6e110100a Just testing a thing 2015-01-27 18:20:12 +01:00
Torkel Ödegaard
a5e450a0dd Worked on anonymous access 2015-01-27 15:45:27 +01:00
Torkel Ödegaard
757b185398 Worked on ease of use for non multi tenant scenarios, Closes #20 2015-01-27 15:14:53 +01:00
Torkel Ödegaard
257519490a Worked on login remember cookie, and redirect after login 2015-01-27 12:05:23 +01:00
Torkel Ödegaard
4572747bd6 Worked on login remember cookie and redirect after login 2015-01-27 11:59:20 +01:00
Torkel Ödegaard
6e5ef561eb Updated Godeps 2015-01-27 10:11:18 +01:00
Torkel Ödegaard
95305e7e11 Changed from goconfig to its new counter part go-ini 2015-01-27 10:09:54 +01:00
Torkel Ödegaard
951ce0a102 API token -> API key rename 2015-01-27 08:26:11 +01:00
Torkel Ödegaard
11b74baf79 Api token -> api key rename 2015-01-27 08:25:52 +01:00
Torkel Ödegaard
c0353ab5d8 Graph: fix for legend show/hide toggle, after hiding requires new data fetch to show, Fixes #1393 2015-01-27 07:56:23 +01:00
Torkel Ödegaard
9fa0a4c973 Dashboard: fixed scroll isssue in firefox after dashboard import, Closes #1391 2015-01-27 07:47:01 +01:00
Torkel Ödegaard
db371d2a5d API: added admin role requirement for account changes, datasource admin, and api keys admin 2015-01-26 20:26:17 +01:00
Torkel Ödegaard
01cce09ef2 Updated frontend 2015-01-26 16:00:03 +01:00
Torkel Ödegaard
d2f21bc93e Merge branch 'master' into pro 2015-01-26 15:56:39 +01:00
Torkel Ödegaard
5ba2423626 Worked on account update view 2015-01-26 15:42:22 +01:00
Torkel Ödegaard
a6b0856020 Worked on account update view 2015-01-26 15:42:11 +01:00
Torkel Ödegaard
9a641ee7c0 Corrected the use of POST vs PUT, POST creates something, PUT updates, got them mixed up 2015-01-26 12:58:03 +01:00
Torkel Ödegaard
ab7e2f89fb Corrected the use of POST vs PUT, POST creates something, PUT updates, got them mixed up 2015-01-26 12:57:44 +01:00
Torkel Ödegaard
71ab8d6afc Merge branch 'master' of github.com:torkelo/grafana-private 2015-01-26 12:41:15 +01:00
Torkel Ödegaard
ea5da627af Panel: Different time periods, panels can override dashboard relative time and/or add a time shift, #171, only works for graph panel for now, need feedback for how to do it for singlestat panel 2015-01-26 11:49:18 +01:00
Torkel Ödegaard
1c8ef716a2 Began work on time overrides for panels, to enable different time periods on the same dashboard, #171 2015-01-26 10:57:08 +01:00
Torkel Ödegaard
6fc451da9e Small fix 2015-01-25 14:51:51 +01:00
Torkel Ödegaard
b940f4a97d Timepicker: New option in timepicker (under dashboard settings), to change now to be for example now-1m, usefull when you want to ignore last minute because it contains incomplete data, Closes #1242, Closes #374 2015-01-25 13:45:08 +01:00
Torkel Ödegaard
c2c81e7e6a Graph: Fix for all series tooltip showing series with all null values when Hide Empty option is enabled, Fixes #1359 2015-01-23 11:36:18 +01:00
Torkel Ödegaard
1508d0ac23 TemplatOCing: Fix to allow custom template variables to contain white space, now only splits on ',', Fixes #1363 2015-01-23 10:41:23 +01:00
Torkel Ödegaard
d3c37bda71 Graphite: Fix for nested complex queries, where a query references a query that references another query (ie the #[A-Z] syntax), Fixes #1372 2015-01-23 10:29:54 +01:00
Torkel Ödegaard
c82e2d74bf Login validation 2015-01-22 11:51:44 +01:00
Torkel Ödegaard
1a11b400b0 Polish and incorporating new design for login screen from matt 2015-01-22 10:14:29 +01:00
Torkel Ödegaard
1d8bb45d3a quickfix for support suburl for sidemenu nav 2015-01-21 20:14:53 +01:00
Torkel Ödegaard
fc9de68ee9 fixed broken html on login page 2015-01-21 20:01:22 +01:00
Torkel Ödegaard
1fb9bbba91 a lot of work on sidemenu, and encoding dash edit view in url 2015-01-21 19:45:23 +01:00
Torkel Ödegaard
cd4fc78aec trying to get dashboard settings, annotations and templating views be opened via url parameters 2015-01-21 16:29:04 +01:00
Torkel Ödegaard
4e6a04923a worked on new sidemenu design 2015-01-21 14:44:34 +01:00
Torkel Ödegaard
83899eb884 added hamburger 2015-01-21 13:05:55 +01:00
Torkel Ödegaard
3744bc3228 fixed server side rendering 2015-01-21 10:51:42 +01:00
Torkel Ödegaard
a0c8d3fa6f Small fix to data source view 2015-01-21 10:51:28 +01:00
Torkel Ödegaard
d3c13a1d8c removed old signup/register view 2015-01-21 09:55:15 +01:00
Torkel Ödegaard
3c8c53194f Sign up and login work 2015-01-21 09:52:40 +01:00
Torkel Ödegaard
8ed9212401 Redesigned and polished login view, still needs work on validation 2015-01-21 09:51:31 +01:00
Torkel Ödegaard
5cef73331c Fixed asteric icon in graphite metric path selector, broken after resent font awesome upgrade, #1361 2015-01-21 07:27:27 +01:00
Torkel Ödegaard
5760fa104c trying to cleanup login page 2015-01-21 06:41:09 +01:00
Torkel Ödegaard
4786e0f882 Changed name for vendor folder 2015-01-20 17:53:20 +01:00
Torkel Ödegaard
3bf7f6ed5f Updated build post processsing to include vendor dir 2015-01-20 17:53:01 +01:00
Torkel Ödegaard
9e6df378c3 worked on account creation 2015-01-20 16:29:48 +01:00
Torkel Ödegaard
9667f324f1 added ability to create accounts from profile page 2015-01-20 16:29:19 +01:00
Torkel Ödegaard
eec178458b Validation check for not removing the last account admin 2015-01-20 15:48:19 +01:00
Torkel Ödegaard
4ea5d80099 Various fixes to data access 2015-01-20 15:23:14 +01:00
Torkel Ödegaard
d9a33680a6 Fixes to account/account users 2015-01-20 15:22:45 +01:00
Torkel Ödegaard
0a695ba17a Final work on migration, now there is no usage of xorm table sync 2015-01-20 14:44:37 +01:00
Torkel Ödegaard
afb847acc8 a lot of work on database schema and migration setup, postgres now works, every integration test passes for all database types, only token table left to do 2015-01-20 14:15:48 +01:00
Torkel Ödegaard
8bb9126b77 added postgres support for db migrations 2015-01-20 09:20:44 +01:00
Torkel Ödegaard
2379c5b770 Added loglevel to migrator, added dashboard table & index migrations 2015-01-20 08:50:08 +01:00
Torkel Ödegaard
581efa857b Small fixes 2015-01-19 19:10:29 +01:00
Torkel Ödegaard
590c3b4b50 Fixes to account users view 2015-01-19 19:10:04 +01:00
Torkel Ödegaard
e750508d76 Fixes for update user and add token 2015-01-19 18:57:51 +01:00
Torkel Ödegaard
efe7279ead Quick fix for frontend for account to user split 2015-01-19 18:57:25 +01:00
Torkel Ödegaard
90925273a0 User / Account model split, User and account now seperate entities, collaborators are now AccountUsers 2015-01-19 18:01:04 +01:00
Torkel Ödegaard
f1996a9f1f Initial work on seperation between user and account 2015-01-19 16:28:45 +01:00
Torkel Ödegaard
e411b8e423 Fixed icons in graph tooltip, not updated after recent font awesome upgrade, Closes #1355 2015-01-19 13:08:18 +01:00
Torkel Ödegaard
d8e5be5782 Worked on database agnostic table creation for db migrations 2015-01-19 10:44:16 +01:00
Torkel Ödegaard
7d70ffe201 adding more columns for account table migration 2015-01-18 20:09:30 +01:00
Torkel Ödegaard
a64a38d7dd Added migration log and migration id, do not execute already executed migrations 2015-01-18 18:41:03 +01:00
Torkel Ödegaard
8bfed7508c More work on sql schema and migrations, starting to get somewhere 2015-01-18 14:51:51 +01:00
Torkel Ödegaard
68a77c4051 More progress on db schema setup and migrations, tricky stuff 2015-01-18 13:08:59 +01:00
Torkel Ödegaard
38f237efcb Merge branch 'master' of github.com:torkelo/grafana-pro 2015-01-18 08:56:32 +01:00
Torkel Ödegaard
2daffe2a15 Api import route updated 2015-01-18 08:56:19 +01:00
Torkel Ödegaard
1f987c1903 Began work on real sql schema definitions, and migration engine 2015-01-17 21:40:22 +01:00
Torkel Ödegaard
9a29b04561 Dashboard import/export now works 2015-01-17 10:39:26 +01:00
Torkel Ödegaard
1c5f902770 Added dashboard import feature 2015-01-17 10:39:01 +01:00
Torkel Ödegaard
3be11b9861 Small cosmetic change 2015-01-17 08:27:55 +01:00
Torkel Ödegaard
c970e82758 Small update to update account command 2015-01-17 08:20:25 +01:00
Torkel Ödegaard
a0036179d5 Removed alerts and graph from sidemenu, added required field to account input fields 2015-01-17 08:19:45 +01:00
Torkel Ödegaard
1532eb4278 Fixed png rendering 2015-01-16 17:00:31 +01:00
Torkel Ödegaard
64f98d2409 Mini fix for sidemenu 2015-01-16 17:00:02 +01:00
Torkel Ödegaard
ed879df1f4 Corrected spelling of SignedInUser (was SignInUser) 2015-01-16 16:17:35 +01:00
Torkel Ödegaard
2b05dac071 Api Key role is now correcty added do middleware context 2015-01-16 16:15:35 +01:00
Torkel Ödegaard
507bff8b59 Godep is acting strangly 2015-01-16 15:48:34 +01:00
Torkel Ödegaard
3912ed5023 Role checking when saving dashboard, making sure that the user has owner or editor role 2015-01-16 15:28:44 +01:00
Torkel Ödegaard
984ece646f Get access denied when trying to save from collaboration role viewer 2015-01-16 15:21:07 +01:00
Torkel Ödegaard
22156fe309 Big refactoring for context.User, and how current user info is fetching, now included collaborator role 2015-01-16 14:32:18 +01:00
Torkel Ödegaard
9637efd5ee renamed isAdmin to isGrafanaAdmin to make it less confusable with admin role 2015-01-16 14:31:09 +01:00
Torkel Ödegaard
52992928d5 Updated macaron dependency 2015-01-16 12:37:25 +01:00
Torkel Ödegaard
aa9ca68883 Tokens small fixes 2015-01-16 12:28:35 +01:00
Torkel Ödegaard
aaa717aac2 Refactoring apikeys into its own view 2015-01-16 12:28:09 +01:00
Torkel Ödegaard
4ece7fc038 Merge remote-tracking branch 'origin/tokens' into pro 2015-01-16 12:07:27 +01:00
Torkel Ödegaard
9feb8a73fd Added binding to tokens api and role validation 2015-01-16 12:06:24 +01:00
Torkel Ödegaard
d3cc6e518d updated collaborators 2015-01-16 12:06:05 +01:00
Torkel Ödegaard
f858f6b621 Add collaborator now handles role, added macaron-contrib/binding for binding and validation 2015-01-16 11:54:19 +01:00
Torkel Ödegaard
500e000661 Add collaborator now handles roles, added macaron-binding for binding and validation 2015-01-16 11:53:31 +01:00
Torkel Ödegaard
4c73d970e5 Merge branch 'master' of github.com:torkelo/grafana-private into pro 2015-01-16 09:32:06 +01:00
Torkel Ödegaard
becdaafdca Refactored away the graphite-target-inner / tight-form-row 2015-01-16 09:31:38 +01:00
woodsaj
3887aa72cb add tokens to UI under the Account Settings.
Adds support for adding and removing API tokens.
2015-01-16 16:04:46 +08:00
Torkel Ödegaard
72d7a7d91d changed grafana-target css names in partials 2015-01-16 08:50:26 +01:00
Torkel Ödegaard
e1f410d32e Starting css refactor for grafana-target 2015-01-16 08:35:32 +01:00
Torkel Ödegaard
cd5843e977 Fixed unit tests 2015-01-16 07:45:37 +01:00
Torkel Ödegaard
af3aa81d71 UI: Fixed position of confirm modal when scrolled down, Fixes #1345 2015-01-16 07:20:00 +01:00
Torkel Ödegaard
04bbdbad12 Worked on account update, moved collaborats to its own api url and files 2015-01-15 19:14:47 +01:00
Torkel Ödegaard
9d1dacb8d4 Worked on account update, moved collaborators to its own view 2015-01-15 19:14:07 +01:00
Torkel Ödegaard
f3bb2d41a7 removed sidemenu controller 2015-01-15 17:41:28 +01:00
Torkel Ödegaard
804bff55ec Accounts admin view/get api 2015-01-15 15:54:22 +01:00
Torkel Ödegaard
5b93e09714 Very basic start for accounts admin view 2015-01-15 15:53:55 +01:00
Torkel Ödegaard
fdfcc3ab2a Admin flagged users, create a default admin user on startup if missing 2015-01-15 14:44:15 +01:00
Torkel Ödegaard
cf344abff2 Admin menu only visible for admins 2015-01-15 14:43:44 +01:00
Torkel Ödegaard
5ec07db143 Refactoring of auth middleware, and starting work on account admin 2015-01-15 12:16:54 +01:00
Torkel Ödegaard
67b935188b Fixed failing unit test 2015-01-15 10:52:22 +01:00
Torkel Ödegaard
0dfd09ed0e fixed build.go setup 2015-01-14 20:51:22 +01:00
Torkel Ödegaard
6f63d63ee0 Working on account collaborators 2015-01-14 16:12:37 +01:00
Torkel Ödegaard
961ebbde6b Working on account collaborators 2015-01-14 16:12:19 +01:00
Torkel Ödegaard
50a5355de0 Merge pull request #17 from torkelo/tokenGetAccountFix
fix getAccountByToken query.
2015-01-14 14:59:23 +01:00
woodsaj
f25cffd24e fix getAccountByToken query. 2015-01-14 21:45:00 +08:00
Torkel Ödegaard
5e18afe916 Refactoring of api routes 2015-01-14 14:25:12 +01:00
Torkel Ödegaard
733a9af629 small changes 2015-01-14 14:24:54 +01:00
Torkel Ödegaard
166ce7d2ae Added Gzip option and the macaron Gzip middleware, but does not seem to work 2015-01-14 10:34:14 +01:00
Torkel Ödegaard
5833867b44 renamed register route to signup 2015-01-14 10:19:53 +01:00
Torkel Ödegaard
6cc1502c89 Renamed register routes/ctrl to signup 2015-01-14 10:19:35 +01:00
Torkel Ödegaard
ced5e5500e mini code cleanup of in auth 2015-01-14 10:14:07 +01:00
woodsaj
7b17e38f5d add Token authentication support
Added CRUD methods for Tokens.
Extend Auth Handler to check for the presence of a Bearer Authorization
header to authenticate against. If there is no header, or the token is not
valid, the Auth Handler falls back to looking for a Session.
2015-01-14 16:33:34 +08:00
Torkel Ödegaard
e58cd91487 updated frontend 2015-01-13 14:07:34 +01:00
Torkel Ödegaard
10fd66b7c5 removed old sample directory, Closes #1333 2015-01-13 10:19:32 +01:00
Torkel Ödegaard
9f4ea7301a Merge branch 'master' of github.com:torkelo/grafana-private into pro 2015-01-12 18:59:48 +01:00
Torkel Ödegaard
14e1bc8702 Graph & Singlestat: New axis/unit format selector and more units (kbytes, Joule, Watt, eV), and new design for graph axis & grid tab and single stat options tab views, #1331 2015-01-12 17:05:43 +01:00
Torkel Ödegaard
cc21c66b3a Updated design of singlestat options view, it now uses the new unit format selector, #1331 2015-01-12 17:02:58 +01:00
Torkel Ödegaard
1e9c51072a Added new units to dropdown in singlestat options, need to add new unit selector to singlestat panel, #1331 2015-01-12 16:24:44 +01:00
Torkel Ödegaard
4544f79471 Fixed influxdb and opentsdb editors to use latest markup and css, #1331 2015-01-12 16:18:35 +01:00
Torkel Ödegaard
a3da11c5bc Fixed legend values check, got rid of the legend values checkbox, #1331 2015-01-12 15:59:22 +01:00
Torkel Ödegaard
66631da1c7 Some last polish to thew new axis editor view, #1331 2015-01-12 15:47:47 +01:00
Torkel Ödegaard
d6f9ff34ce More work on new grap axis & grid edit tab, #1331 2015-01-12 15:37:22 +01:00
Torkel Ödegaard
a1e39ce24d Fixed show/hide axis toggles, #1331 2015-01-12 14:31:15 +01:00
Torkel Ödegaard
c39f9ed2f3 More work on refactoring and changing graph axis edit view, #1331 2015-01-12 14:00:30 +01:00
Torkel Ödegaard
3a27b610d5 Added all unit formats to new unit selector, #1331 2015-01-12 13:42:16 +01:00
Torkel Ödegaard
3dc30e4d8b Major reworking of the graph axis editor tab 2015-01-12 12:55:19 +01:00
Torkel Ödegaard
1a49d51d42 Merge branch 'Bps' of https://github.com/gitbisector/grafana into units
Conflicts:
	src/app/panels/graph/axisEditor.html
	src/app/panels/singlestat/editor.html
2015-01-12 10:06:12 +01:00
Torkel Ödegaard
0b46196ff5 Merge branch 'energy_formatting_units' of https://github.com/chron0/grafana into units
Conflicts:
	src/app/panels/graph/axisEditor.html
2015-01-12 10:04:11 +01:00
Torkel Ödegaard
ea6cea6f29 Merge branch 'master' of https://github.com/grimpy/grafana into units 2015-01-12 10:02:10 +01:00
Torkel Ödegaard
93fb02509b Removed flicker when refreshing a singlestat panel with spark line 2015-01-12 09:27:20 +01:00
Ties Bos
09a0ef2013 Add Bps support, much like bps 2015-01-11 22:19:59 -08:00
Torkel Ödegaard
ccbe055e5b Graph: Added right y axis label setting and graph support, Closes #599 2015-01-11 20:04:33 +01:00
Torkel Ödegaard
8e65f36131 Added system admin skeleton 2015-01-11 12:12:29 +01:00
Torkel Ödegaard
b66894f727 Added system admin page skeleton 2015-01-11 12:12:12 +01:00
Torkel Ödegaard
dc16c8c60c Added openldap docker/fig block, ldap auth seems to be complicated and take some time, not sure if that is high prio now 2015-01-11 12:11:49 +01:00
Torkel Ödegaard
92c3d80189 SingleStatPanel: You can now use template variables in pre & postfix, Closes #1321 2015-01-10 12:49:35 +01:00
Torkel Ödegaard
68cc3f86dd Handle default datasource management 2015-01-09 16:36:23 +01:00
Torkel Ödegaard
1d769fe41c Worked on handling marking a datasource as the default 2015-01-09 16:35:36 +01:00
Torkel Ödegaard
4edf0c9768 Fixed alert popup close icon 2015-01-09 16:28:58 +01:00
Torkel Ödegaard
d562dcd90c Default datasource and event system test 2015-01-09 11:01:37 +01:00
Torkel Ödegaard
f99e1ba441 Updated readme 2015-01-09 10:16:01 +01:00
Torkel Ödegaard
1b9b8ba2bf Fixed two icons 2015-01-09 10:15:42 +01:00
Torkel Ödegaard
16f7f68636 Plugins: fixed broken example panel plugin, Fixes #1318 2015-01-09 09:37:42 +01:00
Torkel Ödegaard
c1272de462 Merge branch 'master' of github.com:torkelo/grafana-private into pro 2015-01-08 19:04:38 +01:00
Torkel Ödegaard
31cf8812f6 Fixed some icons that I had missed when upgrading font awesome to 4.2 2015-01-08 19:03:45 +01:00
Torkel Ödegaard
a81a5315e1 Added graphite docker and fig config 2015-01-08 17:34:41 +01:00
Torkel Ödegaard
f332f22bed Updated icons to font-awesome 4.2 2015-01-08 15:00:34 +01:00
Torkel Ödegaard
08ae183877 Merge branch 'master' of github.com:torkelo/grafana-private into pro 2015-01-08 14:38:10 +01:00
Torkel Ödegaard
c4ce553936 Fixed icon in panel header when drilldown link is present 2015-01-08 14:37:50 +01:00
Torkel Ödegaard
6f987253ac Fixed dependency for unsavedChangesSrv 2015-01-08 12:27:54 +01:00
Torkel Ödegaard
1f1244f285 Upgrade Font-Awesome from 3.2 to 4.2 2015-01-08 12:23:11 +01:00
Torkel Ödegaard
3cf775a1f6 Added handling and view for 404 not found 2015-01-08 09:46:33 +01:00
Torkel Ödegaard
979349388c Added 404 not found view 2015-01-08 09:46:11 +01:00
Torkel Ödegaard
cdcf88cbdf fixed path for solo panel ctrl 2015-01-08 09:34:46 +01:00
Torkel Ödegaard
d573ee22f1 Fixed missing godep dependency for unit tests 2015-01-08 09:23:34 +01:00
Torkel Ödegaard
18ff1569b9 Added missing mysql driver package dependency 2015-01-08 09:01:39 +01:00
Torkel Ödegaard
3226a3a58e Fixed hashing of passwords, Closes #3 2015-01-08 09:00:00 +01:00
Torkel Ödegaard
164435f71d Moving code arround 2015-01-08 08:01:26 +01:00
Torkel Ödegaard
6d814af0cc Updated frontend 2015-01-08 07:40:17 +01:00
Torkel Ödegaard
ffbbb5bc9e Graph: Fixed issue when using zero as a grid threshold, Fixes #1309 2015-01-07 20:03:51 +01:00
Torkel Ödegaard
d3e11cabd5 Fixed link to server side rendered panel 2015-01-07 16:56:57 +01:00
Torkel Ödegaard
35326e1d92 Worked a little on anonymous access, needs more work 2015-01-07 16:37:24 +01:00
Torkel Ödegaard
9d629f2780 Tested with mysql, added simple fig file, need to write a more substantial fig setup 2015-01-07 14:05:57 +01:00
Torkel Ödegaard
1ae52d2472 Dashboard search by tag, and tag cloud now works, god dam I hate SQL 2015-01-07 12:37:24 +01:00
Torkel Ödegaard
37ba2511d5 fixed error handling in default dashboard route 2015-01-06 20:40:12 +01:00
Torkel Ödegaard
bcdbec61d7 Dashboard search works better, tag cloud should be done soon 2015-01-06 18:39:26 +01:00
Torkel Ödegaard
d03949a735 Worked on dashboard and tag search through backend 2015-01-06 18:38:48 +01:00
Torkel Ödegaard
63fa9f4535 InfluxDB: Fix handling of empty array in templating variable query, Fixes #1298 2015-01-06 17:32:39 +01:00
Torkel Ödegaard
3f266a3e1b Fixed dashboard search 2015-01-06 17:22:10 +01:00
Torkel Ödegaard
a5c8bbfe1f Fixed query param in dashboard search for grafana datasource 2015-01-06 17:15:38 +01:00
Torkel Ödegaard
584f40d0c4 Merge branch 'master' of github.com:torkelo/grafana-private into pro 2015-01-06 14:16:06 +01:00
Torkel Ödegaard
72974719ac Remember last dashboard 2015-01-06 14:15:48 +01:00
Torkel Ödegaard
d4c3463f68 InfluxDB: auto escape column names with special characters, Closes #1296 2015-01-06 13:26:09 +01:00
Torkel Ödegaard
47e4b77140 lodash remove override fix, Fixes #1304 2015-01-06 13:03:55 +01:00
Torkel Ödegaard
3e07605260 added a /api/metrics/test query that returns random walk series 2015-01-06 09:11:00 +01:00
Torkel Ödegaard
49b18e17d7 added test query feature to grafana datasource to generate a test graph on first login 2015-01-06 09:10:20 +01:00
Torkel Ödegaard
7c6f0ad445 Graphite: Added cumulative and minimumBelow graphite functions, Closes #1297 2015-01-05 20:25:55 +01:00
Torkel Ödegaard
0e3f91508e Added validation to stop duplicate dashboards with same name from being saved 2015-01-05 17:04:29 +01:00
Torkel Ödegaard
34427f34e8 side menu visible by default after login 2015-01-05 17:03:56 +01:00
Torkel Ödegaard
4131b75562 updated build script and readme with build instructions 2015-01-05 16:17:36 +01:00
Torkel Ödegaard
62af885c09 frontend build script fix 2015-01-05 11:05:21 +01:00
Torkel Ödegaard
344812f1e0 fix in grunt build script 2015-01-05 11:04:58 +01:00
Torkel Ödegaard
d06174fb56 Added build script written in go that adds build symbols for version, commit and build date 2015-01-05 10:46:58 +01:00
Torkel Ödegaard
72d9532207 updated login view with build info 2015-01-05 10:46:16 +01:00
Torkel Ödegaard
ab052a5ed3 Added missing letters to graphite datasource nested query interpolation, #1294 2015-01-05 10:02:03 +01:00
Torkel Ödegaard
6ebf766342 updated frontend 2015-01-05 08:47:44 +01:00
Torkel Ödegaard
d1b31bb3d6 moved stuff around, trying to get rid of the pro folders and fixing some issues 2015-01-05 08:47:29 +01:00
Torkel Ödegaard
19c70a126f fixed oauth login redirect when using app sub url 2015-01-05 08:21:52 +01:00
Torkel Ödegaard
4cc8a9bd18 More work on getting grafana pro to work in sub url 2015-01-05 07:59:18 +01:00
Torkel Ödegaard
9be53f0a79 Updates to support sub url 2015-01-05 07:58:15 +01:00
Torkel Ödegaard
f25a415a9e Work on making grafana work in sub url 2015-01-04 21:03:40 +01:00
Torkel Ödegaard
5feed2344a Fixes to make grafana work in sub url 2015-01-04 21:01:28 +01:00
Torkel Ödegaard
9ba34aabab updated build script to output bin in correct path 2015-01-04 18:57:16 +01:00
Torkel Ödegaard
0b855aeac9 updated wercker script 2015-01-04 18:37:45 +01:00
Torkel Ödegaard
176c042cb6 updated wercker script 2015-01-04 18:29:55 +01:00
Torkel Ödegaard
db4ab8d8a7 updated wercker deploy step 2015-01-04 18:14:28 +01:00
Torkel Ödegaard
836f48b24c updated wercker file again 2015-01-04 18:08:43 +01:00
Torkel Ödegaard
9e01740193 updated wercker script 2015-01-04 18:05:16 +01:00
Torkel Ödegaard
b77a2d0f42 updated wercker script 2015-01-04 17:58:04 +01:00
Torkel Ödegaard
c83b0f2680 updated wercker deploy script 2015-01-04 17:52:10 +01:00
Torkel Ödegaard
5a3d3f5098 updated build and release tasks 2015-01-04 17:51:48 +01:00
Torkel Ödegaard
30c7cb80f9 corrected intendation in wercker file 2015-01-04 15:13:43 +01:00
Torkel Ödegaard
a71e54113e fix to wercker file 2015-01-04 15:07:44 +01:00
Torkel Ödegaard
dff19db58d added test deploy step to wercker file 2015-01-04 15:05:40 +01:00
Torkel Ödegaard
31520844b4 fix in wercker file 2015-01-04 14:44:22 +01:00
Torkel Ödegaard
282b3b3170 Updated wercker file 2015-01-04 14:37:24 +01:00
Torkel Ödegaard
55bc150701 added backend config frontend componenet 2015-01-04 14:36:41 +01:00
Torkel Ödegaard
fc88429282 Graphite: query letter for the whole alfabet, Fixes #1294 2015-01-04 12:25:06 +01:00
Torkel Ödegaard
ee443d91dd Fixed account creation on first github login 2015-01-01 22:27:19 +01:00
Torkel Ödegaard
318338f967 Updated zip release task 2015-01-01 22:26:57 +01:00
Torkel Ödegaard
29c9330965 Changes to config file loading 2015-01-01 15:29:10 +01:00
Torkel Ödegaard
7c72705bc5 more work on build process 2015-01-01 15:28:28 +01:00
Torkel Ödegaard
ad4cf373a6 Work on unifying backend grafnaa and standalone grafana, and being able to build both from the same branch 2014-12-31 19:02:00 +01:00
Torkel Ödegaard
33e3fc70b2 trying to get revision asset replacements to work with different paths 2014-12-31 19:01:10 +01:00
Torkel Ödegaard
9c3cd87bee more work on two grunt build modes, backend/standalone modes 2014-12-31 16:19:45 +01:00
Torkel Ödegaard
f8ddfec98c progress on being able to use exact same code base for backend and standalone version, building optimized build needs a little more work 2014-12-31 14:18:34 +01:00
Torkel Ödegaard
53ff171436 Standalone and backend mode with same code base is starting to work 2014-12-31 12:54:12 +01:00
Torkel Ödegaard
75c77a44c9 Merge branch 'master' of github.com:torkelo/grafana-private into pro
Conflicts:
	src/app/app.js
	src/app/controllers/all.js
	src/app/routes/all.js
	src/app/services/datasourceSrv.js
	src/test/test-main.js
2014-12-31 12:07:22 +01:00
Torkel Ödegaard
11b44f2b01 changes to make requirejs optimizer complete 2014-12-31 11:50:34 +01:00
Torkel Ödegaard
d1e33ec071 Moved routes 2014-12-31 11:48:15 +01:00
Torkel Ödegaard
39f3cfc1eb moved dashboard stuff into a feature folder, not sure about this, but need better structure and better way to organize dependencies 2014-12-31 11:05:19 +01:00
Torkel Ödegaard
2f811375bb Moving templating to feature to feature folder 2014-12-31 09:35:00 +01:00
Torkel Ödegaard
8d7390e765 moved annotation editor and service to features folder 2014-12-31 09:28:30 +01:00
Torkel Ödegaard
8268c65c57 Trying to organize code more around features than the standard controllers, services structure 2014-12-30 21:24:55 +01:00
Torkel Ödegaard
f9b0a01c74 restructuring 2014-12-30 21:08:56 +01:00
Torkel Ödegaard
0a4ccdcef2 moved all graphite code into features/graphite 2014-12-30 20:49:04 +01:00
Torkel Ödegaard
2b02c87b16 updated godeps file 2014-12-30 12:05:01 +01:00
Torkel Ödegaard
e738a67e06 removed the need for symbolic link to grafana/src 2014-12-30 12:03:03 +01:00
Torkel Ödegaard
b2f70c12b9 Updated packages 2014-12-30 11:38:36 +01:00
Torkel Ödegaard
c4a48b35c0 Updated libs 2014-12-30 11:27:36 +01:00
Torkel Ödegaard
9cc47b6b58 Updated godeps file 2014-12-30 11:14:22 +01:00
Torkel Ödegaard
41083b08ce fixed typo in wercker.yml 2014-12-30 11:11:49 +01:00
Torkel Ödegaard
8d6b09e995 Trying to use godep in wercker build 2014-12-30 11:09:50 +01:00
Torkel Ödegaard
599a77c776 Added karma test step to build/relase grunt task 2014-12-30 11:05:24 +01:00
Torkel Ödegaard
d7e796097a Another wercker update 2014-12-30 10:58:13 +01:00
Torkel Ödegaard
79e5dd3794 Updated wercker file 2014-12-30 10:48:46 +01:00
Torkel Ödegaard
ef90f1dca6 Updated readme 2014-12-30 10:37:00 +01:00
Torkel Ödegaard
aafe2c5b98 Updated session lib 2014-12-30 10:28:27 +01:00
Torkel Ödegaard
e9fcca16bd updated to new golang/x/oauth2 2014-12-30 10:10:13 +01:00
Torkel Ödegaard
c04a2ababd added basic wercker file 2014-12-30 09:33:27 +01:00
Torkel Ödegaard
8faa806c90 Refactoring dashboard delete and search 2014-12-29 13:58:06 +01:00
Torkel Ödegaard
164d11c816 InfluxDB now works in proxy mode, influxdb username and password is added in the backend and never exposed to frontend, #8 2014-12-29 13:36:08 +01:00
Torkel Ödegaard
27b11b1d79 InfluxDB now works in proxy mode, influxdb username and password is added in the backend and never exposed to frontend, #8 2014-12-29 13:35:51 +01:00
Torkel Ödegaard
d9386cc2c3 Updated lastest.json 2014-12-29 11:24:14 +01:00
Torkel Ödegaard
38f348e642 Updated version to 1.9.1 2014-12-29 11:21:25 +01:00
Torkel Ödegaard
656ec9c48f SinglestatPanel: added more fontsize options, Closes #1187 2014-12-29 10:51:59 +01:00
Torkel Ödegaard
ec98c201e4 Datasource options are now included in bootData 2014-12-28 19:30:14 +01:00
Torkel Ödegaard
47f226be3b login force full page reload 2014-12-28 19:29:41 +01:00
Torkel Ödegaard
f3132b4513 Trying a different approach to providing frontend settings 2014-12-28 18:37:39 +01:00
Torkel Ödegaard
cfabccc5f2 Work on handling frontend settings 2014-12-28 18:37:09 +01:00
Torkel Ödegaard
f5e8f9334b Fixed test failing in chrome 2014-12-26 11:50:59 +01:00
Torkel Ödegaard
7be2105fd9 Merge pull request #1272 from matschaffer/plugin-spec-support
Allow for plugin testing.
2014-12-26 11:40:54 +01:00
Torkel Ödegaard
49ee388dcf Merge pull request #1274 from matschaffer/panel-alert-tweak
Bring panel alert to front and move tooltip to top.
2014-12-26 11:40:41 +01:00
Mat Schaffer
6cb4b4061c Bring panel alert to front and move tooltip to top.
This makes the panel a lot easier to mouse over without odd visual effects.
2014-12-23 18:12:04 -08:00
Mat Schaffer
85e50ece2e Allow for plugin testing.
With this change in place you can include plugin specs in `grunt test` by creating a `src/config.js` like that includes something like this:

```js
      plugins: {
        // list of plugin panels
        panels: [],
        // requirejs modules in plugins folder that should be loaded
        // for example custom datasources
        dependencies: ['grafana-plugins/atlasDatasource'],
        specs: ['grafana-plugins/specs/atlasDatasource-specs']
      }
```
2014-12-23 12:01:50 -08:00
Torkel Ödegaard
32ae0ea13e Plugins: Custom datasource example adapted to return timestamps in millieseconds, Fixes #1263 2014-12-23 11:32:25 +01:00
Torkel Ödegaard
a55a606a55 Refactoring dashboard data access 2014-12-22 12:25:08 +01:00
Torkel Ödegaard
22bf20a135 Refactoring get account by id and by login to queries 2014-12-19 13:40:02 +01:00
Torkel Ödegaard
5dcf6ff2d3 Refactoring set using account 2014-12-19 13:12:47 +01:00
Torkel Ödegaard
dede578c7d Updated to datasource management 2014-12-19 12:52:00 +01:00
Torkel Ödegaard
607b0c0c0e More refactoring and aligning code to the command query model 2014-12-19 11:53:27 +01:00
Torkel Ödegaard
d5a59ac6b7 More migration to command/query and sql tests, looking good 2014-12-19 11:08:49 +01:00
Torkel Ödegaard
ccba95542b Moved add collaborator to command way of doing it 2014-12-19 10:45:22 +01:00
Torkel Ödegaard
36c46112df Refactoring data access to command query model, and adding tests for sql code 2014-12-19 09:43:16 +01:00
Torkel Ödegaard
1b3bddd622 Graph: graph spinner should not stop until annotation request is complete, #1235 2014-12-19 08:39:23 +01:00
Torkel Ödegaard
e5811e29b1 Added username, site and password for influxdb datasources 2014-12-19 08:19:12 +01:00
Torkel Ödegaard
525b367a6f Config.js generation, simple temp solution, first is default datasource 2014-12-19 07:42:20 +01:00
Torkel Ödegaard
a7c816c65e Datasource proxy, switch to lookup by id 2014-12-19 07:27:25 +01:00
Torkel Ödegaard
a2a0e0394d Work on data source proxying, #6 2014-12-18 20:26:06 +01:00
Torkel Ödegaard
d69258e28f Backend can now generate config.js, the very basic stuff, more work needed 2014-12-18 15:41:38 +01:00
Torkel Ödegaard
4e542d8b83 Changed config.js to backend generated config.js 2014-12-18 15:41:01 +01:00
Torkel Ödegaard
731bb6ba03 Graph: hover tooltip and axis format units fix, bug introduced last week 2014-12-18 09:12:36 +01:00
Torkel Ödegaard
fed06ef97d Graph: Fix for y axis and scaled units (GiB etc) caused rounding, for example 400 GiB instead of 378 GiB, Fixes #1251 2014-12-18 08:44:47 +01:00
Torkel Ödegaard
ce947d4793 Update data sources now work, #8 2014-12-17 17:32:22 +01:00
Torkel Ödegaard
ad91093902 Update datasource now works, #8 2014-12-17 17:31:57 +01:00
Torkel Ödegaard
a58330f4d8 InfluxDB: Support more than 10 series name segments when using alias patterns, Closes #1126 2014-12-17 14:14:24 +01:00
Torkel Ödegaard
5a46c2397b OpenTSDB: Downsample query field now supports interval template variable, Closes #1242 2014-12-17 13:34:52 +01:00
Torkel Ödegaard
adf4e72cf8 More general backend work, in the middle of the night... Zzzz 2014-12-17 03:09:54 +01:00
Torkel Ödegaard
0e97030716 More datasource admin, and backendSrv work 2014-12-17 03:09:25 +01:00
Torkel Ödegaard
c7ed348ee8 Lots of progress on command/query bus concept, in memory sql testing, datasource admin 2014-12-16 21:05:49 +01:00
Torkel Ödegaard
27f07e9de2 Progress on data source admin 2014-12-16 16:45:07 +01:00
Torkel Ödegaard
adb1502e72 Data source admin progress 2014-12-16 16:44:45 +01:00
Torkel Ödegaard
f79588c191 Annotations: mini fix for annotations editor and the list of annotations 2014-12-16 15:47:10 +01:00
Torkel Ödegaard
b70a3f0958 started work datasources admin 2014-12-16 12:04:08 +01:00
Torkel Ödegaard
b3b096e204 Moved things around, started work on datasources view 2014-12-16 12:02:06 +01:00
Torkel Ödegaard
f665a30d28 Added lint step to Makefile 2014-12-16 10:45:16 +01:00
Torkel Ödegaard
53b00d80d6 Fixed GetOtherAccountsFor query 2014-12-16 09:06:49 +01:00
Torkel Ödegaard
705455d5d6 Set active account now works again 2014-12-15 21:56:16 +01:00
Torkel Ödegaard
973b9cad36 moved all http route handling into single package named api 2014-12-15 21:25:02 +01:00
Torkel Ödegaard
1663cbbb34 Merge branch 'master' of github.com:torkelo/grafana-pro
Conflicts:
	.bra.toml
2014-12-15 20:50:38 +01:00
Torkel Ödegaard
26ec858903 Moved grafana bin file to bin folder 2014-12-15 17:36:42 +01:00
Torkel Ödegaard
9f766557f1 Dashboard: fixed minor issue when trying to aborting dashboard delete from search list, Fixes #1233 2014-12-15 17:30:01 +01:00
Torkel Ödegaard
6c351c724d merged grafana upstream 2014-12-15 16:18:24 +01:00
Torkel Ödegaard
373118c5ee Merge branch 'master' of github.com:torkelo/grafana-private into pro 2014-12-15 16:17:59 +01:00
Torkel Ödegaard
a40c6e65dd Merge branch 'master' of github.com:torkelo/grafana-pro 2014-12-15 16:17:29 +01:00
Torkel Ödegaard
29749809d2 Updated 2014-12-15 16:17:20 +01:00
Torkel Ödegaard
846cf934f5 Graph: New legend option hideEmtpy to hide series with only null values from legend, Closes #1028 2014-12-15 16:13:34 +01:00
Torkel Ödegaard
162eb4ca35 Panel: duplicate now always adds the duplicated panel on the same row instead of creating a new row, Closes #1185 2014-12-15 15:21:29 +01:00
Torkel Ödegaard
2f18444a43 Graphite: alt node suggestions will now not include wildcard or template variables if the node is empty, Closes #1230 2014-12-15 15:16:03 +01:00
Torkel Ödegaard
8a4ff5bddc Merge pull request #1205 from noise/master
fix #1204: add separate datasource parameter withCredentials
2014-12-15 15:05:43 +01:00
Torkel Ödegaard
4ae7648bea Merge pull request #1193 from jklukas/master
Add offsetToZero to gfunc.
2014-12-15 12:37:27 +01:00
Torkel Ödegaard
dc75559758 Merge pull request #1206 from nikut/sumSeriesWithWildcards-params
allow multiple params for sumSeriesWithWildcards
2014-12-15 12:35:19 +01:00
Torkel Ödegaard
acd944a649 Graphite: movingAverage / movingMedian parameter type impovement, now handles int and interval parameter, Fixes #1207 2014-12-15 12:33:04 +01:00
Torkel Ödegaard
3c1b30e3c1 Graphite: parser fix for hard case where ip numbers are used as segments, Fixes #1224 2014-12-15 11:36:08 +01:00
Torkel Ödegaard
5daefc8b8e White theme: css fix for links in annotations tooltips, Fixes #1216 2014-12-15 10:53:37 +01:00
Torkel Ödegaard
715b9cbad0 Small fix, removed test code change 2014-12-11 09:44:45 -08:00
Torkel Ödegaard
7194e91d3b Singlestat: small fix for threshold evalutations, use greater or equal for threshold checks, Fixes #1192 2014-12-11 09:43:36 -08:00
Torkel Ödegaard
69d56b8ed7 Graph: fix for series tooltip when one series is hidden/disabled, #1199 2014-12-11 07:47:04 -08:00
Torkel Ödegaard
982a5b1a39 Panel: drilldown link, moved new params tooltip to params property, #1210 2014-12-11 07:26:00 -08:00
Torkel Ödegaard
6b8cb4ac7f Merge pull request #1210 from falkenbt/patch-1
Extend tooltip for drilldown link
2014-12-11 07:23:07 -08:00
Torkel Ödegaard
397f253180 Merge pull request #1214 from DazWorrall/useseriesabove
Added graphite function 'useSeriesAbove'
2014-12-11 07:21:00 -08:00
Darren Worrall
f93b6f7d85 Add missing default parameters to useSeriesAbove 2014-12-10 15:57:12 +00:00
Darren Worrall
edb2cf2cf2 Added graphite function 'useSeriesAbove' 2014-12-10 15:51:45 +00:00
falkenbt
fb12dd4688 Extend tooltip for drilldown link
It took me a bit to find out that variables need to be passed with var-variableName. 
The behavior is not specific to the drilldown link but I couldn't find it in any documentation elsewhere and it might help others to have it documented right here.
2014-12-09 17:23:44 +01:00
Niku Toivola
0a561e5aeb allow multiple params for sumSeriesWithWildcards 2014-12-09 11:41:01 +02:00
bret barker
c140c8cac9 fix #1204: add separate datasource parameter withCredentials 2014-12-08 09:35:55 -05:00
Jeff Klukas
06ab063671 Add offsetToZero to gfunc. 2014-12-04 09:00:47 -08:00
Torkel Ödegaard
1591a486cc Fixed typo in graphite editor tooltip 2014-12-02 14:51:21 -08:00
Torkel Ödegaard
b53efed1ef formating fix for the changelog 2014-12-02 14:49:42 -08:00
Torkel Ödegaard
7a202db5ad Updated latest.json 2014-12-02 14:24:34 -08:00
Torkel Ödegaard
af1ae7cab4 SinglestatPanel: decimal precision fix for uneven numbers, #1066 2014-12-02 13:55:56 -08:00
Torkel Ödegaard
24519cbf78 Updated version to 1.9.0 2014-12-02 11:21:18 -08:00
Torkel Ödegaard
01305462aa Row: css fix for collapsed rows with empty title 2014-12-02 11:07:51 -08:00
Torkel Ödegaard
90ae59ccaf Fixed png rending 2014-12-01 13:25:57 -08:00
Torkel Ödegaard
ff6a2d014a Refactored command/query interface 2014-12-01 08:56:03 -08:00
Torkel Ödegaard
246f41b88a Bus experiment 2014-11-28 22:16:49 +01:00
Torkel Ödegaard
a799fac983 Added Godeps and embedded dependencies 2014-11-28 11:56:03 +01:00
Torkel Ödegaard
50164324f3 moved back to a main.go file in root 2014-11-28 11:51:34 +01:00
Torkel Ödegaard
634d8c9978 sync with oss master 2014-11-28 09:14:54 +01:00
Torkel Ödegaard
e5eb0e3874 Merge branch 'master' of github.com:torkelo/grafana-private into pro 2014-11-27 15:01:48 +01:00
Torkel Ödegaard
63273f4ccf Merge branch 'master' of github.com:torkelo/grafana-private into pro 2014-11-27 14:59:58 +01:00
Torkel Ödegaard
7a4077405e Annotations: added html sanitation to prevent markup injection/XSS, Closes #1121 2014-11-27 14:46:01 +01:00
Torkel Ödegaard
9594effb6c Graph: Fix for tooltip series order when series draw order was changed with zindex property, Fixes #1108 2014-11-27 14:30:17 +01:00
Torkel Ödegaard
e750498696 Templating: added validation for allowed characters in variable names, Closes #1106 2014-11-27 14:22:55 +01:00
Torkel Ödegaard
69e18905f5 Templating: added validation to template editor for variable names, Fixes #1133 2014-11-27 14:17:31 +01:00
Torkel Ödegaard
ac4524cf9b Firefox: Workaround for Firefox bug, casued input text fields to not be selectable and not have placeable cursor, Fixes #1123 2014-11-27 13:35:03 +01:00
Torkel Ödegaard
7baad7ff10 Tech: updated angular libs 2014-11-27 13:31:55 +01:00
Torkel Ödegaard
d7ef6daeb8 SinglestatPanel: Fixed absolute drilldown link issue, Fixes #1150 2014-11-27 10:42:05 +01:00
Torkel Ödegaard
d8d5516e24 Create README.md 2014-11-26 12:57:16 +01:00
Torkel Ödegaard
93e3908a63 Merge pull request #1140 from johnou/support_negative_thresholds
Support for threshold colouring of zero / negative values.
2014-11-26 12:33:29 +01:00
Torkel Ödegaard
d7ee4b4573 Added missing files 2014-11-26 09:58:36 +01:00
Torkel Ödegaard
bf5f6ce97c Merge branch 'master' of github.com:grafana/grafana
Conflicts:
	CHANGELOG.md
2014-11-26 09:36:11 +01:00
Torkel Ödegaard
ed2ca5fced Graph: Fix to legend value Max and negative values, Fixes #1136 2014-11-26 09:34:21 +01:00
Johno Crawford
8dfe85f23e Support for negative thresholds. 2014-11-25 19:31:35 +00:00
Torkel Ödegaard
a492eceff0 refactoring 2014-11-24 17:37:20 +01:00
Torkel Ödegaard
be781bdb98 Tried postgres 2014-11-24 10:17:13 +01:00
Torkel Ödegaard
a8f915f049 Merge branch 'macaron' 2014-11-24 08:20:22 +01:00
Torkel Ödegaard
e750080f00 removed old code 2014-11-24 08:20:16 +01:00
Torkel Ödegaard
79beefe57c Updated grafana datasource 2014-11-24 08:05:07 +01:00
Torkel Ödegaard
fcdcd63dc7 get other accounts works 2014-11-24 08:04:41 +01:00
Torkel Ödegaard
846992930c Merge pull request #1109 from jklukas/master
Purge timspan variable from scripted templates.
2014-11-23 15:43:46 +01:00
Torkel Ödegaard
a1d652d578 SinglestatPanel: Added null point handling, and value to text mapping, Closes #1130, Fixes #1120, #951 2014-11-22 15:26:23 +01:00
Torkel Ödegaard
d0e057722b Graphite: added more optional parameters to aliasByNode function definition, #1124 2014-11-21 17:48:49 +01:00
Torkel Ödegaard
f04932aa67 More work on collaborators, and sql store 2014-11-21 16:43:04 +01:00
Torkel Ödegaard
d1be4e2a90 Light theme: tweaks to background color and table highlight rows, Closes #1119 2014-11-21 10:44:37 +01:00
Torkel Ödegaard
3cde783d1d Graphite: Lexer fix, allow equal sign (=) in metric paths, Fixes #1114 2014-11-21 10:25:36 +01:00
Torkel Ödegaard
e933369f56 Singlestat: changed singlestat title to centered position, Closes #1117 2014-11-21 10:17:08 +01:00
Torkel Ödegaard
e109f8d69c Graphite: added timeStack function definition, Closes #1118 2014-11-21 10:11:21 +01:00
Torkel Ödegaard
d198057eaf InfluxDB: fixed issue with using custom/absolute from time to now(), Fixes #1113 2014-11-21 10:06:42 +01:00
Torkel Ödegaard
88c2f18b20 Graphite: fixed aliasSub graphite func definition 2014-11-21 08:24:13 +01:00
Jeff Klukas
a30a604228 Purge timspan variable from scripted templates. 2014-11-20 09:32:19 -06:00
Torkel Ödegaard
4eefa73441 Progress on account and dashboard save/load 2014-11-20 15:19:44 +01:00
Torkel Ödegaard
00b4d233cc Small progress, save search works 2014-11-20 13:02:25 +01:00
Torkel Ödegaard
eb2c078898 Progres on move to sql from rethinkdb 2014-11-20 12:11:07 +01:00
Torkel Ödegaard
4b5eadf7b5 Merge branch 'master' of github.com:torkelo/grafana-private into pro 2014-11-20 09:16:49 +01:00
Torkel Ödegaard
9b68911d00 Made it it compile again 2014-11-20 09:16:28 +01:00
Torkel Ödegaard
62b58d8bb0 Updated scripted dashboard example 2014-11-20 09:09:59 +01:00
Torkel Ödegaard
a5951592f7 Merge branch 'master' of github.com:jklukas/grafana into jklukas-master 2014-11-20 09:08:00 +01:00
Torkel Ödegaard
6392d6514e Graphite: fixed: moving graphite function left/right did not update query, Fixes #1100 2014-11-20 09:00:30 +01:00
Torkel Ödegaard
91d6641326 Graph: fixed issue with shared tooltip when one or more series is hidden, Fixes #1094 2014-11-19 16:01:04 +01:00
Torkel Ödegaard
dd398f73c2 Css tweak to dark theme, mark submenu carets (ie arrows) white, Fixes #1098 2014-11-19 15:41:16 +01:00
Torkel Ödegaard
de10bd4ef6 DrilldownLink: template variables in params property was not interpolated, Fixes #1095 2014-11-19 15:33:00 +01:00
Torkel Ödegaard
56321da9c1 Bug: Fixed position for drilldown link tooltip when dashboard requires scrolling, Fixes #1093 2014-11-19 15:26:14 +01:00
Torkel Ödegaard
d0d1c5ea5f updated changelog 2014-11-19 11:57:00 +01:00
Torkel Ödegaard
e16872c864 Updated angular-dragdrop to fix issue with IE9, Fixes #1087 2014-11-19 11:55:18 +01:00
Jeff Klukas
1e425244d2 Refactor timspan default in scripted examples. 2014-11-18 14:24:55 -06:00
Torkel Ödegaard
0c6618d2f6 Small tweaks 2014-11-18 16:58:26 +01:00
Torkel Ödegaard
a9d7823186 Singlestat: only show thresholds options when coloring option is checked, Fixes #1077 2014-11-18 08:27:43 +01:00
Torkel Ödegaard
6c0f5329aa Graph: improved decimal precision in legend and graph hover when graph ticks use single decimal point, now graph legend and tooltip always use one more decimal precision than axis ticks (if axis ticks has decimals), Fixes #1072 2014-11-17 19:20:27 +01:00
Torkel Ödegaard
a677a4feff Updated changelog with share panel feature, #864, it was missing 2014-11-17 16:13:47 +01:00
Torkel Ödegaard
4f674c8d19 Updated changelog with RC1 release date 2014-11-17 15:21:43 +01:00
Torkel Ödegaard
e197163019 Changed version to 1.9-rc1 2014-11-17 11:19:17 +01:00
Torkel Ödegaard
7ba0099fa9 Panel: fixes to panel menu when in edito/fullscreen mode, Fixes #1069 2014-11-17 09:59:37 +01:00
Torkel Ödegaard
f45797ec4b trying out panel actions buttons 2014-11-17 09:11:54 +01:00
Torkel Ödegaard
02e1ac12b2 InfluxDB: fixed annotations, broken after switch to millisecond resolution, Fixes #1061 2014-11-17 07:09:21 +01:00
Torkel Ödegaard
bde138177d Singlestat: fixed decimal issue when value was 1, Fixes #1066 2014-11-15 10:38:01 +01:00
Torkel Ödegaard
2423f470ef Merge with oss master 2014-11-14 17:56:27 +01:00
Torkel Ödegaard
e5219af481 Merge branch 'master' of github.com:torkelo/grafana-private into pro
Conflicts:
	src/app/components/require.config.js
2014-11-14 17:40:16 +01:00
Torkel Ödegaard
21a4f3cc05 updated 2014-11-14 17:16:40 +01:00
Torkel Ödegaard
a9d9939bdd Merge branch 'pro' of github.com:torkelo/grafana-private into pro 2014-11-14 17:15:44 +01:00
Torkel Ödegaard
41fb2b4cc4 updated 2014-11-14 17:14:34 +01:00
Torkel Ödegaard
526e232c09 Merge branch 'pro' of github.com:torkelo/grafana-private into pro 2014-11-14 17:14:02 +01:00
Torkel Ödegaard
f2ed3d3ff2 Updated 2014-11-14 17:13:44 +01:00
Torkel Ödegaard
f5b1b192a0 Macaron and sqllite 2014-11-14 17:13:33 +01:00
chrono
a77c33d9b7 Added J,W & eV to unit formatting 2014-11-14 14:19:55 +01:00
Torkel Ödegaard
640c558446 Graph: added export graph time series data as csv file feature, accessed from panel menu dropdown, #861 2014-11-14 12:12:09 +01:00
Torkel Ödegaard
c11ce99bb3 SinglestatPanel: another small fix for drilldown link click while fullscreen mode, #1041 2014-11-14 11:41:36 +01:00
Torkel Ödegaard
8ad83b8d58 SinglestatPanel: small fix for drilldown link click while fullscreen mode, #1041 2014-11-14 11:36:20 +01:00
Torkel Ödegaard
873d3d7c4a SinglestatPanel: Added integration with drilldown link feature, if a drilldown link is present the entire singlestat panel will act as a link, with hover tooltip containing the link name, #951, #1041 2014-11-14 09:33:03 +01:00
Torkel Ödegaard
d4adaaaf2b Graphite: annotations stop working after recent change to millisecond resolution, Fixes #1061 2014-11-14 08:19:49 +01:00
Torkel Ödegaard
104493e725 SharePanel: fix for interval variables and auto value, Fixes #1056 2014-11-13 15:23:34 +01:00
Torkel Ödegaard
b172e7afdc SinglestatPanel: mini fix 2014-11-13 15:23:34 +01:00
Torkel Ödegaard
b1efbeb220 Merge pull request #1057 from kaos/master
panelmeta: fix metrics tab title.
2014-11-13 15:06:31 +01:00
Andreas Stenius
f2a6657b72 panelmeta: fix metrics tab title. 2014-11-13 14:29:42 +01:00
Torkel Ödegaard
4eb4974909 Graph: change to current legend value handling, if last value is null, current will pick next to last value, Closes #190 2014-11-12 13:47:06 +01:00
Torkel Ödegaard
3e2c898881 Graph: legend fix for current legend value 2014-11-12 13:40:22 +01:00
Torkel Ödegaard
2fb176a244 Graphite: fix for graphite query editor, when adding functions and the function selection dropdown get push down the selection did not work properly, Fixes #1038 2014-11-12 12:57:22 +01:00
Torkel Ödegaard
53a6a7b305 Annotations: fixed spelling issue in annoation error handling code 2014-11-12 12:41:53 +01:00
Torkel Ödegaard
2045380223 Graph: moved graph and graph tooltip directive into panels/graph folder 2014-11-12 11:58:04 +01:00
Torkel Ödegaard
1c0fc3c924 Graph: small fix to legend sorting, #1030 2014-11-12 10:19:33 +01:00
Torkel Ödegaard
0b966b7a28 Graph: legend sorting while in table mode implemented, panel persisted property, Closes #1030 2014-11-12 10:11:01 +01:00
Torkel Ödegaard
882a477c0f Graph: increase decimal precision in tooltip and legend values when unit scaling is applied, #1043 2014-11-12 09:09:05 +01:00
Torkel Ödegaard
ebcf2c3f68 InfluxDB: Support for sub second resolution graphs, Closes #714, #728, #752 2014-11-12 08:39:04 +01:00
Torkel Ödegaard
54fafb3a76 Graph: fix to typeahead for series overrides, (bug introduced in recent commit), Fixes #1046 2014-11-11 21:09:50 +01:00
Torkel Ödegaard
01bd662046 Graph: legend fix for bug when running optimized build, Fixes #1045 2014-11-11 21:06:01 +01:00
Jo De Boeck
98d934c8a4 Add mbytes and kbytes y_formats
Usefull when input data is stored in kbytes or mbytes
2014-11-11 19:22:22 +02:00
Torkel Ödegaard
9e26d3e85d SinglestatPanel: increased scaled decimal offset by 2 for, improves decimal precision when units gets scaled, #1043, #951 2014-11-11 16:30:20 +01:00
Torkel Ödegaard
17114778b7 Panel: fixed bug introduced in recent commit that caused blank title in optimized build, #1041 2014-11-11 15:00:31 +01:00
Torkel Ödegaard
98037ca0c6 SinglestatPanel: fixed issue when value is zero, #1039 2014-11-11 14:55:23 +01:00
Torkel Ödegaard
4ec59e8211 Tech: cleanup unused angular-strap directives, Closes #1029 2014-11-11 13:57:39 +01:00
Torkel Ödegaard
1e6a5ff8ec Updated changelog with #1041 2014-11-11 13:44:25 +01:00
Torkel Ödegaard
c12d830162 Panel: added search typeahead for dashboard links, #1041 2014-11-11 13:38:34 +01:00
Torkel Ödegaard
a49a9b3b64 Panel: more work on panel links, #1041 2014-11-11 12:51:57 +01:00
Torkel Ödegaard
5da3da5962 PanelLinks: began work on drilldown panel links feature, #1041 2014-11-11 11:48:27 +01:00
Torkel Ödegaard
8bb51d47f8 DashboardViewState: small fix for bug that caused issue for singlestat panel 2014-11-11 08:07:05 +01:00
Torkel Ödegaard
381b9ee7ee Graph: legend css tweaks 2014-11-11 07:51:52 +01:00
Torkel Ödegaard
a301c96c9d SharePanel: fix to share feature, Closes #1035 2014-11-10 16:18:59 +01:00
Torkel Ödegaard
f9c3cdab67 UI: replaced native confirm dialogs with nicer custom ones 2014-11-10 15:01:30 +01:00
Torkel Ödegaard
27ec0d532e began work on custom confirm modal 2014-11-10 10:40:45 +01:00
Torkel Ödegaard
3aa619b617 Panel: fixed duplicate panel, broken after yesterdays panel menu model refactoring 2014-11-09 09:44:16 +01:00
Torkel Ödegaard
ef92272bee Panel: fixed menu position after moving json to new dropdown 2014-11-08 19:28:16 +01:00
Torkel Ödegaard
815ef05daf Graph: refactoring some stuff with legend values 2014-11-08 19:16:22 +01:00
Torkel Ödegaard
2ab19148c1 Graph: toggle legend on/off from panel menu, #941, no keyboard shortcut yet, but could come 2014-11-08 18:12:05 +01:00
Torkel Ödegaard
d12f4a4aee Panels: refactoring panel meta model & menu, will open up panel specific menu actions 2014-11-08 16:27:49 +01:00
Torkel Ödegaard
81b1939f92 Graph: small fix to legend table mode 2014-11-08 11:44:23 +01:00
Torkel Ödegaard
834daeecd0 OpenTSDB: updated change log with templating support PR #917 2014-11-08 11:35:42 +01:00
Torkel Ödegaard
6aa0208316 Updated changelog with #1030 2014-11-07 14:23:18 +01:00
Torkel Ödegaard
aa87d8eb22 Graph: changed style of legend table mode to full width table and with headers, #1030 2014-11-07 14:20:58 +01:00
Torkel Ödegaard
cd21fa7016 Graph: new legend table display style, #1030 2014-11-07 13:57:52 +01:00
Torkel Ödegaard
7ba4f6b93f Singlestat: removed debug console.log 2014-11-07 13:56:28 +01:00
Torkel Ödegaard
e16a51ad06 Singlestat: fixed decimal precision bug, #951 2014-11-07 13:54:19 +01:00
Torkel Ödegaard
6861dc137f Graph: fix for legend show/hide toggle, broken by recent legend rewrite 2014-11-07 13:39:47 +01:00
Torkel Ödegaard
e530e4d4bc Tech: rewrite of how the legend is implement, performance increase, and will make future legend enhancements easier 2014-11-07 12:15:34 +01:00
Torkel Ödegaard
d150bc1e52 Graphite: added mapSeries and reduceSeries functions, Closes #1018 2014-11-07 06:34:47 +01:00
Torkel Ödegaard
cc8961360a Graphite: added maxDataPoints override option and a help section that describes how graphite point consolidation work, Closes #5 2014-11-06 16:25:46 +01:00
Torkel Ödegaard
c0539e483e Added singlestat panel to changelog 2014-11-06 14:10:25 +01:00
Torkel Ödegaard
f0b7099be3 SingleStatPanel: renamed panel to singlestat 2014-11-06 14:07:32 +01:00
Torkel Ödegaard
ee183d4574 SingleStatPanel: some more tweaks and polish 2014-11-06 13:57:16 +01:00
Torkel Ödegaard
fa813024ca SingleStatPanel: various fixes 2014-11-06 12:30:42 +01:00
Torkel Ödegaard
37176fa42d SingleStatPanel: Finnaly solved automatic decimal precision calculation for singlestat panel, #951 2014-11-06 12:17:46 +01:00
Torkel Ödegaard
7ff8931def SingleStatPanel: added font size options for value, prefix and postfix, #951 2014-11-06 10:47:46 +01:00
Torkel Ödegaard
2a962bf8fd Singlestat: progress on singlestat panel 2014-11-06 09:56:50 +01:00
Torkel Ödegaard
bbbcba8b98 Merge branch 'master' into valuepanel 2014-11-06 08:54:01 +01:00
Torkel Ödegaard
ecdcd10612 Graph: Series hide/show toggle changed to be default exclusive, so clicking on a series name will show only that series. (SHIFT or meta)+click will toggle hide/show. Closes #1007 2014-11-03 10:21:16 +01:00
Torkel Ödegaard
10ea140358 MetricEditors: Ability to reorder metric queries in metrics tag, Closes #716, Closes #856 2014-11-03 08:56:13 +01:00
Torkel Ödegaard
74e0309241 Fixes #912, URL parameters are lost when switching to fullscreen/edit mode 2014-11-02 11:56:51 +01:00
Torkel Ödegaard
c88bfbbf82 SingleStatPanel: editor cleanup 2014-11-02 11:36:11 +01:00
Torkel Ödegaard
4edb89eeb9 Merge branch 'summarize-alignToFrom' of github.com:adriensamson/grafana into adriensamson-summarize-alignToFrom 2014-10-30 09:24:27 +01:00
Torkel Ödegaard
cdb4b3cc7d Panel: fix fullscreen/edit view and page refresh when panel is in collapsed/hidden row, Fixes #992 2014-10-29 09:51:44 +01:00
Torkel Ödegaard
ed8dd03fa1 Merge branch 'master' into valuepanel 2014-10-29 09:24:49 +01:00
Torkel Ödegaard
e5bb7f7c2d CustomDatasource: fixed build optimization issue with custom datasources, Fixes #994 2014-10-28 19:00:46 +01:00
Torkel Ödegaard
a7b0f6dc9f ScriptedDashboard: datasource services are now available in scripted dashboards, you can query datasource for metric keys, generate dashboards, and even save them in a scripted dashboard (see scripted_gen_and_save.js for example), Closes #991 2014-10-28 16:16:52 +01:00
Torkel Ödegaard
c42986c07d Merge branch 'services_in_scripted_dashboard' 2014-10-28 16:14:41 +01:00
Torkel Ödegaard
a982dd1765 ScriptedDashboard: using grafana services in scripted dashboard 2014-10-28 16:14:28 +01:00
Torkel Ödegaard
c3900398fc Merge pull request #917 from mchataigner/master
adding templating in opentsdb graphs
2014-10-28 15:39:14 +01:00
Torkel Ödegaard
4b79a5e9da OpenTSDB: merged PR #930 adding counter max and counter reset options to OpenTSDB query editor 2014-10-28 12:41:17 +01:00
Torkel Ödegaard
eed2feea97 Merge branch 'opentsdb-counterMax' of github.com:rsimiciuc/grafana into rsimiciuc-opentsdb-counterMax 2014-10-28 12:36:15 +01:00
Torkel Ödegaard
60a2d9f624 Dashboard: fix for collapsed rows became invisible when hide controls was enabled, Fixes #987 2014-10-27 10:42:13 +01:00
Torkel Ödegaard
3cd33b6ffc Tech: added cache busting for requirejs fetches, will only affect config.js for optimized builds, should solve user issues where browsers cache config.js which causes initial confusing setup/config issues. 2014-10-26 08:45:42 +01:00
Torkel Ödegaard
e3942b3438 Graph: multi series tooltip fix for long series names, and metric value row alignment, Fixes #983, #984 2014-10-25 12:01:31 +02:00
Torkel Ödegaard
0bf37b8c00 Merge pull request #981 from swoop-inc/mb_value_update_bug
When get_data fails the legend should be cleared
2014-10-24 21:10:07 +02:00
Torkel Ödegaard
0e5dbf3889 Merge pull request #980 from maxstepanov/patch-1
Replace all $interval occurrences in query string
2014-10-24 21:07:38 +02:00
Torkel Ödegaard
785f96aabe Merge pull request #975 from swoop-inc/mb_support_influx_regex_merge
Add support for regex based series merging in InfluxDB
2014-10-24 21:01:52 +02:00
Mark Bell
5cec936128 When get_data fails the legend should be cleared 2014-10-24 14:51:45 -04:00
Max Stepanov
02861142cb Replace all $interval occurrences in query string
because template
2014-10-24 20:06:39 +03:00
Torkel Ödegaard
1cfc4d2f31 ScriptedDashboard: bugfix for scripted dashboards and collapsed rows, Fixes #965 2014-10-24 11:48:08 +02:00
Mark Bell
08e816a539 Add support for regex based series merging in InfluxDB 2014-10-23 10:35:57 -04:00
Torkel Ödegaard
272cf64aac SinglsStatPanel: more work on sparkline option for single stat panel 2014-10-23 13:44:15 +02:00
Torkel Ödegaard
ed57a4099b Merge branch 'master' into valuepanel 2014-10-23 13:35:54 +02:00
Torkel Ödegaard
79c5d48a3c Timepicker: Fix for Zoom out top menu link still visible when timepicker was disabled, Fixes #963 2014-10-23 12:36:25 +02:00
Adrien Samson
6c70122e55 Add alignToFrom param to summarize 2014-10-22 11:31:41 +02:00
Torkel Ödegaard
6c83699e6f Panel: css fix for panel fullscreen/edit mode for latest chrome 38 and Firefox 33, #954 2014-10-20 12:14:58 -04:00
Torkel Ödegaard
ff254ce08d Help: fix for help modal shortcut, and added missing shortcut, #952 2014-10-20 11:33:07 -04:00
Torkel Ödegaard
8a80ea26b8 Graph: fix for series override controller unit test 2014-10-20 10:10:18 -04:00
Torkel Ödegaard
b85fe62389 Graph: series override dropdown menu select did not work after recent commit that added typeahead to this dropdown 2014-10-20 10:06:34 -04:00
Torkel Ödegaard
31a4d9204c SingleStatPanel: Added graph to single stat panel, #951 2014-10-19 19:36:59 -04:00
Torkel Ödegaard
69fdfd5cb3 Merge branch 'master' into valuepanel 2014-10-19 12:34:01 -04:00
Torkel Ödegaard
16e7980982 Help: added help modal, accessed by shortcut '?', the help modal only contains a list of all shortcuts right now but will be extended in the future, #952 2014-10-19 12:30:41 -04:00
Torkel Ödegaard
e3e08cf8e7 Graph: fix for second y axis tick unit labels wrapping on the next line, Fixes #505 2014-10-18 13:31:15 -04:00
Torkel Ödegaard
cae6626b06 StatsPanel: small change to stats panel, #951 2014-10-17 10:38:15 -04:00
Torkel Ödegaard
956d93e871 StatsPanel: fine tuning colors 2014-10-17 10:36:04 -04:00
Torkel Ödegaard
7c4d1b7b01 StatsPanel: made big values template based 2014-10-16 13:44:52 -04:00
Torkel Ödegaard
9866e0851b Graph: single series tooltip and unit format change fix, Closes #946 2014-10-16 11:21:56 -04:00
Torkel Ödegaard
0a97a2435b StatsPanel: more progress 2014-10-16 11:16:20 -04:00
Torkel Ödegaard
5c80f03eae StatsPanel: small progress on stats panel 2014-10-15 18:16:04 -04:00
Torkel Ödegaard
dd03a4b011 Dashboard: fix for fullscreen mode and small gap sometimes showing the underlying dashboard 2014-10-15 17:37:08 -04:00
Torkel Ödegaard
6cd1bc32fe StatsPanel: more work on stats panel 2014-10-15 17:29:47 -04:00
Torkel Ödegaard
dd0193a9a8 Dashboard: removed wip stats panel from settings.js, accidental commit 2014-10-15 15:48:57 -04:00
Torkel Ödegaard
123faa6f8e Merge branch 'master' into valuepanel 2014-10-15 15:48:09 -04:00
Torkel Ödegaard
f743288ce0 Graph: fix for legends on the side and graph dimensions adaptation 2014-10-15 15:47:59 -04:00
Torkel Ödegaard
a1d764bd26 Merge branch 'master' into valuepanel
Conflicts:
	src/app/components/settings.js
2014-10-15 15:41:58 -04:00
Torkel Ödegaard
61f6bd2c80 Graph: added typehead dropdown menu combination for the series override selection 2014-10-15 14:13:53 -04:00
Torkel Ödegaard
fe620d8e44 Graph: fill below to series override option not automatically adds lines=false, as overrides, if you want lines just for the fill below series just remove the overrides, #940 2014-10-15 11:07:51 -04:00
Torkel Ödegaard
22db28d3e7 Graph: New series style override option 'Fill below to', useful to visualize max & min as shadow for the mean, #940 2014-10-15 10:55:46 -04:00
Torkel Ödegaard
1330488e13 Panel: plugins panels can now reside outsude the app/panels directory, added example plugin panel 2014-10-14 16:57:33 -04:00
Torkel Ödegaard
22297be3cf Merge branch 'master' into valuepanel 2014-10-13 12:30:34 -04:00
Raul Simiciuc
29d7d6994a added reset value 2014-10-13 13:43:25 +01:00
Raul Simiciuc
87e8162a2d fixed identation 2014-10-13 13:07:46 +01:00
Raul Simiciuc
38b71bf386 adding counterMax option to opentsdb 2014-10-13 12:36:26 +01:00
Torkel Ödegaard
920689b80e InfluxDB: series lookup & typeahead is now handled by influxdb list series regex queries, Closes #888 2014-10-12 12:47:50 -04:00
Torkel Ödegaard
e9c7523646 Graphite: added second optional parameter to averageSeriesWithWildcards, Closes #926 2014-10-11 06:24:44 -04:00
Torkel Ödegaard
88bbc720ca Graph: removed console logs 2014-10-11 06:08:33 -04:00
Torkel Ödegaard
1bf1469c80 Merge branch 'master' of github.com:grafana/grafana 2014-10-10 13:37:43 -04:00
Torkel Ödegaard
c74eda20dc Graph: fix for legend values min & max, avg & current when series only has null values, Closes #923 2014-10-10 13:37:33 -04:00
Torkel Ödegaard
db0a5bd537 Graph: fix for legend values min & max, avg & current when series only has null values, Closes #923 2014-10-10 10:45:34 -04:00
Torkel Ödegaard
c6cb01aa3b Graph: series tooltip length check 2014-10-10 10:05:12 -04:00
Torkel Ödegaard
7463f91878 Tech: removed jquery-ui and jquiery-ui-angular-drag-drop, replaced with native drag drop for angular, saved ~50kb in js libs, much cleaner & simpler usage, Also changed some behavior for drag drop, now panels are replaced when droped on (switch places), Closes #920 2014-10-09 20:30:23 -04:00
Mathieu Chataigner
482b31298f fixing unused var 2014-10-09 19:12:56 +02:00
Torkel Ödegaard
ce46ca2f39 Search: fixed bug introduced in recent PR #900, related to comment on #909 2014-10-09 12:31:51 -04:00
Mathieu Chataigner
de00d18a7e adding templating in opentsdb graphs 2014-10-09 16:59:29 +02:00
Torkel Ödegaard
b0cf0c558d Merge branch 'master' into valuepanel 2014-10-09 09:55:49 -04:00
Torkel Ödegaard
920e5c93e1 Graph: tooltip fix for single series tooltip and right floated value being pushed down 2014-10-08 17:00:07 -04:00
Torkel Ödegaard
0aae78c6bd Graph: fix for bars not displaying, caused by change in recent commit, added unit test so it does not happen again 2014-10-08 16:24:58 -04:00
Torkel Ödegaard
7fb048f423 Began work on experimental new stats panel 2014-10-08 11:43:51 -04:00
Torkel Ödegaard
e86207bb28 Fixed default panel title when creating new panel, tweaks to panel height calculation, Closes #910 2014-10-08 06:44:46 -04:00
Torkel Ödegaard
d7cd2b970e OAuth remake 2014-10-07 17:56:37 -04:00
Torkel Ödegaard
450d242d5f working on oauth 2014-10-07 15:54:38 -04:00
Torkel Ödegaard
2783196547 updated 2014-10-07 13:44:20 -04:00
Torkel Ödegaard
e84f06b503 more macaroon stuff 2014-10-07 11:53:25 -04:00
Torkel Ödegaard
75d60ccb69 Graphite: added perSecond function to the func def list 2014-10-07 06:40:45 -04:00
Torkel Ödegaard
9245cd6aae Merge branch 'inline_styles' of github.com:mikhailov/grafana into mikhailov-inline_styles 2014-10-07 06:32:13 -04:00
Torkel Ödegaard
d8183b60c3 Merge branch 'mikhailov-patch-1' 2014-10-07 06:31:05 -04:00
Torkel Ödegaard
a24272690d Merge branch 'patch-1' of github.com:mikhailov/grafana into mikhailov-patch-1 2014-10-07 06:30:53 -04:00
Torkel Ödegaard
40b088d6a2 Merge pull request #900 from mikhailov/patch-2
Speed search result parsing
2014-10-07 06:19:52 -04:00
Torkel Ödegaard
f1125d64de Updated default max search results to 100, #909 2014-10-07 06:17:33 -04:00
Torkel Ödegaard
0cba818364 Graph: legend and digest phase fix 2014-10-06 12:37:51 -04:00
Torkel Ödegaard
4285c751b3 Graph: fixed value formating for tooltip, need original data. flotcharts copys the data, so changes to value formats func after plot call does not affect the plot.getData() series 2014-10-06 12:17:48 -04:00
Torkel Ödegaard
1b0cddfa72 Graph: Tooltip refactoring for testability 2014-10-06 11:34:51 -04:00
Torkel Ödegaard
231a599f09 legend html markup cleanup 2014-10-06 11:34:51 -04:00
Torkel Ödegaard
7ffc4d388a Merge pull request #895 from ngmlabs/master
second parameter of groupByNode() should be 0 indexed
2014-10-06 09:50:19 -04:00
Torkel Ödegaard
1f24171238 Merge pull request #902 from toni-moreno/fix_multiple_highlight_points
Fix #901: correct positioning for multiple highlighted stacked and staircase points
2014-10-06 09:27:33 -04:00
toni-moreno
24917a6df5 correct positioning for multiple highlighted stacked and staircase points, fix to #901 2014-10-06 06:22:55 +02:00
Anatoly Mikhailov
67fde17209 Speed searching up a bit
Reuse ElasticSearch hits length via hits.total and cache it rahter than calculation length every iteration.
2014-10-05 23:24:41 +01:00
Anatoly Mikhailov
6abad666db Debounce/Throttling Searching event
New backend call to each keydown may hit the back-end performance.
500ms is reasonable delay to avoid too many requests while user is
typing a search query
2014-10-05 20:54:53 +01:00
Torkel Ödegaard
222319d924 macaron transition progress 2014-10-05 21:13:07 +02:00
mikhailov
2d3f396571 Extract repetitive CSS inline styles
Inline styles slow down rendering proportionally to containers number
2014-10-05 18:30:22 +01:00
Torkel Ödegaard
201e1d3e6d Macaron rewrite 2014-10-05 16:50:04 +02:00
Torkel Ödegaard
2c72831be1 before macaron 2014-10-05 15:34:24 +02:00
Torkel Ödegaard
a4204880e8 started work on new arch 2014-10-04 13:33:20 +02:00
George Negoita
51bcbdac75 second parameter of groupByNode() is 0 indexed 2014-10-04 02:33:36 +03:00
Torkel Ödegaard
5d120de70e Filtered logging and url query helper 2014-10-03 09:03:16 +02:00
Torkel Ödegaard
e63889d5c4 Css fix for metrics tab, help boxes did extend page height so could not scroll if they extended below screen, #891 2014-10-03 07:31:27 +02:00
Torkel Ödegaard
fe6a7c58bf Fixed issue casued by recent angular upgrade and stateful filter, casued template vars in graph titles no update properly, angular was not updated in 1.8.1 so this does affect any released version, Closes #892 2014-10-02 21:48:00 +02:00
Torkel Ödegaard
5f1b4e6183 added ldap dev docker file 2014-10-02 13:42:25 +02:00
Torkel Ödegaard
1e81f8ecfc Merge branch 'master' of github.com:torkelo/grafana-private into pro 2014-10-02 12:26:20 +02:00
Torkel Ödegaard
dac3cb15c4 Merge branch 'v1.8.x' 2014-10-02 12:17:37 +02:00
Torkel Ödegaard
ca654ccaf7 fixed stupid unit test mistake 2014-10-02 12:17:10 +02:00
Torkel Ödegaard
30512b7032 Merge fix from 'v1.8.x' branch
Conflicts:
	CHANGELOG.md
2014-10-02 12:15:21 +02:00
Torkel Ödegaard
bc8fd62cff Dashboard: fix for dashboard schema upgrade during load, ensure that annotation and templating object as a list array, Closes #890 2014-10-02 12:13:18 +02:00
Torkel Ödegaard
a9a51ee3c6 Fix to new checkboxes in features toggles tab 2014-10-02 11:54:06 +02:00
Torkel Ödegaard
28c5fc48ee updated sharePanel with width & height 2014-10-02 11:18:26 +02:00
Torkel Ödegaard
2d2da7c881 Small tweak to shared tooltip edit option in Display styles tab 2014-10-02 10:55:08 +02:00
Torkel Ödegaard
d22d8c4905 Added grafana logo to repo instead of fetching it from grafana.org, Fixes #881 2014-10-02 10:24:18 +02:00
Torkel Ödegaard
bcdc8eafa6 Updated gitter badge 2014-10-02 10:13:23 +02:00
Torkel Ödegaard
9cf6ace979 Updated gitter badge 2014-10-02 10:09:16 +02:00
Torkel Ödegaard
eef063cec2 Merge pull request #889 from gitter-badger/gitter-badge
Add a Gitter chat badge to README.md
2014-10-02 10:05:01 +02:00
The Gitter Badger
8b9bdf9054 Added Gitter badge 2014-10-02 07:59:43 +00:00
Torkel Ödegaard
05f9e5eef1 rendering 2014-10-01 21:07:58 +02:00
Torkel Ödegaard
eb28e63c08 updated 2014-10-01 20:02:42 +02:00
Torkel Ödegaard
1c7b898b01 Dashboard: show error when importing dashboard json file with broken/incorrect json syntax, Closes #878 2014-10-01 13:56:57 +02:00
Torkel Ödegaard
7ad18da08e update to test helper 2014-10-01 13:49:36 +02:00
Torkel Ödegaard
5530915b49 Updated AngularJS from 1.3-beta-17 to 1.3-RC3 2014-10-01 13:44:45 +02:00
Torkel Ödegaard
4a73e2d0e9 Solo panel and phantom rendering work 2014-10-01 13:20:30 +02:00
Torkel Ödegaard
b499bdea3b working on panel rendering 2014-10-01 11:37:04 +02:00
Torkel Ödegaard
de1de852fc worked on solo panel 2014-10-01 11:27:58 +02:00
Torkel Ödegaard
77f380c94b Graph: shared tooltip improvements, info tooltip when point counts are not the same, #850 2014-10-01 10:30:24 +02:00
Torkel Ödegaard
c34d2f91cc Merge branch 'master' of github.com:torkelo/grafana-private into pro 2014-10-01 09:47:44 +02:00
Torkel Ödegaard
ee42ea5f3b merged with master 2014-10-01 09:47:32 +02:00
Torkel Ödegaard
c79ab84fdf More fixes related to shared crosshair #880 2014-10-01 09:42:42 +02:00
Torkel Ödegaard
d77448d84e Fixed unit tests for grafanaGraph component 2014-10-01 09:10:49 +02:00
Torkel Ödegaard
8fc5a2785f Refactoring and fixes for PR #880 2014-10-01 09:08:11 +02:00
Torkel Ödegaard
27da2b026f Merge branch 'add_shared_croshair_to_dashboards' of github.com:toni-moreno/grafana into toni-moreno-add_shared_croshair_to_dashboards 2014-10-01 08:00:20 +02:00
Torkel Ödegaard
2e9cc2a74e Fix for SharePanelCtrl-specs and travis-ci timezone issue 2014-10-01 07:58:31 +02:00
toni-moreno
ffd370176d fix tooltip test expecting for stacked data 2014-10-01 07:15:20 +02:00
toni-moreno
44f2a375f6 Added shared crosshair to dashboards to track better all graphs, and little Fix for #884 2014-10-01 07:03:59 +02:00
Torkel Ödegaard
05cb97819c Updated changelog 2014-09-30 18:21:19 +02:00
Torkel Ödegaard
282c834d9f updated package.json 2014-09-30 17:58:02 +02:00
Torkel Ödegaard
4a6ff9e2aa Merge branch 'v1.8.x' 2014-09-30 17:57:30 +02:00
Torkel Ödegaard
ce972d4f19 Graph: css & scroll fix for dropdown menus in graph edit mode, Closes #855 2014-09-30 17:56:43 +02:00
Torkel Ödegaard
b250d10320 Trying to fox unit tests for sharePanelCtrl 2014-09-30 17:55:07 +02:00
Torkel Ödegaard
8a2541c220 Merge branch 'master' of github.com:torkelo/grafana-private into pro 2014-09-30 15:35:20 +02:00
Torkel Ödegaard
6991e5f3ef updated 2014-09-30 15:34:31 +02:00
Torkel Ödegaard
f63706d118 Small update to share panel 2014-09-30 15:31:18 +02:00
Torkel Ödegaard
c41aa64719 ShareModal: Added template variables to share url, and an option for it, #864 2014-09-30 15:19:48 +02:00
Torkel Ödegaard
285d246c65 PanelMenu: fixed interpolate template vars for new panel title/menu 2014-09-30 14:48:36 +02:00
Torkel Ödegaard
2c85205259 SharePanelModal: working on share feature, #864 2014-09-30 14:42:59 +02:00
Torkel Ödegaard
2d866b9298 Updated changelog with the new panel menu, Closes #770 2014-09-30 10:49:59 +02:00
Torkel Ödegaard
7a7629acf7 Panel-menu: small tweeks to css for cursor types 2014-09-30 10:43:13 +02:00
Torkel Ödegaard
debf820037 New checkbox change is complete 2014-09-30 10:27:56 +02:00
Torkel Ödegaard
f908ae8c40 added checkbox image for white theme 2014-09-30 09:50:01 +02:00
Torkel Ödegaard
022cbdda31 Merge branch 'master' into panel_edit_menu_poc 2014-09-30 09:25:19 +02:00
Torkel Ödegaard
ae2523aa59 Merge branch 'v1.8.x' 2014-09-30 09:23:07 +02:00
Torkel Ödegaard
bf361d2b02 Updated package.json version and latest.json, preparation for 1.8.1 release 2014-09-30 09:03:14 +02:00
Torkel Ödegaard
64f3303711 InfluxDB: save dashboard issue, another fix for #859 2014-09-30 09:02:25 +02:00
Torkel Ödegaard
06f382c454 Merge branch 'master' of github.com:grafana/grafana 2014-09-29 16:59:54 +02:00
Torkel Ödegaard
5f164d99ac Updated changelog with merged PR #850, shared multi series graph tooltip & crosshair 2014-09-29 16:59:17 +02:00
Torkel Ödegaard
2473ae3b47 Graph: shared multi series tooltip, refactoring PR #850 2014-09-29 16:57:05 +02:00
Torkel Ödegaard
3fb457ccd1 Merge branch 'master' into toni-moreno-add_shared_tooltips_to_graphs 2014-09-29 14:25:25 +02:00
toni-moreno
51333c9eda improved tooltip styles, add multiple highlight points, and changed highligth size when graph plotted without points. 2014-09-29 12:48:08 +02:00
Torkel Ödegaard
1aaf3961ff Merge pull request #867 from tobym/patch-1
Fix typo
2014-09-29 12:43:48 +02:00
Torkel Ödegaard
af4f3f62e9 Merged yaxis_precision branch, #877, updated changelog 2014-09-29 12:38:52 +02:00
Torkel Ödegaard
cc31a12b8c Smart decimal precision when using scaled unit format, Closes #877 2014-09-29 12:29:53 +02:00
Torkel Ödegaard
bc9989f9be replaced checkbox options with the new editor-opt-bool directive 2014-09-27 10:47:48 +02:00
toni-moreno
7f33bec71c fixing the previous fix, now working fine 2014-09-25 15:45:18 +02:00
toni-moreno
3ea94c3484 little fix when searching x index time 2014-09-25 06:35:49 +02:00
Toby Matejovsky
68adaea128 Fix typo 2014-09-24 19:01:23 -04:00
Torkel Ödegaard
4997068a0d Added directive element for the new checkboxes 2014-09-24 19:10:00 +02:00
Torkel Ödegaard
4c59ec815e work on share panel view, and better look for checkbox 2014-09-24 18:55:55 +02:00
Torkel Ödegaard
440ea666d9 more work on share panel, #864 2014-09-24 17:15:58 +02:00
Torkel Ödegaard
6f1a6d5a56 Changed name of emitAppEvent to just appEvent 2014-09-24 16:26:39 +02:00
Torkel Ödegaard
69e80fd11c working on share feature, and refactorings 2014-09-24 16:20:55 +02:00
Torkel Ödegaard
bef8cc2d70 Merge branch 'master' into panel_edit_menu_poc 2014-09-24 14:00:55 +02:00
Torkel Ödegaard
eaa899e9cf Small fix to fullscreen mode where scrolling would scroll the background dashboard & page header 2014-09-24 14:00:44 +02:00
Torkel Ödegaard
743c95d0f9 small fix to panel menu positioning 2014-09-24 12:45:03 +02:00
Torkel Ödegaard
a08cb52ad9 tweaks to new panel menu, now how top area of panel is clickable, and if no title a 5px high area can be clicked, this will enable panels without title which is something I have wanted 2014-09-24 12:41:55 +02:00
Torkel Ödegaard
b9604bf3bc Merge branch 'master' into panel_edit_menu_poc 2014-09-24 12:23:04 +02:00
Torkel Ödegaard
978a345ad8 Dashboard: When deleting dashboard show dashboard title in confirmation popup, Closes #860 2014-09-24 12:20:27 +02:00
Torkel Ödegaard
d5ffe6acef White theme: Fixes for hidden series legend text and disabled annotations color, Closes #852 2014-09-24 12:14:20 +02:00
Torkel Ödegaard
622c1a1dad small tweak to new panel edit menu 2014-09-24 11:58:02 +02:00
Torkel Ödegaard
79fea549ef Merge branch 'master' into panel_edit_menu_poc 2014-09-24 11:41:25 +02:00
Torkel Ödegaard
bce6e75cfa InfluxDB: Fix for bug when saving dashboard where title is the same as slugified url id, Fixes #859 2014-09-24 11:35:08 +02:00
Torkel Ödegaard
34f36fff5c small fix for graphite-web import 2014-09-24 11:17:34 +02:00
Torkel Ödegaard
f4e24038fe Import: Fixes to import from json file and import from graphite. Issues was lingering state from previous dashboard. Closes #840, Closes #853 2014-09-24 10:51:20 +02:00
Torkel Ödegaard
81747e1623 Annotations: Fix for annotations not reloaded when switching between 2 dashboards with annotations, Fixes #851 2014-09-24 09:03:04 +02:00
Torkel Ödegaard
d6f1c379c0 fixed text editor & scope issue 2014-09-23 22:30:01 +02:00
Torkel Ödegaard
6794260e3f Lots of progress on new panel edit menu, very tricky to get this right but think I am getting close to something that is good and will work long term 2014-09-23 22:10:10 +02:00
Torkel Ödegaard
1be840f19d More wort on panel edit menu 2014-09-23 16:11:31 +02:00
toni-moreno
f59bb6461a added shared tooltips to graphs 2014-09-23 13:51:59 +02:00
Torkel Ödegaard
bd3bae3af0 another attempt at improving panel edit menu 2014-09-23 10:52:31 +02:00
Torkel Ödegaard
0fbace7285 Row: fix for row editor and scroll pos, Fixes #846 2014-09-23 08:32:04 +02:00
Torkel Ödegaard
af8fec941c Graph: Fix for series draw order not being the same after hiding/unhiding series, Fixes #847 2014-09-23 08:18:59 +02:00
Torkel Ödegaard
139791b0d8 Merge branch 'master' into panel_edit_menu_poc 2014-09-22 18:11:52 +02:00
Torkel Ödegaard
7fe76d32d0 updated latest.json 2014-09-22 13:06:52 +02:00
Torkel Ödegaard
352ad3385a Updated changelog and package.json to new version 1.8.0 2014-09-22 12:59:21 +02:00
Torkel Ödegaard
010baad532 Dashboard: fixed init of editable setting, #837 2014-09-22 12:54:02 +02:00
Torkel Ödegaard
69d2a8f4fa style change to login page 2014-09-22 12:31:38 +02:00
Torkel Ödegaard
3bba8b2c26 Github oauth login works 2014-09-22 11:39:40 +02:00
Torkel Ödegaard
d584076b93 added github oauth sign in 2014-09-22 11:39:18 +02:00
Torkel Ödegaard
b0b77d667c added gravatar 2014-09-22 10:46:56 +02:00
Torkel Ödegaard
071ac0dc85 added gravatar 2014-09-22 10:46:38 +02:00
Torkel Ödegaard
ed8f5dbd22 Lots of progress on account management 2014-09-21 15:02:19 +02:00
Torkel Ödegaard
5dfeddf583 Lots of progress on account management 2014-09-21 15:02:06 +02:00
Torkel Ödegaard
cd9306df45 Lots of progress on account management 2014-09-21 15:01:59 +02:00
Torkel Ödegaard
e0dc530e94 Merge branch 'master' of github.com:torkelo/grafana-private into pro 2014-09-21 08:25:54 +02:00
Torkel Ödegaard
af52b20c4a Merge branch 'master' of github.com:grafana/grafana 2014-09-21 08:21:31 +02:00
Torkel Ödegaard
e82d171041 Dashboard: when opening search or dashboard settings, click the icon again will now hide the view, Closes #836 2014-09-21 08:19:41 +02:00
Torkel Ödegaard
19a35673fa updated 2014-09-20 16:55:54 +02:00
Torkel Ödegaard
639a44d996 accounts progress 2014-09-20 16:55:38 +02:00
Torkel Ödegaard
4f261389db changed placement of color selector popup 2014-09-20 16:55:02 +02:00
Torkel Ödegaard
6003fee33f Merge branch 'master' into panel_edit_menu_poc 2014-09-20 13:37:02 +02:00
Torkel Ödegaard
b56c3eb035 Changed color for warning alert 2014-09-20 13:32:26 +02:00
Torkel Ödegaard
015c929bd7 more account stuff 2014-09-20 13:24:06 +02:00
Torkel Ödegaard
992efda7f6 Account stuff 2014-09-20 12:14:19 +02:00
Torkel Ödegaard
32036d017e Account stuff 2014-09-20 12:14:03 +02:00
Torkel Ödegaard
40ff57d8c4 Account stuff 2014-09-20 12:13:46 +02:00
Torkel Ödegaard
cdabe50320 Merge branch 'master' of github.com:torkelo/grafana-pro
Conflicts:
	grafana
2014-09-20 08:58:17 +02:00
Torkel Ödegaard
c62ee78cba Merge branch 'pro' of github.com:torkelo/grafana-private into pro
Conflicts:
	src/css/less/grafana.less
	src/test/test-main.js
2014-09-20 08:57:40 +02:00
Torkel Ödegaard
a19a2c70ab Fixed spelling in config.sample.js 2014-09-20 08:33:16 +02:00
Torkel Ödegaard
40a491a80b Annotations: Elasticsearch annotation and field mapping fixes, small changes for PR #830 2014-09-20 08:30:59 +02:00
Torkel Ödegaard
a9a06ad51d Working on collaborators 2014-09-19 17:37:18 +02:00
Torkel Ödegaard
c65b7d1591 updated 2014-09-19 17:36:52 +02:00
Torkel Ödegaard
c287405471 Merge branch 'master' of github.com:torkelo/grafana-private into pro 2014-09-19 17:16:34 +02:00
Gregory Becker
06ec91c899 Give maximum width & height constraint to tooltip boxes
Extreme values that go beyond the screen resolution are very likely to be misplaced. This is a simple workaround. A better solution would be to improve the code placing the tooltip and make it handle tooltips containing more content than they can safely display.
2014-09-19 14:16:53 +01:00
Gregory Becker
10f9022d7c Support fields from nested objects pulled from Elasticsearch 2014-09-19 14:11:09 +01:00
Torkel Ödegaard
e78c48620f Trying to improve yaxis precision 2014-09-19 13:24:15 +02:00
Torkel Ödegaard
563dd898c1 Graph: fix for downscaling y-axis format, never downscale when value is zero, Fixes #826 2014-09-19 12:16:00 +02:00
Torkel Ödegaard
a97bcc3ca7 Elasticsearch: fix for issue when saving dashboard with title equal to slugified url, would cause the backward compatible fix to delete it, Closes #828 2014-09-19 10:37:43 +02:00
Torkel Ödegaard
fa31fc046e Merge pull request #823 from beevee/elasticsearch_basic_auth
enable withCredentials in elasticsearch basic auth
2014-09-18 15:54:58 +02:00
Torkel Ödegaard
a68a179c1e Small improvements to dashboard alerts, less intrusive, do not push down page anymore, Closes #822 2014-09-18 15:07:49 +02:00
Alexey Kirpichnikov
77b0d36b55 enable withCredentials in elasticsearch basic auth 2014-09-18 17:50:59 +06:00
Torkel Ödegaard
1705734435 updated 2014-09-18 12:04:22 +02:00
Torkel Ödegaard
e5fd35db34 small progress on adding collaborators 2014-09-18 12:04:03 +02:00
Torkel Ödegaard
158b708eac Small progress on adding collaborator 2014-09-18 12:03:46 +02:00
Torkel Ödegaard
aa47eeffb2 added default default support 2014-09-18 10:16:25 +02:00
Torkel Ödegaard
df00ac736f Merge branch 'master' of github.com:torkelo/grafana-private into pro 2014-09-18 09:38:32 +02:00
Torkel Ödegaard
f2a6fc4d5a Merge pull request #808 from lento/multiple-stacks
add override options to allow multiple stacks
2014-09-18 09:36:48 +02:00
Torkel Ödegaard
c9501d1119 Merge pull request #820 from jozog/master
Handle 'group' graphite method
2014-09-18 09:35:37 +02:00
Torkel Ödegaard
323ff3d491 Merge pull request #821 from linkslice/master
Update playlist.html
2014-09-18 09:35:13 +02:00
Bryan Irvine
98b3126e32 Update playlist.html 2014-09-17 11:04:06 -07:00
Julien Ozog
88ea524f44 Handle 'group' graphite method 2014-09-17 17:12:43 +02:00
Torkel Ödegaard
a0ab9113fc Graph: added percent y-axis format, Closes #818 2014-09-17 15:39:45 +02:00
Torkel Ödegaard
31398718e5 Workin on login user state 2014-09-17 15:25:19 +02:00
Torkel Ödegaard
4dfe8b6f69 Working on login user name state 2014-09-17 15:25:07 +02:00
Torkel Ödegaard
6dae8f44b9 Small fix for favicon 2014-09-17 13:58:32 +02:00
Torkel Ödegaard
4f798cfe56 Merge branch 'master' of github.com:torkelo/grafana-private into pro 2014-09-17 13:35:19 +02:00
Torkel Ödegaard
d8ea970f18 Added support for delete dashboard 2014-09-17 13:35:01 +02:00
Torkel Ödegaard
ecafc7bf8f Added support for delete dashboard 2014-09-17 13:34:42 +02:00
Torkel Ödegaard
bba3f3000f Search: remove dashboard from search result after dashboard deletion, Closes #753 2014-09-17 13:00:35 +02:00
Torkel Ödegaard
4b382e0faf Merge branch 'master' of github.com:torkelo/grafana-private into pro
Conflicts:
	src/css/less/grafana.less
	src/test/test-main.js
2014-09-17 09:54:40 +02:00
Torkel Ödegaard
2380a26987 updated 2014-09-17 09:49:28 +02:00
Torkel Ödegaard
d40e21a7e0 Chrome: Fix for display issue in chrome beta & chrome canary when entering edit mode, Closes #795 2014-09-17 09:29:51 +02:00
Torkel Ödegaard
94d2ae2a6a Merge branch 'master' of github.com:grafana/grafana 2014-09-17 09:06:37 +02:00
Torkel Ödegaard
3099198e47 Fixed default dashboard grafana logo when using https 2014-09-17 09:03:34 +02:00
Torkel Ödegaard
48e9b5f4be Merge pull request #810 from marcusoftnet/“AddingFavIcon”
Added a favicon. This will resolve issue #796
2014-09-16 13:38:32 +02:00
Torkel Ödegaard
430e2e439b Small fix to schemaUpgrade, Closes #807 2014-09-16 13:32:27 +02:00
Torkel Ödegaard
81a21c03b2 Merge branch 'favicon' 2014-09-16 13:20:42 +02:00
Torkel Odegaard
064a97e734 added favicon, Closes #796 2014-09-16 13:19:52 +02:00
Marcus Hammarberg
5e9ed95684 Added a favicon. This will resolve issue #796 2014-09-16 17:45:43 +07:00
Torkel Ödegaard
017d5617a5 Merge pull request #809 from alxrem/master
fix typos
2014-09-16 11:12:48 +02:00
Alexey Remizov
26bb2e0193 fix typos 2014-09-16 13:08:28 +04:00
Torkel Odegaard
ff91430fcc added favicons 2014-09-16 08:01:18 +02:00
Lorenzo Pierfederici
32a41a8422 add override options to allow multiple stacks 2014-09-15 18:12:20 -07:00
Torkel Ödegaard
8b93e20a0b Merge pull request #806 from starshayayord/master
Disable annoying Google Translate plugin
2014-09-15 19:15:57 +02:00
starshayayord
92bec31ccb Update index.html
disable google translate plugin
2014-09-15 18:51:58 +06:00
Torkel Ödegaard
f133a9de79 Merge branch 'master' of github.com:torkelo/grafana-pro
Conflicts:
	grafana
2014-09-13 18:36:40 +02:00
Torkel Ödegaard
9b2476451e Merge branch 'pro' of github.com:torkelo/grafana-private into pro
Conflicts:
	src/test/test-main.js
2014-09-13 18:36:17 +02:00
Torkel Ödegaard
b876d193c4 updated 2014-09-13 18:33:52 +02:00
Torkel Ödegaard
3944c37627 patches from master 2014-09-13 18:33:35 +02:00
Torkel Ödegaard
14080d1531 Merge remote-tracking branch 'origin/master' into pro
Conflicts:
	src/css/less/grafana.less
	src/test/test-main.js
2014-09-13 18:10:14 +02:00
Torkel Ödegaard
96a0d0aefa fixed changelog 2014-09-13 16:38:01 +02:00
Torkel Ödegaard
15f2b2cf9a Annotations: fixed InfluxDB annotation query, added unit test for annotation query, Fixes #802 2014-09-13 16:19:33 +02:00
Torkel Ödegaard
bf9eaea334 Updated lastest.json 2014-09-12 13:19:17 +02:00
Torkel Ödegaard
7b45a2ec51 Small fix to scripted async dashboard example 2014-09-12 13:15:06 +02:00
Torkel Ödegaard
48eb2083f2 Fix for graphite query letter assignment 2014-09-11 17:25:59 +02:00
Torkel Ödegaard
2c6ea276c1 Fixed small bug in graphite target controller when having variable for single parameter function 2014-09-11 17:19:39 +02:00
Torkel Ödegaard
5a3db0505f Small fix to elasticsearch save error handling 2014-09-11 16:00:59 +02:00
Torkel Ödegaard
6ca73f6df0 Do not render graph when width is zero, avoids plot errors 2014-09-11 14:25:20 +02:00
Torkel Ödegaard
762dab618a Small change to datasourceSrv, if datasource is not found, return default datasource 2014-09-11 14:07:27 +02:00
Torkel Ödegaard
a65c61442e minifix for spacing of question sign tooltips when html is minified 2014-09-11 14:01:37 +02:00
Torkel Ödegaard
4883b2a296 Fixed issue with using template variables in panel titles, and text panel, when selecting All option in variable 2014-09-11 13:54:59 +02:00
Torkel Ödegaard
b1abe72ab6 small update to text panel editor 2014-09-11 11:34:32 +02:00
Torkel Ödegaard
a640d55297 Added informatio & help blocks to graphite metric editor 2014-09-11 09:27:49 +02:00
Torkel Ödegaard
99009a11ed Graphite: added divideSeries function, #177 2014-09-11 08:03:00 +02:00
Torkel Ödegaard
2150bbf191 removed console.log from templateValuesSrv 2014-09-10 13:35:54 +02:00
Torkel Ödegaard
6f8cb743b5 Fixed default welcome to grafana dashboard, rows were not marked as editable 2014-09-10 11:53:58 +02:00
Torkel Ödegaard
682d2a1675 Dashboard: time range can now be read from URL parameters, will override dashboard saved time range, Closes #787, Closes #761 2014-09-10 10:46:04 +02:00
Torkel Ödegaard
6022784e42 InfluxDB: support for basic authorization (PR #782) 2014-09-10 09:08:25 +02:00
Torkel Ödegaard
4d4478d969 Added PR #785 to changelog 2014-09-10 09:07:14 +02:00
Ed Dawley
c0935c84ee Fixing some grunt errors with the elasticsearch grammar changes 2014-09-09 15:54:05 -04:00
Ed Dawley
17e040abe4 The elasticsearch datasource will now better handle language specifics when making the search partial (ie for search as you type). This means the search field will now support significantly more complex searches such as:
title:foo AND title:bar OR baz
    title:mysql AND [3306 TO 3308]
    web~
    title:foo AND -bar
2014-09-09 15:17:13 -04:00
Ed Dawley
6152a5e3c2 Adding in global search id counter so that async search responses can be discarded if a newer search is being processed. This prevents older search results from clobbering a newer search that happened to complete faster. 2014-09-09 15:16:47 -04:00
Daniel Shir
4558486cbd Added basic authorization for influxdb if needed 2014-09-09 15:23:40 +03:00
Torkel Ödegaard
3df592c702 Dashboard: elasticsearch dashboard storage now slugifies urls, #781 2014-09-09 13:42:46 +02:00
Torkel Ödegaard
05fabc73c2 Dashboard: elasticsearch dashboard storage now slugifies urls, #781 2014-09-09 13:04:07 +02:00
Torkel Ödegaard
e949761107 Made unsaved changes service ignore template variable options and selection changes 2014-09-09 11:40:37 +02:00
Torkel Ödegaard
4311a20c5f Fixed issue with editing text panel, removed a function from dashboard controller that I though was not used, turned out it was 2014-09-09 11:35:29 +02:00
Torkel Ödegaard
1440d1a147 Fix when changing templated vars, should update child template vars All value 2014-09-09 11:30:00 +02:00
Torkel Ödegaard
4b170ca9a3 Corrected error handling for influxdb datasource when loading/deleting dashboard 2014-09-09 11:14:57 +02:00
Torkel Ödegaard
d6e844c67c Fixes for opentsdb, (broken during 1.8 development) 2014-09-09 10:29:59 +02:00
Torkel Ödegaard
71a307270a Fixed text color in json text area for white theme, #735 2014-09-09 09:16:00 +02:00
Torkel Ödegaard
0f88b470e8 Fix for elasticsearch annotations when timestamp is a field and not in source, Fixes #777 2014-09-09 08:50:01 +02:00
Torkel Ödegaard
4798aa4789 Fixes to requirejs build task to include all modules, Fixes #779 2014-09-09 08:24:04 +02:00
Torkel Ödegaard
a9d96ccc8c Fixed ids for panels in default.json welcome to grafana dashboard 2014-09-08 18:03:10 +02:00
Torkel Ödegaard
e0c9ddbfba Worked on variable initilization and sync to from url, #772 2014-09-08 11:03:14 +02:00
Torkel Ödegaard
bbc5dae1d2 Working on better handling of variables and url init and state 2014-09-07 11:55:26 +02:00
Torkel Ödegaard
9e7c55728f small cleanup of unused code 2014-09-06 18:05:54 +02:00
Torkel Ödegaard
a6fa01f89b POC of panel edit menu 2014-09-06 14:05:07 +02:00
Torkel Ödegaard
6c71754e51 Changed template variable typeahead/autocomplete list limit from 10 to 1000, Fixes #767, Fixes #768 2014-09-06 10:12:28 +02:00
Torkel Ödegaard
e729b3734d Fix for selecting template variable value from typeahead using enter key, Closes #765 2014-09-06 10:05:58 +02:00
Torkel Ödegaard
6337c77532 Rename of edit label on graph panel 2014-09-06 09:49:21 +02:00
Torkel Ödegaard
fb08b71884 Small fix to graphite target controller to still revert to text box for expressions with multiple series that do not use a series reference 2014-09-05 17:44:54 +02:00
Torkel Ödegaard
d749549135 Templating: Full support for InfluxDB, filter by part of series names, extract series substrings, nested queries, multipe where clauses! Closes #613 2014-09-05 15:46:29 +02:00
Torkel Ödegaard
58a2ab4fbd Templating: Can now use template variables in panel titles, Closes #312 2014-09-05 15:17:19 +02:00
Torkel Ödegaard
cc96cfe0c7 Templating: Ability to use template variables for function parameters via custom variable type, can be used as parameter for movingAverage or scaleToSeconds for example, Closes #262 2014-09-05 14:03:36 +02:00
Torkel Ödegaard
656b3e53a8 Templating: Interval variable type for time intervals summarize/group by parameter, included auto option, and auto step counts option.
Closes #243
2014-09-05 13:31:34 +02:00
Torkel Ödegaard
4e5dcafa1b working on auto interval template variable support 2014-09-05 12:07:48 +02:00
Torkel Ödegaard
afc8380f23 Work on getting template variables to work well with functions that take integers, #262 2014-09-05 09:11:50 +02:00
Torkel Ödegaard
0319051891 Extend template variable syntax to include , Closes #760 2014-09-05 08:26:50 +02:00
Torkel Ödegaard
4805a3bc23 Merge remote-tracking branch 'oss/template_variable_syntax' 2014-09-05 07:06:00 +02:00
Torkel Ödegaard
dc63f0ddd0 Fixed so white theme looks good with new search and editor panes, Closes #735, and other small fixes and polish 2014-09-05 07:02:59 +02:00
Torkel Ödegaard
6ff188e4d9 test for adding syntax in addition to [[variable]] 2014-09-04 17:34:36 +02:00
Torkel Ödegaard
44edaad19d Fixed scroll issue with firefox, Fixes #754 2014-09-04 15:25:59 +02:00
Torkel Ödegaard
5304221e46 fixed spelling in changelog concerning InfluxDB breaking changes 2014-09-04 15:09:07 +02:00
Torkel Ödegaard
c6b1fe5349 updated change log with info about InfluxDB breaking changes, and fixes for stacked series and missing values, Fixes #534, Closes #743, Fixes #673,Fixes #674, Closes #756 2014-09-04 14:57:50 +02:00
Torkel Ödegaard
80574334cf Changed variable replacement works for InfluxDB, now , and 2014-09-04 14:41:27 +02:00
Torkel Ödegaard
dd4eaa0758 fixes to target segment markup 2014-09-04 14:17:05 +02:00
Torkel Ödegaard
93550e9ea5 Work on fixing stacking issues with InfluxdB, added fill(0) and fill(null) option to InfluxDB query editor, also a panel wide group by time option that supports setting a low limit, Fixes issues #673, #674, #534, #743 2014-09-04 14:08:31 +02:00
Torkel Ödegaard
3157fc651d Fixed dashboard import view, did not hide search results 2014-09-04 09:58:08 +02:00
Torkel Ödegaard
dd4f27e3fa Fixed issue where a metric request error would set panel error flag, which would cause unsaved changes service to detect change, and prompt the unsaved changes warning. The panel error state is now moved to the panelMeta object that is not part of the dashboard / panel model, Closes #745 2014-09-04 09:44:42 +02:00
Torkel Ödegaard
455e80513b Fixes delete link in search result, broken after recent changes to search results, Closes #749 2014-09-04 08:56:50 +02:00
Torkel Ödegaard
65af872ec6 Small fix to graphiteDatasource and sending cacheTimeout undefined, reintroduced this bug yesterday, added unit test so it should not appear again 2014-09-03 16:48:48 +02:00
Torkel Ödegaard
917cd35005 Dashboard: View dashboard json, edit/update any panel using json editor, makes it possible to quickly copy a graph from one dashboard to another.
Closes #304
2014-09-03 11:15:44 +02:00
Torkel Ödegaard
b989183fce Removed collapse row button, added to row menu, made small change to text pannel to allow smaller height, Closes #727 2014-09-03 09:52:36 +02:00
Torkel Ödegaard
0845d5d451 Removed configure row button when row is collapsed 2014-09-03 09:33:32 +02:00
Torkel Ödegaard
f002ef105e Small fix to influxdb query builder, should update raw query after building query 2014-09-03 09:20:39 +02:00
Torkel Ödegaard
3d202c2ef9 Fixed small issue where dashboard search did not work after loading dashboard and it does not exist, now shows a valid dashboard 2014-09-03 09:12:59 +02:00
Torkel Ödegaard
953eec7326 Fixes and polish for the graphite query editor, #117 2014-09-03 08:53:08 +02:00
Torkel Ödegaard
c3956b4d6f fixed jshint warning 2014-09-03 07:58:00 +02:00
Torkel Ödegaard
d2421bb216 Added better match when using graphite function autocomplete, hit tab key and the first match will be used, you no longer need to use the down arrow to select the typeahead match you want, just hit tab key 2014-09-03 07:41:43 +02:00
Torkel Ödegaard
afdc19ce9d Updated sumSeries, averageSeries to support other series reference arguments, #117 2014-09-03 07:35:14 +02:00
Torkel Ödegaard
4a9380cc95 added limit checks to up/down arrow key selection of search results 2014-09-03 07:24:28 +02:00
Torkel Ödegaard
9f60745e57 Graphite: Graphite query builder can now handle functions that multiple series as arguments! #117 2014-09-02 20:59:54 +02:00
Torkel Ödegaard
666d640216 Graphite: Metric node/segment selection is now a textbox with autocomplete dropdown, allow for custom glob expression for single node segment without enter text editor mode, Closes #281 2014-09-02 12:55:45 +02:00
Torkel Ödegaard
cb479d737b Graphite: Fix for nonNegativeDerivative function, now possible to not include optional first parameter maxValue, Closes #702 2014-09-02 07:58:29 +02:00
Torkel Ödegaard
4ee455fad2 Fixed failing influxdb query builder unit test 2014-09-02 07:21:41 +02:00
Torkel Ödegaard
2da04e72f5 More progress on influxdb query editor, templating, refactoring, unit tests, #740, #507, #586 2014-09-02 07:05:36 +02:00
Torkel Ödegaard
141ea7ba91 More work InfluxDB templated queries and required changes to editor and datasource 2014-09-01 16:55:54 +02:00
Torkel Ödegaard
5ae0239c26 small UI changes to InfluxDB query editor, made each query two lines to give more space to series name 2014-09-01 13:40:34 +02:00
Torkel Ödegaard
2dc4434a49 Progress on influxdb and templated queries/variables, #613 2014-09-01 11:13:18 +02:00
Torkel Ödegaard
39c068bd53 Graph: Fix for tooltip current value decimal precision when 'none' axis format was selected, Closes #733 2014-08-29 12:54:42 +02:00
Torkel Ödegaard
b26dfd8246 Updated changelog with progress on filtering/template overhaul, and UI change 2014-08-29 12:45:58 +02:00
Torkel Ödegaard
3185db9609 new template system is starting to work 100%, not all features are in, like regex selection, influxdb support, and other stuff 2014-08-29 12:34:04 +02:00
Torkel Ödegaard
61a618e473 fixes to templating 2014-08-29 10:17:00 +02:00
Torkel Ödegaard
c4a4ecfc81 Merge branch 'master' into filtering_overhaul
Conflicts:
	src/app/controllers/dashboardNavCtrl.js
2014-08-29 10:04:30 +02:00
Torkel Ödegaard
f9b0ce0f75 Fixes to annotations editor 2014-08-29 09:59:18 +02:00
Torkel Ödegaard
20607c00b1 Fixed playlist pane not showing after modal removal change 2014-08-29 08:44:38 +02:00
Torkel Ödegaard
12e2bf2f85 Trying to restore broken features and some polishing 2014-08-28 16:44:16 +02:00
Torkel Ödegaard
685a2fec6c trying to get new templating / filtering to work 2014-08-28 16:03:13 +02:00
Torkel Ödegaard
f9cd4a4470 More work on templating, added an embry of a dashboard json edit view 2014-08-28 12:44:01 +02:00
Torkel Ödegaard
b761aad903 More work on filter/templating overhaul 2014-08-27 21:47:41 +02:00
Torkel Ödegaard
9ee4fcb36c continued large refactoring of filterSrv, timeSrv and templating 2014-08-27 17:58:49 +02:00
Torkel Ödegaard
1929490deb Renamed filterSrv to timeSrv and made it a service again 2014-08-27 16:29:48 +02:00
Torkel Ödegaard
bb3b31829f Progress on template editor & new templating features 2014-08-27 15:54:30 +02:00
Torkel Ödegaard
e0a58dd1fe More work on template editor 2014-08-27 10:41:27 +02:00
Torkel Ödegaard
7d6e04ac77 Small fixes to dasheditor and firefox fixes for search 2014-08-27 09:01:50 +02:00
Torkel Ödegaard
6502cff8fe Moved search results from fixed dropdown to edit pane 2014-08-26 16:42:15 +02:00
Torkel Ödegaard
fdffb03eba Css polish and tweaks 2014-08-26 15:02:25 +02:00
Torkel Ödegaard
d4d3ae7530 Dashboard: Fix for zoom out causing right hand to range to be set in the future. Closes #724 2014-08-26 14:42:32 +02:00
Torkel Ödegaard
647feb7b33 Progress on new filter/templating editor 2014-08-26 14:17:46 +02:00
Torkel Ödegaard
625781c7f4 Merge branch 'master' into filtering_overhaul 2014-08-26 11:18:30 +02:00
Torkel Ödegaard
02ef6c4e07 Merge branch 'master' of github.com:grafana/grafana 2014-08-26 11:18:08 +02:00
Torkel Ödegaard
43eba6cc31 Dashboard: fix for hideControls setting not used/initlaized on dashboard load, Closes #723 2014-08-26 11:17:56 +02:00
Torkel Ödegaard
3775991ac8 Modals to edit pane work almost done, need to work on light theme 2014-08-26 11:12:26 +02:00
Torkel Ödegaard
08d2492839 tweaks to edit & tabs look, removed add row from dasheditor 2014-08-26 10:49:09 +02:00
Torkel Ödegaard
d0d0e8349f moved custom timepicker from modal to edit pane 2014-08-26 10:16:21 +02:00
Torkel Ödegaard
1a97f79d54 changed playlist modal to edit pane 2014-08-26 09:46:15 +02:00
Torkel Ödegaard
9fc6c4888f converting more modals to edit panels 2014-08-26 09:32:30 +02:00
Torkel Ödegaard
f2de18508a More work on removing modals 2014-08-26 07:27:43 +02:00
Torkel Ödegaard
6342571afe Trying get rid of modals, new better design for dashboard settings and modals 2014-08-25 22:39:40 +02:00
Torkel Ödegaard
00e5bb61fc Trying out an alternative to modals 2014-08-25 17:27:19 +02:00
Torkel Ödegaard
b506e7c267 fixed submenu in fullscreen mode 2014-08-25 16:44:33 +02:00
Torkel Ödegaard
061d1262d4 Small html markup/css simplification 2014-08-25 16:14:47 +02:00
Torkel Ödegaard
8b3c89e267 Starting work on new templating editor 2014-08-25 15:55:42 +02:00
Torkel Ödegaard
c634ee81fc Refactoring the pulldown (filtering/annotations), changing the ui slightly 2014-08-25 15:36:44 +02:00
Torkel Ödegaard
6969a4121c removing pulldowns and simplifying submenu controls code 2014-08-25 13:31:31 +02:00
Torkel Ödegaard
4f8b2ad245 began work on filtering overhaul 2014-08-25 12:55:42 +02:00
Torkel Ödegaard
03353cb652 Merge branch 'famousgarkin-master' 2014-08-24 14:46:50 +02:00
Torkel Ödegaard
6f80862517 Dashboard: new config.js option to change/remove window title prefix from 'Grafana -' to anything, PR #685 2014-08-24 14:46:13 +02:00
Torkel Ödegaard
edd8d63caf Merge branch 'master' of github.com:famousgarkin/grafana into famousgarkin-master 2014-08-24 14:29:35 +02:00
Torkel Ödegaard
ffbdea78ee Fix for plot dimension error when resizing window 2014-08-23 20:23:33 +02:00
Torkel Ödegaard
47a20e6a2f Dashboard: fix for adding rows from dashboard settings modal, Closes #699 2014-08-23 10:45:07 +02:00
Torkel Ödegaard
c00384ad06 work on account registration 2014-08-22 18:05:51 +02:00
Torkel Ödegaard
31fe471da5 working on account registration and more 2014-08-22 18:05:37 +02:00
Torkel Ödegaard
c684b1ddab dashboard load/save work and began work on register 2014-08-22 15:32:42 +02:00
Torkel Ödegaard
477f66f56b dashobard load/save work, and began register view 2014-08-22 15:32:20 +02:00
Torkel Ödegaard
359bca0634 save/load dashboard update 2014-08-22 13:25:22 +02:00
Torkel Ödegaard
8a80623d0c Merged dashboard tag colors feature branch, updated changelog #634 2014-08-22 09:40:11 +02:00
Torkel Ödegaard
adbe8142b6 Merge branch 'dashboard_tag_colors' 2014-08-22 09:34:19 +02:00
Torkel Ödegaard
3579a18da8 Css fix for panel-error position 2014-08-22 09:34:05 +02:00
Torkel Ödegaard
36882ea2a4 More work on dashboard tag colors 2014-08-22 09:04:28 +02:00
Torkel Ödegaard
3fec2cdfd6 Merge branch 'master' into dashboard_tag_colors 2014-08-22 07:14:19 +02:00
Torkel Ödegaard
07d8b542bf working on rethinkdb stuff 2014-08-21 22:09:48 +02:00
Torkel Ödegaard
06de80f2a7 updated 2014-08-21 22:09:26 +02:00
Torkel Ödegaard
ef351bb9a3 Merge branch 'master' of github.com:torkelo/grafana-private into pro 2014-08-21 22:01:32 +02:00
Torkel Ödegaard
28de5cbd97 Merge branch 'master' of github.com:grafana/grafana 2014-08-21 21:59:36 +02:00
Torkel Ödegaard
39cdf85788 small refactoring for search result and dashboard id/title handling 2014-08-21 21:59:23 +02:00
Torkel Ödegaard
37e19cee20 fixed jshint error 2014-08-21 11:18:49 +02:00
Torkel Ödegaard
b39fbff8fa Merge remote-tracking branch 'origin/pro' into pro
Conflicts:
	src/test/test-main.js
2014-08-21 11:17:44 +02:00
Torkel Ödegaard
5ff15f27b7 Merge 2014-08-21 11:16:22 +02:00
Torkel Ödegaard
baf99e8650 Merge branch 'master' of github.com:torkelo/grafana-private into pro
Conflicts:
	src/test/test-main.js
2014-08-21 11:16:08 +02:00
Torkel Odegaard
7c3046e011 Fix for reloadOnSearch missing on all dashboard routes, caused dashboard to be reloaded when entering/exiting edit mode (settings were lost), related to recent fullscreen/edit state present in url, #672, #425 2014-08-21 10:36:18 +02:00
Torkel Ödegaard
1bc8526640 Reverted change, default edit tab should be metrics tab 2014-08-21 09:29:56 +02:00
Torkel Ödegaard
0795af8d42 Fix for search result list and double link to dashboard that caused navigation start recursion when unsaved changed dialog was displayed 2014-08-21 09:28:51 +02:00
Torkel Ödegaard
bd7c045b1c Small fix for dashboard settings dialog controls tab was empty 2014-08-21 09:01:04 +02:00
Torkel Ödegaard
c6812f569f Small js warning fix for firefox 2014-08-21 08:42:09 +02:00
Torkel Ödegaard
17ffb167e2 Small fixes for firefox 2014-08-20 22:34:51 +02:00
Torkel Ödegaard
019d077f5a Added missing max-height to search results container 2014-08-20 19:56:32 +02:00
Torkel Ödegaard
c000f438ae added unit tests for grid thresholds 2014-08-20 15:03:10 +02:00
Torkel Ödegaard
c0d7ddf1fb Updated changelog with new display styles per series option feature, Closes #425, Closes #700 2014-08-20 12:11:14 +02:00
Torkel Ödegaard
5bf794e24e Merge branch 'series_style_overrides' 2014-08-20 11:48:13 +02:00
Torkel Ödegaard
a9cfb160c9 Added typeahead to series overrides, #425 2014-08-20 11:48:00 +02:00
Torkel Ödegaard
468c9a9061 Fix for zindex override removal, should restore series order 2014-08-20 11:31:40 +02:00
Torkel Ödegaard
da1279aa5b Added zindex per series override option, #425 2014-08-20 10:50:26 +02:00
Torkel Ödegaard
3ec053bea7 Moved series override code to TimeSeries 2014-08-20 10:27:30 +02:00
Torkel Ödegaard
b2f9f81eaf Moved yaxis override from aliasYAxis map to the new seriesOverride array 2014-08-20 09:31:22 +02:00
Torkel Ödegaard
939e957fda Made regex match work for per series overrides, #425, #700 2014-08-20 08:35:17 +02:00
Torkel Ödegaard
062fe72030 More options can now be set on pre series basis, this is awesome! 2014-08-19 17:24:37 +02:00
Torkel Ödegaard
cdcbb872d5 options per series is starting to work nicely 2014-08-19 16:57:33 +02:00
Torkel Ödegaard
048763053c Began work on applying per series options to flot options 2014-08-19 16:22:27 +02:00
Torkel Ödegaard
c6489d9b01 Lots of progress on per series overrides 2014-08-19 15:22:03 +02:00
Torkel Ödegaard
299053f2d5 Fix for utc in timepicker, Closes #713 2014-08-19 11:12:48 +02:00
Torkel Ödegaard
937ac84538 Began work on per series style overrides, #425 2014-08-18 21:48:01 +02:00
Torkel Ödegaard
5c0d1355a5 Second take on dashboard tags search result colors 2014-08-18 19:33:38 +02:00
Torkel Ödegaard
a64604de6b UI improvements to search result list (larger click are for dashboard title link, plus UI look polish), Closes #709 2014-08-18 16:38:04 +02:00
Torkel Ödegaard
1a3dac0c17 Fix for timepicker dates and tooltip when UTC timzone is selected,
custom date modal is still local time, Closes #277
2014-08-18 13:43:26 +02:00
Torkel Ödegaard
ffd73e8bfb Fix for graphite queries with glob syntax ([1-9] and ?) that made
the graphite parser / query editor bail and fallback to text edit mode.
2014-08-18 12:17:48 +02:00
Torkel Ödegaard
27c536b1a1 Small fix to 'none' axis formats and zero value when axis tickDecimals is high, Closes #707 2014-08-18 09:03:25 +02:00
Torkel Ödegaard
631c7adf12 updated 2014-08-17 12:26:00 +02:00
Torkel Ödegaard
d8dca20332 updated 2014-08-17 12:25:37 +02:00
Torkel Ödegaard
dc5973a0f3 small css fix for alignment of legend values when shown in table style 2014-08-17 11:53:58 +02:00
Torkel Ödegaard
efed13b9fe Work on login and sidemenu 2014-08-16 21:54:26 +02:00
Torkel Ödegaard
34ab1e529b Lots of work on the side menu 2014-08-16 21:54:05 +02:00
Torkel Ödegaard
b812b1c579 Fixed link to playlist docs in readme.md 2014-08-16 19:02:50 +02:00
Torkel Ödegaard
c892d9d6f6 Merge remote-tracking branch 'origin/master' into pro 2014-08-16 13:15:02 +02:00
Torkel Ödegaard
b89480a284 refactored use of localStorage 2014-08-16 13:13:26 +02:00
Torkel Ödegaard
9951c3825e began work on pro side menu 2014-08-16 10:14:31 +02:00
Torkel Ödegaard
9ac1f6b26b Merge remote-tracking branch 'origin/move_stuff' into pro 2014-08-16 08:56:19 +02:00
Torkel Ödegaard
dac4954215 merged with oss 2014-08-16 08:56:02 +02:00
Torkel Ödegaard
5846c71095 Changed name of some partials and controllers 2014-08-16 08:55:14 +02:00
Torkel Ödegaard
142f081d1e fixed small issue with the recent change to the 'none' axis format,
Closes #703
2014-08-15 21:31:53 +02:00
Torkel Ödegaard
ec2b4f584c some initial work on making it easy to add a custom datasource without modifing the original source, #701, #553 2014-08-15 19:12:25 +02:00
Torkel Ödegaard
88d991ef45 Another angular binding/watcher optimization 2014-08-15 17:23:27 +02:00
Torkel Ödegaard
dc382a6df7 Drag drop binding expression watcher was expensive, removed watcher after first eval, seems to still work 2014-08-15 13:35:17 +02:00
Torkel Ödegaard
c6e57d64d7 moved binding expression for panel width to directive 2014-08-15 13:19:11 +02:00
Torkel Ödegaard
dc3cd430c8 moved binding expression in panels to directive and watchGroup 2014-08-15 12:57:12 +02:00
Torkel Ödegaard
9848600335 Changed panel error icon from ng-show to ng-if 2014-08-15 12:09:04 +02:00
Torkel Ödegaard
cd79b73cb0 moved an expensive binding expression into a directive and a groupWatch 2014-08-15 11:15:24 +02:00
Torkel Ödegaard
21aa1b43fd Save dropdown and search bindings and scope is now not loaded on dashboard load, small performance improvement 2014-08-15 09:35:07 +02:00
Torkel Ödegaard
2f3a96f7a7 Removed add-panel tab from row editor, only add panels from the row menu now, do not want to ways to do the same thing 2014-08-15 08:46:32 +02:00
Torkel Ödegaard
b761dcde45 Switch from watch to watchCollection for bodyclass directive 2014-08-15 08:14:15 +02:00
Torkel Ödegaard
b6cdb0f885 Moved some expensive bindings from timepicker to controller 2014-08-15 08:02:16 +02:00
Torkel Ödegaard
472969ae2a Merge branch 'master' of github.com:grafana/grafana 2014-08-14 22:32:17 +02:00
Torkel Ödegaard
9e3514a993 More small performance tweaks, trying to clean up watcher & scope counts 2014-08-14 22:30:19 +02:00
Torkel Ödegaard
aee3ddd06a Simplified panel bootstrapping, limiting digest cycles during dashboard boot 2014-08-14 15:32:15 +02:00
Torkel Ödegaard
9558d404fa Merge pull request #698 from Topface/http-update
Checking for new version over https
2014-08-14 12:39:54 +02:00
Torkel Ödegaard
0ca6b67132 Added some performance profiling code 2014-08-14 12:26:06 +02:00
Torkel Ödegaard
9390b1eef5 Small cleanup of dashboard partial, removed unused stuff 2014-08-14 12:15:46 +02:00
Ian Babrou
0198167b27 checking for new version over https 2014-08-14 14:13:03 +04:00
Torkel Ödegaard
83e9bc4816 Graph: Fix for axis format none broken for numbers in exponential notation, Closes #696 2014-08-14 12:05:29 +02:00
Torkel Ödegaard
87bf6b3800 Updated changelog and added fix for #695 2014-08-14 10:29:47 +02:00
Torkel Ödegaard
7b3df02640 Performance enhancements 2014-08-13 21:26:33 +02:00
Torkel Ödegaard
499246abae Tech: upgraded jquery from 1.8.0 to 2.1.1, Closes #694 2014-08-13 19:51:27 +02:00
Torkel Ödegaard
71f78cc895 removed comments 2014-08-13 19:26:53 +02:00
Torkel Ödegaard
5896eee693 Dashboard: tooltip fixes for flickering tooltips that sometimes do now want to show on hover, and for tooltips that get stuck after exiting modal, Closes #691 2014-08-13 19:11:46 +02:00
Torkel Ödegaard
ce6b60653c Updated changelog with #672 2014-08-13 17:23:29 +02:00
Torkel Ödegaard
2b865e3505 Merge branch 'panel_id_permalink' 2014-08-13 17:20:59 +02:00
Torkel Ödegaard
dee0e5fce7 final fixes for fullscreen url state, #672 2014-08-13 17:20:54 +02:00
Torkel Ödegaard
56269758c4 refactoring of panel manipulation, moved to dashboard model 2014-08-13 16:35:34 +02:00
Torkel Ödegaard
436f6bda3e Fixed unit tests for dashboardViewStateSrv 2014-08-13 15:17:13 +02:00
Torkel Ödegaard
4d1102db0b Panel edit state is working pretty good now, #672 2014-08-13 15:02:57 +02:00
Torkel Ödegaard
4987a2158e Lots of complicated code for dealing with panel state 2014-08-13 14:22:21 +02:00
Torkel Ödegaard
435a5a67bc Refactoring fullscreen / edit handling 2014-08-13 12:16:50 +02:00
Torkel Ödegaard
fc686ca618 Fullscreen & edit state persisted to url is nearing completion, refactored fullscreen state management to a special dashboardViewState object, Issue #672 2014-08-13 10:07:32 +02:00
Torkel Ödegaard
ec99096d52 experimenting with url and dashboard state 2014-08-13 07:47:36 +02:00
Torkel Ödegaard
9e30599f1f rename backend to pkg 2014-08-12 20:45:41 +02:00
Torkel Ödegaard
472e1c6d8e fixed tests 2014-08-12 20:15:03 +02:00
Torkel Ödegaard
46edd6008f merge sync oss 2014-08-12 20:06:33 +02:00
Torkel Ödegaard
68e520fa2d small css tweak to legend and padding between edit tabs 2014-08-12 19:59:20 +02:00
Torkel Ödegaard
d46e612cb1 Working on linking to panels, #576, #672 2014-08-12 18:21:48 +02:00
Torkel Ödegaard
e7ce371ee8 working on login && auth 2014-08-12 15:07:20 +02:00
Torkel Ödegaard
bfe1ef0733 worked on login view 2014-08-12 15:06:54 +02:00
Torkel Ödegaard
56d449b2ce updated 2014-08-12 12:20:15 +02:00
Torkel Ödegaard
c690d4aae8 added pro routes 2014-08-12 12:19:33 +02:00
Torkel Ödegaard
4966b10a0f pro changes 2014-08-12 12:19:15 +02:00
Torkel Ödegaard
c48df8522a updated readme.md again 2014-08-12 09:24:58 +02:00
Torkel Ödegaard
b0a2c26b22 updated readme.md with a run from master section 2014-08-12 09:23:25 +02:00
Torkel Ödegaard
24579d86d2 updated 2014-08-12 07:25:02 +02:00
Torkel Ödegaard
71573fb5a0 restructing api code 2014-08-11 20:18:46 +02:00
Torkel Ödegaard
f865da6d6a removed generated css that came back after merge 2014-08-11 18:52:34 +02:00
Torkel Ödegaard
3a5f718da8 updated 2014-08-11 16:37:44 +02:00
Torkel Ödegaard
8699dec571 fixed jshint issues 2014-08-11 16:37:31 +02:00
Torkel Ödegaard
6f0c6281e7 Merge remote-tracking branch 'origin/master' into pro 2014-08-11 16:09:40 +02:00
Torkel Ödegaard
58e4dc1b6c updated readme with correct coveralls badge 2014-08-11 16:03:27 +02:00
Torkel Ödegaard
17c03bed21 Added some unit tests for RowCtrl 2014-08-11 15:59:03 +02:00
Torkel Ödegaard
4bfc5355db removed sublime project 2014-08-11 15:32:21 +02:00
Torkel Ödegaard
37b3b1fc3a Merge remote-tracking branch 'origin/master' into pro 2014-08-11 15:30:45 +02:00
Torkel Ödegaard
d865618051 Dashboard: Row option to display row title even when the row is visible, Closes #578 2014-08-11 15:25:36 +02:00
Torkel Ödegaard
a995857cca changed placement of panel error tooltip to the right of icon, works better in when in edit mode 2014-08-11 13:47:58 +02:00
Torkel Ödegaard
fdbdebac32 Merge branch 'master' of github.com:grafana/grafana 2014-08-11 13:44:11 +02:00
Torkel Ödegaard
a242c40b23 Merge branch '1.7.x' 2014-08-11 13:43:05 +02:00
Torkel Ödegaard
f82b84eac7 updated changelog 2014-08-11 13:42:39 +02:00
Torkel Ödegaard
70be333691 Last miniute fix for issue in influxdb http request calling 2014-08-11 13:39:02 +02:00
Torkel Ödegaard
3d9a4dcbf3 Merge branch '1.7.x'
Conflicts:
	src/css/bootstrap.dark.min.css
	src/css/bootstrap.light.min.css
	src/css/default.min.css
2014-08-11 13:35:15 +02:00
Torkel Ödegaard
577efbf0c2 fixed changelog issue link 2014-08-11 12:49:17 +02:00
Torkel Ödegaard
a3fca638ee updated version to 1.7.0 (removed rc1 pre-release tag) 2014-08-11 12:23:00 +02:00
Torkel Ödegaard
027855f891 Small fix for light theme 2014-08-11 12:16:19 +02:00
Torkel Ödegaard
b9b04fd932 Dashboard: Panel error are less intrusive, panel error bar replaced with small indicator, hover for short details, click to open inspector, Closes #681 2014-08-11 12:11:24 +02:00
unknown
2b1dcaf5e3 added global page title prefix setting 2014-08-11 11:25:30 +02:00
Torkel Ödegaard
9e32a5613d Merge pull request #682 from PeterDaveHello/patch-1
Use svg instead of png to get better image quality
2014-08-11 11:18:05 +02:00
Torkel Ödegaard
61b43a0828 Merge pull request #683 from PeterDaveHello/patch-2
make CI build faster
2014-08-11 11:17:14 +02:00
Peter Dave Hello
7fc1fed91e make CI build faster 2014-08-11 17:03:17 +08:00
Peter Dave Hello
1fd97f8732 Use svg instead of png to get better image quality 2014-08-11 16:46:20 +08:00
Torkel Ödegaard
aa03de8e52 More work on integrated console, with request details 2014-08-10 21:25:24 +02:00
Torkel Ödegaard
eb9a7267bd began work on inspection console to visualize metric requests, and other useful troubleshooting info and inspection 2014-08-10 14:35:56 +02:00
Torkel Ödegaard
21b7c6a2c0 Moved css files, removed generated css files from source control, consolidated (concat) css more, now only two css files, dark and light 2014-08-10 09:46:55 +02:00
Torkel Ödegaard
4cd53ce119 Merge branch 'cleanup-generated-files' of github.com:clkao/grafana into clkao-cleanup-generated-files 2014-08-10 09:23:44 +02:00
Torkel Ödegaard
e2283e53b6 Merge branch 'master' into develop 2014-08-10 09:12:18 +02:00
Chia-liang Kao
d51d5af992 Cleanup legend value by using css content 2014-08-10 09:09:45 +02:00
Torkel Ödegaard
b98a8ee83a updated changelog for PR #666, Closes #660 2014-08-10 09:09:45 +02:00
Christophe Furmaniak
21cf1f6c47 fix #660 by checking if options is undefined
- a complete fix with a consistent support of alias in all use cases is not obvious (see #660 for explanations)
2014-08-10 09:09:45 +02:00
Torkel Ödegaard
918ea5d12f Annotation: filter field is not interpreting in elasticsearch query, Fixes #661 2014-08-10 09:09:45 +02:00
Torkel Ödegaard
3b7551e1e4 added coveralls badge 2014-08-10 09:09:45 +02:00
Torkel Ödegaard
5dbc0aedcc General: Fix for refresh icon in IE browsers, Fixes #657 2014-08-10 09:09:45 +02:00
Chia-liang Kao
8819d559b7 move vendor css intor appropriate places and remove generated files from version control 2014-08-10 02:21:05 +08:00
Torkel Ödegaard
448a5c00fd Merge pull request #669 from clkao/release-lodash
Fix release build rules following 23c9f97 and #659
2014-08-09 13:08:42 +02:00
Chia-liang Kao
8194c62f4e Fix release build rules following 23c9f97 and #659 2014-08-09 18:40:40 +08:00
Torkel Ödegaard
e75debbf81 Fixes to text panel, and alert related to angularjs upgrade 2014-08-09 12:18:21 +02:00
Torkel Ödegaard
380f707285 workin on png rendering 2014-08-09 11:57:54 +02:00
Torkel Ödegaard
1bc277fd87 Merge branch 'develop' into pro 2014-08-09 10:24:17 +02:00
Torkel Ödegaard
5b475a05ef Added another unit test for influxdb datasource, fixed angular dragdrop/mocks file mixup 2014-08-09 10:02:47 +02:00
Torkel Ödegaard
f69dcf38ef added unit test for influxdb query 2014-08-08 17:33:16 +02:00
Torkel Ödegaard
c669f8c612 working on rendering panel with phantomjs 2014-08-08 15:53:31 +02:00
Torkel Ödegaard
966ba97b2c updated changelog for PR #666, Closes #660 2014-08-08 15:24:10 +02:00
Christophe Furmaniak
675688cb80 fix #660 by checking if options is undefined
- a complete fix with a consistent support of alias in all use cases is not obvious (see #660 for explanations)
2014-08-08 14:58:03 +02:00
Torkel Ödegaard
f068b2c1d3 Merge remote-tracking branch 'origin/overview' into pro 2014-08-08 14:37:24 +02:00
Torkel Ödegaard
3dd383ba11 solo panel work 2014-08-08 14:36:13 +02:00
Torkel Ödegaard
3a0983d8bf Merge branch 'develop' into overview 2014-08-08 14:11:11 +02:00
Torkel Ödegaard
59c7edfd90 fixed unit test that broke after moving colors array 2014-08-08 14:10:35 +02:00
Torkel Ödegaard
660fbfd73c Moved colors array away from dash controller 2014-08-08 14:03:05 +02:00
Torkel Ödegaard
bc7ef28644 Merge branch 'develop' into overview
Conflicts:
	src/test/test-main.js
2014-08-08 13:48:39 +02:00
Torkel Ödegaard
7b011c1d96 Changed name of dashboard service to dashboardSrv 2014-08-08 13:45:52 +02:00
Torkel Ödegaard
a0780ce48a Began work on solo panel 2014-08-08 13:37:51 +02:00
Torkel Ödegaard
8154b4f60d search and save are 'working', barely 2014-08-08 12:35:15 +02:00
Torkel Ödegaard
91a6ae756f updated grafana datasource 2014-08-08 12:34:28 +02:00
Torkel Ödegaard
3fffd08ae4 Annotation: filter field is not interpreting in elasticsearch query, Fixes #661 2014-08-08 07:19:03 +02:00
Torkel Ödegaard
abc8077a96 added some unit tests for graph panel controller 2014-08-07 18:17:26 +02:00
Torkel Ödegaard
eb6099a93f Began work on pro modification 2014-08-07 16:04:54 +02:00
Torkel Ödegaard
5a125c7fe5 added coveralls badge 2014-08-07 15:05:37 +02:00
Torkel Ödegaard
02fb2baf62 Added code coverage, and sending reports to coveralls 2014-08-07 14:58:57 +02:00
Torkel Ödegaard
23c9f973cc Switch from underscore to lodash, #659 2014-08-07 14:35:28 +02:00
Torkel Ödegaard
db90fa71d4 General: Fix for refresh icon in IE browsers, Fixes #657 2014-08-07 14:16:54 +02:00
Torkel Ödegaard
c416b09089 more work on overview panel 2014-08-07 14:09:07 +02:00
Torkel Ödegaard
f144593c06 Merge branch 'develop' into overview 2014-08-07 13:45:01 +02:00
Torkel Ödegaard
c3a6ae1622 added more graphite target controller tests 2014-08-07 13:44:09 +02:00
Torkel Ödegaard
76aab2a2ac added graphiteTargetCtrl specs 2014-08-07 10:42:05 +02:00
Torkel Ödegaard
5337756792 working on overview panel and unit tests 2014-08-07 10:12:31 +02:00
Torkel Ödegaard
8ed4859bb5 Merge branch 'develop' into overview 2014-08-07 09:01:24 +02:00
Torkel Ödegaard
a02effc32e Merge branch 'master' into develop 2014-08-07 09:01:09 +02:00
Torkel Ödegaard
965c1f0353 Chart: Possible fix for stuck tooltip (annotation or time series point hover tooltip would not disappear), Fixes #450 2014-08-07 09:00:52 +02:00
Torkel Ödegaard
e7086cf6df Timepicker: Fix for setting custom To date with low refresh interval, Fixes #652 2014-08-07 07:58:14 +02:00
Torkel Ödegaard
af073dad46 Fix for auto refresh not being started after loading dashboard, Fixes #655 2014-08-07 07:20:56 +02:00
Torkel Ödegaard
1e7beffafd more unit test work 2014-08-06 19:33:38 +02:00
Torkel Ödegaard
c2c16b6bd2 Merge branch 'develop' into overview 2014-08-06 17:26:52 +02:00
Torkel Ödegaard
b79e8b8130 fixed jshint error in test-main 2014-08-06 16:11:17 +02:00
Torkel Ödegaard
72e5a40e7e began work on overview panel 2014-08-06 16:09:26 +02:00
Torkel Ödegaard
3b25200868 Refactoring base panel features, trying to get controller unit tests to work 2014-08-06 16:00:43 +02:00
Torkel Ödegaard
3985e52a3a Fixed unit tests broken after angular 1.3 upgrade 2014-08-06 10:53:45 +02:00
Torkel Ödegaard
fee44d83c8 Small timepicker angular binding perf improvement 2014-08-06 10:39:27 +02:00
Torkel Ödegaard
d70c81f03b more angular 1.3 upgrade fixes 2014-08-06 09:10:18 +02:00
Torkel Ödegaard
387ec89b95 more angular 1.3 upgrade changes 2014-08-06 09:05:03 +02:00
Torkel Ödegaard
60dd68490c working on angular upgrade 2014-08-06 08:16:54 +02:00
Torkel Ödegaard
378e55ed0c small changelog update 2014-08-05 15:37:09 +02:00
Torkel Ödegaard
16900ad421 Small fixes for 1.7 release 2014-08-05 13:22:54 +02:00
Torkel Ödegaard
0bf1e8f252 Readme fixes 2014-08-05 12:29:58 +02:00
Torkel Ödegaard
0aa5505d7f Updated readme, and other small changes for 1.7.0-rc1 release 2014-08-05 12:27:03 +02:00
Torkel Ödegaard
60f68abd31 Dashboard schema simplifications, moved schema updates to dashboard model creation, removes irritating 'unsaved changes' dialogs that show for dashboard schema changes, Closes #532 2014-08-05 10:15:51 +02:00
Torkel Ödegaard
0a677449dc Fixed issue in dashboard settings modal and timepicker options 2014-08-04 15:52:41 +02:00
Torkel Ödegaard
6e9723325f Fixed issue span set to zero. Removed zero option from row editor. Closes #645 2014-08-04 12:26:53 +02:00
Torkel Ödegaard
e9a046e74d Small annotation fix when leaving edit mode and having series hidden 2014-08-04 07:18:26 +02:00
Torkel Ödegaard
44f0c749d5 Fix for InfluxDB temp dashboards, seperate series name prefix so they do not show up in dashboard search, #633 2014-08-03 12:20:42 +02:00
Torkel Ödegaard
082d2c739e updated changelog with #641 change 2014-08-03 12:12:38 +02:00
Torkel Ödegaard
6354b1aec0 Merge branch 'jordanrinke-master' 2014-08-03 12:08:17 +02:00
Torkel Ödegaard
512dbf1980 Refactoring temp dashboard settings, and handling, moved from dashboard to config.js, defaults are enabled, and ttl of 30 days, #641, #638 2014-08-03 12:07:50 +02:00
Torkel Ödegaard
ed491b0caf Merge branch 'master' of github.com:jordanrinke/grafana into jordanrinke-master 2014-08-01 15:29:29 +02:00
Torkel Ödegaard
d6814587ad Update changelog and config sample 2014-08-01 11:34:57 +02:00
Torkel Ödegaard
586399a814 Graphite: Fix for graphite expressions parser failure when metric expressions starts with curly brace segment, Fixes #528 2014-08-01 09:28:57 +02:00
Torkel Ödegaard
867186fd66 Filtering: Fix for nested filters, changing a child filter could result in infinite recursion in some cases, Fixes #628 2014-08-01 08:54:22 +02:00
Jordan Rinke
48c18ee8d1 fixed 2 coding errors noted by travis 2014-07-31 13:48:28 -07:00
Jordan Rinke
f5d5d9a504 fixed 2 coding errors noted by travis 2014-07-31 13:45:17 -07:00
Jordan Rinke
f958924b79 added saving and showing temp searches also trailing comman in default.json was causing the default to fail to load for me, #633 2014-07-31 12:37:35 -07:00
Torkel Ödegaard
67582aaee4 cleanup of 'loader' settings, removed loader.save_elasticsearch, loader.load_elasticsearch. Save/Load is default enabled and will use any datasource marked with grafanaDB: true property 2014-07-31 14:20:53 +02:00
Torkel Ödegaard
8ebe260628 Added support for deleting dashboards to influxdb datasource, #633 2014-07-31 12:39:49 +02:00
Torkel Ödegaard
a6d2590834 Merge PR #618 2014-07-31 12:28:11 +02:00
Torkel Ödegaard
923cd045cd Changed opentsdb metric option chartLabel to Alias to better conform to grafana naming, updated changelog with PR #618 info 2014-07-31 12:27:49 +02:00
Torkel Ödegaard
f64bcf0d08 Merge branch 'master' of github.com:heldr/grafana into heldr-master 2014-07-31 12:16:07 +02:00
Torkel Ödegaard
c48b6e23eb Updated changelog with PR #626 2014-07-31 11:22:20 +02:00
Torkel Ödegaard
b2eabda5b6 Merge branch 'master' of github.com:kamaradclimber/grafana into kamaradclimber-master 2014-07-31 11:17:08 +02:00
Torkel Ödegaard
305e12be1d Updated changelog and config.sample.js with info about #633 2014-07-31 11:11:33 +02:00
Torkel Ödegaard
30ad784d95 Changed dashboard urls from /dashboard/elasticsearch/<title> to dashboard/db/<title>, old urls will still work 2014-07-31 11:06:02 +02:00
Torkel Ödegaard
7be7b07c19 Changed search result model to be more datasource agnostic 2014-07-31 10:54:36 +02:00
Torkel Ödegaard
88c46f4612 Merge branch 'influxdb_dashstore' 2014-07-31 10:37:17 +02:00
Torkel Ödegaard
1c1b9b5c9d InfluxDB: save/load and search works, tag facets still to be done, but is not critical, #633 2014-07-31 10:36:45 +02:00
Gregoire Seux
f5f3256824 Downscale y axis to more precise unit
y axis unit is already upscaled automatically, this commit adds
automatic downscale.
It also fixes the number of decimals displayed (0 -> decimals)
2014-07-31 09:40:23 +02:00
Torkel Ödegaard
d056b1f1e1 Search: max_results config.js option & scroll in search results (To show more or all dashboards), Closes #631 2014-07-31 09:17:37 +02:00
Torkel Ödegaard
c86a30921f Save/load dashboard from/to influxdb works, #633 2014-07-30 15:38:09 +02:00
Torkel Ödegaard
14f09e3787 Added filtering support for graphite events/metrics, Closes #402 2014-07-30 13:09:23 +02:00
Torkel Ödegaard
d2a342a94e Merge branch 'elastic_annotations'
Conflicts:
	src/css/bootstrap.dark.min.css
	src/css/bootstrap.light.min.css
	src/css/default.min.css
2014-07-30 11:36:47 +02:00
Torkel Ödegaard
c61e4c02bd further work on unifying datasources, #630 2014-07-30 11:34:09 +02:00
Torkel Ödegaard
b8ce61ae45 General architectural changes around datasources, unifying dashboard loading behind datasource abstraction, #630 2014-07-30 10:52:02 +02:00
Torkel Ödegaard
5a25b0885c added datasource filtering based on datasource abilities 2014-07-30 08:34:58 +02:00
Torkel Ödegaard
337cbb2844 Ctrl+H (hide controls) issue introduced in recent commit, Closes #625 2014-07-29 17:50:09 +02:00
Torkel Ödegaard
fa3b84a615 Elastic search annotations are working, need to refactor and unify datasource abstraction more, #201 2014-07-29 17:24:42 +02:00
Torkel Ödegaard
4e47447dec began work on ES annotation datasource, #201 2014-07-29 11:26:05 +02:00
Torkel Ödegaard
a1772d26b5 New global option in config.js to specify admin password (useful to hinder some users from accidentally making changes), Closes #606 2014-07-29 09:45:07 +02:00
Torkel Ödegaard
77e5e75b2f Fixed ngmin build issue introduced in route refactoring, Fixes #622 2014-07-29 08:13:23 +02:00
Torkel Ödegaard
77bfd85e9e Changed all kibana words to grafana 2014-07-28 18:11:52 +02:00
Torkel Ödegaard
272ea9fe17 Added global datasource config option cacheTimeout for graphite datasource, #266 2014-07-28 17:54:32 +02:00
Torkel Ödegaard
8aed1aa634 Fix for cacheTimeout undefined value, #266 2014-07-28 17:01:48 +02:00
Torkel Ödegaard
2bec41b80e Graphite: new option available in metrics view to set cacheTimeout, will override default memcache timeout, Closes #266 2014-07-28 15:01:00 +02:00
Torkel Ödegaard
38633b6db4 Merge branch 'develop' 2014-07-28 12:41:51 +02:00
Torkel Odegaard
e62dc00d7b Fix for build issues on windows, Fixes #574 2014-07-28 11:08:19 +02:00
Torkel Ödegaard
f619fc3e7e merge with master 2014-07-25 12:37:39 +02:00
Torkel Ödegaard
6c7d74c43b updated changelog with PR #604 2014-07-25 12:36:23 +02:00
Torkel Ödegaard
268cead331 Merge pull request #604 from floored1585/add_bps
Adding bps unit type for network gear
2014-07-25 12:30:13 +02:00
Torkel Ödegaard
70521f0756 InfluxDB: support for InfluxDB v0.8 'list series' response schema, Fixes #610 2014-07-25 12:14:15 +02:00
Helder Santana
1f283d93ca add opentsdb chart label field 2014-07-23 14:19:21 -04:00
Torkel Ödegaard
7dc422887c Merge pull request #615 from lathan/english_syntax
english syntax fix
2014-07-23 13:36:34 +02:00
Torkel Ödegaard
7dea0dcfc4 Merge pull request #616 from guequierre/master
'list series' instead of 'select * from /.*/ limit 1'
2014-07-23 13:34:51 +02:00
guequierre
ab11604bfb 'list series' instead of 'select * from /.*/ limit 1'
'list series' response is much faster than 'select * from /.*/ limit 1' for the auto-complete option. Especially noticeable on large datasets.
2014-07-23 12:37:11 +02:00
George Angelopoulos
0e8c026854 english syntax fix
Add a comma to clearly separate the two clauses of the conditional sentence.
Otherwise, it's unclear whether it is referring to "the panel below" or
"the panel below the browser".
2014-07-23 12:47:52 +03:00
Torkel Ödegaard
3b1cc1cc34 removed old timezoneOffset setting 2014-07-22 08:56:12 +02:00
Torkel Ödegaard
85a8f2f147 another small fix for timezone and annotations, #611 2014-07-21 18:52:19 +02:00
Torkel Ödegaard
37c43199ca Fix for annotations hover tooltip and timestamp when timezone set to utc, Fixes #611, #394 2014-07-21 18:49:30 +02:00
Torkel Ödegaard
f22fcc2e59 updated changelog 2014-07-20 18:12:54 +02:00
Torkel Ödegaard
05d7d58cd5 Merge branch 'master' into develop 2014-07-20 18:09:01 +02:00
Torkel Ödegaard
10e89f6802 small tweek to plot hover and annotation hover tooltip css 2014-07-20 18:08:05 +02:00
Torkel Ödegaard
551b802d89 Annotation datasource redesign is done, Closes #608 2014-07-20 16:32:09 +02:00
Torkel Ödegaard
5ae8607771 Fixed dashboard import, broken by dashboard loading redesign #609 2014-07-19 19:06:28 +02:00
Torkel Ödegaard
7b47f40979 better formating of changelog 2014-07-19 18:41:25 +02:00
Torkel Ödegaard
a9a76b9010 annotation redesign is almost done, #608 2014-07-19 13:16:47 +02:00
Torkel Ödegaard
cf68725c89 influxdb annotation column mapping is working 2014-07-18 19:19:30 +02:00
Ian Clark
989d703d1d Adding bps unit type for network gear 2014-07-17 16:52:12 -07:00
Torkel Ödegaard
cf2ef0955d influxdb annotations working, need to figure out how to know which columns to use for title, tags, and data 2014-07-17 10:24:30 +02:00
Torkel Ödegaard
2fe3b0de55 influxdb annoations starting to work 2014-07-16 18:51:51 +02:00
Torkel Ödegaard
b47047a91d Merge branch 'master' into annotations_redesign 2014-07-16 13:18:21 +02:00
Torkel Ödegaard
1c56ac7e48 changed css concat order 2014-07-16 13:17:55 +02:00
Torkel Ödegaard
47fb553d38 Merge pull request #593 from Kixeye/master-fixfilterqueries
influxdbDatasource.js - fix find query
2014-07-16 07:47:24 +02:00
Dave Ertel
bd6362f09f influxdbDatasource.js - fix find query 2014-07-16 14:03:44 +10:00
Torkel Ödegaard
9cc735bdf2 fixed small css bug with the 'no datapoints' warning introduced by legends makeover 2014-07-15 16:57:23 +02:00
Torkel Ödegaard
f5d992f609 InfluxDB: Support for alias & alias patterns when using raw query mode, #584 2014-07-15 16:46:17 +02:00
Torkel Ödegaard
25407fb5f0 updated readme.md 2014-07-15 11:32:03 +02:00
Torkel Ödegaard
9eb9bd8488 moved annotations graphite query to graphite datasource 2014-07-14 18:19:41 +02:00
Torkel Ödegaard
7d6eafb2f2 Merge branch 'dashboard_loading_refactoring' into annotations_redesign 2014-07-14 17:28:19 +02:00
Torkel Ödegaard
bfdf25a162 Merge branch 'master' into dashboard_loading_refactoring 2014-07-14 17:28:00 +02:00
Torkel Ödegaard
6e0e6f5ec4 updated changelog with PR #581 2014-07-14 17:26:16 +02:00
Torkel Ödegaard
dce8b15937 Merge branch 'feature/influxdb-expose-continuous-query-in-series' of github.com:mavimo/grafana into mavimo-feature/influxdb-expose-continuous-query-in-series 2014-07-14 17:20:28 +02:00
Marco Vito Moscaritolo
25e2e07631 ADd contiuous query in series results. 2014-07-13 19:57:09 +02:00
Torkel Ödegaard
b5fb8b6d82 fixed jscs errors 2014-07-13 15:15:10 +02:00
Torkel Ödegaard
171c5aa50c began work on annotations redesign to easier support more annotation sources, #133, #394, #403 2014-07-13 15:01:20 +02:00
Torkel Ödegaard
b5d378c425 Merge branch 'master' into dashboard_loading_refactoring 2014-07-13 12:51:22 +02:00
Torkel Ödegaard
145d65fd60 removed commented out html in graph module 2014-07-13 12:49:54 +02:00
Torkel Ödegaard
5c78fe1070 fixed jshint error 2014-07-08 08:36:59 +02:00
Torkel Ödegaard
31b1203317 fixed failing unit test 2014-07-07 19:04:22 +02:00
Torkel Ödegaard
eaa200a766 Fix for Max legend value when max value is zero (Issue #460) 2014-07-04 11:50:11 +02:00
Torkel Ödegaard
f422c84414 extra fix for percent sign in aliases and plothover, #506 2014-07-03 16:28:38 +02:00
Torkel Ödegaard
4562f31b6b merged with master 2014-07-03 16:25:07 +02:00
Torkel Ödegaard
6911e184f9 New legend display option 'Right side', will show legend to the right of the graph (Closes #556) 2014-07-03 12:38:20 +02:00
Torkel Ödegaard
9627212510 fixed failing unit test 2014-07-03 09:30:44 +02:00
Torkel Ödegaard
0fc8c4e071 small changes to influxdb aliasing, and help text, #525 2014-07-03 09:27:11 +02:00
Torkel Ödegaard
6c93dc6a4c Some changes to influxdb alias pattern expansions, removed as it was to confusion, added help text to influxdb metric editor view, need to polish a litle more, #525 2014-07-02 15:50:57 +02:00
Torkel Ödegaard
1dbbfbbba6 Enhanced InfluxDB series aliasing (legend names) with pattern replacements (Issue #525) 2014-07-02 15:21:29 +02:00
Torkel Ödegaard
88ab36c45b added y2 text after right y axis series, when legend is in table display mode #136 2014-07-02 13:00:33 +02:00
Torkel Ödegaard
14247ddabb New legend display option 'Align as table' (Issue #136) 2014-07-02 12:13:42 +02:00
Torkel Ödegaard
fd8561ac55 added missing file from last commit 2014-07-01 20:01:56 +02:00
Torkel Ödegaard
e1e6ba36ca Refactoring influxdb datasource, split out response handling 2014-07-01 15:55:56 +02:00
Torkel Ödegaard
435a50de4b Merge pull request #550 from Fuitad/master
Fixed invalid references to grid.min and grid.max in function render_panel_as_graphite_png()
2014-06-30 20:45:36 +02:00
Pierre-Luc Brunet
93b2b9b7b0 Fixed invalid references to grid.min and grid.max in function render_panel_as_graphite_png() 2014-06-30 12:13:39 -04:00
Torkel Ödegaard
faa5199a9a removed gist loading/saving 2014-06-30 09:46:34 +02:00
Torkel Ödegaard
5768d7a247 Merge branch 'master' into dashboard_loading_refactoring
Conflicts:
	src/app/partials/dashboard.html
	src/app/partials/dasheditor.html
	src/app/services/graphite/graphiteDatasource.js
2014-06-30 09:21:16 +02:00
Torkel Ödegaard
d9f2fca66d Merge branch 'dashboard_loading_refactoring' of github.com:torkelo/grafana-private into dashboard_loading_refactoring 2014-06-30 09:20:07 +02:00
Torkel Ödegaard
91b48258f0 Refactoring PR #511, Allow filter notation [[..]] in text panels 2014-06-30 09:10:32 +02:00
Torkel Ödegaard
2ac7b9dabf Merge branch 'master' of github.com:Akeru/grafana into Akeru-master 2014-06-30 08:05:48 +02:00
Torkel Ödegaard
505f0f65d0 updated change log with PR #545 2014-06-30 07:56:35 +02:00
Torkel Ödegaard
8262a8dea2 Merge pull request #545 from Akeru/fix-format
Fix formatting negative values
2014-06-30 07:32:11 +02:00
Torkel Ödegaard
406286b970 Merge pull request #544 from Akeru/diffseries
Add diffSeries function support
2014-06-30 07:29:44 +02:00
Akeru
6346f835af Fix formatting negative values 2014-06-27 15:37:11 +02:00
Akeru
73fc437c7d Add diffSeries function support 2014-06-27 15:24:06 +02:00
Torkel Ödegaard
af66739207 Merge pull request #543 from Akeru/html-fix
Fix HTML code
2014-06-27 14:03:56 +02:00
Akeru
65bb6a8b73 Fix HTML code 2014-06-27 13:52:43 +02:00
Torkel Ödegaard
8bda5aa2a7 Merge pull request #539 from looztra/opentsdb-fix-tag-display
Display tag values whenever a tag is part of the query (opentsdb)
2014-06-26 06:59:23 +02:00
Christophe Furmaniak
dd2b43dc73 Display tag values whenever a tag is part of the query (opentsdb datasource) 2014-06-25 23:56:25 +02:00
Torkel Ödegaard
c925014bb5 Use unix epoch for Graphite from/to for absolute time ranges, #536 2014-06-25 10:09:19 -04:00
Torkel Ödegaard
32b11b104f updated version to 1.6.1 2014-06-24 15:06:51 +02:00
Torkel Ödegaard
e25a73f9af updated default dashboard info text 2014-06-24 13:57:46 +02:00
Torkel Ödegaard
15c1b48b25 merged with master 2014-06-22 19:01:04 +02:00
Torkel Ödegaard
d14a86069a Auto-refresh caused 2 refreshes (and hence mulitple queries) each time (at least in firefox) (Fixes #342) 2014-06-22 18:51:27 +02:00
Torkel Ödegaard
186f753aec style changing now works again 2014-06-22 18:21:38 +02:00
Torkel Ödegaard
f180707b6f Merge branch 'master' into dashboard_loading_refactoring 2014-06-22 18:04:37 +02:00
Torkel Ödegaard
9a53779b6c Default property that marks which datasource is default in config.js is now optional (Fixes #526) 2014-06-22 18:02:43 +02:00
Torkel Ödegaard
551771c6cf ixed influxdb issue with raw query that caused wrong value column detection (Fixes #504) 2014-06-22 12:01:41 +02:00
Torkel Ödegaard
a3aca0bae4 restored influxdb series naming default to series.value_func 2014-06-22 11:53:58 +02:00
Torkel Ödegaard
ed0c71fa56 Series names and column name typeahead cache fix (Fixes #522) 2014-06-22 11:27:36 +02:00
Torkel Ödegaard
574ecdb512 fixed column typehead, introduced in PR #500 2014-06-22 11:27:36 +02:00
Torkel Ödegaard
7848a35941 Merge pull request #524 from acedrew/master
Added nginx config examples to docs.
2014-06-21 22:07:04 +02:00
Andrew Rodgers
dfe0314ba0 Added nginx config examples for CORS headers, and CORS selective reflection 2014-06-21 16:17:45 +00:00
Andrew Rodgers
4618ef0cbf Merge branch 'docs-improvement'
Added nginx config examples, including CORS header reflection.
2014-06-21 16:11:53 +00:00
Andrew Rodgers
bb281649fc prepare for master branch after all sorts of git shenanigans 2014-06-21 16:11:36 +00:00
Torkel Ödegaard
012ffcf6f6 Bug in when using % sign in legends (aliases), fixed by removing url decoding of metric names (Fixes #506) 2014-06-21 17:27:57 +02:00
Torkel Ödegaard
bef61cf019 Ability to set y min/max for right y-axis (RR #519, Closes #360) 2014-06-21 17:18:24 +02:00
Andrew Rodgers
5ce6464461 Revert "added nginx conf examples for graphite CORS configuration"
This reverts commit c37496f2b0.
2014-06-20 03:01:13 +00:00
Andrew Rodgers
a0c3f99d80 Revert "updated nginx conf examples for graphite CORS configuration"
This reverts commit be03f6adb6.
2014-06-20 03:00:50 +00:00
Andrew Rodgers
f6ba577cf4 Revert "updated nginx conf examples for graphite CORS configuration"
This reverts commit 9edaa407f2.
2014-06-20 03:00:31 +00:00
Andrew Rodgers
6ef03b7c6c Revert "Revert "Added left and right min and max for y-axis""
This reverts commit 05303dab45.
2014-06-20 02:59:52 +00:00
Andrew Rodgers
05303dab45 Revert "Added left and right min and max for y-axis"
This reverts commit 8743ba2886.
2014-06-20 02:54:34 +00:00
Andrew Rodgers
9edaa407f2 updated nginx conf examples for graphite CORS configuration 2014-06-20 02:44:45 +00:00
Andrew Rodgers
be03f6adb6 updated nginx conf examples for graphite CORS configuration 2014-06-20 02:42:18 +00:00
Andrew Rodgers
c37496f2b0 added nginx conf examples for graphite CORS configuration 2014-06-20 02:40:01 +00:00
Andrew Rodgers
8743ba2886 Added left and right min and max for y-axis 2014-06-19 21:49:49 +00:00
Akeru
c100054d68 Allow [[..]] filter notation in all text panels
Based on #408 with fixed filter service method. Supports html, text and
markdown panels.
2014-06-18 17:28:40 +02:00
Torkel Ödegaard
2fbb87e17a fix jshint and updated changelog with PR #500 2014-06-17 18:09:10 +02:00
Pauly Myjavec
1eadf52f5e Fixes regex InfluxDB queries intoduced in 1.6.0
Do not encapsulate regex with quotes in query string
Fix the way series names are displayed, do not use column name but
rather series names
2014-06-17 22:38:52 +10:00
Torkel Ödegaard
810f46c450 updated karma dependencies in package.json 2014-06-16 12:40:41 +02:00
Torkel Ödegaard
393dfd1e96 changed version to 1.6.0 2014-06-16 12:24:04 +02:00
Torkel Ödegaard
011e95b331 Graphite query lexer change, can now handle regex parameters for aliasSub function (Fixes #126) 2014-06-16 08:14:34 +02:00
Torkel Ödegaard
9f3681642a Merge branch 'dashboard_loading_refactoring' of github.com:torkelo/grafana-private into dashboard_loading_refactoring 2014-06-14 14:55:29 +02:00
Torkel Ödegaard
a4ca679b65 Merge branch 'master' of github.com:torkelo/grafana-private into dashboard_loading_refactoring 2014-06-14 14:54:55 +02:00
Torkel Ödegaard
d198095d7a Merge branch 'master' into dashboard_loading_refactoring 2014-06-14 14:51:09 +02:00
Torkel Ödegaard
da451d013a Refactoring and rewrite parts of influxdb group by feature from PR #441 2014-06-14 14:40:22 +02:00
Torkel Ödegaard
d18244a8a1 removed commented out sections of the opentsdb datasource 2014-06-14 11:53:16 +02:00
Torkel Ödegaard
6214872e0c Merge branch 'master' of github.com:grafana/grafana 2014-06-14 11:39:44 +02:00
Torkel Ödegaard
6885cea0fd Improvement and polish to the OpenTSDB query editor (Issue #492) 2014-06-14 11:38:27 +02:00
Torkel Ödegaard
438455bc8c finally removed elasticjs library 2014-06-13 13:58:34 +02:00
Torkel Ödegaard
7914f65f68 removed redundant load/save options 2014-06-13 13:50:09 +02:00
Torkel Ödegaard
d0b79ad335 now dashboard deleting works 2014-06-12 17:40:37 +02:00
Torkel Ödegaard
7dc4484f6a Renamed dashboard service to dashboardModel, fixed saving default dashboard feature 2014-06-12 17:03:52 +02:00
Torkel Ödegaard
257ea391da fixed issues with unsaved changes srv 2014-06-12 16:35:58 +02:00
Torkel Ödegaard
4c64bcfae7 keyboard binding now work again 2014-06-12 13:37:40 +02:00
Torkel Ödegaard
99d2f537c2 sharing temp dashboard is now working again 2014-06-11 20:22:05 +02:00
Torkel Ödegaard
6c32365e00 more work on refactoring ES usage 2014-06-11 08:19:52 +02:00
Torkel Ödegaard
95925aafb1 removed dependence on elasticsearch js client from search, will try to remove this depdence in other places and just use $http, elasticsearch js client is to big and does not provide enough value 2014-06-11 08:11:13 +02:00
Torkel Ödegaard
77bfaa4245 fixed default dashboard json editable flag, accidentally set to to false 2014-06-11 08:07:18 +02:00
Torkel Ödegaard
0a3d4a5ab0 elasticsearch saving does now work, still have to do ttl and temp dashboard 2014-06-10 21:32:38 +02:00
Torkel Ödegaard
e8c11251de fix for build step that replaces @grafanaVersion@ with correct version string 2014-06-09 16:59:53 +02:00
Torkel Ödegaard
87a8b1b3f5 small fix to config.sample.js 2014-06-09 13:33:30 +02:00
Torkel Ödegaard
2328c60d12 small refactoring progress 2014-06-08 20:46:30 +02:00
Torkel Ödegaard
61cd5cf4e6 fixed jshint and jscs checks 2014-06-08 16:09:36 +02:00
Torkel Ödegaard
1eb9efe2d5 fixing broken things 2014-06-08 16:08:12 +02:00
Torkel Ödegaard
d5882f2efe ES and file loading is working 2014-06-08 15:28:50 +02:00
Torkel Ödegaard
5f3991127b refactoring progress 2014-06-08 14:40:44 +02:00
Torkel Ödegaard
c5d2590293 removed unused code 2014-06-08 13:00:59 +02:00
Torkel Ödegaard
b995dc54f1 further refactoring 2014-06-07 21:00:05 +02:00
Torkel Ödegaard
79404e754e started on some big refactoring of how the app starts and how dashboard object is loaded, created. This should make it easier to add other dashboard storage backends and other views 2014-06-07 19:43:15 +02:00
Torkel Ödegaard
92318d5804 small fix for click on row menu submenus 2014-06-07 09:05:30 +02:00
Torkel Ödegaard
191f9daf4d update changelog 2014-06-07 08:16:34 +02:00
Torkel Ödegaard
b67280f0d4 Merge pull request #476 from lyrixx/axis-s-week
Format seconds metric by week if needed
2014-06-07 07:06:53 +02:00
Torkel Ödegaard
ce8bdabab8 Adding JSCS (javascript style checker) 2014-06-07 07:05:42 +02:00
Grégoire Pineau
b40af07103 Format seconds metric by week if needed 2014-06-07 02:06:34 +02:00
Torkel Ödegaard
f3698cd625 Cleanup of config.sample.js, removed graphiteUrl setting, it will still work for next release 2014-06-06 23:33:33 +02:00
Clicky
c928618d1a Formatting. 2014-06-06 11:59:02 -07:00
Clicky
3cc83ced93 Merge branch 'master' into add-influx-group-by
Conflicts:
	.gitignore
	src/app/partials/influxdb/editor.html
	src/app/services/influxdb/influxdbDatasource.js
2014-06-06 11:52:02 -07:00
Torkel Ödegaard
0ad4f3b85e Row editing and adding new panel is now a lot quicker and easier with the new row menu (Issue #475) 2014-06-06 18:30:15 +02:00
Torkel Ödegaard
2d061ce45a changed default row height to 250px 2014-06-06 16:05:56 +02:00
Torkel Ödegaard
6e2348d2b1 renamed graphite panel to graph 2014-06-06 16:03:39 +02:00
Torkel Ödegaard
525c4d529e cleanup, removal of unused code 2014-06-06 15:51:49 +02:00
Torkel Ödegaard
ea84149c87 Fix for exclusive series toggling (hold down CTRL, SHIFT or META key) and left click a series for exclusive toggling
CTRL does not work on MAC OSX but SHIFT or META should (depending on browser) (Closes #350, Fixes #472)
2014-06-06 11:23:17 +02:00
Torkel Ödegaard
af1855601b Improvement to InfluxDB query editor and function/value column selection, more space efficient, Closes #473 2014-06-06 10:56:38 +02:00
Torkel Ödegaard
1409065005 Merge branch 'master' into mavimo-feature/influxdb-filters 2014-06-06 08:59:06 +02:00
Torkel Ödegaard
623019ee56 Merge branch 'master' of github.com:grafana/grafana 2014-06-06 08:58:24 +02:00
Torkel Ödegaard
740d477801 added a little padding for metric target editor rows, making tthem sligly heigher 2014-06-06 08:58:14 +02:00
Torkel Ödegaard
c2b8f21fd9 small changes to PR #327, Partial support for url encoded metric names when using graphite datasource 2014-06-05 20:50:14 -07:00
Torkel Ödegaard
442ed87cfa Merge branch 'urldecode' of github.com:axe-felix/grafana into axe-felix-urldecode 2014-06-05 20:17:11 -07:00
Torkel Ödegaard
c48b3ded2f Fix for graphite function selection menu that some times draws outside screen. It now displays upward (Fixes #293) 2014-06-03 19:07:59 -07:00
Torkel Ödegaard
5bed5b9870 Fixing PR for influxdb filters 2014-06-03 21:23:42 +02:00
Torkel Ödegaard
2a261a32e2 Merge branch 'feature/influxdb-filters' of github.com:mavimo/grafana into mavimo-feature/influxdb-filters 2014-06-03 21:06:36 +02:00
Torkel Ödegaard
7137a9986f Fix to series toggling bug that caused annotations to be hidden when toggling (hiding) series. Fixes #328 2014-06-03 06:28:16 -07:00
Torkel Ödegaard
4ce386c6dd updated changelog - merge 2014-06-03 06:10:32 -07:00
Torkel Ödegaard
8911da8380 updated changelog 2014-06-03 06:08:42 -07:00
Torkel Ödegaard
a3384d514f Merge pull request #461 from tmonk42/isNonNull
add graphite function isNonNull
2014-06-03 06:05:32 +02:00
Haneysmith, Nathan
b38f6e8062 add graphite function isNonNull 2014-06-02 16:01:42 -07:00
Clicky
6c006d0a78 Don't retry on http status codes >= 300
These status codes are likely to be to be unretryable errors coming from
influx (most likely bad queries)
2014-06-02 13:15:10 -07:00
Torkel Ödegaard
0f7a55d031 improved asset (css/js) build pipeline, added revision to css and js. Will remove issues related to the browser cache when upgrading grafana and improve load performance (Fixes #418) 2014-06-02 20:29:30 +02:00
Torkel Ödegaard
62af77979b Legend Current value did not display when value was zero, Fixes #460 2014-06-02 19:29:59 +02:00
Torkel Ödegaard
384687e19b Added parameter to keepLastValue graphite function definition (default 100), Closes #459 2014-06-02 19:17:05 +02:00
Torkel Ödegaard
f799ded434 worked on css and js asset reving, and angular partial precaching, still need to fix panel module.html, issue #418 2014-06-01 16:57:59 +02:00
Torkel Ödegaard
d499f4e0d0 build system changes 2014-05-31 15:32:00 +02:00
Torkel Ödegaard
fc7b4df98a working on angular partials pre caching, reving 2014-05-31 15:20:12 +02:00
Torkel Ödegaard
3f9a8ecc7e Merge branch 'master' of github.com:grafana/grafana 2014-05-31 12:28:55 +02:00
Torkel Ödegaard
71a801bbb7 updated changelog 2014-05-31 11:54:43 +02:00
Torkel Ödegaard
f333ef803a Merge pull request #455 from casa87/patch-1
influxdb:difference feature
2014-05-31 10:33:08 +02:00
Torkel Ödegaard
36b1dce7e4 trying to get css, and js build file revisioning working 2014-05-31 00:22:49 -07:00
Torkel Ödegaard
877ef36bc7 added css concat task 2014-05-30 22:46:39 -07:00
casa87
6ce242df4d Fix line length 2014-05-30 16:01:25 -07:00
casa87
9640f0251c influxdb:difference feature
Add support for the difference query from InfluxDB
2014-05-30 14:40:43 -07:00
Torkel Ödegaard
53846a15de fixed issue with influxdb datasource introduced in recent filterSrv refactoring 2014-05-29 22:17:01 -07:00
Torkel Ödegaard
1e4ff1e774 Added config setting for default playlist timespan 2014-05-29 21:05:49 -07:00
Torkel Ödegaard
0f40e06d93 Merge branch 'timespanconfig' of github.com:rmca/grafana into rmca-timespanconfig 2014-05-29 20:53:51 -07:00
Torkel Odegaard
86b204ac08 fixed failing unit test 2014-05-27 20:13:49 +02:00
Torkel Ödegaard
8cd5a9963f Fixes for filter option loading and nested filters. Fixes #447, Fixes #412 2014-05-27 19:21:21 +02:00
Torkel Ödegaard
df796e32eb fixed issue with filtersrv refactoring and removing filter parameter 2014-05-27 18:29:14 +02:00
Torkel Ödegaard
e2dae1f484 cleanup of unused code, small style changes 2014-05-27 18:18:05 +02:00
Torkel Ödegaard
8ca06e11de refactoring unsavedChangesSrv and who now owns original 2014-05-27 17:17:12 +02:00
Torkel Ödegaard
9f548b9dee filterSrv refactoring fixes 2014-05-27 16:39:16 +02:00
rob
31c75886c3 Making the default playlist timespan configurable. 2014-05-26 13:12:26 +01:00
Torkel Ödegaard
3e24a87ead trying to get this PR working. a lot has changed and is broken 2014-05-25 21:03:53 +02:00
Torkel Ödegaard
992bcccee9 Merge branch 'master' into Tetha-hkraemer-filtersrv-object-refactoring 2014-05-25 19:08:28 +02:00
Torkel Ödegaard
02bf5f9a58 updated changelog with PR #390, special characters in series names (influxdb) 2014-05-25 17:04:51 +02:00
Torkel Ödegaard
adaf9cbc90 merge PR #390 2014-05-25 17:00:51 +02:00
Clicky
f9ede4bae9 Check for negative return 2014-05-23 11:46:36 -07:00
Clicky
1fe9132761 Cleanup from jshint 2014-05-22 23:14:43 -07:00
Clicky
fe89c101df Add tooltip messages to icons in query editor. 2014-05-22 20:12:59 -07:00
Clicky
6cc7f012d8 Cleanup the influx query parsing 2014-05-22 20:09:02 -07:00
Clicky
3b82ac00d8 Fix typos in condition names 2014-05-22 18:18:22 -07:00
Clicky
9b4c64298b Hookup additional group by into UI
Allow additional group by fields to be specified without writing a full
on influx query by hand.
2014-05-22 18:11:04 -07:00
Clicky
4a4708e3fd Fix single line naming 2014-05-22 16:52:34 -07:00
Clicky
f231af07f9 Parse additional group by columns from a raw query
This needs some further polishing but now parse out additional group by
columns from a raw query, although it really only supports one
additional column.
2014-05-22 16:08:25 -07:00
Clicky
3da1c27692 Proof of concept of multiple groups using "host"
Initial test to make sure this plan works using a predefined alternate
group by. Now to actually figure this out based on the query and add
some UI for it.
2014-05-22 15:20:10 -07:00
Torkel Ödegaard
beca72cc40 filterSrv refactoring cleanup and testing 2014-05-20 16:18:24 +02:00
Torkel Ödegaard
5ea07d0f07 Merge branch 'hkraemer-filtersrv-object-refactoring' of github.com:Tetha/grafana into Tetha-hkraemer-filtersrv-object-refactoring 2014-05-20 15:45:46 +02:00
Harald Kraemer
674390dfa2 Fixed unsaved changes alerting about timechanges only. 2014-05-20 12:40:56 +02:00
Torkel Ödegaard
e47994013a updated changelog with PR #427 2014-05-20 12:04:23 +02:00
Torkel Ödegaard
6bbf2ff876 Merge pull request #427 from jippi/add-second-axis
Add seconds as a new axis formatter
2014-05-20 03:00:31 -07:00
Christian Winther
f7f567adc8 Add seconds as a new axis formatter 2014-05-20 08:55:19 +00:00
Harald Kraemer
e737b51e9d Removed 2 console.logs 2014-05-20 10:24:03 +02:00
Harald Kraemer
6f2dd2e2a5 Fixed an old method name 2014-05-20 10:23:49 +02:00
Harald Kraemer
36b44d6971 Moved init calls to setup method 2014-05-20 10:23:36 +02:00
Harald Kraemer
dcea2c5f4e Fixed last test + a mistake in other tests setup
- filterSrv expects the parameter to init to be the actual
   dashboard object (I'll depend on that later on), so
   I had to pass dashboard.current in there, instead of
   dashboard
 - in the last test, the problem was exactly that again.
2014-05-20 10:00:15 +02:00
Harald Kraemer
ed76d718cd Fixed setTime should disable refresh test
- init with dashboard mock
2014-05-20 09:56:50 +02:00
Harald Kraemer
00e1a1c442 Fixed timerange parsed = true test
- had to call init with dashboard mock
2014-05-20 09:54:07 +02:00
Harald Kraemer
f2b9ea1034 Fixed timerange unparsed
- had to call init with the dashboard mock, since this checks
   dashboard.refresh (need to look at that sometime)
2014-05-20 09:52:55 +02:00
Harald Kraemer
1cbc352c6c Fixed (filter->template)OptionSelected test
- small misunderstanding on my part, fixed the API in the filterSrv back
- renames to match my renames
- init script has to be called or fundefined things happen
2014-05-20 09:48:36 +02:00
Harald Kraemer
51b70a7884 Fixed init-test.
Mostly renames, new init semantic and I forgot to call
updateTemplateParams in addTemplateParameter
2014-05-20 09:43:57 +02:00
Harald Kraemer
d04f2d5e2b Renamed most filter-related things in filterSrv to template.
After all, we are using the function "template" to apply some
data we pull from the URL or other situations in order to call
a function called template. Hence, filtering doesn't make sense
as a term here.
2014-05-20 09:27:54 +02:00
Harald Kraemer
b1c9d5fd4a Warnings in filterSrv 2014-05-19 17:05:53 +02:00
Harald Kraemer
4b8b961705 Warnings in dashboardKeybindings.js 2014-05-19 17:04:59 +02:00
Harald Kraemer
2e26130d96 Warnings in graphiteTarget.js 2014-05-19 17:02:06 +02:00
Harald Kraemer
63c75f714f Warnings in dash.js 2014-05-19 17:01:09 +02:00
Harald Kraemer
03095dfa74 Changed filterSrv singleton into object in scope.
This rework isn't entirely complete here, I haven't
checked the tests yet and I didn't really test anything
furthermore yet, so bear with this commit breaking things.

Besides that, the goal of this commit was to rework the
filterSrv singleton into a factory, so we move the filterSrv
instance around via the scope. This should be a better solution
than the current situation, because services shouldn't contain
model data - the scope should.
This will eventually straighten out control flow between dashboard,
filters and so on, and allow us to leverage angularJS mechanics more.
The latter has already started, since I could rework a bit of the
existing event infrastructure to watches on times.
2014-05-19 15:31:30 +02:00
Harald Kraemer
f70bf61ff6 Added vim swp files to gitignore 2014-05-15 15:07:03 +02:00
Harald Kraemer
4a362704fd Moved dashboard keybinding setup to own service.
The goal is to split up the situation between the dashboard
controller and the current dashboard service. I want to be
able to use the routing in order to select various dashboard
controllers, so I can extend the current scripting
mechanism by implementing new dashboard controllers.

However, to do this in a non-insane way, I need to move as
much functionality as possible into services, so the individual
controllers just need to throw the right set of services
together and add a bit of loading logic.
2014-05-15 15:04:23 +02:00
Harald Kraemer
2c43fdc409 Merge branch 'master' of github.com:Tetha/grafana 2014-05-15 13:17:03 +02:00
Torkel Ödegaard
2a6a3a3af5 updated changelog 2014-05-13 20:20:28 +02:00
Torkel Ödegaard
d8e2192179 Updated version to 1.5.4 2014-05-13 19:08:46 +02:00
Torkel Ödegaard
cfc5fa87d0 Merge branch 'gridmin' of github.com:kamaradclimber/grafana into kamaradclimber-gridmin 2014-05-10 01:56:27 +02:00
Torkel Ödegaard
5ad95a1c3e Merge branch 'influxdb' of github.com:pmenglund/grafana into pmenglund-influxdb 2014-05-10 01:41:25 +02:00
Torkel Ödegaard
de8d456089 Merge branch 'master' of github.com:torkelo/grafana 2014-05-10 01:40:23 +02:00
Torkel Ödegaard
07610a5f92 small change to influxdb template to support older versions of influxdb 2014-05-10 01:40:08 +02:00
felixbarnsteiner
5d6998cf0b url decode metric names #327 2014-05-09 11:18:18 +02:00
Torkel Ödegaard
21b96068e4 Merge pull request #382 from ktoso/nanos-formatting
Added nanosecond y-scale formatting
2014-05-06 09:50:34 -07:00
Stefan Majer
c9df61c43c Quote timeseries names to be able to have special character such as @ in a seriename. 2014-05-06 08:42:49 +02:00
Stefan Majer
c1266abb98 Quote timeseries names to be able to have special character such as @ in a seriename. 2014-05-06 08:38:09 +02:00
Martin Englund
9dfb03aa0f use the influxdb built in time precision 2014-05-05 22:45:15 -07:00
Gregoire Seux
3a35dee0e3 Default to auto scaling for grid min setting
fixes #226
2014-05-05 09:33:45 +02:00
Torkel Ödegaard
f4568ef589 trying to get more unit tests working 2014-05-03 17:00:48 +02:00
Konrad 'ktoso' Malawski
f80871ce7e Added nanosecond y-scale formatting 2014-05-03 16:26:28 +02:00
Torkel Ödegaard
8fe4422d21 updated readme.md with new grafana organization urls 2014-05-01 15:00:56 +02:00
Torkel Ödegaard
c19fafa581 Improvement to series toggling, CTRL+MouseClick on series name will now hide all others (Closes #350) 2014-05-01 11:18:23 +02:00
Marco Vito Moscaritolo
cc43f15eab InfluxDB Filters: added filter to queries. 2014-05-01 00:44:42 +02:00
Marco Vito Moscaritolo
bfecb04697 InfluxDB Filters: added function to generate filter list. 2014-05-01 00:43:34 +02:00
Harald Kraemer
52e1f5273c Extracted multi-graphite query function, fixed loadRecursive
The new function in metricKeys generalizes what my loadAll
from the previous commit did, it takes a request and a
callback. The request is executed on each graphite installation
and the callback is executed for each result. This makes
implementing loadAll and loadRecursive almost as simple as
it was.
2014-04-30 13:13:51 +02:00
Torkel Ödegaard
2b5e974132 updated changelog with PR #369 2014-04-30 10:37:50 +02:00
Torkel Ödegaard
e3d7e3c195 Merge pull request #369 from jbripley/influxdb-columnname-escape
Change InfluxDB SQL generation template to wrap column names in quoutes
2014-04-30 10:33:47 +02:00
Joakim Bodin
11446b3e53 Change InfluxDB SQL generation template to wrap column names in quoutes
Since column names can contain dots or dashes, which will give syntax errors from InfluxDB API, unless wrapped in quoutes
2014-04-30 10:22:22 +02:00
Harald Kraemer
637c720de5 Modified metricKeys to handle multiple graphite sources.
This wasn't all too hard to change, I mostly changed the
single http get to multiple http gets, one for each data
source of type graphite.

It's still not a good idea to call this on the web
frontend, since the whole thing was working for about
20 - 30 minutes when I clicked it, so I'm not
committing my changes to settings.js or the view itself.
2014-04-30 09:40:06 +02:00
Torkel Ödegaard
0dae8f9977 removed unused function 'endsWithWildcard', fixes jshint error 2014-04-28 20:08:25 +02:00
Torkel Ödegaard
9c5674a076 Fixes to filters and the 'All' option. It now never uses '*' as value, but all options in a {node1, node2, node3} expression (Closes #228, Closes #359) 2014-04-28 19:58:25 +02:00
Torkel Ödegaard
35368442ec Merge pull request #356 from Tetha/master
Fixed an exception when adding a graphite function.
2014-04-28 12:09:49 +02:00
Torkel Ödegaard
035b5163fb Merge branch 'unsaved_changes_warning' (Closes #324) 2014-04-27 12:28:57 +02:00
Torkel Ödegaard
a1d5e26f6b Added onbeforeunload check to unsaved changes warning feature 2014-04-27 12:27:06 +02:00
Torkel Ödegaard
bdd2c9d033 More work on unsaved changes warning (Issue #324) 2014-04-27 12:22:38 +02:00
Torkel Ödegaard
8ad00faebc small progress on unsaved changes warning 2014-04-25 16:50:35 +02:00
Harald Kraemer
061bfffd4d Fixed an exception when adding a graphite function.
The error was that funcDef is just a string parsed from an event
like onMouseDown or something like that. This event is turned
into a function instance, and the function instance has
expected parameters and so forth. However, the number of
parameters was actually checked on the funcDef.
2014-04-25 16:48:17 +02:00
Torkel Ödegaard
bfb2376aa3 working on unsaved changes warning 2014-04-25 15:23:17 +02:00
Torkel Ödegaard
9e4656e43f New config setting for graphite datasource to control if json render request is POST or GET (Closes #345) 2014-04-24 17:58:34 +02:00
Torkel Ödegaard
c26926148c began work on unsaved changes warning when changing dashboard, Issue #324 2014-04-23 21:16:53 +02:00
Torkel Ödegaard
827e1846a8 Closes #333, New version availability check will now checks http://grafanarel.s3.amazonaws.com/latest.json if there is a new version. And the link now points to http://grafana.org/download 2014-04-23 09:05:10 +02:00
Torkel Ödegaard
2f58aa280c Review and small refactoring of PR #331 2014-04-22 13:08:14 +02:00
Torkel Ödegaard
66db99faf8 Merge branch 'feature/influxdb-add-where-conditions' of github.com:mavimo/grafana into mavimo-feature/influxdb-add-where-conditions 2014-04-22 12:38:15 +02:00
Torkel Ödegaard
0efafc50dc Increased resolution for graphite datapoints (maxDataPoints), now equal to panel pixel width. (Closes #5) 2014-04-22 12:01:51 +02:00
Marco Vito Moscaritolo
595aab4edf removed unrequired variable (error on merge from master) 2014-04-21 18:14:30 +02:00
Marco Vito Moscaritolo
02696c8bca better variable naming 2014-04-21 18:13:05 +02:00
Marco Vito Moscaritolo
01f3d728ef Added labels per series management 2014-04-21 18:07:55 +02:00
Marco Vito Moscaritolo
bba76cac4d Added conditions management 2014-04-21 18:07:24 +02:00
Marco Vito Moscaritolo
72ab721f22 Added where condiction operators 2014-04-21 18:06:13 +02:00
Marco Vito Moscaritolo
f98db943a5 Merge branch 'master' into feature/influxdb-add-where-conditions
Conflicts:
	src/app/partials/influxdb/editor.html
	src/app/services/influxdb/influxdbDatasource.js
2014-04-21 16:32:05 +02:00
Marco Vito Moscaritolo
f122da58c1 added support to coustom where conditions 2014-04-21 16:20:08 +02:00
Torkel Ödegaard
125db1777a influxdb editor: rawquery text input, changed from fixed pixel width to span10 class 2014-04-20 14:17:25 +02:00
Torkel Ödegaard
c592db4024 Merge branch 'influxdb-updates' of github.com:influxdb/grafana into influxdb-influxdb-updates 2014-04-20 13:59:31 +02:00
Torkel Ödegaard
02af2dbe73 Added rounding for graphites from and to time range filters
for very short absolute ranges (Fixes #320)
2014-04-18 16:06:55 +02:00
Torkel Ödegaard
b1bd04566e updated changelog 2014-04-17 22:36:12 +02:00
Torkel Odegaard
15288b0e84 version bump to 1.5.3 2014-04-17 22:27:19 +02:00
Torkel Ödegaard
dfaa529fa3 updated readme 2014-04-17 14:33:09 +02:00
Torkel Ödegaard
ef54bb1b7c Merge pull request #323 from magicrobotmonkey/slideshow_leak
unbind resize event during slideshow
2014-04-17 09:52:48 +02:00
Todd Persen
b3e459863e Add support for multiple hosts (with retries) and raw queries. 2014-04-16 09:54:25 -04:00
Aaron Bassett
ada56ea8ce unbind resize event during slideshow 2014-04-16 09:52:29 -04:00
Torkel Ödegaard
8ca589cdf5 Support for async scripted dashboards, and accesss to jquery, window & document, Closes #274) 2014-04-16 14:57:35 +02:00
Torkel Odegaard
390c4eed7e Revert "Merge pull request #310 from roidelapluie/master"
This reverts commit 9fc93e285c, reversing
changes made to 30bf838065.
2014-04-15 19:56:35 +02:00
Torkel Ödegaard
9fc93e285c Merge pull request #310 from roidelapluie/master
Reload filters when loading page
2014-04-15 19:50:46 +02:00
Julien Pivotto
1f417f0606 Reload filters when loading page
This commit refreshes the dynamic filters when loading page.
2014-04-14 14:47:39 +02:00
Torkel Ödegaard
30bf838065 added smartSummarize graphite function definition 2014-04-14 08:17:42 +02:00
Torkel Ödegaard
0019101f0e clarified timezoneOffset setting 2014-04-13 15:01:06 +02:00
Torkel Ödegaard
75b2e383c2 Merge branch 'auto_tz' of github.com:magicrobotmonkey/grafana into magicrobotmonkey-auto_tz 2014-04-13 13:45:08 +02:00
Torkel Ödegaard
b5830e0cde Merge pull request #307 from awilliams/patch-1
Fixes documentation typo
2014-04-11 16:33:35 +02:00
Adam Williams
e9dcf0e00b Fixes documentation typo 2014-04-11 15:22:20 +02:00
Torkel Ödegaard
ccd5c01d91 Merge pull request #306 from cruatta/master
Grafana needs hideLegend=false in graphite urls when show legend is selected for Graphite PNG
2014-04-11 11:25:30 +02:00
Cameron Ruatta
2ea3f7a558 Changing behavior to always obey the show legend option in grafana. without hideLegend=false, grafana defaults to the graphite behavior of hiding the legend at (default 10) X number of series. Also should be checking scope.panel.legend.show. 2014-04-10 14:10:29 -07:00
Torkel Ödegaard
993a2daccc fixed failing unit test, added 2 more for setTime & auto refresh behavior 2014-04-10 12:44:19 +02:00
Torkel Ödegaard
541baac49e Closes #282, Disable auto refresh zooming in (every time you change to an absolute time range), refresh will be restored when you change time range back to relative 2014-04-10 12:28:06 +02:00
Torkel Ödegaard
d69b04e9ed Closes #294, Browser page title is now Grafana - {{dashboard title}} 2014-04-10 12:12:15 +02:00
Torkel Ödegaard
78fab41310 Merge pull request #303 from jaimegago/master
Update README.md
2014-04-10 08:58:36 +02:00
Jaime Gago
4502ed068d Update README.md
Caveat about using "*" in CORS
2014-04-09 12:56:31 -07:00
Torkel Ödegaard
5495e0f96a Fixes #302, year dates in changelog was 2013, now corrected to 2014, thx LordFPL for spotting this 2014-04-09 12:36:35 +02:00
Torkel Ödegaard
60a8fe31f1 Fixes #297, filter remove fix 2014-04-08 20:51:26 +02:00
Torkel Ödegaard
93ab2a93d4 updated changelog 2014-04-08 20:51:26 +02:00
Aaron Bassett
688c21cd94 added little workraround for graphites timezones/DST failures 2014-04-08 09:56:00 -04:00
Torkel Ödegaard
39e19fdfba Merge pull request #295 from jaimegago/master
Update dashLoader.js
2014-04-07 14:21:40 -04:00
Jaime Gago
5525ccc409 Update dashLoader.js
Remove "Kibana" left overs in dashboard alerts
2014-04-07 11:13:18 -07:00
Torkel Ödegaard
db9949d403 Fixes #291, row height correction bug fixed 2014-04-07 08:33:52 +02:00
Torkel Ödegaard
f36d91336a Fixes #289, PanelBaseCtrl needs to specify inject dependency annotations as it doesnt follow regular angular controller syntax, ngmin grunt task misses it 2014-04-06 12:44:00 +02:00
Torkel Ödegaard
da13de6af5 fixed failing unit test 2014-04-06 11:07:22 +02:00
Torkel Ödegaard
4029dc3165 Added jshint file for unit tests, and grunt task to verify test syntax. 2014-04-06 10:47:14 +02:00
Torkel Ödegaard
6795383461 Fixes #106. Css fix for Firefox and using top menu dropdowns in panel fullscren / edit mode 2014-04-06 09:53:07 +02:00
Torkel Ödegaard
305d5c5aa9 Fixes #189, correction to ms axis formater, now formats days correctly 2014-04-06 09:17:43 +02:00
Torkel Ödegaard
49492e7bca Removed panel title hide feature I added yesterday, could not get it right right now. 2014-04-06 09:17:43 +02:00
Torkel Odegaard
bd0e96f166 small fix: (lowercase) file name tp panelBaseCtrl 2014-04-05 21:37:03 +02:00
Torkel Ödegaard
2e7b145a81 css fix for legend color selector popover 2014-04-05 19:29:14 +02:00
Torkel Ödegaard
6f114b17d6 Closes ##278, improvements in row height matching, refactorings of base kibana panel features into PanelBaseCtrl 2014-04-05 19:22:24 +02:00
Torkel Ödegaard
5cd73cea4b small code cleanup in grafanaGraph 2014-04-05 19:22:23 +02:00
Torkel Ödegaard
347f6aed3f small code cleanup in grafanaGraph 2014-04-05 19:22:23 +02:00
Torkel Ödegaard
24ea23ce83 Merge pull request #283 from ragzilla/master
use influxdb aliases to distinguish between multiple columns
2014-04-05 10:15:25 -04:00
Torkel Ödegaard
5cb4cfcdd2 Closes #265, Graphite errors are now easier to troubleshoot with the new inspector! 2014-04-05 16:04:49 +02:00
Torkel Ödegaard
58ef61a0bb working on inspector 2014-04-05 13:26:48 +02:00
Matt Addison
58a494f33f fix for jslint maxlen 2014-04-04 13:58:23 -04:00
Matt Addison
c97213f177 use influxdb aliases to distinguish between multiple columns in a single series 2014-04-03 22:49:10 -04:00
Torkel Ödegaard
a9abd2ff5c began work in inspector feature for easy troubleshooting, Issue #265 2014-04-03 22:22:38 +02:00
Torkel Ödegaard
8cba594070 Merge branch 'master' of github.com:nikicat/grafana into nikicat-master 2014-04-03 12:45:08 +02:00
Torkel Ödegaard
f2c9cc17df #Closes #269, changed byte and bit formats to conform with IEC standard symbols, like Kib, Mib for bits, and KiB, MiB, GiB for bytes 2014-04-03 12:42:50 +02:00
Torkel Ödegaard
1a34c2eee3 Merge pull request #280 from syepes/add_functions_v2
Add rangeOfSeries,sortByTotal,removeAbove*,removeBelow*
2014-04-03 02:48:11 -04:00
Nikolay Bryskin
a1632e4874 identation fixed 2014-04-03 02:38:01 +04:00
Sebastian YEPES
9534fccebf Add rangeOfSeries,sortByTotal,removeAbove*,removeBelow* 2014-04-03 00:37:02 +02:00
Nikolay Bryskin
ae9d9ea284 import from graphite: set correct datasource for panel 2014-04-03 02:11:58 +04:00
Nikolay Bryskin
8ea4351797 import from non-default dashboard support 2014-04-03 01:35:49 +04:00
Torkel Odegaard
34a18514b6 Fixes #271, renamed Export schema to Export dashboard 2014-04-01 21:42:05 +02:00
Torkel Ödegaard
7248358ac1 Merge pull request #268 from ImmobilienScout24/feature/linebreak_in_annotations_tooltip
replace linebreaks with <br/> in data section of tooltip.
2014-04-01 09:18:28 -04:00
Jan Gaedicke
9e1e7be574 replace linebreaks with <br/> in data section of tooltip. 2014-04-01 15:14:15 +02:00
Torkel Ödegaard
18e0a60b9e Fixes 267, Functions without params (like integral) now causes graph to update correctly 2014-04-01 12:39:05 +02:00
Torkel Ödegaard
c727863616 Merge pull request #255 from bobrik/patch-1
Fixed installation instructions for config.js
2014-03-31 12:40:46 -04:00
Torkel Ödegaard
75fc0c7017 Merge pull request #256 from bobrik/undefined-length-fix
Fixed annoying undefined length error
2014-03-31 12:35:38 -04:00
Ian Babrou
e3b046aecf fixed annoying undefined length error 2014-03-31 18:53:43 +04:00
Ian Babrou
046f80b9f2 Fixed installation instructions for config.js
Because you cannot edit the file which does not even exist.
2014-03-31 18:22:55 +04:00
Torkel Ödegaard
b1b54740f4 Merge branch 'html_unsafe' of github.com:bruce-lyft/grafana into bruce-lyft-html_unsafe 2014-03-30 16:41:50 +02:00
Torkel Ödegaard
0c1bc378ba updated changelog 2014-03-30 16:40:54 +02:00
Torkel Ödegaard
d067b69d20 Fixes #251, text panel change is now updating panel correctly. Changed button text from Cancel to Close 2014-03-30 15:00:09 +02:00
Torkel Ödegaard
ba928e18bf Merge pull request #245 from magicrobotmonkey/add_functions
Add transformNull, minSeries and maxSeries
2014-03-29 05:00:41 -04:00
Torkel Ödegaard
2d89cb0978 Merge pull request #248 from syepes/add_functions
Add functions: sortByMaxima,sortByMinima,limit,mostDeviant,movingMedian,stdev
2014-03-29 04:59:50 -04:00
Sebastian YEPES
c7c88902bd Add sortByMaxima,sortByMinima,limit,mostDeviant,movingMedian,stdev 2014-03-28 22:23:33 +01:00
Aaron Bassett
8d7669bc08 added min and max 2014-03-28 09:12:25 -04:00
Aaron Bassett
1cff3a6751 add transformNull 2014-03-28 09:12:20 -04:00
Torkel Ödegaard
6100336b2a Merge pull request #237 from maage/some-graphite-func-definitions
Some graphite func definitions
2014-03-27 10:18:36 -04:00
Torkel Ödegaard
da7455f859 Merge pull request #238 from maage/bits-y-axis-format
Fixes #148 add bits format for Y-Axis
2014-03-27 10:17:01 -04:00
Markus Linnala
5ec525a430 add bits format for Y-Axis 2014-03-27 15:58:04 +02:00
Markus Linnala
863e58a8e7 add support for graphite functions: maximumAbove maximumBelow minimumAbove 2014-03-27 15:18:01 +02:00
Markus Linnala
e441e97030 add support for graphite func substr 2014-03-27 15:17:51 +02:00
Markus Linnala
2b0152f6f4 add support for graphite func consolidateBy 2014-03-27 15:17:46 +02:00
Bruce Sherrod
eb20c5bb43 make html-unsafe for text/html panels 2014-03-26 12:00:08 -07:00
Bruce Sherrod
89c8547820 Merge branch 'master' of github.com:bruce-lyft/grafana 2014-03-26 11:52:00 -07:00
Torkel Ödegaard
5087cd2b19 Fixes #225, grid min not sent to graphite png renderer when set to 0 2014-03-26 11:51:52 -07:00
Torkel Ödegaard
06e9256050 Closes #209, sub folder with project name and version suffix in release zip files 2014-03-26 11:51:52 -07:00
Torkel Ödegaard
8aff6f50db Fixes #223, float arguments to functions like scale should now work as expected 2014-03-26 11:51:52 -07:00
Torkel Ödegaard
b2aca66e2d aliasByNode support for second node param, Closes #167 2014-03-26 11:51:52 -07:00
Marco Vito Moscaritolo
add61cf783 Moved function definition out of template. 2014-03-26 11:51:52 -07:00
Marco Vito Moscaritolo
a549bd73f9 Added more query function in InfluxDB 2014-03-26 11:51:51 -07:00
Torkel Ödegaard
f849b8cd4b fixed build issues with last commit (spec file syntax error) 2014-03-26 11:51:51 -07:00
Torkel Ödegaard
d8cf427425 more work on filterSrv unit tests 2014-03-26 11:51:51 -07:00
Torkel Ödegaard
517ac3f111 added unit tests for filterSrv 2014-03-26 11:51:51 -07:00
Jaime Gago
43f1cfba5a Fix a "kibana" leftover in comments 2014-03-26 11:51:51 -07:00
Torkel Ödegaard
dd18b6c836 Adds support to have filters inside filters, (nested templated segments), Closes #128 2014-03-26 11:51:51 -07:00
Bruce Sherrod
d8b86a899d Merge remote-tracking branch 'remotes/torkelo/master' 2014-03-24 12:35:12 -07:00
Torkel Ödegaard
ed9e336c51 Fixes #225, grid min not sent to graphite png renderer when set to 0 2014-03-24 13:17:27 +01:00
Torkel Ödegaard
94fea502b9 Closes #209, sub folder with project name and version suffix in release zip files 2014-03-24 12:51:49 +01:00
Torkel Ödegaard
1e79e39161 Fixes #223, float arguments to functions like scale should now work as expected 2014-03-24 12:20:28 +01:00
Torkel Ödegaard
6f9c2211fa aliasByNode support for second node param, Closes #167 2014-03-24 09:57:03 +01:00
Torkel Ödegaard
2e1e7462dc Merge pull request #218 from mavimo/feature/influx-query-functions
[InfluxDB] Added more query functions
2014-03-23 16:08:34 -04:00
Marco Vito Moscaritolo
6fb36acc9a Moved function definition out of template. 2014-03-23 20:20:18 +01:00
Marco Vito Moscaritolo
f35baffbef Added more query function in InfluxDB 2014-03-23 18:52:56 +01:00
Torkel Ödegaard
69b9189220 fixed build issues with last commit (spec file syntax error) 2014-03-23 16:04:21 +01:00
Torkel Ödegaard
06fe572113 more work on filterSrv unit tests 2014-03-23 07:03:43 +01:00
Torkel Ödegaard
dfd1d09641 added unit tests for filterSrv 2014-03-23 07:03:43 +01:00
Bruce Sherrod
6d981afcbc Merge branch 'master' of github.com:bruce-lyft/grafana 2014-03-19 13:38:08 -07:00
Bruce Sherrod
f90db0ed50 make html-unsafe for text/html panels 2014-03-19 13:37:29 -07:00
Bruce Sherrod
9894023177 make html-unsafe for text/html panels 2014-03-19 13:36:52 -07:00
Torkel Ödegaard
5ac6d28abf Merge pull request #213 from jaimegago/master
Fix a "kibana" leftover in comments
2014-03-19 06:05:55 +01:00
Jaime Gago
b813f48a7e Fix a "kibana" leftover in comments 2014-03-18 17:53:57 -07:00
Torkel Ödegaard
a3b4e40982 Adds support to have filters inside filters, (nested templated segments), Closes #128 2014-03-18 21:08:51 +01:00
Torkel Ödegaard
0c42b9a68e Merge pull request #212 from andrewmichaelsmith/log_func
Add logarithmic scale function
2014-03-18 21:08:31 +01:00
Andy Smith
48d3317136 Add logarithmic scale function 2014-03-18 19:36:31 +00:00
Matt Page
30b62e172d Add an OpenTSDB datasource.
This adds support for querying OpenTSDB for metric data.
2014-03-18 12:21:40 -07:00
Torkel Ödegaard
5a0fa8c09f added phantomjs karma test to run in travis 2014-03-18 20:04:04 +01:00
Torkel Ödegaard
0a6b393b35 fixed karama tests 2014-03-18 19:27:42 +01:00
Torkel Ödegaard
dadae53e51 Merge branch 'master' of github.com:torkelo/grafana 2014-03-17 17:25:21 +01:00
Torkel Ödegaard
c22c4b864c fixed string replace issue that caused problems, this removes build cache busting in requirejs, will need to fix that later 2014-03-17 17:24:38 +01:00
Torkel Ödegaard
aa27c13b20 Merge pull request #208 from fstern/master
Added graphite functions: nPercentile and keepLastValue
2014-03-17 11:31:06 +01:00
Bruno Renié
50771b0762 Workaround a behavior modification probably in grunt-string-replace 2014-03-16 20:50:15 +01:00
Torkel Ödegaard
336cf768d8 Merge pull request #194 from danharvey/add-hitcount-function
Added hitcount Transform function.
2014-03-12 09:57:47 +01:00
Dan Harvey
a76d9b87f0 Improved markdown formatting in the contributing page. 2014-03-12 08:23:28 +00:00
Dan Harvey
5794fc533f Added hitcount Transform function. 2014-03-11 18:43:55 +00:00
Torkel Ödegaard
9ebf769b4d Fixes #191, update graph after adding new function and not changing default value 2014-03-11 13:00:28 +01:00
Falk Stern
2ea21e1f96 Added nPercentile and keepLastValue 2014-03-11 12:06:30 +01:00
Torkel Ödegaard
b396563235 Merge pull request #185 from nikicat/master
added graphite functions: percentileOfSeries, sumSeriesWithWildcards, averageSeriesWithWildcards
2014-03-10 14:17:15 +01:00
Nikolay Bryskin
c5b992e330 added graphite functions: percentileOfSeries, sumSeriesWithWildcards, averageSeriesWithWildcards 2014-03-10 17:04:34 +04:00
Torkel Ödegaard
ec6fae9e65 Merge pull request #183 from merc1031/master
round up maxDataPoints to nearest integer in request. graphite 0.9.x and...
2014-03-10 11:11:24 +01:00
Leonidas Loucas
7f5c6ca18d round up maxDataPoints to nearest integer in request. graphite 0.9.x and 0.9.12 seem to treat decimal maxDataPoints badly returning enourmous amounts of data 2014-03-10 02:50:11 -07:00
Torkel Odegaard
9de60a9a7c updated readme and changelog 2014-03-09 19:12:02 +01:00
Torkel Odegaard
3f64f5a5fc updated readme and version bump 2014-03-09 18:02:04 +01:00
Torkel Ödegaard
7b036cbe3c Merge branch 'playlist' Closes #36 2014-03-08 16:27:26 +01:00
Torkel Ödegaard
5100834156 worked on favorites feature and dashboard playlist, #36 2014-03-08 16:27:01 +01:00
Torkel Ödegaard
a387d48b48 began work on dashboard playlist feature, #36 2014-03-07 19:24:45 +01:00
Torkel Ödegaard
adfa341d6e Merge branch 'new_func_editor' 2014-03-07 15:07:11 +01:00
Torkel Ödegaard
0b03ca158b final touches to aliasByNode automatic stuff 2014-03-07 15:07:02 +01:00
Torkel Ödegaard
d9e6fcd730 move func left right, remove, and link to graphite docs works 2014-03-07 13:43:44 +01:00
Torkel Ödegaard
feb20243e5 added func controls 2014-03-07 13:14:41 +01:00
Torkel Ödegaard
e3e6f511e7 focus first input param after adding function 2014-03-07 09:42:07 +01:00
Torkel Ödegaard
293a2db369 func editor is almost done 2014-03-06 22:08:41 +01:00
Semir Patel
1c72e0c40c Support graphite identifiers with embedded colons. i.e. host:twiggy.servlet:home.method:GET.user:loggedin.50th 2014-03-06 11:37:33 -08:00
Torkel Ödegaard
3e6a4362ee Merge branch 'master' into new_func_editor 2014-03-05 18:57:26 +01:00
Torkel Ödegaard
3b327bab8f Fixes to maxDataPoints / resolution and time axis formats 2014-03-05 18:37:51 +01:00
Torkel Ödegaard
a50b594aac added changelog and contributing docs 2014-03-05 13:02:33 +01:00
Torkel Ödegaard
e186c9b8bc experimenting with new func editor 2014-03-05 12:46:27 +01:00
Torkel Ödegaard
a5502a3751 added typeahead to column for influxdb, #103 2014-03-05 12:43:58 +01:00
Torkel Ödegaard
bd0f694f6a small refactoring and jshint fix for datasourceFactory func 2014-03-04 22:01:25 +01:00
Torkel Ödegaard
c018b4bd6e fix for influxdb as default datasource, #103 2014-03-04 21:49:06 +01:00
Torkel Ödegaard
2be71c577c Closes #164, typeahead / autocomplete for adding graphite functions to a target expression 2014-03-04 18:50:47 +01:00
Torkel Ödegaard
238de4d8b4 Merge pull request #162 from nixfloyd/master
Added currentAbove/Below, highestMax functions.
2014-03-04 09:57:18 +01:00
Lucian Grosu
6664890381 Added currentAbove/Below, highestMax functions. 2014-03-04 09:40:15 +01:00
Torkel Ödegaard
5221db5aa6 restored influxdb listSeries function 2014-03-03 08:39:05 +01:00
Torkel Ödegaard
1e6d998a9c fixed path to influxdb editor, #103 2014-03-03 06:53:50 +01:00
Torkel Ödegaard
da62a5653a added typeahead / autocomplete to influxdb series name, #103 2014-03-02 18:24:15 +01:00
Torkel Ödegaard
125ff957f5 Merge branch 'influxdb' Issue #103, influxdb support ready for testing and feedback 2014-03-02 13:27:02 +01:00
Torkel Ödegaard
73dcd9e11a improvement to bar width 2014-03-02 13:26:08 +01:00
Torkel Ödegaard
50fd5512d6 more work on influxdb datasource, query editor, and refactoring 2014-03-02 10:41:16 +01:00
Torkel Ödegaard
291dd9bd48 absolute time ranges (zoom in) works with influxdb 2014-03-01 15:38:00 +01:00
Torkel Ödegaard
549eeeb29d progress on influxdb datasource and target editor 2014-03-01 12:02:55 +01:00
Torkel Ödegaard
6d59d21770 Merge pull request #154 from jmhobbs/master
Fix variable name for graphite basic auth.
2014-02-28 20:30:02 +01:00
John Hobbs
2ee1063485 Fix variable name for graphite basic auth. 2014-02-28 13:16:24 -06:00
Torkel Ödegaard
75bec29dbc moving stuff out of graphite panel and into kibanaPanel 2014-02-28 16:40:32 +01:00
Torkel Ödegaard
20bc1afec8 more refactoring and moving stuff outof graphite panel 2014-02-28 08:02:20 +01:00
Torkel Ödegaard
e3f56f2645 refactoring of graphite panel to be more datasource agnostic, start of experimental influxdb support 2014-02-27 21:46:06 +01:00
Torkel Ödegaard
ed2770e380 Merge branch 'master' into refactoring_graphite_panel 2014-02-27 20:10:29 +01:00
Torkel Ödegaard
bb6d8ec99f Merge pull request #150 from jippi/better-ms-formatting
allow hour, day, week and year time rounding
2014-02-27 18:27:42 +01:00
Christian Winther
ddb81de58b allow hour, day, week and year time rounding 2014-02-27 15:01:03 +00:00
Torkel Ödegaard
cf9a8a15cd refactoring graphite panel 2014-02-27 08:33:53 +01:00
Torkel Odegaard
c4219ba0ad Refactoring time formats, Closes #142 2014-02-26 19:46:58 +01:00
Khushil Dep
47e54b2399 typo fix 2014-02-26 19:46:58 +01:00
Khushil Dep
215fe16341 fix jslint issues 2014-02-26 19:46:58 +01:00
Khushil Dep
218d481209 Add the ability to set microseconds to the Y-Axis on graphs. 2014-02-26 19:46:57 +01:00
Torkel Ödegaard
78f4a83d05 Merge pull request #145 from nixfloyd/master
Added highestAverage / lowestAverage
2014-02-26 16:56:26 +01:00
Lucian Grosu
733181a6b8 Added highestAverage / lowestAverage 2014-02-26 12:37:16 +01:00
Torkel Ödegaard
d79dcb952d Refactoring pull request for basic auth improvement 2014-02-26 08:50:46 +01:00
Theral Mackey
bb64e812d8 Bugfix for Basic Auth: strip auth from url before using
This fixes the Basic Auth not working issue (issue#16) further, by
removing the auth string from the URL before grafana attempts to use
it. Some js doesn't handle it properly and tries to include the auth
string in dns lookups(?), so the request never even hits the graphite
server when an auth string is present.
2014-02-26 08:50:45 +01:00
Torkel Odegaard
9a324e35a4 added small text to show when no datapoints are returned and when datapoints returned from graphite are outside timerange (can happen when timezone mismatch) #143 2014-02-26 08:31:04 +01:00
Torkel Odegaard
605888bb78 finished refactoring of GraphiteDatasource to angular service and fixed jshint errors 2014-02-25 21:31:30 +01:00
Torkel Ödegaard
ef69d692ef Time is now sent in utc when time correction is set to utc #143 2014-02-25 17:48:13 +01:00
Torkel Ödegaard
a54f05e287 Merge pull request #140 from nixfloyd/master
Added the 'stacked' and 'lowestCurrent' functions
2014-02-25 13:09:34 +01:00
Lucian Grosu
4b0cd0776d Added the 'stacked' and 'lowestCurrent' functions 2014-02-25 12:21:56 +01:00
Torkel Ödegaard
4b75d67732 Fixes #135, show seconds in x-axis when zooming in for short time ranges 2014-02-25 07:33:27 +01:00
Torkel Ödegaard
1ca61a948e Fixes #138, Ignore graphite metric annotations with zero values 2014-02-24 16:50:10 +01:00
Torkel Ödegaard
e13c81e25b Merge pull request #137 from razitz/master
added exclude function
2014-02-24 09:04:58 +01:00
Raz
b69652fc0c added exclude function 2014-02-24 10:01:58 +02:00
Torkel Odegaard
0949b7ec0a fixed jshint error 2014-02-23 19:45:40 +01:00
Torkel Ödegaard
75683c423d Closes #123, you can now specify template (ie filter) values in url. ?fillterName=filterValue 2014-02-23 19:34:33 +01:00
Torkel Ödegaard
3f2c69aea3 Merge pull request #131 from nikicat/master
added movingAverage function
2014-02-21 20:06:22 +01:00
Nikolay Bryskin
9adc3941b9 added movingAverage function 2014-02-21 21:37:23 +04:00
Torkel Ödegaard
8904a6f4e9 version bump to 1.4.0 and link to annotations wiki article 2014-02-21 14:27:38 +01:00
Torkel Ödegaard
b49803855e Closes #44, Closes #8. Fist release of annotations feature is ready 2014-02-21 13:56:27 +01:00
Torkel Ödegaard
7b906aa229 Annotations refactoring 2014-02-21 11:58:08 +01:00
Torkel Ödegaard
f0f4c8cc52 A lot more work on annotations (#44, #8). Graphite events is working, editing, icon size, color and vertical line toggle/options working. To sleepy now... 2014-02-20 23:00:50 +01:00
Torkel Ödegaard
47db82d69b more modal loading optimizations 2014-02-20 19:40:29 +01:00
Torkel Ödegaard
af0374d5f4 moved menu share icon to advanced save dropdown, optimized loding of share modal 2014-02-20 19:26:36 +01:00
Torkel Ödegaard
f2b987b96b major improvement to how modals are loaded, much more reuse in html dom elements, hopefully solves #109. 2014-02-19 21:50:47 +01:00
Torkel Ödegaard
7f28157b32 updated readme with links to wiki pages 2014-02-19 12:56:06 +01:00
Torkel Ödegaard
c0c49350f6 Fixes #110, css fix for fullscreen and edit mode, when fullscreen and edit panel overflows the fullscreen height the panel is now scrollable. Also css fix for segment dropdowns for a graph with many many target rows. 2014-02-19 12:46:45 +01:00
Torkel Ödegaard
700d60058f More work on annotations (#44, #8) It is working for annotations from graphite metrics, basic annotation editor and everything is working. Needs some final touches and support for more datasources 2014-02-18 20:41:56 +01:00
Torkel Ödegaard
bda5ae5b90 fixed unclosed selected html tag (caused issue with optimized build version so no options where shown in graph edit tabs) 2014-02-18 14:28:54 +01:00
Torkel Ödegaard
53075e0ec7 Fixes #104, improvements to graphite target editor and use of wildcard, the "select metric" should now behave/appear correctly 2014-02-18 12:18:52 +01:00
Torkel Ödegaard
64c7c9f712 Fixes #105 (added 0 as option in aliasByNode) 2014-02-18 11:55:58 +01:00
Torkel Ödegaard
8846f63dcf updated readme with link to intro video 2014-02-17 19:42:26 +01:00
Torkel Ödegaard
d10bf9f993 Fixes null checks for legend value formaters (fix for #97) 2014-02-15 22:07:22 +01:00
Torkel Odegaard
4152c0653f fixed jshint errors 2014-02-15 17:18:47 +01:00
Torkel Ödegaard
e2d7ead815 Merge branch 'master' of github.com:torkelo/grafana 2014-02-15 13:47:04 +01:00
Torkel Ödegaard
36f56f3695 Closes #35, grafana now supports multiple graphite backends. Check config.sample for how to setup. In the general tab of the graphite panel you can change datasource 2014-02-15 13:46:36 +01:00
Torkel Ödegaard
5961d54aa8 Changed default value for stack from true to false (#98) 2014-02-15 10:55:04 +01:00
Torkel Ödegaard
207bf183c8 small css fix to light theme 2014-02-15 10:23:05 +01:00
Torkel Ödegaard
6f0ce35ca2 Closes #97, legend values now use selected y axis formater for precision and formating 2014-02-15 10:15:05 +01:00
Torkel Ödegaard
39bbd5604d Final tweaks to light theme (Closes #77) 2014-02-14 08:10:26 +01:00
Torkel Ödegaard
75e493363d Merge remote-tracking branch 'origin/master'
Conflicts:
	src/css/bootstrap.dark.min.css
	src/css/bootstrap.light.min.css
	src/css/less/grafana.less
	src/css/less/variables.dark.less
	src/css/less/variables.light.less
2014-02-14 07:45:23 +01:00
Torkel Ödegaard
2c414d8e45 even more work on light theme (#77) 2014-02-14 07:40:41 +01:00
Torkel Ödegaard
cac70a10fe more work on light theme (#77) 2014-02-13 22:19:11 +01:00
Torkel Ödegaard
9794c2ebbb improvements to light theme (Issue #77) 2014-02-13 20:34:40 +01:00
Torkel Ödegaard
975051b8e1 Closes #94, there is now a "Back to dashboard" link in header when in fullscreen / edit mode 2014-02-13 12:41:38 +01:00
Torkel Ödegaard
33ec638323 Small tag search fix 2014-02-13 09:11:28 +01:00
Torkel Ödegaard
f9f259195d bumped version 2014-02-13 08:17:31 +01:00
Torkel Ödegaard
dceda6e27d Closes #86, dashboard tags and tag search feature is now done! turned out pretty good! 2014-02-13 07:48:47 +01:00
Torkel Ödegaard
ef264920db moved less file that caused travis build error 2014-02-12 20:47:47 +01:00
Torkel Ödegaard
e9b1c92911 more work on dashboard tags / search (#86) 2014-02-12 20:15:00 +01:00
Torkel Ödegaard
123f90d24d jshint fix 2014-02-12 15:54:37 +01:00
Torkel Ödegaard
ff01764f95 Fixes #91, custom datetime picker is one day off 2014-02-12 15:52:53 +01:00
Torkel Ödegaard
4132dd940a search fix (introduced yesterday) 2014-02-12 14:37:34 +01:00
Torkel Ödegaard
9fc6d3d6f0 Fixed tagsinput bug related to shallow clone of dashboard 2014-02-12 14:35:12 +01:00
Torkel Ödegaard
7d9141a055 Fixes #89, switching between two templated (filtered) dashboards caused error 2014-02-12 12:43:32 +01:00
Torkel Ödegaard
2214c0cdf8 More work on adding tags to dashboard, added bootstrap tagsinput 2014-02-12 12:29:46 +01:00
Torkel Ödegaard
11c5fdc328 Fixes #88, Closed row css bug fix 2014-02-12 12:16:13 +01:00
Torkel Odegaard
c81c4f184b #86 Added tags to dashboard general settings panel, search and search display needs more work (grouping, facets etc) 2014-02-11 22:10:16 +01:00
Torkel Odegaard
a35ed05bc3 Closes #54, template/filter can now use "All", when all is not a wildcard but the specific metric segments specified in the filter query. 2014-02-11 20:58:51 +01:00
Torkel Odegaard
e574314472 Closes #82, dashboard search/load now sorts in alfabetical order 2014-02-11 20:38:50 +01:00
Torkel Ödegaard
45ab6d7c5e Merge pull request #85 from ohTHATaaronbrown/master
Fixes #84: Added implementation of fund parameter ...
2014-02-11 17:16:26 +01:00
Torkel Ödegaard
48325b6452 Fixes #83, stack percent with no line fill (workaround fix for bug in flot.stackpercent) 2014-02-11 09:15:23 +01:00
Torkel Ödegaard
4a1c9ac390 added grafana version info to dashboard settings, and link to releases. 2014-02-11 09:03:21 +01:00
Aaron Brown
a868bab24e Fixes torkelo/grafana/issues#84: Added implementation of fund parameter for summarize graphite function 2014-02-10 17:35:34 -06:00
Torkel Ödegaard
1fada5dd0b build/grunt script fixes 2014-02-10 18:05:52 +01:00
Torkel Ödegaard
a55b9bb8e1 version bump 2014-02-10 17:54:31 +01:00
Torkel Ödegaard
6c0f3d701f Fixes #80, stacked percentage and min/max bug, Fixes #81 (grid y min/max not working) 2014-02-10 17:53:39 +01:00
Torkel Odegaard
e86f4f94ef removed annotation test 2014-02-09 22:00:07 +01:00
Torkel Odegaard
ca258deb7a Merge branch 'master' of github.com:torkelo/grafana 2014-02-09 21:57:37 +01:00
Torkel Odegaard
79ca016409 More work on annotations 2014-02-09 21:57:07 +01:00
Torkel Odegaard
869bebed6e more work on annotations 2014-02-09 19:31:06 +01:00
Torkel Odegaard
0e3c0fcc2e Started work on annotations submenu control 2014-02-09 15:43:43 +01:00
Torkel Ödegaard
bf9c0bb914 Merge pull request #76 from axe-felix/patch-1
added support for 'less is worse' thresholds
2014-02-09 13:41:12 +01:00
axe-felix
8669599089 added support for 'less is worse' thresholds
Sometimes you want to express 'less is worse' thresholds. That means setting the error threshold below the warning threshold. The problem was, that the error marking always went up to +Infinity. Concerns 16599a07a9.
2014-02-09 10:13:32 +01:00
Torkel Odegaard
775c0ff2f1 updated readme 2014-02-08 20:47:04 +01:00
Torkel Odegaard
98ab75029e added link to wiki article on scripted dashboards 2014-02-08 20:45:01 +01:00
Torkel Odegaard
682740a020 fix for requirejs optimizer and config.js fallback 2014-02-08 20:30:19 +01:00
Torkel Odegaard
278decfb87 fixed jshint error 2014-02-08 20:13:43 +01:00
Torkel Odegaard
b8a0ca082a updated readme and bumped version to v1.1.1 2014-02-08 20:10:59 +01:00
Torkel Odegaard
f03e4be683 Closes #72, added scripted dashboard example (feature inherited from kibana) 2014-02-08 20:10:59 +01:00
Torkel Ödegaard
ba6a6292f9 trying to get angular mocks / testing to work 2014-02-08 16:38:17 +01:00
Torkel Odegaard
16599a07a9 Closes #70, Fixes #50, Grid thresholds feature 2014-02-08 14:21:41 +01:00
Torkel Ödegaard
a9ac11216d Moved parser/target editor warning icon to the right, now the hide/show eye is still usefull even when only working with the text editor 2014-02-07 15:38:59 +01:00
Torkel Ödegaard
8e2008f821 Fixes #69, lexer correctly tokenizes number-number segments, numericLiterals are only considered literal token if it is folled by a punctuator. 2014-02-07 15:37:03 +01:00
Torkel Ödegaard
0a8b9bad4f Fixes #67, decimal inputs for function parameters (like scale) 2014-02-07 14:07:24 +01:00
Torkel Ödegaard
bd4b75f5d8 added single decimal to short y formater 2014-02-07 13:27:53 +01:00
Torkel Ödegaard
084e7e7d73 Fixes #68, bug when trying open dashboard while in edit/fullscreen mode 2014-02-07 13:27:17 +01:00
Torkel Ödegaard
76f4e3c5b4 Fixed issue where series color or axis change would note take immediate effect (needed a full refresh). 2014-02-07 13:10:35 +01:00
Torkel Ödegaard
adb97a0f3e Fixes #42 : Auto Y scale is working as it should (even when using line fill) 2014-02-07 09:28:54 +01:00
Torkel Ödegaard
f2f435b4cb Changed name off config.js to config.sample.js to make it easier to upgrade with having to worry about config being overwwritten, if there is no config.js file config.sample.js will be read instead (requirejs fallback). Closes #65 2014-02-06 17:10:25 +01:00
Torkel Ödegaard
0015f81645 Implementation of legend values (min, max, current, total, avg), Closes #60, Fixes #14 2014-02-06 13:29:55 +01:00
Torkel Ödegaard
ed76335c96 small change to time axis formats, more graphite like now 2014-02-06 10:39:24 +01:00
Torkel Ödegaard
e0a35a3958 work in progress for legend values 2014-02-06 10:19:26 +01:00
Torkel Ödegaard
d9ec9ed1ef removed metrics tab in dash editor modal (only created confusion, the feature is not ready) 2014-02-06 07:55:19 +01:00
Torkel Ödegaard
0032f934c9 Closes #62, there is now a New button in the open / search dashboard view. 2014-02-05 20:56:48 +01:00
Torkel Ödegaard
8816e18027 Merge pull request #63 from jippi/feature/unique-local-storage-name
Make sure kibana and grafana on same hostname do not interfere with each other
2014-02-05 19:16:02 +01:00
Christian Winther
e8be950752 Make sure kibana and grafana on same hostname do not interfere with each other
This happens if you have kibana on /kibana and grafana on /grafana, resulting in some bad redirects
2014-02-05 18:02:15 +00:00
Torkel Ödegaard
aea4b37760 added highestCurrent function (Fixes #57) 2014-02-05 16:10:09 +01:00
Torkel Ödegaard
1aff1a0000 mini improvement to xasis format (now shows just hours for larger time spans) 2014-02-05 15:39:50 +01:00
Torkel Ödegaard
df54c17dca small refactoring of check if other panel is in fullscreen edit/view mode 2014-02-05 15:26:34 +01:00
Torkel Ödegaard
73c5883f0d small fix for png width error when resize in edit mode / fullscreen mode 2014-02-05 15:13:24 +01:00
Torkel Ödegaard
e3561ce555 fixed jshint errors, dam fever is coming back, time to sleep... 2014-02-05 13:35:32 +01:00
Torkel Ödegaard
a5feb639d9 Merge pull request #58 from andreparodi/master
added nonNegativeDerivative function
2014-02-05 13:28:38 +01:00
Torkel Ödegaard
ac33286c8c added sortByName function (thx @jippi) 2014-02-05 13:23:14 +01:00
Torkel Ödegaard
19d5d32229 simplified a lot of the time series data manipulation prior to handing it to flot, kibana used a lot of code to sort and make sure all time points needed had values, this is not needed for graphite time series data. Fixes som strange issues with "null point mode" and inconsistent rendering between graphite and grafana flot, 2014-02-05 13:14:00 +01:00
Torkel Ödegaard
d90f2537a4 added unit (y axis format) mapping support for png renderer (#22) 2014-02-05 11:30:54 +01:00
Torkel Ödegaard
487aa1f2c3 Added hideAxes and hideYAxis mapping support for png renderer. #22 2014-02-05 11:21:37 +01:00
Torkel Ödegaard
be9ab15c4e added grid min max support for png renderer (url property mappings that is), #22 2014-02-05 11:14:13 +01:00
Torkel Ödegaard
7d4f0d24d5 restructured style settings between axes & grid, and Display Styles 2014-02-05 11:12:47 +01:00
Torkel Ödegaard
bafa334b94 moved timezone correction setting from graph style to dashboard 2014-02-05 09:42:49 +01:00
Torkel Ödegaard
80c5f99f3b Removed pointless setting "selectable" (interactive) 2014-02-05 08:56:10 +01:00
Torkel Ödegaard
212bf5df98 small fix to png rendering 2014-02-05 08:41:46 +01:00
Andre Parodi
32189afc67 added nonNegativeDerivative function 2014-02-02 23:16:53 +01:00
Torkel Ödegaard
0fa6b34f1a working on native png renderer support 2014-02-01 22:06:10 +01:00
Torkel Ödegaard
4d6bb8b6be progress on translating grafana/flot options to graphite png renderer options 2014-02-01 21:23:43 +01:00
Torkel Ödegaard
82da75bc0c began work on adding support for native graphite png renderer support (#22) 2014-02-01 21:23:22 +01:00
Torkel Ödegaard
beda378314 Fixes #45, zero values treated as null values 2014-02-01 14:09:04 +01:00
Torkel Ödegaard
6734864acd small change to readme.md 2014-02-01 13:16:39 +01:00
Torkel Ödegaard
9f548870d0 added build status to readme.md 2014-02-01 13:00:32 +01:00
Torkel Ödegaard
d2bae43d26 Adding travis-ci build 2014-02-01 11:26:22 +01:00
Torkel Ödegaard
e77e43faab Fixes #46, you can now edit a graph with no title 2014-02-01 11:02:24 +01:00
Torkel Ödegaard
224d2f92c3 Save now closes edit mode. (#52). 2014-02-01 10:51:35 +01:00
Torkel Ödegaard
250e354659 Dashboard search fix, only query against title field (Closes #51,Fixes #24) 2014-02-01 09:53:57 +01:00
John Dyer
2e59587c8e Clean up, and set default in config to false 2014-02-01 09:53:56 +01:00
John Dyer
6f4520254b Make search support elastic search clusters with _all disabled. Feature is disabled by default 2014-02-01 09:53:55 +01:00
Torkel Ödegaard
b939c02da0 updated property docs in config.js 2014-02-01 09:03:51 +01:00
Torkel Ödegaard
9e900d5885 fixed small variable name issue with pull request #55 (jshint warning) 2014-02-01 08:53:59 +01:00
Torkel Ödegaard
38d3450160 refactoring, moved graph directive to a seperate js file 2014-02-01 08:47:16 +01:00
Torkel Ödegaard
2c5bfec089 Merge pull request #55 from oroce/elasticsearch-basicauth
basic authentication added for elasticsearch
2014-01-31 23:45:48 -08:00
oroce
a56a2b0057 basic authentication added for elasticsearch 2014-01-31 21:23:32 +01:00
Torkel Ödegaard
89224401a9 Fixes #38, Lexer & parser now handles metrics segments that begin with numbers or only have numbers 2014-01-29 11:00:25 +01:00
Torkel Ödegaard
1c17c8661a Fixes #43, add grunt-cli as dev dependency 2014-01-29 09:17:17 +01:00
Torkel Ödegaard
4ed65891c2 Merge pull request #39 from jeviolle/master
fixed missing module for 'moment' and jslint missing semi colon
2014-01-28 03:37:35 -08:00
Rick Briganti
49e131ce21 updated how moment is included and removed moment as a dep since it is included 2014-01-27 17:30:28 -05:00
Rick Briganti
06f4b017d6 fixed missing module for 'moment' and jslint missing semi colon 2014-01-27 14:01:36 -05:00
Torkel Ödegaard
f52450aef4 Merge pull request #37 from tmeinlschmidt/master
fixes 'derivate' function name - correct name is 'derivative'
2014-01-26 23:33:43 -08:00
Tom Meinlschmidt
6476843e95 - fixes 'derivate' function name - corrent name is 'derivative' 2014-01-27 02:00:04 +01:00
Torkel Ödegaard
67d11dffb9 small readme fix 2014-01-25 17:25:21 +01:00
Torkel Ödegaard
58dbb01e76 Added new config setting timezoneOffset, usefull when your graphite server is on a different timezone thant your users browsers. This is not optimal (for example if your users have different timezones) can be improved by finding a way to query the timezone different between browser and graphite server. Or fix so that the &tz graphite parameter works for json, then all absolute filters can use UTC time. #31 2014-01-24 17:00:54 +01:00
Torkel Ödegaard
81e9a483bc Merge pull request #29 from rsommer/patch-1
Update graphiteSrv.js
2014-01-24 05:23:04 -08:00
Torkel Ödegaard
5688f792cb Merge pull request #30 from johanwiren/fix_graphite_import
Fixed graphite import to include all graphs in a dashboard.
2014-01-24 05:16:54 -08:00
Johan Wirén
3ffc04be4d Fixed graphite import to include all graphs in a dashboard. 2014-01-24 14:08:09 +01:00
Roland Sommer
55e586c2c6 Update graphiteSrv.js
If 'now' is not in 'data', the result is -1, so it should be '>= 0' ...
2014-01-24 13:32:16 +01:00
Torkel Ödegaard
76b535a2e4 Merge pull request #26 from johanwiren/add_title_on_import
Sets graph title when importing from graphite
2014-01-23 20:27:34 -08:00
Johan Wirén
6e27f97bc9 Sets graph title when importing from graphite 2014-01-24 00:07:43 +01:00
Torkel Ödegaard
d9ada8d94e Merge pull request #23 from longnguyen11288/master
Fixed typo in import
2014-01-23 10:39:24 -08:00
Long Nguyen
b3d67c3ed4 Fixed typo in import 2014-01-23 10:35:56 -08:00
Torkel Odegaard
459b0dc5bd Updated readme with link to getting started guide 2014-01-23 19:19:56 +01:00
Torkel Ödegaard
aefd95890e Merge pull request #21 from dcarley/probject_typo
Correct typo "probject".
2014-01-23 10:06:50 -08:00
Dan Carley
36d66494d3 Correct typo "probject". 2014-01-23 17:48:51 +00:00
Torkel Ödegaard
a8ba77f40c bumbed version 2014-01-23 13:57:52 +01:00
Torkel Ödegaard
0c0ca895a8 Closes #9 , new y format 'ms' formats millisecond values as "200 ms" , "3 s", "4 min" etc. 2014-01-23 13:31:02 +01:00
Torkel Ödegaard
3d35595397 Fixed fullscreen not increasing graph height as before 2014-01-23 13:22:35 +01:00
Torkel Ödegaard
533e176566 Fixed issue with date parsing, now saved absolute range should work again 2014-01-23 12:34:35 +01:00
Torkel Ödegaard
915f2a4914 updated readme.md 2014-01-23 11:58:59 +01:00
Torkel Odegaard
d21bd796f8 Added documentation in Readme.md for how to configure apache2 with Basic Auth and CORS 2014-01-22 22:25:15 +01:00
Torkel Odegaard
51186397d7 Fixes #16 (Basic Authentication), set graphiteUrl: http://username:password@domain.com and it should work, but requires special CORS settings in apache2 2014-01-22 22:19:58 +01:00
Torkel Ödegaard
e2dd201e4a Fixes #13 (partially) Use relative time ranges whenever possible when querying graphite 2014-01-22 13:05:07 +01:00
Torkel Ödegaard
f0c8b70f47 fixed config.js grafana_index default value was accidentally changed 2014-01-22 08:27:23 +01:00
Torkel Ödegaard
d259f14267 Initial work on #9 (millisecond y axis formater) 2014-01-21 22:06:54 +01:00
Torkel Ödegaard
3b6bf80ea4 removed more unused code 2014-01-21 21:45:25 +01:00
Torkel Ödegaard
0e4dc5a888 clean up unused code, left over from kibana 2014-01-21 21:11:09 +01:00
Torkel Ödegaard
fc713be9ce Fixes #12, operation without elastic search should now with without error 2014-01-21 21:05:54 +01:00
Torkel Ödegaard
a6df1a9320 Partial fix for #10 , the lexer & parser can now handle curly brace, but target editor needs to be updated to support selecting multiple segment nodes 2014-01-21 12:43:32 +01:00
1287 changed files with 397937 additions and 66281 deletions

17
.bra.toml Normal file
View File

@@ -0,0 +1,17 @@
[run]
init_cmds = [
["go", "build", "-o", "./bin/grafana-server"],
["./bin/grafana-server"]
]
watch_all = true
watch_dirs = [
"$WORKDIR/pkg",
"$WORKDIR/public/views",
"$WORKDIR/conf",
]
watch_exts = [".go", ".ini"]
build_delay = 1500
cmds = [
["go", "build", "-o", "./bin/grafana-server"],
["./bin/grafana-server"]
]

31
.gitignore vendored
View File

@@ -1,6 +1,29 @@
node_modules
coverage/
.aws-config.json
dist
web.config
config.dev.js
*.sublime-workspace
awsconfig
/dist
/tmp
docs/AWS_S3_BUCKET
docs/GIT_BRANCH
docs/VERSION
docs/GITCOMMIT
docs/changed-files
docs/changed-files
# locally required config files
public/css/*.min.css
# Editor junk
*.sublime-workspace
*.swp
.idea/
*.iml
/data/*
/bin/*
conf/custom.ini
fig.yml

7
.hooks/pre-commit Executable file
View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
test -z "$(gofmt -s -l . | grep -v Godeps/_workspace/src/ | tee /dev/stderr)"
if [ $? -gt 0 ]; then
echo "Some files aren't formatted, please run 'go fmt ./pkg/...' to format your source code before committing"
exit 1
fi

13
.jscs.json Normal file
View File

@@ -0,0 +1,13 @@
{
"disallowImplicitTypeConversion": ["string"],
"disallowKeywords": ["with"],
"disallowMultipleLineBreaks": true,
"disallowMixedSpacesAndTabs": true,
"disallowTrailingWhitespace": true,
"requireSpacesInFunctionExpression": {
"beforeOpeningCurlyBrace": true
},
"disallowSpacesInsideArrayBrackets": true,
"disallowSpacesInsideParentheses": true,
"validateIndentation": 2
}

21
.jsfmtrc Normal file
View File

@@ -0,0 +1,21 @@
{
"preset" : "default",
"lineBreak" : {
"before" : {
"VariableDeclarationWithoutInit" : 0,
},
"after": {
"AssignmentOperator": -1,
"ArgumentListArrayExpression": ">=1"
}
},
"whiteSpace" : {
"before" : {
},
"after" : {
}
}
}

View File

@@ -18,12 +18,12 @@
"noempty": true,
"undef": true,
"boss": true,
"trailing": false,
"trailing": true,
"laxbreak": true,
"laxcomma": true,
"sub": true,
"unused": true,
"maxdepth": 5,
"maxlen": 140,
"globals": {

510
CHANGELOG.md Normal file
View File

@@ -0,0 +1,510 @@
# 2.0.0 (2015-04-20)
**Fixes**
- [Issue #1784](https://github.com/grafana/grafana/issues/1784). Data source proxy: Fixed issue with using data source proxy when grafana is behind nginx suburl
- [Issue #1749](https://github.com/grafana/grafana/issues/1749). Graph Panel: Table legends are now visible when rendered to PNG
- [Issue #1786](https://github.com/grafana/grafana/issues/1786). Graph Panel: Legend in table mode now aligns, graph area is reduced depending on how many series
- [Issue #1734](https://github.com/grafana/grafana/issues/1734). Support for unicode / international characters in dashboard title (improved slugify)
- [Issue #1782](https://github.com/grafana/grafana/issues/1782). Github OAuth: Now works with Github for Enterprise, thanks @williamjoy
- [Issue #1780](https://github.com/grafana/grafana/issues/1780). Dashboard snapshot: Should not require login to view snapshot, Fixes #1780
# 2.0.0-Beta3 (2015-04-12)
**RPM / DEB Package changes (to follow HFS)**
- binary name changed to grafana-server
- does not install to `/opt/grafana` any more, installs to `/usr/share/grafana`
- binary to `/usr/sbin/grafana-server`
- init.d script improvements, renamed to `/etc/init.d/grafana-server`
- added default file with environment variables,
- `/etc/default/grafana-server` (deb/ubuntu)
- `/etc/sysconfig/grafana-server` (centos/redhat)
- added systemd service file, tested on debian jessie and centos7
- config file in same location `/etc/grafana/grafana.ini` (now complete config file but with every setting commented out)
- data directory (where sqlite3) file is stored is now by default `/var/lib/grafana`
- no symlinking current to versions anymore
- For more info see [Issue #1758](https://github.com/grafana/grafana/issues/1758).
**Config breaking change (setting rename)**
- `[log] root_path` has changed to `[paths] logs`
# 2.0.0-Beta2 (...)
**Enhancements**
- [Issue #1701](https://github.com/grafana/grafana/issues/1701). Share modal: Override UI theme via URL param for Share link, rendered panel, or embedded panel
- [Issue #1660](https://github.com/grafana/grafana/issues/1660). OAuth: Specify allowed email address domains for google or and github oauth logins
**Fixes**
- [Issue #1649](https://github.com/grafana/grafana/issues/1649). HTTP API: grafana /render calls nows with api keys
- [Issue #1667](https://github.com/grafana/grafana/issues/1667). Datasource proxy & session timeout fix (casued 401 Unauthorized error after a while)
- [Issue #1707](https://github.com/grafana/grafana/issues/1707). Unsaved changes: Do not show for snapshots, scripted and file based dashboards
- [Issue #1703](https://github.com/grafana/grafana/issues/1703). Unsaved changes: Do not show for users with role `Viewer`
- [Issue #1675](https://github.com/grafana/grafana/issues/1675). Data source proxy: Fixed issue with Gzip enabled and data source proxy
- [Issue #1681](https://github.com/grafana/grafana/issues/1681). MySQL session: fixed problem using mysql as session store
- [Issue #1671](https://github.com/grafana/grafana/issues/1671). Data sources: Fixed issue with changing default data source (should not require full page load to take effect, now fixed)
- [Issue #1685](https://github.com/grafana/grafana/issues/1685). Search: Dashboard results should be sorted alphabetically
- [Issue #1673](https://github.com/grafana/grafana/issues/1673). Basic auth: Fixed issue when using basic auth proxy infront of Grafana
# 2.0.0-Beta1 (2015-03-30)
**New features**
- [Issue #1623](https://github.com/grafana/grafana/issues/1623). Share Dashboard: Dashboard snapshot sharing (dash and data snapshot), save to local or save to public snapshot dashboard snapshots.raintank.io site
- [Issue #1622](https://github.com/grafana/grafana/issues/1622). Share Panel: The share modal now has an embed option, gives you an iframe that you can use to embedd a single graph on another web site
- [Issue #718](https://github.com/grafana/grafana/issues/718). Dashboard: When saving a dashboard and another user has made changes inbetween the user is promted with a warning if he really wants to overwrite the other's changes
- [Issue #1331](https://github.com/grafana/grafana/issues/1331). Graph & Singlestat: New axis/unit format selector and more units (kbytes, Joule, Watt, eV), and new design for graph axis & grid tab and single stat options tab views
- [Issue #1241](https://github.com/grafana/grafana/issues/1242). Timepicker: New option in timepicker (under dashboard settings), to change ``now`` to be for example ``now-1m``, usefull when you want to ignore last minute because it contains incomplete data
- [Issue #171](https://github.com/grafana/grafana/issues/171). Panel: Different time periods, panels can override dashboard relative time and/or add a time shift
- [Issue #1488](https://github.com/grafana/grafana/issues/1488). Dashboard: Clone dashboard / Save as
- [Issue #1458](https://github.com/grafana/grafana/issues/1458). User: persisted user option for dark or light theme (no longer an option on a dashboard)
- [Issue #452](https://github.com/grafana/grafana/issues/452). Graph: Adds logarithmic scale option for base 10, base 16 and base 1024
**Enhancements**
- [Issue #1366](https://github.com/grafana/grafana/issues/1366). Graph & Singlestat: Support for additional units, Fahrenheit (°F) and Celsius (°C), Humidity (%H), kW, watt-hour (Wh), kilowatt-hour (kWh), velocities (m/s, km/h, mpg, knot)
- [Issue #978](https://github.com/grafana/grafana/issues/978). Graph: Shared tooltip improvement, can now support metrics of different resolution/intervals
- [Issue #1297](https://github.com/grafana/grafana/issues/1297). Graphite: Added cumulative and minimumBelow graphite functions
- [Issue #1296](https://github.com/grafana/grafana/issues/1296). InfluxDB: Auto escape column names with special characters. Thanks @steven-aerts
- [Issue #1321](https://github.com/grafana/grafana/issues/1321). SingleStatPanel: You can now use template variables in pre & postfix
- [Issue #599](https://github.com/grafana/grafana/issues/599). Graph: Added right y axis label setting and graph support
- [Issue #1253](https://github.com/grafana/grafana/issues/1253). Graph & Singlestat: Users can now set decimal precision for legend and tooltips (override auto precision)
- [Issue #1255](https://github.com/grafana/grafana/issues/1255). Templating: Dashboard will now wait to load until all template variables that have refresh on load set or are initialized via url to be fully loaded and so all variables are in valid state before panels start issuing metric requests.
- [Issue #1344](https://github.com/grafana/grafana/issues/1344). OpenTSDB: Alias patterns (reference tag values), syntax is: $tag_tagname or [[tag_tagname]]
**Fixes**
- [Issue #1298](https://github.com/grafana/grafana/issues/1298). InfluxDB: Fix handling of empty array in templating variable query
- [Issue #1309](https://github.com/grafana/grafana/issues/1309). Graph: Fixed issue when using zero as a grid threshold
- [Issue #1345](https://github.com/grafana/grafana/issues/1345). UI: Fixed position of confirm modal when scrolled down
- [Issue #1372](https://github.com/grafana/grafana/issues/1372). Graphite: Fix for nested complex queries, where a query references a query that references another query (ie the #[A-Z] syntax)
- [Issue #1363](https://github.com/grafana/grafana/issues/1363). Templating: Fix to allow custom template variables to contain white space, now only splits on ','
- [Issue #1359](https://github.com/grafana/grafana/issues/1359). Graph: Fix for all series tooltip showing series with all null values when ``Hide Empty`` option is enabled
- [Issue #1497](https://github.com/grafana/grafana/issues/1497). Dashboard: Fixed memory leak when switching dashboards
**Changes**
- Dashboard title change & save will no longer create a new dashboard, it will just change the title.
**OpenTSDB breaking change**
- [Issue #1438](https://github.com/grafana/grafana/issues/1438). OpenTSDB: Automatic downsample interval passed to OpenTSDB (depends on timespan and graph width)
- NOTICE, Downsampling is now enabled by default, so if you have not picked a downsample aggregator in your metric query do so or your graphs will be missleading
- This will make Grafana a lot quicker for OpenTSDB users when viewing large time spans without having to change the downsample interval manually.
**Tech**
- [Issue #1311](https://github.com/grafana/grafana/issues/1311). Tech: Updated Font-Awesome from 3.2 to 4.2
# 1.9.1 (2014-12-29)
**Enhancements**
- [Issue #1028](https://github.com/grafana/grafana/issues/1028). Graph: New legend option ``hideEmtpy`` to hide series with only null values from legend
- [Issue #1242](https://github.com/grafana/grafana/issues/1242). OpenTSDB: Downsample query field now supports interval template variable
- [Issue #1126](https://github.com/grafana/grafana/issues/1126). InfluxDB: Support more than 10 series name segments when using alias ``$number`` patterns
**Fixes**
- [Issue #1251](https://github.com/grafana/grafana/issues/1251). Graph: Fix for y axis and scaled units (GiB etc) caused rounding, for example 400 GiB instead of 378 GiB
- [Issue #1199](https://github.com/grafana/grafana/issues/1199). Graph: fix for series tooltip when one series is hidden/disabled
- [Issue #1207](https://github.com/grafana/grafana/issues/1207). Graphite: movingAverage / movingMedian parameter type impovement, now handles int and interval parameter
# 1.9.0 (2014-12-02)
**Enhancements**
- [Issue #1130](https://github.com/grafana/grafana/issues/1130). SinglestatPanel: Added null point handling, and value to text mapping
**Fixes**
- [Issue #1087](https://github.com/grafana/grafana/issues/1087). Panel: Fixed IE9 crash due to angular drag drop
- [Issue #1093](https://github.com/grafana/grafana/issues/1093). SingleStatPanel: Fixed position for drilldown link tooltip when dashboard requires scrolling
- [Issue #1095](https://github.com/grafana/grafana/issues/1095). DrilldownLink: template variables in params property was not interpolated
- [Issue #1114](https://github.com/grafana/grafana/issues/1114). Graphite: Lexer fix, allow equal sign (=) in metric paths
- [Issue #1136](https://github.com/grafana/grafana/issues/1136). Graph: Fix to legend value Max and negative values
- [Issue #1150](https://github.com/grafana/grafana/issues/1150). SinglestatPanel: Fixed absolute drilldown link issue
- [Issue #1123](https://github.com/grafana/grafana/issues/1123). Firefox: Workaround for Firefox bug, casued input text fields to not be selectable and not have placeable cursor
- [Issue #1108](https://github.com/grafana/grafana/issues/1108). Graph: Fix for tooltip series order when series draw order was changed with zindex property
# 1.9.0-rc1 (2014-11-17)
**UI Improvements**
- [Issue #770](https://github.com/grafana/grafana/issues/770). UI: Panel dropdown menu replaced with a new panel menu
**Graph**
- [Issue #877](https://github.com/grafana/grafana/issues/877). Graph: Smart auto decimal precision when using scaled unit formats
- [Issue #850](https://github.com/grafana/grafana/issues/850). Graph: Shared tooltip that shows multiple series & crosshair line, thx @toni-moreno
- [Issue #940](https://github.com/grafana/grafana/issues/940). Graph: New series style override option "Fill below to", useful to visualize max & min as a shadow for the mean
- [Issue #1030](https://github.com/grafana/grafana/issues/1030). Graph: Legend table display/look changed, now includes column headers for min/max/avg, and full width (unless on right side)
- [Issue #861](https://github.com/grafana/grafana/issues/861). Graph: Export graph time series data as csv file
**New Panels**
- [Issue #951](https://github.com/grafana/grafana/issues/951). SingleStat: New singlestat panel
**Misc**
- [Issue #864](https://github.com/grafana/grafana/issues/846). Panel: Share panel feature, get a link to panel with the current time range
- [Issue #938](https://github.com/grafana/grafana/issues/938). Panel: Plugin panels now reside outside of app/panels directory
- [Issue #952](https://github.com/grafana/grafana/issues/952). Help: Shortcut "?" to open help modal with list of all shortcuts
- [Issue #991](https://github.com/grafana/grafana/issues/991). ScriptedDashboard: datasource services are now available in scripted dashboards, you can query datasource for metric keys, generate dashboards, and even save them in a scripted dashboard (see scripted_gen_and_save.js for example)
- [Issue #1041](https://github.com/grafana/grafana/issues/1041). Panel: All panels can now have links to other dashboards or absolute links, these links are available in the panel menu.
**Changes**
- [Issue #1007](https://github.com/grafana/grafana/issues/1007). Graph: Series hide/show toggle changed to be default exclusive, so clicking on a series name will show only that series. (SHIFT or meta)+click will toggle hide/show.
**OpenTSDB**
- [Issue #930](https://github.com/grafana/grafana/issues/930). OpenTSDB: Adding counter max and counter reset value to open tsdb query editor, thx @rsimiciuc
- [Issue #917](https://github.com/grafana/grafana/issues/917). OpenTSDB: Templating support for OpenTSDB series name and tags, thx @mchataigner
**InfluxDB**
- [Issue #714](https://github.com/grafana/grafana/issues/714). InfluxDB: Support for sub second resolution graphs
**Fixes**
- [Issue #925](https://github.com/grafana/grafana/issues/925). Graph: bar width calculation fix for some edge cases (bars would render on top of each other)
- [Issue #505](https://github.com/grafana/grafana/issues/505). Graph: fix for second y axis tick unit labels wrapping on the next line
- [Issue #987](https://github.com/grafana/grafana/issues/987). Dashboard: Collapsed rows became invisible when hide controls was enabled
=======
# 1.8.1 (2014-09-30)
**Fixes**
- [Issue #855](https://github.com/grafana/grafana/issues/855). Graph: Fix for scroll issue in graph edit mode when dropdown goes below screen
- [Issue #847](https://github.com/grafana/grafana/issues/847). Graph: Fix for series draw order not being the same after hiding/unhiding series
- [Issue #851](https://github.com/grafana/grafana/issues/851). Annotations: Fix for annotations not reloaded when switching between 2 dashboards with annotations
- [Issue #846](https://github.com/grafana/grafana/issues/846). Edit panes: Issue when open row or json editor when scrolled down the page, unable to scroll and you did not see editor
- [Issue #840](https://github.com/grafana/grafana/issues/840). Import: Fixes to import from json file and import from graphite. Issues was lingering state from previous dashboard.
- [Issue #859](https://github.com/grafana/grafana/issues/859). InfluxDB: Fix for bug when saving dashboard where title is the same as slugified url id
- [Issue #852](https://github.com/grafana/grafana/issues/852). White theme: Fixes for hidden series legend text and disabled annotations color
# 1.8.0 (2014-09-22)
Read this [blog post](http://grafana.org/blog/2014/09/11/grafana-1-8-0-rc1-released.html) for an overview of all improvements.
**Fixes**
- [Issue #802](https://github.com/grafana/grafana/issues/802). Annotations: Fix when using InfluxDB datasource
- [Issue #795](https://github.com/grafana/grafana/issues/795). Chrome: Fix for display issue in chrome beta & chrome canary when entering edit mode
- [Issue #818](https://github.com/grafana/grafana/issues/818). Graph: Added percent y-axis format
- [Issue #828](https://github.com/grafana/grafana/issues/828). Elasticsearch: saving new dashboard with title equal to slugified url would cause it to deleted.
- [Issue #830](https://github.com/grafana/grafana/issues/830). Annotations: Fix for elasticsearch annotations and mapping nested fields
# 1.8.0-RC1 (2014-09-12)
**UI polish / changes**
- [Issue #725](https://github.com/grafana/grafana/issues/725). UI: All modal editors are removed and replaced by an edit pane under menu. The look of editors is also updated and polished. Search dropdown is also shown as pane under menu and has seen some UI polish.
**Filtering/Templating feature overhaul**
- Filtering renamed to Templating, and filter items to variables
- Filter editing has gotten its own edit pane with much improved UI and options
- [Issue #296](https://github.com/grafana/grafana/issues/296). Templating: Can now retrieve variable values from a non-default data source
- [Issue #219](https://github.com/grafana/grafana/issues/219). Templating: Template variable value selection is now a typeahead autocomplete dropdown
- [Issue #760](https://github.com/grafana/grafana/issues/760). Templating: Extend template variable syntax to include $variable syntax replacement
- [Issue #234](https://github.com/grafana/grafana/issues/234). Templating: Interval variable type for time intervals summarize/group by parameter, included "auto" option, and auto step counts option.
- [Issue #262](https://github.com/grafana/grafana/issues/262). Templating: Ability to use template variables for function parameters via custom variable type, can be used as parameter for movingAverage or scaleToSeconds for example
- [Issue #312](https://github.com/grafana/grafana/issues/312). Templating: Can now use template variables in panel titles
- [Issue #613](https://github.com/grafana/grafana/issues/613). Templating: Full support for InfluxDB, filter by part of series names, extract series substrings, nested queries, multipe where clauses!
- Template variables can be initialized from url, with var-my_varname=value, breaking change, before it was just my_varname.
- Templating and url state sync has some issues that are not solved for this release, see [Issue #772](https://github.com/grafana/grafana/issues/772) for more details.
**InfluxDB Breaking changes**
- To better support templating, fill(0) and group by time low limit some changes has been made to the editor and query model schema
- Currently some of these changes are breaking
- If you used custom condition filter you need to open the graph in edit mode, the editor will update the schema, and the queries should work again
- If you used a raw query you need to remove the time filter and replace it with $timeFilter (this is done automatically when you switch from query editor to raw query, but old raw queries needs to updated)
- If you used group by and later removed the group by the graph could break, open in editor and should correct it
- InfluxDB annotation queries that used [[timeFilter]] should be updated to use $timeFilter syntax instead
- Might write an upgrade tool to update dashboards automatically, but right now master (1.8) includes the above breaking changes
**InfluxDB query editor enhancements**
- [Issue #756](https://github.com/grafana/grafana/issues/756). InfluxDB: Add option for fill(0) and fill(null), integrated help in editor for why this option is important when stacking series
- [Issue #743](https://github.com/grafana/grafana/issues/743). InfluxDB: A group by time option for all queries in graph panel that supports a low limit for auto group by time, very important for stacking and fill(0)
- The above to enhancements solves the problems associated with stacked bars and lines when points are missing, these issues are solved:
- [Issue #673](https://github.com/grafana/grafana/issues/673). InfluxDB: stacked bars missing intermediate data points, unless lines also enabled
- [Issue #674](https://github.com/grafana/grafana/issues/674). InfluxDB: stacked chart ignoring series without latest values
- [Issue #534](https://github.com/grafana/grafana/issues/534). InfluxDB: No order in stacked bars mode
**New features and improvements**
- [Issue #117](https://github.com/grafana/grafana/issues/117). Graphite: Graphite query builder can now handle functions that multiple series as arguments!
- [Issue #281](https://github.com/grafana/grafana/issues/281). Graphite: Metric node/segment selection is now a textbox with autocomplete dropdown, allow for custom glob expression for single node segment without entering text editor mode.
- [Issue #304](https://github.com/grafana/grafana/issues/304). Dashboard: View dashboard json, edit/update any panel using json editor, makes it possible to quickly copy a graph from one dashboard to another.
- [Issue #578](https://github.com/grafana/grafana/issues/578). Dashboard: Row option to display row title even when the row is visible
- [Issue #672](https://github.com/grafana/grafana/issues/672). Dashboard: panel fullscreen & edit state is present in url, can now link to graph in edit & fullscreen mode.
- [Issue #709](https://github.com/grafana/grafana/issues/709). Dashboard: Small UI look polish to search results, made dashboard title link are larger
- [Issue #425](https://github.com/grafana/grafana/issues/425). Graph: New section in 'Display Styles' tab to override any display setting on per series bases (mix and match lines, bars, points, fill, stack, line width etc)
- [Issue #634](https://github.com/grafana/grafana/issues/634). Dashboard: Dashboard tags now in different colors (from fixed palette) determined by tag name.
- [Issue #685](https://github.com/grafana/grafana/issues/685). Dashboard: New config.js option to change/remove window title prefix.
- [Issue #781](https://github.com/grafana/grafana/issues/781). Dashboard: Title URL is now slugified for greater URL readability, works with both ES & InfluxDB storage, is backward compatible
- [Issue #785](https://github.com/grafana/grafana/issues/785). Elasticsearch: Support for full elasticsearch lucene search grammar when searching for dashboards, better async search
- [Issue #787](https://github.com/grafana/grafana/issues/787). Dashboard: time range can now be read from URL parameters, will override dashboard saved time range
**Fixes**
- [Issue #696](https://github.com/grafana/grafana/issues/696). Graph: Fix for y-axis format 'none' when values are in scientific notation (ex 2.3e-13)
- [Issue #733](https://github.com/grafana/grafana/issues/733). Graph: Fix for tooltip current value decimal precision when 'none' axis format was selected
- [Issue #697](https://github.com/grafana/grafana/issues/697). Graphite: Fix for Glob syntax in graphite queries ([1-9] and ?) that made the query editor / parser bail and fallback to a text box.
- [Issue #702](https://github.com/grafana/grafana/issues/702). Graphite: Fix for nonNegativeDerivative function, now possible to not include optional first parameter maxValue
- [Issue #277](https://github.com/grafana/grafana/issues/277). Dashboard: Fix for timepicker date & tooltip when UTC timezone selected.
- [Issue #699](https://github.com/grafana/grafana/issues/699). Dashboard: Fix for bug when adding rows from dashboard settings dialog.
- [Issue #723](https://github.com/grafana/grafana/issues/723). Dashboard: Fix for hide controls setting not used/initialized on dashboard load
- [Issue #724](https://github.com/grafana/grafana/issues/724). Dashboard: Fix for zoom out causing right hand "to" range to be set in the future.
**Tech**
- Upgraded from angularjs 1.1.5 to 1.3 beta 17;
- Switch from underscore to lodash
- helpers to easily unit test angularjs controllers and services
- Test coverage through coveralls
- Upgrade from jquery 1.8.0 to 2.1.1 (**Removes support for IE7 & IE8**)
# 1.7.1 (unreleased)
**Fixes**
- [Issue #691](https://github.com/grafana/grafana/issues/691). Dashboard: Tooltip fixes, sometimes they would not show, and sometimes they would get stuck.
- [Issue #695](https://github.com/grafana/grafana/issues/695). Dashboard: Tooltip on goto home menu icon would get stuck after clicking on it
# 1.7.0 (2014-08-11)
**Fixes**
- [Issue #652](https://github.com/grafana/grafana/issues/652). Timepicker: Entering custom date range impossible when refresh is low (now is constantly reset)
- [Issue #450](https://github.com/grafana/grafana/issues/450). Graph: Tooltip does not disappear sometimes and would get stuck
- [Issue #655](https://github.com/grafana/grafana/issues/655). General: Auto refresh not initiated / started after dashboard loading
- [Issue #657](https://github.com/grafana/grafana/issues/657). General: Fix for refresh icon in IE browsers
- [Issue #661](https://github.com/grafana/grafana/issues/661). Annotations: Elasticsearch querystring with filter template replacements was not interpolated
- [Issue #660](https://github.com/grafana/grafana/issues/660). OpenTSDB: fix opentsdb queries that returned more than one series
**Change**
- [Issue #681](https://github.com/grafana/grafana/issues/681). Dashboard: The panel error bar has been replaced with a small error indicator, this indicator does not change panel height and is a lot less intrusive. Hover over it for short details, click on it for more details.
# 1.7.0-rc1 (2014-08-05)
**New features or improvements**
- [Issue #581](https://github.com/grafana/grafana/issues/581). InfluxDB: Add continuous query in series results (series typeahead).
- [Issue #584](https://github.com/grafana/grafana/issues/584). InfluxDB: Support for alias & alias patterns when using raw query mode
- [Issue #394](https://github.com/grafana/grafana/issues/394). InfluxDB: Annotation support
- [Issue #633](https://github.com/grafana/grafana/issues/633). InfluxDB: InfluxDB can now act as a datastore for dashboards
- [Issue #610](https://github.com/grafana/grafana/issues/610). InfluxDB: Support for InfluxdB v0.8 list series response schemea (series typeahead)
- [Issue #525](https://github.com/grafana/grafana/issues/525). InfluxDB: Enhanced series aliasing (legend names) with pattern replacements
- [Issue #266](https://github.com/grafana/grafana/issues/266). Graphite: New option cacheTimeout to override graphite default memcache timeout
- [Issue #606](https://github.com/grafana/grafana/issues/606). General: New global option in config.js to specify admin password (useful to hinder users from accidentally make changes)
- [Issue #201](https://github.com/grafana/grafana/issues/201). Annotations: Elasticsearch datasource support for events
- [Issue #344](https://github.com/grafana/grafana/issues/344). Annotations: Annotations can now be fetched from non default datasources
- [Issue #631](https://github.com/grafana/grafana/issues/631). Search: max_results config.js option & scroll in search results (To show more or all dashboards)
- [Issue #511](https://github.com/grafana/grafana/issues/511). Text panel: Allow [[..]] filter notation in all text panels (markdown/html/text)
- [Issue #136](https://github.com/grafana/grafana/issues/136). Graph: New legend display option "Align as table"
- [Issue #556](https://github.com/grafana/grafana/issues/556). Graph: New legend display option "Right side", will show legend to the right of the graph
- [Issue #604](https://github.com/grafana/grafana/issues/604). Graph: New axis format, 'bps' (SI unit in steps of 1000) useful for network gear metics
- [Issue #626](https://github.com/grafana/grafana/issues/626). Graph: Downscale y axis to more precise unit, value of 0.1 for seconds format will be formated as 100 ms. Thanks @kamaradclimber
- [Issue #618](https://github.com/grafana/grafana/issues/618). OpenTSDB: Series alias option to override metric name returned from opentsdb. Thanks @heldr
**Documentation**
- [Issue #635](https://github.com/grafana/grafana/issues/635). Docs for features and changes in v1.7, new troubleshooting guide, new Getting started guide, improved install & config guide.
**Changes**
- [Issue #536](https://github.com/grafana/grafana/issues/536). Graphite: Use unix epoch for Graphite from/to for absolute time ranges
- [Issue #641](https://github.com/grafana/grafana/issues/536). General: Dashboard save temp copy feature settings moved from dashboard to config.js, default is enabled, and ttl to 30 days
- [Issue #532](https://github.com/grafana/grafana/issues/532). Schema: Dashboard schema changes, "Unsaved changes" should not appear for schema changes. All changes are backward compatible with old schema.
**Fixes**
- [Issue #545](https://github.com/grafana/grafana/issues/545). Graph: Fix formatting negative values (axis formats, legend values)
- [Issue #460](https://github.com/grafana/grafana/issues/460). Graph: fix for max legend value when max value is zero
- [Issue #628](https://github.com/grafana/grafana/issues/628). Filtering: Fix for nested filters, changing a child filter could result in infinite recursion in some cases
- [Issue #528](https://github.com/grafana/grafana/issues/528). Graphite: Fix for graphite expressions parser failure when metric expressions starts with curly brace segment
# 1.6.1 (2014-06-24)
**New features or improvements**
- [Issue #360](https://github.com/grafana/grafana/issues/360). Ability to set y min/max for right y-axis (RR #519)
**Fixes**
- [Issue #500](https://github.com/grafana/grafana/issues/360). Fixes regex InfluxDB queries intoduced in 1.6.0
- [Issue #506](https://github.com/grafana/grafana/issues/506). Bug in when using % sign in legends (aliases), fixed by removing url decoding of metric names
- [Issue #522](https://github.com/grafana/grafana/issues/522). Series names and column name typeahead cache fix
- [Issue #504](https://github.com/grafana/grafana/issues/504). Fixed influxdb issue with raw query that caused wrong value column detection
- [Issue #526](https://github.com/grafana/grafana/issues/526). Default property that marks which datasource is default in config.js is now optional
- [Issue #342](https://github.com/grafana/grafana/issues/342). Auto-refresh caused 2 refreshes (and hence mulitple queries) each time (at least in firefox)
# 1.6.0 (2014-06-16)
#### New features or improvements
- [Issue #427](https://github.com/grafana/grafana/issues/427). New Y-axis formater for metric values that represent seconds, Thanks @jippi
- [Issue #390](https://github.com/grafana/grafana/issues/390). Allow special characters in serie names (influxdb datasource), Thanks @majst01
- [Issue #428](https://github.com/grafana/grafana/issues/428). Refactoring of filterSrv, Thanks @Tetha
- [Issue #445](https://github.com/grafana/grafana/issues/445). New config for playlist feature. Set playlist_timespan to set default playlist interval, Thanks @rmca
- [Issue #461](https://github.com/grafana/grafana/issues/461). New graphite function definition added isNonNull, Thanks @tmonk42
- [Issue #455](https://github.com/grafana/grafana/issues/455). New InfluxDB function difference add to function dropdown
- [Issue #459](https://github.com/grafana/grafana/issues/459). Added parameter to keepLastValue graphite function definition (default 100)
[Issue #418](https://github.com/grafana/grafana/issues/418). to the browser cache when upgrading grafana and improve load performance
- [Issue #327](https://github.com/grafana/grafana/issues/327). Partial support for url encoded metrics when using Graphite datasource. Thanks @axe-felix
- [Issue #473](https://github.com/grafana/grafana/issues/473). Improvement to InfluxDB query editor and function/value column selection
- [Issue #375](https://github.com/grafana/grafana/issues/375). Initial support for filtering (templated queries) for InfluxDB. Thanks @mavimo
- [Issue #475](https://github.com/grafana/grafana/issues/475). Row editing and adding new panel is now a lot quicker and easier with the new row menu
- [Issue #211](https://github.com/grafana/grafana/issues/211). New datasource! Initial support for OpenTSDB, Thanks @mpage
- [Issue #492](https://github.com/grafana/grafana/issues/492). Improvement and polish to the OpenTSDB query editor
- [Issue #441](https://github.com/grafana/grafana/issues/441). Influxdb group by support, Thanks @piis3
- improved asset (css/js) build pipeline, added revision to css and js. Will remove issues related
#### Changes
- [Issue #475](https://github.com/grafana/grafana/issues/475). Add panel icon and Row edit button is replaced by the Row edit menu
- New graphs now have a default empty query
- Add Row button now creates a row with default height of 250px (no longer opens dashboard settings modal)
- Clean up of config.sample.js, graphiteUrl removed (still works, but depricated, removed in future)
Use datasources config instead. panel_names removed from config.js. Use plugins.panels to add custom panels
- Graphite panel is now renamed graph (Existing dashboards will still work)
#### Fixes
- [Issue #126](https://github.com/grafana/grafana/issues/126). Graphite query lexer change, can now handle regex parameters for aliasSub function
- [Issue #447](https://github.com/grafana/grafana/issues/447). Filter option loading when having muliple nested filters now works better. Options are now reloaded correctly and there are no multiple renders/refresh inbetween.
- [Issue #412](https://github.com/grafana/grafana/issues/412). After a filter option is changed and a nested template param is reloaded, if the current value exists after the options are reloaded the current selected value is kept.
- [Issue #460](https://github.com/grafana/grafana/issues/460). Legend Current value did not display when value was zero
- [Issue #328](https://github.com/grafana/grafana/issues/328). Fix to series toggling bug that caused annotations to be hidden when toggling/hiding series.
- [Issue #293](https://github.com/grafana/grafana/issues/293). Fix for graphite function selection menu that some times draws outside screen. It now displays upward
- [Issue #350](https://github.com/grafana/grafana/issues/350). Fix for exclusive series toggling (hold down CTRL, SHIFT or META key) and left click a series for exclusive toggling
- [Issue #472](https://github.com/grafana/grafana/issues/472). CTRL does not work on MAC OSX but SHIFT or META should (depending on browser)
# 1.5.4 (2014-05-13)
### New features and improvements
- InfluxDB enhancement: support for multiple hosts (with retries) and raw queries ([Issue #318](https://github.com/grafana/grafana/issues/318), thx @toddboom)
- Added rounding for graphites from and to time range filters
for very short absolute ranges ([Issue #320](https://github.com/grafana/grafana/issues/320))
- Increased resolution for graphite datapoints (maxDataPoints), now equal to panel pixel width. ([Issue #5](https://github.com/grafana/grafana/issues/5))
- Improvement to influxdb query editor, can now add where clause and alias ([Issue #331](https://github.com/grafana/grafana/issues/331), thanks @mavimo)
- New config setting for graphite datasource to control if json render request is POST or GET ([Issue #345](https://github.com/grafana/grafana/issues/345))
- Unsaved changes warning feature ([Issue #324](https://github.com/grafana/grafana/issues/324))
- Improvement to series toggling, CTRL+MouseClick on series name will now hide all others ([Issue #350](https://github.com/grafana/grafana/issues/350))
### Changes
- Graph default setting for Y-Min changed from zero to auto scalling (will not effect existing dashboards). ([Issue #386](https://github.com/grafana/grafana/issues/386)) - thx @kamaradclimber
### Fixes
- Fixes to filters and "All" option. It now never uses "*" as value, but all options in a {node1, node2, node3} expression ([Issue #228](https://github.com/grafana/grafana/issues/228), #359)
- Fix for InfluxDB query generation with columns containing dots or dashes ([Issue #369](https://github.com/grafana/grafana/issues/369), #348) - Thanks to @jbripley
# 1.5.3 (2014-04-17)
- Add support for async scripted dashboards ([Issue #274](https://github.com/grafana/grafana/issues/274))
- Text panel now accepts html (for links to other dashboards, etc) ([Issue #236](https://github.com/grafana/grafana/issues/236))
- Fix for Text panel, now changes take effect directly ([Issue #251](https://github.com/grafana/grafana/issues/251))
- Fix when adding functions without params that did not cause graph to update ([Issue #267](https://github.com/grafana/grafana/issues/267))
- Graphite errors are now much easier to see and troubleshoot with the new inspector ([Issue #265](https://github.com/grafana/grafana/issues/265))
- Use influxdb aliases to distinguish between multiple columns ([Issue #283](https://github.com/grafana/grafana/issues/283))
- Correction to ms axis formater, now formats days correctly. ([Issue #189](https://github.com/grafana/grafana/issues/189))
- Css fix for Firefox and using top menu dropdowns in panel fullscren / edit mode ([Issue #106](https://github.com/grafana/grafana/issues/106))
- Browser page title is now Grafana - {{dashboard title}} ([Issue #294](https://github.com/grafana/grafana/issues/294))
- Disable auto refresh zooming in (every time you change to an absolute time range), refresh will be restored when you change time range back to relative ([Issue #282](https://github.com/grafana/grafana/issues/282))
- More graphite functions
# 1.5.2 (2014-03-24)
### New Features and improvements
- Support for second optional params for functions like aliasByNode ([Issue #167](https://github.com/grafana/grafana/issues/167)). Read the wiki on the [Function Editor](https://github.com/torkelo/grafana/wiki/Graphite-Function-Editor) for more info.
- More functions added to InfluxDB query editor ([Issue #218](https://github.com/grafana/grafana/issues/218))
- Filters can now be used inside other filters (templated segments) ([Issue #128](https://github.com/grafana/grafana/issues/128))
- More graphite functions added
### Fixes
- Float arguments now work for functions like scale ([Issue #223](https://github.com/grafana/grafana/issues/223))
- Fix for graphite function editor, the graph & target was not updated after adding a function and leaving default params as is #191
The zip files now contains a sub folder with project name and version prefix. ([Issue #209](https://github.com/grafana/grafana/issues/209))
# 1.5.1 (2014-03-10)
### Fixes
- maxDataPoints must be an integer #184 (thanks @frejsoya for fixing this)
For people who are find Grafana slow for large time spans or high resolution metrics. This is most likely due to graphite returning a large number of datapoints. The maxDataPoints parameter solves this issue. For maxDataPoints to work you need to run the latest graphite-web (some builds of 0.9.12 does not include this feature).
Read this for more info:
[Performance for large time spans](https://github.com/torkelo/grafana/wiki/Performance-for-large-time-spans)
# 1.5.0 (2014-03-09)
### New Features and improvements
- New function editor [video demo](http://youtu.be/I90WHRwE1ZM) ([Issue #178](https://github.com/grafana/grafana/issues/178))
- Links to function documentation from function editor ([Issue #3](https://github.com/grafana/grafana/issues/3))
- Reorder functions ([Issue #130](https://github.com/grafana/grafana/issues/130))
- [Initial support for InfluxDB](https://github.com/torkelo/grafana/wiki/InfluxDB) as metric datasource (#103), need feedback!
- [Dashboard playlist](https://github.com/torkelo/grafana/wiki/Dashboard-playlist) ([Issue #36](https://github.com/grafana/grafana/issues/36))
- When adding aliasByNode smartly set node number ([Issue #175](https://github.com/grafana/grafana/issues/175))
- Support graphite identifiers with embedded colons ([Issue #173](https://github.com/grafana/grafana/issues/173))
- Typeahead & autocomplete when adding new function ([Issue #164](https://github.com/grafana/grafana/issues/164))
- More graphite function definitions
- Make "ms" axis format include hour, day, weeks, month and year ([Issue #149](https://github.com/grafana/grafana/issues/149))
- Microsecond axis format ([Issue #146](https://github.com/grafana/grafana/issues/146))
- Specify template parameters in URL ([Issue #123](https://github.com/grafana/grafana/issues/123))
### Fixes
- Basic Auth fix ([Issue #152](https://github.com/grafana/grafana/issues/152))
- Fix to annotations with graphite source & null values ([Issue #138](https://github.com/grafana/grafana/issues/138))
# 1.4.0 (2014-02-21)
### New Features
- #44 Annotations! Required a lot of work to get right. Read wiki article for more info. Supported annotations data sources are graphite metrics and graphite events. Support for more will be added in the future!
- #35 Support for multiple graphite servers! (Read wiki article for more)
- #116 Back to dashboard link in top menu to easily exist full screen / edit mode.
- #114, #97 Legend values now use the same y axes formatter
- #77 Improvements and polish to the light theme
### Changes
- #98 Stack is no longer by default turned on in graph display settings.
- Hide controls (Ctrl+h) now hides the sub menu row (where filtering, and annotations are). So if you had filtering enabled and hide controls enabled you will not see the filtering sub menu.
### Fixes:
- #94 Fix for bug that caused dashboard settings to sometimes not contain timepicker tab.
- #110 Graph with many many metrics caused legend to push down graph editor below screen. You can now scroll in edit mode & full screen mode for graphs with lots of series & legends.
- #104 Improvement to graphite target editor, select wildcard now gives you a "select metric" link for the next node.
- #105 Added zero as a possible node value in groupByAlias function
# 1.3.0 (2014-02-13)
### New features or improvements
- #86 Dashboard tags and search (see wiki article for details)
- #54 Enhancement to filter / template. "Include All" improvement
- #82 Dashboard search result sorted in alphabetical order
### Fixes
- #91 Custom date selector is one day behind
- #89 Filter / template does not work after switching dashboard
- #88 Closed / Minimized row css bug
- #85 Added all parameters to summarize function
- #83 Stack as percent should now work a lot better!
# 1.2.0 (2014-02-10)
### New features
- #70 Grid Thresholds (warning and error regions or lines in graph)
- #72 Added an example of a scripted dashboard and a short wiki article documenting scripted dashboards.
### Fixes
- #81 Grid min/max values are ignored bug
- #80 "stacked as percent" graphs should always use "max" value of 100 bug
- #73 Left Y format change did not work
- #42 Fixes to grid min/max auto scaling
- #69 Fixes to lexer/parser for metrics segments like "10-20".
- #67 Allow decimal input for scale function
- #68 Bug when trying to open dashboard while in edit mode
# 1.1.0 (2014-02-06)
### New features:
- #22 Support for native graphite png renderer, does not support click and select zoom yet
- #60 Support for legend values (cactiStyle, min, max, current, total, avg). The options for these are found in the new "Axes & Grid" tab for now.
- #62 There is now a "New" button in the search/open dashboard view to quickly open a clean empty dashboard.
- #55 Basic auth is now supported for elastic search as well
- some new function definitions added (will focus more on this for next release).
### Fixes
- #45 zero values from graphite was handled as null.
- #63 Kibana / Grafana on same host would use same localStorage keys, now fixed
- #46 Impossible to edit graph without a name fixed.
- #24 fix for dashboard search when elastic search is configured to disable _all field.
- #38 Improvement to lexer / parser to support pure numeric literals in metric segments
Thanks to everyone who contributed fixes and provided feedback :+1:
# 1.0.4 (2014-01-24)
- [Issue #28](https://github.com/grafana/grafana/issues/28) - Relative time range caused 500 graphite error in some cases (thx rsommer for the fix)
# 1.0.3 (2014-01-23)
- #9 Add Y-axis format for milliseconds
- #16 Add support for Basic Auth (use http://username:password@yourgraphitedomain.com)
- #13 Relative time ranges now uses relative time ranges when issuing graphite query
# 1.0.2 (2014-01-21)
- [Issue #12](https://github.com/grafana/grafana/issues/12), should now work ok without ElasticSearch
# 1.0.1 (2014-01-21)
- Resize fix
- Improvements to drag & drop
- Added a few graphite function definitions
- Fixed duplicate panel bug
- Updated default dashboard with welcome message and randomWalk graph
# 1.0.0 (2014-01-19)
First public release

14
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,14 @@
If you have any idea for an improvement or found a bug do not hesitate to open an issue.
And if you have time clone this repo and submit a pull request and help me make Grafana the
kickass metrics & devops dashboard we all dream about!
Prerequisites:
- Nodejs (for jshint & grunt & development server)
Clone repository:
npm install
grunt server (starts development web server in src folder)
grunt (runs jshint and less -> css compilation)
Please remember to run grunt before doing pull request to verify that your code passes all the jshint validations.

96
Godeps/Godeps.json generated Normal file
View File

@@ -0,0 +1,96 @@
{
"ImportPath": "github.com/grafana/grafana",
"GoVersion": "go1.4.2",
"Packages": [
"./pkg/..."
],
"Deps": [
{
"ImportPath": "github.com/Unknwon/com",
"Rev": "d9bcf409c8a368d06c9b347705c381e7c12d54df"
},
{
"ImportPath": "github.com/Unknwon/macaron",
"Rev": "93de4f3fad97bf246b838f828e2348f46f21f20a"
},
{
"ImportPath": "github.com/go-sql-driver/mysql",
"Comment": "v1.2-26-g9543750",
"Rev": "9543750295406ef070f7de8ae9c43ccddd44e15e"
},
{
"ImportPath": "github.com/go-xorm/core",
"Rev": "be6e7ac47dc57bd0ada25322fa526944f66ccaa6"
},
{
"ImportPath": "github.com/go-xorm/xorm",
"Comment": "v0.4.2-58-ge2889e5",
"Rev": "e2889e5517600b82905f1d2ba8b70deb71823ffe"
},
{
"ImportPath": "github.com/gosimple/slug",
"Rev": "a2392a4a87fa0366cbff131d3fd421f83f52492f"
},
{
"ImportPath": "github.com/jtolds/gls",
"Rev": "f1ac7f4f24f50328e6bc838ca4437d1612a0243c"
},
{
"ImportPath": "github.com/lib/pq",
"Comment": "go1.0-cutoff-13-g19eeca3",
"Rev": "19eeca3e30d2577b1761db471ec130810e67f532"
},
{
"ImportPath": "github.com/macaron-contrib/binding",
"Rev": "0fbe4b9707e6eb556ef843e5471592f55ce0a5e7"
},
{
"ImportPath": "github.com/macaron-contrib/session",
"Rev": "31e841d95c7302b9ac456c830ea2d6dfcef4f84a"
},
{
"ImportPath": "github.com/mattn/go-sqlite3",
"Rev": "e28cd440fabdd39b9520344bc26829f61db40ece"
},
{
"ImportPath": "github.com/smartystreets/goconvey/convey",
"Comment": "1.5.0-356-gfbc0a1c",
"Rev": "fbc0a1c888f9f96263f9a559d1769905245f1123"
},
{
"ImportPath": "github.com/streadway/amqp",
"Rev": "150b7f24d6ad507e6026c13d85ce1f1391ac7400"
},
{
"ImportPath": "golang.org/x/net/context",
"Rev": "972f0c5fbe4ae29e666c3f78c3ed42ae7a448b0a"
},
{
"ImportPath": "golang.org/x/oauth2",
"Rev": "c58fcf0ffc1c772aa2e1ee4894bc19f2649263b2"
},
{
"ImportPath": "gopkg.in/bufio.v1",
"Comment": "v1",
"Rev": "567b2bfa514e796916c4747494d6ff5132a1dfce"
},
{
"ImportPath": "gopkg.in/ini.v1",
"Comment": "v0-16-g1772191",
"Rev": "177219109c97e7920c933e21c9b25f874357b237"
},
{
"ImportPath": "gopkg.in/redis.v2",
"Comment": "v2.3.2",
"Rev": "e6179049628164864e6e84e973cfb56335748dea"
},
{
"ImportPath": "gopkgs.com/pool.v1",
"Rev": "c850f092aad1780cbffff25f471c5cc32097932a"
},
{
"ImportPath": "gopkgs.com/unidecode.v1",
"Rev": "4deae2c05236b41cc39f8144ac87a837ba974d40"
}
]
}

5
Godeps/Readme generated Normal file
View File

@@ -0,0 +1,5 @@
This directory tree is generated automatically by godep.
Please do not edit.
See https://github.com/tools/godep for more information.

2
Godeps/_workspace/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,2 @@
/pkg
/bin

View File

@@ -0,0 +1,24 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
.idea
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
*.iml

191
Godeps/_workspace/src/github.com/Unknwon/com/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,191 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and
distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright
owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities
that control, are controlled by, or are under common control with that entity.
For the purposes of this definition, "control" means (i) the power, direct or
indirect, to cause the direction or management of such entity, whether by
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising
permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including
but not limited to software source code, documentation source, and configuration
files.
"Object" form shall mean any form resulting from mechanical transformation or
translation of a Source form, including but not limited to compiled object code,
generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made
available under the License, as indicated by a copyright notice that is included
in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that
is based on (or derived from) the Work and for which the editorial revisions,
annotations, elaborations, or other modifications represent, as a whole, an
original work of authorship. For the purposes of this License, Derivative Works
shall not include works that remain separable from, or merely link (or bind by
name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version
of the Work and any modifications or additions to that Work or Derivative Works
thereof, that is intentionally submitted to Licensor for inclusion in the Work
by the copyright owner or by an individual or Legal Entity authorized to submit
on behalf of the copyright owner. For the purposes of this definition,
"submitted" means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems, and
issue tracking systems that are managed by, or on behalf of, the Licensor for
the purpose of discussing and improving the Work, but excluding communication
that is conspicuously marked or otherwise designated in writing by the copyright
owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
of whom a Contribution has been received by Licensor and subsequently
incorporated within the Work.
2. Grant of Copyright License.
Subject to the terms and conditions of this License, each Contributor hereby
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
irrevocable copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the Work and such
Derivative Works in Source or Object form.
3. Grant of Patent License.
Subject to the terms and conditions of this License, each Contributor hereby
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to make, have
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
such license applies only to those patent claims licensable by such Contributor
that are necessarily infringed by their Contribution(s) alone or by combination
of their Contribution(s) with the Work to which such Contribution(s) was
submitted. If You institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
Contribution incorporated within the Work constitutes direct or contributory
patent infringement, then any patent licenses granted to You under this License
for that Work shall terminate as of the date such litigation is filed.
4. Redistribution.
You may reproduce and distribute copies of the Work or Derivative Works thereof
in any medium, with or without modifications, and in Source or Object form,
provided that You meet the following conditions:
You must give any other recipients of the Work or Derivative Works a copy of
this License; and
You must cause any modified files to carry prominent notices stating that You
changed the files; and
You must retain, in the Source form of any Derivative Works that You distribute,
all copyright, patent, trademark, and attribution notices from the Source form
of the Work, excluding those notices that do not pertain to any part of the
Derivative Works; and
If the Work includes a "NOTICE" text file as part of its distribution, then any
Derivative Works that You distribute must include a readable copy of the
attribution notices contained within such NOTICE file, excluding those notices
that do not pertain to any part of the Derivative Works, in at least one of the
following places: within a NOTICE text file distributed as part of the
Derivative Works; within the Source form or documentation, if provided along
with the Derivative Works; or, within a display generated by the Derivative
Works, if and wherever such third-party notices normally appear. The contents of
the NOTICE file are for informational purposes only and do not modify the
License. You may add Your own attribution notices within Derivative Works that
You distribute, alongside or as an addendum to the NOTICE text from the Work,
provided that such additional attribution notices cannot be construed as
modifying the License.
You may add Your own copyright statement to Your modifications and may provide
additional or different license terms and conditions for use, reproduction, or
distribution of Your modifications, or for any such Derivative Works as a whole,
provided Your use, reproduction, and distribution of the Work otherwise complies
with the conditions stated in this License.
5. Submission of Contributions.
Unless You explicitly state otherwise, any Contribution intentionally submitted
for inclusion in the Work by You to the Licensor shall be under the terms and
conditions of this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify the terms of
any separate license agreement you may have executed with Licensor regarding
such Contributions.
6. Trademarks.
This License does not grant permission to use the trade names, trademarks,
service marks, or product names of the Licensor, except as required for
reasonable and customary use in describing the origin of the Work and
reproducing the content of the NOTICE file.
7. Disclaimer of Warranty.
Unless required by applicable law or agreed to in writing, Licensor provides the
Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
including, without limitation, any warranties or conditions of TITLE,
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
solely responsible for determining the appropriateness of using or
redistributing the Work and assume any risks associated with Your exercise of
permissions under this License.
8. Limitation of Liability.
In no event and under no legal theory, whether in tort (including negligence),
contract, or otherwise, unless required by applicable law (such as deliberate
and grossly negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special, incidental,
or consequential damages of any character arising as a result of this License or
out of the use or inability to use the Work (including but not limited to
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
any and all other commercial damages or losses), even if such Contributor has
been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability.
While redistributing the Work or Derivative Works thereof, You may choose to
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
other liability obligations and/or rights consistent with this License. However,
in accepting such obligations, You may act only on Your own behalf and on Your
sole responsibility, not on behalf of any other Contributor, and only if You
agree to indemnify, defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason of your
accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work
To apply the Apache License to your work, attach the following boilerplate
notice, with the fields enclosed by brackets "[]" replaced with your own
identifying information. (Don't include the brackets!) The text should be
enclosed in the appropriate comment syntax for the file format. We also
recommend that a file or class name and description of purpose be included on
the same "printed page" as the copyright notice for easier identification within
third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

24
Godeps/_workspace/src/github.com/Unknwon/com/README.md generated vendored Normal file
View File

@@ -0,0 +1,24 @@
Common functions
===
[![Build Status](https://drone.io/github.com/Unknwon/com/status.png)](https://drone.io/github.com/Unknwon/com/latest) [![Go Walker](http://gowalker.org/api/v1/badge)](http://gowalker.org/github.com/Unknwon/com)
This is an open source project for commonly used functions for the Go programming language.
This package need >= **go 1.2**
Code Convention: based on [Go Code Convention](https://github.com/Unknwon/go-code-convention).
## Contribute
Your contribute is welcome, but you have to check following steps after you added some functions and commit them:
1. Make sure you wrote user-friendly comments for **all functions** .
2. Make sure you wrote test cases with any possible condition for **all functions** in file `*_test.go`.
3. Make sure you wrote benchmarks for **all functions** in file `*_test.go`.
4. Make sure you wrote useful examples for **all functions** in file `example_test.go`.
5. Make sure you ran `go test -bench="."` and got **PASS** .
## Performance
See results on [drone.io](https://drone.io/github.com/Unknwon/com/latest) by `go test -bench="."`.

161
Godeps/_workspace/src/github.com/Unknwon/com/cmd.go generated vendored Normal file
View File

@@ -0,0 +1,161 @@
// +build go1.2
// Copyright 2013 com authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
// Package com is an open source project for commonly used functions for the Go programming language.
package com
import (
"bytes"
"fmt"
"os/exec"
"runtime"
"strings"
)
// ExecCmdDirBytes executes system command in given directory
// and return stdout, stderr in bytes type, along with possible error.
func ExecCmdDirBytes(dir, cmdName string, args ...string) ([]byte, []byte, error) {
bufOut := new(bytes.Buffer)
bufErr := new(bytes.Buffer)
cmd := exec.Command(cmdName, args...)
cmd.Dir = dir
cmd.Stdout = bufOut
cmd.Stderr = bufErr
err := cmd.Run()
return bufOut.Bytes(), bufErr.Bytes(), err
}
// ExecCmdBytes executes system command
// and return stdout, stderr in bytes type, along with possible error.
func ExecCmdBytes(cmdName string, args ...string) ([]byte, []byte, error) {
return ExecCmdDirBytes("", cmdName, args...)
}
// ExecCmdDir executes system command in given directory
// and return stdout, stderr in string type, along with possible error.
func ExecCmdDir(dir, cmdName string, args ...string) (string, string, error) {
bufOut, bufErr, err := ExecCmdDirBytes(dir, cmdName, args...)
return string(bufOut), string(bufErr), err
}
// ExecCmd executes system command
// and return stdout, stderr in string type, along with possible error.
func ExecCmd(cmdName string, args ...string) (string, string, error) {
return ExecCmdDir("", cmdName, args...)
}
// _________ .__ .____
// \_ ___ \ ____ | | ___________ | | ____ ____
// / \ \/ / _ \| | / _ \_ __ \ | | / _ \ / ___\
// \ \___( <_> ) |_( <_> ) | \/ | |__( <_> ) /_/ >
// \______ /\____/|____/\____/|__| |_______ \____/\___ /
// \/ \/ /_____/
// Color number constants.
const (
Gray = uint8(iota + 90)
Red
Green
Yellow
Blue
Magenta
//NRed = uint8(31) // Normal
EndColor = "\033[0m"
)
// getColorLevel returns colored level string by given level.
func getColorLevel(level string) string {
level = strings.ToUpper(level)
switch level {
case "TRAC":
return fmt.Sprintf("\033[%dm%s\033[0m", Blue, level)
case "ERRO":
return fmt.Sprintf("\033[%dm%s\033[0m", Red, level)
case "WARN":
return fmt.Sprintf("\033[%dm%s\033[0m", Magenta, level)
case "SUCC":
return fmt.Sprintf("\033[%dm%s\033[0m", Green, level)
default:
return level
}
}
// ColorLogS colors log and return colored content.
// Log format: <level> <content [highlight][path]> [ error ].
// Level: TRAC -> blue; ERRO -> red; WARN -> Magenta; SUCC -> green; others -> default.
// Content: default; path: yellow; error -> red.
// Level has to be surrounded by "[" and "]".
// Highlights have to be surrounded by "# " and " #"(space), "#" will be deleted.
// Paths have to be surrounded by "( " and " )"(space).
// Errors have to be surrounded by "[ " and " ]"(space).
// Note: it hasn't support windows yet, contribute is welcome.
func ColorLogS(format string, a ...interface{}) string {
log := fmt.Sprintf(format, a...)
var clog string
if runtime.GOOS != "windows" {
// Level.
i := strings.Index(log, "]")
if log[0] == '[' && i > -1 {
clog += "[" + getColorLevel(log[1:i]) + "]"
}
log = log[i+1:]
// Error.
log = strings.Replace(log, "[ ", fmt.Sprintf("[\033[%dm", Red), -1)
log = strings.Replace(log, " ]", EndColor+"]", -1)
// Path.
log = strings.Replace(log, "( ", fmt.Sprintf("(\033[%dm", Yellow), -1)
log = strings.Replace(log, " )", EndColor+")", -1)
// Highlights.
log = strings.Replace(log, "# ", fmt.Sprintf("\033[%dm", Gray), -1)
log = strings.Replace(log, " #", EndColor, -1)
} else {
// Level.
i := strings.Index(log, "]")
if log[0] == '[' && i > -1 {
clog += "[" + log[1:i] + "]"
}
log = log[i+1:]
// Error.
log = strings.Replace(log, "[ ", "[", -1)
log = strings.Replace(log, " ]", "]", -1)
// Path.
log = strings.Replace(log, "( ", "(", -1)
log = strings.Replace(log, " )", ")", -1)
// Highlights.
log = strings.Replace(log, "# ", "", -1)
log = strings.Replace(log, " #", "", -1)
}
return clog + log
}
// ColorLog prints colored log to stdout.
// See color rules in function 'ColorLogS'.
func ColorLog(format string, a ...interface{}) {
fmt.Print(ColorLogS(format, a...))
}

View File

@@ -0,0 +1,140 @@
// Copyright 2013 com authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package com
import (
"fmt"
"runtime"
"strings"
"testing"
)
func TestColorLogS(t *testing.T) {
if runtime.GOOS != "windows" {
// Trace + path.
cls := ColorLogS("[TRAC] Trace level test with path( %s )", "/path/to/somethere")
clsR := fmt.Sprintf(
"[\033[%dmTRAC%s] Trace level test with path(\033[%dm%s%s)",
Blue, EndColor, Yellow, "/path/to/somethere", EndColor)
if cls != clsR {
t.Errorf("ColorLogS:\n Expect => %s\n Got => %s\n", clsR, cls)
}
// Error + error.
cls = ColorLogS("[ERRO] Error level test with error[ %s ]", "test error")
clsR = fmt.Sprintf(
"[\033[%dmERRO%s] Error level test with error[\033[%dm%s%s]",
Red, EndColor, Red, "test error", EndColor)
if cls != clsR {
t.Errorf("ColorLogS:\n Expect => %s\n Got => %s\n", clsR, cls)
}
// Warning + highlight.
cls = ColorLogS("[WARN] Warnning level test with highlight # %s #", "special offer!")
clsR = fmt.Sprintf(
"[\033[%dmWARN%s] Warnning level test with highlight \033[%dm%s%s",
Magenta, EndColor, Gray, "special offer!", EndColor)
if cls != clsR {
t.Errorf("ColorLogS:\n Expect => %s\n Got => %s\n", clsR, cls)
}
// Success.
cls = ColorLogS("[SUCC] Success level test")
clsR = fmt.Sprintf(
"[\033[%dmSUCC%s] Success level test",
Green, EndColor)
if cls != clsR {
t.Errorf("ColorLogS:\n Expect => %s\n Got => %s\n", clsR, cls)
}
// Default.
cls = ColorLogS("[INFO] Default level test")
clsR = fmt.Sprintf(
"[INFO] Default level test")
if cls != clsR {
t.Errorf("ColorLogS:\n Expect => %s\n Got => %s\n", clsR, cls)
}
} else {
// Trace + path.
cls := ColorLogS("[TRAC] Trace level test with path( %s )", "/path/to/somethere")
clsR := fmt.Sprintf(
"[TRAC] Trace level test with path(%s)",
"/path/to/somethere")
if cls != clsR {
t.Errorf("ColorLogS:\n Expect => %s\n Got => %s\n", clsR, cls)
}
// Error + error.
cls = ColorLogS("[ERRO] Error level test with error[ %s ]", "test error")
clsR = fmt.Sprintf(
"[ERRO] Error level test with error[%s]",
"test error")
if cls != clsR {
t.Errorf("ColorLogS:\n Expect => %s\n Got => %s\n", clsR, cls)
}
// Warning + highlight.
cls = ColorLogS("[WARN] Warnning level test with highlight # %s #", "special offer!")
clsR = fmt.Sprintf(
"[WARN] Warnning level test with highlight %s",
"special offer!")
if cls != clsR {
t.Errorf("ColorLogS:\n Expect => %s\n Got => %s\n", clsR, cls)
}
// Success.
cls = ColorLogS("[SUCC] Success level test")
clsR = fmt.Sprintf(
"[SUCC] Success level test")
if cls != clsR {
t.Errorf("ColorLogS:\n Expect => %s\n Got => %s\n", clsR, cls)
}
// Default.
cls = ColorLogS("[INFO] Default level test")
clsR = fmt.Sprintf(
"[INFO] Default level test")
if cls != clsR {
t.Errorf("ColorLogS:\n Expect => %s\n Got => %s\n", clsR, cls)
}
}
}
func TestExecCmd(t *testing.T) {
stdout, stderr, err := ExecCmd("go", "help", "get")
if err != nil {
t.Errorf("ExecCmd:\n Expect => %v\n Got => %v\n", nil, err)
} else if len(stderr) != 0 {
t.Errorf("ExecCmd:\n Expect => %s\n Got => %s\n", "", stderr)
} else if !strings.HasPrefix(stdout, "usage: go get") {
t.Errorf("ExecCmd:\n Expect => %s\n Got => %s\n", "usage: go get", stdout)
}
}
func BenchmarkColorLogS(b *testing.B) {
log := fmt.Sprintf(
"[WARN] This is a tesing log that should be colored, path( %s ),"+
" highlight # %s #, error [ %s ].",
"path to somewhere", "highlighted content", "tesing error")
for i := 0; i < b.N; i++ {
ColorLogS(log)
}
}
func BenchmarkExecCmd(b *testing.B) {
for i := 0; i < b.N; i++ {
ExecCmd("go", "help", "get")
}
}

157
Godeps/_workspace/src/github.com/Unknwon/com/convert.go generated vendored Normal file
View File

@@ -0,0 +1,157 @@
// Copyright 2014 com authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package com
import (
"fmt"
"strconv"
)
// Convert string to specify type.
type StrTo string
func (f StrTo) Exist() bool {
return string(f) != string(0x1E)
}
func (f StrTo) Uint8() (uint8, error) {
v, err := strconv.ParseUint(f.String(), 10, 8)
return uint8(v), err
}
func (f StrTo) Int() (int, error) {
v, err := strconv.ParseInt(f.String(), 10, 32)
return int(v), err
}
func (f StrTo) Int64() (int64, error) {
v, err := strconv.ParseInt(f.String(), 10, 64)
return int64(v), err
}
func (f StrTo) MustUint8() uint8 {
v, _ := f.Uint8()
return v
}
func (f StrTo) MustInt() int {
v, _ := f.Int()
return v
}
func (f StrTo) MustInt64() int64 {
v, _ := f.Int64()
return v
}
func (f StrTo) String() string {
if f.Exist() {
return string(f)
}
return ""
}
// Convert any type to string.
func ToStr(value interface{}, args ...int) (s string) {
switch v := value.(type) {
case bool:
s = strconv.FormatBool(v)
case float32:
s = strconv.FormatFloat(float64(v), 'f', argInt(args).Get(0, -1), argInt(args).Get(1, 32))
case float64:
s = strconv.FormatFloat(v, 'f', argInt(args).Get(0, -1), argInt(args).Get(1, 64))
case int:
s = strconv.FormatInt(int64(v), argInt(args).Get(0, 10))
case int8:
s = strconv.FormatInt(int64(v), argInt(args).Get(0, 10))
case int16:
s = strconv.FormatInt(int64(v), argInt(args).Get(0, 10))
case int32:
s = strconv.FormatInt(int64(v), argInt(args).Get(0, 10))
case int64:
s = strconv.FormatInt(v, argInt(args).Get(0, 10))
case uint:
s = strconv.FormatUint(uint64(v), argInt(args).Get(0, 10))
case uint8:
s = strconv.FormatUint(uint64(v), argInt(args).Get(0, 10))
case uint16:
s = strconv.FormatUint(uint64(v), argInt(args).Get(0, 10))
case uint32:
s = strconv.FormatUint(uint64(v), argInt(args).Get(0, 10))
case uint64:
s = strconv.FormatUint(v, argInt(args).Get(0, 10))
case string:
s = v
case []byte:
s = string(v)
default:
s = fmt.Sprintf("%v", v)
}
return s
}
type argInt []int
func (a argInt) Get(i int, args ...int) (r int) {
if i >= 0 && i < len(a) {
r = a[i]
} else if len(args) > 0 {
r = args[0]
}
return
}
// HexStr2int converts hex format string to decimal number.
func HexStr2int(hexStr string) (int, error) {
num := 0
length := len(hexStr)
for i := 0; i < length; i++ {
char := hexStr[length-i-1]
factor := -1
switch {
case char >= '0' && char <= '9':
factor = int(char) - '0'
case char >= 'a' && char <= 'f':
factor = int(char) - 'a' + 10
default:
return -1, fmt.Errorf("invalid hex: %s", string(char))
}
num += factor * PowInt(16, i)
}
return num, nil
}
// Int2HexStr converts decimal number to hex format string.
func Int2HexStr(num int) (hex string) {
if num == 0 {
return "0"
}
for num > 0 {
r := num % 16
c := "?"
if r >= 0 && r <= 9 {
c = string(r + '0')
} else {
c = string(r + 'a' - 10)
}
hex = c + hex
num = num / 16
}
return hex
}

View File

@@ -0,0 +1,56 @@
// Copyright 2014 com authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package com
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestHexStr2int(t *testing.T) {
Convey("Convert hex format string to decimal", t, func() {
hexDecs := map[string]int{
"1": 1,
"002": 2,
"011": 17,
"0a1": 161,
"35e": 862,
}
for hex, dec := range hexDecs {
val, err := HexStr2int(hex)
So(err, ShouldBeNil)
So(val, ShouldEqual, dec)
}
})
}
func TestInt2HexStr(t *testing.T) {
Convey("Convert decimal to hex format string", t, func() {
decHexs := map[int]string{
1: "1",
2: "2",
17: "11",
161: "a1",
862: "35e",
}
for dec, hex := range decHexs {
val := Int2HexStr(dec)
So(val, ShouldEqual, hex)
}
})
}

173
Godeps/_workspace/src/github.com/Unknwon/com/dir.go generated vendored Normal file
View File

@@ -0,0 +1,173 @@
// Copyright 2013 com authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package com
import (
"errors"
"fmt"
"os"
"path"
"strings"
)
// IsDir returns true if given path is a directory,
// or returns false when it's a file or does not exist.
func IsDir(dir string) bool {
f, e := os.Stat(dir)
if e != nil {
return false
}
return f.IsDir()
}
func statDir(dirPath, recPath string, includeDir, isDirOnly bool) ([]string, error) {
dir, err := os.Open(dirPath)
if err != nil {
return nil, err
}
defer dir.Close()
fis, err := dir.Readdir(0)
if err != nil {
return nil, err
}
statList := make([]string, 0)
for _, fi := range fis {
if strings.Contains(fi.Name(), ".DS_Store") {
continue
}
relPath := path.Join(recPath, fi.Name())
curPath := path.Join(dirPath, fi.Name())
if fi.IsDir() {
if includeDir {
statList = append(statList, relPath+"/")
}
s, err := statDir(curPath, relPath, includeDir, isDirOnly)
if err != nil {
return nil, err
}
statList = append(statList, s...)
} else if !isDirOnly {
statList = append(statList, relPath)
}
}
return statList, nil
}
// StatDir gathers information of given directory by depth-first.
// It returns slice of file list and includes subdirectories if enabled;
// it returns error and nil slice when error occurs in underlying functions,
// or given path is not a directory or does not exist.
//
// Slice does not include given path itself.
// If subdirectories is enabled, they will have suffix '/'.
func StatDir(rootPath string, includeDir ...bool) ([]string, error) {
if !IsDir(rootPath) {
return nil, errors.New("not a directory or does not exist: " + rootPath)
}
isIncludeDir := false
if len(includeDir) >= 1 {
isIncludeDir = includeDir[0]
}
return statDir(rootPath, "", isIncludeDir, false)
}
// GetAllSubDirs returns all subdirectories of given root path.
// Slice does not include given path itself.
func GetAllSubDirs(rootPath string) ([]string, error) {
if !IsDir(rootPath) {
return nil, errors.New("not a directory or does not exist: " + rootPath)
}
return statDir(rootPath, "", true, true)
}
// GetFileListBySuffix returns an ordered list of file paths.
// It recognize if given path is a file, and don't do recursive find.
func GetFileListBySuffix(dirPath, suffix string) ([]string, error) {
if !IsExist(dirPath) {
return nil, fmt.Errorf("given path does not exist: %s", dirPath)
} else if IsFile(dirPath) {
return []string{dirPath}, nil
}
// Given path is a directory.
dir, err := os.Open(dirPath)
if err != nil {
return nil, err
}
fis, err := dir.Readdir(0)
if err != nil {
return nil, err
}
files := make([]string, 0, len(fis))
for _, fi := range fis {
if strings.HasSuffix(fi.Name(), suffix) {
files = append(files, path.Join(dirPath, fi.Name()))
}
}
return files, nil
}
// CopyDir copy files recursively from source to target directory.
//
// The filter accepts a function that process the path info.
// and should return true for need to filter.
//
// It returns error when error occurs in underlying functions.
func CopyDir(srcPath, destPath string, filters ...func(filePath string) bool) error {
// Check if target directory exists.
if IsExist(destPath) {
return errors.New("file or directory alreay exists: " + destPath)
}
err := os.MkdirAll(destPath, os.ModePerm)
if err != nil {
return err
}
// Gather directory info.
infos, err := StatDir(srcPath, true)
if err != nil {
return err
}
var filter func(filePath string) bool
if len(filters) > 0 {
filter = filters[0]
}
for _, info := range infos {
if filter != nil && filter(info) {
continue
}
curPath := path.Join(destPath, info)
if strings.HasSuffix(info, "/") {
err = os.MkdirAll(curPath, os.ModePerm)
} else {
err = Copy(path.Join(srcPath, info), curPath)
}
if err != nil {
return err
}
}
return nil
}

View File

@@ -0,0 +1,58 @@
// Copyright 2013 com authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package com
import (
"os"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestIsDir(t *testing.T) {
Convey("Check if given path is a directory", t, func() {
Convey("Pass a file name", func() {
So(IsDir("file.go"), ShouldEqual, false)
})
Convey("Pass a directory name", func() {
So(IsDir("testdata"), ShouldEqual, true)
})
Convey("Pass a invalid path", func() {
So(IsDir("foo"), ShouldEqual, false)
})
})
}
func TestCopyDir(t *testing.T) {
Convey("Items of two slices should be same", t, func() {
s1, err := StatDir("testdata", true)
So(err, ShouldEqual, nil)
err = CopyDir("testdata", "testdata2")
So(err, ShouldEqual, nil)
s2, err := StatDir("testdata2", true)
os.RemoveAll("testdata2")
So(err, ShouldEqual, nil)
So(CompareSliceStr(s1, s2), ShouldEqual, true)
})
}
func BenchmarkIsDir(b *testing.B) {
for i := 0; i < b.N; i++ {
IsDir("file.go")
}
}

View File

@@ -0,0 +1,299 @@
// Copyright 2013 com authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package com_test
import (
"fmt"
"io/ioutil"
"net/http"
"github.com/Unknwon/com"
)
// ------------------------------
// cmd.go
// ------------------------------
func ExampleColorLogS() {
coloredLog := com.ColorLogS(fmt.Sprintf(
"[WARN] This is a tesing log that should be colored, path( %s ),"+
" highlight # %s #, error [ %s ].",
"path to somewhere", "highlighted content", "tesing error"))
fmt.Println(coloredLog)
}
func ExampleColorLog() {
com.ColorLog(fmt.Sprintf(
"[WARN] This is a tesing log that should be colored, path( %s ),"+
" highlight # %s #, error [ %s ].",
"path to somewhere", "highlighted content", "tesing error"))
}
func ExampleExecCmd() {
stdout, stderr, err := com.ExecCmd("go", "help", "get")
fmt.Println(stdout, stderr, err)
}
// ------------- END ------------
// ------------------------------
// html.go
// ------------------------------
func ExampleHtml2JS() {
htm := "<div id=\"button\" class=\"btn\">Click me</div>\n\r"
js := string(com.Html2JS([]byte(htm)))
fmt.Println(js)
// Output: <div id=\"button\" class=\"btn\">Click me</div>\n
}
// ------------- END ------------
// ------------------------------
// path.go
// ------------------------------
func ExampleGetGOPATHs() {
gps := com.GetGOPATHs()
fmt.Println(gps)
}
func ExampleGetSrcPath() {
srcPath, err := com.GetSrcPath("github.com/Unknwon/com")
if err != nil {
fmt.Println(err)
return
}
fmt.Println(srcPath)
}
func ExampleHomeDir() {
hd, err := com.HomeDir()
fmt.Println(hd, err)
}
// ------------- END ------------
// ------------------------------
// file.go
// ------------------------------
func ExampleIsFile() {
if com.IsFile("file.go") {
fmt.Println("file.go exists")
return
}
fmt.Println("file.go is not a file or does not exist")
}
func ExampleIsExist() {
if com.IsExist("file.go") {
fmt.Println("file.go exists")
return
}
fmt.Println("file.go does not exist")
}
// ------------- END ------------
// ------------------------------
// dir.go
// ------------------------------
func ExampleIsDir() {
if com.IsDir("files") {
fmt.Println("directory 'files' exists")
return
}
fmt.Println("'files' is not a directory or does not exist")
}
// ------------- END ------------
// ------------------------------
// string.go
// ------------------------------
func ExampleIsLetter() {
fmt.Println(com.IsLetter('1'))
fmt.Println(com.IsLetter('['))
fmt.Println(com.IsLetter('a'))
fmt.Println(com.IsLetter('Z'))
// Output:
// false
// false
// true
// true
}
func ExampleExpand() {
match := map[string]string{
"domain": "gowalker.org",
"subdomain": "github.com",
}
s := "http://{domain}/{subdomain}/{0}/{1}"
fmt.Println(com.Expand(s, match, "Unknwon", "gowalker"))
// Output: http://gowalker.org/github.com/Unknwon/gowalker
}
// ------------- END ------------
// ------------------------------
// http.go
// ------------------------------
func ExampleHttpGet() ([]byte, error) {
rc, err := com.HttpGet(&http.Client{}, "http://gowalker.org", nil)
if err != nil {
return nil, err
}
p, err := ioutil.ReadAll(rc)
rc.Close()
return p, err
}
func ExampleHttpGetBytes() ([]byte, error) {
p, err := com.HttpGetBytes(&http.Client{}, "http://gowalker.org", nil)
return p, err
}
func ExampleHttpGetJSON() interface{} {
j := com.HttpGetJSON(&http.Client{}, "http://gowalker.org", nil)
return j
}
type rawFile struct {
name string
rawURL string
data []byte
}
func (rf *rawFile) Name() string {
return rf.name
}
func (rf *rawFile) RawUrl() string {
return rf.rawURL
}
func (rf *rawFile) Data() []byte {
return rf.data
}
func (rf *rawFile) SetData(p []byte) {
rf.data = p
}
func ExampleFetchFiles() {
// Code that should be outside of your function body.
// type rawFile struct {
// name string
// rawURL string
// data []byte
// }
// func (rf *rawFile) Name() string {
// return rf.name
// }
// func (rf *rawFile) RawUrl() string {
// return rf.rawURL
// }
// func (rf *rawFile) Data() []byte {
// return rf.data
// }
// func (rf *rawFile) SetData(p []byte) {
// rf.data = p
// }
files := []com.RawFile{
&rawFile{rawURL: "http://example.com"},
&rawFile{rawURL: "http://example.com/foo"},
}
err := com.FetchFiles(&http.Client{}, files, nil)
fmt.Println(err, len(files[0].Data()), len(files[1].Data()))
}
func ExampleFetchFilesCurl() {
// Code that should be outside of your function body.
// type rawFile struct {
// name string
// rawURL string
// data []byte
// }
// func (rf *rawFile) Name() string {
// return rf.name
// }
// func (rf *rawFile) RawUrl() string {
// return rf.rawURL
// }
// func (rf *rawFile) Data() []byte {
// return rf.data
// }
// func (rf *rawFile) SetData(p []byte) {
// rf.data = p
// }
files := []com.RawFile{
&rawFile{rawURL: "http://example.com"},
&rawFile{rawURL: "http://example.com/foo"},
}
err := com.FetchFilesCurl(files)
fmt.Println(err, len(files[0].Data()), len(files[1].Data()))
}
// ------------- END ------------
// ------------------------------
// regex.go
// ------------------------------
func ExampleIsEmail() {
fmt.Println(com.IsEmail("test@example.com"))
fmt.Println(com.IsEmail("@example.com"))
// Output:
// true
// false
}
func ExampleIsUrl() {
fmt.Println(com.IsUrl("http://example.com"))
fmt.Println(com.IsUrl("http//example.com"))
// Output:
// true
// false
}
// ------------- END ------------
// ------------------------------
// slice.go
// ------------------------------
func ExampleAppendStr() {
s := []string{"a"}
s = com.AppendStr(s, "a")
s = com.AppendStr(s, "b")
fmt.Println(s)
// Output: [a b]
}
// ------------- END ------------

145
Godeps/_workspace/src/github.com/Unknwon/com/file.go generated vendored Normal file
View File

@@ -0,0 +1,145 @@
// Copyright 2013 com authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package com
import (
"fmt"
"io"
"io/ioutil"
"math"
"os"
"path"
)
// Storage unit constants.
const (
Byte = 1
KByte = Byte * 1024
MByte = KByte * 1024
GByte = MByte * 1024
TByte = GByte * 1024
PByte = TByte * 1024
EByte = PByte * 1024
)
func logn(n, b float64) float64 {
return math.Log(n) / math.Log(b)
}
func humanateBytes(s uint64, base float64, sizes []string) string {
if s < 10 {
return fmt.Sprintf("%dB", s)
}
e := math.Floor(logn(float64(s), base))
suffix := sizes[int(e)]
val := float64(s) / math.Pow(base, math.Floor(e))
f := "%.0f"
if val < 10 {
f = "%.1f"
}
return fmt.Sprintf(f+"%s", val, suffix)
}
// HumaneFileSize calculates the file size and generate user-friendly string.
func HumaneFileSize(s uint64) string {
sizes := []string{"B", "KB", "MB", "GB", "TB", "PB", "EB"}
return humanateBytes(s, 1024, sizes)
}
// FileMTime returns file modified time and possible error.
func FileMTime(file string) (int64, error) {
f, err := os.Stat(file)
if err != nil {
return 0, err
}
return f.ModTime().Unix(), nil
}
// FileSize returns file size in bytes and possible error.
func FileSize(file string) (int64, error) {
f, err := os.Stat(file)
if err != nil {
return 0, err
}
return f.Size(), nil
}
// Copy copies file from source to target path.
func Copy(src, dest string) error {
// Gather file information to set back later.
si, err := os.Lstat(src)
if err != nil {
return err
}
// Handle symbolic link.
if si.Mode()&os.ModeSymlink != 0 {
target, err := os.Readlink(src)
if err != nil {
return err
}
// NOTE: os.Chmod and os.Chtimes don't recoganize symbolic link,
// which will lead "no such file or directory" error.
return os.Symlink(target, dest)
}
sr, err := os.Open(src)
if err != nil {
return err
}
defer sr.Close()
dw, err := os.Create(dest)
if err != nil {
return err
}
defer dw.Close()
if _, err = io.Copy(dw, sr); err != nil {
return err
}
// Set back file information.
if err = os.Chtimes(dest, si.ModTime(), si.ModTime()); err != nil {
return err
}
return os.Chmod(dest, si.Mode())
}
// WriteFile writes data to a file named by filename.
// If the file does not exist, WriteFile creates it
// and its upper level paths.
func WriteFile(filename string, data []byte) error {
os.MkdirAll(path.Dir(filename), os.ModePerm)
return ioutil.WriteFile(filename, data, 0655)
}
// IsFile returns true if given path is a file,
// or returns false when it's a directory or does not exist.
func IsFile(filePath string) bool {
f, e := os.Stat(filePath)
if e != nil {
return false
}
return !f.IsDir()
}
// IsExist checks whether a file or directory exists.
// It returns false when the file or directory does not exist.
func IsExist(path string) bool {
_, err := os.Stat(path)
return err == nil || os.IsExist(err)
}

View File

@@ -0,0 +1,61 @@
// Copyright 2013 com authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package com
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestIsFile(t *testing.T) {
if !IsFile("file.go") {
t.Errorf("IsExist:\n Expect => %v\n Got => %v\n", true, false)
}
if IsFile("testdata") {
t.Errorf("IsExist:\n Expect => %v\n Got => %v\n", false, true)
}
if IsFile("files.go") {
t.Errorf("IsExist:\n Expect => %v\n Got => %v\n", false, true)
}
}
func TestIsExist(t *testing.T) {
Convey("Check if file or directory exists", t, func() {
Convey("Pass a file name that exists", func() {
So(IsExist("file.go"), ShouldEqual, true)
})
Convey("Pass a directory name that exists", func() {
So(IsExist("testdata"), ShouldEqual, true)
})
Convey("Pass a directory name that does not exist", func() {
So(IsExist(".hg"), ShouldEqual, false)
})
})
}
func BenchmarkIsFile(b *testing.B) {
for i := 0; i < b.N; i++ {
IsFile("file.go")
}
}
func BenchmarkIsExist(b *testing.B) {
for i := 0; i < b.N; i++ {
IsExist("file.go")
}
}

60
Godeps/_workspace/src/github.com/Unknwon/com/html.go generated vendored Normal file
View File

@@ -0,0 +1,60 @@
// Copyright 2013 com authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package com
import (
"html"
"regexp"
"strings"
)
// Html2JS converts []byte type of HTML content into JS format.
func Html2JS(data []byte) []byte {
s := string(data)
s = strings.Replace(s, `\`, `\\`, -1)
s = strings.Replace(s, "\n", `\n`, -1)
s = strings.Replace(s, "\r", "", -1)
s = strings.Replace(s, "\"", `\"`, -1)
s = strings.Replace(s, "<table>", "&lt;table>", -1)
return []byte(s)
}
// encode html chars to string
func HtmlEncode(str string) string {
return html.EscapeString(str)
}
// decode string to html chars
func HtmlDecode(str string) string {
return html.UnescapeString(str)
}
// strip tags in html string
func StripTags(src string) string {
//去除style,script,html tag
re := regexp.MustCompile(`(?s)<(?:style|script)[^<>]*>.*?</(?:style|script)>|</?[a-z][a-z0-9]*[^<>]*>|<!--.*?-->`)
src = re.ReplaceAllString(src, "")
//trim all spaces(2+) into \n
re = regexp.MustCompile(`\s{2,}`)
src = re.ReplaceAllString(src, "\n")
return strings.TrimSpace(src)
}
// change \n to <br/>
func Nl2br(str string) string {
return strings.Replace(str, "\n", "<br/>", -1)
}

View File

@@ -0,0 +1,35 @@
// Copyright 2013 com authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package com
import (
"testing"
)
func TestHtml2JS(t *testing.T) {
htm := "<div id=\"button\" class=\"btn\">Click me</div>\n\r"
js := string(Html2JS([]byte(htm)))
jsR := `<div id=\"button\" class=\"btn\">Click me</div>\n`
if js != jsR {
t.Errorf("Html2JS:\n Expect => %s\n Got => %s\n", jsR, js)
}
}
func BenchmarkHtml2JS(b *testing.B) {
htm := "<div id=\"button\" class=\"btn\">Click me</div>\n\r"
for i := 0; i < b.N; i++ {
Html2JS([]byte(htm))
}
}

201
Godeps/_workspace/src/github.com/Unknwon/com/http.go generated vendored Normal file
View File

@@ -0,0 +1,201 @@
// Copyright 2013 com authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package com
import (
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"path"
)
type NotFoundError struct {
Message string
}
func (e NotFoundError) Error() string {
return e.Message
}
type RemoteError struct {
Host string
Err error
}
func (e *RemoteError) Error() string {
return e.Err.Error()
}
var UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1541.0 Safari/537.36"
// HttpCall makes HTTP method call.
func HttpCall(client *http.Client, method, url string, header http.Header, body io.Reader) (io.ReadCloser, error) {
req, err := http.NewRequest(method, url, body)
if err != nil {
return nil, err
}
req.Header.Set("User-Agent", UserAgent)
for k, vs := range header {
req.Header[k] = vs
}
resp, err := client.Do(req)
if err != nil {
return nil, err
}
if resp.StatusCode == 200 {
return resp.Body, nil
}
resp.Body.Close()
if resp.StatusCode == 404 { // 403 can be rate limit error. || resp.StatusCode == 403 {
err = fmt.Errorf("resource not found: %s", url)
} else {
err = fmt.Errorf("%s %s -> %d", method, url, resp.StatusCode)
}
return nil, err
}
// HttpGet gets the specified resource.
// ErrNotFound is returned if the server responds with status 404.
func HttpGet(client *http.Client, url string, header http.Header) (io.ReadCloser, error) {
return HttpCall(client, "GET", url, header, nil)
}
// HttpPost posts the specified resource.
// ErrNotFound is returned if the server responds with status 404.
func HttpPost(client *http.Client, url string, header http.Header, body []byte) (io.ReadCloser, error) {
return HttpCall(client, "POST", url, header, bytes.NewBuffer(body))
}
// HttpGetToFile gets the specified resource and writes to file.
// ErrNotFound is returned if the server responds with status 404.
func HttpGetToFile(client *http.Client, url string, header http.Header, fileName string) error {
rc, err := HttpGet(client, url, header)
if err != nil {
return err
}
defer rc.Close()
os.MkdirAll(path.Dir(fileName), os.ModePerm)
f, err := os.Create(fileName)
if err != nil {
return err
}
defer f.Close()
_, err = io.Copy(f, rc)
return err
}
// HttpGetBytes gets the specified resource. ErrNotFound is returned if the server
// responds with status 404.
func HttpGetBytes(client *http.Client, url string, header http.Header) ([]byte, error) {
rc, err := HttpGet(client, url, header)
if err != nil {
return nil, err
}
defer rc.Close()
return ioutil.ReadAll(rc)
}
// HttpGetJSON gets the specified resource and mapping to struct.
// ErrNotFound is returned if the server responds with status 404.
func HttpGetJSON(client *http.Client, url string, v interface{}) error {
rc, err := HttpGet(client, url, nil)
if err != nil {
return err
}
defer rc.Close()
err = json.NewDecoder(rc).Decode(v)
if _, ok := err.(*json.SyntaxError); ok {
return fmt.Errorf("JSON syntax error at %s", url)
}
return nil
}
// HttpPostJSON posts the specified resource with struct values,
// and maps results to struct.
// ErrNotFound is returned if the server responds with status 404.
func HttpPostJSON(client *http.Client, url string, body, v interface{}) error {
data, err := json.Marshal(body)
if err != nil {
return err
}
rc, err := HttpPost(client, url, http.Header{"content-type": []string{"application/json"}}, data)
if err != nil {
return err
}
defer rc.Close()
err = json.NewDecoder(rc).Decode(v)
if _, ok := err.(*json.SyntaxError); ok {
return fmt.Errorf("JSON syntax error at %s", url)
}
return nil
}
// A RawFile describes a file that can be downloaded.
type RawFile interface {
Name() string
RawUrl() string
Data() []byte
SetData([]byte)
}
// FetchFiles fetches files specified by the rawURL field in parallel.
func FetchFiles(client *http.Client, files []RawFile, header http.Header) error {
ch := make(chan error, len(files))
for i := range files {
go func(i int) {
p, err := HttpGetBytes(client, files[i].RawUrl(), nil)
if err != nil {
ch <- err
return
}
files[i].SetData(p)
ch <- nil
}(i)
}
for _ = range files {
if err := <-ch; err != nil {
return err
}
}
return nil
}
// FetchFiles uses command `curl` to fetch files specified by the rawURL field in parallel.
func FetchFilesCurl(files []RawFile, curlOptions ...string) error {
ch := make(chan error, len(files))
for i := range files {
go func(i int) {
stdout, _, err := ExecCmd("curl", append(curlOptions, files[i].RawUrl())...)
if err != nil {
ch <- err
return
}
files[i].SetData([]byte(stdout))
ch <- nil
}(i)
}
for _ = range files {
if err := <-ch; err != nil {
return err
}
}
return nil
}

View File

@@ -0,0 +1,111 @@
// Copyright 2013 com authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package com
import (
"io/ioutil"
"net/http"
"strings"
"testing"
)
var examplePrefix = `<!doctype html>
<html>
<head>
<title>Example Domain</title>
`
func TestHttpGet(t *testing.T) {
// 200.
rc, err := HttpGet(&http.Client{}, "http://example.com", nil)
if err != nil {
t.Fatalf("HttpGet:\n Expect => %v\n Got => %s\n", nil, err)
}
p, err := ioutil.ReadAll(rc)
if err != nil {
t.Errorf("HttpGet:\n Expect => %v\n Got => %s\n", nil, err)
}
s := string(p)
if !strings.HasPrefix(s, examplePrefix) {
t.Errorf("HttpGet:\n Expect => %s\n Got => %s\n", examplePrefix, s)
}
}
func TestHttpGetBytes(t *testing.T) {
p, err := HttpGetBytes(&http.Client{}, "http://example.com", nil)
if err != nil {
t.Errorf("HttpGetBytes:\n Expect => %v\n Got => %s\n", nil, err)
}
s := string(p)
if !strings.HasPrefix(s, examplePrefix) {
t.Errorf("HttpGet:\n Expect => %s\n Got => %s\n", examplePrefix, s)
}
}
func TestHttpGetJSON(t *testing.T) {
}
type rawFile struct {
name string
rawURL string
data []byte
}
func (rf *rawFile) Name() string {
return rf.name
}
func (rf *rawFile) RawUrl() string {
return rf.rawURL
}
func (rf *rawFile) Data() []byte {
return rf.data
}
func (rf *rawFile) SetData(p []byte) {
rf.data = p
}
func TestFetchFiles(t *testing.T) {
files := []RawFile{
&rawFile{rawURL: "http://example.com"},
&rawFile{rawURL: "http://example.com"},
}
err := FetchFiles(&http.Client{}, files, nil)
if err != nil {
t.Errorf("FetchFiles:\n Expect => %v\n Got => %s\n", nil, err)
} else if len(files[0].Data()) != 1270 {
t.Errorf("FetchFiles:\n Expect => %d\n Got => %d\n", 1270, len(files[0].Data()))
} else if len(files[1].Data()) != 1270 {
t.Errorf("FetchFiles:\n Expect => %d\n Got => %d\n", 1270, len(files[1].Data()))
}
}
func TestFetchFilesCurl(t *testing.T) {
files := []RawFile{
&rawFile{rawURL: "http://example.com"},
&rawFile{rawURL: "http://example.com"},
}
err := FetchFilesCurl(files)
if err != nil {
t.Errorf("FetchFilesCurl:\n Expect => %v\n Got => %s\n", nil, err)
} else if len(files[0].Data()) != 1270 {
t.Errorf("FetchFilesCurl:\n Expect => %d\n Got => %d\n", 1270, len(files[0].Data()))
} else if len(files[1].Data()) != 1270 {
t.Errorf("FetchFilesCurl:\n Expect => %d\n Got => %d\n", 1270, len(files[1].Data()))
}
}

24
Godeps/_workspace/src/github.com/Unknwon/com/math.go generated vendored Normal file
View File

@@ -0,0 +1,24 @@
// Copyright 2014 com authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package com
// PowInt is int type of math.Pow function.
func PowInt(x int, y int) int {
num := 1
for i := 0; i < y; i++ {
num *= x
}
return num
}

80
Godeps/_workspace/src/github.com/Unknwon/com/path.go generated vendored Normal file
View File

@@ -0,0 +1,80 @@
// Copyright 2013 com authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package com
import (
"errors"
"os"
"path/filepath"
"runtime"
"strings"
)
// GetGOPATHs returns all paths in GOPATH variable.
func GetGOPATHs() []string {
gopath := os.Getenv("GOPATH")
var paths []string
if runtime.GOOS == "windows" {
gopath = strings.Replace(gopath, "\\", "/", -1)
paths = strings.Split(gopath, ";")
} else {
paths = strings.Split(gopath, ":")
}
return paths
}
// GetSrcPath returns app. source code path.
// It only works when you have src. folder in GOPATH,
// it returns error not able to locate source folder path.
func GetSrcPath(importPath string) (appPath string, err error) {
paths := GetGOPATHs()
for _, p := range paths {
if IsExist(p + "/src/" + importPath + "/") {
appPath = p + "/src/" + importPath + "/"
break
}
}
if len(appPath) == 0 {
return "", errors.New("Unable to locate source folder path")
}
appPath = filepath.Dir(appPath) + "/"
if runtime.GOOS == "windows" {
// Replace all '\' to '/'.
appPath = strings.Replace(appPath, "\\", "/", -1)
}
return appPath, nil
}
// HomeDir returns path of '~'(in Linux) on Windows,
// it returns error when the variable does not exist.
func HomeDir() (home string, err error) {
if runtime.GOOS == "windows" {
home = os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH")
if home == "" {
home = os.Getenv("USERPROFILE")
}
} else {
home = os.Getenv("HOME")
}
if len(home) == 0 {
return "", errors.New("Cannot specify home directory because it's empty")
}
return home, nil
}

View File

@@ -0,0 +1,67 @@
// Copyright 2013 com authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package com
import (
"os"
"runtime"
"testing"
)
func TestGetGOPATHs(t *testing.T) {
var gpsR []string
if runtime.GOOS != "windows" {
gpsR = []string{"path/to/gopath1", "path/to/gopath2", "path/to/gopath3"}
os.Setenv("GOPATH", "path/to/gopath1:path/to/gopath2:path/to/gopath3")
} else {
gpsR = []string{"path/to/gopath1", "path/to/gopath2", "path/to/gopath3"}
os.Setenv("GOPATH", "path\\to\\gopath1;path\\to\\gopath2;path\\to\\gopath3")
}
gps := GetGOPATHs()
if !CompareSliceStr(gps, gpsR) {
t.Errorf("GetGOPATHs:\n Expect => %s\n Got => %s\n", gpsR, gps)
}
}
func TestGetSrcPath(t *testing.T) {
}
func TestHomeDir(t *testing.T) {
_, err := HomeDir()
if err != nil {
t.Errorf("HomeDir:\n Expect => %v\n Got => %s\n", nil, err)
}
}
func BenchmarkGetGOPATHs(b *testing.B) {
for i := 0; i < b.N; i++ {
GetGOPATHs()
}
}
func BenchmarkGetSrcPath(b *testing.B) {
for i := 0; i < b.N; i++ {
GetSrcPath("github.com/Unknwon/com")
}
}
func BenchmarkHomeDir(b *testing.B) {
for i := 0; i < b.N; i++ {
HomeDir()
}
}

56
Godeps/_workspace/src/github.com/Unknwon/com/regex.go generated vendored Normal file
View File

@@ -0,0 +1,56 @@
// Copyright 2013 com authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package com
import "regexp"
const (
regex_email_pattern = `(?i)[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,6}`
regex_strict_email_pattern = `(?i)[A-Z0-9!#$%&'*+/=?^_{|}~-]+` +
`(?:\.[A-Z0-9!#$%&'*+/=?^_{|}~-]+)*` +
`@(?:[A-Z0-9](?:[A-Z0-9-]*[A-Z0-9])?\.)+` +
`[A-Z0-9](?:[A-Z0-9-]*[A-Z0-9])?`
regex_url_pattern = `(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?`
)
var (
regex_email *regexp.Regexp
regex_strict_email *regexp.Regexp
regex_url *regexp.Regexp
)
func init() {
regex_email = regexp.MustCompile(regex_email_pattern)
regex_strict_email = regexp.MustCompile(regex_strict_email_pattern)
regex_url = regexp.MustCompile(regex_url_pattern)
}
// validate string is an email address, if not return false
// basically validation can match 99% cases
func IsEmail(email string) bool {
return regex_email.MatchString(email)
}
// validate string is an email address, if not return false
// this validation omits RFC 2822
func IsEmailRFC(email string) bool {
return regex_strict_email.MatchString(email)
}
// validate string is a url link, if not return false
// simple validation can match 99% cases
func IsUrl(url string) bool {
return regex_url.MatchString(url)
}

View File

@@ -0,0 +1,70 @@
// Copyright 2013 com authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package com
import (
"testing"
)
func TestIsEmail(t *testing.T) {
emails := map[string]bool{
`test@example.com`: true,
`single-character@b.org`: true,
`uncommon_address@test.museum`: true,
`local@sld.UPPER`: true,
`@missing.org`: false,
`missing@.com`: false,
`missing@qq.`: false,
`wrong-ip@127.1.1.1.26`: false,
}
for e, r := range emails {
b := IsEmail(e)
if b != r {
t.Errorf("IsEmail:\n Expect => %v\n Got => %v\n", r, b)
}
}
}
func TestIsUrl(t *testing.T) {
urls := map[string]bool{
"http://www.example.com": true,
"http://example.com": true,
"http://example.com?user=test&password=test": true,
"http://example.com?user=test#login": true,
"ftp://example.com": true,
"https://example.com": true,
"htp://example.com": false,
"http//example.com": false,
"http://example": true,
}
for u, r := range urls {
b := IsUrl(u)
if b != r {
t.Errorf("IsUrl:\n Expect => %v\n Got => %v\n", r, b)
}
}
}
func BenchmarkIsEmail(b *testing.B) {
for i := 0; i < b.N; i++ {
IsEmail("test@example.com")
}
}
func BenchmarkIsUrl(b *testing.B) {
for i := 0; i < b.N; i++ {
IsEmail("http://example.com")
}
}

87
Godeps/_workspace/src/github.com/Unknwon/com/slice.go generated vendored Normal file
View File

@@ -0,0 +1,87 @@
// Copyright 2013 com authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package com
import (
"strings"
)
// AppendStr appends string to slice with no duplicates.
func AppendStr(strs []string, str string) []string {
for _, s := range strs {
if s == str {
return strs
}
}
return append(strs, str)
}
// CompareSliceStr compares two 'string' type slices.
// It returns true if elements and order are both the same.
func CompareSliceStr(s1, s2 []string) bool {
if len(s1) != len(s2) {
return false
}
for i := range s1 {
if s1[i] != s2[i] {
return false
}
}
return true
}
// CompareSliceStr compares two 'string' type slices.
// It returns true if elements are the same, and ignores the order.
func CompareSliceStrU(s1, s2 []string) bool {
if len(s1) != len(s2) {
return false
}
for i := range s1 {
for j := len(s2) - 1; j >= 0; j-- {
if s1[i] == s2[j] {
s2 = append(s2[:j], s2[j+1:]...)
break
}
}
}
if len(s2) > 0 {
return false
}
return true
}
// IsSliceContainsStr returns true if the string exists in given slice, ignore case.
func IsSliceContainsStr(sl []string, str string) bool {
str = strings.ToLower(str)
for _, s := range sl {
if strings.ToLower(s) == str {
return true
}
}
return false
}
// IsSliceContainsInt64 returns true if the int64 exists in given slice.
func IsSliceContainsInt64(sl []int64, i int64) bool {
for _, s := range sl {
if s == i {
return true
}
}
return false
}

View File

@@ -0,0 +1,99 @@
// Copyright 2013 com authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package com
import (
"fmt"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestAppendStr(t *testing.T) {
Convey("Append a string to a slice with no duplicates", t, func() {
s := []string{"a"}
Convey("Append a string that does not exist in slice", func() {
s = AppendStr(s, "b")
So(len(s), ShouldEqual, 2)
})
Convey("Append a string that does exist in slice", func() {
s = AppendStr(s, "b")
So(len(s), ShouldEqual, 2)
})
})
}
func TestCompareSliceStr(t *testing.T) {
Convey("Compares two 'string' type slices with elements and order", t, func() {
Convey("Compare two slices that do have same elements and order", func() {
So(CompareSliceStr(
[]string{"1", "2", "3"}, []string{"1", "2", "3"}), ShouldBeTrue)
})
Convey("Compare two slices that do have same elements but does not have same order", func() {
So(!CompareSliceStr(
[]string{"2", "1", "3"}, []string{"1", "2", "3"}), ShouldBeTrue)
})
Convey("Compare two slices that have different number of elements", func() {
So(!CompareSliceStr(
[]string{"2", "1"}, []string{"1", "2", "3"}), ShouldBeTrue)
})
})
}
func TestCompareSliceStrU(t *testing.T) {
Convey("Compare two 'string' type slices with elements and ignore the order", t, func() {
Convey("Compare two slices that do have same elements and order", func() {
So(CompareSliceStrU(
[]string{"1", "2", "3"}, []string{"1", "2", "3"}), ShouldBeTrue)
})
Convey("Compare two slices that do have same elements but does not have same order", func() {
So(CompareSliceStrU(
[]string{"2", "1", "3"}, []string{"1", "2", "3"}), ShouldBeTrue)
})
Convey("Compare two slices that have different number of elements", func() {
So(!CompareSliceStrU(
[]string{"2", "1"}, []string{"1", "2", "3"}), ShouldBeTrue)
})
})
}
func BenchmarkAppendStr(b *testing.B) {
s := []string{"a"}
for i := 0; i < b.N; i++ {
s = AppendStr(s, fmt.Sprint(b.N%3))
}
}
func BenchmarkCompareSliceStr(b *testing.B) {
s1 := []string{"1", "2", "3"}
s2 := []string{"1", "2", "3"}
for i := 0; i < b.N; i++ {
CompareSliceStr(s1, s2)
}
}
func BenchmarkCompareSliceStrU(b *testing.B) {
s1 := []string{"1", "4", "2", "3"}
s2 := []string{"1", "2", "3", "4"}
for i := 0; i < b.N; i++ {
CompareSliceStrU(s1, s2)
}
}

140
Godeps/_workspace/src/github.com/Unknwon/com/string.go generated vendored Normal file
View File

@@ -0,0 +1,140 @@
// Copyright 2013 com authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package com
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/base64"
"errors"
"io"
r "math/rand"
"strconv"
"strings"
"time"
)
// AESEncrypt encrypts text and given key with AES.
func AESEncrypt(key, text []byte) ([]byte, error) {
block, err := aes.NewCipher(key)
if err != nil {
return nil, err
}
b := base64.StdEncoding.EncodeToString(text)
ciphertext := make([]byte, aes.BlockSize+len(b))
iv := ciphertext[:aes.BlockSize]
if _, err := io.ReadFull(rand.Reader, iv); err != nil {
return nil, err
}
cfb := cipher.NewCFBEncrypter(block, iv)
cfb.XORKeyStream(ciphertext[aes.BlockSize:], []byte(b))
return ciphertext, nil
}
// AESDecrypt decrypts text and given key with AES.
func AESDecrypt(key, text []byte) ([]byte, error) {
block, err := aes.NewCipher(key)
if err != nil {
return nil, err
}
if len(text) < aes.BlockSize {
return nil, errors.New("ciphertext too short")
}
iv := text[:aes.BlockSize]
text = text[aes.BlockSize:]
cfb := cipher.NewCFBDecrypter(block, iv)
cfb.XORKeyStream(text, text)
data, err := base64.StdEncoding.DecodeString(string(text))
if err != nil {
return nil, err
}
return data, nil
}
// IsLetter returns true if the 'l' is an English letter.
func IsLetter(l uint8) bool {
n := (l | 0x20) - 'a'
if n >= 0 && n < 26 {
return true
}
return false
}
// Expand replaces {k} in template with match[k] or subs[atoi(k)] if k is not in match.
func Expand(template string, match map[string]string, subs ...string) string {
var p []byte
var i int
for {
i = strings.Index(template, "{")
if i < 0 {
break
}
p = append(p, template[:i]...)
template = template[i+1:]
i = strings.Index(template, "}")
if s, ok := match[template[:i]]; ok {
p = append(p, s...)
} else {
j, _ := strconv.Atoi(template[:i])
if j >= len(subs) {
p = append(p, []byte("Missing")...)
} else {
p = append(p, subs[j]...)
}
}
template = template[i+1:]
}
p = append(p, template...)
return string(p)
}
// Reverse s string, support unicode
func Reverse(s string) string {
n := len(s)
runes := make([]rune, n)
for _, rune := range s {
n--
runes[n] = rune
}
return string(runes[n:])
}
// RandomCreateBytes generate random []byte by specify chars.
func RandomCreateBytes(n int, alphabets ...byte) []byte {
const alphanum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
var bytes = make([]byte, n)
var randby bool
if num, err := rand.Read(bytes); num != n || err != nil {
r.Seed(time.Now().UnixNano())
randby = true
}
for i, b := range bytes {
if len(alphabets) == 0 {
if randby {
bytes[i] = alphanum[r.Intn(len(alphanum))]
} else {
bytes[i] = alphanum[b%byte(len(alphanum))]
}
} else {
if randby {
bytes[i] = alphabets[r.Intn(len(alphabets))]
} else {
bytes[i] = alphabets[b%byte(len(alphabets))]
}
}
}
return bytes
}

View File

@@ -0,0 +1,82 @@
// Copyright 2013 com authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package com
import (
"testing"
)
func TestIsLetter(t *testing.T) {
if IsLetter('1') {
t.Errorf("IsLetter:\n Expect => %v\n Got => %v\n", false, true)
}
if IsLetter('[') {
t.Errorf("IsLetter:\n Expect => %v\n Got => %v\n", false, true)
}
if !IsLetter('a') {
t.Errorf("IsLetter:\n Expect => %v\n Got => %v\n", true, false)
}
if !IsLetter('Z') {
t.Errorf("IsLetter:\n Expect => %v\n Got => %v\n", true, false)
}
}
func TestExpand(t *testing.T) {
match := map[string]string{
"domain": "gowalker.org",
"subdomain": "github.com",
}
s := "http://{domain}/{subdomain}/{0}/{1}"
sR := "http://gowalker.org/github.com/Unknwon/gowalker"
if Expand(s, match, "Unknwon", "gowalker") != sR {
t.Errorf("Expand:\n Expect => %s\n Got => %s\n", sR, s)
}
}
func TestReverse(t *testing.T) {
if Reverse("abcdefg") != "gfedcba" {
t.Errorf("Reverse:\n Except => %s\n Got =>%s\n", "gfedcba", Reverse("abcdefg"))
}
if Reverse("上善若水厚德载物") != "物载德厚水若善上" {
t.Errorf("Reverse:\n Except => %s\n Got =>%s\n", "物载德厚水若善上", Reverse("上善若水厚德载物"))
}
}
func BenchmarkIsLetter(b *testing.B) {
for i := 0; i < b.N; i++ {
IsLetter('a')
}
}
func BenchmarkExpand(b *testing.B) {
match := map[string]string{
"domain": "gowalker.org",
"subdomain": "github.com",
}
s := "http://{domain}/{subdomain}/{0}/{1}"
for i := 0; i < b.N; i++ {
Expand(s, match, "Unknwon", "gowalker")
}
}
func BenchmarkReverse(b *testing.B) {
s := "abscef中文"
for i := 0; i < b.N; i++ {
Reverse(s)
}
}

View File

@@ -0,0 +1 @@
TestSaveFile

View File

@@ -0,0 +1 @@
TestSaveFileS

View File

View File

@@ -0,0 +1 @@
TestSaveFile

View File

@@ -0,0 +1 @@
TestSaveFileS

View File

@@ -0,0 +1 @@
TestSaveFile

View File

@@ -0,0 +1 @@
TestSaveFileS

115
Godeps/_workspace/src/github.com/Unknwon/com/time.go generated vendored Normal file
View File

@@ -0,0 +1,115 @@
// Copyright 2013 com authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package com
import (
"fmt"
"strconv"
"strings"
"time"
)
// Format unix time int64 to string
func Date(ti int64, format string) string {
t := time.Unix(int64(ti), 0)
return DateT(t, format)
}
// Format unix time string to string
func DateS(ts string, format string) string {
i, _ := strconv.ParseInt(ts, 10, 64)
return Date(i, format)
}
// Format time.Time struct to string
// MM - month - 01
// M - month - 1, single bit
// DD - day - 02
// D - day 2
// YYYY - year - 2006
// YY - year - 06
// HH - 24 hours - 03
// H - 24 hours - 3
// hh - 12 hours - 03
// h - 12 hours - 3
// mm - minute - 04
// m - minute - 4
// ss - second - 05
// s - second = 5
func DateT(t time.Time, format string) string {
res := strings.Replace(format, "MM", t.Format("01"), -1)
res = strings.Replace(res, "M", t.Format("1"), -1)
res = strings.Replace(res, "DD", t.Format("02"), -1)
res = strings.Replace(res, "D", t.Format("2"), -1)
res = strings.Replace(res, "YYYY", t.Format("2006"), -1)
res = strings.Replace(res, "YY", t.Format("06"), -1)
res = strings.Replace(res, "HH", fmt.Sprintf("%02d", t.Hour()), -1)
res = strings.Replace(res, "H", fmt.Sprintf("%d", t.Hour()), -1)
res = strings.Replace(res, "hh", t.Format("03"), -1)
res = strings.Replace(res, "h", t.Format("3"), -1)
res = strings.Replace(res, "mm", t.Format("04"), -1)
res = strings.Replace(res, "m", t.Format("4"), -1)
res = strings.Replace(res, "ss", t.Format("05"), -1)
res = strings.Replace(res, "s", t.Format("5"), -1)
return res
}
// DateFormat pattern rules.
var datePatterns = []string{
// year
"Y", "2006", // A full numeric representation of a year, 4 digits Examples: 1999 or 2003
"y", "06", //A two digit representation of a year Examples: 99 or 03
// month
"m", "01", // Numeric representation of a month, with leading zeros 01 through 12
"n", "1", // Numeric representation of a month, without leading zeros 1 through 12
"M", "Jan", // A short textual representation of a month, three letters Jan through Dec
"F", "January", // A full textual representation of a month, such as January or March January through December
// day
"d", "02", // Day of the month, 2 digits with leading zeros 01 to 31
"j", "2", // Day of the month without leading zeros 1 to 31
// week
"D", "Mon", // A textual representation of a day, three letters Mon through Sun
"l", "Monday", // A full textual representation of the day of the week Sunday through Saturday
// time
"g", "3", // 12-hour format of an hour without leading zeros 1 through 12
"G", "15", // 24-hour format of an hour without leading zeros 0 through 23
"h", "03", // 12-hour format of an hour with leading zeros 01 through 12
"H", "15", // 24-hour format of an hour with leading zeros 00 through 23
"a", "pm", // Lowercase Ante meridiem and Post meridiem am or pm
"A", "PM", // Uppercase Ante meridiem and Post meridiem AM or PM
"i", "04", // Minutes with leading zeros 00 to 59
"s", "05", // Seconds, with leading zeros 00 through 59
// time zone
"T", "MST",
"P", "-07:00",
"O", "-0700",
// RFC 2822
"r", time.RFC1123Z,
}
// Parse Date use PHP time format.
func DateParse(dateString, format string) (time.Time, error) {
replacer := strings.NewReplacer(datePatterns...)
format = replacer.Replace(format)
return time.ParseInLocation(format, dateString, time.Local)
}

41
Godeps/_workspace/src/github.com/Unknwon/com/url.go generated vendored Normal file
View File

@@ -0,0 +1,41 @@
// Copyright 2013 com authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package com
import (
"encoding/base64"
"net/url"
)
// url encode string, is + not %20
func UrlEncode(str string) string {
return url.QueryEscape(str)
}
// url decode string
func UrlDecode(str string) (string, error) {
return url.QueryUnescape(str)
}
// base64 encode
func Base64Encode(str string) string {
return base64.StdEncoding.EncodeToString([]byte(str))
}
// base64 decode
func Base64Decode(str string) (string, error) {
s, e := base64.StdEncoding.DecodeString(str)
return string(s), e
}

View File

@@ -0,0 +1,2 @@
macaron.sublime-project
macaron.sublime-workspace

View File

@@ -0,0 +1,191 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and
distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright
owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities
that control, are controlled by, or are under common control with that entity.
For the purposes of this definition, "control" means (i) the power, direct or
indirect, to cause the direction or management of such entity, whether by
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising
permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including
but not limited to software source code, documentation source, and configuration
files.
"Object" form shall mean any form resulting from mechanical transformation or
translation of a Source form, including but not limited to compiled object code,
generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made
available under the License, as indicated by a copyright notice that is included
in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that
is based on (or derived from) the Work and for which the editorial revisions,
annotations, elaborations, or other modifications represent, as a whole, an
original work of authorship. For the purposes of this License, Derivative Works
shall not include works that remain separable from, or merely link (or bind by
name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version
of the Work and any modifications or additions to that Work or Derivative Works
thereof, that is intentionally submitted to Licensor for inclusion in the Work
by the copyright owner or by an individual or Legal Entity authorized to submit
on behalf of the copyright owner. For the purposes of this definition,
"submitted" means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems, and
issue tracking systems that are managed by, or on behalf of, the Licensor for
the purpose of discussing and improving the Work, but excluding communication
that is conspicuously marked or otherwise designated in writing by the copyright
owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
of whom a Contribution has been received by Licensor and subsequently
incorporated within the Work.
2. Grant of Copyright License.
Subject to the terms and conditions of this License, each Contributor hereby
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
irrevocable copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the Work and such
Derivative Works in Source or Object form.
3. Grant of Patent License.
Subject to the terms and conditions of this License, each Contributor hereby
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to make, have
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
such license applies only to those patent claims licensable by such Contributor
that are necessarily infringed by their Contribution(s) alone or by combination
of their Contribution(s) with the Work to which such Contribution(s) was
submitted. If You institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
Contribution incorporated within the Work constitutes direct or contributory
patent infringement, then any patent licenses granted to You under this License
for that Work shall terminate as of the date such litigation is filed.
4. Redistribution.
You may reproduce and distribute copies of the Work or Derivative Works thereof
in any medium, with or without modifications, and in Source or Object form,
provided that You meet the following conditions:
You must give any other recipients of the Work or Derivative Works a copy of
this License; and
You must cause any modified files to carry prominent notices stating that You
changed the files; and
You must retain, in the Source form of any Derivative Works that You distribute,
all copyright, patent, trademark, and attribution notices from the Source form
of the Work, excluding those notices that do not pertain to any part of the
Derivative Works; and
If the Work includes a "NOTICE" text file as part of its distribution, then any
Derivative Works that You distribute must include a readable copy of the
attribution notices contained within such NOTICE file, excluding those notices
that do not pertain to any part of the Derivative Works, in at least one of the
following places: within a NOTICE text file distributed as part of the
Derivative Works; within the Source form or documentation, if provided along
with the Derivative Works; or, within a display generated by the Derivative
Works, if and wherever such third-party notices normally appear. The contents of
the NOTICE file are for informational purposes only and do not modify the
License. You may add Your own attribution notices within Derivative Works that
You distribute, alongside or as an addendum to the NOTICE text from the Work,
provided that such additional attribution notices cannot be construed as
modifying the License.
You may add Your own copyright statement to Your modifications and may provide
additional or different license terms and conditions for use, reproduction, or
distribution of Your modifications, or for any such Derivative Works as a whole,
provided Your use, reproduction, and distribution of the Work otherwise complies
with the conditions stated in this License.
5. Submission of Contributions.
Unless You explicitly state otherwise, any Contribution intentionally submitted
for inclusion in the Work by You to the Licensor shall be under the terms and
conditions of this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify the terms of
any separate license agreement you may have executed with Licensor regarding
such Contributions.
6. Trademarks.
This License does not grant permission to use the trade names, trademarks,
service marks, or product names of the Licensor, except as required for
reasonable and customary use in describing the origin of the Work and
reproducing the content of the NOTICE file.
7. Disclaimer of Warranty.
Unless required by applicable law or agreed to in writing, Licensor provides the
Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
including, without limitation, any warranties or conditions of TITLE,
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
solely responsible for determining the appropriateness of using or
redistributing the Work and assume any risks associated with Your exercise of
permissions under this License.
8. Limitation of Liability.
In no event and under no legal theory, whether in tort (including negligence),
contract, or otherwise, unless required by applicable law (such as deliberate
and grossly negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special, incidental,
or consequential damages of any character arising as a result of this License or
out of the use or inability to use the Work (including but not limited to
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
any and all other commercial damages or losses), even if such Contributor has
been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability.
While redistributing the Work or Derivative Works thereof, You may choose to
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
other liability obligations and/or rights consistent with this License. However,
in accepting such obligations, You may act only on Your own behalf and on Your
sole responsibility, not on behalf of any other Contributor, and only if You
agree to indemnify, defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason of your
accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work
To apply the Apache License to your work, attach the following boilerplate
notice, with the fields enclosed by brackets "[]" replaced with your own
identifying information. (Don't include the brackets!) The text should be
enclosed in the appropriate comment syntax for the file format. We also
recommend that a file or class name and description of purpose be included on
the same "printed page" as the copyright notice for easier identification within
third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -0,0 +1,94 @@
Macaron [![Build Status](https://drone.io/github.com/Unknwon/macaron/status.png)](https://drone.io/github.com/Unknwon/macaron/latest) [![](http://gocover.io/_badge/github.com/Unknwon/macaron)](http://gocover.io/github.com/Unknwon/macaron)
=======================
![Macaron Logo](https://raw.githubusercontent.com/Unknwon/macaron/master/macaronlogo.png)
Package macaron is a high productive and modular design web framework in Go.
##### Current version: 0.5.4
## Getting Started
To install Macaron:
go get github.com/Unknwon/macaron
The very basic usage of Macaron:
```go
package main
import "github.com/Unknwon/macaron"
func main() {
m := macaron.Classic()
m.Get("/", func() string {
return "Hello world!"
})
m.Run()
}
```
## Features
- Powerful routing with suburl.
- Flexible routes combinations.
- Unlimited nested group routers.
- Directly integrate with existing services.
- Dynamically change template files at runtime.
- Allow to use in-memory template and static files.
- Easy to plugin/unplugin features with modular design.
- Handy dependency injection powered by [inject](https://github.com/codegangsta/inject).
- Better router layer and less reflection make faster speed.
## Middlewares
Middlewares allow you easily plugin/unplugin features for your Macaron applications.
There are already many [middlewares](https://github.com/macaron-contrib) to simplify your work:
- gzip - Gzip compression to all requests
- render - Go template engine
- static - Serves static files
- [binding](https://github.com/macaron-contrib/binding) - Request data binding and validation
- [i18n](https://github.com/macaron-contrib/i18n) - Internationalization and Localization
- [cache](https://github.com/macaron-contrib/cache) - Cache manager
- [session](https://github.com/macaron-contrib/session) - Session manager
- [csrf](https://github.com/macaron-contrib/csrf) - Generates and validates csrf tokens
- [captcha](https://github.com/macaron-contrib/captcha) - Captcha service
- [pongo2](https://github.com/macaron-contrib/pongo2) - Pongo2 template engine support
- [sockets](https://github.com/macaron-contrib/sockets) - WebSockets channels binding
- [bindata](https://github.com/macaron-contrib/bindata) - Embed binary data as static and template files
- [toolbox](https://github.com/macaron-contrib/toolbox) - Health check, pprof, profile and statistic services
- [oauth2](https://github.com/macaron-contrib/oauth2) - OAuth 2.0 backend
- [switcher](https://github.com/macaron-contrib/switcher) - Multiple-site support
- [method](https://github.com/macaron-contrib/method) - HTTP method override
- [permissions2](https://github.com/xyproto/permissions2) - Cookies, users and permissions
- [renders](https://github.com/macaron-contrib/renders) - Beego-like render engine(Macaron has built-in template engine, this is another option)
## Use Cases
- [Gogs](https://github.com/gogits/gogs): Go Git Service
- [Gogs Web](https://github.com/gogits/gogsweb): Gogs official website
- [Go Walker](https://gowalker.org): Go online API documentation
- [Switch](https://github.com/gpmgo/switch): Gopm registry
- [YouGam](http://yougam.com): Online Forum
- [Car Girl](http://qcnl.gzsy.com/): Online campaign
- [Critical Stack Intel](https://intel.criticalstack.com/): A 100% free intel marketplace from Critical Stack, Inc.
## Getting Help
- [API Reference](https://gowalker.org/github.com/Unknwon/macaron)
- [Documentation](http://macaron.gogs.io)
- [FAQs](http://macaron.gogs.io/docs/faqs)
- [![Join the chat at https://gitter.im/Unknwon/macaron](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Unknwon/macaron?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
## Credits
- Basic design of [Martini](https://github.com/go-martini/martini).
- Router layer of [beego](https://github.com/astaxie/beego).
- Logo is modified by [@insionng](https://github.com/insionng) based on [Tribal Dragon](http://xtremeyamazaki.deviantart.com/art/Tribal-Dragon-27005087).
## License
This project is under Apache v2 License. See the [LICENSE](LICENSE) file for the full license text.

View File

@@ -0,0 +1,478 @@
// Copyright 2014 Unknwon
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package macaron
import (
"crypto/md5"
"encoding/hex"
"html/template"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"net/url"
"os"
"path"
"path/filepath"
"reflect"
"strconv"
"strings"
"time"
"github.com/Unknwon/com"
"github.com/Unknwon/macaron/inject"
)
// Locale reprents a localization interface.
type Locale interface {
Language() string
Tr(string, ...interface{}) string
}
// RequestBody represents a request body.
type RequestBody struct {
reader io.ReadCloser
}
// Bytes reads and returns content of request body in bytes.
func (rb *RequestBody) Bytes() ([]byte, error) {
return ioutil.ReadAll(rb.reader)
}
// String reads and returns content of request body in string.
func (rb *RequestBody) String() (string, error) {
data, err := rb.Bytes()
return string(data), err
}
// ReadCloser returns a ReadCloser for request body.
func (rb *RequestBody) ReadCloser() io.ReadCloser {
return rb.reader
}
// Request represents an HTTP request received by a server or to be sent by a client.
type Request struct {
*http.Request
}
func (r *Request) Body() *RequestBody {
return &RequestBody{r.Request.Body}
}
// Context represents the runtime context of current request of Macaron instance.
// It is the integration of most frequently used middlewares and helper methods.
type Context struct {
inject.Injector
handlers []Handler
action Handler
index int
*Router
Req Request
Resp ResponseWriter
params Params
Render // Not nil only if you use macaran.Render middleware.
Locale
Data map[string]interface{}
}
func (c *Context) handler() Handler {
if c.index < len(c.handlers) {
return c.handlers[c.index]
}
if c.index == len(c.handlers) {
return c.action
}
panic("invalid index for context handler")
}
func (c *Context) Next() {
c.index += 1
c.run()
}
func (c *Context) Written() bool {
return c.Resp.Written()
}
func (c *Context) run() {
for c.index <= len(c.handlers) {
vals, err := c.Invoke(c.handler())
if err != nil {
panic(err)
}
c.index += 1
// if the handler returned something, write it to the http response
if len(vals) > 0 {
ev := c.GetVal(reflect.TypeOf(ReturnHandler(nil)))
handleReturn := ev.Interface().(ReturnHandler)
handleReturn(c, vals)
}
if c.Written() {
return
}
}
}
// RemoteAddr returns more real IP address.
func (ctx *Context) RemoteAddr() string {
addr := ctx.Req.Header.Get("X-Real-IP")
if len(addr) == 0 {
addr = ctx.Req.Header.Get("X-Forwarded-For")
if addr == "" {
addr = ctx.Req.RemoteAddr
if i := strings.LastIndex(addr, ":"); i > -1 {
addr = addr[:i]
}
}
}
return addr
}
func (ctx *Context) renderHTML(status int, setName, tplName string, data ...interface{}) {
if ctx.Render == nil {
panic("renderer middleware hasn't been registered")
}
if len(data) <= 0 {
ctx.Render.HTMLSet(status, setName, tplName, ctx.Data)
} else if len(data) == 1 {
ctx.Render.HTMLSet(status, setName, tplName, data[0])
} else {
ctx.Render.HTMLSet(status, setName, tplName, data[0], data[1].(HTMLOptions))
}
}
// HTML calls Render.HTML but allows less arguments.
func (ctx *Context) HTML(status int, name string, data ...interface{}) {
ctx.renderHTML(status, _DEFAULT_TPL_SET_NAME, name, data...)
}
// HTML calls Render.HTMLSet but allows less arguments.
func (ctx *Context) HTMLSet(status int, setName, tplName string, data ...interface{}) {
ctx.renderHTML(status, setName, tplName, data...)
}
func (ctx *Context) Redirect(location string, status ...int) {
code := http.StatusFound
if len(status) == 1 {
code = status[0]
}
http.Redirect(ctx.Resp, ctx.Req.Request, location, code)
}
// Query querys form parameter.
func (ctx *Context) Query(name string) string {
if ctx.Req.Form == nil {
ctx.Req.ParseForm()
}
return ctx.Req.Form.Get(name)
}
// QueryTrim querys and trims spaces form parameter.
func (ctx *Context) QueryTrim(name string) string {
return strings.TrimSpace(ctx.Query(name))
}
// QueryStrings returns a list of results by given query name.
func (ctx *Context) QueryStrings(name string) []string {
if ctx.Req.Form == nil {
ctx.Req.ParseForm()
}
vals, ok := ctx.Req.Form[name]
if !ok {
return []string{}
}
return vals
}
// QueryEscape returns escapred query result.
func (ctx *Context) QueryEscape(name string) string {
return template.HTMLEscapeString(ctx.Query(name))
}
// QueryInt returns query result in int type.
func (ctx *Context) QueryInt(name string) int {
return com.StrTo(ctx.Query(name)).MustInt()
}
// QueryInt64 returns query result in int64 type.
func (ctx *Context) QueryInt64(name string) int64 {
return com.StrTo(ctx.Query(name)).MustInt64()
}
// QueryFloat64 returns query result in float64 type.
func (ctx *Context) QueryFloat64(name string) float64 {
v, _ := strconv.ParseFloat(ctx.Query(name), 64)
return v
}
// Params returns value of given param name.
// e.g. ctx.Params(":uid") or ctx.Params("uid")
func (ctx *Context) Params(name string) string {
if len(name) == 0 {
return ""
}
if name[0] != '*' && name[0] != ':' {
name = ":" + name
}
return ctx.params[name]
}
// SetParams sets value of param with given name.
func (ctx *Context) SetParams(name, val string) {
if !strings.HasPrefix(name, ":") {
name = ":" + name
}
ctx.params[name] = val
}
// ParamsEscape returns escapred params result.
// e.g. ctx.ParamsEscape(":uname")
func (ctx *Context) ParamsEscape(name string) string {
return template.HTMLEscapeString(ctx.Params(name))
}
// ParamsInt returns params result in int type.
// e.g. ctx.ParamsInt(":uid")
func (ctx *Context) ParamsInt(name string) int {
return com.StrTo(ctx.Params(name)).MustInt()
}
// ParamsInt64 returns params result in int64 type.
// e.g. ctx.ParamsInt64(":uid")
func (ctx *Context) ParamsInt64(name string) int64 {
return com.StrTo(ctx.Params(name)).MustInt64()
}
// ParamsFloat64 returns params result in int64 type.
// e.g. ctx.ParamsFloat64(":uid")
func (ctx *Context) ParamsFloat64(name string) float64 {
v, _ := strconv.ParseFloat(ctx.Params(name), 64)
return v
}
// GetFile returns information about user upload file by given form field name.
func (ctx *Context) GetFile(name string) (multipart.File, *multipart.FileHeader, error) {
return ctx.Req.FormFile(name)
}
// SetCookie sets given cookie value to response header.
// FIXME: IE support? http://golanghome.com/post/620#reply2
func (ctx *Context) SetCookie(name string, value string, others ...interface{}) {
cookie := http.Cookie{}
cookie.Name = name
cookie.Value = url.QueryEscape(value)
if len(others) > 0 {
switch v := others[0].(type) {
case int:
cookie.MaxAge = v
case int64:
cookie.MaxAge = int(v)
case int32:
cookie.MaxAge = int(v)
}
}
cookie.Path = "/"
if len(others) > 1 {
if v, ok := others[1].(string); ok && len(v) > 0 {
cookie.Path = v
}
}
if len(others) > 2 {
if v, ok := others[2].(string); ok && len(v) > 0 {
cookie.Domain = v
}
}
if len(others) > 3 {
switch v := others[3].(type) {
case bool:
cookie.Secure = v
default:
if others[3] != nil {
cookie.Secure = true
}
}
}
if len(others) > 4 {
if v, ok := others[4].(bool); ok && v {
cookie.HttpOnly = true
}
}
ctx.Resp.Header().Add("Set-Cookie", cookie.String())
}
// GetCookie returns given cookie value from request header.
func (ctx *Context) GetCookie(name string) string {
cookie, err := ctx.Req.Cookie(name)
if err != nil {
return ""
}
val, _ := url.QueryUnescape(cookie.Value)
return val
}
// GetCookieInt returns cookie result in int type.
func (ctx *Context) GetCookieInt(name string) int {
return com.StrTo(ctx.GetCookie(name)).MustInt()
}
// GetCookieInt64 returns cookie result in int64 type.
func (ctx *Context) GetCookieInt64(name string) int64 {
return com.StrTo(ctx.GetCookie(name)).MustInt64()
}
// GetCookieFloat64 returns cookie result in float64 type.
func (ctx *Context) GetCookieFloat64(name string) float64 {
v, _ := strconv.ParseFloat(ctx.GetCookie(name), 64)
return v
}
var defaultCookieSecret string
// SetDefaultCookieSecret sets global default secure cookie secret.
func (m *Macaron) SetDefaultCookieSecret(secret string) {
defaultCookieSecret = secret
}
// SetSecureCookie sets given cookie value to response header with default secret string.
func (ctx *Context) SetSecureCookie(name, value string, others ...interface{}) {
ctx.SetSuperSecureCookie(defaultCookieSecret, name, value, others...)
}
// GetSecureCookie returns given cookie value from request header with default secret string.
func (ctx *Context) GetSecureCookie(key string) (string, bool) {
return ctx.GetSuperSecureCookie(defaultCookieSecret, key)
}
// SetSuperSecureCookie sets given cookie value to response header with secret string.
func (ctx *Context) SetSuperSecureCookie(secret, name, value string, others ...interface{}) {
m := md5.Sum([]byte(secret))
secret = hex.EncodeToString(m[:])
text, err := com.AESEncrypt([]byte(secret), []byte(value))
if err != nil {
panic("error encrypting cookie: " + err.Error())
}
ctx.SetCookie(name, hex.EncodeToString(text), others...)
}
// GetSuperSecureCookie returns given cookie value from request header with secret string.
func (ctx *Context) GetSuperSecureCookie(secret, key string) (string, bool) {
val := ctx.GetCookie(key)
if val == "" {
return "", false
}
data, err := hex.DecodeString(val)
if err != nil {
return "", false
}
m := md5.Sum([]byte(secret))
secret = hex.EncodeToString(m[:])
text, err := com.AESDecrypt([]byte(secret), data)
return string(text), err == nil
}
func (ctx *Context) setRawContentHeader() {
ctx.Resp.Header().Set("Content-Description", "Raw content")
ctx.Resp.Header().Set("Content-Type", "text/plain")
ctx.Resp.Header().Set("Expires", "0")
ctx.Resp.Header().Set("Cache-Control", "must-revalidate")
ctx.Resp.Header().Set("Pragma", "public")
}
// ServeContent serves given content to response.
func (ctx *Context) ServeContent(name string, r io.ReadSeeker, params ...interface{}) {
modtime := time.Now()
for _, p := range params {
switch v := p.(type) {
case time.Time:
modtime = v
}
}
ctx.setRawContentHeader()
http.ServeContent(ctx.Resp, ctx.Req.Request, name, modtime, r)
}
// ServeFileContent serves given file as content to response.
func (ctx *Context) ServeFileContent(file string, names ...string) {
var name string
if len(names) > 0 {
name = names[0]
} else {
name = path.Base(file)
}
f, err := os.Open(file)
if err != nil {
if Env == PROD {
http.Error(ctx.Resp, "Internal Server Error", 500)
} else {
http.Error(ctx.Resp, err.Error(), 500)
}
return
}
defer f.Close()
ctx.setRawContentHeader()
http.ServeContent(ctx.Resp, ctx.Req.Request, name, time.Now(), f)
}
// ServeFile serves given file to response.
func (ctx *Context) ServeFile(file string, names ...string) {
var name string
if len(names) > 0 {
name = names[0]
} else {
name = path.Base(file)
}
ctx.Resp.Header().Set("Content-Description", "File Transfer")
ctx.Resp.Header().Set("Content-Type", "application/octet-stream")
ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+name)
ctx.Resp.Header().Set("Content-Transfer-Encoding", "binary")
ctx.Resp.Header().Set("Expires", "0")
ctx.Resp.Header().Set("Cache-Control", "must-revalidate")
ctx.Resp.Header().Set("Pragma", "public")
http.ServeFile(ctx.Resp, ctx.Req.Request, file)
}
// ChangeStaticPath changes static path from old to new one.
func (ctx *Context) ChangeStaticPath(oldPath, newPath string) {
if !filepath.IsAbs(oldPath) {
oldPath = filepath.Join(Root, oldPath)
}
dir := statics.Get(oldPath)
if dir != nil {
statics.Delete(oldPath)
if !filepath.IsAbs(newPath) {
newPath = filepath.Join(Root, newPath)
}
*dir = http.Dir(newPath)
statics.Set(dir)
}
}

View File

@@ -0,0 +1,370 @@
// Copyright 2014 Unknwon
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package macaron
import (
"bytes"
"io/ioutil"
"net/http"
"net/http/httptest"
"net/url"
"strings"
"testing"
"time"
"github.com/Unknwon/com"
. "github.com/smartystreets/goconvey/convey"
)
func Test_Context(t *testing.T) {
Convey("Do advanced encapsulation operations", t, func() {
m := Classic()
m.Use(Renderers(RenderOptions{
Directory: "fixtures/basic",
}, "fixtures/basic2"))
Convey("Get request body", func() {
m.Get("/body1", func(ctx *Context) {
data, err := ioutil.ReadAll(ctx.Req.Body().ReadCloser())
So(err, ShouldBeNil)
So(string(data), ShouldEqual, "This is my request body")
})
m.Get("/body2", func(ctx *Context) {
data, err := ctx.Req.Body().Bytes()
So(err, ShouldBeNil)
So(string(data), ShouldEqual, "This is my request body")
})
m.Get("/body3", func(ctx *Context) {
data, err := ctx.Req.Body().String()
So(err, ShouldBeNil)
So(data, ShouldEqual, "This is my request body")
})
for i := 1; i <= 3; i++ {
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/body"+com.ToStr(i), nil)
req.Body = ioutil.NopCloser(bytes.NewBufferString("This is my request body"))
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
}
})
Convey("Get remote IP address", func() {
m.Get("/remoteaddr", func(ctx *Context) string {
return ctx.RemoteAddr()
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/remoteaddr", nil)
req.RemoteAddr = "127.0.0.1:3333"
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "127.0.0.1")
})
Convey("Render HTML", func() {
Convey("Normal HTML", func() {
m.Get("/html", func(ctx *Context) {
ctx.HTML(304, "hello", "Unknwon") // 304 for logger test.
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/html", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "<h1>Hello Unknwon</h1>")
})
Convey("HTML template set", func() {
m.Get("/html2", func(ctx *Context) {
ctx.Data["Name"] = "Unknwon"
ctx.HTMLSet(200, "basic2", "hello2")
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/html2", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "<h1>Hello Unknwon</h1>")
})
Convey("With layout", func() {
m.Get("/layout", func(ctx *Context) {
ctx.HTML(200, "hello", "Unknwon", HTMLOptions{"layout"})
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/layout", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "head<h1>Hello Unknwon</h1>foot")
})
})
Convey("Parse from and query", func() {
m.Get("/query", func(ctx *Context) string {
var buf bytes.Buffer
buf.WriteString(ctx.QueryTrim("name") + " ")
buf.WriteString(ctx.QueryEscape("name") + " ")
buf.WriteString(com.ToStr(ctx.QueryInt("int")) + " ")
buf.WriteString(com.ToStr(ctx.QueryInt64("int64")) + " ")
buf.WriteString(com.ToStr(ctx.QueryFloat64("float64")) + " ")
return buf.String()
})
m.Get("/query2", func(ctx *Context) string {
var buf bytes.Buffer
buf.WriteString(strings.Join(ctx.QueryStrings("list"), ",") + " ")
buf.WriteString(strings.Join(ctx.QueryStrings("404"), ",") + " ")
return buf.String()
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/query?name=Unknwon&int=12&int64=123&float64=1.25", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "Unknwon Unknwon 12 123 1.25 ")
resp = httptest.NewRecorder()
req, err = http.NewRequest("GET", "/query2?list=item1&list=item2", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "item1,item2 ")
})
Convey("URL parameter", func() {
m.Get("/:name/:int/:int64/:float64", func(ctx *Context) string {
var buf bytes.Buffer
ctx.SetParams("name", ctx.Params("name"))
buf.WriteString(ctx.Params(""))
buf.WriteString(ctx.Params(":name") + " ")
buf.WriteString(ctx.ParamsEscape(":name") + " ")
buf.WriteString(com.ToStr(ctx.ParamsInt(":int")) + " ")
buf.WriteString(com.ToStr(ctx.ParamsInt64(":int64")) + " ")
buf.WriteString(com.ToStr(ctx.ParamsFloat64(":float64")) + " ")
return buf.String()
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/user/1/13/1.24", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "user user 1 13 1.24 ")
})
Convey("Get file", func() {
m.Get("/getfile", func(ctx *Context) {
ctx.GetFile("hi")
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/getfile", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
})
Convey("Set and get cookie", func() {
m.Get("/set", func(ctx *Context) {
ctx.SetCookie("user", "Unknwon", 1, "/", "localhost", true, true)
ctx.SetCookie("user", "Unknwon", int32(1), "/", "localhost", 1)
ctx.SetCookie("user", "Unknwon", int64(1))
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/set", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Header().Get("Set-Cookie"), ShouldEqual, "user=Unknwon; Path=/; Domain=localhost; Max-Age=1; HttpOnly; Secure")
m.Get("/get", func(ctx *Context) string {
ctx.GetCookie("404")
So(ctx.GetCookieInt("uid"), ShouldEqual, 1)
So(ctx.GetCookieInt64("uid"), ShouldEqual, 1)
So(ctx.GetCookieFloat64("balance"), ShouldEqual, 1.25)
return ctx.GetCookie("user")
})
resp = httptest.NewRecorder()
req, err = http.NewRequest("GET", "/get", nil)
So(err, ShouldBeNil)
req.Header.Set("Cookie", "user=Unknwon; uid=1; balance=1.25")
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "Unknwon")
})
Convey("Set and get secure cookie", func() {
m.SetDefaultCookieSecret("macaron")
m.Get("/set", func(ctx *Context) {
ctx.SetSecureCookie("user", "Unknwon", 1)
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/set", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
cookie := resp.Header().Get("Set-Cookie")
m.Get("/get", func(ctx *Context) string {
name, ok := ctx.GetSecureCookie("user")
So(ok, ShouldBeTrue)
return name
})
resp = httptest.NewRecorder()
req, err = http.NewRequest("GET", "/get", nil)
So(err, ShouldBeNil)
req.Header.Set("Cookie", cookie)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "Unknwon")
})
Convey("Serve files", func() {
m.Get("/file", func(ctx *Context) {
ctx.ServeFile("fixtures/custom_funcs/index.tmpl")
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/file", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "{{ myCustomFunc }}")
m.Get("/file2", func(ctx *Context) {
ctx.ServeFile("fixtures/custom_funcs/index.tmpl", "ok.tmpl")
})
resp = httptest.NewRecorder()
req, err = http.NewRequest("GET", "/file2", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "{{ myCustomFunc }}")
})
Convey("Serve file content", func() {
m.Get("/file", func(ctx *Context) {
ctx.ServeFileContent("fixtures/custom_funcs/index.tmpl")
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/file", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "{{ myCustomFunc }}")
m.Get("/file2", func(ctx *Context) {
ctx.ServeFileContent("fixtures/custom_funcs/index.tmpl", "ok.tmpl")
})
resp = httptest.NewRecorder()
req, err = http.NewRequest("GET", "/file2", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "{{ myCustomFunc }}")
m.Get("/file3", func(ctx *Context) {
ctx.ServeFileContent("404.tmpl")
})
resp = httptest.NewRecorder()
req, err = http.NewRequest("GET", "/file3", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "open 404.tmpl: no such file or directory\n")
So(resp.Code, ShouldEqual, 500)
})
Convey("Serve content", func() {
m.Get("/content", func(ctx *Context) {
ctx.ServeContent("content1", bytes.NewReader([]byte("Hello world!")))
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/content", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "Hello world!")
m.Get("/content2", func(ctx *Context) {
ctx.ServeContent("content1", bytes.NewReader([]byte("Hello world!")), time.Now())
})
resp = httptest.NewRecorder()
req, err = http.NewRequest("GET", "/content2", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "Hello world!")
})
})
}
func Test_Context_Render(t *testing.T) {
Convey("Invalid render", t, func() {
defer func() {
So(recover(), ShouldNotBeNil)
}()
m := New()
m.Get("/", func(ctx *Context) {
ctx.HTML(200, "hey")
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
})
}
func Test_Context_Redirect(t *testing.T) {
Convey("Context with default redirect", t, func() {
url, err := url.Parse("http://localhost/path/one")
So(err, ShouldBeNil)
resp := httptest.NewRecorder()
req := http.Request{
Method: "GET",
URL: url,
}
ctx := &Context{
Req: Request{&req},
Resp: NewResponseWriter(resp),
Data: make(map[string]interface{}),
}
ctx.Redirect("two")
So(resp.Code, ShouldEqual, http.StatusFound)
So(resp.HeaderMap["Location"][0], ShouldEqual, "/path/two")
})
Convey("Context with custom redirect", t, func() {
url, err := url.Parse("http://localhost/path/one")
So(err, ShouldBeNil)
resp := httptest.NewRecorder()
req := http.Request{
Method: "GET",
URL: url,
}
ctx := &Context{
Req: Request{&req},
Resp: NewResponseWriter(resp),
Data: make(map[string]interface{}),
}
ctx.Redirect("two", 307)
So(resp.Code, ShouldEqual, http.StatusTemporaryRedirect)
So(resp.HeaderMap["Location"][0], ShouldEqual, "/path/two")
})
}

View File

@@ -0,0 +1 @@
<h1>Admin {{.}}</h1>

View File

@@ -0,0 +1 @@
another head{{ yield }}another foot

View File

@@ -0,0 +1 @@
<h1>{{ . }}</h1>

View File

@@ -0,0 +1 @@
{{ current }} head{{ yield }}{{ current }} foot

View File

@@ -0,0 +1 @@
<h1>Hello {[{.}]}</h1>

View File

@@ -0,0 +1 @@
<h1>Hello {{.}}</h1>

View File

@@ -0,0 +1 @@
Hypertext!

View File

@@ -0,0 +1 @@
head{{ yield }}foot

View File

@@ -0,0 +1 @@
<h1>What's up, {{.}}</h1>

View File

@@ -0,0 +1 @@
<h1>Hello {{.Name}}</h1>

View File

@@ -0,0 +1 @@
{{ myCustomFunc }}

View File

@@ -0,0 +1,81 @@
// Copyright 2013 Martini Authors
// Copyright 2014 Unknwon
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package macaron
import (
"bufio"
"compress/gzip"
"fmt"
"net"
"net/http"
"strings"
)
const (
HeaderAcceptEncoding = "Accept-Encoding"
HeaderContentEncoding = "Content-Encoding"
HeaderContentLength = "Content-Length"
HeaderContentType = "Content-Type"
HeaderVary = "Vary"
)
// Gziper returns a Handler that adds gzip compression to all requests.
// Make sure to include the Gzip middleware above other middleware
// that alter the response body (like the render middleware).
func Gziper() Handler {
return func(ctx *Context) {
if !strings.Contains(ctx.Req.Header.Get(HeaderAcceptEncoding), "gzip") {
return
}
headers := ctx.Resp.Header()
headers.Set(HeaderContentEncoding, "gzip")
headers.Set(HeaderVary, HeaderAcceptEncoding)
gz := gzip.NewWriter(ctx.Resp)
defer gz.Close()
gzw := gzipResponseWriter{gz, ctx.Resp}
ctx.Resp = gzw
ctx.MapTo(gzw, (*http.ResponseWriter)(nil))
ctx.Next()
// delete content length after we know we have been written to
gzw.Header().Del("Content-Length")
}
}
type gzipResponseWriter struct {
w *gzip.Writer
ResponseWriter
}
func (grw gzipResponseWriter) Write(p []byte) (int, error) {
if len(grw.Header().Get(HeaderContentType)) == 0 {
grw.Header().Set(HeaderContentType, http.DetectContentType(p))
}
return grw.w.Write(p)
}
func (grw gzipResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
hijacker, ok := grw.ResponseWriter.(http.Hijacker)
if !ok {
return nil, nil, fmt.Errorf("the ResponseWriter doesn't support the Hijacker interface")
}
return hijacker.Hijack()
}

View File

@@ -0,0 +1,65 @@
// Copyright 2013 Martini Authors
// Copyright 2014 Unknwon
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package macaron
import (
"net/http"
"net/http/httptest"
"strings"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func Test_Gzip(t *testing.T) {
Convey("Gzip response content", t, func() {
before := false
m := New()
m.Use(Gziper())
m.Use(func(r http.ResponseWriter) {
r.(ResponseWriter).Before(func(rw ResponseWriter) {
before = true
})
})
m.Get("/", func() string { return "hello wolrd!" })
// Not yet gzip.
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
_, ok := resp.HeaderMap[HeaderContentEncoding]
So(ok, ShouldBeFalse)
ce := resp.Header().Get(HeaderContentEncoding)
So(strings.EqualFold(ce, "gzip"), ShouldBeFalse)
// Gzip now.
resp = httptest.NewRecorder()
req.Header.Set(HeaderAcceptEncoding, "gzip")
m.ServeHTTP(resp, req)
_, ok = resp.HeaderMap[HeaderContentEncoding]
So(ok, ShouldBeTrue)
ce = resp.Header().Get(HeaderContentEncoding)
So(strings.EqualFold(ce, "gzip"), ShouldBeTrue)
So(before, ShouldBeTrue)
})
}

View File

@@ -0,0 +1,4 @@
inject
======
Dependency injection for go

View File

@@ -0,0 +1,187 @@
// Package inject provides utilities for mapping and injecting dependencies in various ways.
package inject
import (
"fmt"
"reflect"
)
// Injector represents an interface for mapping and injecting dependencies into structs
// and function arguments.
type Injector interface {
Applicator
Invoker
TypeMapper
// SetParent sets the parent of the injector. If the injector cannot find a
// dependency in its Type map it will check its parent before returning an
// error.
SetParent(Injector)
}
// Applicator represents an interface for mapping dependencies to a struct.
type Applicator interface {
// Maps dependencies in the Type map to each field in the struct
// that is tagged with 'inject'. Returns an error if the injection
// fails.
Apply(interface{}) error
}
// Invoker represents an interface for calling functions via reflection.
type Invoker interface {
// Invoke attempts to call the interface{} provided as a function,
// providing dependencies for function arguments based on Type. Returns
// a slice of reflect.Value representing the returned values of the function.
// Returns an error if the injection fails.
Invoke(interface{}) ([]reflect.Value, error)
}
// TypeMapper represents an interface for mapping interface{} values based on type.
type TypeMapper interface {
// Maps the interface{} value based on its immediate type from reflect.TypeOf.
Map(interface{}) TypeMapper
// Maps the interface{} value based on the pointer of an Interface provided.
// This is really only useful for mapping a value as an interface, as interfaces
// cannot at this time be referenced directly without a pointer.
MapTo(interface{}, interface{}) TypeMapper
// Provides a possibility to directly insert a mapping based on type and value.
// This makes it possible to directly map type arguments not possible to instantiate
// with reflect like unidirectional channels.
Set(reflect.Type, reflect.Value) TypeMapper
// Returns the Value that is mapped to the current type. Returns a zeroed Value if
// the Type has not been mapped.
GetVal(reflect.Type) reflect.Value
}
type injector struct {
values map[reflect.Type]reflect.Value
parent Injector
}
// InterfaceOf dereferences a pointer to an Interface type.
// It panics if value is not an pointer to an interface.
func InterfaceOf(value interface{}) reflect.Type {
t := reflect.TypeOf(value)
for t.Kind() == reflect.Ptr {
t = t.Elem()
}
if t.Kind() != reflect.Interface {
panic("Called inject.InterfaceOf with a value that is not a pointer to an interface. (*MyInterface)(nil)")
}
return t
}
// New returns a new Injector.
func New() Injector {
return &injector{
values: make(map[reflect.Type]reflect.Value),
}
}
// Invoke attempts to call the interface{} provided as a function,
// providing dependencies for function arguments based on Type.
// Returns a slice of reflect.Value representing the returned values of the function.
// Returns an error if the injection fails.
// It panics if f is not a function
func (inj *injector) Invoke(f interface{}) ([]reflect.Value, error) {
t := reflect.TypeOf(f)
var in = make([]reflect.Value, t.NumIn()) //Panic if t is not kind of Func
for i := 0; i < t.NumIn(); i++ {
argType := t.In(i)
val := inj.GetVal(argType)
if !val.IsValid() {
return nil, fmt.Errorf("Value not found for type %v", argType)
}
in[i] = val
}
return reflect.ValueOf(f).Call(in), nil
}
// Maps dependencies in the Type map to each field in the struct
// that is tagged with 'inject'.
// Returns an error if the injection fails.
func (inj *injector) Apply(val interface{}) error {
v := reflect.ValueOf(val)
for v.Kind() == reflect.Ptr {
v = v.Elem()
}
if v.Kind() != reflect.Struct {
return nil // Should not panic here ?
}
t := v.Type()
for i := 0; i < v.NumField(); i++ {
f := v.Field(i)
structField := t.Field(i)
if f.CanSet() && (structField.Tag == "inject" || structField.Tag.Get("inject") != "") {
ft := f.Type()
v := inj.GetVal(ft)
if !v.IsValid() {
return fmt.Errorf("Value not found for type %v", ft)
}
f.Set(v)
}
}
return nil
}
// Maps the concrete value of val to its dynamic type using reflect.TypeOf,
// It returns the TypeMapper registered in.
func (i *injector) Map(val interface{}) TypeMapper {
i.values[reflect.TypeOf(val)] = reflect.ValueOf(val)
return i
}
func (i *injector) MapTo(val interface{}, ifacePtr interface{}) TypeMapper {
i.values[InterfaceOf(ifacePtr)] = reflect.ValueOf(val)
return i
}
// Maps the given reflect.Type to the given reflect.Value and returns
// the Typemapper the mapping has been registered in.
func (i *injector) Set(typ reflect.Type, val reflect.Value) TypeMapper {
i.values[typ] = val
return i
}
func (i *injector) GetVal(t reflect.Type) reflect.Value {
val := i.values[t]
if val.IsValid() {
return val
}
// no concrete types found, try to find implementors
// if t is an interface
if t.Kind() == reflect.Interface {
for k, v := range i.values {
if k.Implements(t) {
val = v
break
}
}
}
// Still no type found, try to look it up on the parent
if !val.IsValid() && i.parent != nil {
val = i.parent.GetVal(t)
}
return val
}
func (i *injector) SetParent(parent Injector) {
i.parent = parent
}

View File

@@ -0,0 +1 @@
ignore

View File

@@ -0,0 +1,174 @@
// Copyright 2013 Martini Authors
// Copyright 2014 Unknwon
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package inject_test
import (
"fmt"
"reflect"
"testing"
"github.com/Unknwon/macaron/inject"
)
type SpecialString interface {
}
type TestStruct struct {
Dep1 string `inject:"t" json:"-"`
Dep2 SpecialString `inject`
Dep3 string
}
type Greeter struct {
Name string
}
func (g *Greeter) String() string {
return "Hello, My name is" + g.Name
}
/* Test Helpers */
func expect(t *testing.T, a interface{}, b interface{}) {
if a != b {
t.Errorf("Expected %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a))
}
}
func refute(t *testing.T, a interface{}, b interface{}) {
if a == b {
t.Errorf("Did not expect %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a))
}
}
func Test_InjectorInvoke(t *testing.T) {
injector := inject.New()
expect(t, injector == nil, false)
dep := "some dependency"
injector.Map(dep)
dep2 := "another dep"
injector.MapTo(dep2, (*SpecialString)(nil))
dep3 := make(chan *SpecialString)
dep4 := make(chan *SpecialString)
typRecv := reflect.ChanOf(reflect.RecvDir, reflect.TypeOf(dep3).Elem())
typSend := reflect.ChanOf(reflect.SendDir, reflect.TypeOf(dep4).Elem())
injector.Set(typRecv, reflect.ValueOf(dep3))
injector.Set(typSend, reflect.ValueOf(dep4))
_, err := injector.Invoke(func(d1 string, d2 SpecialString, d3 <-chan *SpecialString, d4 chan<- *SpecialString) {
expect(t, d1, dep)
expect(t, d2, dep2)
expect(t, reflect.TypeOf(d3).Elem(), reflect.TypeOf(dep3).Elem())
expect(t, reflect.TypeOf(d4).Elem(), reflect.TypeOf(dep4).Elem())
expect(t, reflect.TypeOf(d3).ChanDir(), reflect.RecvDir)
expect(t, reflect.TypeOf(d4).ChanDir(), reflect.SendDir)
})
expect(t, err, nil)
}
func Test_InjectorInvokeReturnValues(t *testing.T) {
injector := inject.New()
expect(t, injector == nil, false)
dep := "some dependency"
injector.Map(dep)
dep2 := "another dep"
injector.MapTo(dep2, (*SpecialString)(nil))
result, err := injector.Invoke(func(d1 string, d2 SpecialString) string {
expect(t, d1, dep)
expect(t, d2, dep2)
return "Hello world"
})
expect(t, result[0].String(), "Hello world")
expect(t, err, nil)
}
func Test_InjectorApply(t *testing.T) {
injector := inject.New()
injector.Map("a dep").MapTo("another dep", (*SpecialString)(nil))
s := TestStruct{}
err := injector.Apply(&s)
expect(t, err, nil)
expect(t, s.Dep1, "a dep")
expect(t, s.Dep2, "another dep")
}
func Test_InterfaceOf(t *testing.T) {
iType := inject.InterfaceOf((*SpecialString)(nil))
expect(t, iType.Kind(), reflect.Interface)
iType = inject.InterfaceOf((**SpecialString)(nil))
expect(t, iType.Kind(), reflect.Interface)
// Expecting nil
defer func() {
rec := recover()
refute(t, rec, nil)
}()
iType = inject.InterfaceOf((*testing.T)(nil))
}
func Test_InjectorSet(t *testing.T) {
injector := inject.New()
typ := reflect.TypeOf("string")
typSend := reflect.ChanOf(reflect.SendDir, typ)
typRecv := reflect.ChanOf(reflect.RecvDir, typ)
// instantiating unidirectional channels is not possible using reflect
// http://golang.org/src/pkg/reflect/value.go?s=60463:60504#L2064
chanRecv := reflect.MakeChan(reflect.ChanOf(reflect.BothDir, typ), 0)
chanSend := reflect.MakeChan(reflect.ChanOf(reflect.BothDir, typ), 0)
injector.Set(typSend, chanSend)
injector.Set(typRecv, chanRecv)
expect(t, injector.GetVal(typSend).IsValid(), true)
expect(t, injector.GetVal(typRecv).IsValid(), true)
expect(t, injector.GetVal(chanSend.Type()).IsValid(), false)
}
func Test_InjectorGet(t *testing.T) {
injector := inject.New()
injector.Map("some dependency")
expect(t, injector.GetVal(reflect.TypeOf("string")).IsValid(), true)
expect(t, injector.GetVal(reflect.TypeOf(11)).IsValid(), false)
}
func Test_InjectorSetParent(t *testing.T) {
injector := inject.New()
injector.MapTo("another dep", (*SpecialString)(nil))
injector2 := inject.New()
injector2.SetParent(injector)
expect(t, injector2.GetVal(inject.InterfaceOf((*SpecialString)(nil))).IsValid(), true)
}
func TestInjectImplementors(t *testing.T) {
injector := inject.New()
g := &Greeter{"Jeremy"}
injector.Map(g)
expect(t, injector.GetVal(inject.InterfaceOf((*fmt.Stringer)(nil))).IsValid(), true)
}

View File

@@ -0,0 +1,61 @@
// Copyright 2013 Martini Authors
// Copyright 2014 Unknwon
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package macaron
import (
"fmt"
"log"
"net/http"
"runtime"
"time"
)
var ColorLog = true
func init() {
ColorLog = runtime.GOOS != "windows"
}
// Logger returns a middleware handler that logs the request as it goes in and the response as it goes out.
func Logger() Handler {
return func(ctx *Context, log *log.Logger) {
start := time.Now()
log.Printf("Started %s %s for %s", ctx.Req.Method, ctx.Req.RequestURI, ctx.RemoteAddr())
rw := ctx.Resp.(ResponseWriter)
ctx.Next()
content := fmt.Sprintf("Completed %s %v %s in %v", ctx.Req.RequestURI, rw.Status(), http.StatusText(rw.Status()), time.Since(start))
if ColorLog {
switch rw.Status() {
case 200, 201, 202:
content = fmt.Sprintf("\033[1;32m%s\033[0m", content)
case 301, 302:
content = fmt.Sprintf("\033[1;37m%s\033[0m", content)
case 304:
content = fmt.Sprintf("\033[1;33m%s\033[0m", content)
case 401, 403:
content = fmt.Sprintf("\033[4;31m%s\033[0m", content)
case 404:
content = fmt.Sprintf("\033[1;31m%s\033[0m", content)
case 500:
content = fmt.Sprintf("\033[1;36m%s\033[0m", content)
}
}
log.Println(content)
}
}

View File

@@ -0,0 +1,67 @@
// Copyright 2013 Martini Authors
// Copyright 2014 Unknwon
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package macaron
import (
"bytes"
"log"
"net/http"
"net/http/httptest"
"testing"
"github.com/Unknwon/com"
. "github.com/smartystreets/goconvey/convey"
)
func Test_Logger(t *testing.T) {
Convey("Global logger", t, func() {
buf := bytes.NewBufferString("")
m := New()
m.Map(log.New(buf, "[Macaron] ", 0))
m.Use(Logger())
m.Use(func(res http.ResponseWriter) {
res.WriteHeader(http.StatusNotFound)
})
m.Get("/", func() {})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "http://localhost:4000/", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusNotFound)
So(len(buf.String()), ShouldBeGreaterThan, 0)
})
if ColorLog {
Convey("Color console output", t, func() {
m := Classic()
m.Get("/:code:int", func(ctx *Context) (int, string) {
return ctx.ParamsInt(":code"), ""
})
// Just for testing if logger would capture.
codes := []int{200, 201, 202, 301, 302, 304, 401, 403, 404, 500}
for _, code := range codes {
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "http://localhost:4000/"+com.ToStr(code), nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, code)
}
})
}
}

View File

@@ -0,0 +1,273 @@
// Copyright 2014 Unknwon
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
// Package macaron is a high productive and modular design web framework in Go.
package macaron
import (
"io"
"log"
"net/http"
"os"
"reflect"
"strings"
"github.com/Unknwon/com"
"gopkg.in/ini.v1"
"github.com/Unknwon/macaron/inject"
)
const _VERSION = "0.5.4.0318"
func Version() string {
return _VERSION
}
// Handler can be any callable function.
// Macaron attempts to inject services into the handler's argument list,
// and panics if an argument could not be fullfilled via dependency injection.
type Handler interface{}
// validateHandler makes sure a handler is a callable function,
// and panics if it is not.
func validateHandler(h Handler) {
if reflect.TypeOf(h).Kind() != reflect.Func {
panic("Macaron handler must be a callable function")
}
}
// validateHandlers makes sure handlers are callable functions,
// and panics if any of them is not.
func validateHandlers(handlers []Handler) {
for _, h := range handlers {
validateHandler(h)
}
}
// Macaron represents the top level web application.
// inject.Injector methods can be invoked to map services on a global level.
type Macaron struct {
inject.Injector
befores []BeforeHandler
handlers []Handler
action Handler
urlPrefix string // For suburl support.
*Router
logger *log.Logger
}
// NewWithLogger creates a bare bones Macaron instance.
// Use this method if you want to have full control over the middleware that is used.
// You can specify logger output writer with this function.
func NewWithLogger(out io.Writer) *Macaron {
m := &Macaron{
Injector: inject.New(),
action: func() {},
Router: NewRouter(),
logger: log.New(out, "[Macaron] ", 0),
}
m.Router.m = m
m.Map(m.logger)
m.Map(defaultReturnHandler())
m.notFound = func(resp http.ResponseWriter, req *http.Request) {
c := m.createContext(resp, req)
c.handlers = append(c.handlers, http.NotFound)
c.run()
}
return m
}
// New creates a bare bones Macaron instance.
// Use this method if you want to have full control over the middleware that is used.
func New() *Macaron {
return NewWithLogger(os.Stdout)
}
// Classic creates a classic Macaron with some basic default middleware:
// mocaron.Logger, mocaron.Recovery and mocaron.Static.
func Classic() *Macaron {
m := New()
m.Use(Logger())
m.Use(Recovery())
m.Use(Static("public"))
return m
}
// Handlers sets the entire middleware stack with the given Handlers.
// This will clear any current middleware handlers,
// and panics if any of the handlers is not a callable function
func (m *Macaron) Handlers(handlers ...Handler) {
m.handlers = make([]Handler, 0)
for _, handler := range handlers {
m.Use(handler)
}
}
// Action sets the handler that will be called after all the middleware has been invoked.
// This is set to macaron.Router in a macaron.Classic().
func (m *Macaron) Action(handler Handler) {
validateHandler(handler)
m.action = handler
}
// BeforeHandler represents a handler executes at beginning of every request.
// Macaron stops future process when it returns true.
type BeforeHandler func(rw http.ResponseWriter, req *http.Request) bool
func (m *Macaron) Before(handler BeforeHandler) {
m.befores = append(m.befores, handler)
}
// Use adds a middleware Handler to the stack,
// and panics if the handler is not a callable func.
// Middleware Handlers are invoked in the order that they are added.
func (m *Macaron) Use(handler Handler) {
validateHandler(handler)
m.handlers = append(m.handlers, handler)
}
func (m *Macaron) createContext(rw http.ResponseWriter, req *http.Request) *Context {
c := &Context{
Injector: inject.New(),
handlers: m.handlers,
action: m.action,
index: 0,
Router: m.Router,
Req: Request{req},
Resp: NewResponseWriter(rw),
Data: make(map[string]interface{}),
}
c.SetParent(m)
c.Map(c)
c.MapTo(c.Resp, (*http.ResponseWriter)(nil))
c.Map(req)
return c
}
// ServeHTTP is the HTTP Entry point for a Macaron instance.
// Useful if you want to control your own HTTP server.
// Be aware that none of middleware will run without registering any router.
func (m *Macaron) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
req.URL.Path = strings.TrimPrefix(req.URL.Path, m.urlPrefix)
for _, h := range m.befores {
if h(rw, req) {
return
}
}
m.Router.ServeHTTP(rw, req)
}
func GetDefaultListenInfo() (string, int) {
host := os.Getenv("HOST")
if len(host) == 0 {
host = "0.0.0.0"
}
port := com.StrTo(os.Getenv("PORT")).MustInt()
if port == 0 {
port = 4000
}
return host, port
}
// Run the http server. Listening on os.GetEnv("PORT") or 4000 by default.
func (m *Macaron) Run(args ...interface{}) {
host, port := GetDefaultListenInfo()
if len(args) == 1 {
switch arg := args[0].(type) {
case string:
host = arg
case int:
port = arg
}
} else if len(args) >= 2 {
if arg, ok := args[0].(string); ok {
host = arg
}
if arg, ok := args[1].(int); ok {
port = arg
}
}
addr := host + ":" + com.ToStr(port)
logger := m.Injector.GetVal(reflect.TypeOf(m.logger)).Interface().(*log.Logger)
logger.Printf("listening on %s (%s)\n", addr, Env)
logger.Fatalln(http.ListenAndServe(addr, m))
}
// SetURLPrefix sets URL prefix of router layer, so that it support suburl.
func (m *Macaron) SetURLPrefix(prefix string) {
m.urlPrefix = prefix
}
// ____ ____ .__ ___. .__
// \ \ / /____ _______|__|____ \_ |__ | | ____ ______
// \ Y /\__ \\_ __ \ \__ \ | __ \| | _/ __ \ / ___/
// \ / / __ \| | \/ |/ __ \| \_\ \ |_\ ___/ \___ \
// \___/ (____ /__| |__(____ /___ /____/\___ >____ >
// \/ \/ \/ \/ \/
const (
DEV = "development"
PROD = "production"
TEST = "test"
)
var (
// Env is the environment that Macaron is executing in.
// The MACARON_ENV is read on initialization to set this variable.
Env = DEV
// Path of work directory.
Root string
// Flash applies to current request.
FlashNow bool
// Configuration convention object.
cfg *ini.File
)
func setENV(e string) {
if len(e) > 0 {
Env = e
}
}
func init() {
setENV(os.Getenv("MACARON_ENV"))
var err error
Root, err = os.Getwd()
if err != nil {
panic("error getting work directory: " + err.Error())
}
}
// SetConfig sets data sources for configuration.
func SetConfig(source interface{}, others ...interface{}) (_ *ini.File, err error) {
cfg, err = ini.Load(source, others...)
return Config(), err
}
// Config returns configuration convention object.
// It returns an empty object if there is no one available.
func Config() *ini.File {
if cfg == nil {
return ini.Empty()
}
return cfg
}

View File

@@ -0,0 +1,218 @@
// Copyright 2013 Martini Authors
// Copyright 2014 Unknwon
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package macaron
import (
"net/http"
"net/http/httptest"
"os"
"testing"
"time"
. "github.com/smartystreets/goconvey/convey"
)
func Test_Version(t *testing.T) {
Convey("Get version", t, func() {
So(Version(), ShouldEqual, _VERSION)
})
}
func Test_New(t *testing.T) {
Convey("Initialize a new instance", t, func() {
So(New(), ShouldNotBeNil)
})
Convey("Just test that Run doesn't bomb", t, func() {
go New().Run()
time.Sleep(1 * time.Second)
os.Setenv("PORT", "4001")
go New().Run("0.0.0.0")
go New().Run(4002)
go New().Run("0.0.0.0", 4003)
})
}
func Test_Macaron_Before(t *testing.T) {
Convey("Register before handlers", t, func() {
m := New()
m.Before(func(rw http.ResponseWriter, req *http.Request) bool {
return false
})
m.Before(func(rw http.ResponseWriter, req *http.Request) bool {
return true
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
})
}
func Test_Macaron_ServeHTTP(t *testing.T) {
Convey("Serve HTTP requests", t, func() {
result := ""
m := New()
m.Use(func(c *Context) {
result += "foo"
c.Next()
result += "ban"
})
m.Use(func(c *Context) {
result += "bar"
c.Next()
result += "baz"
})
m.Get("/", func() {})
m.Action(func(res http.ResponseWriter, req *http.Request) {
result += "bat"
res.WriteHeader(http.StatusBadRequest)
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(result, ShouldEqual, "foobarbatbazban")
So(resp.Code, ShouldEqual, http.StatusBadRequest)
})
}
func Test_Macaron_Handlers(t *testing.T) {
Convey("Add custom handlers", t, func() {
result := ""
batman := func(c *Context) {
result += "batman!"
}
m := New()
m.Use(func(c *Context) {
result += "foo"
c.Next()
result += "ban"
})
m.Handlers(
batman,
batman,
batman,
)
Convey("Add not callable function", func() {
defer func() {
So(recover(), ShouldNotBeNil)
}()
m.Use("shit")
})
m.Get("/", func() {})
m.Action(func(res http.ResponseWriter, req *http.Request) {
result += "bat"
res.WriteHeader(http.StatusBadRequest)
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(result, ShouldEqual, "batman!batman!batman!bat")
So(resp.Code, ShouldEqual, http.StatusBadRequest)
})
}
func Test_Macaron_EarlyWrite(t *testing.T) {
Convey("Write early content to response", t, func() {
result := ""
m := New()
m.Use(func(res http.ResponseWriter) {
result += "foobar"
res.Write([]byte("Hello world"))
})
m.Use(func() {
result += "bat"
})
m.Get("/", func() {})
m.Action(func(res http.ResponseWriter) {
result += "baz"
res.WriteHeader(http.StatusBadRequest)
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(result, ShouldEqual, "foobar")
So(resp.Code, ShouldEqual, http.StatusOK)
})
}
func Test_Macaron_Written(t *testing.T) {
Convey("Written sign", t, func() {
resp := httptest.NewRecorder()
m := New()
m.Handlers(func(res http.ResponseWriter) {
res.WriteHeader(http.StatusOK)
})
ctx := m.createContext(resp, &http.Request{Method: "GET"})
So(ctx.Written(), ShouldBeFalse)
ctx.run()
So(ctx.Written(), ShouldBeTrue)
})
}
func Test_Macaron_Basic_NoRace(t *testing.T) {
Convey("Make sure no race between requests", t, func() {
m := New()
handlers := []Handler{func() {}, func() {}}
// Ensure append will not realloc to trigger the race condition
m.handlers = handlers[:1]
m.Get("/", func() {})
req, _ := http.NewRequest("GET", "/", nil)
for i := 0; i < 2; i++ {
go func() {
resp := httptest.NewRecorder()
m.ServeHTTP(resp, req)
}()
}
})
}
func Test_SetENV(t *testing.T) {
Convey("Get and save environment variable", t, func() {
tests := []struct {
in string
out string
}{
{"", "development"},
{"not_development", "not_development"},
}
for _, test := range tests {
setENV(test.in)
So(Env, ShouldEqual, test.out)
}
})
}
func Test_Config(t *testing.T) {
Convey("Set and get configuration object", t, func() {
So(Config(), ShouldNotBeNil)
cfg, err := SetConfig([]byte(""))
So(err, ShouldBeNil)
So(cfg, ShouldNotBeNil)
})
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

View File

@@ -0,0 +1,163 @@
// Copyright 2013 Martini Authors
// Copyright 2014 Unknwon
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package macaron
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"net/http"
"runtime"
"github.com/Unknwon/macaron/inject"
)
const (
panicHtml = `<html>
<head><title>PANIC: %s</title>
<meta charset="utf-8" />
<style type="text/css">
html, body {
font-family: "Roboto", sans-serif;
color: #333333;
background-color: #ea5343;
margin: 0px;
}
h1 {
color: #d04526;
background-color: #ffffff;
padding: 20px;
border-bottom: 1px dashed #2b3848;
}
pre {
margin: 20px;
padding: 20px;
border: 2px solid #2b3848;
background-color: #ffffff;
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
</style>
</head><body>
<h1>PANIC</h1>
<pre style="font-weight: bold;">%s</pre>
<pre>%s</pre>
</body>
</html>`
)
var (
dunno = []byte("???")
centerDot = []byte("·")
dot = []byte(".")
slash = []byte("/")
)
// stack returns a nicely formated stack frame, skipping skip frames
func stack(skip int) []byte {
buf := new(bytes.Buffer) // the returned data
// As we loop, we open files and read them. These variables record the currently
// loaded file.
var lines [][]byte
var lastFile string
for i := skip; ; i++ { // Skip the expected number of frames
pc, file, line, ok := runtime.Caller(i)
if !ok {
break
}
// Print this much at least. If we can't find the source, it won't show.
fmt.Fprintf(buf, "%s:%d (0x%x)\n", file, line, pc)
if file != lastFile {
data, err := ioutil.ReadFile(file)
if err != nil {
continue
}
lines = bytes.Split(data, []byte{'\n'})
lastFile = file
}
fmt.Fprintf(buf, "\t%s: %s\n", function(pc), source(lines, line))
}
return buf.Bytes()
}
// source returns a space-trimmed slice of the n'th line.
func source(lines [][]byte, n int) []byte {
n-- // in stack trace, lines are 1-indexed but our array is 0-indexed
if n < 0 || n >= len(lines) {
return dunno
}
return bytes.TrimSpace(lines[n])
}
// function returns, if possible, the name of the function containing the PC.
func function(pc uintptr) []byte {
fn := runtime.FuncForPC(pc)
if fn == nil {
return dunno
}
name := []byte(fn.Name())
// The name includes the path name to the package, which is unnecessary
// since the file name is already included. Plus, it has center dots.
// That is, we see
// runtime/debug.*T·ptrmethod
// and want
// *T.ptrmethod
// Also the package path might contains dot (e.g. code.google.com/...),
// so first eliminate the path prefix
if lastslash := bytes.LastIndex(name, slash); lastslash >= 0 {
name = name[lastslash+1:]
}
if period := bytes.Index(name, dot); period >= 0 {
name = name[period+1:]
}
name = bytes.Replace(name, centerDot, dot, -1)
return name
}
// Recovery returns a middleware that recovers from any panics and writes a 500 if there was one.
// While Martini is in development mode, Recovery will also output the panic as HTML.
func Recovery() Handler {
return func(c *Context, log *log.Logger) {
defer func() {
if err := recover(); err != nil {
stack := stack(3)
log.Printf("PANIC: %s\n%s", err, stack)
// Lookup the current responsewriter
val := c.GetVal(inject.InterfaceOf((*http.ResponseWriter)(nil)))
res := val.Interface().(http.ResponseWriter)
// respond with panic message while in development mode
var body []byte
if Env == DEV {
res.Header().Set("Content-Type", "text/html")
body = []byte(fmt.Sprintf(panicHtml, err, err, stack))
}
res.WriteHeader(http.StatusInternalServerError)
if nil != body {
res.Write(body)
}
}
}()
c.Next()
}
}

View File

@@ -0,0 +1,74 @@
// Copyright 2013 Martini Authors
// Copyright 2014 Unknwon
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package macaron
import (
"bytes"
"log"
"net/http"
"net/http/httptest"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func Test_Recovery(t *testing.T) {
Convey("Recovery from panic", t, func() {
buf := bytes.NewBufferString("")
setENV(DEV)
m := New()
m.Map(log.New(buf, "[Macaron] ", 0))
m.Use(func(res http.ResponseWriter, req *http.Request) {
res.Header().Set("Content-Type", "unpredictable")
})
m.Use(Recovery())
m.Use(func(res http.ResponseWriter, req *http.Request) {
panic("here is a panic!")
})
m.Get("/", func() {})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusInternalServerError)
So(resp.HeaderMap.Get("Content-Type"), ShouldEqual, "text/html")
So(buf.String(), ShouldNotBeEmpty)
})
Convey("Revocery panic to another response writer", t, func() {
resp := httptest.NewRecorder()
resp2 := httptest.NewRecorder()
setENV(DEV)
m := New()
m.Use(Recovery())
m.Use(func(c *Context) {
c.MapTo(resp2, (*http.ResponseWriter)(nil))
panic("here is a panic!")
})
m.Get("/", func() {})
req, err := http.NewRequest("GET", "/", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp2.Code, ShouldEqual, http.StatusInternalServerError)
So(resp2.HeaderMap.Get("Content-Type"), ShouldEqual, "text/html")
So(resp2.Body.Len(), ShouldBeGreaterThan, 0)
})
}

View File

@@ -0,0 +1,624 @@
// Copyright 2013 Martini Authors
// Copyright 2013 oxtoacart
// Copyright 2014 Unknwon
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package macaron
import (
"bytes"
"encoding/json"
"encoding/xml"
"fmt"
"html/template"
"io"
"io/ioutil"
"net/http"
"os"
"path"
"path/filepath"
"strings"
"sync"
"time"
"github.com/Unknwon/com"
)
// BufferPool implements a pool of bytes.Buffers in the form of a bounded channel.
type BufferPool struct {
c chan *bytes.Buffer
}
// NewBufferPool creates a new BufferPool bounded to the given size.
func NewBufferPool(size int) (bp *BufferPool) {
return &BufferPool{
c: make(chan *bytes.Buffer, size),
}
}
// Get gets a Buffer from the BufferPool, or creates a new one if none are available
// in the pool.
func (bp *BufferPool) Get() (b *bytes.Buffer) {
select {
case b = <-bp.c:
// reuse existing buffer
default:
// create new buffer
b = bytes.NewBuffer([]byte{})
}
return
}
// Put returns the given Buffer to the BufferPool.
func (bp *BufferPool) Put(b *bytes.Buffer) {
b.Reset()
bp.c <- b
}
const (
ContentType = "Content-Type"
ContentLength = "Content-Length"
ContentBinary = "application/octet-stream"
ContentJSON = "application/json"
ContentHTML = "text/html"
CONTENT_PLAIN = "text/plain"
ContentXHTML = "application/xhtml+xml"
ContentXML = "text/xml"
defaultCharset = "UTF-8"
)
var (
// Provides a temporary buffer to execute templates into and catch errors.
bufpool = NewBufferPool(64)
// Included helper functions for use when rendering html
helperFuncs = template.FuncMap{
"yield": func() (string, error) {
return "", fmt.Errorf("yield called with no layout defined")
},
"current": func() (string, error) {
return "", nil
},
}
)
type (
// TemplateFile represents a interface of template file that has name and can be read.
TemplateFile interface {
Name() string
Data() []byte
Ext() string
}
// TemplateFileSystem represents a interface of template file system that able to list all files.
TemplateFileSystem interface {
ListFiles() []TemplateFile
}
// Delims represents a set of Left and Right delimiters for HTML template rendering
Delims struct {
// Left delimiter, defaults to {{
Left string
// Right delimiter, defaults to }}
Right string
}
// RenderOptions represents a struct for specifying configuration options for the Render middleware.
RenderOptions struct {
// Directory to load templates. Default is "templates".
Directory string
// Layout template name. Will not render a layout if "". Default is to "".
Layout string
// Extensions to parse template files from. Defaults are [".tmpl", ".html"].
Extensions []string
// Funcs is a slice of FuncMaps to apply to the template upon compilation. This is useful for helper functions. Default is [].
Funcs []template.FuncMap
// Delims sets the action delimiters to the specified strings in the Delims struct.
Delims Delims
// Appends the given charset to the Content-Type header. Default is "UTF-8".
Charset string
// Outputs human readable JSON.
IndentJSON bool
// Outputs human readable XML.
IndentXML bool
// Prefixes the JSON output with the given bytes.
PrefixJSON []byte
// Prefixes the XML output with the given bytes.
PrefixXML []byte
// Allows changing of output to XHTML instead of HTML. Default is "text/html"
HTMLContentType string
// TemplateFileSystem is the interface for supporting any implmentation of template file system.
TemplateFileSystem
}
// HTMLOptions is a struct for overriding some rendering Options for specific HTML call
HTMLOptions struct {
// Layout template name. Overrides Options.Layout.
Layout string
}
Render interface {
http.ResponseWriter
RW() http.ResponseWriter
JSON(int, interface{})
JSONString(interface{}) (string, error)
RawData(int, []byte)
RenderData(int, []byte)
HTML(int, string, interface{}, ...HTMLOptions)
HTMLSet(int, string, string, interface{}, ...HTMLOptions)
HTMLSetString(string, string, interface{}, ...HTMLOptions) (string, error)
HTMLString(string, interface{}, ...HTMLOptions) (string, error)
HTMLSetBytes(string, string, interface{}, ...HTMLOptions) ([]byte, error)
HTMLBytes(string, interface{}, ...HTMLOptions) ([]byte, error)
XML(int, interface{})
Error(int, ...string)
Status(int)
SetTemplatePath(string, string)
HasTemplateSet(string) bool
}
)
// TplFile implements TemplateFile interface.
type TplFile struct {
name string
data []byte
ext string
}
// NewTplFile cerates new template file with given name and data.
func NewTplFile(name string, data []byte, ext string) *TplFile {
return &TplFile{name, data, ext}
}
func (f *TplFile) Name() string {
return f.name
}
func (f *TplFile) Data() []byte {
return f.data
}
func (f *TplFile) Ext() string {
return f.ext
}
// TplFileSystem implements TemplateFileSystem interface.
type TplFileSystem struct {
files []TemplateFile
}
// NewTemplateFileSystem creates new template file system with given options.
func NewTemplateFileSystem(opt RenderOptions, omitData bool) TplFileSystem {
fs := TplFileSystem{}
fs.files = make([]TemplateFile, 0, 10)
if err := filepath.Walk(opt.Directory, func(path string, info os.FileInfo, err error) error {
r, err := filepath.Rel(opt.Directory, path)
if err != nil {
return err
}
ext := GetExt(r)
for _, extension := range opt.Extensions {
if ext == extension {
var data []byte
if !omitData {
data, err = ioutil.ReadFile(path)
if err != nil {
return err
}
}
name := filepath.ToSlash((r[0 : len(r)-len(ext)]))
fs.files = append(fs.files, NewTplFile(name, data, ext))
break
}
}
return nil
}); err != nil {
panic("NewTemplateFileSystem: " + err.Error())
}
return fs
}
func (fs TplFileSystem) ListFiles() []TemplateFile {
return fs.files
}
func PrepareCharset(charset string) string {
if len(charset) != 0 {
return "; charset=" + charset
}
return "; charset=" + defaultCharset
}
func GetExt(s string) string {
index := strings.Index(s, ".")
if index == -1 {
return ""
}
return s[index:]
}
func compile(opt RenderOptions) *template.Template {
dir := opt.Directory
t := template.New(dir)
t.Delims(opt.Delims.Left, opt.Delims.Right)
// Parse an initial template in case we don't have any.
template.Must(t.Parse("Macaron"))
if opt.TemplateFileSystem == nil {
opt.TemplateFileSystem = NewTemplateFileSystem(opt, false)
}
for _, f := range opt.TemplateFileSystem.ListFiles() {
tmpl := t.New(f.Name())
for _, funcs := range opt.Funcs {
tmpl.Funcs(funcs)
}
// Bomb out if parse fails. We don't want any silent server starts.
template.Must(tmpl.Funcs(helperFuncs).Parse(string(f.Data())))
}
return t
}
const (
_DEFAULT_TPL_SET_NAME = "DEFAULT"
)
// templateSet represents a template set of type *template.Template.
type templateSet struct {
lock sync.RWMutex
sets map[string]*template.Template
dirs map[string]string
}
func newTemplateSet() *templateSet {
return &templateSet{
sets: make(map[string]*template.Template),
dirs: make(map[string]string),
}
}
func (ts *templateSet) Set(name string, opt *RenderOptions) *template.Template {
t := compile(*opt)
ts.lock.Lock()
defer ts.lock.Unlock()
ts.sets[name] = t
ts.dirs[name] = opt.Directory
return t
}
func (ts *templateSet) Get(name string) *template.Template {
ts.lock.RLock()
defer ts.lock.RUnlock()
return ts.sets[name]
}
func (ts *templateSet) GetDir(name string) string {
ts.lock.RLock()
defer ts.lock.RUnlock()
return ts.dirs[name]
}
func prepareOptions(options []RenderOptions) RenderOptions {
var opt RenderOptions
if len(options) > 0 {
opt = options[0]
}
// Defaults.
if len(opt.Directory) == 0 {
opt.Directory = "templates"
}
if len(opt.Extensions) == 0 {
opt.Extensions = []string{".tmpl", ".html"}
}
if len(opt.HTMLContentType) == 0 {
opt.HTMLContentType = ContentHTML
}
return opt
}
func ParseTplSet(tplSet string) (tplName string, tplDir string) {
tplSet = strings.TrimSpace(tplSet)
if len(tplSet) == 0 {
panic("empty template set argument")
}
infos := strings.Split(tplSet, ":")
if len(infos) == 1 {
tplDir = infos[0]
tplName = path.Base(tplDir)
} else {
tplName = infos[0]
tplDir = infos[1]
}
if !com.IsDir(tplDir) {
panic("template set path does not exist or is not a directory")
}
return tplName, tplDir
}
func renderHandler(opt RenderOptions, tplSets []string) Handler {
cs := PrepareCharset(opt.Charset)
ts := newTemplateSet()
ts.Set(_DEFAULT_TPL_SET_NAME, &opt)
var tmpOpt RenderOptions
for _, tplSet := range tplSets {
tplName, tplDir := ParseTplSet(tplSet)
tmpOpt = opt
tmpOpt.Directory = tplDir
ts.Set(tplName, &tmpOpt)
}
return func(ctx *Context) {
r := &TplRender{
ResponseWriter: ctx.Resp,
templateSet: ts,
Opt: &opt,
CompiledCharset: cs,
}
ctx.Data["TmplLoadTimes"] = func() string {
if r.startTime.IsZero() {
return ""
}
return fmt.Sprint(time.Since(r.startTime).Nanoseconds()/1e6) + "ms"
}
ctx.Render = r
ctx.MapTo(r, (*Render)(nil))
}
}
// Renderer is a Middleware that maps a macaron.Render service into the Macaron handler chain.
// An single variadic macaron.RenderOptions struct can be optionally provided to configure
// HTML rendering. The default directory for templates is "templates" and the default
// file extension is ".tmpl" and ".html".
//
// If MACARON_ENV is set to "" or "development" then templates will be recompiled on every request. For more performance, set the
// MACARON_ENV environment variable to "production".
func Renderer(options ...RenderOptions) Handler {
return renderHandler(prepareOptions(options), []string{})
}
func Renderers(options RenderOptions, tplSets ...string) Handler {
return renderHandler(prepareOptions([]RenderOptions{options}), tplSets)
}
type TplRender struct {
http.ResponseWriter
*templateSet
Opt *RenderOptions
CompiledCharset string
startTime time.Time
}
func (r *TplRender) RW() http.ResponseWriter {
return r.ResponseWriter
}
func (r *TplRender) JSON(status int, v interface{}) {
var (
result []byte
err error
)
if r.Opt.IndentJSON {
result, err = json.MarshalIndent(v, "", " ")
} else {
result, err = json.Marshal(v)
}
if err != nil {
http.Error(r, err.Error(), 500)
return
}
// json rendered fine, write out the result
r.Header().Set(ContentType, ContentJSON+r.CompiledCharset)
r.WriteHeader(status)
if len(r.Opt.PrefixJSON) > 0 {
r.Write(r.Opt.PrefixJSON)
}
r.Write(result)
}
func (r *TplRender) JSONString(v interface{}) (string, error) {
var result []byte
var err error
if r.Opt.IndentJSON {
result, err = json.MarshalIndent(v, "", " ")
} else {
result, err = json.Marshal(v)
}
if err != nil {
return "", err
}
return string(result), nil
}
func (r *TplRender) XML(status int, v interface{}) {
var result []byte
var err error
if r.Opt.IndentXML {
result, err = xml.MarshalIndent(v, "", " ")
} else {
result, err = xml.Marshal(v)
}
if err != nil {
http.Error(r, err.Error(), 500)
return
}
// XML rendered fine, write out the result
r.Header().Set(ContentType, ContentXML+r.CompiledCharset)
r.WriteHeader(status)
if len(r.Opt.PrefixXML) > 0 {
r.Write(r.Opt.PrefixXML)
}
r.Write(result)
}
func (r *TplRender) data(status int, contentType string, v []byte) {
if r.Header().Get(ContentType) == "" {
r.Header().Set(ContentType, contentType)
}
r.WriteHeader(status)
r.Write(v)
}
func (r *TplRender) RawData(status int, v []byte) {
r.data(status, ContentBinary, v)
}
func (r *TplRender) RenderData(status int, v []byte) {
r.data(status, CONTENT_PLAIN, v)
}
func (r *TplRender) execute(t *template.Template, name string, data interface{}) (*bytes.Buffer, error) {
buf := bufpool.Get()
return buf, t.ExecuteTemplate(buf, name, data)
}
func (r *TplRender) addYield(t *template.Template, tplName string, data interface{}) {
funcs := template.FuncMap{
"yield": func() (template.HTML, error) {
buf, err := r.execute(t, tplName, data)
// return safe html here since we are rendering our own template
return template.HTML(buf.String()), err
},
"current": func() (string, error) {
return tplName, nil
},
}
t.Funcs(funcs)
}
func (r *TplRender) renderBytes(setName, tplName string, data interface{}, htmlOpt ...HTMLOptions) (*bytes.Buffer, error) {
t := r.templateSet.Get(setName)
if Env == DEV {
opt := *r.Opt
opt.Directory = r.templateSet.GetDir(setName)
t = r.templateSet.Set(setName, &opt)
}
if t == nil {
return nil, fmt.Errorf("html/template: template \"%s\" is undefined", tplName)
}
opt := r.prepareHTMLOptions(htmlOpt)
if len(opt.Layout) > 0 {
r.addYield(t, tplName, data)
tplName = opt.Layout
}
out, err := r.execute(t, tplName, data)
if err != nil {
return nil, err
}
return out, nil
}
func (r *TplRender) renderHTML(status int, setName, tplName string, data interface{}, htmlOpt ...HTMLOptions) {
r.startTime = time.Now()
out, err := r.renderBytes(setName, tplName, data, htmlOpt...)
if err != nil {
http.Error(r, err.Error(), http.StatusInternalServerError)
return
}
r.Header().Set(ContentType, r.Opt.HTMLContentType+r.CompiledCharset)
r.WriteHeader(status)
io.Copy(r, out)
bufpool.Put(out)
}
func (r *TplRender) HTML(status int, name string, data interface{}, htmlOpt ...HTMLOptions) {
r.renderHTML(status, _DEFAULT_TPL_SET_NAME, name, data, htmlOpt...)
}
func (r *TplRender) HTMLSet(status int, setName, tplName string, data interface{}, htmlOpt ...HTMLOptions) {
r.renderHTML(status, setName, tplName, data, htmlOpt...)
}
func (r *TplRender) HTMLSetBytes(setName, tplName string, data interface{}, htmlOpt ...HTMLOptions) ([]byte, error) {
out, err := r.renderBytes(setName, tplName, data, htmlOpt...)
if err != nil {
return []byte(""), err
}
return out.Bytes(), nil
}
func (r *TplRender) HTMLBytes(name string, data interface{}, htmlOpt ...HTMLOptions) ([]byte, error) {
return r.HTMLSetBytes(_DEFAULT_TPL_SET_NAME, name, data, htmlOpt...)
}
func (r *TplRender) HTMLSetString(setName, tplName string, data interface{}, htmlOpt ...HTMLOptions) (string, error) {
p, err := r.HTMLSetBytes(setName, tplName, data, htmlOpt...)
return string(p), err
}
func (r *TplRender) HTMLString(name string, data interface{}, htmlOpt ...HTMLOptions) (string, error) {
p, err := r.HTMLBytes(name, data, htmlOpt...)
return string(p), err
}
// Error writes the given HTTP status to the current ResponseWriter
func (r *TplRender) Error(status int, message ...string) {
r.WriteHeader(status)
if len(message) > 0 {
r.Write([]byte(message[0]))
}
}
func (r *TplRender) Status(status int) {
r.WriteHeader(status)
}
func (r *TplRender) prepareHTMLOptions(htmlOpt []HTMLOptions) HTMLOptions {
if len(htmlOpt) > 0 {
return htmlOpt[0]
}
return HTMLOptions{
Layout: r.Opt.Layout,
}
}
func (r *TplRender) SetTemplatePath(setName, dir string) {
if len(setName) == 0 {
setName = _DEFAULT_TPL_SET_NAME
}
opt := *r.Opt
opt.Directory = dir
r.templateSet.Set(setName, &opt)
}
func (r *TplRender) HasTemplateSet(name string) bool {
return r.templateSet.Get(name) != nil
}

View File

@@ -0,0 +1,581 @@
// Copyright 2013 Martini Authors
// Copyright 2014 Unknwon
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package macaron
import (
"encoding/xml"
"html/template"
"net/http"
"net/http/httptest"
"testing"
"time"
. "github.com/smartystreets/goconvey/convey"
)
type Greeting struct {
One string `json:"one"`
Two string `json:"two"`
}
type GreetingXML struct {
XMLName xml.Name `xml:"greeting"`
One string `xml:"one,attr"`
Two string `xml:"two,attr"`
}
func Test_Render_JSON(t *testing.T) {
Convey("Render JSON", t, func() {
m := Classic()
m.Use(Renderer())
m.Get("/foobar", func(r Render) {
r.JSON(300, Greeting{"hello", "world"})
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/foobar", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusMultipleChoices)
So(resp.Header().Get(ContentType), ShouldEqual, ContentJSON+"; charset=UTF-8")
So(resp.Body.String(), ShouldEqual, `{"one":"hello","two":"world"}`)
})
Convey("Render JSON with prefix", t, func() {
m := Classic()
prefix := ")]}',\n"
m.Use(Renderer(RenderOptions{
PrefixJSON: []byte(prefix),
}))
m.Get("/foobar", func(r Render) {
r.JSON(300, Greeting{"hello", "world"})
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/foobar", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusMultipleChoices)
So(resp.Header().Get(ContentType), ShouldEqual, ContentJSON+"; charset=UTF-8")
So(resp.Body.String(), ShouldEqual, prefix+`{"one":"hello","two":"world"}`)
})
Convey("Render Indented JSON", t, func() {
m := Classic()
m.Use(Renderer(RenderOptions{
IndentJSON: true,
}))
m.Get("/foobar", func(r Render) {
r.JSON(300, Greeting{"hello", "world"})
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/foobar", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusMultipleChoices)
So(resp.Header().Get(ContentType), ShouldEqual, ContentJSON+"; charset=UTF-8")
So(resp.Body.String(), ShouldEqual, `{
"one": "hello",
"two": "world"
}`)
})
Convey("Render JSON and return string", t, func() {
m := Classic()
m.Use(Renderer())
m.Get("/foobar", func(r Render) {
result, err := r.JSONString(Greeting{"hello", "world"})
So(err, ShouldBeNil)
So(result, ShouldEqual, `{"one":"hello","two":"world"}`)
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/foobar", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
})
Convey("Render with charset JSON", t, func() {
m := Classic()
m.Use(Renderer(RenderOptions{
Charset: "foobar",
}))
m.Get("/foobar", func(r Render) {
r.JSON(300, Greeting{"hello", "world"})
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/foobar", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusMultipleChoices)
So(resp.Header().Get(ContentType), ShouldEqual, ContentJSON+"; charset=foobar")
So(resp.Body.String(), ShouldEqual, `{"one":"hello","two":"world"}`)
})
}
func Test_Render_XML(t *testing.T) {
Convey("Render XML", t, func() {
m := Classic()
m.Use(Renderer())
m.Get("/foobar", func(r Render) {
r.XML(300, GreetingXML{One: "hello", Two: "world"})
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/foobar", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusMultipleChoices)
So(resp.Header().Get(ContentType), ShouldEqual, ContentXML+"; charset=UTF-8")
So(resp.Body.String(), ShouldEqual, `<greeting one="hello" two="world"></greeting>`)
})
Convey("Render XML with prefix", t, func() {
m := Classic()
prefix := ")]}',\n"
m.Use(Renderer(RenderOptions{
PrefixXML: []byte(prefix),
}))
m.Get("/foobar", func(r Render) {
r.XML(300, GreetingXML{One: "hello", Two: "world"})
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/foobar", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusMultipleChoices)
So(resp.Header().Get(ContentType), ShouldEqual, ContentXML+"; charset=UTF-8")
So(resp.Body.String(), ShouldEqual, prefix+`<greeting one="hello" two="world"></greeting>`)
})
Convey("Render Indented XML", t, func() {
m := Classic()
m.Use(Renderer(RenderOptions{
IndentXML: true,
}))
m.Get("/foobar", func(r Render) {
r.XML(300, GreetingXML{One: "hello", Two: "world"})
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/foobar", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusMultipleChoices)
So(resp.Header().Get(ContentType), ShouldEqual, ContentXML+"; charset=UTF-8")
So(resp.Body.String(), ShouldEqual, `<greeting one="hello" two="world"></greeting>`)
})
}
func Test_Render_HTML(t *testing.T) {
Convey("Render HTML", t, func() {
m := Classic()
m.Use(Renderers(RenderOptions{
Directory: "fixtures/basic",
}, "fixtures/basic2"))
m.Get("/foobar", func(r Render) {
r.HTML(200, "hello", "jeremy")
r.SetTemplatePath("", "fixtures/basic2")
})
m.Get("/foobar2", func(r Render) {
if r.HasTemplateSet("basic2") {
r.HTMLSet(200, "basic2", "hello", "jeremy")
}
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/foobar", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusOK)
So(resp.Header().Get(ContentType), ShouldEqual, ContentHTML+"; charset=UTF-8")
So(resp.Body.String(), ShouldEqual, "<h1>Hello jeremy</h1>")
resp = httptest.NewRecorder()
req, err = http.NewRequest("GET", "/foobar2", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusOK)
So(resp.Header().Get(ContentType), ShouldEqual, ContentHTML+"; charset=UTF-8")
So(resp.Body.String(), ShouldEqual, "<h1>What's up, jeremy</h1>")
Convey("Change render templates path", func() {
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/foobar", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusOK)
So(resp.Header().Get(ContentType), ShouldEqual, ContentHTML+"; charset=UTF-8")
So(resp.Body.String(), ShouldEqual, "<h1>What's up, jeremy</h1>")
})
})
Convey("Render HTML and return string", t, func() {
m := Classic()
m.Use(Renderers(RenderOptions{
Directory: "fixtures/basic",
}, "basic2:fixtures/basic2"))
m.Get("/foobar", func(r Render) {
result, err := r.HTMLString("hello", "jeremy")
So(err, ShouldBeNil)
So(result, ShouldEqual, "<h1>Hello jeremy</h1>")
})
m.Get("/foobar2", func(r Render) {
result, err := r.HTMLSetString("basic2", "hello", "jeremy")
So(err, ShouldBeNil)
So(result, ShouldEqual, "<h1>What's up, jeremy</h1>")
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/foobar", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
resp = httptest.NewRecorder()
req, err = http.NewRequest("GET", "/foobar2", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
})
Convey("Render with nested HTML", t, func() {
m := Classic()
m.Use(Renderer(RenderOptions{
Directory: "fixtures/basic",
}))
m.Get("/foobar", func(r Render) {
r.HTML(200, "admin/index", "jeremy")
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/foobar", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusOK)
So(resp.Header().Get(ContentType), ShouldEqual, ContentHTML+"; charset=UTF-8")
So(resp.Body.String(), ShouldEqual, "<h1>Admin jeremy</h1>")
})
Convey("Render bad HTML", t, func() {
m := Classic()
m.Use(Renderer(RenderOptions{
Directory: "fixtures/basic",
}))
m.Get("/foobar", func(r Render) {
r.HTML(200, "nope", nil)
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/foobar", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusInternalServerError)
So(resp.Body.String(), ShouldEqual, "html/template: \"nope\" is undefined\n")
})
Convey("Invalid template set", t, func() {
Convey("Empty template set argument", func() {
defer func() {
So(recover(), ShouldNotBeNil)
}()
m := Classic()
m.Use(Renderers(RenderOptions{
Directory: "fixtures/basic",
}, ""))
})
Convey("Bad template set path", func() {
defer func() {
So(recover(), ShouldNotBeNil)
}()
m := Classic()
m.Use(Renderers(RenderOptions{
Directory: "fixtures/basic",
}, "404"))
})
})
}
func Test_Render_XHTML(t *testing.T) {
Convey("Render XHTML", t, func() {
m := Classic()
m.Use(Renderer(RenderOptions{
Directory: "fixtures/basic",
HTMLContentType: ContentXHTML,
}))
m.Get("/foobar", func(r Render) {
r.HTML(200, "hello", "jeremy")
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/foobar", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusOK)
So(resp.Header().Get(ContentType), ShouldEqual, ContentXHTML+"; charset=UTF-8")
So(resp.Body.String(), ShouldEqual, "<h1>Hello jeremy</h1>")
})
}
func Test_Render_Extensions(t *testing.T) {
Convey("Render with extensions", t, func() {
m := Classic()
m.Use(Renderer(RenderOptions{
Directory: "fixtures/basic",
Extensions: []string{".tmpl", ".html"},
}))
m.Get("/foobar", func(r Render) {
r.HTML(200, "hypertext", nil)
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/foobar", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusOK)
So(resp.Header().Get(ContentType), ShouldEqual, ContentHTML+"; charset=UTF-8")
So(resp.Body.String(), ShouldEqual, "Hypertext!")
})
}
func Test_Render_Funcs(t *testing.T) {
Convey("Render with functions", t, func() {
m := Classic()
m.Use(Renderer(RenderOptions{
Directory: "fixtures/custom_funcs",
Funcs: []template.FuncMap{
{
"myCustomFunc": func() string {
return "My custom function"
},
},
},
}))
m.Get("/foobar", func(r Render) {
r.HTML(200, "index", "jeremy")
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/foobar", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "My custom function")
})
}
func Test_Render_Layout(t *testing.T) {
Convey("Render with layout", t, func() {
m := Classic()
m.Use(Renderer(RenderOptions{
Directory: "fixtures/basic",
Layout: "layout",
}))
m.Get("/foobar", func(r Render) {
r.HTML(200, "content", "jeremy")
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/foobar", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "head<h1>jeremy</h1>foot")
})
Convey("Render with current layout", t, func() {
m := Classic()
m.Use(Renderer(RenderOptions{
Directory: "fixtures/basic",
Layout: "current_layout",
}))
m.Get("/foobar", func(r Render) {
r.HTML(200, "content", "jeremy")
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/foobar", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "content head<h1>jeremy</h1>content foot")
})
Convey("Render with override layout", t, func() {
m := Classic()
m.Use(Renderer(RenderOptions{
Directory: "fixtures/basic",
Layout: "layout",
}))
m.Get("/foobar", func(r Render) {
r.HTML(200, "content", "jeremy", HTMLOptions{
Layout: "another_layout",
})
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/foobar", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusOK)
So(resp.Header().Get(ContentType), ShouldEqual, ContentHTML+"; charset=UTF-8")
So(resp.Body.String(), ShouldEqual, "another head<h1>jeremy</h1>another foot")
})
}
func Test_Render_Delimiters(t *testing.T) {
Convey("Render with delimiters", t, func() {
m := Classic()
m.Use(Renderer(RenderOptions{
Delims: Delims{"{[{", "}]}"},
Directory: "fixtures/basic",
}))
m.Get("/foobar", func(r Render) {
r.HTML(200, "delims", "jeremy")
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/foobar", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusOK)
So(resp.Header().Get(ContentType), ShouldEqual, ContentHTML+"; charset=UTF-8")
So(resp.Body.String(), ShouldEqual, "<h1>Hello jeremy</h1>")
})
}
func Test_Render_BinaryData(t *testing.T) {
Convey("Render binary data", t, func() {
m := Classic()
m.Use(Renderer())
m.Get("/foobar", func(r Render) {
r.RawData(200, []byte("hello there"))
})
m.Get("/foobar2", func(r Render) {
r.RenderData(200, []byte("hello there"))
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/foobar", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusOK)
So(resp.Header().Get(ContentType), ShouldEqual, ContentBinary)
So(resp.Body.String(), ShouldEqual, "hello there")
resp = httptest.NewRecorder()
req, err = http.NewRequest("GET", "/foobar2", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusOK)
So(resp.Header().Get(ContentType), ShouldEqual, CONTENT_PLAIN)
So(resp.Body.String(), ShouldEqual, "hello there")
})
Convey("Render binary data with mime type", t, func() {
m := Classic()
m.Use(Renderer())
m.Get("/foobar", func(r Render) {
r.RW().Header().Set(ContentType, "image/jpeg")
r.RawData(200, []byte("..jpeg data.."))
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/foobar", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusOK)
So(resp.Header().Get(ContentType), ShouldEqual, "image/jpeg")
So(resp.Body.String(), ShouldEqual, "..jpeg data..")
})
}
func Test_Render_Status(t *testing.T) {
Convey("Render with status 204", t, func() {
resp := httptest.NewRecorder()
r := TplRender{resp, newTemplateSet(), &RenderOptions{}, "", time.Now()}
r.Status(204)
So(resp.Code, ShouldEqual, http.StatusNoContent)
})
Convey("Render with status 404", t, func() {
resp := httptest.NewRecorder()
r := TplRender{resp, newTemplateSet(), &RenderOptions{}, "", time.Now()}
r.Error(404)
So(resp.Code, ShouldEqual, http.StatusNotFound)
})
Convey("Render with status 500", t, func() {
resp := httptest.NewRecorder()
r := TplRender{resp, newTemplateSet(), &RenderOptions{}, "", time.Now()}
r.Error(500)
So(resp.Code, ShouldEqual, http.StatusInternalServerError)
})
}
func Test_Render_NoRace(t *testing.T) {
Convey("Make sure render has no race", t, func() {
m := Classic()
m.Use(Renderer(RenderOptions{
Directory: "fixtures/basic",
}))
m.Get("/foobar", func(r Render) {
r.HTML(200, "hello", "world")
})
done := make(chan bool)
doreq := func() {
resp := httptest.NewRecorder()
req, _ := http.NewRequest("GET", "/foobar", nil)
m.ServeHTTP(resp, req)
done <- true
}
// Run two requests to check there is no race condition
go doreq()
go doreq()
<-done
<-done
})
}
func Test_GetExt(t *testing.T) {
Convey("Get extension", t, func() {
So(GetExt("test"), ShouldBeBlank)
So(GetExt("test.tmpl"), ShouldEqual, ".tmpl")
So(GetExt("test.go.tmpl"), ShouldEqual, ".go.tmpl")
})
}

View File

@@ -0,0 +1,111 @@
// Copyright 2013 Martini Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package macaron
import (
"bufio"
"fmt"
"net"
"net/http"
)
// ResponseWriter is a wrapper around http.ResponseWriter that provides extra information about
// the response. It is recommended that middleware handlers use this construct to wrap a responsewriter
// if the functionality calls for it.
type ResponseWriter interface {
http.ResponseWriter
http.Flusher
// Status returns the status code of the response or 0 if the response has not been written.
Status() int
// Written returns whether or not the ResponseWriter has been written.
Written() bool
// Size returns the size of the response body.
Size() int
// Before allows for a function to be called before the ResponseWriter has been written to. This is
// useful for setting headers or any other operations that must happen before a response has been written.
Before(BeforeFunc)
}
// BeforeFunc is a function that is called before the ResponseWriter has been written to.
type BeforeFunc func(ResponseWriter)
// NewResponseWriter creates a ResponseWriter that wraps an http.ResponseWriter
func NewResponseWriter(rw http.ResponseWriter) ResponseWriter {
return &responseWriter{rw, 0, 0, nil}
}
type responseWriter struct {
http.ResponseWriter
status int
size int
beforeFuncs []BeforeFunc
}
func (rw *responseWriter) WriteHeader(s int) {
rw.callBefore()
rw.ResponseWriter.WriteHeader(s)
rw.status = s
}
func (rw *responseWriter) Write(b []byte) (int, error) {
if !rw.Written() {
// The status will be StatusOK if WriteHeader has not been called yet
rw.WriteHeader(http.StatusOK)
}
size, err := rw.ResponseWriter.Write(b)
rw.size += size
return size, err
}
func (rw *responseWriter) Status() int {
return rw.status
}
func (rw *responseWriter) Size() int {
return rw.size
}
func (rw *responseWriter) Written() bool {
return rw.status != 0
}
func (rw *responseWriter) Before(before BeforeFunc) {
rw.beforeFuncs = append(rw.beforeFuncs, before)
}
func (rw *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
hijacker, ok := rw.ResponseWriter.(http.Hijacker)
if !ok {
return nil, nil, fmt.Errorf("the ResponseWriter doesn't support the Hijacker interface")
}
return hijacker.Hijack()
}
func (rw *responseWriter) CloseNotify() <-chan bool {
return rw.ResponseWriter.(http.CloseNotifier).CloseNotify()
}
func (rw *responseWriter) callBefore() {
for i := len(rw.beforeFuncs) - 1; i >= 0; i-- {
rw.beforeFuncs[i](rw)
}
}
func (rw *responseWriter) Flush() {
flusher, ok := rw.ResponseWriter.(http.Flusher)
if ok {
flusher.Flush()
}
}

View File

@@ -0,0 +1,188 @@
// Copyright 2013 Martini Authors
// Copyright 2014 Unknwon
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package macaron
import (
"bufio"
"io"
"net"
"net/http"
"net/http/httptest"
"testing"
"time"
. "github.com/smartystreets/goconvey/convey"
)
type closeNotifyingRecorder struct {
*httptest.ResponseRecorder
closed chan bool
}
func newCloseNotifyingRecorder() *closeNotifyingRecorder {
return &closeNotifyingRecorder{
httptest.NewRecorder(),
make(chan bool, 1),
}
}
func (c *closeNotifyingRecorder) close() {
c.closed <- true
}
func (c *closeNotifyingRecorder) CloseNotify() <-chan bool {
return c.closed
}
type hijackableResponse struct {
Hijacked bool
}
func newHijackableResponse() *hijackableResponse {
return &hijackableResponse{}
}
func (h *hijackableResponse) Header() http.Header { return nil }
func (h *hijackableResponse) Write(buf []byte) (int, error) { return 0, nil }
func (h *hijackableResponse) WriteHeader(code int) {}
func (h *hijackableResponse) Flush() {}
func (h *hijackableResponse) Hijack() (net.Conn, *bufio.ReadWriter, error) {
h.Hijacked = true
return nil, nil, nil
}
func Test_ResponseWriter(t *testing.T) {
Convey("Write string to response writer", t, func() {
resp := httptest.NewRecorder()
rw := NewResponseWriter(resp)
rw.Write([]byte("Hello world"))
So(resp.Code, ShouldEqual, rw.Status())
So(resp.Body.String(), ShouldEqual, "Hello world")
So(rw.Status(), ShouldEqual, http.StatusOK)
So(rw.Size(), ShouldEqual, 11)
So(rw.Written(), ShouldBeTrue)
})
Convey("Write strings to response writer", t, func() {
resp := httptest.NewRecorder()
rw := NewResponseWriter(resp)
rw.Write([]byte("Hello world"))
rw.Write([]byte("foo bar bat baz"))
So(resp.Code, ShouldEqual, rw.Status())
So(resp.Body.String(), ShouldEqual, "Hello worldfoo bar bat baz")
So(rw.Status(), ShouldEqual, http.StatusOK)
So(rw.Size(), ShouldEqual, 26)
So(rw.Written(), ShouldBeTrue)
})
Convey("Write header to response writer", t, func() {
resp := httptest.NewRecorder()
rw := NewResponseWriter(resp)
rw.WriteHeader(http.StatusNotFound)
So(resp.Code, ShouldEqual, rw.Status())
So(resp.Body.String(), ShouldBeBlank)
So(rw.Status(), ShouldEqual, http.StatusNotFound)
So(rw.Size(), ShouldEqual, 0)
})
Convey("Write before response write", t, func() {
result := ""
resp := httptest.NewRecorder()
rw := NewResponseWriter(resp)
rw.Before(func(ResponseWriter) {
result += "foo"
})
rw.Before(func(ResponseWriter) {
result += "bar"
})
rw.WriteHeader(http.StatusNotFound)
So(resp.Code, ShouldEqual, rw.Status())
So(resp.Body.String(), ShouldBeBlank)
So(rw.Status(), ShouldEqual, http.StatusNotFound)
So(rw.Size(), ShouldEqual, 0)
So(result, ShouldEqual, "barfoo")
})
Convey("Response writer with Hijack", t, func() {
hijackable := newHijackableResponse()
rw := NewResponseWriter(hijackable)
hijacker, ok := rw.(http.Hijacker)
So(ok, ShouldBeTrue)
_, _, err := hijacker.Hijack()
So(err, ShouldBeNil)
So(hijackable.Hijacked, ShouldBeTrue)
})
Convey("Response writer with bad Hijack", t, func() {
hijackable := new(http.ResponseWriter)
rw := NewResponseWriter(*hijackable)
hijacker, ok := rw.(http.Hijacker)
So(ok, ShouldBeTrue)
_, _, err := hijacker.Hijack()
So(err, ShouldNotBeNil)
})
Convey("Response writer with close notify", t, func() {
resp := newCloseNotifyingRecorder()
rw := NewResponseWriter(resp)
closed := false
notifier := rw.(http.CloseNotifier).CloseNotify()
resp.close()
select {
case <-notifier:
closed = true
case <-time.After(time.Second):
}
So(closed, ShouldBeTrue)
})
Convey("Response writer with flusher", t, func() {
resp := httptest.NewRecorder()
rw := NewResponseWriter(resp)
_, ok := rw.(http.Flusher)
So(ok, ShouldBeTrue)
})
Convey("Response writer with flusher handler", t, func() {
m := Classic()
m.Get("/events", func(w http.ResponseWriter, r *http.Request) {
f, ok := w.(http.Flusher)
So(ok, ShouldBeTrue)
w.Header().Set("Content-Type", "text/event-stream")
w.Header().Set("Cache-Control", "no-cache")
w.Header().Set("Connection", "keep-alive")
for i := 0; i < 2; i++ {
time.Sleep(10 * time.Millisecond)
io.WriteString(w, "data: Hello\n\n")
f.Flush()
}
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/events", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusOK)
So(resp.Body.String(), ShouldEqual, "data: Hello\n\ndata: Hello\n\n")
})
}

View File

@@ -0,0 +1,59 @@
// Copyright 2013 Martini Authors
// Copyright 2014 Unknwon
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package macaron
import (
"net/http"
"reflect"
"github.com/Unknwon/macaron/inject"
)
// ReturnHandler is a service that Martini provides that is called
// when a route handler returns something. The ReturnHandler is
// responsible for writing to the ResponseWriter based on the values
// that are passed into this function.
type ReturnHandler func(*Context, []reflect.Value)
func canDeref(val reflect.Value) bool {
return val.Kind() == reflect.Interface || val.Kind() == reflect.Ptr
}
func isByteSlice(val reflect.Value) bool {
return val.Kind() == reflect.Slice && val.Type().Elem().Kind() == reflect.Uint8
}
func defaultReturnHandler() ReturnHandler {
return func(ctx *Context, vals []reflect.Value) {
rv := ctx.GetVal(inject.InterfaceOf((*http.ResponseWriter)(nil)))
res := rv.Interface().(http.ResponseWriter)
var respVal reflect.Value
if len(vals) > 1 && vals[0].Kind() == reflect.Int {
res.WriteHeader(int(vals[0].Int()))
respVal = vals[1]
} else if len(vals) > 0 {
respVal = vals[0]
}
if canDeref(respVal) {
respVal = respVal.Elem()
}
if isByteSlice(respVal) {
res.Write(respVal.Bytes())
} else {
res.Write([]byte(respVal.String()))
}
}
}

View File

@@ -0,0 +1,69 @@
// Copyright 2014 Unknwon
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package macaron
import (
"net/http"
"net/http/httptest"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func Test_Return_Handler(t *testing.T) {
Convey("Return with status and body", t, func() {
m := Classic()
m.Get("/", func() (int, string) {
return 418, "i'm a teapot"
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusTeapot)
So(resp.Body.String(), ShouldEqual, "i'm a teapot")
})
Convey("Return with pointer", t, func() {
m := Classic()
m.Get("/", func() *string {
str := "hello world"
return &str
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "hello world")
})
Convey("Return with byte slice", t, func() {
m := Classic()
m.Get("/", func() []byte {
return []byte("hello world")
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "hello world")
})
}

View File

@@ -0,0 +1,300 @@
// Copyright 2014 Unknwon
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package macaron
import (
"net/http"
"strings"
"sync"
"github.com/Unknwon/com"
)
var (
// Known HTTP methods.
_HTTP_METHODS = map[string]bool{
"GET": true,
"POST": true,
"PUT": true,
"DELETE": true,
"PATCH": true,
"OPTIONS": true,
"HEAD": true,
}
)
// routeMap represents a thread-safe map for route tree.
type routeMap struct {
lock sync.RWMutex
routes map[string]map[string]bool
}
// NewRouteMap initializes and returns a new routeMap.
func NewRouteMap() *routeMap {
rm := &routeMap{
routes: make(map[string]map[string]bool),
}
for m := range _HTTP_METHODS {
rm.routes[m] = make(map[string]bool)
}
return rm
}
// isExist returns true if a route has been registered.
func (rm *routeMap) isExist(method, pattern string) bool {
rm.lock.RLock()
defer rm.lock.RUnlock()
return rm.routes[method][pattern]
}
// add adds new route to route tree map.
func (rm *routeMap) add(method, pattern string) {
rm.lock.Lock()
defer rm.lock.Unlock()
rm.routes[method][pattern] = true
}
type group struct {
pattern string
handlers []Handler
}
// Router represents a Macaron router layer.
type Router struct {
m *Macaron
routers map[string]*Tree
*routeMap
groups []group
notFound http.HandlerFunc
}
func NewRouter() *Router {
return &Router{
routers: make(map[string]*Tree),
routeMap: NewRouteMap(),
}
}
type Params map[string]string
// Handle is a function that can be registered to a route to handle HTTP requests.
// Like http.HandlerFunc, but has a third parameter for the values of wildcards (variables).
type Handle func(http.ResponseWriter, *http.Request, Params)
// handle adds new route to the router tree.
func (r *Router) handle(method, pattern string, handle Handle) {
method = strings.ToUpper(method)
// Prevent duplicate routes.
if r.isExist(method, pattern) {
return
}
// Validate HTTP methods.
if !_HTTP_METHODS[method] && method != "*" {
panic("unknown HTTP method: " + method)
}
// Generate methods need register.
methods := make(map[string]bool)
if method == "*" {
for m := range _HTTP_METHODS {
methods[m] = true
}
} else {
methods[method] = true
}
// Add to router tree.
for m := range methods {
if t, ok := r.routers[m]; ok {
t.AddRouter(pattern, handle)
} else {
t := NewTree()
t.AddRouter(pattern, handle)
r.routers[m] = t
}
r.add(m, pattern)
}
}
// Handle registers a new request handle with the given pattern, method and handlers.
func (r *Router) Handle(method string, pattern string, handlers []Handler) {
if len(r.groups) > 0 {
groupPattern := ""
h := make([]Handler, 0)
for _, g := range r.groups {
groupPattern += g.pattern
h = append(h, g.handlers...)
}
pattern = groupPattern + pattern
h = append(h, handlers...)
handlers = h
}
validateHandlers(handlers)
r.handle(method, pattern, func(resp http.ResponseWriter, req *http.Request, params Params) {
c := r.m.createContext(resp, req)
c.params = params
c.handlers = make([]Handler, 0, len(r.m.handlers)+len(handlers))
c.handlers = append(c.handlers, r.m.handlers...)
c.handlers = append(c.handlers, handlers...)
c.run()
})
}
func (r *Router) Group(pattern string, fn func(), h ...Handler) {
r.groups = append(r.groups, group{pattern, h})
fn()
r.groups = r.groups[:len(r.groups)-1]
}
// Get is a shortcut for r.Handle("GET", pattern, handlers)
func (r *Router) Get(pattern string, h ...Handler) {
r.Handle("GET", pattern, h)
}
// Patch is a shortcut for r.Handle("PATCH", pattern, handlers)
func (r *Router) Patch(pattern string, h ...Handler) {
r.Handle("PATCH", pattern, h)
}
// Post is a shortcut for r.Handle("POST", pattern, handlers)
func (r *Router) Post(pattern string, h ...Handler) {
r.Handle("POST", pattern, h)
}
// Put is a shortcut for r.Handle("PUT", pattern, handlers)
func (r *Router) Put(pattern string, h ...Handler) {
r.Handle("PUT", pattern, h)
}
// Delete is a shortcut for r.Handle("DELETE", pattern, handlers)
func (r *Router) Delete(pattern string, h ...Handler) {
r.Handle("DELETE", pattern, h)
}
// Options is a shortcut for r.Handle("OPTIONS", pattern, handlers)
func (r *Router) Options(pattern string, h ...Handler) {
r.Handle("OPTIONS", pattern, h)
}
// Head is a shortcut for r.Handle("HEAD", pattern, handlers)
func (r *Router) Head(pattern string, h ...Handler) {
r.Handle("HEAD", pattern, h)
}
// Any is a shortcut for r.Handle("*", pattern, handlers)
func (r *Router) Any(pattern string, h ...Handler) {
r.Handle("*", pattern, h)
}
// Route is a shortcut for same handlers but different HTTP methods.
//
// Example:
// m.Route("/", "GET,POST", h)
func (r *Router) Route(pattern, methods string, h ...Handler) {
for _, m := range strings.Split(methods, ",") {
r.Handle(strings.TrimSpace(m), pattern, h)
}
}
// Combo returns a combo router.
func (r *Router) Combo(pattern string, h ...Handler) *ComboRouter {
return &ComboRouter{r, pattern, h, map[string]bool{}}
}
// Configurable http.HandlerFunc which is called when no matching route is
// found. If it is not set, http.NotFound is used.
// Be sure to set 404 response code in your handler.
func (r *Router) NotFound(handlers ...Handler) {
r.notFound = func(rw http.ResponseWriter, req *http.Request) {
c := r.m.createContext(rw, req)
c.handlers = append(r.m.handlers, handlers...)
c.run()
}
}
func (r *Router) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
if t, ok := r.routers[req.Method]; ok {
h, p := t.Match(req.URL.Path)
if h != nil {
if splat, ok := p[":splat"]; ok {
p["*"] = p[":splat"] // Better name.
splatlist := strings.Split(splat, "/")
for k, v := range splatlist {
p[com.ToStr(k)] = v
}
}
h(rw, req, p)
return
}
}
r.notFound(rw, req)
}
// ComboRouter represents a combo router.
type ComboRouter struct {
router *Router
pattern string
handlers []Handler
methods map[string]bool // Registered methods.
}
func (cr *ComboRouter) checkMethod(name string) {
if cr.methods[name] {
panic("method '" + name + "' has already been registered")
}
cr.methods[name] = true
}
func (cr *ComboRouter) route(fn func(string, ...Handler), method string, h ...Handler) *ComboRouter {
cr.checkMethod(method)
fn(cr.pattern, append(cr.handlers, h...)...)
return cr
}
func (cr *ComboRouter) Get(h ...Handler) *ComboRouter {
return cr.route(cr.router.Get, "GET", h...)
}
func (cr *ComboRouter) Patch(h ...Handler) *ComboRouter {
return cr.route(cr.router.Patch, "PATCH", h...)
}
func (cr *ComboRouter) Post(h ...Handler) *ComboRouter {
return cr.route(cr.router.Post, "POST", h...)
}
func (cr *ComboRouter) Put(h ...Handler) *ComboRouter {
return cr.route(cr.router.Put, "PUT", h...)
}
func (cr *ComboRouter) Delete(h ...Handler) *ComboRouter {
return cr.route(cr.router.Delete, "DELETE", h...)
}
func (cr *ComboRouter) Options(h ...Handler) *ComboRouter {
return cr.route(cr.router.Options, "OPTIONS", h...)
}
func (cr *ComboRouter) Head(h ...Handler) *ComboRouter {
return cr.route(cr.router.Head, "HEAD", h...)
}

View File

@@ -0,0 +1,199 @@
// Copyright 2014 Unknwon
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package macaron
import (
"net/http"
"net/http/httptest"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func Test_Router_Handle(t *testing.T) {
Convey("Register all HTTP methods routes", t, func() {
m := Classic()
m.Get("/get", func() string {
return "GET"
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/get", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "GET")
m.Patch("/patch", func() string {
return "PATCH"
})
resp = httptest.NewRecorder()
req, err = http.NewRequest("PATCH", "/patch", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "PATCH")
m.Post("/post", func() string {
return "POST"
})
resp = httptest.NewRecorder()
req, err = http.NewRequest("POST", "/post", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "POST")
m.Put("/put", func() string {
return "PUT"
})
resp = httptest.NewRecorder()
req, err = http.NewRequest("PUT", "/put", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "PUT")
m.Delete("/delete", func() string {
return "DELETE"
})
resp = httptest.NewRecorder()
req, err = http.NewRequest("DELETE", "/delete", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "DELETE")
m.Options("/options", func() string {
return "OPTIONS"
})
resp = httptest.NewRecorder()
req, err = http.NewRequest("OPTIONS", "/options", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "OPTIONS")
m.Head("/head", func() string {
return "HEAD"
})
resp = httptest.NewRecorder()
req, err = http.NewRequest("HEAD", "/head", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "HEAD")
m.Any("/any", func() string {
return "ANY"
})
resp = httptest.NewRecorder()
req, err = http.NewRequest("GET", "/any", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "ANY")
m.Route("/route", "GET,POST", func() string {
return "ROUTE"
})
resp = httptest.NewRecorder()
req, err = http.NewRequest("POST", "/route", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "ROUTE")
})
Convey("Register all HTTP methods routes with combo", t, func() {
m := Classic()
m.SetURLPrefix("/prefix")
m.Use(Renderer())
m.Combo("/", func(ctx *Context) {
ctx.Data["prefix"] = "Prefix_"
}).
Get(func(ctx *Context) string { return ctx.Data["prefix"].(string) + "GET" }).
Patch(func(ctx *Context) string { return ctx.Data["prefix"].(string) + "PATCH" }).
Post(func(ctx *Context) string { return ctx.Data["prefix"].(string) + "POST" }).
Put(func(ctx *Context) string { return ctx.Data["prefix"].(string) + "PUT" }).
Delete(func(ctx *Context) string { return ctx.Data["prefix"].(string) + "DELETE" }).
Options(func(ctx *Context) string { return ctx.Data["prefix"].(string) + "OPTIONS" }).
Head(func(ctx *Context) string { return ctx.Data["prefix"].(string) + "HEAD" })
for name := range _HTTP_METHODS {
resp := httptest.NewRecorder()
req, err := http.NewRequest(name, "/", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "Prefix_"+name)
}
defer func() {
So(recover(), ShouldNotBeNil)
}()
m.Combo("/").Get(func() {}).Get(nil)
})
Convey("Register duplicated routes", t, func() {
r := NewRouter()
r.Get("/")
r.Get("/")
})
Convey("Register invalid HTTP method", t, func() {
defer func() {
So(recover(), ShouldNotBeNil)
}()
r := NewRouter()
r.Handle("404", "/", nil)
})
}
func Test_Router_Group(t *testing.T) {
Convey("Register route group", t, func() {
m := Classic()
m.Group("/api", func() {
m.Group("/v1", func() {
m.Get("/list", func() string {
return "Well done!"
})
})
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/api/v1/list", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "Well done!")
})
}
func Test_Router_NotFound(t *testing.T) {
Convey("Custom not found handler", t, func() {
m := Classic()
m.Get("/", func() {})
m.NotFound(func() string {
return "Custom not found"
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/404", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "Custom not found")
})
}
func Test_Router_splat(t *testing.T) {
Convey("Register router with glob", t, func() {
m := Classic()
m.Get("/*", func(ctx *Context) string {
return ctx.Params("*")
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/hahaha", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Body.String(), ShouldEqual, "hahaha")
})
}

View File

@@ -0,0 +1,205 @@
// Copyright 2013 Martini Authors
// Copyright 2014 Unknwon
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package macaron
import (
"log"
"net/http"
"path"
"path/filepath"
"strings"
"sync"
)
// StaticOptions is a struct for specifying configuration options for the macaron.Static middleware.
type StaticOptions struct {
// Prefix is the optional prefix used to serve the static directory content
Prefix string
// SkipLogging will disable [Static] log messages when a static file is served.
SkipLogging bool
// IndexFile defines which file to serve as index if it exists.
IndexFile string
// Expires defines which user-defined function to use for producing a HTTP Expires Header
// https://developers.google.com/speed/docs/insights/LeverageBrowserCaching
Expires func() string
// FileSystem is the interface for supporting any implmentation of file system.
FileSystem http.FileSystem
}
// FIXME: to be deleted.
type staticMap struct {
lock sync.RWMutex
data map[string]*http.Dir
}
func (sm *staticMap) Set(dir *http.Dir) {
sm.lock.Lock()
defer sm.lock.Unlock()
sm.data[string(*dir)] = dir
}
func (sm *staticMap) Get(name string) *http.Dir {
sm.lock.RLock()
defer sm.lock.RUnlock()
return sm.data[name]
}
func (sm *staticMap) Delete(name string) {
sm.lock.Lock()
defer sm.lock.Unlock()
delete(sm.data, name)
}
var statics = staticMap{sync.RWMutex{}, map[string]*http.Dir{}}
// staticFileSystem implements http.FileSystem interface.
type staticFileSystem struct {
dir *http.Dir
}
func newStaticFileSystem(directory string) staticFileSystem {
if !filepath.IsAbs(directory) {
directory = filepath.Join(Root, directory)
}
dir := http.Dir(directory)
statics.Set(&dir)
return staticFileSystem{&dir}
}
func (fs staticFileSystem) Open(name string) (http.File, error) {
return fs.dir.Open(name)
}
func prepareStaticOption(dir string, opt StaticOptions) StaticOptions {
// Defaults
if len(opt.IndexFile) == 0 {
opt.IndexFile = "index.html"
}
// Normalize the prefix if provided
if opt.Prefix != "" {
// Ensure we have a leading '/'
if opt.Prefix[0] != '/' {
opt.Prefix = "/" + opt.Prefix
}
// Remove any trailing '/'
opt.Prefix = strings.TrimRight(opt.Prefix, "/")
}
if opt.FileSystem == nil {
opt.FileSystem = newStaticFileSystem(dir)
}
return opt
}
func prepareStaticOptions(dir string, options []StaticOptions) StaticOptions {
var opt StaticOptions
if len(options) > 0 {
opt = options[0]
}
return prepareStaticOption(dir, opt)
}
func staticHandler(ctx *Context, log *log.Logger, opt StaticOptions) bool {
if ctx.Req.Method != "GET" && ctx.Req.Method != "HEAD" {
return false
}
file := ctx.Req.URL.Path
// if we have a prefix, filter requests by stripping the prefix
if opt.Prefix != "" {
if !strings.HasPrefix(file, opt.Prefix) {
return false
}
file = file[len(opt.Prefix):]
if file != "" && file[0] != '/' {
return false
}
}
f, err := opt.FileSystem.Open(file)
if err != nil {
return false
}
defer f.Close()
fi, err := f.Stat()
if err != nil {
return true // File exists but fail to open.
}
// Try to serve index file
if fi.IsDir() {
// Redirect if missing trailing slash.
if !strings.HasSuffix(ctx.Req.URL.Path, "/") {
http.Redirect(ctx.Resp, ctx.Req.Request, ctx.Req.URL.Path+"/", http.StatusFound)
return true
}
file = path.Join(file, opt.IndexFile)
f, err = opt.FileSystem.Open(file)
if err != nil {
return false // Discard error.
}
defer f.Close()
fi, err = f.Stat()
if err != nil || fi.IsDir() {
return true
}
}
if !opt.SkipLogging {
log.Println("[Static] Serving " + file)
}
// Add an Expires header to the static content
if opt.Expires != nil {
ctx.Resp.Header().Set("Expires", opt.Expires())
}
http.ServeContent(ctx.Resp, ctx.Req.Request, file, fi.ModTime(), f)
return true
}
// Static returns a middleware handler that serves static files in the given directory.
func Static(directory string, staticOpt ...StaticOptions) Handler {
opt := prepareStaticOptions(directory, staticOpt)
return func(ctx *Context, log *log.Logger) {
staticHandler(ctx, log, opt)
}
}
// Statics registers multiple static middleware handlers all at once.
func Statics(opt StaticOptions, dirs ...string) Handler {
if len(dirs) == 0 {
panic("no static directory is given")
}
opts := make([]StaticOptions, len(dirs))
for i := range dirs {
opts[i] = prepareStaticOption(dirs[i], opt)
}
return func(ctx *Context, log *log.Logger) {
for i := range opts {
if staticHandler(ctx, log, opts[i]) {
return
}
}
}
}

View File

@@ -0,0 +1,246 @@
// Copyright 2013 Martini Authors
// Copyright 2014 Unknwon
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package macaron
import (
"bytes"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"path"
"strings"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
var currentRoot, _ = os.Getwd()
func Test_Static(t *testing.T) {
Convey("Serve static files", t, func() {
m := New()
m.Use(Static("./"))
resp := httptest.NewRecorder()
resp.Body = new(bytes.Buffer)
req, err := http.NewRequest("GET", "http://localhost:4000/macaron.go", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusOK)
So(resp.Header().Get("Expires"), ShouldBeBlank)
So(resp.Body.Len(), ShouldBeGreaterThan, 0)
Convey("Change static path", func() {
m.Get("/", func(ctx *Context) {
ctx.ChangeStaticPath("./", "inject")
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
resp = httptest.NewRecorder()
resp.Body = new(bytes.Buffer)
req, err = http.NewRequest("GET", "http://localhost:4000/inject.go", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusOK)
So(resp.Header().Get("Expires"), ShouldBeBlank)
So(resp.Body.Len(), ShouldBeGreaterThan, 0)
})
})
Convey("Serve static files with local path", t, func() {
Root = os.TempDir()
f, err := ioutil.TempFile(Root, "static_content")
So(err, ShouldBeNil)
f.WriteString("Expected Content")
f.Close()
m := New()
m.Use(Static("."))
resp := httptest.NewRecorder()
resp.Body = new(bytes.Buffer)
req, err := http.NewRequest("GET", "http://localhost:4000/"+path.Base(strings.Replace(f.Name(), "\\", "/", -1)), nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusOK)
So(resp.Header().Get("Expires"), ShouldBeBlank)
So(resp.Body.String(), ShouldEqual, "Expected Content")
})
Convey("Serve static files with head", t, func() {
m := New()
m.Use(Static(currentRoot))
resp := httptest.NewRecorder()
resp.Body = new(bytes.Buffer)
req, err := http.NewRequest("HEAD", "http://localhost:4000/macaron.go", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusOK)
So(resp.Body.Len(), ShouldEqual, 0)
})
Convey("Serve static files as post", t, func() {
m := New()
m.Use(Static(currentRoot))
resp := httptest.NewRecorder()
req, err := http.NewRequest("POST", "http://localhost:4000/macaron.go", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusNotFound)
})
Convey("Serve static files with bad directory", t, func() {
m := Classic()
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "http://localhost:4000/macaron.go", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldNotEqual, http.StatusOK)
})
}
func Test_Static_Options(t *testing.T) {
Convey("Serve static files with options logging", t, func() {
var buf bytes.Buffer
m := NewWithLogger(&buf)
opt := StaticOptions{}
m.Use(Static(currentRoot, opt))
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "http://localhost:4000/macaron.go", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusOK)
So(buf.String(), ShouldEqual, "[Macaron] [Static] Serving /macaron.go\n")
// Not disable logging.
m.Handlers()
buf.Reset()
opt.SkipLogging = true
m.Use(Static(currentRoot, opt))
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusOK)
So(buf.Len(), ShouldEqual, 0)
})
Convey("Serve static files with options serve index", t, func() {
var buf bytes.Buffer
m := NewWithLogger(&buf)
opt := StaticOptions{IndexFile: "macaron.go"}
m.Use(Static(currentRoot, opt))
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "http://localhost:4000/", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusOK)
So(buf.String(), ShouldEqual, "[Macaron] [Static] Serving /macaron.go\n")
})
Convey("Serve static files with options prefix", t, func() {
var buf bytes.Buffer
m := NewWithLogger(&buf)
opt := StaticOptions{Prefix: "public"}
m.Use(Static(currentRoot, opt))
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "http://localhost:4000/public/macaron.go", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusOK)
So(buf.String(), ShouldEqual, "[Macaron] [Static] Serving /macaron.go\n")
})
Convey("Serve static files with options expires", t, func() {
var buf bytes.Buffer
m := NewWithLogger(&buf)
opt := StaticOptions{Expires: func() string { return "46" }}
m.Use(Static(currentRoot, opt))
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "http://localhost:4000/macaron.go", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Header().Get("Expires"), ShouldEqual, "46")
})
}
func Test_Static_Redirect(t *testing.T) {
Convey("Serve static files with redirect", t, func() {
m := New()
m.Use(Static(currentRoot, StaticOptions{Prefix: "/public"}))
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "http://localhost:4000/public", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusFound)
So(resp.Header().Get("Location"), ShouldEqual, "/public/")
})
}
func Test_Statics(t *testing.T) {
Convey("Serve multiple static routers", t, func() {
Convey("Register empty directory", func() {
defer func() {
So(recover(), ShouldNotBeNil)
}()
m := New()
m.Use(Statics(StaticOptions{}))
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "http://localhost:4000/", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
})
Convey("Serve normally", func() {
var buf bytes.Buffer
m := NewWithLogger(&buf)
m.Use(Statics(StaticOptions{}, currentRoot, currentRoot+"/inject"))
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "http://localhost:4000/macaron.go", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusOK)
So(buf.String(), ShouldEqual, "[Macaron] [Static] Serving /macaron.go\n")
resp = httptest.NewRecorder()
req, err = http.NewRequest("GET", "http://localhost:4000/inject/inject.go", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(resp.Code, ShouldEqual, http.StatusOK)
So(buf.String(), ShouldEndWith, "[Macaron] [Static] Serving /inject/inject.go\n")
})
})
}

View File

@@ -0,0 +1,421 @@
// Copyright 2013 Beego Authors
// Copyright 2014 Unknwon
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package macaron
// NOTE: last sync 0c93364 on Dec 19, 2014.
import (
"path"
"regexp"
"strings"
"github.com/Unknwon/com"
)
type leafInfo struct {
// Names of wildcards that lead to this leaf.
// eg, ["id" "name"] for the wildcard ":id" and ":name".
wildcards []string
// Not nil if the leaf is regexp.
regexps *regexp.Regexp
handle Handle
}
func (leaf *leafInfo) match(wildcardValues []string) (ok bool, params Params) {
if leaf.regexps == nil {
if len(wildcardValues) == 0 && len(leaf.wildcards) > 0 {
if com.IsSliceContainsStr(leaf.wildcards, ":") {
params = make(map[string]string)
j := 0
for _, v := range leaf.wildcards {
if v == ":" {
continue
}
params[v] = ""
j += 1
}
return true, params
}
return false, nil
} else if len(wildcardValues) == 0 {
return true, nil // Static path.
}
// Match *
if len(leaf.wildcards) == 1 && leaf.wildcards[0] == ":splat" {
params = make(map[string]string)
params[":splat"] = path.Join(wildcardValues...)
return true, params
}
// Match *.*
if len(leaf.wildcards) == 3 && leaf.wildcards[0] == "." {
params = make(map[string]string)
lastone := wildcardValues[len(wildcardValues)-1]
strs := strings.SplitN(lastone, ".", 2)
if len(strs) == 2 {
params[":ext"] = strs[1]
} else {
params[":ext"] = ""
}
params[":path"] = path.Join(wildcardValues[:len(wildcardValues)-1]...) + "/" + strs[0]
return true, params
}
// Match :id
params = make(map[string]string)
j := 0
for _, v := range leaf.wildcards {
if v == ":" {
continue
}
if v == "." {
lastone := wildcardValues[len(wildcardValues)-1]
strs := strings.SplitN(lastone, ".", 2)
if len(strs) == 2 {
params[":ext"] = strs[1]
} else {
params[":ext"] = ""
}
if len(wildcardValues[j:]) == 1 {
params[":path"] = strs[0]
} else {
params[":path"] = path.Join(wildcardValues[j:]...) + "/" + strs[0]
}
return true, params
}
if len(wildcardValues) <= j {
return false, nil
}
params[v] = wildcardValues[j]
j++
}
if len(params) != len(wildcardValues) {
return false, nil
}
return true, params
}
if !leaf.regexps.MatchString(path.Join(wildcardValues...)) {
return false, nil
}
params = make(map[string]string)
matches := leaf.regexps.FindStringSubmatch(path.Join(wildcardValues...))
for i, match := range matches[1:] {
params[leaf.wildcards[i]] = match
}
return true, params
}
// Tree represents a router tree for Macaron instance.
type Tree struct {
fixroutes map[string]*Tree
wildcard *Tree
leaves []*leafInfo
}
// NewTree initializes and returns a router tree.
func NewTree() *Tree {
return &Tree{
fixroutes: make(map[string]*Tree),
}
}
// splitPath splites patthen into parts.
//
// Examples:
// "/" -> []
// "/admin" -> ["admin"]
// "/admin/" -> ["admin"]
// "/admin/users" -> ["admin", "users"]
func splitPath(pattern string) []string {
if len(pattern) == 0 {
return []string{}
}
elements := strings.Split(pattern, "/")
if elements[0] == "" {
elements = elements[1:]
}
if elements[len(elements)-1] == "" {
elements = elements[:len(elements)-1]
}
return elements
}
// AddRouter adds a new route to router tree.
func (t *Tree) AddRouter(pattern string, handle Handle) {
t.addSegments(splitPath(pattern), handle, nil, "")
}
// splitSegment splits segment into parts.
//
// Examples:
// "admin" -> false, nil, ""
// ":id" -> true, [:id], ""
// "?:id" -> true, [: :id], "" : meaning can empty
// ":id:int" -> true, [:id], ([0-9]+)
// ":name:string" -> true, [:name], ([\w]+)
// ":id([0-9]+)" -> true, [:id], ([0-9]+)
// ":id([0-9]+)_:name" -> true, [:id :name], ([0-9]+)_(.+)
// "cms_:id_:page.html" -> true, [:id :page], cms_(.+)_(.+).html
// "*" -> true, [:splat], ""
// "*.*" -> true,[. :path :ext], "" . meaning separator
func splitSegment(key string) (bool, []string, string) {
if strings.HasPrefix(key, "*") {
if key == "*.*" {
return true, []string{".", ":path", ":ext"}, ""
} else {
return true, []string{":splat"}, ""
}
}
if strings.ContainsAny(key, ":") {
var paramsNum int
var out []rune
var start bool
var startexp bool
var param []rune
var expt []rune
var skipnum int
params := []string{}
reg := regexp.MustCompile(`[a-zA-Z0-9]+`)
for i, v := range key {
if skipnum > 0 {
skipnum -= 1
continue
}
if start {
//:id:int and :name:string
if v == ':' {
if len(key) >= i+4 {
if key[i+1:i+4] == "int" {
out = append(out, []rune("([0-9]+)")...)
params = append(params, ":"+string(param))
start = false
startexp = false
skipnum = 3
param = make([]rune, 0)
paramsNum += 1
continue
}
}
if len(key) >= i+7 {
if key[i+1:i+7] == "string" {
out = append(out, []rune(`([\w]+)`)...)
params = append(params, ":"+string(param))
paramsNum += 1
start = false
startexp = false
skipnum = 6
param = make([]rune, 0)
continue
}
}
}
// params only support a-zA-Z0-9
if reg.MatchString(string(v)) {
param = append(param, v)
continue
}
if v != '(' {
out = append(out, []rune(`(.+)`)...)
params = append(params, ":"+string(param))
param = make([]rune, 0)
paramsNum += 1
start = false
startexp = false
}
}
if startexp {
if v != ')' {
expt = append(expt, v)
continue
}
}
if v == ':' {
param = make([]rune, 0)
start = true
} else if v == '(' {
startexp = true
start = false
params = append(params, ":"+string(param))
paramsNum += 1
expt = make([]rune, 0)
expt = append(expt, '(')
} else if v == ')' {
startexp = false
expt = append(expt, ')')
out = append(out, expt...)
param = make([]rune, 0)
} else if v == '?' {
params = append(params, ":")
} else {
out = append(out, v)
}
}
if len(param) > 0 {
if paramsNum > 0 {
out = append(out, []rune(`(.+)`)...)
}
params = append(params, ":"+string(param))
}
return true, params, string(out)
} else {
return false, nil, ""
}
}
// addSegments add segments to the router tree.
func (t *Tree) addSegments(segments []string, handle Handle, wildcards []string, reg string) {
// Fixed root route.
if len(segments) == 0 {
if reg != "" {
filterCards := make([]string, 0, len(wildcards))
for _, v := range wildcards {
if v == ":" || v == "." {
continue
}
filterCards = append(filterCards, v)
}
t.leaves = append(t.leaves, &leafInfo{
handle: handle,
wildcards: filterCards,
regexps: regexp.MustCompile("^" + reg + "$"),
})
} else {
t.leaves = append(t.leaves, &leafInfo{
handle: handle,
wildcards: wildcards,
})
}
return
}
seg := segments[0]
iswild, params, regexpStr := splitSegment(seg)
//for the router /login/*/access match /login/2009/11/access
if !iswild && com.IsSliceContainsStr(wildcards, ":splat") {
iswild = true
regexpStr = seg
}
if seg == "*" && len(wildcards) > 0 && reg == "" {
iswild = true
regexpStr = "(.+)"
}
if iswild {
if t.wildcard == nil {
t.wildcard = NewTree()
}
if regexpStr != "" {
if reg == "" {
rr := ""
for _, w := range wildcards {
if w == "." || w == ":" {
continue
}
if w == ":splat" {
rr = rr + "(.+)/"
} else {
rr = rr + "([^/]+)/"
}
}
regexpStr = rr + regexpStr
} else {
regexpStr = "/" + regexpStr
}
} else if reg != "" {
if seg == "*.*" {
regexpStr = "/([^.]+).(.+)"
} else {
for _, w := range params {
if w == "." || w == ":" {
continue
}
regexpStr = "/([^/]+)" + regexpStr
}
}
}
t.wildcard.addSegments(segments[1:], handle, append(wildcards, params...), reg+regexpStr)
} else {
subTree, ok := t.fixroutes[seg]
if !ok {
subTree = NewTree()
t.fixroutes[seg] = subTree
}
subTree.addSegments(segments[1:], handle, wildcards, reg)
}
}
func (t *Tree) match(segments []string, wildcardValues []string) (handle Handle, params Params) {
// Handle leaf nodes.
if len(segments) == 0 {
for _, l := range t.leaves {
if ok, pa := l.match(wildcardValues); ok {
return l.handle, pa
}
}
if t.wildcard != nil {
for _, l := range t.wildcard.leaves {
if ok, pa := l.match(wildcardValues); ok {
return l.handle, pa
}
}
}
return nil, nil
}
seg, segs := segments[0], segments[1:]
subTree, ok := t.fixroutes[seg]
if ok {
handle, params = subTree.match(segs, wildcardValues)
} else if len(segs) == 0 { //.json .xml
if subindex := strings.LastIndex(seg, "."); subindex != -1 {
subTree, ok = t.fixroutes[seg[:subindex]]
if ok {
handle, params = subTree.match(segs, wildcardValues)
if handle != nil {
if params == nil {
params = make(map[string]string)
}
params[":ext"] = seg[subindex+1:]
return handle, params
}
}
}
}
if handle == nil && t.wildcard != nil {
handle, params = t.wildcard.match(segs, append(wildcardValues, seg))
}
if handle == nil {
for _, l := range t.leaves {
if ok, pa := l.match(append(wildcardValues, segments...)); ok {
return l.handle, pa
}
}
}
return handle, params
}
// Match returns Handle and params if any route is matched.
func (t *Tree) Match(pattern string) (Handle, Params) {
if len(pattern) == 0 || pattern[0] != '/' {
return nil, nil
}
return t.match(splitPath(pattern), nil)
}

View File

@@ -0,0 +1,112 @@
// Copyright 2014 Unknwon
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
package macaron
import (
// "net/http"
"strings"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func Test_splitSegment(t *testing.T) {
type result struct {
Ok bool
Parts []string
Regex string
}
cases := map[string]result{
"admin": result{false, nil, ""},
":id": result{true, []string{":id"}, ""},
"?:id": result{true, []string{":", ":id"}, ""},
":id:int": result{true, []string{":id"}, "([0-9]+)"},
":name:string": result{true, []string{":name"}, `([\w]+)`},
":id([0-9]+)": result{true, []string{":id"}, "([0-9]+)"},
":id([0-9]+)_:name": result{true, []string{":id", ":name"}, "([0-9]+)_(.+)"},
"cms_:id_:page.html": result{true, []string{":id", ":page"}, "cms_(.+)_(.+).html"},
"*": result{true, []string{":splat"}, ""},
"*.*": result{true, []string{".", ":path", ":ext"}, ""},
}
Convey("Splits segment into parts", t, func() {
for key, result := range cases {
ok, parts, regex := splitSegment(key)
So(ok, ShouldEqual, result.Ok)
if result.Parts == nil {
So(parts, ShouldBeNil)
} else {
So(parts, ShouldNotBeNil)
So(strings.Join(parts, " "), ShouldEqual, strings.Join(result.Parts, " "))
}
So(regex, ShouldEqual, result.Regex)
}
})
}
func Test_Tree_Match(t *testing.T) {
type result struct {
pattern string
reqUrl string
params map[string]string
}
cases := []result{
{"/:id", "/123", map[string]string{":id": "123"}},
{"/hello/?:id", "/hello", map[string]string{":id": ""}},
{"/", "/", nil},
{"", "", nil},
{"/customer/login", "/customer/login", nil},
{"/customer/login", "/customer/login.json", map[string]string{":ext": "json"}},
{"/*", "/customer/123", map[string]string{":splat": "customer/123"}},
{"/*", "/customer/2009/12/11", map[string]string{":splat": "customer/2009/12/11"}},
{"/aa/*/bb", "/aa/2009/bb", map[string]string{":splat": "2009"}},
{"/cc/*/dd", "/cc/2009/11/dd", map[string]string{":splat": "2009/11"}},
{"/ee/:year/*/ff", "/ee/2009/11/ff", map[string]string{":year": "2009", ":splat": "11"}},
{"/thumbnail/:size/uploads/*", "/thumbnail/100x100/uploads/items/2014/04/20/dPRCdChkUd651t1Hvs18.jpg",
map[string]string{":size": "100x100", ":splat": "items/2014/04/20/dPRCdChkUd651t1Hvs18.jpg"}},
{"/*.*", "/nice/api.json", map[string]string{":path": "nice/api", ":ext": "json"}},
{"/:name/*.*", "/nice/api.json", map[string]string{":name": "nice", ":path": "api", ":ext": "json"}},
{"/:name/test/*.*", "/nice/test/api.json", map[string]string{":name": "nice", ":path": "api", ":ext": "json"}},
{"/dl/:width:int/:height:int/*.*", "/dl/48/48/05ac66d9bda00a3acf948c43e306fc9a.jpg",
map[string]string{":width": "48", ":height": "48", ":ext": "jpg", ":path": "05ac66d9bda00a3acf948c43e306fc9a"}},
{"/v1/shop/:id:int", "/v1/shop/123", map[string]string{":id": "123"}},
{"/:year:int/:month:int/:id/:endid", "/1111/111/aaa/aaa", map[string]string{":year": "1111", ":month": "111", ":id": "aaa", ":endid": "aaa"}},
{"/v1/shop/:id/:name", "/v1/shop/123/nike", map[string]string{":id": "123", ":name": "nike"}},
{"/v1/shop/:id/account", "/v1/shop/123/account", map[string]string{":id": "123"}},
{"/v1/shop/:name:string", "/v1/shop/nike", map[string]string{":name": "nike"}},
{"/v1/shop/:id([0-9]+)", "/v1/shop//123", map[string]string{":id": "123"}},
{"/v1/shop/:id([0-9]+)_:name", "/v1/shop/123_nike", map[string]string{":id": "123", ":name": "nike"}},
{"/v1/shop/:id(.+)_cms.html", "/v1/shop/123_cms.html", map[string]string{":id": "123"}},
{"/v1/shop/cms_:id(.+)_:page(.+).html", "/v1/shop/cms_123_1.html", map[string]string{":id": "123", ":page": "1"}},
{"/v1/:v/cms/aaa_:id(.+)_:page(.+).html", "/v1/2/cms/aaa_123_1.html", map[string]string{":v": "2", ":id": "123", ":page": "1"}},
{"/v1/:v/cms_:id(.+)_:page(.+).html", "/v1/2/cms_123_1.html", map[string]string{":v": "2", ":id": "123", ":page": "1"}},
{"/v1/:v(.+)_cms/ttt_:id(.+)_:page(.+).html", "/v1/2_cms/ttt_123_1.html", map[string]string{":v": "2", ":id": "123", ":page": "1"}},
}
Convey("Match routers in tree", t, func() {
for _, c := range cases {
t := NewTree()
t.AddRouter(c.pattern, nil)
_, params := t.Match(c.reqUrl)
if params != nil {
for k, v := range c.params {
vv, ok := params[k]
So(ok, ShouldBeTrue)
So(vv, ShouldEqual, v)
}
}
}
})
}

View File

@@ -0,0 +1,8 @@
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db

View File

@@ -0,0 +1,9 @@
language: go
go:
- 1.1
- 1.2
- 1.3
- tip
before_script:
- mysql -e 'create database gotest;'

View File

@@ -0,0 +1,36 @@
# This is the official list of Go-MySQL-Driver authors for copyright purposes.
# If you are submitting a patch, please add your name or the name of the
# organization which holds the copyright to this list in alphabetical order.
# Names should be added to this file as
# Name <email address>
# The email address is not required for organizations.
# Please keep the list sorted.
# Individual Persons
Aaron Hopkins <go-sql-driver at die.net>
Arne Hormann <arnehormann at gmail.com>
Carlos Nieto <jose.carlos at menteslibres.net>
DisposaBoy <disposaboy at dby.me>
Frederick Mayle <frederickmayle at gmail.com>
Gustavo Kristic <gkristic at gmail.com>
Hanno Braun <mail at hannobraun.com>
Henri Yandell <flamefew at gmail.com>
James Harr <james.harr at gmail.com>
Jian Zhen <zhenjl at gmail.com>
Julien Schmidt <go-sql-driver at julienschmidt.com>
Leonardo YongUk Kim <dalinaum at gmail.com>
Lucas Liu <extrafliu at gmail.com>
Luke Scott <luke at webconnex.com>
Michael Woolnough <michael.woolnough at gmail.com>
Nicola Peduzzi <thenikso at gmail.com>
Xiaobing Jiang <s7v7nislands at gmail.com>
Xiuming Chen <cc at cxm.cc>
# Organizations
Barracuda Networks, Inc.
Google Inc.

View File

@@ -0,0 +1,83 @@
## HEAD
Changes:
- Use decimals field from MySQL to format time types
Bugfixes:
- Enable microsecond resolution on TIME, DATETIME and TIMESTAMP
## Version 1.2 (2014-06-03)
Changes:
- We switched back to a "rolling release". `go get` installs the current master branch again
- Version v1 of the driver will not be maintained anymore. Go 1.0 is no longer supported by this driver
- Exported errors to allow easy checking from application code
- Enabled TCP Keepalives on TCP connections
- Optimized INFILE handling (better buffer size calculation, lazy init, ...)
- The DSN parser also checks for a missing separating slash
- Faster binary date / datetime to string formatting
- Also exported the MySQLWarning type
- mysqlConn.Close returns the first error encountered instead of ignoring all errors
- writePacket() automatically writes the packet size to the header
- readPacket() uses an iterative approach instead of the recursive approach to merge splitted packets
New Features:
- `RegisterDial` allows the usage of a custom dial function to establish the network connection
- Setting the connection collation is possible with the `collation` DSN parameter. This parameter should be preferred over the `charset` parameter
- Logging of critical errors is configurable with `SetLogger`
- Google CloudSQL support
Bugfixes:
- Allow more than 32 parameters in prepared statements
- Various old_password fixes
- Fixed TestConcurrent test to pass Go's race detection
- Fixed appendLengthEncodedInteger for large numbers
- Renamed readLengthEnodedString to readLengthEncodedString and skipLengthEnodedString to skipLengthEncodedString (fixed typo)
## Version 1.1 (2013-11-02)
Changes:
- Go-MySQL-Driver now requires Go 1.1
- Connections now use the collation `utf8_general_ci` by default. Adding `&charset=UTF8` to the DSN should not be necessary anymore
- Made closing rows and connections error tolerant. This allows for example deferring rows.Close() without checking for errors
- `[]byte(nil)` is now treated as a NULL value. Before, it was treated like an empty string / `[]byte("")`
- DSN parameter values must now be url.QueryEscape'ed. This allows text values to contain special characters, such as '&'.
- Use the IO buffer also for writing. This results in zero allocations (by the driver) for most queries
- Optimized the buffer for reading
- stmt.Query now caches column metadata
- New Logo
- Changed the copyright header to include all contributors
- Improved the LOAD INFILE documentation
- The driver struct is now exported to make the driver directly accessible
- Refactored the driver tests
- Added more benchmarks and moved all to a separate file
- Other small refactoring
New Features:
- Added *old_passwords* support: Required in some cases, but must be enabled by adding `allowOldPasswords=true` to the DSN since it is insecure
- Added a `clientFoundRows` parameter: Return the number of matching rows instead of the number of rows changed on UPDATEs
- Added TLS/SSL support: Use a TLS/SSL encrypted connection to the server. Custom TLS configs can be registered and used
Bugfixes:
- Fixed MySQL 4.1 support: MySQL 4.1 sends packets with lengths which differ from the specification
- Convert to DB timezone when inserting `time.Time`
- Splitted packets (more than 16MB) are now merged correctly
- Fixed false positive `io.EOF` errors when the data was fully read
- Avoid panics on reuse of closed connections
- Fixed empty string producing false nil values
- Fixed sign byte for positive TIME fields
## Version 1.0 (2013-05-14)
Initial Release

View File

@@ -0,0 +1,40 @@
# Contributing Guidelines
## Reporting Issues
Before creating a new Issue, please check first if a similar Issue [already exists](https://github.com/go-sql-driver/mysql/issues?state=open) or was [recently closed](https://github.com/go-sql-driver/mysql/issues?direction=desc&page=1&sort=updated&state=closed).
Please provide the following minimum information:
* Your Go-MySQL-Driver version (or git SHA)
* Your Go version (run `go version` in your console)
* A detailed issue description
* Error Log if present
* If possible, a short example
## Contributing Code
By contributing to this project, you share your code under the Mozilla Public License 2, as specified in the LICENSE file.
Don't forget to add yourself to the AUTHORS file.
### Pull Requests Checklist
Please check the following points before submitting your pull request:
- [x] Code compiles correctly
- [x] Created tests, if possible
- [x] All tests pass
- [x] Extended the README / documentation, if necessary
- [x] Added yourself to the AUTHORS file
### Code Review
Everyone is invited to review and comment on pull requests.
If it looks fine to you, comment with "LGTM" (Looks good to me).
If changes are required, notice the reviewers with "PTAL" (Please take another look) after committing the fixes.
Before merging the Pull Request, at least one [team member](https://github.com/go-sql-driver?tab=members) must have commented with "LGTM".
## Development Ideas
If you are looking for ideas for code contributions, please check our [Development Ideas](https://github.com/go-sql-driver/mysql/wiki/Development-Ideas) Wiki page.

View File

@@ -0,0 +1,373 @@
Mozilla Public License Version 2.0
==================================
1. Definitions
--------------
1.1. "Contributor"
means each individual or legal entity that creates, contributes to
the creation of, or owns Covered Software.
1.2. "Contributor Version"
means the combination of the Contributions of others (if any) used
by a Contributor and that particular Contributor's Contribution.
1.3. "Contribution"
means Covered Software of a particular Contributor.
1.4. "Covered Software"
means Source Code Form to which the initial Contributor has attached
the notice in Exhibit A, the Executable Form of such Source Code
Form, and Modifications of such Source Code Form, in each case
including portions thereof.
1.5. "Incompatible With Secondary Licenses"
means
(a) that the initial Contributor has attached the notice described
in Exhibit B to the Covered Software; or
(b) that the Covered Software was made available under the terms of
version 1.1 or earlier of the License, but not also under the
terms of a Secondary License.
1.6. "Executable Form"
means any form of the work other than Source Code Form.
1.7. "Larger Work"
means a work that combines Covered Software with other material, in
a separate file or files, that is not Covered Software.
1.8. "License"
means this document.
1.9. "Licensable"
means having the right to grant, to the maximum extent possible,
whether at the time of the initial grant or subsequently, any and
all of the rights conveyed by this License.
1.10. "Modifications"
means any of the following:
(a) any file in Source Code Form that results from an addition to,
deletion from, or modification of the contents of Covered
Software; or
(b) any new file in Source Code Form that contains any Covered
Software.
1.11. "Patent Claims" of a Contributor
means any patent claim(s), including without limitation, method,
process, and apparatus claims, in any patent Licensable by such
Contributor that would be infringed, but for the grant of the
License, by the making, using, selling, offering for sale, having
made, import, or transfer of either its Contributions or its
Contributor Version.
1.12. "Secondary License"
means either the GNU General Public License, Version 2.0, the GNU
Lesser General Public License, Version 2.1, the GNU Affero General
Public License, Version 3.0, or any later versions of those
licenses.
1.13. "Source Code Form"
means the form of the work preferred for making modifications.
1.14. "You" (or "Your")
means an individual or a legal entity exercising rights under this
License. For legal entities, "You" includes any entity that
controls, is controlled by, or is under common control with You. For
purposes of this definition, "control" means (a) the power, direct
or indirect, to cause the direction or management of such entity,
whether by contract or otherwise, or (b) ownership of more than
fifty percent (50%) of the outstanding shares or beneficial
ownership of such entity.
2. License Grants and Conditions
--------------------------------
2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
(a) under intellectual property rights (other than patent or trademark)
Licensable by such Contributor to use, reproduce, make available,
modify, display, perform, distribute, and otherwise exploit its
Contributions, either on an unmodified basis, with Modifications, or
as part of a Larger Work; and
(b) under Patent Claims of such Contributor to make, use, sell, offer
for sale, have made, import, and otherwise transfer either its
Contributions or its Contributor Version.
2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution
become effective for each Contribution on the date the Contributor first
distributes such Contribution.
2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under
this License. No additional rights or licenses will be implied from the
distribution or licensing of Covered Software under this License.
Notwithstanding Section 2.1(b) above, no patent license is granted by a
Contributor:
(a) for any code that a Contributor has removed from Covered Software;
or
(b) for infringements caused by: (i) Your and any other third party's
modifications of Covered Software, or (ii) the combination of its
Contributions with other software (except as part of its Contributor
Version); or
(c) under Patent Claims infringed by Covered Software in the absence of
its Contributions.
This License does not grant any rights in the trademarks, service marks,
or logos of any Contributor (except as may be necessary to comply with
the notice requirements in Section 3.4).
2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to
distribute the Covered Software under a subsequent version of this
License (see Section 10.2) or under the terms of a Secondary License (if
permitted under the terms of Section 3.3).
2.5. Representation
Each Contributor represents that the Contributor believes its
Contributions are its original creation(s) or it has sufficient rights
to grant the rights to its Contributions conveyed by this License.
2.6. Fair Use
This License is not intended to limit any rights You have under
applicable copyright doctrines of fair use, fair dealing, or other
equivalents.
2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
in Section 2.1.
3. Responsibilities
-------------------
3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any
Modifications that You create or to which You contribute, must be under
the terms of this License. You must inform recipients that the Source
Code Form of the Covered Software is governed by the terms of this
License, and how they can obtain a copy of this License. You may not
attempt to alter or restrict the recipients' rights in the Source Code
Form.
3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:
(a) such Covered Software must also be made available in Source Code
Form, as described in Section 3.1, and You must inform recipients of
the Executable Form how they can obtain a copy of such Source Code
Form by reasonable means in a timely manner, at a charge no more
than the cost of distribution to the recipient; and
(b) You may distribute such Executable Form under the terms of this
License, or sublicense it under different terms, provided that the
license for the Executable Form does not attempt to limit or alter
the recipients' rights in the Source Code Form under this License.
3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice,
provided that You also comply with the requirements of this License for
the Covered Software. If the Larger Work is a combination of Covered
Software with a work governed by one or more Secondary Licenses, and the
Covered Software is not Incompatible With Secondary Licenses, this
License permits You to additionally distribute such Covered Software
under the terms of such Secondary License(s), so that the recipient of
the Larger Work may, at their option, further distribute the Covered
Software under the terms of either this License or such Secondary
License(s).
3.4. Notices
You may not remove or alter the substance of any license notices
(including copyright notices, patent notices, disclaimers of warranty,
or limitations of liability) contained within the Source Code Form of
the Covered Software, except that You may alter any license notices to
the extent required to remedy known factual inaccuracies.
3.5. Application of Additional Terms
You may choose to offer, and to charge a fee for, warranty, support,
indemnity or liability obligations to one or more recipients of Covered
Software. However, You may do so only on Your own behalf, and not on
behalf of any Contributor. You must make it absolutely clear that any
such warranty, support, indemnity, or liability obligation is offered by
You alone, and You hereby agree to indemnify every Contributor for any
liability incurred by such Contributor as a result of warranty, support,
indemnity or liability terms You offer. You may include additional
disclaimers of warranty and limitations of liability specific to any
jurisdiction.
4. Inability to Comply Due to Statute or Regulation
---------------------------------------------------
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Software due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description must
be placed in a text file included with all distributions of the Covered
Software under this License. Except to the extent prohibited by statute
or regulation, such description must be sufficiently detailed for a
recipient of ordinary skill to be able to understand it.
5. Termination
--------------
5.1. The rights granted under this License will terminate automatically
if You fail to comply with any of its terms. However, if You become
compliant, then the rights granted under this License from a particular
Contributor are reinstated (a) provisionally, unless and until such
Contributor explicitly and finally terminates Your grants, and (b) on an
ongoing basis, if such Contributor fails to notify You of the
non-compliance by some reasonable means prior to 60 days after You have
come back into compliance. Moreover, Your grants from a particular
Contributor are reinstated on an ongoing basis if such Contributor
notifies You of the non-compliance by some reasonable means, this is the
first time You have received notice of non-compliance with this License
from such Contributor, and You become compliant prior to 30 days after
Your receipt of the notice.
5.2. If You initiate litigation against any entity by asserting a patent
infringement claim (excluding declaratory judgment actions,
counter-claims, and cross-claims) alleging that a Contributor Version
directly or indirectly infringes any patent, then the rights granted to
You by any and all Contributors for the Covered Software under Section
2.1 of this License shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
end user license agreements (excluding distributors and resellers) which
have been validly granted by You or Your distributors under this License
prior to termination shall survive termination.
************************************************************************
* *
* 6. Disclaimer of Warranty *
* ------------------------- *
* *
* Covered Software is provided under this License on an "as is" *
* basis, without warranty of any kind, either expressed, implied, or *
* statutory, including, without limitation, warranties that the *
* Covered Software is free of defects, merchantable, fit for a *
* particular purpose or non-infringing. The entire risk as to the *
* quality and performance of the Covered Software is with You. *
* Should any Covered Software prove defective in any respect, You *
* (not any Contributor) assume the cost of any necessary servicing, *
* repair, or correction. This disclaimer of warranty constitutes an *
* essential part of this License. No use of any Covered Software is *
* authorized under this License except under this disclaimer. *
* *
************************************************************************
************************************************************************
* *
* 7. Limitation of Liability *
* -------------------------- *
* *
* Under no circumstances and under no legal theory, whether tort *
* (including negligence), contract, or otherwise, shall any *
* Contributor, or anyone who distributes Covered Software as *
* permitted above, be liable to You for any direct, indirect, *
* special, incidental, or consequential damages of any character *
* including, without limitation, damages for lost profits, loss of *
* goodwill, work stoppage, computer failure or malfunction, or any *
* and all other commercial damages or losses, even if such party *
* shall have been informed of the possibility of such damages. This *
* limitation of liability shall not apply to liability for death or *
* personal injury resulting from such party's negligence to the *
* extent applicable law prohibits such limitation. Some *
* jurisdictions do not allow the exclusion or limitation of *
* incidental or consequential damages, so this exclusion and *
* limitation may not apply to You. *
* *
************************************************************************
8. Litigation
-------------
Any litigation relating to this License may be brought only in the
courts of a jurisdiction where the defendant maintains its principal
place of business and such litigation shall be governed by laws of that
jurisdiction, without reference to its conflict-of-law provisions.
Nothing in this Section shall prevent a party's ability to bring
cross-claims or counter-claims.
9. Miscellaneous
----------------
This License represents the complete agreement concerning the subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. Any law or regulation which provides
that the language of a contract shall be construed against the drafter
shall not be used to construe this License against a Contributor.
10. Versions of the License
---------------------------
10.1. New Versions
Mozilla Foundation is the license steward. Except as provided in Section
10.3, no one other than the license steward has the right to modify or
publish new versions of this License. Each version will be given a
distinguishing version number.
10.2. Effect of New Versions
You may distribute the Covered Software under the terms of the version
of the License under which You originally received the Covered Software,
or under the terms of any subsequent version published by the license
steward.
10.3. Modified Versions
If you create software not governed by this License, and you want to
create a new license for such software, you may create and use a
modified version of this License if you rename the license and remove
any references to the name of the license steward (except to note that
such modified license differs from this License).
10.4. Distributing Source Code Form that is Incompatible With Secondary
Licenses
If You choose to distribute Source Code Form that is Incompatible With
Secondary Licenses under the terms of this version of the License, the
notice described in Exhibit B of this License must be attached.
Exhibit A - Source Code Form License Notice
-------------------------------------------
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular
file, then You may include the notice in a location (such as a LICENSE
file in a relevant directory) where a recipient would be likely to look
for such a notice.
You may add additional accurate notices of copyright ownership.
Exhibit B - "Incompatible With Secondary Licenses" Notice
---------------------------------------------------------
This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.

View File

@@ -0,0 +1,346 @@
# Go-MySQL-Driver
A MySQL-Driver for Go's [database/sql](http://golang.org/pkg/database/sql) package
![Go-MySQL-Driver logo](https://raw.github.com/wiki/go-sql-driver/mysql/gomysql_m.png "Golang Gopher holding the MySQL Dolphin")
**Latest stable Release:** [Version 1.2 (June 03, 2014)](https://github.com/go-sql-driver/mysql/releases)
[![Build Status](https://travis-ci.org/go-sql-driver/mysql.png?branch=master)](https://travis-ci.org/go-sql-driver/mysql)
---------------------------------------
* [Features](#features)
* [Requirements](#requirements)
* [Installation](#installation)
* [Usage](#usage)
* [DSN (Data Source Name)](#dsn-data-source-name)
* [Password](#password)
* [Protocol](#protocol)
* [Address](#address)
* [Parameters](#parameters)
* [Examples](#examples)
* [LOAD DATA LOCAL INFILE support](#load-data-local-infile-support)
* [time.Time support](#timetime-support)
* [Unicode support](#unicode-support)
* [Testing / Development](#testing--development)
* [License](#license)
---------------------------------------
## Features
* Lightweight and [fast](https://github.com/go-sql-driver/sql-benchmark "golang MySQL-Driver performance")
* Native Go implementation. No C-bindings, just pure Go
* Connections over TCP/IPv4, TCP/IPv6 or Unix domain sockets
* Automatic handling of broken connections
* Automatic Connection Pooling *(by database/sql package)*
* Supports queries larger than 16MB
* Full [`sql.RawBytes`](http://golang.org/pkg/database/sql/#RawBytes) support.
* Intelligent `LONG DATA` handling in prepared statements
* Secure `LOAD DATA LOCAL INFILE` support with file Whitelisting and `io.Reader` support
* Optional `time.Time` parsing
## Requirements
* Go 1.1 or higher
* MySQL (4.1+), MariaDB, Percona Server, Google CloudSQL or Sphinx (2.2.3+)
---------------------------------------
## Installation
Simple install the package to your [$GOPATH](http://code.google.com/p/go-wiki/wiki/GOPATH "GOPATH") with the [go tool](http://golang.org/cmd/go/ "go command") from shell:
```bash
$ go get github.com/go-sql-driver/mysql
```
Make sure [Git is installed](http://git-scm.com/downloads) on your machine and in your system's `PATH`.
## Usage
_Go MySQL Driver_ is an implementation of Go's `database/sql/driver` interface. You only need to import the driver and can use the full [`database/sql`](http://golang.org/pkg/database/sql) API then.
Use `mysql` as `driverName` and a valid [DSN](#dsn-data-source-name) as `dataSourceName`:
```go
import "database/sql"
import _ "github.com/go-sql-driver/mysql"
db, err := sql.Open("mysql", "user:password@/dbname")
```
[Examples are available in our Wiki](https://github.com/go-sql-driver/mysql/wiki/Examples "Go-MySQL-Driver Examples").
### DSN (Data Source Name)
The Data Source Name has a common format, like e.g. [PEAR DB](http://pear.php.net/manual/en/package.database.db.intro-dsn.php) uses it, but without type-prefix (optional parts marked by squared brackets):
```
[username[:password]@][protocol[(address)]]/dbname[?param1=value1&...&paramN=valueN]
```
A DSN in its fullest form:
```
username:password@protocol(address)/dbname?param=value
```
Except for the databasename, all values are optional. So the minimal DSN is:
```
/dbname
```
If you do not want to preselect a database, leave `dbname` empty:
```
/
```
This has the same effect as an empty DSN string:
```
```
#### Password
Passwords can consist of any character. Escaping is **not** necessary.
#### Protocol
See [net.Dial](http://golang.org/pkg/net/#Dial) for more information which networks are available.
In general you should use an Unix domain socket if available and TCP otherwise for best performance.
#### Address
For TCP and UDP networks, addresses have the form `host:port`.
If `host` is a literal IPv6 address, it must be enclosed in square brackets.
The functions [net.JoinHostPort](http://golang.org/pkg/net/#JoinHostPort) and [net.SplitHostPort](http://golang.org/pkg/net/#SplitHostPort) manipulate addresses in this form.
For Unix domain sockets the address is the absolute path to the MySQL-Server-socket, e.g. `/var/run/mysqld/mysqld.sock` or `/tmp/mysql.sock`.
#### Parameters
*Parameters are case-sensitive!*
Notice that any of `true`, `TRUE`, `True` or `1` is accepted to stand for a true boolean value. Not surprisingly, false can be specified as any of: `false`, `FALSE`, `False` or `0`.
##### `allowAllFiles`
```
Type: bool
Valid Values: true, false
Default: false
```
`allowAllFiles=true` disables the file Whitelist for `LOAD DATA LOCAL INFILE` and allows *all* files.
[*Might be insecure!*](http://dev.mysql.com/doc/refman/5.7/en/load-data-local.html)
##### `allowOldPasswords`
```
Type: bool
Valid Values: true, false
Default: false
```
`allowOldPasswords=true` allows the usage of the insecure old password method. This should be avoided, but is necessary in some cases. See also [the old_passwords wiki page](https://github.com/go-sql-driver/mysql/wiki/old_passwords).
##### `charset`
```
Type: string
Valid Values: <name>
Default: none
```
Sets the charset used for client-server interaction (`"SET NAMES <value>"`). If multiple charsets are set (separated by a comma), the following charset is used if setting the charset failes. This enables for example support for `utf8mb4` ([introduced in MySQL 5.5.3](http://dev.mysql.com/doc/refman/5.5/en/charset-unicode-utf8mb4.html)) with fallback to `utf8` for older servers (`charset=utf8mb4,utf8`).
Usage of the `charset` parameter is discouraged because it issues additional queries to the server.
Unless you need the fallback behavior, please use `collation` instead.
##### `collation`
```
Type: string
Valid Values: <name>
Default: utf8_general_ci
```
Sets the collation used for client-server interaction on connection. In contrast to `charset`, `collation` does not issue additional queries. If the specified collation is unavailable on the target server, the connection will fail.
A list of valid charsets for a server is retrievable with `SHOW COLLATION`.
##### `clientFoundRows`
```
Type: bool
Valid Values: true, false
Default: false
```
`clientFoundRows=true` causes an UPDATE to return the number of matching rows instead of the number of rows changed.
##### `loc`
```
Type: string
Valid Values: <escaped name>
Default: UTC
```
Sets the location for time.Time values (when using `parseTime=true`). *"Local"* sets the system's location. See [time.LoadLocation](http://golang.org/pkg/time/#LoadLocation) for details.
Please keep in mind, that param values must be [url.QueryEscape](http://golang.org/pkg/net/url/#QueryEscape)'ed. Alternatively you can manually replace the `/` with `%2F`. For example `US/Pacific` would be `loc=US%2FPacific`.
##### `parseTime`
```
Type: bool
Valid Values: true, false
Default: false
```
`parseTime=true` changes the output type of `DATE` and `DATETIME` values to `time.Time` instead of `[]byte` / `string`
##### `strict`
```
Type: bool
Valid Values: true, false
Default: false
```
`strict=true` enables the strict mode in which MySQL warnings are treated as errors.
By default MySQL also treats notes as warnings. Use [`sql_notes=false`](http://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_sql_notes) to ignore notes. See the [examples](#examples) for an DSN example.
##### `timeout`
```
Type: decimal number
Default: OS default
```
*Driver* side connection timeout. The value must be a string of decimal numbers, each with optional fraction and a unit suffix ( *"ms"*, *"s"*, *"m"*, *"h"* ), such as *"30s"*, *"0.5m"* or *"1m30s"*. To set a server side timeout, use the parameter [`wait_timeout`](http://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_wait_timeout).
##### `tls`
```
Type: bool / string
Valid Values: true, false, skip-verify, <name>
Default: false
```
`tls=true` enables TLS / SSL encrypted connection to the server. Use `skip-verify` if you want to use a self-signed or invalid certificate (server side). Use a custom value registered with [`mysql.RegisterTLSConfig`](http://godoc.org/github.com/go-sql-driver/mysql#RegisterTLSConfig).
##### System Variables
All other parameters are interpreted as system variables:
* `autocommit`: `"SET autocommit=<value>"`
* `time_zone`: `"SET time_zone=<value>"`
* [`tx_isolation`](https://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_tx_isolation): `"SET tx_isolation=<value>"`
* `param`: `"SET <param>=<value>"`
*The values must be [url.QueryEscape](http://golang.org/pkg/net/url/#QueryEscape)'ed!*
#### Examples
```
user@unix(/path/to/socket)/dbname
```
```
root:pw@unix(/tmp/mysql.sock)/myDatabase?loc=Local
```
```
user:password@tcp(localhost:5555)/dbname?tls=skip-verify&autocommit=true
```
Use the [strict mode](#strict) but ignore notes:
```
user:password@/dbname?strict=true&sql_notes=false
```
TCP via IPv6:
```
user:password@tcp([de:ad:be:ef::ca:fe]:80)/dbname?timeout=90s&collation=utf8mb4_unicode_ci
```
TCP on a remote host, e.g. Amazon RDS:
```
id:password@tcp(your-amazonaws-uri.com:3306)/dbname
```
Google Cloud SQL on App Engine:
```
user@cloudsql(project-id:instance-name)/dbname
```
TCP using default port (3306) on localhost:
```
user:password@tcp/dbname?charset=utf8mb4,utf8&sys_var=esc%40ped
```
Use the default protocol (tcp) and host (localhost:3306):
```
user:password@/dbname
```
No Database preselected:
```
user:password@/
```
### `LOAD DATA LOCAL INFILE` support
For this feature you need direct access to the package. Therefore you must change the import path (no `_`):
```go
import "github.com/go-sql-driver/mysql"
```
Files must be whitelisted by registering them with `mysql.RegisterLocalFile(filepath)` (recommended) or the Whitelist check must be deactivated by using the DSN parameter `allowAllFiles=true` ([*Might be insecure!*](http://dev.mysql.com/doc/refman/5.7/en/load-data-local.html)).
To use a `io.Reader` a handler function must be registered with `mysql.RegisterReaderHandler(name, handler)` which returns a `io.Reader` or `io.ReadCloser`. The Reader is available with the filepath `Reader::<name>` then.
See the [godoc of Go-MySQL-Driver](http://godoc.org/github.com/go-sql-driver/mysql "golang mysql driver documentation") for details.
### `time.Time` support
The default internal output type of MySQL `DATE` and `DATETIME` values is `[]byte` which allows you to scan the value into a `[]byte`, `string` or `sql.RawBytes` variable in your programm.
However, many want to scan MySQL `DATE` and `DATETIME` values into `time.Time` variables, which is the logical opposite in Go to `DATE` and `DATETIME` in MySQL. You can do that by changing the internal output type from `[]byte` to `time.Time` with the DSN parameter `parseTime=true`. You can set the default [`time.Time` location](http://golang.org/pkg/time/#Location) with the `loc` DSN parameter.
**Caution:** As of Go 1.1, this makes `time.Time` the only variable type you can scan `DATE` and `DATETIME` values into. This breaks for example [`sql.RawBytes` support](https://github.com/go-sql-driver/mysql/wiki/Examples#rawbytes).
Alternatively you can use the [`NullTime`](http://godoc.org/github.com/go-sql-driver/mysql#NullTime) type as the scan destination, which works with both `time.Time` and `string` / `[]byte`.
### Unicode support
Since version 1.1 Go-MySQL-Driver automatically uses the collation `utf8_general_ci` by default.
Other collations / charsets can be set using the [`collation`](#collation) DSN parameter.
Version 1.0 of the driver recommended adding `&charset=utf8` (alias for `SET NAMES utf8`) to the DSN to enable proper UTF-8 support. This is not necessary anymore. The [`collation`](#collation) parameter should be preferred to set another collation / charset than the default.
See http://dev.mysql.com/doc/refman/5.7/en/charset-unicode.html for more details on MySQL's Unicode support.
## Testing / Development
To run the driver tests you may need to adjust the configuration. See the [Testing Wiki-Page](https://github.com/go-sql-driver/mysql/wiki/Testing "Testing") for details.
Go-MySQL-Driver is not feature-complete yet. Your help is very appreciated.
If you want to contribute, you can work on an [open issue](https://github.com/go-sql-driver/mysql/issues?state=open) or review a [pull request](https://github.com/go-sql-driver/mysql/pulls).
See the [Contribution Guidelines](https://github.com/go-sql-driver/mysql/blob/master/CONTRIBUTING.md) for details.
---------------------------------------
## License
Go-MySQL-Driver is licensed under the [Mozilla Public License Version 2.0](https://raw.github.com/go-sql-driver/mysql/master/LICENSE)
Mozilla summarizes the license scope as follows:
> MPL: The copyleft applies to any files containing MPLed code.
That means:
* You can **use** the **unchanged** source code both in private and commercially
* When distributing, you **must publish** the source code of any **changed files** licensed under the MPL 2.0 under a) the MPL 2.0 itself or b) a compatible license (e.g. GPL 3.0 or Apache License 2.0)
* You **needn't publish** the source code of your library as long as the files licensed under the MPL 2.0 are **unchanged**
Please read the [MPL 2.0 FAQ](http://www.mozilla.org/MPL/2.0/FAQ.html) if you have further questions regarding the license.
You can read the full terms here: [LICENSE](https://raw.github.com/go-sql-driver/mysql/master/LICENSE)
![Go Gopher and MySQL Dolphin](https://raw.github.com/wiki/go-sql-driver/mysql/go-mysql-driver_m.jpg "Golang Gopher transporting the MySQL Dolphin in a wheelbarrow")

View File

@@ -0,0 +1,19 @@
// Go MySQL Driver - A MySQL-Driver for Go's database/sql package
//
// Copyright 2013 The Go-MySQL-Driver Authors. All rights reserved.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at http://mozilla.org/MPL/2.0/.
// +build appengine
package mysql
import (
"appengine/cloudsql"
)
func init() {
RegisterDial("cloudsql", cloudsql.Dial)
}

View File

@@ -0,0 +1,208 @@
// Go MySQL Driver - A MySQL-Driver for Go's database/sql package
//
// Copyright 2013 The Go-MySQL-Driver Authors. All rights reserved.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at http://mozilla.org/MPL/2.0/.
package mysql
import (
"bytes"
"database/sql"
"strings"
"sync"
"sync/atomic"
"testing"
)
type TB testing.B
func (tb *TB) check(err error) {
if err != nil {
tb.Fatal(err)
}
}
func (tb *TB) checkDB(db *sql.DB, err error) *sql.DB {
tb.check(err)
return db
}
func (tb *TB) checkRows(rows *sql.Rows, err error) *sql.Rows {
tb.check(err)
return rows
}
func (tb *TB) checkStmt(stmt *sql.Stmt, err error) *sql.Stmt {
tb.check(err)
return stmt
}
func initDB(b *testing.B, queries ...string) *sql.DB {
tb := (*TB)(b)
db := tb.checkDB(sql.Open("mysql", dsn))
for _, query := range queries {
if _, err := db.Exec(query); err != nil {
b.Fatalf("Error on %q: %v", query, err)
}
}
return db
}
const concurrencyLevel = 10
func BenchmarkQuery(b *testing.B) {
tb := (*TB)(b)
b.StopTimer()
b.ReportAllocs()
db := initDB(b,
"DROP TABLE IF EXISTS foo",
"CREATE TABLE foo (id INT PRIMARY KEY, val CHAR(50))",
`INSERT INTO foo VALUES (1, "one")`,
`INSERT INTO foo VALUES (2, "two")`,
)
db.SetMaxIdleConns(concurrencyLevel)
defer db.Close()
stmt := tb.checkStmt(db.Prepare("SELECT val FROM foo WHERE id=?"))
defer stmt.Close()
remain := int64(b.N)
var wg sync.WaitGroup
wg.Add(concurrencyLevel)
defer wg.Wait()
b.StartTimer()
for i := 0; i < concurrencyLevel; i++ {
go func() {
for {
if atomic.AddInt64(&remain, -1) < 0 {
wg.Done()
return
}
var got string
tb.check(stmt.QueryRow(1).Scan(&got))
if got != "one" {
b.Errorf("query = %q; want one", got)
wg.Done()
return
}
}
}()
}
}
func BenchmarkExec(b *testing.B) {
tb := (*TB)(b)
b.StopTimer()
b.ReportAllocs()
db := tb.checkDB(sql.Open("mysql", dsn))
db.SetMaxIdleConns(concurrencyLevel)
defer db.Close()
stmt := tb.checkStmt(db.Prepare("DO 1"))
defer stmt.Close()
remain := int64(b.N)
var wg sync.WaitGroup
wg.Add(concurrencyLevel)
defer wg.Wait()
b.StartTimer()
for i := 0; i < concurrencyLevel; i++ {
go func() {
for {
if atomic.AddInt64(&remain, -1) < 0 {
wg.Done()
return
}
if _, err := stmt.Exec(); err != nil {
b.Fatal(err.Error())
}
}
}()
}
}
// data, but no db writes
var roundtripSample []byte
func initRoundtripBenchmarks() ([]byte, int, int) {
if roundtripSample == nil {
roundtripSample = []byte(strings.Repeat("0123456789abcdef", 1024*1024))
}
return roundtripSample, 16, len(roundtripSample)
}
func BenchmarkRoundtripTxt(b *testing.B) {
b.StopTimer()
sample, min, max := initRoundtripBenchmarks()
sampleString := string(sample)
b.ReportAllocs()
tb := (*TB)(b)
db := tb.checkDB(sql.Open("mysql", dsn))
defer db.Close()
b.StartTimer()
var result string
for i := 0; i < b.N; i++ {
length := min + i
if length > max {
length = max
}
test := sampleString[0:length]
rows := tb.checkRows(db.Query(`SELECT "` + test + `"`))
if !rows.Next() {
rows.Close()
b.Fatalf("crashed")
}
err := rows.Scan(&result)
if err != nil {
rows.Close()
b.Fatalf("crashed")
}
if result != test {
rows.Close()
b.Errorf("mismatch")
}
rows.Close()
}
}
func BenchmarkRoundtripBin(b *testing.B) {
b.StopTimer()
sample, min, max := initRoundtripBenchmarks()
b.ReportAllocs()
tb := (*TB)(b)
db := tb.checkDB(sql.Open("mysql", dsn))
defer db.Close()
stmt := tb.checkStmt(db.Prepare("SELECT ?"))
defer stmt.Close()
b.StartTimer()
var result sql.RawBytes
for i := 0; i < b.N; i++ {
length := min + i
if length > max {
length = max
}
test := sample[0:length]
rows := tb.checkRows(stmt.Query(test))
if !rows.Next() {
rows.Close()
b.Fatalf("crashed")
}
err := rows.Scan(&result)
if err != nil {
rows.Close()
b.Fatalf("crashed")
}
if !bytes.Equal(result, test) {
rows.Close()
b.Errorf("mismatch")
}
rows.Close()
}
}

View File

@@ -0,0 +1,136 @@
// Go MySQL Driver - A MySQL-Driver for Go's database/sql package
//
// Copyright 2013 The Go-MySQL-Driver Authors. All rights reserved.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at http://mozilla.org/MPL/2.0/.
package mysql
import "io"
const defaultBufSize = 4096
// A buffer which is used for both reading and writing.
// This is possible since communication on each connection is synchronous.
// In other words, we can't write and read simultaneously on the same connection.
// The buffer is similar to bufio.Reader / Writer but zero-copy-ish
// Also highly optimized for this particular use case.
type buffer struct {
buf []byte
rd io.Reader
idx int
length int
}
func newBuffer(rd io.Reader) buffer {
var b [defaultBufSize]byte
return buffer{
buf: b[:],
rd: rd,
}
}
// fill reads into the buffer until at least _need_ bytes are in it
func (b *buffer) fill(need int) error {
n := b.length
// move existing data to the beginning
if n > 0 && b.idx > 0 {
copy(b.buf[0:n], b.buf[b.idx:])
}
// grow buffer if necessary
// TODO: let the buffer shrink again at some point
// Maybe keep the org buf slice and swap back?
if need > len(b.buf) {
// Round up to the next multiple of the default size
newBuf := make([]byte, ((need/defaultBufSize)+1)*defaultBufSize)
copy(newBuf, b.buf)
b.buf = newBuf
}
b.idx = 0
for {
nn, err := b.rd.Read(b.buf[n:])
n += nn
switch err {
case nil:
if n < need {
continue
}
b.length = n
return nil
case io.EOF:
if n >= need {
b.length = n
return nil
}
return io.ErrUnexpectedEOF
default:
return err
}
}
}
// returns next N bytes from buffer.
// The returned slice is only guaranteed to be valid until the next read
func (b *buffer) readNext(need int) ([]byte, error) {
if b.length < need {
// refill
if err := b.fill(need); err != nil {
return nil, err
}
}
offset := b.idx
b.idx += need
b.length -= need
return b.buf[offset:b.idx], nil
}
// returns a buffer with the requested size.
// If possible, a slice from the existing buffer is returned.
// Otherwise a bigger buffer is made.
// Only one buffer (total) can be used at a time.
func (b *buffer) takeBuffer(length int) []byte {
if b.length > 0 {
return nil
}
// test (cheap) general case first
if length <= defaultBufSize || length <= cap(b.buf) {
return b.buf[:length]
}
if length < maxPacketSize {
b.buf = make([]byte, length)
return b.buf
}
return make([]byte, length)
}
// shortcut which can be used if the requested buffer is guaranteed to be
// smaller than defaultBufSize
// Only one buffer (total) can be used at a time.
func (b *buffer) takeSmallBuffer(length int) []byte {
if b.length == 0 {
return b.buf[:length]
}
return nil
}
// takeCompleteBuffer returns the complete existing buffer.
// This can be used if the necessary buffer size is unknown.
// Only one buffer (total) can be used at a time.
func (b *buffer) takeCompleteBuffer() []byte {
if b.length == 0 {
return b.buf
}
return nil
}

View File

@@ -0,0 +1,236 @@
// Go MySQL Driver - A MySQL-Driver for Go's database/sql package
//
// Copyright 2014 The Go-MySQL-Driver Authors. All rights reserved.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at http://mozilla.org/MPL/2.0/.
package mysql
const defaultCollation byte = 33 // utf8_general_ci
// A list of available collations mapped to the internal ID.
// To update this map use the following MySQL query:
// SELECT COLLATION_NAME, ID FROM information_schema.COLLATIONS
var collations = map[string]byte{
"big5_chinese_ci": 1,
"latin2_czech_cs": 2,
"dec8_swedish_ci": 3,
"cp850_general_ci": 4,
"latin1_german1_ci": 5,
"hp8_english_ci": 6,
"koi8r_general_ci": 7,
"latin1_swedish_ci": 8,
"latin2_general_ci": 9,
"swe7_swedish_ci": 10,
"ascii_general_ci": 11,
"ujis_japanese_ci": 12,
"sjis_japanese_ci": 13,
"cp1251_bulgarian_ci": 14,
"latin1_danish_ci": 15,
"hebrew_general_ci": 16,
"tis620_thai_ci": 18,
"euckr_korean_ci": 19,
"latin7_estonian_cs": 20,
"latin2_hungarian_ci": 21,
"koi8u_general_ci": 22,
"cp1251_ukrainian_ci": 23,
"gb2312_chinese_ci": 24,
"greek_general_ci": 25,
"cp1250_general_ci": 26,
"latin2_croatian_ci": 27,
"gbk_chinese_ci": 28,
"cp1257_lithuanian_ci": 29,
"latin5_turkish_ci": 30,
"latin1_german2_ci": 31,
"armscii8_general_ci": 32,
"utf8_general_ci": 33,
"cp1250_czech_cs": 34,
"ucs2_general_ci": 35,
"cp866_general_ci": 36,
"keybcs2_general_ci": 37,
"macce_general_ci": 38,
"macroman_general_ci": 39,
"cp852_general_ci": 40,
"latin7_general_ci": 41,
"latin7_general_cs": 42,
"macce_bin": 43,
"cp1250_croatian_ci": 44,
"utf8mb4_general_ci": 45,
"utf8mb4_bin": 46,
"latin1_bin": 47,
"latin1_general_ci": 48,
"latin1_general_cs": 49,
"cp1251_bin": 50,
"cp1251_general_ci": 51,
"cp1251_general_cs": 52,
"macroman_bin": 53,
"utf16_general_ci": 54,
"utf16_bin": 55,
"utf16le_general_ci": 56,
"cp1256_general_ci": 57,
"cp1257_bin": 58,
"cp1257_general_ci": 59,
"utf32_general_ci": 60,
"utf32_bin": 61,
"utf16le_bin": 62,
"binary": 63,
"armscii8_bin": 64,
"ascii_bin": 65,
"cp1250_bin": 66,
"cp1256_bin": 67,
"cp866_bin": 68,
"dec8_bin": 69,
"greek_bin": 70,
"hebrew_bin": 71,
"hp8_bin": 72,
"keybcs2_bin": 73,
"koi8r_bin": 74,
"koi8u_bin": 75,
"latin2_bin": 77,
"latin5_bin": 78,
"latin7_bin": 79,
"cp850_bin": 80,
"cp852_bin": 81,
"swe7_bin": 82,
"utf8_bin": 83,
"big5_bin": 84,
"euckr_bin": 85,
"gb2312_bin": 86,
"gbk_bin": 87,
"sjis_bin": 88,
"tis620_bin": 89,
"ucs2_bin": 90,
"ujis_bin": 91,
"geostd8_general_ci": 92,
"geostd8_bin": 93,
"latin1_spanish_ci": 94,
"cp932_japanese_ci": 95,
"cp932_bin": 96,
"eucjpms_japanese_ci": 97,
"eucjpms_bin": 98,
"cp1250_polish_ci": 99,
"utf16_unicode_ci": 101,
"utf16_icelandic_ci": 102,
"utf16_latvian_ci": 103,
"utf16_romanian_ci": 104,
"utf16_slovenian_ci": 105,
"utf16_polish_ci": 106,
"utf16_estonian_ci": 107,
"utf16_spanish_ci": 108,
"utf16_swedish_ci": 109,
"utf16_turkish_ci": 110,
"utf16_czech_ci": 111,
"utf16_danish_ci": 112,
"utf16_lithuanian_ci": 113,
"utf16_slovak_ci": 114,
"utf16_spanish2_ci": 115,
"utf16_roman_ci": 116,
"utf16_persian_ci": 117,
"utf16_esperanto_ci": 118,
"utf16_hungarian_ci": 119,
"utf16_sinhala_ci": 120,
"utf16_german2_ci": 121,
"utf16_croatian_ci": 122,
"utf16_unicode_520_ci": 123,
"utf16_vietnamese_ci": 124,
"ucs2_unicode_ci": 128,
"ucs2_icelandic_ci": 129,
"ucs2_latvian_ci": 130,
"ucs2_romanian_ci": 131,
"ucs2_slovenian_ci": 132,
"ucs2_polish_ci": 133,
"ucs2_estonian_ci": 134,
"ucs2_spanish_ci": 135,
"ucs2_swedish_ci": 136,
"ucs2_turkish_ci": 137,
"ucs2_czech_ci": 138,
"ucs2_danish_ci": 139,
"ucs2_lithuanian_ci": 140,
"ucs2_slovak_ci": 141,
"ucs2_spanish2_ci": 142,
"ucs2_roman_ci": 143,
"ucs2_persian_ci": 144,
"ucs2_esperanto_ci": 145,
"ucs2_hungarian_ci": 146,
"ucs2_sinhala_ci": 147,
"ucs2_german2_ci": 148,
"ucs2_croatian_ci": 149,
"ucs2_unicode_520_ci": 150,
"ucs2_vietnamese_ci": 151,
"ucs2_general_mysql500_ci": 159,
"utf32_unicode_ci": 160,
"utf32_icelandic_ci": 161,
"utf32_latvian_ci": 162,
"utf32_romanian_ci": 163,
"utf32_slovenian_ci": 164,
"utf32_polish_ci": 165,
"utf32_estonian_ci": 166,
"utf32_spanish_ci": 167,
"utf32_swedish_ci": 168,
"utf32_turkish_ci": 169,
"utf32_czech_ci": 170,
"utf32_danish_ci": 171,
"utf32_lithuanian_ci": 172,
"utf32_slovak_ci": 173,
"utf32_spanish2_ci": 174,
"utf32_roman_ci": 175,
"utf32_persian_ci": 176,
"utf32_esperanto_ci": 177,
"utf32_hungarian_ci": 178,
"utf32_sinhala_ci": 179,
"utf32_german2_ci": 180,
"utf32_croatian_ci": 181,
"utf32_unicode_520_ci": 182,
"utf32_vietnamese_ci": 183,
"utf8_unicode_ci": 192,
"utf8_icelandic_ci": 193,
"utf8_latvian_ci": 194,
"utf8_romanian_ci": 195,
"utf8_slovenian_ci": 196,
"utf8_polish_ci": 197,
"utf8_estonian_ci": 198,
"utf8_spanish_ci": 199,
"utf8_swedish_ci": 200,
"utf8_turkish_ci": 201,
"utf8_czech_ci": 202,
"utf8_danish_ci": 203,
"utf8_lithuanian_ci": 204,
"utf8_slovak_ci": 205,
"utf8_spanish2_ci": 206,
"utf8_roman_ci": 207,
"utf8_persian_ci": 208,
"utf8_esperanto_ci": 209,
"utf8_hungarian_ci": 210,
"utf8_sinhala_ci": 211,
"utf8_german2_ci": 212,
"utf8_croatian_ci": 213,
"utf8_unicode_520_ci": 214,
"utf8_vietnamese_ci": 215,
"utf8_general_mysql500_ci": 223,
"utf8mb4_unicode_ci": 224,
"utf8mb4_icelandic_ci": 225,
"utf8mb4_latvian_ci": 226,
"utf8mb4_romanian_ci": 227,
"utf8mb4_slovenian_ci": 228,
"utf8mb4_polish_ci": 229,
"utf8mb4_estonian_ci": 230,
"utf8mb4_spanish_ci": 231,
"utf8mb4_swedish_ci": 232,
"utf8mb4_turkish_ci": 233,
"utf8mb4_czech_ci": 234,
"utf8mb4_danish_ci": 235,
"utf8mb4_lithuanian_ci": 236,
"utf8mb4_slovak_ci": 237,
"utf8mb4_spanish2_ci": 238,
"utf8mb4_roman_ci": 239,
"utf8mb4_persian_ci": 240,
"utf8mb4_esperanto_ci": 241,
"utf8mb4_hungarian_ci": 242,
"utf8mb4_sinhala_ci": 243,
"utf8mb4_german2_ci": 244,
"utf8mb4_croatian_ci": 245,
"utf8mb4_unicode_520_ci": 246,
"utf8mb4_vietnamese_ci": 247,
}

View File

@@ -0,0 +1,268 @@
// Go MySQL Driver - A MySQL-Driver for Go's database/sql package
//
// Copyright 2012 The Go-MySQL-Driver Authors. All rights reserved.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at http://mozilla.org/MPL/2.0/.
package mysql
import (
"crypto/tls"
"database/sql/driver"
"errors"
"net"
"strings"
"time"
)
type mysqlConn struct {
buf buffer
netConn net.Conn
affectedRows uint64
insertId uint64
cfg *config
maxPacketAllowed int
maxWriteSize int
flags clientFlag
sequence uint8
parseTime bool
strict bool
}
type config struct {
user string
passwd string
net string
addr string
dbname string
params map[string]string
loc *time.Location
tls *tls.Config
timeout time.Duration
collation uint8
allowAllFiles bool
allowOldPasswords bool
clientFoundRows bool
}
// Handles parameters set in DSN after the connection is established
func (mc *mysqlConn) handleParams() (err error) {
for param, val := range mc.cfg.params {
switch param {
// Charset
case "charset":
charsets := strings.Split(val, ",")
for i := range charsets {
// ignore errors here - a charset may not exist
err = mc.exec("SET NAMES " + charsets[i])
if err == nil {
break
}
}
if err != nil {
return
}
// time.Time parsing
case "parseTime":
var isBool bool
mc.parseTime, isBool = readBool(val)
if !isBool {
return errors.New("Invalid Bool value: " + val)
}
// Strict mode
case "strict":
var isBool bool
mc.strict, isBool = readBool(val)
if !isBool {
return errors.New("Invalid Bool value: " + val)
}
// Compression
case "compress":
err = errors.New("Compression not implemented yet")
return
// System Vars
default:
err = mc.exec("SET " + param + "=" + val + "")
if err != nil {
return
}
}
}
return
}
func (mc *mysqlConn) Begin() (driver.Tx, error) {
if mc.netConn == nil {
errLog.Print(ErrInvalidConn)
return nil, driver.ErrBadConn
}
err := mc.exec("START TRANSACTION")
if err == nil {
return &mysqlTx{mc}, err
}
return nil, err
}
func (mc *mysqlConn) Close() (err error) {
// Makes Close idempotent
if mc.netConn != nil {
err = mc.writeCommandPacket(comQuit)
if err == nil {
err = mc.netConn.Close()
} else {
mc.netConn.Close()
}
mc.netConn = nil
}
mc.cfg = nil
mc.buf.rd = nil
return
}
func (mc *mysqlConn) Prepare(query string) (driver.Stmt, error) {
if mc.netConn == nil {
errLog.Print(ErrInvalidConn)
return nil, driver.ErrBadConn
}
// Send command
err := mc.writeCommandPacketStr(comStmtPrepare, query)
if err != nil {
return nil, err
}
stmt := &mysqlStmt{
mc: mc,
}
// Read Result
columnCount, err := stmt.readPrepareResultPacket()
if err == nil {
if stmt.paramCount > 0 {
if err = mc.readUntilEOF(); err != nil {
return nil, err
}
}
if columnCount > 0 {
err = mc.readUntilEOF()
}
}
return stmt, err
}
func (mc *mysqlConn) Exec(query string, args []driver.Value) (driver.Result, error) {
if mc.netConn == nil {
errLog.Print(ErrInvalidConn)
return nil, driver.ErrBadConn
}
if len(args) == 0 { // no args, fastpath
mc.affectedRows = 0
mc.insertId = 0
err := mc.exec(query)
if err == nil {
return &mysqlResult{
affectedRows: int64(mc.affectedRows),
insertId: int64(mc.insertId),
}, err
}
return nil, err
}
// with args, must use prepared stmt
return nil, driver.ErrSkip
}
// Internal function to execute commands
func (mc *mysqlConn) exec(query string) error {
// Send command
err := mc.writeCommandPacketStr(comQuery, query)
if err != nil {
return err
}
// Read Result
resLen, err := mc.readResultSetHeaderPacket()
if err == nil && resLen > 0 {
if err = mc.readUntilEOF(); err != nil {
return err
}
err = mc.readUntilEOF()
}
return err
}
func (mc *mysqlConn) Query(query string, args []driver.Value) (driver.Rows, error) {
if mc.netConn == nil {
errLog.Print(ErrInvalidConn)
return nil, driver.ErrBadConn
}
if len(args) == 0 { // no args, fastpath
// Send command
err := mc.writeCommandPacketStr(comQuery, query)
if err == nil {
// Read Result
var resLen int
resLen, err = mc.readResultSetHeaderPacket()
if err == nil {
rows := new(textRows)
rows.mc = mc
if resLen == 0 {
// no columns, no more data
return emptyRows{}, nil
}
// Columns
rows.columns, err = mc.readColumns(resLen)
return rows, err
}
}
return nil, err
}
// with args, must use prepared stmt
return nil, driver.ErrSkip
}
// Gets the value of the given MySQL System Variable
// The returned byte slice is only valid until the next read
func (mc *mysqlConn) getSystemVar(name string) ([]byte, error) {
// Send command
if err := mc.writeCommandPacketStr(comQuery, "SELECT @@"+name); err != nil {
return nil, err
}
// Read Result
resLen, err := mc.readResultSetHeaderPacket()
if err == nil {
rows := new(textRows)
rows.mc = mc
if resLen > 0 {
// Columns
if err := mc.readUntilEOF(); err != nil {
return nil, err
}
}
dest := make([]driver.Value, resLen)
if err = rows.readRow(dest); err == nil {
return dest[0].([]byte), mc.readUntilEOF()
}
}
return nil, err
}

Some files were not shown because too many files have changed in this diff Show More