http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinRestApiTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinRestApiTest.java b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinRestApiTest.java index 3b92c14..692b4da 100644 --- a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinRestApiTest.java +++ b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinRestApiTest.java @@ -29,10 +29,8 @@ import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.httpclient.methods.PutMethod; import org.apache.commons.lang3.StringUtils; -import org.apache.zeppelin.interpreter.InterpreterSetting; import org.apache.zeppelin.notebook.Note; import org.apache.zeppelin.notebook.Paragraph; -import org.apache.zeppelin.scheduler.Job.Status; import org.apache.zeppelin.server.ZeppelinServer; import org.apache.zeppelin.user.AuthenticationInfo; import org.junit.AfterClass; @@ -84,8 +82,8 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { } @Test - public void testGetNotebookInfo() throws IOException { - LOG.info("testGetNotebookInfo"); + public void testGetNoteInfo() throws IOException { + LOG.info("testGetNoteInfo"); // Create note to get info Note note = ZeppelinServer.notebook.createNote(anonymous); assertNotNull("can't create new note", note); @@ -98,10 +96,10 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { paragraph.setText(paragraphText); note.persist(anonymous); - String sourceNoteID = note.getId(); - GetMethod get = httpGet("/notebook/" + sourceNoteID); - LOG.info("testGetNotebookInfo \n" + get.getResponseBodyAsString()); - assertThat("test notebook get method:", get, isAllowed()); + String sourceNoteId = note.getId(); + GetMethod get = httpGet("/notebook/" + sourceNoteId); + LOG.info("testGetNoteInfo \n" + get.getResponseBodyAsString()); + assertThat("test note get method:", get, isAllowed()); Map<String, Object> resp = gson.fromJson(get.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() { }.getType()); @@ -115,45 +113,45 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { assertTrue(paragraphs.size() > 0); assertEquals(paragraphText, paragraphs.get(0).get("text")); // - ZeppelinServer.notebook.removeNote(sourceNoteID, anonymous); + ZeppelinServer.notebook.removeNote(sourceNoteId, anonymous); } @Test - public void testNotebookCreateWithName() throws IOException { + public void testNoteCreateWithName() throws IOException { String noteName = "Test note name"; - testNotebookCreate(noteName); + testNoteCreate(noteName); } @Test - public void testNotebookCreateNoName() throws IOException { - testNotebookCreate(""); + public void testNoteCreateNoName() throws IOException { + testNoteCreate(""); } @Test - public void testNotebookCreateWithParagraphs() throws IOException { - // Call Create Notebook REST API + public void testNoteCreateWithParagraphs() throws IOException { + // Call Create Note REST API String noteName = "test"; String jsonRequest = "{\"name\":\"" + noteName + "\", \"paragraphs\": [" + "{\"title\": \"title1\", \"text\": \"text1\"}," + "{\"title\": \"title2\", \"text\": \"text2\"}" + "]}"; PostMethod post = httpPost("/notebook/", jsonRequest); - LOG.info("testNotebookCreate \n" + post.getResponseBodyAsString()); - assertThat("test notebook create method:", post, isCreated()); + LOG.info("testNoteCreate \n" + post.getResponseBodyAsString()); + assertThat("test note create method:", post, isCreated()); Map<String, Object> resp = gson.fromJson(post.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() { }.getType()); - String newNotebookId = (String) resp.get("body"); - LOG.info("newNotebookId:=" + newNotebookId); - Note newNote = ZeppelinServer.notebook.getNote(newNotebookId); + String newNoteId = (String) resp.get("body"); + LOG.info("newNoteId:=" + newNoteId); + Note newNote = ZeppelinServer.notebook.getNote(newNoteId); assertNotNull("Can not find new note by id", newNote); // This is partial test as newNote is in memory but is not persistent String newNoteName = newNote.getName(); LOG.info("new note name is: " + newNoteName); String expectedNoteName = noteName; if (noteName.isEmpty()) { - expectedNoteName = "Note " + newNotebookId; + expectedNoteName = "Note " + newNoteId; } assertEquals("compare note name", expectedNoteName, newNoteName); assertEquals("initial paragraph check failed", 3, newNote.getParagraphs().size()); @@ -165,34 +163,34 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { assertTrue("paragraph text check failed", p.getText().startsWith("text")); } // cleanup - ZeppelinServer.notebook.removeNote(newNotebookId, anonymous); + ZeppelinServer.notebook.removeNote(newNoteId, anonymous); post.releaseConnection(); } - private void testNotebookCreate(String noteName) throws IOException { - // Call Create Notebook REST API + private void testNoteCreate(String noteName) throws IOException { + // Call Create Note REST API String jsonRequest = "{\"name\":\"" + noteName + "\"}"; PostMethod post = httpPost("/notebook/", jsonRequest); - LOG.info("testNotebookCreate \n" + post.getResponseBodyAsString()); - assertThat("test notebook create method:", post, isCreated()); + LOG.info("testNoteCreate \n" + post.getResponseBodyAsString()); + assertThat("test note create method:", post, isCreated()); Map<String, Object> resp = gson.fromJson(post.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() { }.getType()); - String newNotebookId = (String) resp.get("body"); - LOG.info("newNotebookId:=" + newNotebookId); - Note newNote = ZeppelinServer.notebook.getNote(newNotebookId); + String newNoteId = (String) resp.get("body"); + LOG.info("newNoteId:=" + newNoteId); + Note newNote = ZeppelinServer.notebook.getNote(newNoteId); assertNotNull("Can not find new note by id", newNote); // This is partial test as newNote is in memory but is not persistent String newNoteName = newNote.getName(); LOG.info("new note name is: " + newNoteName); String expectedNoteName = noteName; if (noteName.isEmpty()) { - expectedNoteName = "Note " + newNotebookId; + expectedNoteName = "Note " + newNoteId; } assertEquals("compare note name", expectedNoteName, newNoteName); // cleanup - ZeppelinServer.notebook.removeNote(newNotebookId, anonymous); + ZeppelinServer.notebook.removeNote(newNoteId, anonymous); post.releaseConnection(); } @@ -203,20 +201,20 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { //Create note and get ID Note note = ZeppelinServer.notebook.createNote(anonymous); String noteId = note.getId(); - testDeleteNotebook(noteId); + testDeleteNote(noteId); } @Test public void testDeleteNoteBadId() throws IOException { LOG.info("testDeleteNoteBadId"); - testDeleteNotebook("2AZFXEX97"); - testDeleteNotebook("bad_ID"); + testDeleteNote("2AZFXEX97"); + testDeleteNote("bad_ID"); } @Test - public void testExportNotebook() throws IOException { - LOG.info("testExportNotebook"); + public void testexportNote() throws IOException { + LOG.info("testexportNote"); Note note = ZeppelinServer.notebook.createNote(anonymous); assertNotNull("can't create new note", note); note.setName("source note for export"); @@ -226,11 +224,11 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { paragraph.setConfig(config); paragraph.setText("%md This is my new paragraph in my new note"); note.persist(anonymous); - String sourceNoteID = note.getId(); - // Call export Notebook REST API - GetMethod get = httpGet("/notebook/export/" + sourceNoteID); - LOG.info("testNotebookExport \n" + get.getResponseBodyAsString()); - assertThat("test notebook export method:", get, isAllowed()); + String sourceNoteId = note.getId(); + // Call export Note REST API + GetMethod get = httpGet("/notebook/export/" + sourceNoteId); + LOG.info("testNoteExport \n" + get.getResponseBodyAsString()); + assertThat("test note export method:", get, isAllowed()); Map<String, Object> resp = gson.fromJson(get.getResponseBodyAsString(), @@ -239,7 +237,7 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { String exportJSON = (String) resp.get("body"); assertNotNull("Can not find new notejson", exportJSON); LOG.info("export JSON:=" + exportJSON); - ZeppelinServer.notebook.removeNote(sourceNoteID, anonymous); + ZeppelinServer.notebook.removeNote(sourceNoteId, anonymous); get.releaseConnection(); } @@ -248,8 +246,8 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { public void testImportNotebook() throws IOException { Map<String, Object> resp; String noteName = "source note for import"; - LOG.info("testImortNotebook"); - // create test notebook + LOG.info("testImortNote"); + // create test note Note note = ZeppelinServer.notebook.createNote(anonymous); assertNotNull("can't create new note", note); note.setName(noteName); @@ -259,10 +257,10 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { paragraph.setConfig(config); paragraph.setText("%md This is my new paragraph in my new note"); note.persist(anonymous); - String sourceNoteID = note.getId(); + String sourceNoteId = note.getId(); // get note content as JSON - String oldJson = getNoteContent(sourceNoteID); - // call notebook post + String oldJson = getNoteContent(sourceNoteId); + // call note post PostMethod importPost = httpPost("/notebook/import/", oldJson); assertThat(importPost, isCreated()); resp = @@ -270,7 +268,7 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { new TypeToken<Map<String, Object>>() {}.getType()); String importId = (String) resp.get("body"); - assertNotNull("Did not get back a notebook id in body", importId); + assertNotNull("Did not get back a note id in body", importId); Note newNote = ZeppelinServer.notebook.getNote(importId); assertEquals("Compare note names", noteName, newNote.getName()); assertEquals("Compare paragraphs count", note.getParagraphs().size(), newNote.getParagraphs() @@ -295,22 +293,22 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { return body; } - private void testDeleteNotebook(String notebookId) throws IOException { + private void testDeleteNote(String noteId) throws IOException { - DeleteMethod delete = httpDelete(("/notebook/" + notebookId)); - LOG.info("testDeleteNotebook delete response\n" + delete.getResponseBodyAsString()); + DeleteMethod delete = httpDelete(("/notebook/" + noteId)); + LOG.info("testDeleteNote delete response\n" + delete.getResponseBodyAsString()); assertThat("Test delete method:", delete, isAllowed()); delete.releaseConnection(); // make sure note is deleted - if (!notebookId.isEmpty()) { - Note deletedNote = ZeppelinServer.notebook.getNote(notebookId); + if (!noteId.isEmpty()) { + Note deletedNote = ZeppelinServer.notebook.getNote(noteId); assertNull("Deleted note should be null", deletedNote); } } @Test - public void testCloneNotebook() throws IOException, CloneNotSupportedException, IllegalArgumentException { - LOG.info("testCloneNotebook"); + public void testCloneNote() throws IOException, CloneNotSupportedException, IllegalArgumentException { + LOG.info("testCloneNote"); // Create note to clone Note note = ZeppelinServer.notebook.createNote(anonymous); assertNotNull("can't create new note", note); @@ -321,21 +319,21 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { paragraph.setConfig(config); paragraph.setText("%md This is my new paragraph in my new note"); note.persist(anonymous); - String sourceNoteID = note.getId(); + String sourceNoteId = note.getId(); String noteName = "clone Note Name"; - // Call Clone Notebook REST API + // Call Clone Note REST API String jsonRequest = "{\"name\":\"" + noteName + "\"}"; - PostMethod post = httpPost("/notebook/" + sourceNoteID, jsonRequest); - LOG.info("testNotebookClone \n" + post.getResponseBodyAsString()); - assertThat("test notebook clone method:", post, isCreated()); + PostMethod post = httpPost("/notebook/" + sourceNoteId, jsonRequest); + LOG.info("testNoteClone \n" + post.getResponseBodyAsString()); + assertThat("test note clone method:", post, isCreated()); Map<String, Object> resp = gson.fromJson(post.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() { }.getType()); - String newNotebookId = (String) resp.get("body"); - LOG.info("newNotebookId:=" + newNotebookId); - Note newNote = ZeppelinServer.notebook.getNote(newNotebookId); + String newNoteId = (String) resp.get("body"); + LOG.info("newNoteId:=" + newNoteId); + Note newNote = ZeppelinServer.notebook.getNote(newNoteId); assertNotNull("Can not find new note by id", newNote); assertEquals("Compare note names", noteName, newNote.getName()); assertEquals("Compare paragraphs count", note.getParagraphs().size(), newNote.getParagraphs().size()); @@ -346,16 +344,16 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { } @Test - public void testListNotebooks() throws IOException { - LOG.info("testListNotebooks"); + public void testListNotes() throws IOException { + LOG.info("testListNotes"); GetMethod get = httpGet("/notebook/ "); - assertThat("List notebooks method", get, isAllowed()); + assertThat("List notes method", get, isAllowed()); Map<String, Object> resp = gson.fromJson(get.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() { }.getType()); List<Map<String, String>> body = (List<Map<String, String>>) resp.get("body"); //TODO(khalid): anonymous or specific user notes? HashSet<String> anonymous = Sets.newHashSet("anonymous"); - assertEquals("List notebooks are equal", ZeppelinServer.notebook.getAllNotes(anonymous).size(), body.size()); + assertEquals("List notes are equal", ZeppelinServer.notebook.getAllNotes(anonymous).size(), body.size()); get.releaseConnection(); } @@ -374,7 +372,7 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { paragraph.setText("%md This is test paragraph."); note.persist(anonymous); - String noteID = note.getId(); + String noteId = note.getId(); note.runAll(); // wait until job is finished or timeout. @@ -387,25 +385,25 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { } } - // Call Run Notebook Jobs REST API - PostMethod postNoteJobs = httpPost("/notebook/job/" + noteID, ""); - assertThat("test notebook jobs run:", postNoteJobs, isAllowed()); + // Call Run note jobs REST API + PostMethod postNoteJobs = httpPost("/notebook/job/" + noteId, ""); + assertThat("test note jobs run:", postNoteJobs, isAllowed()); postNoteJobs.releaseConnection(); - // Call Stop Notebook Jobs REST API - DeleteMethod deleteNoteJobs = httpDelete("/notebook/job/" + noteID); - assertThat("test notebook stop:", deleteNoteJobs, isAllowed()); + // Call Stop note jobs REST API + DeleteMethod deleteNoteJobs = httpDelete("/notebook/job/" + noteId); + assertThat("test note stop:", deleteNoteJobs, isAllowed()); deleteNoteJobs.releaseConnection(); Thread.sleep(1000); // Call Run paragraph REST API - PostMethod postParagraph = httpPost("/notebook/job/" + noteID + "/" + paragraph.getId(), ""); + PostMethod postParagraph = httpPost("/notebook/job/" + noteId + "/" + paragraph.getId(), ""); assertThat("test paragraph run:", postParagraph, isAllowed()); postParagraph.releaseConnection(); Thread.sleep(1000); // Call Stop paragraph REST API - DeleteMethod deleteParagraph = httpDelete("/notebook/job/" + noteID + "/" + paragraph.getId()); + DeleteMethod deleteParagraph = httpDelete("/notebook/job/" + noteId + "/" + paragraph.getId()); assertThat("test paragraph stop:", deleteParagraph, isAllowed()); deleteParagraph.releaseConnection(); Thread.sleep(1000); @@ -415,8 +413,8 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { } @Test - public void testGetNotebookJob() throws IOException, InterruptedException { - LOG.info("testGetNotebookJob"); + public void testGetNoteJob() throws IOException, InterruptedException { + LOG.info("testGetNoteJob"); // Create note to run test. Note note = ZeppelinServer.notebook.createNote(anonymous); assertNotNull("can't create new note", note); @@ -430,7 +428,7 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { paragraph.setText("%sh sleep 1"); paragraph.setAuthenticationInfo(anonymous); note.persist(anonymous); - String noteID = note.getId(); + String noteId = note.getId(); note.runAll(); @@ -440,12 +438,12 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { } // assume that status of the paragraph is running - GetMethod get = httpGet("/notebook/job/" + noteID); - assertThat("test get notebook job: ", get, isAllowed()); + GetMethod get = httpGet("/notebook/job/" + noteId); + assertThat("test get note job: ", get, isAllowed()); String responseBody = get.getResponseBodyAsString(); get.releaseConnection(); - LOG.info("test get notebook job: \n" + responseBody); + LOG.info("test get note job: \n" + responseBody); Map<String, Object> resp = gson.fromJson(responseBody, new TypeToken<Map<String, Object>>() { }.getType()); @@ -460,7 +458,7 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { while (!paragraph.isTerminated()) { Thread.sleep(100); if (timeout++ > 10) { - LOG.info("testGetNotebookJob timeout job."); + LOG.info("testGetNoteJob timeout job."); break; } } @@ -483,7 +481,7 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { paragraph.setText("%spark\nval param = z.input(\"param\").toString\nprintln(param)"); note.persist(anonymous); - String noteID = note.getId(); + String noteId = note.getId(); note.runAll(); // wait until job is finished or timeout. @@ -497,13 +495,13 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { } // Call Run paragraph REST API - PostMethod postParagraph = httpPost("/notebook/job/" + noteID + "/" + paragraph.getId(), + PostMethod postParagraph = httpPost("/notebook/job/" + noteId + "/" + paragraph.getId(), "{\"params\": {\"param\": \"hello\", \"param2\": \"world\"}}"); assertThat("test paragraph run:", postParagraph, isAllowed()); postParagraph.releaseConnection(); Thread.sleep(1000); - Note retrNote = ZeppelinServer.notebook.getNote(noteID); + Note retrNote = ZeppelinServer.notebook.getNote(noteId); Paragraph retrParagraph = retrNote.getParagraph(paragraph.getId()); Map<String, Object> params = retrParagraph.settings.getParams(); assertEquals("hello", params.get("param")); @@ -574,7 +572,7 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { note.persist(anonymous); GetMethod getNoteJobs = httpGet("/notebook/job/" + note.getId()); - assertThat("test notebook jobs run:", getNoteJobs, isAllowed()); + assertThat("test note jobs run:", getNoteJobs, isAllowed()); Map<String, Object> resp = gson.fromJson(getNoteJobs.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() { }.getType()); List<Map<String, String>> body = (List<Map<String, String>>) resp.get("body"); @@ -722,13 +720,13 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { Note note1 = ZeppelinServer.notebook.createNote(anonymous); String jsonRequest = "{\"title\": \"title1\", \"text\": \"ThisIsToTestSearchMethodWithPermissions 1\"}"; - PostMethod postNotebookText = httpPost("/notebook/" + note1.getId() + "/paragraph", jsonRequest); - postNotebookText.releaseConnection(); + PostMethod postNoteText = httpPost("/notebook/" + note1.getId() + "/paragraph", jsonRequest); + postNoteText.releaseConnection(); Note note2 = ZeppelinServer.notebook.createNote(anonymous); jsonRequest = "{\"title\": \"title1\", \"text\": \"ThisIsToTestSearchMethodWithPermissions 2\"}"; - postNotebookText = httpPost("/notebook/" + note2.getId() + "/paragraph", jsonRequest); - postNotebookText.releaseConnection(); + postNoteText = httpPost("/notebook/" + note2.getId() + "/paragraph", jsonRequest); + postNoteText.releaseConnection(); String jsonPermissions = "{\"owners\":[\"" + username + "\"],\"readers\":[\"" + username + "\"],\"writers\":[\"" + username + "\"]}"; PutMethod putPermission = httpPut("/notebook/" + note1.getId() + "/permissions", jsonPermissions); @@ -738,9 +736,9 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { putPermission = httpPut("/notebook/" + note2.getId() + "/permissions", jsonPermissions); putPermission.releaseConnection(); - GetMethod searchNotebook = httpGet("/notebook/search?q='ThisIsToTestSearchMethodWithPermissions'"); - searchNotebook.addRequestHeader("Origin", "http://localhost"); - Map<String, Object> respSearchResult = gson.fromJson(searchNotebook.getResponseBodyAsString(), + GetMethod searchNote = httpGet("/notebook/search?q='ThisIsToTestSearchMethodWithPermissions'"); + searchNote.addRequestHeader("Origin", "http://localhost"); + Map<String, Object> respSearchResult = gson.fromJson(searchNote.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() { }.getType()); ArrayList searchBody = (ArrayList) respSearchResult.get("body"); @@ -766,7 +764,7 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { } getPermission.releaseConnection(); } - searchNotebook.releaseConnection(); + searchNote.releaseConnection(); ZeppelinServer.notebook.removeNote(note1.getId(), anonymous); ZeppelinServer.notebook.removeNote(note2.getId(), anonymous); } @@ -775,12 +773,12 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { public void testTitleSearch() throws IOException { Note note = ZeppelinServer.notebook.createNote(anonymous); String jsonRequest = "{\"title\": \"testTitleSearchOfParagraph\", \"text\": \"ThisIsToTestSearchMethodWithTitle \"}"; - PostMethod postNotebookText = httpPost("/notebook/" + note.getId() + "/paragraph", jsonRequest); - postNotebookText.releaseConnection(); + PostMethod postNoteText = httpPost("/notebook/" + note.getId() + "/paragraph", jsonRequest); + postNoteText.releaseConnection(); - GetMethod searchNotebook = httpGet("/notebook/search?q='testTitleSearchOfParagraph'"); - searchNotebook.addRequestHeader("Origin", "http://localhost"); - Map<String, Object> respSearchResult = gson.fromJson(searchNotebook.getResponseBodyAsString(), + GetMethod searchNote = httpGet("/notebook/search?q='testTitleSearchOfParagraph'"); + searchNote.addRequestHeader("Origin", "http://localhost"); + Map<String, Object> respSearchResult = gson.fromJson(searchNote.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() { }.getType()); ArrayList searchBody = (ArrayList) respSearchResult.get("body"); @@ -793,7 +791,7 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi { } } assertEquals("Paragraph title hits must be at-least one", true, numberOfTitleHits >= 1); - searchNotebook.releaseConnection(); + searchNote.releaseConnection(); ZeppelinServer.notebook.removeNote(note.getId(), anonymous); }
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-server/src/test/java/org/apache/zeppelin/socket/NotebookServerTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/socket/NotebookServerTest.java b/zeppelin-server/src/test/java/org/apache/zeppelin/socket/NotebookServerTest.java index caac043..a2225ab 100644 --- a/zeppelin-server/src/test/java/org/apache/zeppelin/socket/NotebookServerTest.java +++ b/zeppelin-server/src/test/java/org/apache/zeppelin/socket/NotebookServerTest.java @@ -154,7 +154,7 @@ public class NotebookServerTest extends AbstractTestRestApi { @Test public void testImportNotebook() throws IOException { String msg = "{\"op\":\"IMPORT_NOTE\",\"data\":" + - "{\"notebook\":{\"paragraphs\": [{\"text\": \"Test " + + "{\"note\":{\"paragraphs\": [{\"text\": \"Test " + "paragraphs import\",\"config\":{},\"settings\":{}}]," + "\"name\": \"Test Zeppelin notebook import\",\"config\": " + "{}}}}"; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-web/src/app/home/home.controller.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/app/home/home.controller.js b/zeppelin-web/src/app/home/home.controller.js index 9063e33..171a275 100644 --- a/zeppelin-web/src/app/home/home.controller.js +++ b/zeppelin-web/src/app/home/home.controller.js @@ -18,17 +18,17 @@ HomeCtrl.$inject = [ '$scope', - 'notebookListDataFactory', + 'noteListDataFactory', 'websocketMsgSrv', '$rootScope', 'arrayOrderingSrv', 'ngToast' ]; - function HomeCtrl($scope, notebookListDataFactory, websocketMsgSrv, $rootScope, arrayOrderingSrv, ngToast) { + function HomeCtrl($scope, noteListDataFactory, websocketMsgSrv, $rootScope, arrayOrderingSrv, ngToast) { ngToast.dismiss(); var vm = this; - vm.notes = notebookListDataFactory; + vm.notes = noteListDataFactory; vm.websocketMsgSrv = websocketMsgSrv; vm.arrayOrderingSrv = arrayOrderingSrv; @@ -42,12 +42,12 @@ $scope.isReloading = false; var initHome = function() { - websocketMsgSrv.getHomeNotebook(); + websocketMsgSrv.getHomeNote(); }; initHome(); - $scope.reloadNotebookList = function() { + $scope.reloadNoteList = function() { websocketMsgSrv.reloadAllNotesFromRepo(); $scope.isReloadingNotes = true; }; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-web/src/app/home/home.html ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/app/home/home.html b/zeppelin-web/src/app/home/home.html index 1959a47..0f8e968 100644 --- a/zeppelin-web/src/app/home/home.html +++ b/zeppelin-web/src/app/home/home.html @@ -47,7 +47,7 @@ limitations under the License. <h4>Notebook <i ng-class="isReloadingNotes ? 'fa fa-refresh fa-spin' : 'fa fa-refresh'" ng-style="!isReloadingNotes && {'cursor': 'pointer'}" style="font-size: 13px;" - ng-click="reloadNotebookList();" + ng-click="reloadNoteList();" tooltip-placement="bottom" tooltip="Reload notes from storage"> </i> </h4> @@ -59,15 +59,15 @@ limitations under the License. <i style="font-size: 15px;" class="icon-notebook"></i> Create new note</a></h5> <ul id="notebook-names"> <li class="filter-names" ng-include="'components/filterNoteNames/filter-note-names.html'"></li> - <li ng-repeat="note in home.notes.list | filter:query.q | orderBy:home.arrayOrderingSrv.notebookListOrdering track by $index"> + <li ng-repeat="note in home.notes.list | filter:query.q | orderBy:home.arrayOrderingSrv.noteListOrdering track by $index"> <i style="font-size: 10px;" class="icon-doc"></i> <a style="text-decoration: none;" href="#/notebook/{{note.id}}">{{noteName(note)}}</a> </li> <div ng-if="!query || query.name === ''"> - <li ng-repeat="node in home.notes.root.children | orderBy:home.arrayOrderingSrv.notebookListOrdering track by $index" ng-include="'notebook_folder_renderer.html'" /> + <li ng-repeat="node in home.notes.root.children | orderBy:home.arrayOrderingSrv.noteListOrdering track by $index" ng-include="'notebook_folder_renderer.html'" /> </div> <div ng-if="query && query.name !== ''"> - <li ng-repeat="note in home.notes.flatList | filter:query.q | orderBy:home.arrayOrderingSrv.notebookListOrdering track by $index"> + <li ng-repeat="note in home.notes.flatList | filter:query.q | orderBy:home.arrayOrderingSrv.noteListOrdering track by $index"> <i style="font-size: 10px;" class="icon-doc"></i> <a style="text-decoration: none;" href="#/notebook/{{note.id}}">{{noteName(note)}}</a> </li> http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-web/src/app/jobmanager/jobmanager.controller.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/app/jobmanager/jobmanager.controller.js b/zeppelin-web/src/app/jobmanager/jobmanager.controller.js index d28b374..903a81f 100644 --- a/zeppelin-web/src/app/jobmanager/jobmanager.controller.js +++ b/zeppelin-web/src/app/jobmanager/jobmanager.controller.js @@ -34,7 +34,7 @@ $scope.jobInfomations = []; $scope.JobInfomationsByFilter = $scope.jobInfomations; - websocketMsgSrv.getNotebookJobsList(); + websocketMsgSrv.getNoteJobsList(); $scope.$on('$destroy', function() { websocketMsgSrv.unsubscribeJobManager(); @@ -45,34 +45,34 @@ ** $scope.$on functions below */ - $scope.$on('setNotebookJobs', function(event, responseData) { + $scope.$on('setNoteJobs', function(event, responseData) { $scope.lastJobServerUnixTime = responseData.lastResponseUnixTime; $scope.jobInfomations = responseData.jobs; - $scope.jobInfomationsIndexs = $scope.jobInfomations ? _.indexBy($scope.jobInfomations, 'notebookId') : {}; + $scope.jobInfomationsIndexs = $scope.jobInfomations ? _.indexBy($scope.jobInfomations, 'noteId') : {}; }); - $scope.$on('setUpdateNotebookJobs', function(event, responseData) { + $scope.$on('setUpdateNoteJobs', function(event, responseData) { var jobInfomations = $scope.jobInfomations; var indexStore = $scope.jobInfomationsIndexs; $scope.lastJobServerUnixTime = responseData.lastResponseUnixTime; var notes = responseData.jobs; notes.map(function(changedItem) { - if (indexStore[changedItem.notebookId] === undefined) { + if (indexStore[changedItem.noteId] === undefined) { var newItem = angular.copy(changedItem); jobInfomations.push(newItem); - indexStore[changedItem.notebookId] = newItem; + indexStore[changedItem.noteId] = newItem; } else { - var changeOriginTarget = indexStore[changedItem.notebookId]; + var changeOriginTarget = indexStore[changedItem.noteId]; if (changedItem.isRemoved !== undefined && changedItem.isRemoved === true) { // remove Item. - var removeIndex = _.findIndex(indexStore, changedItem.notebookId); + var removeIndex = _.findIndex(indexStore, changedItem.noteId); if (removeIndex > -1) { indexStore.splice(removeIndex, 1); } - removeIndex = _.findIndex(jobInfomations, {'notebookId': changedItem.notebookId}); + removeIndex = _.findIndex(jobInfomations, {'noteId': changedItem.noteId}); if (removeIndex) { jobInfomations.splice(removeIndex, 1); } @@ -80,8 +80,8 @@ } else { // change value for item. changeOriginTarget.isRunningJob = changedItem.isRunningJob; - changeOriginTarget.notebookName = changedItem.notebookName; - changeOriginTarget.notebookType = changedItem.notebookType; + changeOriginTarget.noteName = changedItem.noteName; + changeOriginTarget.noteType = changedItem.noteType; changeOriginTarget.interpreter = changedItem.interpreter; changeOriginTarget.unixTimeLastRun = changedItem.unixTimeLastRun; changeOriginTarget.paragraphs = changedItem.paragraphs; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-web/src/app/jobmanager/jobmanager.html ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/app/jobmanager/jobmanager.html b/zeppelin-web/src/app/jobmanager/jobmanager.html index 2884b85..f8b78dd 100644 --- a/zeppelin-web/src/app/jobmanager/jobmanager.html +++ b/zeppelin-web/src/app/jobmanager/jobmanager.html @@ -23,7 +23,7 @@ limitations under the License. </div> <div class="row"> <div class="col-md-12"> - You can monitor the written notebook. Check the status of the Notebook and can control the action. + You can monitor the status of notebook and navigate to note or paragraph. </div> </div> </div> http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-web/src/app/jobmanager/jobs/job-control.html ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/app/jobmanager/jobs/job-control.html b/zeppelin-web/src/app/jobmanager/jobs/job-control.html index 2cd0bf8..e800521 100644 --- a/zeppelin-web/src/app/jobmanager/jobs/job-control.html +++ b/zeppelin-web/src/app/jobmanager/jobs/job-control.html @@ -12,16 +12,16 @@ See the License for the specific language governing permissions and limitations under the License. --> -<div id="{{notebookJob.notebookId}}_control" class="control"> +<div id="{{notebookJob.noteId}}_control" class="control"> <span> {{lastExecuteTime(notebookJob.unixTimeLastRun)}} </span> <span> <span ng-if="notebookJob.isRunningJob === true"> - Notebook is RUNNING + Note is RUNNING </span> <span ng-if="notebookJob.isRunningJob === false"> - Notebook is READY + Note is READY </span> </span> http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-web/src/app/jobmanager/jobs/job-progressBar.html ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/app/jobmanager/jobs/job-progressBar.html b/zeppelin-web/src/app/jobmanager/jobs/job-progressBar.html index 11e3c17..00b290b 100644 --- a/zeppelin-web/src/app/jobmanager/jobs/job-progressBar.html +++ b/zeppelin-web/src/app/jobmanager/jobs/job-progressBar.html @@ -12,8 +12,8 @@ See the License for the specific language governing permissions and limitations under the License. --> -<div id="{{notebookJob.notebookId}}_runControl" class="runControl"> - <div id="{{notebookJob.notebookId}}_progress" class="progress" ng-if="notebookJob.isRunningJob === true"> +<div id="{{notebookJob.noteId}}_runControl" class="runControl"> + <div id="{{notebookJob.noteId}}_progress" class="progress" ng-if="notebookJob.isRunningJob === true"> <div ng-if="getProgress()>0 && getProgress()<100 && notebookJob.isRunningJob === true" class="progress-bar" role="progressbar" ng-style="{width:getProgress()+'%'}"></div> <div ng-if="(getProgress()<=0 || getProgress()>=100) && (notebookJob.isRunningJob === true)" http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-web/src/app/jobmanager/jobs/job.html ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/app/jobmanager/jobs/job.html b/zeppelin-web/src/app/jobmanager/jobs/job.html index 0a6ad67..a89b67f 100644 --- a/zeppelin-web/src/app/jobmanager/jobs/job.html +++ b/zeppelin-web/src/app/jobmanager/jobs/job.html @@ -17,15 +17,15 @@ limitations under the License. <div ng-include src="'app/jobmanager/jobs/job-control.html'"></div> <span class="job-types" - ng-switch="notebookJob.notebookType"> + ng-switch="notebookJob.noteType"> <i ng-switch-when="normal" class="icon-doc"></i> <i ng-switch-when="cron" class="icon-clock"></i> <i ng-switch-default class="icon-question"></i> </span> - <a style="text-decoration: none !important;" ng-href="#/notebook/{{notebookJob.notebookId}}"> + <a style="text-decoration: none !important;" ng-href="#/notebook/{{notebookJob.noteId}}"> <span> - {{notebookJob.notebookName}} + {{notebookJob.noteName}} </span> <span> - @@ -48,7 +48,7 @@ limitations under the License. ng-switch="paragraphJob.status"> <a ng-switch-when="READY" style="text-decoration: none !important;" - ng-href="#/notebook/{{notebookJob.notebookId}}/paragraph/{{paragraphJob.id}}"> + ng-href="#/notebook/{{notebookJob.noteId}}/paragraph/{{paragraphJob.id}}"> <i style="color: green" class="fa fa-circle-o" tooltip-placement="top-left" tooltip="{{paragraphJob.name}} is READY"> @@ -56,7 +56,7 @@ limitations under the License. </a> <a ng-switch-when="FINISHED" style="text-decoration: none !important;" - ng-href="#/notebook/{{notebookJob.notebookId}}/paragraph/{{paragraphJob.id}}"> + ng-href="#/notebook/{{notebookJob.noteId}}/paragraph/{{paragraphJob.id}}"> <i style="color: green" class="fa fa-circle" tooltip-placement="top-left" tooltip="{{paragraphJob.name}} is FINISHED"> @@ -64,7 +64,7 @@ limitations under the License. </a> <a ng-switch-when="ABORT" style="text-decoration: none !important;" - ng-href="#/notebook/{{notebookJob.notebookId}}/paragraph/{{paragraphJob.id}}"> + ng-href="#/notebook/{{notebookJob.noteId}}/paragraph/{{paragraphJob.id}}"> <i style="color: orange" class="fa fa-circle" tooltip-placement="top-left" tooltip="{{paragraphJob.name}} is ABORT"> @@ -72,7 +72,7 @@ limitations under the License. </a> <a ng-switch-when="ERROR" style="text-decoration: none !important;" - ng-href="#/notebook/{{notebookJob.notebookId}}/paragraph/{{paragraphJob.id}}"> + ng-href="#/notebook/{{notebookJob.noteId}}/paragraph/{{paragraphJob.id}}"> <i style="color: red" class="fa fa-circle" tooltip-placement="top-left" tooltip="{{paragraphJob.name}} is ERROR"> @@ -80,7 +80,7 @@ limitations under the License. </a> <a ng-switch-when="PENDING" style="text-decoration: none !important;" - ng-href="#/notebook/{{notebookJob.notebookId}}/paragraph/{{paragraphJob.id}}"> + ng-href="#/notebook/{{notebookJob.noteId}}/paragraph/{{paragraphJob.id}}"> <i style="color: gray" class="fa fa-circle" tooltip-placement="top-left" tooltip="{{paragraphJob.name}} is PENDING"> @@ -88,7 +88,7 @@ limitations under the License. </a> <a ng-switch-when="RUNNING" style="text-decoration: none !important;" - ng-href="#/notebook/{{notebookJob.notebookId}}/paragraph/{{paragraphJob.id}}"> + ng-href="#/notebook/{{notebookJob.noteId}}/paragraph/{{paragraphJob.id}}"> <i style="color: blue" class="fa fa-spinner spinAnimation" tooltip-placement="top-left" tooltip="{{paragraphJob.name}} is RUNNING"> @@ -96,7 +96,7 @@ limitations under the License. </a> <a ng-switch-default class="icon-question" style="text-decoration: none !important;" - ng-href="#/notebook/{{notebookJob.notebookId}}/paragraph/{{paragraphJob.id}}"> + ng-href="#/notebook/{{notebookJob.noteId}}/paragraph/{{paragraphJob.id}}"> <i class="icon-question" tooltip-placement="top-left" tooltip="{{paragraphJob.name}} is {{paragraphJob.status}}"> http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-web/src/app/notebook/notebook-actionBar.html ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/app/notebook/notebook-actionBar.html b/zeppelin-web/src/app/notebook/notebook-actionBar.html index fcc0e67..38406df 100644 --- a/zeppelin-web/src/app/notebook/notebook-actionBar.html +++ b/zeppelin-web/src/app/notebook/notebook-actionBar.html @@ -53,7 +53,7 @@ limitations under the License. <button type="button" class="btn btn-default btn-xs" ng-hide="viewOnly" - tooltip-placement="bottom" tooltip="Clone the notebook" data-source-note-name="{{note.name}}" + tooltip-placement="bottom" tooltip="Clone this note" data-source-note-name="{{note.name}}" data-toggle="modal" data-target="#noteNameModal" data-clone="true" > <i class="fa fa-copy"></i> @@ -61,8 +61,8 @@ limitations under the License. <button type="button" class="btn btn-default btn-xs" ng-hide="viewOnly" - ng-click="exportNotebook()" - tooltip-placement="bottom" tooltip="Export the notebook"> + ng-click="exportNote()" + tooltip-placement="bottom" tooltip="Export this note"> <i class="fa fa-download"></i> </button> </span> @@ -91,9 +91,9 @@ limitations under the License. <button type="button" class="btn btn-default btn-xs" ng-hide="viewOnly" - ng-click="checkpointNotebook(note.checkpoint.message)" + ng-click="checkpointNote(note.checkpoint.message)" style="margin-left: 4px;" - tooltip-placement="bottom" tooltip="Commit the notebook">Commit + tooltip-placement="bottom" tooltip="Commit this note">Commit </button> </div> </div> @@ -130,7 +130,7 @@ limitations under the License. class="btn btn-default btn-xs" ng-click="removeNote(note.id)" ng-hide="viewOnly" - tooltip-placement="bottom" tooltip="Remove the notebook"> + tooltip-placement="bottom" tooltip="Remove this note"> <i class="icon-trash"></i> </button> </span> http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-web/src/app/notebook/notebook.controller.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/app/notebook/notebook.controller.js b/zeppelin-web/src/app/notebook/notebook.controller.js index f2aa67d..6255d73 100644 --- a/zeppelin-web/src/app/notebook/notebook.controller.js +++ b/zeppelin-web/src/app/notebook/notebook.controller.js @@ -86,7 +86,7 @@ /** Init the new controller */ var initNotebook = function() { - websocketMsgSrv.getNotebook($routeParams.noteId); + websocketMsgSrv.getNote($routeParams.noteId); websocketMsgSrv.listRevisionHistory($routeParams.noteId); var currentRoute = $route.current; if (currentRoute) { @@ -145,10 +145,10 @@ BootstrapDialog.confirm({ closable: true, title: '', - message: 'Do you want to delete this notebook?', + message: 'Do you want to delete this note?', callback: function(result) { if (result) { - websocketMsgSrv.deleteNotebook(noteId); + websocketMsgSrv.deleteNote(noteId); $location.path('/'); } } @@ -156,7 +156,7 @@ }; //Export notebook - $scope.exportNotebook = function() { + $scope.exportNote = function() { var jsonContent = JSON.stringify($scope.note); saveAsService.saveAs(jsonContent, $scope.note.name, 'json'); }; @@ -166,10 +166,10 @@ BootstrapDialog.confirm({ closable: true, title: '', - message: 'Do you want to clone this notebook?', + message: 'Do you want to clone this note?', callback: function(result) { if (result) { - websocketMsgSrv.cloneNotebook(noteId); + websocketMsgSrv.cloneNote(noteId); $location.path('/'); } } @@ -177,14 +177,14 @@ }; // checkpoint/commit notebook - $scope.checkpointNotebook = function(commitMessage) { + $scope.checkpointNote = function(commitMessage) { BootstrapDialog.confirm({ closable: true, title: '', - message: 'Commit notebook to current repository?', + message: 'Commit note to current repository?', callback: function(result) { if (result) { - websocketMsgSrv.checkpointNotebook($routeParams.noteId, commitMessage); + websocketMsgSrv.checkpointNote($routeParams.noteId, commitMessage); } } }); @@ -336,13 +336,13 @@ if (config) { $scope.note.config = config; } - websocketMsgSrv.updateNotebook($scope.note.id, $scope.note.name, $scope.note.config); + websocketMsgSrv.updateNote($scope.note.id, $scope.note.name, $scope.note.config); }; /** Update the note name */ $scope.sendNewName = function() { if ($scope.note.name) { - websocketMsgSrv.updateNotebook($scope.note.id, $scope.note.name, $scope.note.config); + websocketMsgSrv.updateNote($scope.note.id, $scope.note.name, $scope.note.config); } }; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-web/src/components/arrayOrderingSrv/arrayOrdering.service.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/arrayOrderingSrv/arrayOrdering.service.js b/zeppelin-web/src/components/arrayOrderingSrv/arrayOrdering.service.js index 3f7d1b8..7e23ab7 100644 --- a/zeppelin-web/src/components/arrayOrderingSrv/arrayOrdering.service.js +++ b/zeppelin-web/src/components/arrayOrderingSrv/arrayOrdering.service.js @@ -19,7 +19,7 @@ function arrayOrderingSrv() { var arrayOrderingSrv = this; - this.notebookListOrdering = function(note) { + this.noteListOrdering = function(note) { return arrayOrderingSrv.getNoteName(note); }; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-web/src/components/navbar/navbar-noteList-elem.html ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/navbar/navbar-noteList-elem.html b/zeppelin-web/src/components/navbar/navbar-noteList-elem.html new file mode 100644 index 0000000..6d44b96 --- /dev/null +++ b/zeppelin-web/src/components/navbar/navbar-noteList-elem.html @@ -0,0 +1,36 @@ +<!-- +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +--> + +<a class="notebook-list-item" ng-if="note.id" href="#/notebook/{{note.id}}"> + <i style="font-size: 10px; margin-right: 5px;" class="icon-doc"></i> + <span>{{noteName(note)}}</span> +</a> +<li ng-if="!note.id" ng-click="$event.stopPropagation()"> + <expand-collapse> + <div> + <a class="notebook-list-item" href="javascript:void(0)"> + <i style="font-size: 10px; margin-right: 5px;" class="icon-folder"></i> + <span>{{noteName(note)}}</span> + </a> + </div> + <div class="expandable" style="color: black;"> + <ul> + <li ng-repeat="note in note.children | orderBy:navbar.arrayOrderingSrv.noteListOrdering track by $index" + ng-class="{'active' : navbar.isActive(note.id)}" + ng-include="'components/navbar/navbar-noteList-elem.html'"> + </li> + </ul> + </div> + </expand-collapse> +</li> http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-web/src/components/navbar/navbar-notebookList-elem.html ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/navbar/navbar-notebookList-elem.html b/zeppelin-web/src/components/navbar/navbar-notebookList-elem.html deleted file mode 100644 index 590154f..0000000 --- a/zeppelin-web/src/components/navbar/navbar-notebookList-elem.html +++ /dev/null @@ -1,36 +0,0 @@ -<!-- -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. ---> - -<a class="notebook-list-item" ng-if="note.id" href="#/notebook/{{note.id}}"> - <i style="font-size: 10px; margin-right: 5px;" class="icon-doc"></i> - <span>{{noteName(note)}}</span> -</a> -<li ng-if="!note.id" ng-click="$event.stopPropagation()"> - <expand-collapse> - <div> - <a class="notebook-list-item" href="javascript:void(0)"> - <i style="font-size: 10px; margin-right: 5px;" class="icon-folder"></i> - <span>{{noteName(note)}}</span> - </a> - </div> - <div class="expandable" style="color: black;"> - <ul> - <li ng-repeat="note in note.children | orderBy:navbar.arrayOrderingSrv.notebookListOrdering track by $index" - ng-class="{'active' : navbar.isActive(note.id)}" - ng-include="'components/navbar/navbar-notebookList-elem.html'"> - </li> - </ul> - </div> - </expand-collapse> -</li> http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-web/src/components/navbar/navbar.controller.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/navbar/navbar.controller.js b/zeppelin-web/src/components/navbar/navbar.controller.js index 8586960..4778669 100644 --- a/zeppelin-web/src/components/navbar/navbar.controller.js +++ b/zeppelin-web/src/components/navbar/navbar.controller.js @@ -22,7 +22,7 @@ '$http', '$routeParams', '$location', - 'notebookListDataFactory', + 'noteListDataFactory', 'baseUrlSrv', 'websocketMsgSrv', 'arrayOrderingSrv', @@ -30,14 +30,14 @@ ]; function NavCtrl($scope, $rootScope, $http, $routeParams, $location, - notebookListDataFactory, baseUrlSrv, websocketMsgSrv, + noteListDataFactory, baseUrlSrv, websocketMsgSrv, arrayOrderingSrv, searchService) { var vm = this; vm.arrayOrderingSrv = arrayOrderingSrv; vm.connected = websocketMsgSrv.isConnected(); vm.isActive = isActive; vm.logout = logout; - vm.notes = notebookListDataFactory; + vm.notes = noteListDataFactory; vm.search = search; vm.searchForm = searchService; vm.showLoginWindow = showLoginWindow; @@ -57,7 +57,7 @@ } function initController() { - $scope.isDrawNavbarNotebookList = false; + $scope.isDrawNavbarNoteList = false; angular.element('#notebook-list').perfectScrollbar({suppressScrollX: true}); angular.element(document).click(function() { @@ -73,7 +73,7 @@ } function loadNotes() { - websocketMsgSrv.getNotebookList(); + websocketMsgSrv.getNoteList(); } function logout() { @@ -113,7 +113,7 @@ */ $scope.$on('setNoteMenu', function(event, notes) { - notebookListDataFactory.setNotes(notes); + noteListDataFactory.setNotes(notes); }); $scope.$on('setConnectedStatus', function(event, param) { @@ -129,11 +129,11 @@ */ angular.element(document).ready(function() { angular.element('.notebook-list-dropdown').on('show.bs.dropdown', function() { - $scope.isDrawNavbarNotebookList = true; + $scope.isDrawNavbarNoteList = true; }); angular.element('.notebook-list-dropdown').on('hide.bs.dropdown', function() { - $scope.isDrawNavbarNotebookList = false; + $scope.isDrawNavbarNoteList = false; }); }); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-web/src/components/navbar/navbar.html ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/navbar/navbar.html b/zeppelin-web/src/components/navbar/navbar.html index 8851409..d2ec728 100644 --- a/zeppelin-web/src/components/navbar/navbar.html +++ b/zeppelin-web/src/components/navbar/navbar.html @@ -30,10 +30,10 @@ limitations under the License. <ul class="dropdown-menu navbar-dropdown-maxHeight" role="menu"> <li><a href="" data-toggle="modal" data-target="#noteNameModal"><i class="fa fa-plus"></i> Create new note</a></li> <li class="divider"></li> - <div id="notebook-list" class="scrollbar-container" ng-if="isDrawNavbarNotebookList"> + <div id="notebook-list" class="scrollbar-container" ng-if="isDrawNavbarNoteList"> <li class="filter-names" ng-include="'components/filterNoteNames/filter-note-names.html'"></li> - <li ng-repeat="note in navbar.notes.root.children | filter:query.q | orderBy:navbar.arrayOrderingSrv.notebookListOrdering track by $index" - ng-class="{'active' : navbar.isActive(note.id)}" ng-include="'components/navbar/navbar-notebookList-elem.html'"> + <li ng-repeat="note in navbar.notes.root.children | filter:query.q | orderBy:navbar.arrayOrderingSrv.noteListOrdering track by $index" + ng-class="{'active' : navbar.isActive(note.id)}" ng-include="'components/navbar/navbar-noteList-elem.html'"> </li> </div> </ul> @@ -57,7 +57,7 @@ limitations under the License. id="searchTermId" ng-disabled="!navbar.connected" class="form-control" - placeholder="Search your Notebooks" + placeholder="Search your Notes" /> <span class="input-group-btn"> <button http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-web/src/components/noteListDataFactory/noteList.datafactory.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/noteListDataFactory/noteList.datafactory.js b/zeppelin-web/src/components/noteListDataFactory/noteList.datafactory.js new file mode 100644 index 0000000..24ddca7 --- /dev/null +++ b/zeppelin-web/src/components/noteListDataFactory/noteList.datafactory.js @@ -0,0 +1,69 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; +(function() { + + angular.module('zeppelinWebApp').factory('noteListDataFactory', noteListDataFactory); + + function noteListDataFactory() { + var notes = { + root: {children: []}, + flatList: [], + + setNotes: function(notesList) { + // a flat list to boost searching + notes.flatList = angular.copy(notesList); + + // construct the folder-based tree + notes.root = {children: []}; + _.reduce(notesList, function(root, note) { + var noteName = note.name || note.id; + var nodes = noteName.match(/([^\/][^\/]*)/g); + + // recursively add nodes + addNode(root, nodes, note.id); + + return root; + }, notes.root); + } + }; + + var addNode = function(curDir, nodes, noteId) { + if (nodes.length === 1) { // the leaf + curDir.children.push({ + name: nodes[0], + id: noteId + }); + } else { // a folder node + var node = nodes.shift(); + var dir = _.find(curDir.children, + function(c) {return c.name === node && c.children !== undefined;}); + if (dir !== undefined) { // found an existing dir + addNode(dir, nodes, noteId); + } else { + var newDir = { + name: node, + hidden: true, + children: [] + }; + curDir.children.push(newDir); + addNode(newDir, nodes, noteId); + } + } + }; + + return notes; + } + +})(); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-web/src/components/noteName-create/notename.controller.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/noteName-create/notename.controller.js b/zeppelin-web/src/components/noteName-create/notename.controller.js index 5090a77..604254f 100644 --- a/zeppelin-web/src/components/noteName-create/notename.controller.js +++ b/zeppelin-web/src/components/noteName-create/notename.controller.js @@ -18,24 +18,24 @@ NotenameCtrl.$inject = [ '$scope', - 'notebookListDataFactory', + 'noteListDataFactory', '$routeParams', 'websocketMsgSrv' ]; - function NotenameCtrl($scope, notebookListDataFactory, $routeParams, websocketMsgSrv) { + function NotenameCtrl($scope, noteListDataFactory, $routeParams, websocketMsgSrv) { var vm = this; vm.clone = false; - vm.notes = notebookListDataFactory; + vm.notes = noteListDataFactory; vm.websocketMsgSrv = websocketMsgSrv; $scope.note = {}; vm.createNote = function() { if (!vm.clone) { - vm.websocketMsgSrv.createNotebook($scope.note.notename); + vm.websocketMsgSrv.createNote($scope.note.notename); } else { var noteId = $routeParams.noteId; - vm.websocketMsgSrv.cloneNotebook(noteId, $scope.note.notename); + vm.websocketMsgSrv.cloneNote(noteId, $scope.note.notename); } }; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-web/src/components/noteName-import/notenameImport.controller.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/noteName-import/notenameImport.controller.js b/zeppelin-web/src/components/noteName-import/notenameImport.controller.js index abcff43..d2d1b8d 100644 --- a/zeppelin-web/src/components/noteName-import/notenameImport.controller.js +++ b/zeppelin-web/src/components/noteName-import/notenameImport.controller.js @@ -112,7 +112,7 @@ } else { result.name = $scope.note.noteImportName; } - websocketMsgSrv.importNotebook(result); + websocketMsgSrv.importNote(result); //angular.element('#noteImportModal').modal('hide'); } else { $scope.note.errorText = 'Invalid JSON'; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-web/src/components/notebookListDataFactory/notebookList.datafactory.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/notebookListDataFactory/notebookList.datafactory.js b/zeppelin-web/src/components/notebookListDataFactory/notebookList.datafactory.js deleted file mode 100644 index 709edf2..0000000 --- a/zeppelin-web/src/components/notebookListDataFactory/notebookList.datafactory.js +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -'use strict'; -(function() { - - angular.module('zeppelinWebApp').factory('notebookListDataFactory', notebookListDataFactory); - - function notebookListDataFactory() { - var notes = { - root: {children: []}, - flatList: [], - - setNotes: function(notesList) { - // a flat list to boost searching - notes.flatList = angular.copy(notesList); - - // construct the folder-based tree - notes.root = {children: []}; - _.reduce(notesList, function(root, note) { - var noteName = note.name || note.id; - var nodes = noteName.match(/([^\/][^\/]*)/g); - - // recursively add nodes - addNode(root, nodes, note.id); - - return root; - }, notes.root); - } - }; - - var addNode = function(curDir, nodes, noteId) { - if (nodes.length === 1) { // the leaf - curDir.children.push({ - name: nodes[0], - id: noteId - }); - } else { // a folder node - var node = nodes.shift(); - var dir = _.find(curDir.children, - function(c) {return c.name === node && c.children !== undefined;}); - if (dir !== undefined) { // found an existing dir - addNode(dir, nodes, noteId); - } else { - var newDir = { - name: node, - hidden: true, - children: [] - }; - curDir.children.push(newDir); - addNode(newDir, nodes, noteId); - } - } - }; - - return notes; - } - -})(); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-web/src/components/websocketEvents/websocketEvents.factory.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/websocketEvents/websocketEvents.factory.js b/zeppelin-web/src/components/websocketEvents/websocketEvents.factory.js index da261ea..c01b06f 100644 --- a/zeppelin-web/src/components/websocketEvents/websocketEvents.factory.js +++ b/zeppelin-web/src/components/websocketEvents/websocketEvents.factory.js @@ -64,10 +64,10 @@ $location.path('/notebook/' + data.note.id); } else if (op === 'NOTES_INFO') { $rootScope.$broadcast('setNoteMenu', data.notes); - } else if (op === 'LIST_NOTEBOOK_JOBS') { - $rootScope.$broadcast('setNotebookJobs', data.notebookJobs); - } else if (op === 'LIST_UPDATE_NOTEBOOK_JOBS') { - $rootScope.$broadcast('setUpdateNotebookJobs', data.notebookRunningJobs); + } else if (op === 'LIST_NOTE_JOBS') { + $rootScope.$broadcast('setNoteJobs', data.noteJobs); + } else if (op === 'LIST_UPDATE_NOTE_JOBS') { + $rootScope.$broadcast('setUpdateNoteJobs', data.noteRunningJobs); } else if (op === 'AUTH_INFO') { BootstrapDialog.show({ closable: false, http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js b/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js index b163a8e..fd1cc97 100644 --- a/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js +++ b/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js @@ -21,23 +21,23 @@ function websocketMsgSrv($rootScope, websocketEvents) { return { - getHomeNotebook: function() { + getHomeNote: function() { websocketEvents.sendNewEvent({op: 'GET_HOME_NOTE'}); }, - createNotebook: function(noteName) { + createNote: function(noteName) { websocketEvents.sendNewEvent({op: 'NEW_NOTE',data: {name: noteName}}); }, - deleteNotebook: function(noteId) { + deleteNote: function(noteId) { websocketEvents.sendNewEvent({op: 'DEL_NOTE', data: {id: noteId}}); }, - cloneNotebook: function(noteIdToClone, newNoteName) { + cloneNote: function(noteIdToClone, newNoteName) { websocketEvents.sendNewEvent({op: 'CLONE_NOTE', data: {id: noteIdToClone, name: newNoteName}}); }, - getNotebookList: function() { + getNoteList: function() { websocketEvents.sendNewEvent({op: 'LIST_NOTES'}); }, @@ -45,11 +45,11 @@ websocketEvents.sendNewEvent({op: 'RELOAD_NOTES_FROM_REPO'}); }, - getNotebook: function(noteId) { + getNote: function(noteId) { websocketEvents.sendNewEvent({op: 'GET_NOTE', data: {id: noteId}}); }, - updateNotebook: function(noteId, noteName, noteConfig) { + updateNote: function(noteId, noteName, noteConfig) { websocketEvents.sendNewEvent({op: 'NOTE_UPDATE', data: {id: noteId, name: noteName, config: noteConfig}}); }, @@ -146,18 +146,18 @@ }); }, - importNotebook: function(notebook) { + importNote: function(note) { websocketEvents.sendNewEvent({ op: 'IMPORT_NOTE', data: { - notebook: notebook + note: note } }); }, - checkpointNotebook: function(noteId, commitMessage) { + checkpointNote: function(noteId, commitMessage) { websocketEvents.sendNewEvent({ - op: 'CHECKPOINT_NOTEBOOK', + op: 'CHECKPOINT_NOTE', data: { noteId: noteId, commitMessage: commitMessage @@ -198,27 +198,27 @@ return websocketEvents.isConnected(); }, - getNotebookJobsList: function() { - websocketEvents.sendNewEvent({op: 'LIST_NOTEBOOK_JOBS'}); + getNoteJobsList: function() { + websocketEvents.sendNewEvent({op: 'LIST_NOTE_JOBS'}); }, - getUpdateNotebookJobsList: function(lastUpdateServerUnixTime) { + getUpdateNoteJobsList: function(lastUpdateServerUnixTime) { websocketEvents.sendNewEvent( - {op: 'LIST_UPDATE_NOTEBOOK_JOBS', data: {lastUpdateUnixTime: lastUpdateServerUnixTime * 1}} + {op: 'LIST_UPDATE_NOTE_JOBS', data: {lastUpdateUnixTime: lastUpdateServerUnixTime * 1}} ); }, unsubscribeJobManager: function() { - websocketEvents.sendNewEvent({op: 'UNSUBSCRIBE_UPDATE_NOTEBOOK_JOBS'}); + websocketEvents.sendNewEvent({op: 'UNSUBSCRIBE_UPDATE_NOTE_JOBS'}); }, - getInterpreterBindings: function(noteID) { - websocketEvents.sendNewEvent({op: 'GET_INTERPRETER_BINDINGS', data: {noteID: noteID}}); + getInterpreterBindings: function(noteId) { + websocketEvents.sendNewEvent({op: 'GET_INTERPRETER_BINDINGS', data: {noteId: noteId}}); }, - saveInterpreterBindings: function(noteID, selectedSettingIds) { + saveInterpreterBindings: function(noteId, selectedSettingIds) { websocketEvents.sendNewEvent({op: 'SAVE_INTERPRETER_BINDINGS', - data: {noteID: noteID, selectedSettingIds: selectedSettingIds}}); + data: {noteId: noteId, selectedSettingIds: selectedSettingIds}}); }, listConfigurations: function() { http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-web/src/index.html ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/index.html b/zeppelin-web/src/index.html index 8180e68..05a349f 100644 --- a/zeppelin-web/src/index.html +++ b/zeppelin-web/src/index.html @@ -177,7 +177,7 @@ limitations under the License. <script src="components/noteName-create/visible.directive.js"></script> <script src="components/websocketEvents/websocketMsg.service.js"></script> <script src="components/websocketEvents/websocketEvents.factory.js"></script> - <script src="components/notebookListDataFactory/notebookList.datafactory.js"></script> + <script src="components/noteListDataFactory/noteList.datafactory.js"></script> <script src="components/baseUrl/baseUrl.service.js"></script> <script src="components/browser-detect/browserDetect.service.js"></script> <script src="components/saveAs/saveAs.service.js"></script> http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-web/test/spec/controllers/notebook.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/test/spec/controllers/notebook.js b/zeppelin-web/test/spec/controllers/notebook.js index 0b21cc0..44a0c43 100644 --- a/zeppelin-web/test/spec/controllers/notebook.js +++ b/zeppelin-web/test/spec/controllers/notebook.js @@ -6,7 +6,7 @@ describe('Controller: NotebookCtrl', function() { var scope; var websocketMsgSrvMock = { - getNotebook: function() {}, + getNote: function() {}, listRevisionHistory: function() {}, getInterpreterBindings: function() {} }; @@ -19,7 +19,7 @@ describe('Controller: NotebookCtrl', function() { var noteMock = { id: 1, - name: 'my notebook', + name: 'my note', config: {}, }; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-web/test/spec/controllers/notename.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/test/spec/controllers/notename.js b/zeppelin-web/test/spec/controllers/notename.js index 8f6b85a..129f1d1 100644 --- a/zeppelin-web/test/spec/controllers/notename.js +++ b/zeppelin-web/test/spec/controllers/notename.js @@ -5,14 +5,14 @@ describe('Controller: NotenameCtrl', function() { var scope; var ctrl; - var notebookList; + var noteList; beforeEach(inject(function($injector, $rootScope, $controller) { - notebookList = $injector.get('notebookListDataFactory'); + noteList = $injector.get('noteListDataFactory'); scope = $rootScope.$new(); ctrl = $controller('NotenameCtrl', { $scope: scope, - notebookListDataFactory: notebookList + noteListDataFactory: noteList }); })); @@ -25,7 +25,7 @@ describe('Controller: NotenameCtrl', function() { {name: 'Untitled Note 6', id: '4'} ]; - notebookList.setNotes(notesList); + noteList.setNotes(notesList); ctrl.sourceNoteName = 'test name'; expect(ctrl.cloneNoteName()).toEqual('test name 1'); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-web/test/spec/factory/noteList.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/test/spec/factory/noteList.js b/zeppelin-web/test/spec/factory/noteList.js new file mode 100644 index 0000000..07eac9c --- /dev/null +++ b/zeppelin-web/test/spec/factory/noteList.js @@ -0,0 +1,79 @@ +'use strict'; + +describe('Factory: NoteList', function() { + + var noteList; + + beforeEach(function() { + module('zeppelinWebApp'); + + inject(function($injector) { + noteList = $injector.get('noteListDataFactory'); + }); + }); + + it('should generate both flat list and folder-based list properly', function() { + var notesList = [ + {name: 'A', id: '000001'}, + {name: 'B', id: '000002'}, + {id: '000003'}, // note without name + {name: '/C/CA', id: '000004'}, + {name: '/C/CB', id: '000005'}, + {name: '/C/CB/CBA', id: '000006'}, // same name with a dir + {name: '/C/CB/CBA', id: '000007'}, // same name with another note + {name: 'C///CB//CBB', id: '000008'}, + {name: 'D/D[A/DA]B', id: '000009'} // check if '[' and ']' considered as folder seperator + ]; + noteList.setNotes(notesList); + + var flatList = noteList.flatList; + expect(flatList.length).toBe(9); + expect(flatList[0].name).toBe('A'); + expect(flatList[0].id).toBe('000001'); + expect(flatList[1].name).toBe('B'); + expect(flatList[2].name).toBeUndefined(); + expect(flatList[3].name).toBe('/C/CA'); + expect(flatList[4].name).toBe('/C/CB'); + expect(flatList[5].name).toBe('/C/CB/CBA'); + expect(flatList[6].name).toBe('/C/CB/CBA'); + expect(flatList[7].name).toBe('C///CB//CBB'); + expect(flatList[8].name).toBe('D/D[A/DA]B'); + + var folderList = noteList.root.children; + expect(folderList.length).toBe(5); + expect(folderList[0].name).toBe('A'); + expect(folderList[0].id).toBe('000001'); + expect(folderList[1].name).toBe('B'); + expect(folderList[2].name).toBe('000003'); + expect(folderList[3].name).toBe('C'); + expect(folderList[3].id).toBeUndefined(); + expect(folderList[3].children.length).toBe(3); + expect(folderList[3].children[0].name).toBe('CA'); + expect(folderList[3].children[0].id).toBe('000004'); + expect(folderList[3].children[0].children).toBeUndefined(); + expect(folderList[3].children[1].name).toBe('CB'); + expect(folderList[3].children[1].id).toBe('000005'); + expect(folderList[3].children[1].children).toBeUndefined(); + expect(folderList[3].children[2].name).toBe('CB'); + expect(folderList[3].children[2].id).toBeUndefined(); + expect(folderList[3].children[2].children.length).toBe(3); + expect(folderList[3].children[2].children[0].name).toBe('CBA'); + expect(folderList[3].children[2].children[0].id).toBe('000006'); + expect(folderList[3].children[2].children[0].children).toBeUndefined(); + expect(folderList[3].children[2].children[1].name).toBe('CBA'); + expect(folderList[3].children[2].children[1].id).toBe('000007'); + expect(folderList[3].children[2].children[1].children).toBeUndefined(); + expect(folderList[3].children[2].children[2].name).toBe('CBB'); + expect(folderList[3].children[2].children[2].id).toBe('000008'); + expect(folderList[3].children[2].children[2].children).toBeUndefined(); + expect(folderList[4].name).toBe('D'); + expect(folderList[4].id).toBeUndefined(); + expect(folderList[4].children.length).toBe(1); + expect(folderList[4].children[0].name).toBe('D[A'); + expect(folderList[4].children[0].id).toBeUndefined(); + expect(folderList[4].children[0].children[0].name).toBe('DA]B'); + expect(folderList[4].children[0].children[0].id).toBe('000009'); + expect(folderList[4].children[0].children[0].children).toBeUndefined(); + }); + +}); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4f6a0e34/zeppelin-web/test/spec/factory/notebookList.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/test/spec/factory/notebookList.js b/zeppelin-web/test/spec/factory/notebookList.js deleted file mode 100644 index e411f28..0000000 --- a/zeppelin-web/test/spec/factory/notebookList.js +++ /dev/null @@ -1,79 +0,0 @@ -'use strict'; - -describe('Factory: NotebookList', function() { - - var notebookList; - - beforeEach(function() { - module('zeppelinWebApp'); - - inject(function($injector) { - notebookList = $injector.get('notebookListDataFactory'); - }); - }); - - it('should generate both flat list and folder-based list properly', function() { - var notesList = [ - {name: 'A', id: '000001'}, - {name: 'B', id: '000002'}, - {id: '000003'}, // notebook without name - {name: '/C/CA', id: '000004'}, - {name: '/C/CB', id: '000005'}, - {name: '/C/CB/CBA', id: '000006'}, // same name with a dir - {name: '/C/CB/CBA', id: '000007'}, // same name with another note - {name: 'C///CB//CBB', id: '000008'}, - {name: 'D/D[A/DA]B', id: '000009'} // check if '[' and ']' considered as folder seperator - ]; - notebookList.setNotes(notesList); - - var flatList = notebookList.flatList; - expect(flatList.length).toBe(9); - expect(flatList[0].name).toBe('A'); - expect(flatList[0].id).toBe('000001'); - expect(flatList[1].name).toBe('B'); - expect(flatList[2].name).toBeUndefined(); - expect(flatList[3].name).toBe('/C/CA'); - expect(flatList[4].name).toBe('/C/CB'); - expect(flatList[5].name).toBe('/C/CB/CBA'); - expect(flatList[6].name).toBe('/C/CB/CBA'); - expect(flatList[7].name).toBe('C///CB//CBB'); - expect(flatList[8].name).toBe('D/D[A/DA]B'); - - var folderList = notebookList.root.children; - expect(folderList.length).toBe(5); - expect(folderList[0].name).toBe('A'); - expect(folderList[0].id).toBe('000001'); - expect(folderList[1].name).toBe('B'); - expect(folderList[2].name).toBe('000003'); - expect(folderList[3].name).toBe('C'); - expect(folderList[3].id).toBeUndefined(); - expect(folderList[3].children.length).toBe(3); - expect(folderList[3].children[0].name).toBe('CA'); - expect(folderList[3].children[0].id).toBe('000004'); - expect(folderList[3].children[0].children).toBeUndefined(); - expect(folderList[3].children[1].name).toBe('CB'); - expect(folderList[3].children[1].id).toBe('000005'); - expect(folderList[3].children[1].children).toBeUndefined(); - expect(folderList[3].children[2].name).toBe('CB'); - expect(folderList[3].children[2].id).toBeUndefined(); - expect(folderList[3].children[2].children.length).toBe(3); - expect(folderList[3].children[2].children[0].name).toBe('CBA'); - expect(folderList[3].children[2].children[0].id).toBe('000006'); - expect(folderList[3].children[2].children[0].children).toBeUndefined(); - expect(folderList[3].children[2].children[1].name).toBe('CBA'); - expect(folderList[3].children[2].children[1].id).toBe('000007'); - expect(folderList[3].children[2].children[1].children).toBeUndefined(); - expect(folderList[3].children[2].children[2].name).toBe('CBB'); - expect(folderList[3].children[2].children[2].id).toBe('000008'); - expect(folderList[3].children[2].children[2].children).toBeUndefined(); - expect(folderList[4].name).toBe('D'); - expect(folderList[4].id).toBeUndefined(); - expect(folderList[4].children.length).toBe(1); - expect(folderList[4].children[0].name).toBe('D[A'); - expect(folderList[4].children[0].id).toBeUndefined(); - expect(folderList[4].children[0].children[0].name).toBe('DA]B'); - expect(folderList[4].children[0].children[0].id).toBe('000009'); - expect(folderList[4].children[0].children[0].children).toBeUndefined(); - }); - -});
