Example #1
0
func (w *WebGrabberController) GetLog(r *knot.WebContext) interface{} {
	r.Config.OutputType = knot.OutputJson
	w.PrepareHistoryPath()

	payload := struct {
		ID   string `json:"_id"`
		Date string `json:"date"`
	}{}
	err := r.GetPayload(&payload)
	if err != nil {
		return helper.CreateResult(false, nil, err.Error())
	}

	wg := new(colonycore.WebGrabber)
	err = colonycore.Get(wg, payload.ID)
	if err != nil {
		return helper.CreateResult(false, nil, err.Error())
	}

	o, err := toolkit.ToM(wg)
	if err != nil {
		return helper.CreateResult(false, nil, err.Error())
	}

	history := modules.NewHistory(payload.ID)
	logs := history.GetLog([]interface{}{o}, payload.Date)

	return helper.CreateResult(true, logs, "")
}
Example #2
0
func (a *DashboardController) Getlog(k *knot.WebContext) interface{} {
	k.Config.OutputType = knot.OutputJson

	a.PrepareHistoryPath()

	t := struct {
		Date   string
		NameId string
	}{}
	e := k.GetPayload(&t)
	if e != nil {
		return e.Error()
	}

	ds, _ := Getquery(t.NameId)

	hs := modules.NewHistory(t.NameId)
	logs := hs.GetLog(ds, t.Date)

	return logs
}
Example #3
0
func (w *WebGrabberController) GetHistory(r *knot.WebContext) interface{} {
	r.Config.OutputType = knot.OutputJson
	w.PrepareHistoryPath()

	payload := new(colonycore.WebGrabber)
	err := r.GetPayload(payload)
	if err != nil {
		return helper.CreateResult(false, nil, err.Error())
	}

	module := modules.NewHistory(payload.ID)
	history := module.OpenHistory()

	if reflect.ValueOf(history).Kind() == reflect.String {
		if strings.Contains(history.(string), "Cannot Open File") {
			return helper.CreateResult(false, nil, "Cannot Open File")
		}
	}

	return helper.CreateResult(true, history, "")
}
Example #4
0
func (a *DashboardController) Gethistory(k *knot.WebContext) interface{} {
	k.Config.OutputType = knot.OutputJson

	a.PrepareHistoryPath()

	t := struct {
		NameId string
	}{}
	e := k.GetPayload(&t)
	if e != nil {
		return e.Error()
	}

	hm := modules.NewHistory(t.NameId)
	hs := hm.OpenHistory()

	if reflect.ValueOf(hs).Kind() == reflect.String {
		if strings.Contains(hs.(string), "Cannot Open File") {
			return nil
		}
	}

	return hs
}