Skip to content

Commit 3a2c6e7

Browse files
committed
Add install wizard JS
1 parent 44218ef commit 3a2c6e7

8 files changed

Lines changed: 129 additions & 23 deletions

File tree

‎ui/index-test.html‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,8 @@ <h3>Isolation mode</h3>
14031403
<!-- CloudStack -->
14041404
<script src="scripts/ui-custom/login.js" type="text/javascript"></script>
14051405
<script src="scripts-test/cloudStack.js" type="text/javascript"></script>
1406+
<script src="scripts-test/installWizard.js" type="text/javascript"></script>
1407+
<script src="scripts/ui-custom/installWizard.js" type="text/javascript"></script>
14061408
<script src="scripts/ui-custom/projects.js" type="text/javascript"></script>
14071409
<script src="scripts-test/projects.js" type="text/javascript"></script>
14081410
<script src="scripts-test/dashboard.js" type="text/javascript"></script>

‎ui/index.jsp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,6 +1411,8 @@
14111411
<script src="scripts/ui-custom/login.js" type="text/javascript"></script>
14121412
<script src="scripts/ui-custom/projects.js" type="text/javascript"></script>
14131413
<script src="scripts/cloudStack.js" type="text/javascript"></script>
1414+
<script src="scripts/installWizard.js" type="text/javascript"></script>
1415+
<script src="scripts/ui-custom/installWizard.js" type="text/javascript"></script>
14141416
<script src="scripts/projects.js" type="text/javascript"></script>
14151417
<script src="scripts/dashboard.js" type="text/javascript"></script>
14161418
<script src="scripts/ui-custom/instanceWizard.js" type="text/javascript"></script>

‎ui/scripts-test/cloudStack.js‎

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828

2929
$(function() {
3030
var $container = $('#cloudStack3-container');
31-
31+
3232
// Login
3333
cloudStack.uiCustom.login({
3434
$container: $container,
35-
35+
3636
// Use this for checking the session, to bypass login screen
3737
bypassLoginCheck: function(args) {
3838
var disabledLogin = document.location.href.split('?')[1] == 'login=disabled';
@@ -66,13 +66,31 @@
6666
return args.response.error();
6767
},
6868

69-
// Show cloudStack main UI widget
7069
complete: function(args) {
71-
$container.cloudStack($.extend(cloudStack, {
72-
context: {
73-
users: [args.user]
70+
var context = {
71+
users: [args.user]
72+
};
73+
var cloudStackArgs = $.extend(cloudStack, {
74+
context: context
75+
});
76+
77+
// Check to invoke install wizard
78+
cloudStack.installWizard.check({
79+
context: context,
80+
response: {
81+
success: function(args) {
82+
if (args.doInstall) {
83+
cloudStack.uiCustom.installWizard({
84+
$container: $container,
85+
context: context
86+
});
87+
} else {
88+
// Show cloudStack main UI
89+
$container.cloudStack(cloudStackArgs);
90+
}
91+
}
7492
}
75-
}));
93+
});
7694
}
7795
});
7896
});

‎ui/scripts-test/installWizard.js‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
(function($, cloudStack, testData) {
2+
cloudStack.installWizard = {
3+
// Check if install wizard should be invoked
4+
check: function(args) {
5+
setTimeout(function() {
6+
args.response.success({
7+
doInstall: false
8+
});
9+
}, 100);
10+
}
11+
};
12+
}(jQuery, cloudStack, testData));

‎ui/scripts/cloudStack.js‎

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,30 @@
151151

152152
// Show cloudStack main UI widget
153153
complete: function(args) {
154-
$container.cloudStack($.extend(cloudStack, {
155-
context: {
156-
users: [args.user]
154+
var context = {
155+
users: [args.user]
156+
};
157+
var cloudStackArgs = $.extend(cloudStack, {
158+
context: context
159+
});
160+
161+
// Check to invoke install wizard
162+
cloudStack.installWizard.check({
163+
context: context,
164+
response: {
165+
success: function(args) {
166+
if (args.doInstall) {
167+
cloudStack.uiCustom.installWizard({
168+
$container: $container,
169+
context: context
170+
});
171+
} else {
172+
// Show cloudStack main UI
173+
$container.cloudStack(cloudStackArgs);
174+
}
175+
}
157176
}
158-
}));
177+
});
159178
}
160179
});
161180
});

‎ui/scripts/installWizard.js‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
(function($, cloudStack, testData) {
2+
cloudStack.installWizard = {
3+
// Check if install wizard should be invoked
4+
check: function(args) {
5+
$.ajax({
6+
url: createURL('listZones'),
7+
dataType: 'json',
8+
async: true,
9+
success: function(data) {
10+
args.response.success({
11+
doInstall: !(data.listzonesresponse.zone && data.listzonesresponse.zone.length)
12+
});
13+
}
14+
});
15+
}
16+
};
17+
}(jQuery, cloudStack, testData));
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
(function($, cloudStack, testData) {
2+
cloudStack.uiCustom.installWizard = function(args) {
3+
var context = args.context;
4+
var $installWizard = $('<div>').addClass('install-wizard');
5+
var $container = args.$container;
6+
7+
var elems = {
8+
nextButton: function() {
9+
return $('<div>').addClass('button next').html('Next');
10+
}
11+
};
12+
13+
// Layout/behavior for each step in wizard
14+
var steps = {
15+
// Welcome screen
16+
welcome: function(args) {
17+
return $.merge(
18+
$('<h1>').html('Welcome screen'),
19+
$('<p>').html('Welcome text goes here.'),
20+
$('<div>').addClass('button next').html('Next'),
21+
elems.nextButton().click(args.nextStep)
22+
);
23+
},
24+
25+
addZone: function(args) {
26+
var $zoneWizard = $('#template').find('.multi-wizard.zone-wizard').clone();
27+
28+
return $.merge(
29+
$zoneWizard.find('.steps .setup-zone'),
30+
elems.nextButton().click(function() {
31+
args.nextStep({
32+
data: {
33+
zone: cloudStack.serializeForm
34+
}
35+
});
36+
})
37+
);
38+
}
39+
};
40+
41+
$installWizard.append(steps.addZone).appendTo($container);
42+
};
43+
}(jQuery, cloudStack, testData));

‎ui/scripts/ui/widgets/listView.js‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,9 @@
441441
var $filters = $('<div></div>').addClass('filters reduced-hide');
442442
$filters.append('<label>Filter By: </label>');
443443

444-
var $filterSelect = $('<select id="filterBy"></select>').appendTo($filters);
445-
444+
var $filterSelect = $('<select></select>').appendTo($filters);
445+
$filterSelect.append('<option value="all">All</option>'); // Always appears by default
446+
446447
if (filters)
447448
$.each(filters, function(key) {
448449
var $option = $('<option>').attr({
@@ -870,21 +871,13 @@
870871

871872
createFilters($toolbar, listViewData.filters);
872873
createSearchBar($toolbar);
873-
874874
loadBody(
875875
$table,
876876
listViewData.dataProvider,
877877
listViewData.fields,
878878
false,
879879
{
880-
page: page,
881-
filterBy: {
882-
kind: $listView.find('select[id=filterBy]').val(),
883-
search: {
884-
value: $listView.find('input[type=text]').val(),
885-
by: 'name'
886-
}
887-
},
880+
page: page,
888881
ref: args.ref
889882
},
890883
actions,
@@ -935,7 +928,7 @@
935928
{
936929
page: 1,
937930
filterBy: {
938-
kind: $listView.find('select[id=filterBy]').val(),
931+
kind: $listView.find('select').val(),
939932
search: {
940933
value: $listView.find('input[type=text]').val(),
941934
by: 'name'

0 commit comments

Comments
 (0)