Ejemplo n.º 1
0
func (wc *WidgetChartController) RemoveChart(r *knot.WebContext) interface{} {
	r.Config.OutputType = knot.OutputJson

	payload := map[string]interface{}{}
	if err := r.GetPayload(&payload); !helper.HandleError(err) {
		return helper.CreateResult(false, nil, err.Error())
	}
	idArray := payload["_id"].([]interface{})
	for _, id := range idArray {
		mapchart := new(colonycore.MapChart)
		mapchart.ID = id.(string)
		if err := mapchart.Delete(); !helper.HandleError(err) {
			return helper.CreateResult(false, nil, err.Error())
		}

		filechart := new(colonycore.Chart)
		filechart.ID = id.(string)

		if err := filechart.Remove(); !helper.HandleError(err) {
			return helper.CreateResult(false, nil, err.Error())
		}
	}

	return helper.CreateResult(true, payload["_id"], "")
}
Ejemplo n.º 2
0
func (w *WidgetController) RemoveWidget(r *knot.WebContext) interface{} {
	r.Config.OutputType = knot.OutputJson

	payload := map[string]interface{}{}
	if err := r.GetPayload(&payload); !helper.HandleError(err) {
		return helper.CreateResult(false, nil, err.Error())
	}

	idArray := payload["_id"].([]interface{})

	for _, id := range idArray {
		o := new(colonycore.Widget)
		o.ID = id.(string)
		if err := o.Delete(compressedSource); err != nil {
			return helper.CreateResult(false, nil, err.Error())
		}
	}

	return helper.CreateResult(true, nil, "")
}
Ejemplo n.º 3
0
func (ws *WidgetSelectorController) RemoveSelector(r *knot.WebContext) interface{} {
	r.Config.OutputType = knot.OutputJson

	payload := map[string]interface{}{}
	err := r.GetPayload(&payload)
	if !helper.HandleError(err) {
		return helper.CreateResult(false, nil, err.Error())
	}

	idArray := payload["_id"].([]interface{})

	for _, id := range idArray {
		o := new(colonycore.Selector)
		o.ID = id.(string)
		err = colonycore.Delete(o)
		if err != nil {
			return helper.CreateResult(false, nil, err.Error())
		}
	}
	return helper.CreateResult(true, nil, "")
}