浏览代码

Add show_from filter support in the web UI. (#430)

Alexey Alexandrov 6 年前
父节点
当前提交
fde099a545
没有帐户链接到提交者的电子邮件
共有 2 个文件被更改,包括 8 次插入4 次删除
  1. 6
    4
      internal/driver/webhtml.go
  2. 2
    0
      internal/driver/webui.go

+ 6
- 4
internal/driver/webhtml.go 查看文件

274
       <a title="{{.Help.ignore}}" href="?" id="ignore">Ignore</a>
274
       <a title="{{.Help.ignore}}" href="?" id="ignore">Ignore</a>
275
       <a title="{{.Help.hide}}" href="?" id="hide">Hide</a>
275
       <a title="{{.Help.hide}}" href="?" id="hide">Hide</a>
276
       <a title="{{.Help.show}}" href="?" id="show">Show</a>
276
       <a title="{{.Help.show}}" href="?" id="show">Show</a>
277
+      <a title="{{.Help.show_from}}" href="?" id="show-from">Show from</a>
277
       <hr>
278
       <hr>
278
       <a title="{{.Help.reset}}" href="?">Reset</a>
279
       <a title="{{.Help.reset}}" href="?">Reset</a>
279
     </div>
280
     </div>
754
     if (id == 'ignore') param = 'i';
755
     if (id == 'ignore') param = 'i';
755
     if (id == 'hide') param = 'h';
756
     if (id == 'hide') param = 'h';
756
     if (id == 'show') param = 's';
757
     if (id == 'show') param = 's';
758
+    if (id == 'show-from') param = 'sf';
757
 
759
 
758
     // We update on mouseenter so middle-click/right-click work properly.
760
     // We update on mouseenter so middle-click/right-click work properly.
759
     elem.addEventListener('mouseenter', updater);
761
     elem.addEventListener('mouseenter', updater);
768
 
770
 
769
       setHrefParams(elem, function (params) {
771
       setHrefParams(elem, function (params) {
770
         if (re != '') {
772
         if (re != '') {
771
-          // For focus/show, forget old parameter.  For others, add to re.
772
-          if (param != 'f' && param != 's' && params.has(param)) {
773
+          // For focus/show/show-from, forget old parameter. For others, add to re.
774
+          if (param != 'f' && param != 's' && param != 'sf' && params.has(param)) {
773
             const old = params.get(param);
775
             const old = params.get(param);
774
             if (old != '') {
776
             if (old != '') {
775
               re += '|' + old;
777
               re += '|' + old;
830
     const enable = (search.value != '' || selected.size != 0);
832
     const enable = (search.value != '' || selected.size != 0);
831
     if (buttonsEnabled == enable) return;
833
     if (buttonsEnabled == enable) return;
832
     buttonsEnabled = enable;
834
     buttonsEnabled = enable;
833
-    for (const id of ['focus', 'ignore', 'hide', 'show']) {
835
+    for (const id of ['focus', 'ignore', 'hide', 'show', 'show-from']) {
834
       const link = document.getElementById(id);
836
       const link = document.getElementById(id);
835
       if (link != null) {
837
       if (link != null) {
836
         link.classList.toggle('disabled', !enable);
838
         link.classList.toggle('disabled', !enable);
852
   }
854
   }
853
 
855
 
854
   const ids = ['topbtn', 'graphbtn', 'peek', 'list', 'disasm',
856
   const ids = ['topbtn', 'graphbtn', 'peek', 'list', 'disasm',
855
-               'focus', 'ignore', 'hide', 'show'];
857
+               'focus', 'ignore', 'hide', 'show', 'show-from'];
856
   ids.forEach(makeSearchLinkDynamic);
858
   ids.forEach(makeSearchLinkDynamic);
857
 
859
 
858
   const sampleIDs = [{{range .SampleTypes}}'{{.}}', {{end}}];
860
   const sampleIDs = [{{range .SampleTypes}}'{{.}}', {{end}}];

+ 2
- 0
internal/driver/webui.go 查看文件

200
 	for _, p := range []struct{ param, key string }{
200
 	for _, p := range []struct{ param, key string }{
201
 		{"f", "focus"},
201
 		{"f", "focus"},
202
 		{"s", "show"},
202
 		{"s", "show"},
203
+		{"sf", "show_from"},
203
 		{"i", "ignore"},
204
 		{"i", "ignore"},
204
 		{"h", "hide"},
205
 		{"h", "hide"},
205
 		{"si", "sample_index"},
206
 		{"si", "sample_index"},
232
 	vars := pprofVariables.makeCopy()
233
 	vars := pprofVariables.makeCopy()
233
 	vars["focus"].value = u.Query().Get("f")
234
 	vars["focus"].value = u.Query().Get("f")
234
 	vars["show"].value = u.Query().Get("s")
235
 	vars["show"].value = u.Query().Get("s")
236
+	vars["show_from"].value = u.Query().Get("sf")
235
 	vars["ignore"].value = u.Query().Get("i")
237
 	vars["ignore"].value = u.Query().Get("i")
236
 	vars["hide"].value = u.Query().Get("h")
238
 	vars["hide"].value = u.Query().Get("h")
237
 	vars["sample_index"].value = u.Query().Get("si")
239
 	vars["sample_index"].value = u.Query().Get("si")