SOLR-7263: Add files tab support to AngularJS Admin UI

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1671281 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erick Erickson 2015-04-04 17:14:59 +00:00
parent 1aaf420958
commit 7092d9a022
6 changed files with 202 additions and 6 deletions

47
partials/files.html Normal file
View File

@ -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>

View File

@ -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;
}

View File

@ -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>

View File

@ -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});
});
});
}
}

View File

@ -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();
});

View File

@ -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) {