graphite-dev team mailing list archive
-
graphite-dev team
-
Mailing list archive
-
Message #01790
[Merge] lp:~octplane/graphite/url_management into lp:graphite
Pierre Baillet has proposed merging lp:~octplane/graphite/url_management into lp:graphite.
Requested reviews:
graphite-dev (graphite-dev)
Related bugs:
Bug #784414 in Graphite: "Saving a MyGraph with a % in the title/vtitle does not work"
https://bugs.launchpad.net/graphite/+bug/784414
Bug #893159 in Graphite: "Share Window in Dashboard does not focus URL correctly"
https://bugs.launchpad.net/graphite/+bug/893159
Bug #893160 in Graphite: "Reloading the dashboard loses the context"
https://bugs.launchpad.net/graphite/+bug/893160
For more details, see:
https://code.launchpad.net/~octplane/graphite/url_management/+merge/82998
. Support any title in graph names ( Fix for #784414 )
. Fix Auto select url when opening share window in dashboard ( Fix for #893159 )
. Add dashboard name to # in url when editing a dashboard. Load matching dashboard upon first load (fix for #893160)
. Display render url and graph name in at top of contextual menu
--
https://code.launchpad.net/~octplane/graphite/url_management/+merge/82998
Your team graphite-dev is requested to review the proposed merge of lp:~octplane/graphite/url_management into lp:graphite.
=== modified file 'webapp/content/js/browser.js'
--- webapp/content/js/browser.js 2011-04-02 21:39:09 +0000
+++ webapp/content/js/browser.js 2011-11-22 10:49:02 +0000
@@ -121,7 +121,7 @@
if (node.attributes.graphUrl) {
var url = decodeURIComponent(node.attributes.graphUrl).replace(/#/,'%23');
- Composer.loadMyGraph(node.id, url);
+ Composer.loadMyGraph(node.attributes.text, url);
return;
}
=== modified file 'webapp/content/js/composer_widgets.js'
--- webapp/content/js/composer_widgets.js 2011-11-17 18:43:47 +0000
+++ webapp/content/js/composer_widgets.js 2011-11-22 10:49:02 +0000
@@ -333,11 +333,6 @@
return;
}
- if (text.search(/[^A-Za-z0-9_.]/) != -1) {
- Ext.Msg.alert("Graph names can only contain letters, numbers, underscores, or periods.");
- return;
- }
-
if (text.charAt(text.length - 1) == '.') {
Ext.Msg.alert("Graph names cannot end in a period.");
return;
@@ -1100,7 +1095,7 @@
return {
xtype: 'menu',
items: [
- menuInputItem("Graph Title", "title"),
+ menuInputItem("Graph Title", "title", "Graph Title", /^$/),
{text: "Y Axis", menu: yAxisMenu},
{text: "Left/Right Y Axis Options", menu: SecondYAxisMenu},
menuInputItem("Line Thickness", "lineWidth"),
@@ -1161,21 +1156,26 @@
return colorPicker;
}
-function menuInputItem(name, param, question) {
- return new Ext.menu.Item({text: name, handler: paramPrompt(question || name, param)});
+function menuInputItem(name, param, question, regexp) {
+ return new Ext.menu.Item({text: name, handler: paramPrompt(question || name, param, regexp)});
}
function menuHelpItem(name, message) {
return new Ext.menu.Item({text: name, handler: helpMessage('FYI', message)});
}
-function paramPrompt(question, param) {
+function paramPrompt(question, param, regexp) {
+
+ if(regexp == null) {
+ regexp = /[^A-Za-z0-9_.]/;
+ }
+
return function (menuItem, e) {
Ext.MessageBox.prompt(
"Input Required",
question,
function (button, value) {
- if (value.search(/[^A-Za-z0-9_.]/) != -1) {
+ if (value.search(regexp) != -1) {
Ext.Msg.alert("Input can only contain letters, numbers, underscores, or periods.");
return;
}
=== modified file 'webapp/content/js/dashboard.js'
--- webapp/content/js/dashboard.js 2011-10-21 05:32:18 +0000
+++ webapp/content/js/dashboard.js 2011-11-22 10:49:02 +0000
@@ -701,6 +701,11 @@
navBar.collapse();
}
+ if(window.location.hash != '')
+ {
+ sendLoadRequest(window.location.hash.substr(1));
+ }
+
if (initialError) {
Ext.Msg.alert("Error", initialError);
}
@@ -1351,7 +1356,7 @@
editable: false,
style: "text-align: center; font-size: large;",
listeners: {
- afterrender: function (field) { field.selectText(); }
+ focus: function (field) { field.selectText(); }
}
}
],
@@ -1473,6 +1478,49 @@
}
}
});
+
+ urlButton = new Ext.Button({
+ icon: SHARE_ICON,
+ text: (record.data.params.title || "Unamed Graph"),
+ width: gridWidth,
+ handler: function(thisButton) {
+ menu.destroy();
+ var win = new Ext.Window({
+ title: "Graph URL",
+ width: 600,
+ height: 125,
+ layout: 'border',
+ modal: true,
+ items: [
+ {
+ xtype: "label",
+ region: 'north',
+ style: "text-align: center;",
+ text: "You can use this URL to graph directly this Graph"
+ }, {
+ xtype: 'textfield',
+ region: 'center',
+ value: record.data.url,
+ editable: false,
+ style: "text-align: center; font-size: large;",
+ listeners: {
+ focus: function (field) { field.selectText(); }
+ }
+ }
+ ],
+ buttonAlign: 'center',
+ buttons: [
+ {text: "Close", handler: function () { win.close(); } }
+ ]
+ });
+ win.show();
+
+ }
+
+ });
+
+ menuItems.push(urlButton);
+
menuItems.push(targetGrid);
/* Setup our menus */
@@ -1983,6 +2031,7 @@
dashboardURL = urlparts.join('/');
document.title = name + " - Graphite Dashboard";
+ window.location.hash = name;
navBar.setTitle(name + " - (" + dashboardURL + ")");
saveButton.setText('Save "' + name + '"');
saveButton.enable();
=== modified file 'webapp/graphite/browser/views.py'
--- webapp/graphite/browser/views.py 2011-04-02 21:42:57 +0000
+++ webapp/graphite/browser/views.py 2011-11-22 10:49:02 +0000
@@ -19,6 +19,8 @@
from graphite.account.models import Profile
from graphite.util import getProfile, getProfileByUsername, defaultUser, json
from graphite.logger import log
+import hashlib
+
try:
import cPickle as pickle
except ImportError:
@@ -132,7 +134,10 @@
node.update(branchNode)
else:
- node.update( { 'id' : str(userpath_prefix + name), 'graphUrl' : str(graph.url) } )
+ m = hashlib.md5() # don't forget to "import hashlib"
+ m.update(name)
+ md5 = m.hexdigest()
+ node.update( { 'id' : str(userpath_prefix + md5), 'graphUrl' : str(graph.url) } )
node.update(leafNode)
nodes.append(node)
@@ -215,9 +220,13 @@
}
node.update(branchNode)
else: # leaf
+ m = hashlib.md5() # don't forget to "import hashlib"
+ m.update(nodeName)
+ md5 = m.hexdigest()
+
node = {
- 'text' : str(nodeName),
- 'id' : str(username + '.' + prefix + nodeName),
+ 'text' : str(nodeName ),
+ 'id' : str(username + '.' + prefix + md5),
'graphUrl' : str(graph.url),
}
node.update(leafNode)
Follow ups