|
33 |
"dojo/_base/lang", |
33 |
"dojo/_base/lang", |
34 |
"dojo/_base/array", |
34 |
"dojo/_base/array", |
35 |
"umc/tools", |
35 |
"umc/tools", |
36 |
"umc/widgets/Form", |
36 |
"umc/widgets/StandbyMixin", |
37 |
"umc/widgets/Page", |
37 |
"umc/modules/appcenter/AppCenterPage", |
38 |
"umc/widgets/MultiSelect", |
|
|
39 |
"umc/i18n!umc/modules/setup" |
38 |
"umc/i18n!umc/modules/setup" |
40 |
], function(declare, lang, array, tools, Form, Page, MultiSelect, _) { |
39 |
], function(declare, lang, array, tools, StandbyMixin, AppCenterPage, _) { |
41 |
|
40 |
|
42 |
return declare("umc.modules.setup.SoftwarePage", [ Page ], { |
41 |
return declare("umc.modules.setup.SoftwarePage", [ AppCenterPage, StandbyMixin ], { |
43 |
// summary: |
42 |
liveSearch: false, |
44 |
// This class renderes a detail page containing subtabs and form elements |
43 |
addMissingAppButton: false, |
45 |
// in order to edit UDM objects. |
44 |
standbyDuringUpdateApplications: false, |
46 |
|
45 |
|
47 |
// system-setup-boot |
46 |
title: _('Software'), |
48 |
wizard_mode: false, |
47 |
headerText: _('Software settings'), |
|
|
48 |
helpText: _('Via the <i>software settings</i>, particular software components may be installed or removed.'), |
49 |
|
49 |
|
50 |
// __systemsetup__ user is logged in at local firefox session |
50 |
getAppCenterSeen: function() { |
51 |
local_mode: false, |
51 |
return true; |
52 |
|
|
|
53 |
umcpCommand: tools.umcpCommand, |
54 |
|
55 |
// internal reference to the formular containing all form widgets of an UDM object |
56 |
_form: null, |
57 |
|
58 |
_orgComponents: undefined, |
59 |
|
60 |
_noteShowed: false, |
61 |
|
62 |
postMixInProperties: function() { |
63 |
this.inherited(arguments); |
64 |
|
65 |
this.title = _('Software'); |
66 |
this.headerText = _('Software settings'); |
67 |
this.helpText = _('Via the <i>software settings</i>, particular software components may be installed or removed.'); |
68 |
}, |
52 |
}, |
69 |
|
53 |
|
70 |
buildRendering: function() { |
54 |
showDetails: function(app) { |
71 |
this.inherited(arguments); |
55 |
// do not show anything. toggle installed flag |
72 |
|
56 |
app.is_installed = !app.is_installed; |
73 |
var widgets = [{ |
57 |
this._grid.store.notify(app, app.id); |
74 |
type: MultiSelect, |
58 |
// TODO: show warning? notes? |
75 |
name: 'components', |
|
|
76 |
label: _('Installed software components'), |
77 |
umcpCommand: this.umcpCommand, |
78 |
dynamicValues: 'setup/software/components', |
79 |
dynamicOptions: {}, |
80 |
sortDynamicValues: false, |
81 |
style: 'width: 500px;', |
82 |
height: '200px' |
83 |
}]; |
84 |
|
85 |
var layout = [{ |
86 |
label: _('Installation of software components'), |
87 |
layout: ['components'] |
88 |
}]; |
89 |
|
90 |
this._form = new Form({ |
91 |
widgets: widgets, |
92 |
layout: layout, |
93 |
scrollable: true |
94 |
}); |
95 |
this._form.on('submit', lang.hitch(this, 'onSave')); |
96 |
|
97 |
this.addChild(this._form); |
98 |
|
99 |
// show notes when samba 3/4 is selected |
100 |
this.own(this._form.getWidget('components').watch('value', lang.hitch(this, function(name, oldVal, newVal) { |
101 |
array.forEach(['samba', 'samba4'], function(ikey) { |
102 |
var r = new RegExp('univention-' + ikey + '\\b'); |
103 |
if (array.some(this._getInstalledComponents(), function(icomponent) { return (r.test(icomponent)); }, this)) { |
104 |
this._showNote(ikey); |
105 |
} |
106 |
}, this); |
107 |
}))); |
108 |
|
109 |
// show notes for changes in the software settings |
110 |
this.own(this._form.getWidget('components').watch('value', lang.hitch(this, function() { |
111 |
this._showNote('software'); |
112 |
}))); |
113 |
|
114 |
// remember which notes have already been shown |
115 |
this._noteShowed = { }; |
116 |
this._myNotes = { |
117 |
samba: _('It is not possible to mix NT and Active Directory compatible domaincontroller. Make sure the existing UCS domain is NT-compatible (Samba 3).'), |
118 |
samba4: _('It is not possible to mix NT and Active Directory compatible domaincontroller. Make sure the existing UCS domain is Active Directory-compatible (Samba 4).'), |
119 |
software: _('Installing or removing software components may result in restarting or stopping services. This can have severe side-effects when the system is in productive use at the moment.') |
120 |
}; |
121 |
}, |
59 |
}, |
122 |
|
60 |
|
123 |
_showNote: function(key) { |
|
|
124 |
if (!(key in this._noteShowed) || !this._form.getWidget('components').focused) { |
125 |
// make sure key exists |
126 |
return; |
127 |
} |
128 |
|
129 |
if (!this._noteShowed[key]) { |
130 |
this._noteShowed[key] = true; |
131 |
this.addNote(this._myNotes[key]); |
132 |
} |
133 |
}, |
134 |
|
135 |
setValues: function(vals) { |
61 |
setValues: function(vals) { |
136 |
// set dynamicOption to get list of components corresponding to selected system role |
62 |
this._components = lang.clone(vals.components); |
137 |
this._form.getWidget('components').set('dynamicOptions', { role: vals['server/role'] }); |
|
|
138 |
|
139 |
// get a dict of all installed components and initialise component list |
140 |
var components = (vals.components || '').split(/\s+/); |
141 |
this._form.getWidget('components').setInitialValue(components, true); |
142 |
|
143 |
if (this._orgComponents === undefined) { |
63 |
if (this._orgComponents === undefined) { |
144 |
this._orgComponents = {}; |
64 |
this._orgComponents = lang.clone(this._components); |
145 |
array.forEach(components, function(icomponent) { |
|
|
146 |
if(icomponent !== "") { |
147 |
this._orgComponents[icomponent] = true; |
148 |
} |
149 |
}, this); |
150 |
} |
65 |
} |
|
|
66 |
this.updateApplications(); |
67 |
this.set('appQuery', { |
68 |
serverrole: { |
69 |
test: function(serverrole) { |
70 |
return serverrole.length === 0 || array.indexOf(serverrole, vals['server/role']) >= 0; |
71 |
} |
72 |
} |
73 |
}); |
74 |
}, |
151 |
|
75 |
|
152 |
// handling of notes |
76 |
getApplications: function() { |
153 |
this._noteShowed = { }; |
77 |
return this._components || []; |
154 |
var role = vals['server/role']; |
|
|
155 |
if (role == 'domaincontroller_backup' || role == 'domaincontroller_slave') { |
156 |
// only show samba notes on backup/slave |
157 |
this._noteShowed.samba = false; |
158 |
this._noteShowed.samba4 = false; |
159 |
} |
160 |
// show note when changing software only on a joined system in productive mode |
161 |
this._noteShowed.software = this.wizard_mode; |
162 |
this.clearNotes(); |
163 |
}, |
78 |
}, |
164 |
|
79 |
|
165 |
getValues: function() { |
80 |
getValues: function() { |
166 |
return { |
81 |
return { |
167 |
components: this._form.getWidget('components').get('value').join(' ') |
82 |
components: this.getApplications() |
168 |
}; |
83 |
}; |
169 |
}, |
84 |
}, |
170 |
|
85 |
|
171 |
_getComponents: function() { |
|
|
172 |
// return a dict of currently selected components |
173 |
var components = {}; |
174 |
array.forEach(this._form.get('value').components, function(icomp) { |
175 |
components[icomp] = true; |
176 |
}); |
177 |
return components; |
178 |
}, |
179 |
|
180 |
_getRemovedComponents: function() { |
86 |
_getRemovedComponents: function() { |
181 |
// if a previously installed component has been deselected |
87 |
// if a previously installed component has been deselected |
182 |
// -> uninstall all its packages |
88 |
// -> uninstall all its packages |
183 |
var components = []; |
89 |
return array.filter(this._orgComponents, lang.hitch(this, function(component) { |
184 |
var selectedComponents = this._getComponents(); |
90 |
return component.is_installed && !this._grid.store.get(component.id).is_installed; |
185 |
tools.forIn(this._orgComponents, function(icomponent) { |
91 |
})); |
186 |
if (!(icomponent in selectedComponents)) { |
|
|
187 |
components.push(icomponent); |
188 |
} |
189 |
}); |
190 |
return components; |
191 |
}, |
92 |
}, |
192 |
|
93 |
|
193 |
_getInstalledComponents: function() { |
94 |
_getInstalledComponents: function() { |
194 |
// if a previously not/partly installed component has been selected |
95 |
// if a previously not/partly installed component has been selected |
195 |
// -> install all its packages |
96 |
// -> install all its packages |
196 |
var components = []; |
97 |
return array.filter(this._orgComponents, lang.hitch(this, function(component) { |
197 |
tools.forIn(this._getComponents(), function(icomponent) { |
98 |
return !component.is_installed && this._grid.store.get(component.id).is_installed; |
198 |
if (!(icomponent in this._orgComponents)) { |
99 |
})); |
199 |
components.push(icomponent); |
|
|
200 |
} |
201 |
}, this); |
202 |
return components; |
203 |
}, |
100 |
}, |
204 |
|
101 |
|
205 |
getSummary: function() { |
102 |
getSummary: function() { |
206 |
// a list of all components with their labels |
103 |
// a list of all components with their labels |
207 |
var allComponents = {}; |
104 |
var allComponents = {}; |
208 |
array.forEach(this._form.getWidget('components').getAllItems(), function(iitem) { |
105 |
array.forEach(this._grid.store.data, function(component) { |
209 |
allComponents[iitem.id] = iitem.label; |
106 |
allComponents[component.id] = component.name; |
210 |
}); |
107 |
}); |
211 |
|
108 |
|
212 |
// get changed components |
109 |
// get changed components |
|
218 |
var components = []; |
115 |
var components = []; |
219 |
if (installComponents.length) { |
116 |
if (installComponents.length) { |
220 |
components = array.map(installComponents, function(icomponent) { |
117 |
components = array.map(installComponents, function(icomponent) { |
221 |
return allComponents[icomponent]; |
118 |
return allComponents[icomponent.id]; |
222 |
}); |
119 |
}); |
223 |
result.push({ |
120 |
result.push({ |
224 |
variables: ['components'], |
121 |
variables: ['components'], |
|
228 |
} |
125 |
} |
229 |
if (removeComponents.length) { |
126 |
if (removeComponents.length) { |
230 |
components = array.map(removeComponents, function(icomponent) { |
127 |
components = array.map(removeComponents, function(icomponent) { |
231 |
return allComponents[icomponent]; |
128 |
return allComponents[icomponent.id]; |
232 |
}); |
129 |
}); |
233 |
result.push({ |
130 |
result.push({ |
234 |
variables: ['components'], |
131 |
variables: ['components'], |