Support trunk selection in frontend
This commit is contained in:
@@ -12,7 +12,8 @@ pub struct Did {
|
|||||||
did_number: String,
|
did_number: String,
|
||||||
target_type: String,
|
target_type: String,
|
||||||
target: Option<String>,
|
target: Option<String>,
|
||||||
active: bool
|
active: bool,
|
||||||
|
trunk: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Properties, PartialEq)]
|
#[derive(Properties, PartialEq)]
|
||||||
@@ -22,6 +23,7 @@ pub struct DidProps {
|
|||||||
pub target_type: String,
|
pub target_type: String,
|
||||||
pub target: String,
|
pub target: String,
|
||||||
pub active: bool,
|
pub active: bool,
|
||||||
|
pub trunk: String,
|
||||||
pub on_changed: Callback<()>
|
pub on_changed: Callback<()>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,6 +35,7 @@ pub fn DidComponent(props: &DidProps) -> Html {
|
|||||||
let target_type = use_state(||props.target_type.clone());
|
let target_type = use_state(||props.target_type.clone());
|
||||||
let target = use_state(||props.target.clone());
|
let target = use_state(||props.target.clone());
|
||||||
let active= use_state(||props.active);
|
let active= use_state(||props.active);
|
||||||
|
let trunk= use_state(||props.trunk.clone());
|
||||||
let on_changed = props.on_changed.clone();
|
let on_changed = props.on_changed.clone();
|
||||||
let dialog_ref: NodeRef = use_node_ref();
|
let dialog_ref: NodeRef = use_node_ref();
|
||||||
|
|
||||||
@@ -87,10 +90,21 @@ pub fn DidComponent(props: &DidProps) -> Html {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
target_type.set(t.value());
|
target_type.set(t.value());
|
||||||
changed.set(true);
|
changed.set(true);
|
||||||
gloo_console::log!(t.value());
|
|
||||||
}
|
}
|
||||||
)};
|
)};
|
||||||
|
|
||||||
|
let handle_trunk_change = {
|
||||||
|
let trunk = trunk.clone();
|
||||||
|
let changed = changed.clone();
|
||||||
|
Callback::from(move |event: Event| {
|
||||||
|
let t = event
|
||||||
|
.target()
|
||||||
|
.and_then(|t| t.dyn_into::<HtmlSelectElement>().ok())
|
||||||
|
.unwrap();
|
||||||
|
trunk.set(t.value());
|
||||||
|
changed.set(true);
|
||||||
|
}
|
||||||
|
)};
|
||||||
let handle_save = {
|
let handle_save = {
|
||||||
let changed = changed.clone();
|
let changed = changed.clone();
|
||||||
let did_number = did_number.clone();
|
let did_number = did_number.clone();
|
||||||
@@ -106,7 +120,8 @@ pub fn DidComponent(props: &DidProps) -> Html {
|
|||||||
did_number: (*did_number).clone(),
|
did_number: (*did_number).clone(),
|
||||||
target_type: (*target_type).clone(),
|
target_type: (*target_type).clone(),
|
||||||
target: Some((*target).clone()),
|
target: Some((*target).clone()),
|
||||||
active: (*active).clone()
|
active: (*active).clone(),
|
||||||
|
trunk: (*trunk).clone(),
|
||||||
};
|
};
|
||||||
let url = if id == 0 {
|
let url = if id == 0 {
|
||||||
API_BASE.to_string()
|
API_BASE.to_string()
|
||||||
@@ -187,6 +202,15 @@ pub fn DidComponent(props: &DidProps) -> Html {
|
|||||||
oninput={handle_target_input.clone()}
|
oninput={handle_target_input.clone()}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<select class="select select-ghost" onchange={handle_trunk_change}>
|
||||||
|
<option selected={props.trunk == "3229"}>{"3229"}</option>
|
||||||
|
<option selected={props.trunk == "3401"}>{"3401"}</option>
|
||||||
|
<option selected={props.trunk == "413"}>{"413"}</option>
|
||||||
|
<option selected={props.trunk == "435"}>{"435"}</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<input type="checkbox"
|
<input type="checkbox"
|
||||||
checked={*active}
|
checked={*active}
|
||||||
@@ -272,6 +296,7 @@ pub fn DidListComponent() -> Html {
|
|||||||
target_type={"NoService"}
|
target_type={"NoService"}
|
||||||
target={""}
|
target={""}
|
||||||
active=true
|
active=true
|
||||||
|
trunk="3229"
|
||||||
on_changed={handle_change.clone()}
|
on_changed={handle_change.clone()}
|
||||||
/>
|
/>
|
||||||
</table>
|
</table>
|
||||||
@@ -282,6 +307,7 @@ pub fn DidListComponent() -> Html {
|
|||||||
<th>{"DID number"}</th>
|
<th>{"DID number"}</th>
|
||||||
<th>{"Target type"}</th>
|
<th>{"Target type"}</th>
|
||||||
<th>{"Target"}</th>
|
<th>{"Target"}</th>
|
||||||
|
<th>{"Trunk"}</th>
|
||||||
<th>{"Active"}</th>
|
<th>{"Active"}</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -296,6 +322,7 @@ pub fn DidListComponent() -> Html {
|
|||||||
target_type={d.target_type.clone()}
|
target_type={d.target_type.clone()}
|
||||||
target={d.target.clone().unwrap_or_default()}
|
target={d.target.clone().unwrap_or_default()}
|
||||||
active ={d.active}
|
active ={d.active}
|
||||||
|
trunk = {d.trunk.clone()}
|
||||||
on_changed={handle_change.clone()}
|
on_changed={handle_change.clone()}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user