checkpoint wip on components rendering

This commit is contained in:
R Tyler Croy 2023-01-30 22:21:15 -08:00
parent 9506a78da9
commit 6d8e7d1b6b
No known key found for this signature in database
GPG Key ID: E5C92681BEF6CEA2
4 changed files with 17 additions and 5 deletions

View File

@ -100,6 +100,14 @@ pub struct Agent {
}
impl Agent {
pub fn render_compact(&self, state: &AppState<'_>) -> String {
"".into()
//let data = serde_json::to_str(self).unwrap_or(serde_json::Value::Array);
//state.render("views/components/agent/compact.hbs",
// data: data).await.unwrap_or("".into())
}
pub fn can_meet(&self, needs: &Vec<String>) -> bool {
// TODO: Improve the performance of this by reducing the clones
let mut needs = needs.clone();

View File

@ -11,9 +11,12 @@ use tide::{Body, Request};
* GET /
*/
pub async fn index(req: Request<AppState<'_>>) -> Result<Body, tide::Error> {
let agents: Vec<String> = req.state().agents
.iter()
.map(|a| a.render_compact(req.state())).collect();
let params = json!({
"page": "home",
"agents" : req.state().agents,
"agents" : agents,
"config" : req.state().config,
"projects" : crate::dao::Project::list(&req.state().db).await?,
});

View File

@ -0,0 +1,4 @@
<span title="Capabilities: {{#each this.capabilities}}
* {{this.name}} {{/each}}">
{{this.name}}
</span>

View File

@ -20,10 +20,7 @@
{{#each agents}}
<tr>
<td>
<span title="Capabilities: {{#each this.capabilities}}
* {{this.name}} {{/each}}">
{{this.name}}
</span>
{{this}}
</td>
</tr>
{{/each}}