summaryrefslogtreecommitdiffstats
path: root/install/ui/src/freeipa/realmdomains.js
blob: 0bd3eddaaeffd612703db106823d83c206a32bdd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*  Authors:
 *    Ana Krivokapic <akrivoka@redhat.com>
 *
 * Copyright (C) 2013 Red Hat
 * see file 'COPYING' for use and warranty information
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

define(['./ipa', './jquery', './details', './entity'], function (IPA, $) {

    IPA.realmdomains = {};

    IPA.realmdomains.entity = function (spec) {

        spec = spec || {};
        spec.defines_key = false;
        var that = IPA.entity(spec);

        that.init = function () {
            that.entity_init();

            that.builder.details_facet({
                factory: IPA.realmdomains_details_facet,
                title: IPA.metadata.objects.realmdomains.label,
                sections: [
                    {
                        name: 'identity',
                        label: '@i18n:objects.realmdomains.identity',
                        fields: [
                            {
                                name: 'associateddomain',
                                type: 'multivalued'
                            }
                        ]
                    }
                ],
                needs_update: true
            });
        };
        return that;
    };

    IPA.realmdomains_details_facet = function (spec) {
        spec = spec || {};
        var that = IPA.details_facet(spec);

        that.update = function (on_success, on_error) {
            var command = that.create_update_command();

            command.on_success = function (data, text_status, xhr) {
                that.update_on_success(data, text_status, xhr);
                if (on_success) on_success.call(this, data, text_status, xhr);
            };

            command.on_error = function (xhr, text_status, error_thrown) {
                that.update_on_error(xhr, text_status, error_thrown);
                if (on_error) on_error.call(this, xhr, text_status, error_thrown);
            };

            var dialog = IPA.confirm_dialog({
                title: IPA.messages.objects.realmdomains.check_dns,
                message: '@i18n:objects.realmdomains.check_dns_confirmation',
                ok_label: '@i18n:objects.realmdomains.check_dns',
                on_ok: function () {
                    command.execute();
                }
            });

            var cancel_button = dialog.get_button('cancel');
            dialog.buttons.remove('cancel');

            dialog.create_button({
                name: 'force',
                label: '@i18n:objects.realmdomains.force_update',
                visible: true,
                click: function () {
                    command.set_option('force', true);
                    command.execute();
                    dialog.close();
                }
            });

            dialog.add_button(cancel_button);
            dialog.open();
        };

        return that;
    };

    IPA.register('realmdomains', IPA.realmdomains.entity);

    return {};
});