This repository was archived by the owner on Jul 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathazure-pricing.tsx
More file actions
580 lines (501 loc) · 20.8 KB
/
azure-pricing.tsx
File metadata and controls
580 lines (501 loc) · 20.8 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
import * as ReactDOM from 'react-dom';
import * as React from 'react';
import { SliderComponent } from '@syncfusion/ej2-react-inputs';
import { CheckBoxComponent, ButtonComponent, ChangeEventArgs } from '@syncfusion/ej2-react-buttons';
import { SliderChangeEventArgs } from '@syncfusion/ej2-inputs';
import { DialogComponent } from '@syncfusion/ej2-react-popups';
import { SampleBase } from '../common/sample-base';
import { isNullOrUndefined } from '@syncfusion/ej2-base';
const slidercss = `
html,
body {
height: 100%;
width: 100%;
margin: 0px;
}
#pricing-slider #cloud-right-pane .btn-size {
padding-top: 16px;
padding-bottom: 30px;
border-bottom: 1px solid lightgrey;
}
#pricing-slider .e-slider-container.e-horizontal {
height: 56px;
}
#pricing-slider .row {
border: 1px solid #CCCCCC;
box-shadow: 0px 0px 4px;
opacity: 100;
border-radius: 4px;
}
.discount .e-label,
.discount .e-label {
white-space: initial;
}
#pricing-slider .sub-heading {
margin-top: -8px;
font-size: 13px;
font-family: Roboto-Regular;
color: #808080;
}
#pricing-slider .label-text.right-text {
padding-top: 16px;
padding-bottom: 20px;
}
#pricing-slider .label-text {
color: #000000;
font-size: 14px;
font-weight: 500;
}
span.e-label .offer {
color: #4A90E2;
}
.cloud-slider {
display: block;
position: relative;
}
#processor {
background-color: #A06AFF;
}
#memory {
background-color: #7ED321;
}
#storage {
background-color: #4A90E2;
}
#memory,
#storage,
#processor {
font-family: Roboto-Medium;
font-size: 14px;
height: 24px;
width: 70px;
text-align: center;
line-height: 24px;
float: right;
color: #FFFFFF;
font-weight: 500;
border-radius: 18px;
}
#cPanel,
#discount {
height: 30px;
margin-top: -10px;
width: 20px;
}
#value {
color: #000000;
font-family: Roboto-Bold;
font-size: 28px;
font-weight: bold;
}
#suffix {
color: #000000;
font-family: Roboto-Regular;
font-size: 16px;
font-weight: 500;
}
.text {
font-size: 13px;
padding-top: 26px;
width: 190px;
}
#cloud-right-pane {
background-color: #FFFFFF;
border-left: 1px solid #CCCCCC;
padding: 20px;
height: 443px;
}
.pricing-slider {
margin-top: 40px;
min-height: 20px;
margin-bottom: 20px;
}
.cloud-slider-right {
color: #000000;
font-size: 14px;
}
.cloud-slider-right.discount-pay {
padding-top: 20px;
}
#cloud-left-pane {
height: 443px;
padding: 40px;
background-color: #FAFAFA;
}
.discount {
padding-top: 20px;
padding-bottom: 35px;
}
@media (max-width: 1010px) {
#cloud-right-pane {
border-top: 1px solid #d5d7d8 !important;
border-left: none !important;
border-width: 1px 0 0!important;
padding-top: 15px !important;
padding-left: 0!important;
}
.cloud-right-content {
padding-left: 24px !important;
}
#cloud-left-pane {
width: 100%;
}
#cloud-right-pane {
width: 100%;
}
}
#cloud-slider-text {
padding-bottom: 20px;
border-bottom: 1px solid lightgrey;
}
#dollar {
color: #000000;
font-family: Roboto-Regular;
font-size: 14px;
font-weight: 500;
position: relative;
top: -7px;
}
#btn {
text-transform: uppercase;
width: -webkit-fill-available;
}
.cloud-left-slider {
margin-top: 40px;
}
.control-section {
padding-top: 0px;
margin-left: 75px;
}
@media screen and (max-width: 1199px) {
.control-section {
margin-left: 0px;
}
}
.cloud-right-content .e-btn.e-info {
padding: 0px;
width: 30px;
height: 30px;
line-height: inherit;
margin: 2px;
}
.highcontrast .pricing-slider,
.highcontrast #pricing-slider .label-text,
.highcontrast #pricing-slider .sub-heading {
color: white;
}
.fabric .cloud-right-content .e-btn.e-info,
.highcontrast .e-btn.e-info {
line-height: 2px;
}
.highcontrast #dollar,
.highcontrast #value,
.highcontrast #dialog-header,
.highcontrast #StorgeDialog,
.highcontrast #CloudDialog,
.highcontrast #processorDialog {
color: white;
}
.highcontrast #pricing-slider .row {
border: 1px solid #969696;
}
.highcontrast #cloud-right-pane {
border-left: 1px solid #969696;
}
.highcontrast #cloud-slider-text,
.highcontrast #pricing-slider #cloud-right-pane .btn-size {
border-bottom: 1px solid #969696;
}
.highcontrast #processor {
background-color: #AE80FF;
}
.highcontrast #memory {
background-color: #7ED321;
}
.highcontrast #storage {
background-color: #61A4EF;
}
.highcontrast #cloud-left-pane {
background-color: #1a1a1a;
}
.highcontrast #cloud-right-pane {
background-color: #000;
}
.highcontrast #processorPriceName,
.highcontrast #memoryPriceName,
.highcontrast #storgePriceName,
.highcontrast #cloudPriceName {
color: white;
opacity: 1;
}
#dialog-header {
color: #000000;
opacity: .87;
font-family: Roboto-Medium;
font-weight: 600;
font-size: 20px;
}
#CloudDialog {
color: #000000;
padding-top: 14px;
padding-bottom: 24px;
border-top: 1px solid #CCCCCC;
}
#processorPrice,
#memoryPrice,
#storgePrice {
opacity: 0.9;
font-family: Roboto-Bold;
font-weight: 600;
font-size: 16px;
float: right;
}
#alertDialog .e-footer-content {
padding-top: 0;
}
#processorPriceName,
#memoryPriceName,
#storgePriceName,
#cloudPriceName {
opacity: 0.9;
color: #000000;
font-family: Roboto-Regular;
font-size: 16px;
}
#cloudPrice {
opacity: 0.9;
font-family: Roboto-Bold;
font-weight: 600;
font-size: 26px;
float: right;
}
#processorDialog {
color: #000000;
padding-top: 12px;
padding-bottom: 12px;
}
#StorgeDialog {
color: #000000;
padding-top: 12px;
padding-bottom: 16px;
}
`
export class Cloudpricing extends SampleBase<{}, {}> {
public processorSlider: SliderComponent;
public memorySlider: SliderComponent;
public storageSlider: SliderComponent;
public panelCheckBox: CheckBoxComponent;
public discountCheckBox: CheckBoxComponent;
public button: ButtonComponent;
public alertDialogObj: DialogComponent;
public checkboxObj: CheckBoxComponent;
public proceessorElem: HTMLElement;
public memoryElem: HTMLElement;
public storageElem: HTMLElement;
public nullValue: string = '';
public elemValue: HTMLElement;
public finalValue: number;
public discountValue: number;
public objElements: string[] = ['#xSmallBtn', '#smallBtn', '#mediumBtn', '#largeBtn', '#xLargeBtn'];
public buttonObj: any = { obj: ButtonComponent, prop: { cssClass: 'e-info', isPrimary: true } };
public cssClass = 'e-success';
private content: string = '<div id = "dialog-content"><div id = "dialog-header">Cloud Price Details</div>' +
'<div id="processorDialog"><span id="processorPriceName">Processor Price</span><span id="processorPrice"></span></div>' +
'<div id="MemoryDialog"><span id="memoryPriceName">Memory Price</span><span id="memoryPrice"></span></div>' +
'<div id="StorgeDialog"><span id="storgePriceName">Storge Price</span><span id="storgePrice"></span></div>' +
'<div id="CloudDialog"><span id="cloudPriceName">Estimated Prices</span><span id="cloudPrice"></span></div></div>';
public showCloseIcon: any = false;
public buttons: any = [{
click: this.alertDlgBtnClick, buttonModel: { content: 'Close', isPrimary: true }
}];
public closeOnEscape: any = false;
public width: any = '360px';
public target: any = '#pricing-slider';
public animationSettings: Object = { effect: 'None' };
// //Sets processor value
public onCreateProcessor(args: any): void {
if (!isNullOrUndefined(document.getElementById('processor'))) {
document.getElementById('processor').innerHTML = (document.getElementById('processor-slider') as any).ej2_instances[0].value + ' ' + 'CORE';
}
}
public onCreateStorage(args: any): void {
if (!isNullOrUndefined(document.getElementById('storage'))) {
document.getElementById('storage').innerHTML = (document.getElementById('storage-slider') as any).ej2_instances[0].value + ' ' + 'GB';
this.sliderValueChange();
}
}
//Sets memory value
public onCreateMemory(args: any): void {
if (!isNullOrUndefined(document.getElementById('memory'))) {
document.getElementById('memory').innerHTML = (document.getElementById('memory-slider') as any).ej2_instances[0].value + ' ' + 'GB';
}
}
//Processor Slider value change method
public onChangeProcessor(args: SliderChangeEventArgs): void {
this.onChange(document.getElementById('processor'), (args.value as number), 'CORE');
}
//Memory Slider value change method
public onChangeMemory(args: SliderChangeEventArgs): void {
this.onChange(document.getElementById('memory'), (args.value as number), 'GB');
}
//Storage Slider value change method
public onChangeStorage(args: SliderChangeEventArgs): void {
this.onChange(document.getElementById('storage'), (args.value as number), 'GB');
}
//common method for Slider value change
public onChange(elem: HTMLElement, value: number, notation: string): void {
if (!isNullOrUndefined(elem)) {
elem.innerText = value + ' ' + notation;
this.sliderValueChange();
}
}
//method to calculate monthly cloud price based on slider value
public sliderValueChange(): void {
if (!isNullOrUndefined(document.getElementById('value')) && !isNullOrUndefined(document.getElementById('processor-slider'))
&& !isNullOrUndefined(document.getElementById('memory-slider')) && !isNullOrUndefined(document.getElementById('storage-slider'))) {
this.elemValue = document.getElementById('value');
let porcessorValue: any = (document.getElementById('processor-slider') as any).ej2_instances[0].value
let memoryValue: any = (document.getElementById('memory-slider') as any).ej2_instances[0].value;
let storageValue: any = (document.getElementById('storage-slider') as any).ej2_instances[0].value
//formula to calculate cloud price based on slider value
this.finalValue = Number(((((porcessorValue * memoryValue) * 1000) + ((porcessorValue * memoryValue) * storageValue)
+ ((porcessorValue * memoryValue) * 100)) / 12).toFixed(2));
if ((document.getElementById('cPanel') as any).ej2_instances && (document.getElementById('cPanel') as any).ej2_instances[0].checked) {
this.finalValue = Number((this.finalValue - 10).toFixed(2));
}
if ((document.getElementById('discount') as any).ej2_instances && (document.getElementById('discount') as any).ej2_instances[0].checked) {
this.finalValue = Number((this.finalValue - ((this.finalValue * 25) / 100)).toFixed(2));
}
this.elemValue.innerText = this.finalValue.toString();
}
}
public sliderPriceValue(processor: number, memory: number, storage: number): void {
this.processorSlider.value = processor;
this.memorySlider.value = memory;
this.storageSlider.value = storage;
}
constructor() {
super()
for (let i: number = 0; i < this.objElements.length; i++) {
this.buttonObj.obj = this.buttonObj.prop;
this.buttonObj.obj = this.objElements[i];
}
}
btnClick(e: Event) {
let processorPrice: HTMLElement = document.getElementById('processorPrice');
this.onChange(processorPrice, (this.processorSlider.value as number), 'CORE');
let memoryPrice: HTMLElement = document.getElementById('memoryPrice');
this.onChange(memoryPrice, (this.processorSlider.value as number), 'GB');
let storgePrice: HTMLElement = document.getElementById('storgePrice');
this.onChange(storgePrice, (this.storageSlider.value as number), 'GB');
let cloudPrice: HTMLElement = document.getElementById('cloudPrice');
cloudPrice.innerText = '$' + this.finalValue;
this.sliderValueChange();
(document.getElementById('alertDialog') as any).ej2_instances[0].show();
};
public alertDlgBtnClick(): void {
if (!isNullOrUndefined(document.getElementById('alertDialog')) &&
!isNullOrUndefined((document.getElementById('alertDialog') as any).ej2_instances[0])) {
(document.getElementById('alertDialog') as any).ej2_instances[0].hide();
}
}
render() {
return (
<div className='control-pane'>
<div className="col-lg-10 control-section">
<div className="cloud-content-wrapper">
<div id="pricing-slider" className="pricing-slider">
<style>{slidercss}</style>
<div className="row">
<div id="cloud-left-pane" className="col-lg-8 col-md-8 col-sm-8">
<div className="cloud-slider">
<div id="processor"></div>
<span className="label-text"> Processor </span>
{/* processor Slider element */}
<SliderComponent id="processor-slider" value={4} min={1} max={16} ref={(slider) => { this.processorSlider = slider }} change={this.onChangeProcessor.bind(this)} created={this.onCreateProcessor.bind(this)} />
<div className="sub-heading"> Each core included minimum 2.26 GHz power </div>
</div>
<div className="cloud-slider cloud-left-slider">
<div id="memory"></div>
<span className="label-text"> Memory </span>
{/* memory Slider element */}
<SliderComponent id="memory-slider" value={4} min={1} max={12} ref={(slider) => { this.memorySlider = slider }} change={this.onChangeMemory.bind(this)} created={this.onCreateMemory.bind(this)} />
<div className="sub-heading"> Equal to burstable memory included </div>
</div>
<div className="cloud-slider cloud-left-slider">
<div id="storage"></div>
<span className="label-text"> Storage </span>
{/* storage Slider element */}
<SliderComponent id="storage-slider" value={300} min={10} max={500} step={10} ref={(slider) => { this.storageSlider = slider }} change={this.onChangeStorage.bind(this)} created={this.onCreateStorage.bind(this)} />
<div className="sub-heading"> 1000 GB bandwidth per month, at 100 Mbit/s uplink port </div>
</div>
</div>
<div id="cloud-right-pane" className="col-lg-4 col-md-4 col-sm-4">
<div className="cloud-right-content">
<div className="label-text"> Size Range </div>
<div className="btn-size">
{/* Button element */}
<ButtonComponent id="xSmallBtn" cssClass='e-info' isPrimary={true} onClick={this.sliderPriceValue.bind(this, 1, 1, 10)}>XS</ButtonComponent>
{/* Button element */}
<ButtonComponent id="smallBtn" cssClass='e-info' isPrimary={true} onClick={this.sliderPriceValue.bind(this, 1, 2, 10)}>S</ButtonComponent>
{/* Button element */}
<ButtonComponent id="mediumBtn" cssClass='e-info' isPrimary={true} onClick={this.sliderPriceValue.bind(this, 4, 4, 300)}>M</ButtonComponent>
{/* Button element */}
<ButtonComponent id="largeBtn" cssClass='e-info' isPrimary={true} onClick={this.sliderPriceValue.bind(this, 12, 6, 100)}>L</ButtonComponent>
{/* Button element */}
<ButtonComponent id="xLargeBtn" cssClass='e-info' isPrimary={true} onClick={this.sliderPriceValue.bind(this, 8, 12, 300)}>XL</ButtonComponent>
</div>
<div className="label-text right-text"> ESTIMATED PRICE </div>
<div id="cloud-slider-text">
<span id="dollar">$ </span>
<span id="value"></span>
<span className="suffix">/month</span>
</div>
<div className="discount">
<div className="cloud-slider-right">
{/* cPanel Check Box element */}
<CheckBoxComponent id="cPanel" label='Not required cPanel included' checked={false} change={this.sliderValueChange.bind(this)} ></CheckBoxComponent>
</div>
<div className="cloud-slider-right discount-pay">
{/* discount Check Box element */}
<CheckBoxComponent id="discount" label='12 Months <span class = "offer" > Save 25%.</span> Pay Monthly' checked={false} ref={(scope) => { this.checkboxObj = scope; }} change={this.sliderValueChange.bind(this)} ></CheckBoxComponent>
</div>
</div>
{/* Button element */}
<div className="slider-button">
<ButtonComponent className="dlgbtn" id="btn" isPrimary={true} onClick={this.btnClick.bind(this)} ref={(button) => { this.buttonObj = button }}>Signup Now!</ButtonComponent>
</div>
<div id="dialogWrapper" className="cloud-content-wrapper">
{/* Initialize alert Dialog */}
<DialogComponent id="alertDialog" animationSettings={this.animationSettings} width='360px' content={this.content} ref={(alertdialog) => { this.alertDialogObj = alertdialog }} showCloseIcon={false}
target={this.target} visible={false} buttons={this.buttons} closeOnEscape={false}></DialogComponent>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="action-description">
<p>This sample demonstrate the cloud pricing slider which is used to calculate the cloud costs by considering Web Hosting,
VPS Hosting, Cloud Server providers. Drag the thumb over the bar for selecting Processor, Memory and Storage.
</p>
</div>
<div id="description">
<p>This sample calculates the cloud cost based on number of workloads, complexity of workloads, system and monitoring requirements
which is used under cloud operation.
</p>
<p>In this demo, we have used default rendering of slider for selecting Processor, Memory and Storage. The estimated price
for the selection will appear on the left pane.</p>
<p>We can avail 25% offer for annual pack. This can be applied by checking the checkbox from the left pane.</p>
<p>By default, cPanel will be included in the monthly pack. If you don't want, check the checkbox from the left pane which
will reduce $10 from the estimated price..</p>
<p>We can also select different range of pack from the left pane toolbar which will have default configuration based on
the range size.</p>
<p>After choosing your pack, confirm it by clicking sign up button which will show your selected package detail in a dialog
box.</p>
</div>
</div>
)
}
}