Skip to content

Commit 596c4f5

Browse files
authored
Merge pull request #642 from parallaxinc/demo
Demo
2 parents 10851ec + 4c9f74c commit 596c4f5

File tree

39 files changed

+928
-514
lines changed

39 files changed

+928
-514
lines changed

CONFIGURATION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ For each provider:
3434
- Cloud session: **oauth.<provider>.enabled**. Defaults to: *false*
3535
- OAuth provider key: **oauth.<provider>.key**. No default, needs to be configured if provider is enabled.
3636
- OAuth provider secret: **oauth.<provider>.secret**. No default, needs to be configured if provider is enabled.
37-
- Callback url: **oauth.<provider>.callback**. No default, needs to be configured if provider is enabled.
37+
- Callback url: **oauth.<provider>.callback**. No default, needs to be configured if provider is enabled.

src/main/java/com/parallax/server/blocklyprop/converter/ProjectConverter.java

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,19 @@ public JsonObject toJson(ProjectRecord project) {
9797
if (project.getBasedOn() != null) {
9898
JsonObject basedOn = new JsonObject();
9999
ProjectRecord basedOnProject = projectDao.getProject(project.getBasedOn());
100-
basedOn.addProperty("id", basedOnProject.getId());
101-
basedOn.addProperty("name", basedOnProject.getName());
102-
boolean basedOnProjectisYours = basedOnProject.getIdUser().equals(BlocklyPropSecurityUtils.getCurrentUserId());
103-
basedOn.addProperty("yours", basedOnProjectisYours);
104-
if (!isYours) {
105-
basedOn.addProperty("user", userService.getUserScreenName(basedOnProject.getIdUser()));
100+
if (basedOnProject != null) {
101+
basedOn.addProperty("id", basedOnProject.getId());
102+
basedOn.addProperty("name", basedOnProject.getName());
103+
boolean basedOnProjectisYours = basedOnProject.getIdUser().equals(BlocklyPropSecurityUtils.getCurrentUserId());
104+
basedOn.addProperty("yours", basedOnProjectisYours);
105+
if (!isYours) {
106+
basedOn.addProperty("user", userService.getUserScreenName(basedOnProject.getIdUser()));
107+
}
108+
result.add("basedOn", basedOn);
106109
}
107-
result.add("basedOn", basedOn);
108110
}
109111

112+
System.out.println("project to json" + result.get("name").getAsString());
110113
return result;
111114
}
112115

@@ -130,14 +133,16 @@ public JsonObject toJson(Project project) {
130133
if (project.getBasedOn() != null) {
131134
JsonObject basedOn = new JsonObject();
132135
ProjectRecord basedOnProject = projectDao.getProject(project.getBasedOn());
133-
basedOn.addProperty("id", basedOnProject.getId());
134-
basedOn.addProperty("name", basedOnProject.getName());
135-
boolean basedOnProjectisYours = basedOnProject.getIdUser().equals(BlocklyPropSecurityUtils.getCurrentUserId());
136-
basedOn.addProperty("yours", basedOnProjectisYours);
137-
if (!isYours) {
138-
basedOn.addProperty("user", userService.getUserScreenName(basedOnProject.getIdUser()));
136+
if (basedOnProject != null) {
137+
basedOn.addProperty("id", basedOnProject.getId());
138+
basedOn.addProperty("name", basedOnProject.getName());
139+
boolean basedOnProjectisYours = basedOnProject.getIdUser().equals(BlocklyPropSecurityUtils.getCurrentUserId());
140+
basedOn.addProperty("yours", basedOnProjectisYours);
141+
if (!isYours) {
142+
basedOn.addProperty("user", userService.getUserScreenName(basedOnProject.getIdUser()));
143+
}
144+
result.add("basedOn", basedOn);
139145
}
140-
result.add("basedOn", basedOn);
141146
}
142147
return result;
143148
}

src/main/java/com/parallax/server/blocklyprop/db/dao/impl/ProjectDaoImpl.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ public ProjectRecord createProject(String name, String description, String descr
6464
return record;
6565
}
6666

67+
public ProjectRecord createProject(String name, String description, String descriptionHtml, String code, ProjectType type, String board, boolean privateProject, boolean sharedProject, Long idProjectBasedOn) {
68+
Long idUser = BlocklyPropSecurityUtils.getCurrentUserId();
69+
Long idCloudUser = BlocklyPropSecurityUtils.getCurrentSessionUserId();
70+
ProjectRecord record = create.insertInto(Tables.PROJECT, Tables.PROJECT.ID_USER, Tables.PROJECT.ID_CLOUDUSER, Tables.PROJECT.NAME, Tables.PROJECT.DESCRIPTION, Tables.PROJECT.DESCRIPTION_HTML, Tables.PROJECT.CODE, Tables.PROJECT.TYPE, Tables.PROJECT.BOARD, Tables.PROJECT.PRIVATE, Tables.PROJECT.SHARED, Tables.PROJECT.BASED_ON)
71+
.values(idUser, idCloudUser, name, description, descriptionHtml, code, type, board, privateProject, sharedProject, idProjectBasedOn).returning().fetchOne();
72+
System.out.println("Save as: " + record.getName());
73+
return record;
74+
}
75+
6776
@Override
6877
public ProjectRecord createProject(String name, String description, String descriptionHtml, ProjectType type, String board, boolean privateProject, boolean sharedProject) {
6978
return createProject(name, description, descriptionHtml, "", type, board, privateProject, sharedProject);
@@ -198,12 +207,17 @@ public ProjectRecord updateProjectCode(Long idProject, String code) {
198207

199208
@Override
200209
public ProjectRecord saveProjectCodeAs(Long idProject, String code, String newName) {
201-
ProjectRecord newProject = cloneProject(idProject);
202-
newProject.setCode(code);
203-
newProject.setName(newName);
204-
// newProject.update();
205-
create.update(Tables.PROJECT).set(Tables.PROJECT.CODE, code).set(Tables.PROJECT.NAME, newName).where(Tables.PROJECT.ID.equal(newProject.getId()));
206-
return newProject;
210+
ProjectRecord original = getProject(idProject);
211+
if (original == null) {
212+
throw new NullPointerException("Project doesn't exist");
213+
}
214+
Long idUser = BlocklyPropSecurityUtils.getCurrentUserId();
215+
if (original.getIdUser().equals(idUser) || original.getShared()) { // TODO check if friends
216+
ProjectRecord cloned = createProject(newName, original.getDescription(), original.getDescriptionHtml(), code, original.getType(), original.getBoard(), original.getPrivate(), original.getShared(), original.getId());
217+
218+
return cloned;
219+
}
220+
return null;
207221
}
208222

209223
}

src/main/resources/com/parallax/server/blocklyprop/internationalization/translations.properties

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ menu.profile = Profile
1919
menu.public-profile = Public profile
2020
menu.help = Help
2121
menu.newproject.title = New project
22-
menu.newproject.spin = Spin
22+
menu.newproject.spin = S3 Robot
2323
menu.newproject.c = Propeller C
2424

2525
footer.licenselink = License
2626
footer.changelog = Change log
2727
footer.librarieslink = External libraries
2828
footer.clientdownloadlink = BlocklyProp-client
29+
footer.appversion = v0.91
30+
footer.buildversion = 184
2931

3032
html.content_missing = Content missing
3133

@@ -50,7 +52,7 @@ help.search.submit = Search
5052
home.latest_projects.title = Latest projects
5153
home.c_project.title = C Project
5254
home.c_project.newlink = New
53-
home.spin_project.title = Spin project
55+
home.spin_project.title = S3 Robot Project
5456
home.spin_project.newlink = New
5557

5658
oauth.new-user = New user
@@ -195,7 +197,7 @@ login.forgotlink = Forgot your password?
195197
login.notconfirmedlink = Email not yet confirmed?
196198

197199
editor.newproject.title = New project
198-
editor.newproject.spin = Spin
200+
editor.newproject.spin = S3 Robot
199201
editor.newproject.c = Propeller C
200202
editor.projects.title = Projects
201203
editor.view.title = View

src/main/resources/com/parallax/server/blocklyprop/internationalization/translations_nl.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ menu.your_projects = Jouw projecten
1111
menu.project_list = Projecten lijst
1212
menu.profile = Profiel
1313

14+
footer.appversion = v0.91
15+
footer.buildversion = 184
16+
1417
home.latest_projects.title = Laatste projecten
1518
home.c_project.title = C Project
1619
home.c_project.newlink = Nieuw

src/main/resources/shiro.ini

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ securityManager.sessionManager.sessionIdCookieEnabled = true
2020
ssl.enabled = false
2121
shiro.loginUrl = /login.jsp
2222

23+
# Disable scheduler in a multi-host environment
24+
# sessionValidationScheduler = org.apache.shiro.session.mgt.ExecutorServiceSessionValidationScheduler
25+
# Default is 3,600,000 millis = 1 hour:
26+
# One day is 86,400,000 millis
27+
# sessionValidationScheduler.interval = 86400000
28+
# securityManager.sessionManager.sessionValidationScheduler = $sessionValidationScheduler
29+
30+
2331
[urls]
2432
# CDN (data, local during development) (maybe add a hotlink protection?)
2533
/cdn/** = anon

src/main/webapp/WEB-INF/includes/pageparts/footer.jsp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
</ul>
2222
<ul class="nav navbar-nav navbar-right">
2323
<jsp:useBean id="date" class="java.util.Date" />
24-
<li><a href="http://www.parallax.com" target="_blank">Parallax &copy; 2015 - <fmt:formatDate value="${date}" pattern="yyyy" /></a></li>
24+
<li><a href="http://www.parallax.com" target="_blank">
25+
<fmt:message key="footer.appversion" />.<fmt:message key="footer.buildversion" />
26+
Parallax &copy; 2015 - <fmt:formatDate value="${date}" pattern="yyyy" /></a></li>
2527
</ul>
2628
</div>
2729
</div>

src/main/webapp/cdn/blockly/generators/propc.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ var profile = {
8282
["78", "32846"], ["79", "32847"], ["80", "32848"], ["81", "32849"], ["82", "32850"], ["83", "32851"], ["84", "32852"], ["85", "32853"], ["86", "32854"], ["87", "32855"], ["88", "32856"],
8383
["89", "32857"], ["90", "32858"], ["91", "32859"], ["92", "32860"], ["92", "32861"], ["93", "32862"], ["94", "32863"], ["95", "32864"], ["96", "32865"], ["97", "32866"], ["98", "32867"],
8484
["99", "32868"], ["100", "32869"]],
85-
serial: 9600
85+
baudrate: 115200
8686
},
8787
"s3": {
8888
description: "Parallax propeller C3",
@@ -99,7 +99,7 @@ var profile = {
9999
["78", "32846"], ["79", "32847"], ["80", "32848"], ["81", "32849"], ["82", "32850"], ["83", "32851"], ["84", "32852"], ["85", "32853"], ["86", "32854"], ["87", "32855"], ["88", "32856"],
100100
["89", "32857"], ["90", "32858"], ["91", "32859"], ["92", "32860"], ["92", "32861"], ["93", "32862"], ["94", "32863"], ["95", "32864"], ["96", "32865"], ["97", "32866"], ["98", "32867"],
101101
["99", "32868"], ["100", "32869"]],
102-
serial: 9600
102+
baudrate: 9600
103103
},
104104
"heb": {
105105
description: "Parallax propeller proto board",
@@ -116,7 +116,7 @@ var profile = {
116116
["78", "32846"], ["79", "32847"], ["80", "32848"], ["81", "32849"], ["82", "32850"], ["83", "32851"], ["84", "32852"], ["85", "32853"], ["86", "32854"], ["87", "32855"], ["88", "32856"],
117117
["89", "32857"], ["90", "32858"], ["91", "32859"], ["92", "32860"], ["92", "32861"], ["93", "32862"], ["94", "32863"], ["95", "32864"], ["96", "32865"], ["97", "32866"], ["98", "32867"],
118118
["99", "32868"], ["100", "32869"]],
119-
serial: 9600
119+
baudrate: 115200
120120
},
121121
"other": {
122122
description: "Other propeller boards",
@@ -133,7 +133,7 @@ var profile = {
133133
["78", "32846"], ["79", "32847"], ["80", "32848"], ["81", "32849"], ["82", "32850"], ["83", "32851"], ["84", "32852"], ["85", "32853"], ["86", "32854"], ["87", "32855"], ["88", "32856"],
134134
["89", "32857"], ["90", "32858"], ["91", "32859"], ["92", "32860"], ["92", "32861"], ["93", "32862"], ["94", "32863"], ["95", "32864"], ["96", "32865"], ["97", "32866"], ["98", "32867"],
135135
["99", "32868"], ["100", "32869"]],
136-
serial: 9600
136+
baudrate: 115200
137137
}
138138
};
139139
function setProfile(profileName) {
@@ -142,6 +142,8 @@ function setProfile(profileName) {
142142
} else {
143143
profile["default"] = profile["other"];
144144
}
145+
146+
window.parent.setBaudrate(profile["default"]["baudrate"]);
145147
}
146148

147149
/**

src/main/webapp/cdn/blockly/generators/propc/TiltandAcceleration.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Blockly.Blocks.MX2125_acceleration_xaxis = {
3030
init: function () {
3131
this.setColour(colorPalette.getColor('input'));
3232
this.appendDummyInput()
33-
.appendField("MX2125 acceleration x-axis pin#")
33+
.appendField("Memsic acceleration x-axis PIN")
3434
.appendField(new Blockly.FieldDropdown(profile.default.digital), "PINX");
3535

3636
this.setNextStatement(false, null);
@@ -43,7 +43,7 @@ Blockly.Blocks.MX2125_acceleration_yaxis = {
4343
init: function () {
4444
this.setColour(colorPalette.getColor('input'));
4545
this.appendDummyInput()
46-
.appendField("MX2125 acceleration y-axis pin#")
46+
.appendField("Memsic acceleration y-axis PIN")
4747
.appendField(new Blockly.FieldDropdown(profile.default.digital), "PINY");
4848

4949
this.setNextStatement(false, null);
@@ -57,9 +57,9 @@ Blockly.Blocks.MX2125_rotation = {
5757
this.setColour(colorPalette.getColor('input'));
5858
this.appendDummyInput()
5959
.appendField("MX2125 rotation")
60-
.appendField("x-axis pin#")
60+
.appendField("x-axis PIN")
6161
.appendField(new Blockly.FieldDropdown(profile.default.digital), "PINX")
62-
.appendField("y-axis pin#")
62+
.appendField("y-axis PIN")
6363
.appendField(new Blockly.FieldDropdown(profile.default.digital), "PINY");
6464

6565
this.setInputsInline(true);
@@ -73,7 +73,7 @@ Blockly.Blocks.MX2125_tilt_xaxis = {
7373
init: function () {
7474
this.setColour(colorPalette.getColor('input'));
7575
this.appendDummyInput()
76-
.appendField("MX2125 tilt x-axis pin#")
76+
.appendField("Memsic tilt x-axis PIN")
7777
.appendField(new Blockly.FieldDropdown(profile.default.digital), "PINX");
7878

7979
this.setNextStatement(false, null);
@@ -86,7 +86,7 @@ Blockly.Blocks.MX2125_tilt_yaxis = {
8686
init: function () {
8787
this.setColour(colorPalette.getColor('input'));
8888
this.appendDummyInput()
89-
.appendField("MX2125 tilt y-axis pin#")
89+
.appendField("Memsic tilt y-axis PIN")
9090
.appendField(new Blockly.FieldDropdown(profile.default.digital), "PINY");
9191

9292
this.setNextStatement(false, null);
@@ -99,25 +99,25 @@ Blockly.Blocks.MMA7455_acceleration = {
9999
init: function () {
100100
this.setColour(colorPalette.getColor('input'));
101101
this.appendDummyInput()
102-
.appendField("MMA7455 x-axis pin#")
102+
.appendField("Accelerometer x-axis PIN")
103103
.appendField(new Blockly.FieldDropdown(profile.default.digital), "PINX")
104104
this.appendDummyInput()
105-
.appendField("store x-axis value")
105+
.appendField("store x value in")
106106
.appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'X_VAR');
107107
this.appendDummyInput()
108-
.appendField("MMA7455 y-axis pin#")
108+
.appendField("y-axis PIN")
109109
.appendField(new Blockly.FieldDropdown(profile.default.digital), "PINY")
110110
this.appendDummyInput()
111-
.appendField("store y-axis value")
111+
.appendField("store y value in")
112112
.appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'Y_VAR');
113113
this.appendDummyInput()
114-
.appendField("MMA7455 z-axis pin#")
114+
.appendField("z-axis PIN")
115115
.appendField(new Blockly.FieldDropdown(profile.default.digital), "PINZ")
116116
this.appendDummyInput()
117-
.appendField("store z-axis value")
117+
.appendField("store z value in")
118118
.appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'Z_VAR');
119119

120-
this.setInputsInline(true);
120+
this.setInputsInline(false);
121121
this.setNextStatement(true, null);
122122
this.setPreviousStatement(true, null);
123123
},
@@ -139,11 +139,10 @@ Blockly.Blocks.HMC5883L_init = {
139139
init: function () {
140140
this.setColour(colorPalette.getColor('input'));
141141
this.appendDummyInput()
142-
.appendField("Initialize")
143-
.appendField("SCL pin#")
142+
.appendField("Compass initialize SCL")
144143
.appendField(new Blockly.FieldDropdown(profile.default.digital), "SCL");
145144
this.appendDummyInput()
146-
.appendField("SDA pin#")
145+
.appendField("SDA")
147146
.appendField(new Blockly.FieldDropdown(profile.default.digital), "SDA");
148147

149148
this.setInputsInline(true);
@@ -156,7 +155,7 @@ Blockly.Blocks.HMC5883L_read = {
156155
init: function () {
157156
this.setColour(colorPalette.getColor('input'));
158157
this.appendDummyInput()
159-
.appendField("read heading and store in")
158+
.appendField("Compass store heading in")
160159
.appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'HEADING');
161160

162161
this.setInputsInline(true);

src/main/webapp/cdn/blockly/generators/propc/abvolts.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Blockly.Blocks.ab_volt_in = {
3131
init: function() {
3232
this.setColour(colorPalette.getColor('io'));
3333
this.appendDummyInput()
34-
.appendField("0-5V ADC reading in Volts x 100")
34+
.appendField("ADC read (0-5V) in volt-100ths")
3535
.appendField("channel")
3636
.appendField(new Blockly.FieldDropdown([["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"]]), "CHANNEL");
3737

@@ -45,13 +45,13 @@ Blockly.Blocks.ab_volt_out = {
4545
init: function() {
4646
this.setColour(colorPalette.getColor('io'));
4747
this.appendDummyInput()
48-
.appendField("0-3.3V DAC output in Volts x 100")
49-
.appendField("channel")
50-
.appendField(new Blockly.FieldDropdown([["0", "0"], ["1", "1"]]), "CHANNEL");
51-
this.appendValueInput("VALUE")
48+
.appendField("DAC channel")
49+
.appendField(new Blockly.FieldDropdown([["0", "0"], ["1", "1"]]), "CHANNEL")
50+
.appendField("output (0-3.3V)");
51+
this.appendValueInput("VALUE")
5252
.setCheck('Number')
5353
.setAlign(Blockly.ALIGN_RIGHT)
54-
.appendField("Value");
54+
.appendField("volt-100ths");
5555

5656
this.setPreviousStatement(true, null);
5757
this.setNextStatement(true, null);

0 commit comments

Comments
 (0)