Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit b70b962

Browse files
author
test@exmaple.com
committed
rm-vm
1 parent e5ceaf0 commit b70b962

File tree

4 files changed

+138
-24
lines changed

4 files changed

+138
-24
lines changed

src/java/main/com/topcoder/direct/services/view/dto/contest/ContestStatsDTO.java

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,9 @@
5959
* Version 1.7 - Topcoder - Remove JIRA Issues Related Functionality In Direct App v1.0
6060
* - remove JIRA related functionality
6161
* </p>
62-
*
63-
* <p>
64-
* Version 1.8 - Quick72Hrs!! Topcoder - Remove VM Management Feature In Direct App version 1.0
65-
* - remove VM related functionality
66-
* </p>
6762
*
6863
* @author isv, Veve, jiajizhou86, -jacob-, TCCoder
69-
* @version 1.8
64+
* @version 1.7
7065
*/
7166
public class ContestStatsDTO implements Serializable {
7267

@@ -200,6 +195,13 @@ public static interface Aware {
200195
*/
201196
private boolean showStudioFinalFixTab;
202197

198+
/**
199+
* <p>An <code>int</code> providing the number of active VM's associated to the contest.</p>
200+
*
201+
* @since 1.4
202+
*/
203+
private int totalActiveVMNumber;
204+
203205
/**
204206
* <p>Constructs new <code>ContestStatsDTO</code> instance. This implementation does nothing.</p>
205207
*/
@@ -432,6 +434,26 @@ public void setSvn(String svn) {
432434
this.svn = svn;
433435
}
434436

437+
/**
438+
* <p>Gets the number of the active VM instances associated to the contest.</p>
439+
*
440+
* @return tht total number of active VM instances associated to the contest.
441+
* @since 1.4
442+
*/
443+
public int getTotalActiveVMNumber() {
444+
return totalActiveVMNumber;
445+
}
446+
447+
/**
448+
* <p>Sets the total number of active VM instances associated to the contest.</p>
449+
*
450+
* @param totalActiveVMNumber the number of active VM instances.
451+
* @since 1.4
452+
*/
453+
public void setTotalActiveVMNumber(int totalActiveVMNumber) {
454+
this.totalActiveVMNumber = totalActiveVMNumber;
455+
}
456+
435457
/**
436458
* <p>Set if show spec review.</p>
437459
*

src/web/WEB-INF/projectPlanner.jsp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
-
1313
- Version 1.3 (TopCoder Direct - Change Right Sidebar to pure Ajax)
1414
- Add the right sidebar script reference
15-
-
16-
- Version 1.4 (Quick72Hrs!! Topcoder - Remove VM Management Feature In Direct App version 1.0)
17-
- remove the vm related things
1815
-
1916
- Copyright (C) 2013 - 2014 TopCoder Inc., All Rights Reserved.
2017
-
@@ -452,6 +449,16 @@
452449
</div>
453450
<!-- End .bugRacesWrapper -->
454451

452+
<!-- bugRacesWrapper -->
453+
<div class="planVMWrapper">
454+
<p><label>VM Environment Cost</label></p>
455+
<p><input type="checkbox" name="useVM" title="Check if the project is planned to use VM for dev"/> Do you plan to use VM (Virtual Machine environments)
456+
457+
</p>
458+
<p><span>Based on our calculations, you should expect to spend about <span id="vmCost">$0.00</span> on VM's during the course of this project</span></p>
459+
</div>
460+
<!-- End .bugRacesWrapper -->
461+
455462
<!-- buttonBar -->
456463
<div class="buttonBar bottom">
457464
<a class="newButton1 exportToExcel fRight" href="javascript:;"><span class="btnR"><span

src/web/css/direct/projectPlanner.css

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
/* project planner */
2-
/*
3-
*
4-
* - Quick72Hrs!! Topcoder - Remove VM Management Feature In Direct App v1.0
5-
* - Remove jira related css
6-
*/
72
#mainContent.projectPlanner {
83
background: #ffffff;
94
}
@@ -142,13 +137,41 @@
142137
font-size: 13px;
143138
}
144139

140+
#area1 .projectPlanner .planVMWrapper {
141+
padding: 15px 0 20px 25px;
142+
height: 76px;
143+
line-height: 20px;
144+
border-bottom: 1px solid #a9acae;
145+
}
146+
147+
#area1 .projectPlanner .planVMWrapper input {
148+
width: 35px;
149+
line-height: 20px;
150+
padding: 0 5px;
151+
}
152+
153+
#area1 .projectPlanner .planVMWrapper p {
154+
padding-bottom: 7px;
155+
}
156+
157+
158+
#area1 .projectPlanner .planVMWrapper label {
159+
vertical-align: middle;
160+
padding-right: 8px;
161+
font-weight: bold;
162+
}
163+
145164
#area1 .projectPlanner .planBugRacesWrapper span.total {
146165
vertical-align: middle;
147166
padding-right: 8px;
148167
font-weight: bold;
149168
font-size: 13px;
150169
}
151170

171+
#vmCost {
172+
font-weight: bold;
173+
}
174+
152175
#area1 .projectPlanner .buttonBar {
153176
padding: 20px 0 0 25px;
154177
line-height: 24px;

src/web/scripts/projectPlanner.js

Lines changed: 72 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,53 @@
1111
* Version 1.2 - Topcoder - Remove JIRA Issues Related Functionality In Direct App v1.0
1212
* - remove JIRA related functionality
1313
*
14-
* Version 1.3 - Quick72Hrs!! Topcoder - Remove VM Management Feature In Direct App version 1.0
15-
* - remove VM related functionality
16-
*
1714
*
1815
* @author GreatKevin, TCCoder
19-
* @version 1.3
16+
* @version 1.2
2017
*/
2118
$(function(){
2219

2320
var contestInterval = 72;
2421
var contestDescription;
2522

23+
var updateVMCost = function (result) {
24+
25+
if (!result && ($("select[name=billingAccount]").val() <= 0 || !$('input[name=useVM]').is(":checked"))) {
26+
$("#vmCost").text("$0.00");
27+
return 0;
28+
}
29+
30+
var contests;
31+
32+
if (result) {
33+
contests = result.contests;
34+
35+
if (result.useVM == false) {
36+
return 0;
37+
}
38+
39+
} else {
40+
contests = buildProjectTree(true);
41+
42+
if(contests.circular) {
43+
contests = contests.contests;
44+
}
45+
46+
}
47+
48+
49+
var vmCost = 0;
50+
$.each(contests, function (index, c) {
51+
if (c.type == '2' || c.type == '9' || c.type == '13' || c.type == '14') {
52+
vmCost += getContestTypeValue(c.type, 'cost') * 0.15;
53+
}
54+
})
55+
56+
$("#vmCost").text('$' + vmCost.formatMoney(2));
57+
58+
return vmCost;
59+
};
60+
2661
$(':input').live('focus',function(){
2762
$(this).attr('autocomplete', 'off');
2863
});
@@ -31,6 +66,7 @@ $(function(){
3166
$("select[name=contestType]").val(0);
3267

3368
$("input[name=contestName]").live('keydown keyup paste', limitContestProjectNameChars(200));
69+
$("input[name=contestName]").live('keydown keyup paste', updateVMCost);
3470

3571
$("select[name=billingAccount]").change(function(){
3672
var billingAccountId = $(this).val();
@@ -301,6 +337,8 @@ $(function(){
301337

302338
$(this).closest('tr').find('.memberCost').text('$' + parseFloat(cost).toFixed(1));
303339
$(this).closest('tr').find('.contestFee').text('$' + parseFloat(getContestTypeContestFee(this.value)).toFixed(1));
340+
341+
updateVMCost();
304342
});
305343

306344
// delete contest row
@@ -314,6 +352,8 @@ $(function(){
314352
if ($('tr', contestTable).length <= 1) {
315353
$('.deleteContest', contestTable).addClass('hide');
316354
}
355+
356+
updateVMCost();
317357
});
318358

319359
// returns project tree for gantt chart if no circulars presents
@@ -575,6 +615,15 @@ $(function(){
575615
updateDisabledControls();
576616

577617
$("select[name=contestType]").trigger('change');
618+
619+
if (data.useVM == true) {
620+
$("input[name=useVM]").attr('checked', 'checked');
621+
}
622+
else {
623+
$("input[name=useVM]").removeAttr('checked');
624+
}
625+
626+
updateVMCost();
578627
}
579628

580629
var projectPlanUploader =
@@ -637,7 +686,7 @@ $(function(){
637686

638687
// show possible send-to-server json for generate export excel file
639688
var exportJson = {
640-
useVM : false,
689+
useVM : $("input[name=useVM]").is(":checked"),
641690
contests:contests
642691
}
643692

@@ -697,10 +746,12 @@ $(function(){
697746
calculateWidth();
698747
modalPosition();
699748

700-
var totalCost = totalContestFee + totalMemberCost;
749+
var vmCost = updateVMCost();
750+
751+
var totalCost = totalContestFee + totalMemberCost + vmCost;
701752

702753
$("#durationStat").text(((maxHours - minHours) / 24) + " Days");
703-
$("#totalStat").text(("$" + totalCost.formatMoney(0))).attr('title', 'Member Cost: $' + totalMemberCost + " Fee: $" + totalContestFee);
754+
$("#totalStat").text(("$" + totalCost.formatMoney(0))).attr('title', 'Member Cost: $' + totalMemberCost + " Fee: $" + totalContestFee + " VM Cost: $" + vmCost);
704755

705756

706757
});
@@ -814,6 +865,14 @@ $(function(){
814865

815866
// add event handler for input bug race plan
816867

868+
$("input[name=useVM]").click(function() {
869+
if($(this).is(":checked")) {
870+
updateVMCost();
871+
} else {
872+
$("#vmCost").text("$0.00");
873+
}
874+
})
875+
817876
if ($("#CopilotPostingSubmissions").length > 0) {
818877

819878
var submissionsResultCache = {};
@@ -838,7 +897,10 @@ $(function(){
838897
maxHours = value.timeEnd > maxHours ? value.timeEnd : maxHours;
839898
}
840899

841-
var totalCost = totalContestFee + totalMemberCost;
900+
901+
var vmCost = updateVMCost(result);
902+
903+
var totalCost = totalContestFee + totalMemberCost + vmCost;
842904
var totalDuration = (maxHours - minHours) / 24;
843905

844906
if(!viewType) {
@@ -847,7 +909,7 @@ $(function(){
847909
calculateWidth();
848910
modalPosition();
849911
$("#durationStat").text(totalDuration + " Days");
850-
$("#totalStat").text(("$" + totalCost.formatMoney(0))).attr('title', 'Member Cost: $' + totalMemberCost + " Fee: $" + totalContestFee);
912+
$("#totalStat").text(("$" + totalCost.formatMoney(0))).attr('title', 'Member Cost: $' + totalMemberCost + " Fee: $" + totalContestFee + " VM Cost: $" + vmCost);
851913
} else {
852914
var estHolder;
853915
if(viewType == 'list') {
@@ -884,7 +946,7 @@ $(function(){
884946
estHolder.append("<p>Duration: " + totalDuration + " days </p>");
885947
estHolder.append($("<p>Total Member Cost: $" + totalMemberCost.formatMoney(0) + "</p>").attr('title', ' Challenges Cost: $' + (totalMemberCost)));
886948
estHolder.append($("<p>Total Challenge Fee: $" + totalContestFee.formatMoney(0) + "</p>").attr('title', 'Challenges Fee: $' + (totalContestFee)));
887-
estHolder.append($("<p>Total Cost: $" + totalCost.formatMoney(0) + "</p>").attr('title', 'Member Cost: $' + totalMemberCost + " Fee: $" + totalContestFee));
949+
estHolder.append($("<p>Total Cost: $" + totalCost.formatMoney(0) + "</p>").attr('title', 'Member Cost: $' + totalMemberCost + " Fee: $" + totalContestFee + " VM Cost: $" + vmCost));
888950
estHolder.append("<p>Planned Challenge Number: " + result.contests.length + " </p>");
889951
}
890952
}

0 commit comments

Comments
 (0)