diff --git css/angular/files.css solr/webapp/web/css/angular/files.css new file mode 100644 index 0000000..46b3e8c --- /dev/null +++ css/angular/files.css @@ -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; +} diff --git index.html solr/webapp/web/index.html index 5188df8..b6d3dc7 100644 --- index.html +++ index.html @@ -29,7 +29,7 @@ limitations under the License. - + @@ -65,6 +65,7 @@ limitations under the License. + diff --git js/angular/app.js solr/webapp/web/js/angular/app.js index 8af05ec..cf39853 100644 --- js/angular/app.js +++ js/angular/app.js @@ -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' @@ -85,7 +89,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; } }) @@ -133,10 +137,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}); + }); }); } } diff --git js/angular/controllers/files.js solr/webapp/web/js/angular/controllers/files.js new file mode 100644 index 0000000..2fa4020 --- /dev/null +++ js/angular/controllers/files.js @@ -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(); + }); diff --git js/angular/services.js solr/webapp/web/js/angular/services.js index 1ac9077..b30af03 100644 --- js/angular/services.js +++ js/angular/services.js @@ -141,7 +141,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) { diff --git partials/files.html solr/webapp/web/partials/files.html new file mode 100644 index 0000000..1278fbe --- /dev/null +++ partials/files.html @@ -0,0 +1,47 @@ + +
+