chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1297353 - /chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/index.html
Date Tue, 06 Mar 2012 06:53:17 GMT
Author: jens
Date: Tue Mar  6 06:53:17 2012
New Revision: 1297353

URL: http://svn.apache.org/viewvc?rev=1297353&view=rev
Log:
add support for createFolder, better error display, add content link, minor improvements

Modified:
    chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/index.html

Modified: chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/index.html
URL: http://svn.apache.org/viewvc/chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/index.html?rev=1297353&r1=1297352&r2=1297353&view=diff
==============================================================================
--- chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/index.html (original)
+++ chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/index.html Tue
Mar  6 06:53:17 2012
@@ -44,7 +44,7 @@
     }
  	            
     function createSession(connectionUrl, repoId) {
- 	            console.log("Initialzing session to " + connectionUrl);
+ 	            console.log("Initializing session to " + connectionUrl);
  	            var factory = new CmisSessionFactory({
  	                url : connectionUrl,
  	                repositoryId : repoId
@@ -105,11 +105,17 @@
                 row = null;
                 tbody.append(row = $('<tr>'));
                 for (var propKey in propsToDisplay) {
-                    var prop = children.objects[child].object.properties[propsToDisplay[propKey]];
-                    console.log ("add col: " + prop.value);
-                    if (null != prop && null != prop.value)
-			            row.append($('<td>').text(convertValue(prop.value, prop.type)));
-                    else
+                    var props = children.objects[child].object.properties;
+                    var prop = props[propsToDisplay[propKey]];
+                    if (null != prop && null != prop.value) {
+                        var text = convertValue(prop.value, prop.type);
+                        if (baseType == "cmis:document" && propsToDisplay[propKey]
== "cmis:name" && props["cmis:contentStreamFileName"] != null &&
+                                props["cmis:contentStreamFileName"].value != null) {
+                            text = "<a href='" + session.getRootUrl() + "?cmisselector=content&objectId="
+ props["cmis:objectId"].value + "' >" + text + "</a>"
+                        }
+			            row.append($('<td>').html(text));
+	                    console.log ("add col: " + prop.value);
+                    } else
                         row.append($('<td>'));//.text("<n/a>"));
 		        }
             }
@@ -121,7 +127,7 @@
     function getTypesRecursive(typeId, tbl) {
         console.log("getTypesRecursive: " + typeId );
     	session.getTypeChildren(typeId, function(types) {
-	    	if (!checkError(types)) {
+	    	if (!checkError(types, "#typessection")) {
 	    	    for (var i in types.types) {	    	        
 	                tbl.append(row = $('<tr>'));
 	                row.append($('<td>').text(types.types[i].id ));
@@ -137,20 +143,22 @@
     	});
     }
     
-    function checkSession() {
+    function checkSession(domId) {
 	    if (null == session)
-    	    displayError("No session! Please connect first...");
+    	    displayError("No session! Please connect first...", domId);
     }
 
-    function displayError(cmisError) {
-        $("#errorsection *").remove();
-        $("#errorsection").append($("<p>").text(cmisError.toString()).css("color",
"red"));        
+    function displayError(cmisError, domId) {
+        if (null == domId)
+            domId = "#errorsection";
+        $(domId + " *").remove();
+        $(domId).append($("<p>").text(cmisError.toString()).css("color", "red")); 
      
     }
     
-    function checkError(jsonObj) {
+    function checkError(jsonObj, domId) {
         if (jsonObj != null && jsonObj.exception != null) {
             var cmisError = session.createErrorFromErrorResponse(jsonObj);
-            displayError(cmisError);
+            displayError(cmisError, domId);
             return cmisError;
         } else
             return null;
@@ -180,34 +188,36 @@
             	$("#repoidfield").attr('value', firstRepoId);
             	$("#folderidfield").attr('value', repoInfos[firstRepoId].rootFolderId);
             	
-            	createSession($("#reposfield").val(), "A1");
+            	createSession($("#reposfield").val(), firstRepoId);
             });
         });
         
         $('#repositoryInfo').click(function() {
-            checkSession();
+            checkSession("#repoinfosection");
             session.getRepositoryInfo(function(repoInfos) {
                 console.log("getRepositoryInfo()");
                 for (var repoInfo in repoInfos) {
-                	var text = "Found Repository with id: " + repoInfos[repoInfo].repositoryId
+
-                	", vendor: " +  repoInfos[repoInfo].vendorName + 
-                	",  description: " +  repoInfos[repoInfo].repositoryDescription + 
-                	", root url: " + repoInfos[repoInfo].rootFolderUrl;
-                	$("#repoinfosection").html(text);
                 	session.rootFolderId = repoInfos[repoInfo].rootFolderId;
                 	session.rootUrl = repoInfos[repoInfo].rootFolderUrl;
+                    var tbl = $('<table>').attr('border', 1);    
+                  	tbl.append($('<tr>').append($('<td>').text("Repository-Id")).append($('<td>').text(repoInfos[repoInfo].repositoryId)));
+                  	tbl.append($('<tr>').append($('<td>').text("Vendor")).append($('<td>').text(repoInfos[repoInfo].vendorName)));
+                  	tbl.append($('<tr>').append($('<td>').text("Description")).append($('<td>').text(repoInfos[repoInfo].repositoryDescription)));
+                  	tbl.append($('<tr>').append($('<td>').text("Root-URL")).append($('<td>').text(repoInfos[repoInfo].rootFolderUrl)));
+                  	tbl.append($('<tr>').append($('<td>').text("Root-Folder-Id")).append($('<td>').text(repoInfos[repoInfo].rootFolderId)));
+                  	$("#repoinfosection").append(tbl);
                 	break;
                 }
             });
         });
 
-        $('#typebutton').click(function() {
-            checkSession();
+        $('#typebutton').click(function() {            
+            $("#typessection *").remove();
+
+            checkSession("#typessection");
             
             var tbl = $('<table>').attr('id', 'typesTable').attr('border', 1);    
-            $("#typessection *").remove();
           	$("#typessection").append($('<h4>').text("Type Definitions:")).append(tbl);
-
           	tbl.append(row = $('<tr>'));
             row.append($('<td>').text("Type-Id"));
             row.append($('<td>').text("Parent-Id"));
@@ -218,9 +228,9 @@
         });
 
         $('#getbutton').click(function() {
-            checkSession();
+            checkSession("#documentsection");
             session.getDocument($('#docidfield').val(), function(doc) {
-            	if (!checkError(doc)) {
+            	if (!checkError(doc, "#documentsection")) {
                   	console.log("getObject cmis:name= " + doc.properties["cmis:name"].value);
                   	var text = "Retrieved document with cmis:name= " + doc.properties["cmis:name"].value;
                   	$("#documentsection").html(text)
@@ -229,9 +239,9 @@
         });
         
         $('#deletebutton').click(function() {
-            checkSession();
+            checkSession("#documentsection");
             session.deleteDocument($('#docidfield').val(), function(doc) {
-            	if (!checkError(doc)) {
+            	if (!checkError(doc, "#documentsection")) {
                   	console.log("Deleted document with id: " + $('#docidfield').val());
                   	$("#documentsection").html("Deleted document with id: " + $('#docidfield').val());
             	}
@@ -239,11 +249,11 @@
         });
         
         $('#cmischildren').click(function() {
-            checkSession();
+            checkSession("#childrensection");
             var rootFolderId = session.rootFolderId == null ? session.rootFolderId : 100;
             
             session.getChildren($('#folderidfield').val(), function(children) {
-                if (!checkError(children)) {
+                if (!checkError(children, "#childrensection")) {
                   	var tbl1 = createTable(children, "cmis:folder");
                   	var tbl2 = createTable(children, "cmis:document");
                     $("#childrensection *").remove();
@@ -255,14 +265,26 @@
         });
         
         $('#createdoc').click(function() {
-            checkSession();
-           	session.createDocument($('#name').val(), $('#typeId').val(), $('#folderId').val(),
function(data) {
-   				var text = "Document successfully created with id: " + data.properties["cmis:objectId"].value;
-        			$("#createdocsection").html(text);
+            checkSession("#createdocsection");
+           	session.createDocument($('#name').val(), $('#typeId').val(), $('#folderId').val(),
null, function(data) {
+           	 	if (!checkError(data, "#createdocsection")) {
+	   				var text = "Document successfully created with id: " + data.properties["cmis:objectId"].value;
+    	    			$("#createdocsection").html(text);
+           	 	}
            	});
         });
         
-	});    
+        $('#createfolder').click(function() {
+            checkSession("#createfoldersection");
+           	session.createFolder($('#fName').val(), $('#fTypeId').val(), $('#fFolderId').val(),
null, function(data) {
+           	 	if (!checkError(data, "#createfoldersection")) {
+   					var text = "Folder successfully created with id: " + data.properties["cmis:objectId"].value;
+        				$("#createfoldersection").html(text);
+           	 	}
+           	});
+        });
+
+    });    
     </script>
     
     <div id="errorsection"> </div>
@@ -284,15 +306,15 @@
     <button id="repositories">Connect!</button> <br/>
     <div id="repositoriessection">
     </div>
-    <hr/>    
     <form >
 	    <table>
 	      <tr>
-	        <td><label for="repoidfield">Repository-Id:</label></td>
-	        <td><input type="text" id="repoidfield" value="?"/></td>
+	        <td><label for="repoidfield">Using Repository-Id:</label></td>
+	        <td><input type="text" id="repoidfield" value="?" readonly="readonly"/></td>
 	      </tr>
 	    </table>
 	</form>
+    <hr/>    
     <button id="repositoryInfo">Get RepositoryInfo!</button> <br/>
     <div id="repoinfosection">
     </div>
@@ -395,5 +417,28 @@
 	</form>
     <div id="createdochtmlsection">
     </div>        
+    <h3> Create Folder (Ajax): </h3>
+    <form >
+	  <fieldset>
+	    <legend>Create Folder</legend>
+	    <table>
+	      <tr>
+	        <td><label for="name">Name:</label></td>
+	        <td><input type="text" id="fName" name="Name" value="My folder"/></td>
+	      </tr>
+	      <tr>
+	        <td><label for="typeId">Type-Id:</label></td>
+	        <td><input type="text" id="fTypeId" name="Type" value="cmis:folder"/></td>
+	      </tr>
+	      <tr>
+	        <td><label for="folderId">Folder-Id:</label></td>
+	        <td><input type="text" id="fFolderId" name="Folder Id" value="100"/></td>
+	      </tr>
+	    </table>
+	  </fieldset>
+	</form>
+    <button id="createfolder">Create Folder!</button>  <br/>
+    <div id="createfoldersection">
+    </div>   
   </body>
 </html>
\ No newline at end of file



Mime
View raw message