|
|
@@ -12,6 +12,7 @@ import (
|
|
|
"gitp78su.ipnodns.ru/svi/kern/v4/lev1/comp_spec"
|
|
|
"gitp78su.ipnodns.ru/svi/kern/v4/lev2/kctx"
|
|
|
"gitp78su.ipnodns.ru/svi/kern/v4/lev2/kspec"
|
|
|
+ "gitp78su.ipnodns.ru/svi/kern/v4/lev3/mod_ent/mod_num"
|
|
|
)
|
|
|
|
|
|
// PageModule -- страница показа модуля.
|
|
|
@@ -53,10 +54,15 @@ var strLogBlock string
|
|
|
|
|
|
// Возвращает страницу лога модуля.
|
|
|
func (sf *PageModule) postModuleLog(ctx fiber.Ctx) error {
|
|
|
- id := ctx.Params("id", "1")
|
|
|
- module, _ := sf.getModule(id)
|
|
|
+ _modNum := ctx.Params("id", "1")
|
|
|
+ resNum := mod_num.FromStr(_modNum)
|
|
|
+ if resNum.IsErr() {
|
|
|
+ return ctx.SendString(resNum.Err().Error())
|
|
|
+ }
|
|
|
+ modNum := resNum.Ok()
|
|
|
+ module, _ := sf.getModule(modNum)
|
|
|
if module == nil {
|
|
|
- strOut := strings.ReplaceAll(strLogBlock, "{.id}", id)
|
|
|
+ strOut := strings.ReplaceAll(strLogBlock, "{.id}", modNum.String())
|
|
|
strOut = strings.ReplaceAll(strOut, "{.log}", strOut)
|
|
|
strOut = strings.ReplaceAll(strOut, "{.name}", "not found")
|
|
|
strOut = strings.ReplaceAll(strOut, "{.mod_state}", "")
|
|
|
@@ -77,7 +83,7 @@ func (sf *PageModule) postModuleLog(ctx fiber.Ctx) error {
|
|
|
}
|
|
|
strOut = strings.ReplaceAll(strLogBlock, "{.log}", strOut)
|
|
|
strOut = strings.ReplaceAll(strOut, "{.name}", module.Name().Get())
|
|
|
- strOut = strings.ReplaceAll(strOut, "{.id}", id)
|
|
|
+ strOut = strings.ReplaceAll(strOut, "{.id}", _modNum)
|
|
|
return ctx.SendString(strOut)
|
|
|
}
|
|
|
|
|
|
@@ -89,10 +95,17 @@ var strCtxRowBlock string
|
|
|
|
|
|
// Возвращает блок контекста монолита.
|
|
|
func (sf *PageModule) postModuleCtx(ctx fiber.Ctx) error {
|
|
|
- id := ctx.Params("id", "1")
|
|
|
- module, _ := sf.getModule(id)
|
|
|
+ _modNum := ctx.Params("id", "1")
|
|
|
+ resNum := mod_num.FromStr(_modNum)
|
|
|
+ if resNum.IsErr() {
|
|
|
+ err := fmt.Errorf("PageModule.postModuleCtx(): in extract module num(%q), err=\n\t%w",
|
|
|
+ _modNum, resNum.Err())
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ modNum := resNum.Ok()
|
|
|
+ module, _ := sf.getModule(modNum)
|
|
|
if module == nil {
|
|
|
- strOut := strings.ReplaceAll(strCtxRowBlock, "{.id}", id)
|
|
|
+ strOut := strings.ReplaceAll(strCtxRowBlock, "{.id}", modNum.String())
|
|
|
strOut = strings.ReplaceAll(strOut, "{.name}", "not found")
|
|
|
strOut = strings.ReplaceAll(strOut, "{.ctx_block}", "")
|
|
|
return ctx.SendString(strOut)
|
|
|
@@ -124,7 +137,7 @@ func (sf *PageModule) postModuleCtx(ctx fiber.Ctx) error {
|
|
|
strOut += strRow
|
|
|
}
|
|
|
strOut = strings.ReplaceAll(strCtxRowBlock, "{.ctx_block}", strOut)
|
|
|
- strOut = strings.ReplaceAll(strOut, "{.id}", id)
|
|
|
+ strOut = strings.ReplaceAll(strOut, "{.id}", modNum.String())
|
|
|
strOut = strings.ReplaceAll(strOut, "{.name}", module.Name().Get())
|
|
|
return ctx.SendString(strOut)
|
|
|
}
|
|
|
@@ -137,8 +150,15 @@ var strStateModuleBlock string
|
|
|
|
|
|
// Показывает состояние модуля.
|
|
|
func (sf *PageModule) postModuleState(ctx fiber.Ctx) error {
|
|
|
- id := ctx.Params("id", "1")
|
|
|
- module, modVal := sf.getModule(id)
|
|
|
+ _modNum := ctx.Params("id", "1")
|
|
|
+ resNum := mod_num.FromStr(_modNum)
|
|
|
+ if resNum.IsErr() {
|
|
|
+ err := fmt.Errorf("PageModule.postModuleState(): in extract module num(%q), err=\n\t%w",
|
|
|
+ _modNum, resNum.Err())
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ modNum := resNum.Ok()
|
|
|
+ module, modVal := sf.getModule(modNum)
|
|
|
if module == nil {
|
|
|
strOut := strings.ReplaceAll(strStateModuleBlock, "{.id}", "")
|
|
|
return ctx.SendString(strOut)
|
|
|
@@ -148,7 +168,7 @@ func (sf *PageModule) postModuleState(ctx fiber.Ctx) error {
|
|
|
dictState["{.createAt}"] = modVal.CreateAt()
|
|
|
dictState["{.updateAt}"] = modVal.UpdateAt()
|
|
|
dictState["{.comment}"] = modVal.Comment()
|
|
|
- dictState["{.id}"] = id
|
|
|
+ dictState["{.id}"] = modNum.String()
|
|
|
dictState["{.live}"] = module.Live()
|
|
|
dictState["{.svg_sec}"] = module.Stat().SvgSec()
|
|
|
strOut := strStateModuleBlock
|
|
|
@@ -161,8 +181,15 @@ func (sf *PageModule) postModuleState(ctx fiber.Ctx) error {
|
|
|
|
|
|
// Показывает состояние модуля.
|
|
|
func (sf *PageModule) postModule(ctx fiber.Ctx) error {
|
|
|
- id := ctx.Params("id", "1")
|
|
|
- module, modVal := sf.getModule(id)
|
|
|
+ _modNum := ctx.Params("id", "1")
|
|
|
+ resNum := mod_num.FromStr(_modNum)
|
|
|
+ if resNum.IsErr() {
|
|
|
+ err := fmt.Errorf("PageModule.postModule(): in extract module num(%q), err=\n\t%w",
|
|
|
+ _modNum, resNum.Err())
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ modNum := resNum.Ok()
|
|
|
+ module, modVal := sf.getModule(modNum)
|
|
|
if module == nil {
|
|
|
strOut := strings.ReplaceAll(strStateModule, "{.name}", "unknown")
|
|
|
strOut = strings.ReplaceAll(strOut, "{.mod_state}", "")
|
|
|
@@ -184,7 +211,7 @@ func (sf *PageModule) postModule(ctx fiber.Ctx) error {
|
|
|
{
|
|
|
strOut = strings.ReplaceAll(strStateModule, "{.mod_state}", strOut)
|
|
|
strOut = strings.ReplaceAll(strOut, "{.name}", module.Name().Get())
|
|
|
- strOut = strings.ReplaceAll(strOut, "{.id}", id)
|
|
|
+ strOut = strings.ReplaceAll(strOut, "{.id}", modNum.String())
|
|
|
}
|
|
|
|
|
|
return ctx.SendString(strOut)
|
|
|
@@ -192,8 +219,15 @@ func (sf *PageModule) postModule(ctx fiber.Ctx) error {
|
|
|
|
|
|
// Возвращает секундную статистику модуля.
|
|
|
func (sf *PageModule) postSvgDay(ctx fiber.Ctx) error {
|
|
|
- id := ctx.Params("id", "1")
|
|
|
- module, _ := sf.getModule(id)
|
|
|
+ _modNum := ctx.Params("id", "1")
|
|
|
+ resNum := mod_num.FromStr(_modNum)
|
|
|
+ if resNum.IsErr() {
|
|
|
+ err := fmt.Errorf("PageModule.postSvgDay(): in extract module num(%q), err=\n\t%w",
|
|
|
+ _modNum, resNum.Err())
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ modNum := resNum.Ok()
|
|
|
+ module, _ := sf.getModule(modNum)
|
|
|
if module == nil {
|
|
|
return ctx.SendString("")
|
|
|
}
|
|
|
@@ -204,8 +238,15 @@ func (sf *PageModule) postSvgDay(ctx fiber.Ctx) error {
|
|
|
|
|
|
// Возвращает секундную статистику модуля.
|
|
|
func (sf *PageModule) postSvgMin(ctx fiber.Ctx) error {
|
|
|
- id := ctx.Params("id", "1")
|
|
|
- module, _ := sf.getModule(id)
|
|
|
+ _modNum := ctx.Params("id", "1")
|
|
|
+ resNum := mod_num.FromStr(_modNum)
|
|
|
+ if resNum.IsErr() {
|
|
|
+ err := fmt.Errorf("PageModule.postSvgMin(): in extract module num(%q), err=\n\t%w",
|
|
|
+ _modNum, resNum.Err())
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ modNum := resNum.Ok()
|
|
|
+ module, _ := sf.getModule(modNum)
|
|
|
if module == nil {
|
|
|
return ctx.SendString("")
|
|
|
}
|
|
|
@@ -216,8 +257,15 @@ func (sf *PageModule) postSvgMin(ctx fiber.Ctx) error {
|
|
|
|
|
|
// Возвращает секундную статистику модуля.
|
|
|
func (sf *PageModule) postSvgSec(ctx fiber.Ctx) error {
|
|
|
- id := ctx.Params("id", "1")
|
|
|
- module, _ := sf.getModule(id)
|
|
|
+ _modNum := ctx.Params("id", "1")
|
|
|
+ resNum := mod_num.FromStr(_modNum)
|
|
|
+ if resNum.IsErr() {
|
|
|
+ err := fmt.Errorf("PageModule.postSvgSec(): in extract module num(%q), err=\n\t%w",
|
|
|
+ _modNum, resNum.Err())
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ modNum := resNum.Ok()
|
|
|
+ module, _ := sf.getModule(modNum)
|
|
|
if module == nil {
|
|
|
return ctx.SendString("")
|
|
|
}
|
|
|
@@ -227,7 +275,7 @@ func (sf *PageModule) postSvgSec(ctx fiber.Ctx) error {
|
|
|
}
|
|
|
|
|
|
// Возвращает модуль.
|
|
|
-func (sf *PageModule) getModule(id string) (kspec.IKernelModule, comp_spec.ICtxValue) {
|
|
|
+func (sf *PageModule) getModule(modNum mod_num.IModNumFix) (kspec.IKernelModule, comp_spec.ICtxValue) {
|
|
|
optMonolit := sf.ctx.Get("monolit")
|
|
|
if optMonolit.IsNone() {
|
|
|
return nil, nil
|
|
|
@@ -239,7 +287,7 @@ func (sf *PageModule) getModule(id string) (kspec.IKernelModule, comp_spec.ICtxV
|
|
|
isFind bool
|
|
|
)
|
|
|
for _, val = range chLst {
|
|
|
- name := "module_" + id
|
|
|
+ name := "module_" + modNum.String()
|
|
|
if name == val.Key() {
|
|
|
isFind = true
|
|
|
break
|