fix tags update validate

This commit is contained in:
mbecker20
2024-03-29 21:05:53 -07:00
parent 7b95e6b276
commit f617f91d96
2 changed files with 18 additions and 3 deletions
+13 -2
View File
@@ -1,7 +1,7 @@
use std::str::FromStr;
use anyhow::{anyhow, Context};
use futures::future::join_all;
use futures::{future::join_all, FutureExt};
use monitor_client::entities::{
alerter::{
Alerter, AlerterConfig, AlerterInfo, AlerterListItem,
@@ -41,7 +41,10 @@ use serde::{de::DeserializeOwned, Serialize};
use crate::db::db_client;
use super::cache::{deployment_status_cache, server_status_cache};
use super::{
cache::{deployment_status_cache, server_status_cache},
get_tag,
};
pub trait StateResource {
type ListItem: Serialize + Send;
@@ -193,6 +196,14 @@ pub trait StateResource {
id_or_name: &str,
tags: Vec<String>,
) -> anyhow::Result<()> {
let futures = tags
.iter()
.map(|tag| get_tag(tag).map(|tag| tag.map(|tag| tag.id)));
let tags = join_all(futures)
.await
.into_iter()
.flatten()
.collect::<Vec<_>>();
Self::coll()
.await
.update_one(
@@ -58,8 +58,12 @@ export const DeploymentLogs = ({ id }: { id: string }) => {
);
const deployment = useDeployment(id);
console.log(deployment);
if (deployment?.info.state === Types.DockerContainerState.NotDeployed)
if (
deployment?.info.state === Types.DockerContainerState.Unknown ||
deployment?.info.state === Types.DockerContainerState.NotDeployed
)
return null;
return (