[GitHub] [skywalking-cli] kezhenxu94 commented on a change in pull request #56: Add traces search

2020-08-17 Thread GitBox


kezhenxu94 commented on a change in pull request #56:
URL: https://github.com/apache/skywalking-cli/pull/56#discussion_r471929804



##
File path: display/graph/tree/list.go
##
@@ -0,0 +1,190 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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 tree
+
+import (
+   "fmt"
+   "strings"
+
+   d "github.com/apache/skywalking-cli/display/displayable"
+   "github.com/apache/skywalking-cli/graphql/schema"
+   "github.com/apache/skywalking-cli/graphql/trace"
+
+   ui "github.com/gizak/termui/v3"
+   "github.com/gizak/termui/v3/widgets"
+   "github.com/urfave/cli"
+
+   "github.com/apache/skywalking-cli/logger"
+)
+
+const DefaultPageSize = 15
+const keymap = " Keymap "
+const cc = ""
+
+func DisplayList(ctx *cli.Context, displayable *d.Displayable) error {
+   data := displayable.Data.(schema.TraceBrief)
+   condition := displayable.Condition.(*schema.TraceQueryCondition)
+   if err := ui.Init(); err != nil {
+   logger.Log.Fatalf("failed to initialize termui: %v", err)
+   }
+   defer ui.Close()
+
+   list := widgets.NewList()
+   list.TitleStyle.Fg = ui.ColorRed
+   list.TextStyle = ui.NewStyle(ui.ColorYellow)
+   list.WrapText = false
+
+   tree := widgets.NewTree()
+   tree.TextStyle = ui.NewStyle(ui.ColorYellow)
+   tree.WrapText = false
+   tree.TitleStyle.Fg = ui.ColorRed
+
+   help := widgets.NewParagraph()
+   help.WrapText = false
+   help.Title = keymap
+   help.Text = `[k  ](fg:red,mod:bold) Scroll Up
+   [   ](fg:red,mod:bold) Scroll Up
+   [j  ](fg:red,mod:bold) Scroll Down
+   [ ](fg:red,mod:bold) Scroll Down
+   [](fg:red,mod:bold) list Page Up
+   [](fg:red,mod:bold) list Page Down   
+   [p  ](fg:red,mod:bold) list Page Up
+   [n  ](fg:red,mod:bold) list Page Down
+   [](fg:red,mod:bold) Scroll Half Page Up
+   [](fg:red,mod:bold) Scroll Half Page Down
+   [ ](fg:red,mod:bold) Scroll to Top
+   [](fg:red,mod:bold) Show Trace
+   [  ](fg:red,mod:bold) Scroll to Bottom
+   [q  ](fg:red,mod:bold) Quit
+   [](fg:red,mod:bold) Quit
+`
+   draw(list, tree, help, data, 0, ctx, condition)
+   listenTracesKeyboard(list, tree, data, ctx, help, condition)
+
+   return nil
+}
+
+func draw(list *widgets.List, tree *widgets.Tree, help *widgets.Paragraph, 
data schema.TraceBrief, showIndex int,
+   ctx *cli.Context, condition *schema.TraceQueryCondition) {
+   x, y := ui.TerminalDimensions()
+
+   if data.Total != 0 {
+   var traceID = data.Traces[showIndex].TraceIds[0]
+   list.Title = fmt.Sprintf("[ %d/%d  %s]", 
*condition.Paging.PageNum, totalPages(data.Total), traceID)
+   nodes, serviceNames := getNodeData(ctx, traceID)
+   tree.Title = fmt.Sprintf("[%s]", strings.Join(serviceNames, 
"->"))
+   tree.SetNodes(nodes)
+   list.Rows = rows(data, x/4)
+   } else {
+   noData := "no data"
+   list.Title = noData
+   tree.Title = noData
+   }
+
+   list.SetRect(0, 0, x, y)
+   tree.SetRect(x/4, 0, x, y)
+   help.SetRect(x-x/7, 0, x, y)
+   tree.ExpandAll()

Review comment:
   The reason why we cannot switch the focus between the `list` and `tree` 
is that we manually set the rectangle area of them, by placing these widgets 
into containers, the focus can be switched between them, refer to 
`skywalking-cli/display/graph/linear/linear.go`





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [skywalking-cli] kezhenxu94 commented on a change in pull request #56: Add traces search

2020-08-17 Thread GitBox


kezhenxu94 commented on a change in pull request #56:
URL: https://github.com/apache/skywalking-cli/pull/56#discussion_r471501358



##
File path: .gitmodules
##
@@ -1,3 +1,4 @@
 [submodule "query-protocol"]
path = query-protocol
url = http://github.com/apache/skywalking-query-protocol/
+branch = master

Review comment:
   > I haven't used submodules, ci errors, keep trying.
   
   This should be reverted, it doesn't fix the CI, see my changes above





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org