generated from VLADIMIR/template
update edit node
This commit is contained in:
parent
48e7adace0
commit
3b182d7380
@ -202,25 +202,25 @@ message GetGraphRsp {
|
||||
int32 countEdges = 4;
|
||||
|
||||
message Edge {
|
||||
int32 from = 1;
|
||||
int32 to = 2;
|
||||
string from = 1;
|
||||
string to = 2;
|
||||
string arrows = 3;
|
||||
string type = 4;
|
||||
}
|
||||
}
|
||||
|
||||
message UpdateNodeReq {
|
||||
GraphNode node = 1;
|
||||
string code = 1;
|
||||
GraphNode node = 2;
|
||||
}
|
||||
|
||||
message UpdateNodeRsp {}
|
||||
|
||||
message GraphNode {
|
||||
int32 id = 1;
|
||||
string label = 2;
|
||||
string name = 3;
|
||||
string text = 4;
|
||||
repeated GraphApplication applications = 5;
|
||||
string code = 1;
|
||||
string name = 2;
|
||||
string text = 3;
|
||||
repeated GraphApplication applications = 4;
|
||||
}
|
||||
|
||||
message GraphApplication {
|
||||
|
||||
File diff suppressed because one or more lines are too long
115
cmd/evening_detective/static/admin/assets/index-DTvRzGpy.js
Normal file
115
cmd/evening_detective/static/admin/assets/index-DTvRzGpy.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -5,8 +5,8 @@
|
||||
<link rel="icon" href="/favicon.ico">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>ВД Админка</title>
|
||||
<script type="module" crossorigin src="/assets/index-NoTmivv5.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-b0_hiwBH.css">
|
||||
<script type="module" crossorigin src="/assets/index-DTvRzGpy.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-BkyopZAN.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -211,13 +211,12 @@ func (s *Services) UpdateNode(ctx context.Context, req *proto.UpdateNodeReq) (*p
|
||||
)
|
||||
}
|
||||
node := &story_service.GraphNode{
|
||||
ID: req.Node.Id,
|
||||
Label: req.Node.Label,
|
||||
Code: req.Node.Code,
|
||||
Name: req.Node.Name,
|
||||
Text: req.Node.Text,
|
||||
Applications: applications,
|
||||
}
|
||||
if err := s.storyService.UpdatePlace(node); err != nil {
|
||||
if err := s.storyService.UpdatePlace(req.Code, node); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &proto.UpdateNodeRsp{}, nil
|
||||
@ -237,8 +236,7 @@ func (s *Services) GetGraph(ctx context.Context, req *proto.GetGraphReq) (*proto
|
||||
)
|
||||
}
|
||||
nodes = append(nodes, &proto.GraphNode{
|
||||
Id: node.ID,
|
||||
Label: node.Label,
|
||||
Code: node.Code,
|
||||
Name: node.Name,
|
||||
Text: node.Text,
|
||||
Applications: applications,
|
||||
|
||||
@ -6,16 +6,15 @@ type Graph struct {
|
||||
}
|
||||
|
||||
type GraphNode struct {
|
||||
ID int32
|
||||
Label string
|
||||
Code string
|
||||
Name string
|
||||
Text string
|
||||
Applications []*GraphApplication
|
||||
}
|
||||
|
||||
type GraphEdge struct {
|
||||
From int32
|
||||
To int32
|
||||
From string
|
||||
To string
|
||||
Type string
|
||||
}
|
||||
|
||||
|
||||
@ -96,36 +96,61 @@ func (s *StoryService) GetPlace(code string) *Place {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *StoryService) UpdatePlace(node *GraphNode) error {
|
||||
func (s *StoryService) UpdatePlace(code string, node *GraphNode) error {
|
||||
update := false
|
||||
for i := range s.story.Places {
|
||||
if s.story.Places[i].Code == node.Label {
|
||||
applications := make([]*Application, 0, len(node.Applications))
|
||||
if s.story.Places[i].Code == code {
|
||||
nodeApplications := make([]*Application, 0, len(node.Applications))
|
||||
for _, application := range node.Applications {
|
||||
applications = append(
|
||||
applications,
|
||||
nodeApplications = append(
|
||||
nodeApplications,
|
||||
&Application{
|
||||
Name: application.Name,
|
||||
},
|
||||
)
|
||||
}
|
||||
s.story.Places[i] = &Place{
|
||||
Code: s.story.Places[i].Code,
|
||||
Code: node.Code,
|
||||
Name: node.Name,
|
||||
Text: formatText(node.Text),
|
||||
Applications: applications,
|
||||
Applications: nodeApplications,
|
||||
}
|
||||
update = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !update {
|
||||
for i := range s.story.Places {
|
||||
if s.story.Places[i].Code == node.Code {
|
||||
nodeApplications := make([]*Application, 0, len(node.Applications))
|
||||
for _, application := range node.Applications {
|
||||
nodeApplications = append(
|
||||
nodeApplications,
|
||||
&Application{
|
||||
Name: application.Name,
|
||||
},
|
||||
)
|
||||
}
|
||||
s.story.Places[i] = &Place{
|
||||
Code: code,
|
||||
Name: node.Name,
|
||||
Text: formatText(node.Text),
|
||||
Applications: nodeApplications,
|
||||
}
|
||||
update = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
s.Update()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *StoryService) GetGraph(ctx context.Context) *Graph {
|
||||
m := make(map[string]int32, len(s.story.Places))
|
||||
m := make(map[string]string, len(s.story.Places))
|
||||
nodes := make([]*GraphNode, 0, len(s.story.Places))
|
||||
for i, place := range s.story.Places {
|
||||
m[clearCode(place.Code)] = int32(i)
|
||||
for _, place := range s.story.Places {
|
||||
m[clearCode(place.Code)] = place.Code
|
||||
applications := make([]*GraphApplication, 0, len(place.Applications))
|
||||
for _, application := range place.Applications {
|
||||
applications = append(
|
||||
@ -137,8 +162,7 @@ func (s *StoryService) GetGraph(ctx context.Context) *Graph {
|
||||
}
|
||||
nodes = append(
|
||||
nodes, &GraphNode{
|
||||
ID: int32(i),
|
||||
Label: place.Code,
|
||||
Code: place.Code,
|
||||
Name: place.Name,
|
||||
Text: place.Text,
|
||||
Applications: applications,
|
||||
|
||||
@ -1356,7 +1356,8 @@ func (x *GetGraphRsp) GetCountEdges() int32 {
|
||||
|
||||
type UpdateNodeReq struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Node *GraphNode `protobuf:"bytes,1,opt,name=node,proto3" json:"node,omitempty"`
|
||||
Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"`
|
||||
Node *GraphNode `protobuf:"bytes,2,opt,name=node,proto3" json:"node,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@ -1391,6 +1392,13 @@ func (*UpdateNodeReq) Descriptor() ([]byte, []int) {
|
||||
return file_main_proto_rawDescGZIP(), []int{29}
|
||||
}
|
||||
|
||||
func (x *UpdateNodeReq) GetCode() string {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *UpdateNodeReq) GetNode() *GraphNode {
|
||||
if x != nil {
|
||||
return x.Node
|
||||
@ -1436,11 +1444,10 @@ func (*UpdateNodeRsp) Descriptor() ([]byte, []int) {
|
||||
|
||||
type GraphNode struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Label string `protobuf:"bytes,2,opt,name=label,proto3" json:"label,omitempty"`
|
||||
Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Text string `protobuf:"bytes,4,opt,name=text,proto3" json:"text,omitempty"`
|
||||
Applications []*GraphApplication `protobuf:"bytes,5,rep,name=applications,proto3" json:"applications,omitempty"`
|
||||
Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"`
|
||||
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Text string `protobuf:"bytes,3,opt,name=text,proto3" json:"text,omitempty"`
|
||||
Applications []*GraphApplication `protobuf:"bytes,4,rep,name=applications,proto3" json:"applications,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@ -1475,16 +1482,9 @@ func (*GraphNode) Descriptor() ([]byte, []int) {
|
||||
return file_main_proto_rawDescGZIP(), []int{31}
|
||||
}
|
||||
|
||||
func (x *GraphNode) GetId() int32 {
|
||||
func (x *GraphNode) GetCode() string {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *GraphNode) GetLabel() string {
|
||||
if x != nil {
|
||||
return x.Label
|
||||
return x.Code
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@ -1556,8 +1556,8 @@ func (x *GraphApplication) GetName() string {
|
||||
|
||||
type GetGraphRsp_Edge struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
From int32 `protobuf:"varint,1,opt,name=from,proto3" json:"from,omitempty"`
|
||||
To int32 `protobuf:"varint,2,opt,name=to,proto3" json:"to,omitempty"`
|
||||
From string `protobuf:"bytes,1,opt,name=from,proto3" json:"from,omitempty"`
|
||||
To string `protobuf:"bytes,2,opt,name=to,proto3" json:"to,omitempty"`
|
||||
Arrows string `protobuf:"bytes,3,opt,name=arrows,proto3" json:"arrows,omitempty"`
|
||||
Type string `protobuf:"bytes,4,opt,name=type,proto3" json:"type,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
@ -1594,18 +1594,18 @@ func (*GetGraphRsp_Edge) Descriptor() ([]byte, []int) {
|
||||
return file_main_proto_rawDescGZIP(), []int{28, 0}
|
||||
}
|
||||
|
||||
func (x *GetGraphRsp_Edge) GetFrom() int32 {
|
||||
func (x *GetGraphRsp_Edge) GetFrom() string {
|
||||
if x != nil {
|
||||
return x.From
|
||||
}
|
||||
return 0
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *GetGraphRsp_Edge) GetTo() int32 {
|
||||
func (x *GetGraphRsp_Edge) GetTo() string {
|
||||
if x != nil {
|
||||
return x.To
|
||||
}
|
||||
return 0
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *GetGraphRsp_Edge) GetArrows() string {
|
||||
@ -1702,19 +1702,19 @@ const file_main_proto_rawDesc = "" +
|
||||
"countEdges\x18\x04 \x01(\x05R\n" +
|
||||
"countEdges\x1aV\n" +
|
||||
"\x04Edge\x12\x12\n" +
|
||||
"\x04from\x18\x01 \x01(\x05R\x04from\x12\x0e\n" +
|
||||
"\x02to\x18\x02 \x01(\x05R\x02to\x12\x16\n" +
|
||||
"\x04from\x18\x01 \x01(\tR\x04from\x12\x0e\n" +
|
||||
"\x02to\x18\x02 \x01(\tR\x02to\x12\x16\n" +
|
||||
"\x06arrows\x18\x03 \x01(\tR\x06arrows\x12\x12\n" +
|
||||
"\x04type\x18\x04 \x01(\tR\x04type\"G\n" +
|
||||
"\rUpdateNodeReq\x126\n" +
|
||||
"\x04node\x18\x01 \x01(\v2\".crabs.evening_detective.GraphNodeR\x04node\"\x0f\n" +
|
||||
"\rUpdateNodeRsp\"\xa8\x01\n" +
|
||||
"\tGraphNode\x12\x0e\n" +
|
||||
"\x02id\x18\x01 \x01(\x05R\x02id\x12\x14\n" +
|
||||
"\x05label\x18\x02 \x01(\tR\x05label\x12\x12\n" +
|
||||
"\x04name\x18\x03 \x01(\tR\x04name\x12\x12\n" +
|
||||
"\x04text\x18\x04 \x01(\tR\x04text\x12M\n" +
|
||||
"\fapplications\x18\x05 \x03(\v2).crabs.evening_detective.GraphApplicationR\fapplications\"&\n" +
|
||||
"\x04type\x18\x04 \x01(\tR\x04type\"[\n" +
|
||||
"\rUpdateNodeReq\x12\x12\n" +
|
||||
"\x04code\x18\x01 \x01(\tR\x04code\x126\n" +
|
||||
"\x04node\x18\x02 \x01(\v2\".crabs.evening_detective.GraphNodeR\x04node\"\x0f\n" +
|
||||
"\rUpdateNodeRsp\"\x96\x01\n" +
|
||||
"\tGraphNode\x12\x12\n" +
|
||||
"\x04code\x18\x01 \x01(\tR\x04code\x12\x12\n" +
|
||||
"\x04name\x18\x02 \x01(\tR\x04name\x12\x12\n" +
|
||||
"\x04text\x18\x03 \x01(\tR\x04text\x12M\n" +
|
||||
"\fapplications\x18\x04 \x03(\v2).crabs.evening_detective.GraphApplicationR\fapplications\"&\n" +
|
||||
"\x10GraphApplication\x12\x12\n" +
|
||||
"\x04name\x18\x01 \x01(\tR\x04name2\xe4\v\n" +
|
||||
"\x10EveningDetective\x12Y\n" +
|
||||
|
||||
@ -368,12 +368,10 @@
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"from": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
"type": "string"
|
||||
},
|
||||
"to": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
"type": "string"
|
||||
},
|
||||
"arrows": {
|
||||
"type": "string"
|
||||
@ -583,11 +581,7 @@
|
||||
"evening_detectiveGraphNode": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"label": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
@ -661,6 +655,9 @@
|
||||
"evening_detectiveUpdateNodeReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"node": {
|
||||
"$ref": "#/definitions/evening_detectiveGraphNode"
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user