Skip to content

Commit 6be953e

Browse files
committed
Add upload and download (local files) to the BlocklyProp system
2 parents 50f60ba + 7bc4408 commit 6be953e

File tree

9 files changed

+294
-23
lines changed

9 files changed

+294
-23
lines changed

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,8 @@ public JsonObject toJson(ProjectRecord project) {
8484
result.addProperty("modified", DateConversion.toDateTimeString(project.getModified().getTime()));
8585
boolean isYours = project.getIdUser().equals(BlocklyPropSecurityUtils.getCurrentUserId());
8686
result.addProperty("yours", isYours);
87-
if (!isYours) {
88-
result.addProperty("user", userService.getUserScreenName(project.getIdUser()));
89-
90-
} else {
87+
result.addProperty("user", userService.getUserScreenName(project.getIdUser()));
88+
if (isYours) {
9189
List<ProjectSharingRecord> projectSharingRecords = projectSharingService.getSharingInfo(project.getId());
9290
if (projectSharingRecords != null && !projectSharingRecords.isEmpty()) {
9391
result.addProperty("share-key", projectSharingRecords.get(0).getSharekey());
@@ -126,9 +124,7 @@ public JsonObject toJson(Project project) {
126124
result.addProperty("modified", DateConversion.toDateTimeString(project.getModified().getTime()));
127125
boolean isYours = project.getIdUser().equals(BlocklyPropSecurityUtils.getCurrentUserId());
128126
result.addProperty("yours", isYours);
129-
if (!isYours) {
130-
result.addProperty("user", userService.getUserScreenName(project.getIdUser()));
131-
}
127+
result.addProperty("user", userService.getUserScreenName(project.getIdUser()));
132128

133129
if (project.getBasedOn() != null) {
134130
JsonObject basedOn = new JsonObject();

src/main/java/com/parallax/server/blocklyprop/servlets/PingServlet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class PingServlet extends HttpServlet {
2424
*/
2525
@Override
2626
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
27-
resp.getWriter().write("pong");
27+
resp.getWriter().write("<html><body>pong</body></html>");
2828
}
2929

3030
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ project.table.user = User
101101
project.changed = Project changes have been saved
102102
project.created = Created
103103
project.modified = Modified
104+
104105
project.create.title = Your project
105106
project.create.basic = Basic info
106107
project.create.basic.title = Basic project info
@@ -215,6 +216,19 @@ editor.client.title = BlocklyPropClient
215216
editor.client.checking = Checking for BlocklyPropClient
216217
editor.client.available = BlocklyPropClient available
217218
editor.client.not-available = BlocklyPropClient not available
219+
editor.download = Download
220+
editor.upload = Upload
221+
editor.upload.selectfile = Select File
222+
editor.upload.valid = The selected file appears valid.
223+
editor.upload.notvalid = The selected file is not valid.
224+
editor.upload.boardtype.warning = <strong>Warning!</strong> You are about to upload a blocks file from a different board than you are currently using. If the blocks you are trying to upload are not available for your current board, uploading this blocks file into your project may <strong>break your project</strong>. If your project does break after uploading this file - do not save it! Click your browser's refresh button to reload your project.
225+
editor.clear-workspace = Clear Workspace
226+
editor.button.close = Close
227+
editor.button.cancel = Cancel
228+
editor.button.replace = Replace
229+
editor.button.append = Append
230+
editor.title.terminal = Terminal
231+
editor.title.result = Result
218232

219233
editor.demo.dialog.title = You are not logged in
220234
editor.demo.dialog.continue = Continue demo

src/main/webapp/WEB-INF/includes/pageparts/editor-menu.jsp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,21 @@
1313
<div class="collapse navbar-collapse">
1414
<ul class="nav navbar-nav" id="navbar-left">
1515
<!-- <li><a href="help/index.html">Manual</a></li> -->
16+
17+
<!-- Activate From Here ---------------------------
18+
<li><a class="external_link" href="<url:getUrl url="/projectcreate.jsp?lang=PROPC"/>" ><fmt:message key="editor.newproject.title" /></a></li>
19+
---- To Here when closing SPIN access --------- -->
20+
21+
<!-- Delete From Here ------------------------- -->
1622
<li class="dropdown">
1723
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><fmt:message key="editor.newproject.title" /><b class="caret"></b></a>
1824
<ul class="dropdown-menu">
1925
<li><a href="<url:getUrl url="/projectcreate.jsp?lang=SPIN"/>"><fmt:message key="editor.newproject.spin" /></a></li>
2026
<li><a href="<url:getUrl url="/projectcreate.jsp?lang=PROPC"/>"><fmt:message key="editor.newproject.c" /></a></li>
2127
</ul>
2228
</li>
29+
<!-- To Here when closing SPIN access --------- -->
30+
2331
<li class="dropdown">
2432
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><fmt:message key="editor.projects.title" /> <b class="caret"></b></a>
2533
<ul class="dropdown-menu" role="menu">
@@ -90,6 +98,11 @@
9098
</button>
9199
<ul class="dropdown-menu">
92100
<li><a id="save-project-as" href="#"><fmt:message key="editor.save-as" /></a></li>
101+
102+
<li><a id="download-project" href="#"><fmt:message key="editor.download" /></a></li>
103+
<li><a id="upload-project" href="#"><fmt:message key="editor.upload" /></a></li>
104+
<!-- -->
105+
<li><a id="clear-workspace" href="#"><fmt:message key="editor.clear-workspace" /></a></li>
93106
</ul>
94107
</div>
95108
</li>

src/main/webapp/cdn/blockly/language/en/_messages.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ Blockly.MSG_DISABLE_BLOCK = 'Disable Block';
4242
Blockly.MSG_ENABLE_BLOCK = 'Enable Block';
4343
Blockly.MSG_HELP = 'Help';
4444

45+
// Editor dialogs.
46+
Blockly.Msg.DIALOG_CLEAR_WORKSPACE = 'Clear Workspace';
47+
Blockly.Msg.DIALOG_CLEAR_WORKSPACE_WARNING = 'Are you sure you want to clear your workspace? This action cannot be undone!';
48+
Blockly.Msg.DIALOG_CHANGED_SINCE = 'The project has been changed since the last save.';
49+
Blockly.Msg.DIALOG_PROJECT_SAVED = 'Project saved';
50+
Blockly.Msg.DIALOG_PROJECT_SAVED_TEXT = 'The project has been saved';
51+
4552
// Variable renaming.
4653
Blockly.MSG_CHANGE_VALUE_TITLE = 'Change value:';
4754
Blockly.MSG_NEW_VARIABLE = 'New variable...';

src/main/webapp/cdn/demoeditor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ function getUrlParameters(parameter, staticURL, decode) {
8484

8585
for (var i = 0; i < parArr.length; i++) {
8686
parr = parArr[i].split("=");
87-
if (parr[0] == parameter) {
88-
return (decode) ? decodeURIComponent(parr[1]) : parr[1];
87+
if (parr[0] === parameter) {
8988
returnBool = true;
89+
return (decode) ? decodeURIComponent(parr[1]) : parr[1];
9090
} else {
9191
returnBool = false;
9292
}

0 commit comments

Comments
 (0)