frameworkModule.controller("appIndexAnalysisConfigController", ['$scope', '$uibModalInstance', '$log', 'vatSessionService', 'orgService', 'widget',
function ($scope, $uibModalInstance, $log, vatSessionService, orgService, widget) {
    'use strict';

    $scope.widget = widget;
    $scope.model = $.extend(true, {}, widget);
    var dataSources = {
        onSave: function (data) {
            $log.debug("calling ok from appIndexAnalysisConfigController!");
            $scope.model.dataModelOptions.chartConfig = data;
            $uibModalInstance.close($scope.model);
        },
        onCancel: function () {
            $log.debug("calling cancel from appIndexAnalysisConfigController!");
            $uibModalInstance.dismiss("cancel");
        }
    };

    orgService.getOrganizationFilterList().success(function (data) {
        if (_.isEmpty(data)) {
            dataSources.orgIds = [];
        }
        else {
            dataSources.orgIds = _.pluck(data, 'id');
        }

        $scope.dataSources = dataSources;

    });
}]);