You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by er...@apache.org on 2015/04/04 19:15:00 UTC

svn commit: r1671281 - in /lucene/dev/trunk: partials/files.html solr/webapp/web/css/angular/files.css solr/webapp/web/index.html solr/webapp/web/js/angular/app.js solr/webapp/web/js/angular/controllers/files.js solr/webapp/web/js/angular/services.js

Author: erick
Date: Sat Apr  4 17:14:59 2015
New Revision: 1671281

URL: http://svn.apache.org/r1671281
Log:
SOLR-7263: Add files tab support to AngularJS Admin UI

Added:
    lucene/dev/trunk/partials/files.html   (with props)
    lucene/dev/trunk/solr/webapp/web/css/angular/files.css   (with props)
    lucene/dev/trunk/solr/webapp/web/js/angular/controllers/files.js   (with props)
Modified:
    lucene/dev/trunk/solr/webapp/web/index.html
    lucene/dev/trunk/solr/webapp/web/js/angular/app.js
    lucene/dev/trunk/solr/webapp/web/js/angular/services.js

Added: lucene/dev/trunk/partials/files.html
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/partials/files.html?rev=1671281&view=auto
==============================================================================
--- lucene/dev/trunk/partials/files.html (added)
+++ lucene/dev/trunk/partials/files.html Sat Apr  4 17:14:59 2015
@@ -0,0 +1,47 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You 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.
+-->
+<div id="files" class="clearfix">
+
+  <div id="frame">
+
+    <div id="tree-holder">
+
+     <jstree class="tree" on-select="showTreeLink(data)" data="tree" id="tree"></jstree>
+
+    </div>
+    <div id="file-content" class="clearfix">
+
+      <div class="top clearfix">
+
+        <a id="url" class="address-bar" href="{{url}}" ng-show="url">{{url}}</a>
+
+      </div>
+
+      <div class="view-file">
+
+        <div class="response" ng-show="content">
+            <pre class="syntax language-{{lang}}"><code ng-bind-html="content | highlight:lang | unsafe"></code></pre>
+        </div>
+
+
+      </div>
+
+    </div>
+
+  </div>
+
+</div>
\ No newline at end of file

Added: lucene/dev/trunk/solr/webapp/web/css/angular/files.css
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/webapp/web/css/angular/files.css?rev=1671281&view=auto
==============================================================================
--- lucene/dev/trunk/solr/webapp/web/css/angular/files.css (added)
+++ lucene/dev/trunk/solr/webapp/web/css/angular/files.css Sat Apr  4 17:14:59 2015
@@ -0,0 +1,53 @@
+/*
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You 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.
+
+*/
+
+#content #files #tree-holder
+{
+  float: left;
+  width: 20%;
+}
+
+#content #files #tree-holder li
+{
+  overflow: hidden;
+}
+
+#content #files form .buttons button
+{
+  float: right;
+}
+
+#content #files #file-content
+{
+  float: right;
+  position: relative;
+  width: 78%;
+  min-height: 100px
+}
+
+#content #files .show #file-content
+{
+  display: block;
+}
+
+#content #files #file-content .response
+{
+  border: 1px solid transparent;
+  padding: 2px;
+}

Modified: lucene/dev/trunk/solr/webapp/web/index.html
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/webapp/web/index.html?rev=1671281&r1=1671280&r2=1671281&view=diff
==============================================================================
--- lucene/dev/trunk/solr/webapp/web/index.html (original)
+++ lucene/dev/trunk/solr/webapp/web/index.html Sat Apr  4 17:14:59 2015
@@ -29,7 +29,7 @@ limitations under the License.
   <link rel="stylesheet" type="text/css" href="css/angular/cores.css?_=${version}">
   <link rel="stylesheet" type="text/css" href="css/styles/dashboard.css?_=${version}">
   <link rel="stylesheet" type="text/css" href="css/styles/dataimport.css?_=${version}">
-  <link rel="stylesheet" type="text/css" href="css/styles/files.css?_=${version}">
+  <link rel="stylesheet" type="text/css" href="css/angular/files.css?_=${version}">
   <link rel="stylesheet" type="text/css" href="css/angular/index.css?_=${version}">
   <link rel="stylesheet" type="text/css" href="css/styles/java-properties.css?_=${version}">
   <link rel="stylesheet" type="text/css" href="css/angular/logging.css?_=${version}">
@@ -64,6 +64,7 @@ limitations under the License.
   <script src="js/angular/controllers/core-overview.js"></script>
   <script src="js/angular/controllers/analysis.js"></script>
   <script src="js/angular/controllers/documents.js"></script>
+  <script src="js/angular/controllers/files.js"></script>
   <script src="js/angular/controllers/query.js"></script>
 
 </head>

Modified: lucene/dev/trunk/solr/webapp/web/js/angular/app.js
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/webapp/web/js/angular/app.js?rev=1671281&r1=1671280&r2=1671281&view=diff
==============================================================================
--- lucene/dev/trunk/solr/webapp/web/js/angular/app.js (original)
+++ lucene/dev/trunk/solr/webapp/web/js/angular/app.js Sat Apr  4 17:14:59 2015
@@ -71,6 +71,10 @@ solrAdminApp.config([
         templateUrl: 'partials/documents.html',
         controller: 'DocumentsController'
       }).
+      when('/:core/files', {
+        templateUrl: 'partials/files.html',
+        controller: 'FilesController'
+      }).
       when('/:core/query', {
         templateUrl: 'partials/query.html',
         controller: 'QueryController'
@@ -81,7 +85,7 @@ solrAdminApp.config([
 }])
 .filter('highlight', function($sce) {
   return function(input, lang) {
-    if (lang && input) return hljs.highlight(lang, input).value;
+    if (lang && input && lang!="text") return hljs.highlight(lang, input).value;
     return input;
   }
 })
@@ -129,10 +133,14 @@ solrAdminApp.config([
                         "animation" : 0
                       }
                   };
-                  var tree = $(element).jstree(treeConfig).jstree('open_node','li:first');
+
+                  var tree = $(element).jstree(treeConfig);
+                  tree.jstree('open_node','li:first');
                   if (tree) {
-                      tree.bind("select_node.jstree", function (event, data) {
-                          scope.onSelect({url: data.args[0].href});
+                      element.bind("select_node.jstree", function (event, data) {
+                          scope.$apply(function() {
+                              scope.onSelect({url: data.args[0].href, data: data});
+                          });
                       });
                   }
                 }

Added: lucene/dev/trunk/solr/webapp/web/js/angular/controllers/files.js
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/webapp/web/js/angular/controllers/files.js?rev=1671281&view=auto
==============================================================================
--- lucene/dev/trunk/solr/webapp/web/js/angular/controllers/files.js (added)
+++ lucene/dev/trunk/solr/webapp/web/js/angular/controllers/files.js Sat Apr  4 17:14:59 2015
@@ -0,0 +1,82 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+*/
+
+var contentTypeMap = { xml : 'text/xml', html : 'text/html', js : 'text/javascript', json : 'application/json', 'css' : 'text/css' };
+var languages = {js: "javascript", xml:"xml", xsl:"xml", html: "xml", json: "text", css: "css"};
+
+solrAdminApp.controller('FilesController',
+    function($scope, $rootScope, $routeParams, $location, Files) {
+        $scope.resetMenu("files");
+
+        $scope.file = $location.search().file;
+        $scope.content = null;
+
+        $scope.baseurl = $location.protocol()+ "://" + $location.host() + ":" + $location.port();
+
+        $scope.refresh = function () {
+
+            var process = function (path, tree) {
+
+                Files.list({core: $routeParams.core, file: path}, function (data) {
+                    for (var file in data.files) {
+                        var filedata = data.files[file];
+                        var state = undefined;
+                        var children = undefined;
+
+                        if (filedata.directory) {
+                            file = file + "/";
+                            if ($scope.file && $scope.file.indexOf(path + file) == 0) {
+                                state = "open";
+                            } else {
+                                state = "closed";
+                            }
+                            children = [];
+                            process(path + file, children);
+                        }
+                        tree.push({
+                            data: {
+                                title: file,
+                                attr: { id: path + file}
+                            },
+                            children: children,
+                            state: state
+                        });
+                    }
+                });
+            }
+            $scope.tree = [];
+            process("", $scope.tree);
+
+            if ($scope.file && $scope.file != '' && $scope.file.split('').pop()!='/') {
+                var extension = $scope.file.match( /\.(\w+)$/)[1] || '';
+                var contentType = (contentTypeMap[extension] || 'text/plain' ) + ';charset=utf-8';
+
+                Files.get({core: $routeParams.core, file: $scope.file, contentType: contentType}, function(data) {
+                    $scope.content = data.data;
+                    $scope.url = $scope.baseurl + data.config.url + "?" + $.param(data.config.params);
+                    $scope.lang = languages[extension] || "text";
+                });
+            }
+        };
+
+        $scope.showTreeLink = function(data) {
+            var file = data.args[0].id;
+            $location.search({file:file});
+        };
+
+        $scope.refresh();
+    });

Modified: lucene/dev/trunk/solr/webapp/web/js/angular/services.js
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/webapp/web/js/angular/services.js?rev=1671281&r1=1671280&r2=1671281&view=diff
==============================================================================
--- lucene/dev/trunk/solr/webapp/web/js/angular/services.js (original)
+++ lucene/dev/trunk/solr/webapp/web/js/angular/services.js Sat Apr  4 17:14:59 2015
@@ -129,7 +129,12 @@ solrAdminServices.factory('System',
   }])
 .factory('Files',
   ['$resource', function($resource) {
-    return $resource('/solr/:core/admin/file', {'wt':'json', '_':Date.now()}); // @core
+    return $resource('/solr/:core/admin/file', {'wt':'json', core: '@core', '_':Date.now()}, {
+      "list": {},
+      "get": {method: "GET", interceptor: {
+          response: function(config) {return config;}
+      }}
+    });
   }])
 .factory('Query', // use $http for Query, as we need complete control over the URL
   ['$http', '$location', function($http, $location) {