[webui] move javascript function into asset
[api] move some model code out of request controller