show and update agentname/identifier

This commit is contained in:
Shivering Ocelot committed 2025-07-03 16:48:52 -05:00
1 parent 6530ff0a24
commit ba48846ba1
3 files changed
+109 -2

No files matched your search

+100
View File
@@ -24,6 +24,7 @@ class AgentScreen extends StatefulWidget {
class _AgentScreenState extends State<AgentScreen> {
String? _title;
String? _agentname;
final TextEditingController nameController = TextEditingController();
String description = "";
List<ConfigField> configFields = [];
@@ -51,6 +52,8 @@ class _AgentScreenState extends State<AgentScreen> {
final kindResponse = await Backend.sendAction('get-agent-kind-info', {'kind': agentEntry['kind']});
setState(() {
_title = agentEntry['name'];
_agentname = agentEntry['agentname'];
description = kindResponse['info']['description'];
});
}
@@ -106,6 +109,103 @@ class _AgentScreenState extends State<AgentScreen> {
child: Text(description),
)
),
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Align(
alignment: Alignment.centerLeft,
child: Row(
children: [
Text('agent id: ${widget.agentId}, identifier: ${_agentname}'),
ElevatedButton(
onPressed: () {
TextEditingController _textFieldController = TextEditingController();
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text('Enter new identifier'),
content: TextField(
controller: _textFieldController,
decoration: InputDecoration(hintText: "agent identifier"),
),
actions: <Widget>[
ElevatedButton(
child: Text('CANCEL'),
onPressed: () {
Navigator.pop(context);
},
),
ElevatedButton(
child: Text('OK'),
onPressed: () {
Backend.sendAction("update-agent", {
'agentId': widget.agentId,
'agentname': _textFieldController.text,
}).then((response) {
final message = response['error'] != null ?
'Error updating agent identifier.' :
'Agent identifier updated.';
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(message)),
);
});
Navigator.pop(context);
},
),
],
);
},
);
},
child: Text('Update identifier'),
),
ElevatedButton(
onPressed: () {
TextEditingController _textFieldController = TextEditingController();
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text('Enter new agent name'),
content: TextField(
controller: _textFieldController,
decoration: InputDecoration(hintText: "name"),
),
actions: <Widget>[
ElevatedButton(
child: Text('CANCEL'),
onPressed: () {
Navigator.pop(context);
},
),
ElevatedButton(
child: Text('OK'),
onPressed: () {
Backend.sendAction("update-agent", {
'agentId': widget.agentId,
'name': _textFieldController.text,
}).then((response) {
final message = response['error'] != null ?
'Error updating agent name.' :
'Agent name updated.';
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(message)),
);
});
Navigator.pop(context);
},
),
],
);
},
);
},
child: Text('Update name'),
),
]
)
)
),
ListView.builder(
shrinkWrap: true,
itemCount: configFields.length,