/// class PD.Manage.Modules.SyncService

PD.Manage.Modules.SyncService =
Class.extend({

    //===================================
    // FIELDS
    //===================================

    _viewGrid: null,

    //===================================
    // EVENT HANDLERS
    //===================================

    init: function (viewGrid) {
        this._viewGrid = viewGrid;
    },

    syncGroup: function (groupId) {

        var grid = this._viewGrid;

        

    },

    syncGroups: function () {

        var grid = this._viewGrid;

        

    },

    syncUser: function (userId) {

        var grid = this._viewGrid;

        PD.Shared.Dialogs.TaskStatus.open({
            config: {
                title: "Sync User"
            },
            showDetail: true,
            taskStart: function (args) {

                PD.ajax({
                    type: "POST",
                    url: PD.Path.resolve("~/Manage/ActiveDirectory/SyncUser/" + userId),
                    success: function (e) {
                        args.startPolling(e);
                    },
                    error: function (e) {
                        args.abort(e.responseJSON);
                        e.errorHandled = true;
                    }
                });

            },
            taskSuccess: function () {
                grid.refresh();
            }
        });

    },

    syncUsers: function () {

        var grid = this._viewGrid;

        PD.Shared.Dialogs.TaskStatus.open({
            config: {
                title: "Sync Users"
            },
            showDetail: true,
            taskStart: function (args) {

                PD.ajax({
                    type: "POST",
                    url: PD.Path.resolve("~/Manage/ActiveDirectory/SyncUsers"),
                    success: function (e) {
                        args.startPolling(e);
                    },
                    error: function (e) {
                        args.abort(e.responseJSON);
                        e.errorHandled = true;
                    }
                });

            },
            taskSuccess: function () {
                grid.refresh();
            }
        });

    }

});