aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/js/wizard/wizard.js
blob: 62a3fccbdfb158c642fdef625e04af56115dd8f3 (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
/**
 * Copyright (c) 2015, Arthur Schiwon <blizzz@owncloud.com>
 * This file is licensed under the Affero General Public License version 3 or later.
 * See the COPYING-README file.
 */

OCA = OCA || {};



/**
 * initializes the wizard and related components and kicks it off.
 */

(function() {
	var Wizard = function() {
		var detectorQueue = new OCA.LDAP.Wizard.WizardDetectorQueue();
		detectorQueue.init();

		var detectors = [];
		detectors.push(new OCA.LDAP.Wizard.WizardDetectorPort());
		detectors.push(new OCA.LDAP.Wizard.WizardDetectorBaseDN());
		detectors.push(new OCA.LDAP.Wizard.WizardDetectorEmailAttribute());
		detectors.push(new OCA.LDAP.Wizard.WizardDetectorUserDisplayNameAttribute());
		detectors.push(new OCA.LDAP.Wizard.WizardDetectorUserGroupAssociation());
		detectors.push(new OCA.LDAP.Wizard.WizardDetectorUserObjectClasses());
		detectors.push(new OCA.LDAP.Wizard.WizardDetectorGroupObjectClasses());
		detectors.push(new OCA.LDAP.Wizard.WizardDetectorGroupsForUsers());
		detectors.push(new OCA.LDAP.Wizard.WizardDetectorGroupsForGroups());
		detectors.push(new OCA.LDAP.Wizard.WizardDetectorFilterUser());
		detectors.push(new OCA.LDAP.Wizard.WizardDetectorFilterLogin());
		detectors.push(new OCA.LDAP.Wizard.WizardDetectorFilterGroup());
		detectors.push(new OCA.LDAP.Wizard.WizardDetectorUserCount());
		detectors.push(new OCA.LDAP.Wizard.WizardDetectorGroupCount());
		detectors.push(new OCA.LDAP.Wizard.WizardDetectorAvailableAttributes());
		detectors.push(new OCA.LDAP.Wizard.WizardDetectorTestLoginName());
		detectors.push(new OCA.LDAP.Wizard.WizardDetectorTestBaseDN());
		detectors.push(new OCA.LDAP.Wizard.WizardDetectorTestConfiguration());
		detectors.push(new OCA.LDAP.Wizard.WizardDetectorClearUserMappings());
		detectors.push(new OCA.LDAP.Wizard.WizardDetectorClearGroupMappings());

		var model = new OCA.LDAP.Wizard.ConfigModel();
		model.init(detectorQueue);
		// NOTE: order of detectors may play a role
		// for example, BaseDN detector needs the port. The port is typically found
		// by the Port Detector. If BaseDN detector was run first, it will not have
		// all necessary information. Only after Port Detector was executed…
		for (var i = 0; i <= detectors.length; i++) {
			model.registerDetector(detectors[i]);
		}

		var filterOnTypeFactory = new OCA.LDAP.Wizard.FilterOnTypeFactory();

		var tabs = [];
		tabs.push(new OCA.LDAP.Wizard.WizardTabUserFilter(filterOnTypeFactory, 1));
		tabs.push(new OCA.LDAP.Wizard.WizardTabLoginFilter(2));
		tabs.push(new OCA.LDAP.Wizard.WizardTabGroupFilter(filterOnTypeFactory, 3));
		tabs.push(new OCA.LDAP.Wizard.WizardTabAdvanced());
		tabs.push(new OCA.LDAP.Wizard.WizardTabExpert());

		var view = new OCA.LDAP.Wizard.WizardView(model);
		view.init();
		view.setModel(model);
		for (var j = 0; j <= tabs.length; j++) {
			view.registerTab(tabs[j], '#ldapWizard' + (j + 2));
		}

		var controller = new OCA.LDAP.Wizard.Controller();
		controller.init();
		controller.setView(view);
		controller.setModel(model);
		controller.run();
	};

	OCA.LDAP.Wizard.Wizard = Wizard;
})();

$(document).ready(function() {
	new OCA.LDAP.Wizard.Wizard();
});