Statistics
| Branch: | Tag: | Revision:

root / ui / templates / alt_instances.pt @ e7cf4cb8

History | View | Annotate | Download (11.4 kB)

1
<a id="create" rel="#wizard" href="#">Create New +</a>
2

    
3
<div id="instancesview" class="standard" tal:define="nodes context['nodes']">
4
    <a id="list" href="/instances/list">list view</a>
5
    <div class="instance running" tal:repeat="node nodes">
6
        <div tal:condition="node['state']=='3'" tal:omit-tag="">
7

    
8
        <div class="actions">
9
            <a href="#" class="action">Reboot</a>
10
            <a href="#" class="action">Shutdown</a>
11
            <a href="#" class="more">more &hellip;</a>
12
        </div>
13
        
14
        <div class="state">
15
            <div>Running</div>
16
            <div class="indicator" />
17
            <div class="indicator" />
18
            <div class="indicator" />
19
            <div class="indicator" />
20
        </div>
21

    
22
        <img src="static/pc.png" />
23
        <img class="os" src="static/${node['thumb']}" />
24
        <a href="#" class="name">
25
            <h5>Hostname: <span tal:replace="node['name']" /><span class="rename"></span></h5>
26
        </a>
27
        <a href="#" class="ip">
28
            <h5>IP: <span tal:replace="node['public_ip']" /></h5>
29
        </a>
30
        <br />
31
        <h5 class="storage">
32
            Show: <a href="#">disks</a> | <a href="#">networks</a> | <a href="#">group</a> | uptime: 24 days
33
        </h5>
34
        </div>
35
    </div>
36
</div>
37

    
38
<!-- the form -->
39
<form action="#">
40
	<!-- scrollable root element -->
41
	<div class="modal" id="wizard">
42
		<!-- status bar -->
43
		<ul id="status">
44
			<li class="active"><strong>1.</strong> Select image</li>
45
			<li><strong>2.</strong> Instance type</li>
46
			<li><strong>3.</strong> Review</li>
47
		</ul>
48
		<!-- scrollable items -->
49
		<div class="items">
50
			<!-- pages -->
51
			<div class="page">
52
                <h2>
53
					<strong>Step 1: </strong> Select image
54
					<em>Select an OS image to boot from</em>
55
				</h2>
56
                <ul class="tabs">
57
                    <li><a href="#">standard</a></li>
58
                    <li><a href="#">custom</a></li>
59
                </ul>
60
                <div class="panes" tal:define="images context['images']">
61
                    <ul class="pane">
62
					    <!-- standard images -->
63
					    <li>
64
						    <label for="${image['id']}" tal:repeat="image images"> 
65
                                <a tal:condition="image['type']=='standard'">
66
                                    <div class="image">
67
                                        <img tal:attributes="src image['logo']" class="image-logo" /> <strong>${image['title']}</strong><br />
68
                                        <span class="description">${image['description']}</span> 
69
                                        <span class="size">${image['size']}MB</span>
70
                                        <input class="radio" type="radio" name="image-id" id="${image['id']}" value="${image['id']}" checked="${repeat.image.start}" />
71
                                    </div>
72
                                </a>
73
						    </label> 
74
					    </li>
75
				    </ul>
76
                    <ul class="pane">
77
					    <!-- custom images -->
78
					    <li>
79
						    <label for="${image['id']}" tal:repeat="image images"> 
80
                                <a tal:condition="image['type']=='custom'">
81
                                    <div class="image">
82
                                        <img tal:attributes="src image['logo']" class="image-logo" /> <strong>${image['title']}</strong><br />
83
                                        <span class="description">${image['description']}</span> 
84
                                        <span class="size">${image['size']}MB</span>
85
                                        <input class="radio" type="radio" name="image-id" id="${image['id']}" value="${image['id']}" checked="${repeat.image.start}" />
86
                                    </div>
87
                                </a>
88
						    </label> 
89
					    </li>
90
                    </ul>
91
                </div>
92
				<button type="button" class="prev" id="cancel">Cancel</button>
93
				<button type="button" class="next right">Next &raquo;</button>
94
            </div>
95
			<div class="page">
96
				<h2>
97
					<strong>Step 2: </strong> Instance type <b></b>
98
					<em>Select CPU cores, RAM and storage space for your instance</em>
99
				</h2>
100
                <ul>
101
                    <li>
102
                        <div class="instance-type">
103
                            <label for="small">
104
                                <input type="radio" id="small" name="instance-type" value="small" checked="true" />
105
                                <strong>small</strong>
106
                            </label>
107
                        </div>
108
                        <div class="instance-type">      
109
                            <label for="medium">
110
                                <input type="radio" id="medium" name="instance-type" value="medium" />                  
111
                                <strong>medium</strong>
112
                            </label>
113
                        </div>
114
                        <div class="instance-type">
115
                            <label for="large">
116
                                <input type="radio" id="large" name="instance-type" value="large" />
117
                                <strong>large</strong>
118
                            </label>
119
                        </div>
120
                        <div class="instance-type">
121
                            <label for="custom">
122
                                <input type="radio" name="instance-type" id="custom" value="large" />
123
                                <strong>custom</strong>
124
                            </label>
125
                        </div>
126
                    </li>
127
                    <li>
128
			            <label><strong class="sliders">CPU (cores)</strong></label>
129
                        <input type="range" id="cpu" value="1" max="8" min="1" />
130
                    </li>
131
                    <li>
132
			            <label><strong class="sliders">RAM (MB)</strong></label>
133
                        <input type="range" id="ram" value="256" max="2048" min="256" step="256" />
134
                    </li>
135
                    <li>
136
		                <label><strong class="sliders">Storage (GB)</strong></label>
137
                        <input type="range" id="storage" value="5" step="1" max="100" min="2" />
138
                    </li>
139
                    <li>
140
                        <div class="cost">
141
                            Cost per hour for this VM: 20 credits | Credits currently in account: 10.000
142
                        </div>
143
                    </li>
144
                </ul>
145
				<button type="button" class="prev">&laquo; Back</button>
146
				<button type="button" class="next right">Next &raquo;</button>
147
            </div>
148
			<div class="page">
149
				<h2>
150
					<strong>Step 3: </strong> Review <b></b>
151
					<em>Confirm the settings below and create your new instance</em>
152
				</h2>
153
                <ul>
154
                    <li class="required">
155
                        <label>
156
                            <strong></strong> Instance name <span>*</span><br />
157
                            <input type="text" class="text" name="instance_name" value="My Ubuntu 10.04 x86_64 server"/>
158
                        </label>
159
                    </li>
160
                    <li>
161
                        <strong>Image:</strong> <span>Ubuntu 10.04 x86_64 server</span>
162
                    </li>
163
                    <li>
164
                        <strong>CPU:</strong> <span>2 cores</span>
165
                    </li>
166
                    <li>
167
                        <strong>RAM:</strong> <span>1024MB</span>
168
                    </li>
169
                    <li>
170
                        <strong>Storage:</strong> <span>10GB</span>
171
                    </li>
172
                    <li>
173
                        <strong>Cost per hour:</strong> <span>20 credits</span>
174
                    </li>
175
                    <li>
176
                        <strong>Remaining credits:</strong> <span>10.000</span>
177
                    </li>
178
                </ul>
179
				<button type="button" class="prev">&laquo; Back</button>
180
				<button type="button" class="next right" id="start">Create VM</button>        
181
            </div>
182
		</div>
183
	</div>
184
</form>
185

    
186
<div class="modal" id="misc">
187
    <h3>Your VM is being created!</h3>
188
    <p>Your password is:<strong> sdeEFre</strong></p>
189
    <p>Please copy this! Without it you can not connect to your VM.</p>
190
</div>
191

    
192
<script>
193
// <![CDATA[ 
194

    
195
$("#list").click(function(event){
196
    $("div#instancesview").load($("#list").attr("href"));
197
    return false;
198
});
199

    
200
$("ul.tabs").tabs("div.panes ul");
201

    
202
$(":range").rangeinput();
203

    
204
function disableSliders() {
205
    $("#cpu").attr('disabled',true);
206
    $("#ram").attr('disabled',true);
207
    $("#storage").attr('disabled',true);
208
}
209

    
210
$("#custom").click(function(event){
211
    $("#cpu").attr('disabled',false);
212
    $("#ram").attr('disabled',false);
213
    $("#storage").attr('disabled',false);
214
    $("strong.sliders").style = 'color: #778899;';
215
});
216

    
217
$("#small").click(function(event){
218
    $("#cpu").data('rangeinput').setValue(1);
219
    $("#ram").data('rangeinput').setValue(256);
220
    $("#storage").data('rangeinput').setValue(5);
221
});
222

    
223
$("#medium").click(function(event){
224
    $("#cpu").data('rangeinput').setValue(4);
225
    $("#ram").data('rangeinput').setValue(1024);
226
    $("#storage").data('rangeinput').setValue(30);
227
});
228

    
229
$("#large").click(function(event){
230
    $("#cpu").data('rangeinput').setValue(8);
231
    $("#ram").data('rangeinput').setValue(4096);
232
    $("#storage").data('rangeinput').setValue(80);
233
});
234

    
235
$("#cancel").click(function(event){
236
    $("a#create[rel]").overlay().close();
237
});
238

    
239
$("#start").click(function(event){
240
    $("a#create[rel]").overlay().close();
241

    
242
    var triggers = $("div#misc").overlay({
243
	    // some mask tweaks suitable for modal dialogs
244
	    mask: {
245
		    color: '#ebecff',
246
		    opacity: '0.9'
247
	    },
248
        top: 'center',
249
        load: 'true',
250
	    closeOnClick: 'false'  
251
    });
252
});
253

    
254
$("a#create").click(function(event){
255
    $("#wizard").scrollable().begin();
256
});
257

    
258
$("#cpu").change(function(event){
259
    $("#custom").click();
260
});
261

    
262
$("#ram").change(function(event){
263
    $("#custom").click();
264
});
265

    
266
$("#storage").change(function(event){
267
    $("#custom").click();
268
});
269

    
270
$(function() { 
271
    $("a#create[rel]").overlay({mask: '#000', effect: 'default', top: '5%'});
272

    
273
});
274

    
275
$(function() {
276
    var root = $("#wizard").scrollable();
277

    
278
    // some variables that we need
279
    var api = root.scrollable();
280

    
281
    // rangeinput with default configuration
282
    // validation logic is done inside the onBeforeSeek callback
283
    api.onBeforeSeek(function(event, i) {
284
	    // we are going 1 step backwards so no need for validation
285
	    if (api.getIndex() < i) {
286
             // 1. get current page
287
		     var page = root.find(".page").eq(api.getIndex()),
288
			 // 2. .. and all required fields inside the page
289
			 inputs = page.find(".required :input").removeClass("error"),
290
			 // 3. .. which are empty
291
			 empty = inputs.filter(function() {
292
				return $(this).val().replace(/\s*/g, '') == '';
293
			 });
294
		     // if there are empty fields, then
295
		    if (empty.length) {
296
			    // add a CSS class name "error" for empty & required fields
297
			    empty.addClass("error");
298
			    // cancel seeking of the scrollable by returning false
299
			    return false;
300
		    // everything is good
301
		    } 
302
	    }
303
	    // update status bar
304
	    $("#status li").removeClass("active").eq(i).addClass("active");
305
    });
306

    
307
    // if tab is pressed on the next button seek to next page
308
    root.find("button.next").keydown(function(e) {
309
	    if (e.keyCode == 9) {
310
		    // seeks to next tab by executing our validation routine
311
		    api.next();
312
		    e.preventDefault();
313
	    }
314
    });
315
// ]]>
316
});
317
</script>
318