function upsertWidget(dashboardId, widget) {
            // create a copy so we don't modify the original
            widget = angular.copy(widget);

            var widgetId = widget.id;

            if (widgetId) {
                // remove the id since that would cause an api failure
                delete widget.id;
            }

            var route = widgetId ?
                $http.put(dashboardRoute + '/' + dashboardId + '/widget/' + widgetId, widget) :
                $http.post(dashboardRoute + '/' + dashboardId + '/widget', widget);

            return route.then(function (response) {
                return response.data;
            });
        }
// can be used to add a new widget or update an existing one
can be used to add a new widget or update an existing one
can be used to add a new widget or update an existing one
function upsertWidget(dashboardId, widget) {
            widget = angular.copy(widget);
            var widgetId = widget.id;
            if (widgetId) {
                delete widget.id;
            }
            var route = widgetId ?
                $http.put(dashboardRoute + '/' + dashboardId + '/widget/' + widgetId, widget) :
                $http.post(dashboardRoute + '/' + dashboardId + '/widget', widget);
            return route.then(function (response) {
                return response.data;
            });
        }
function upsertWidget ( dashboardId , widget ) { widget = angular . copy ( widget ) ; var widgetId = widget . id ; if ( widgetId ) { delete widget . id ; } var route = widgetId ? $http . put ( dashboardRoute + '/' + dashboardId + '/widget/' + widgetId , widget ) : $http . post ( dashboardRoute + '/' + dashboardId + '/widget' , widget ) ; return route . then ( function ( response ) { return response . data ; } ) ; }
can be used to add a new widget or update an existing one
can be used to add a new widget or update an existing one
// create a copy so we don't modify the original // remove the id since that would cause an api failure