You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ss...@apache.org on 2013/11/28 20:36:53 UTC

[5/6] git commit: start working on a user interface for logging configuration using AngularJS (MARMOTTA-390)

start working on a user interface for logging configuration using AngularJS (MARMOTTA-390)


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/1154a3d2
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/1154a3d2
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/1154a3d2

Branch: refs/heads/develop
Commit: 1154a3d2f954d893d7ada2f1cdc929ff46db2c54
Parents: 3d9163b
Author: Sebastian Schaffert <ss...@apache.org>
Authored: Thu Nov 28 20:35:47 2013 +0100
Committer: Sebastian Schaffert <ss...@apache.org>
Committed: Thu Nov 28 20:35:47 2013 +0100

----------------------------------------------------------------------
 parent/pom.xml                                  |   4 +
 platform/marmotta-core/pom.xml                  |   4 +
 .../services/logging/LoggingServiceImpl.java    |  17 +-
 .../src/main/resources/kiwi-module.properties   |  31 +--
 .../main/resources/web/admin/configuration.html |   2 +-
 .../src/main/resources/web/admin/js/logging.js  |  69 ++++++
 .../src/main/resources/web/admin/logging.html   | 219 +++++++++++++++++++
 7 files changed, 328 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/1154a3d2/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index d16ed01..0120b6a 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -917,6 +917,10 @@
                 <version>1.8.21</version>
             </dependency>
             <dependency>
+                <groupId>org.webjars</groupId>
+                <artifactId>angularjs</artifactId>
+                <version>1.2.2</version>
+            </dependency>            <dependency>
                 <groupId>org.apache.marmotta.webjars</groupId>
                 <artifactId>codemirror</artifactId>
                 <version>${project.version}</version>

http://git-wip-us.apache.org/repos/asf/marmotta/blob/1154a3d2/platform/marmotta-core/pom.xml
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/pom.xml b/platform/marmotta-core/pom.xml
index 487dacb..41ee240 100644
--- a/platform/marmotta-core/pom.xml
+++ b/platform/marmotta-core/pom.xml
@@ -316,6 +316,10 @@
             <artifactId>jquery</artifactId>
         </dependency>
         <dependency>
+            <groupId>org.webjars</groupId>
+            <artifactId>angularjs</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.apache.marmotta.webjars</groupId>
             <artifactId>sgvizler</artifactId>
         </dependency>

http://git-wip-us.apache.org/repos/asf/marmotta/blob/1154a3d2/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/logging/LoggingServiceImpl.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/logging/LoggingServiceImpl.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/logging/LoggingServiceImpl.java
index 0265660..47671a3 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/logging/LoggingServiceImpl.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/logging/LoggingServiceImpl.java
@@ -31,7 +31,6 @@ import com.google.common.base.Function;
 import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.CacheLoader;
 import com.google.common.cache.LoadingCache;
-import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 import org.apache.commons.lang3.StringUtils;
@@ -56,7 +55,10 @@ import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.inject.Inject;
 import java.io.File;
+import java.text.Collator;
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -129,7 +131,7 @@ public class LoggingServiceImpl implements LoggingService {
 
         loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
 
-        log.info("- configured logging modules: {}", StringUtils.join(Iterables.transform(loggingModules, new Function<LoggingModule, Object>() {
+        log.info("- configured logging modules: {}", StringUtils.join(Iterables.transform(listModules(), new Function<LoggingModule, Object>() {
             @Override
             public Object apply(LoggingModule input) {
                 return input.getName();
@@ -392,6 +394,15 @@ public class LoggingServiceImpl implements LoggingService {
      */
     @Override
     public List<LoggingModule> listModules() {
-        return ImmutableList.copyOf(loggingModules);
+        List<LoggingModule> result = Lists.newArrayList(loggingModules);
+
+        Collections.sort(result, new Comparator<LoggingModule>() {
+            @Override
+            public int compare(LoggingModule o1, LoggingModule o2) {
+                return Collator.getInstance().compare(o1.getName(), o2.getName());
+            }
+        });
+
+        return result;
     }
 }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/1154a3d2/platform/marmotta-core/src/main/resources/kiwi-module.properties
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/resources/kiwi-module.properties b/platform/marmotta-core/src/main/resources/kiwi-module.properties
index a71bb0b..7fe8273 100644
--- a/platform/marmotta-core/src/main/resources/kiwi-module.properties
+++ b/platform/marmotta-core/src/main/resources/kiwi-module.properties
@@ -35,26 +35,29 @@ adminpage.0.link=/admin/about.html
 adminpage.1.title=Configuration
 adminpage.1.link=/admin/configuration.html
 
-adminpage.2.title=Tasks
-adminpage.2.link=/admin/tasks.html
+adminpage.2.title=Logging
+adminpage.2.link=/admin/logging.html
 
-adminpage.3.title=Import
-adminpage.3.link=/admin/import.html
+adminpage.3.title=Tasks
+adminpage.3.link=/admin/tasks.html
 
-adminpage.4.title=Export
-adminpage.4.link=/admin/export.html
+adminpage.4.title=Import
+adminpage.4.link=/admin/import.html
 
-adminpage.5.title=Data Views
-adminpage.5.link=/admin/dataview.html
+adminpage.5.title=Export
+adminpage.5.link=/admin/export.html
 
-adminpage.6.title=Context Manager
-adminpage.6.link=/admin/contexts.html
+adminpage.6.title=Data Views
+adminpage.6.link=/admin/dataview.html
 
-adminpage.7.title=Prefix Manager
-adminpage.7.link=/admin/prefixes.html
+adminpage.7.title=Context Manager
+adminpage.7.link=/admin/contexts.html
 
-adminpage.8.title=System
-adminpage.8.link=/admin/system.html
+adminpage.8.title=Prefix Manager
+adminpage.8.link=/admin/prefixes.html
+
+adminpage.9.title=System
+adminpage.9.link=/admin/system.html
 
 webservices=org.apache.marmotta.platform.core.webservices.config.ConfigurationWebService,\
   org.apache.marmotta.platform.core.webservices.config.DependenciesWebService,\

http://git-wip-us.apache.org/repos/asf/marmotta/blob/1154a3d2/platform/marmotta-core/src/main/resources/web/admin/configuration.html
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/resources/web/admin/configuration.html b/platform/marmotta-core/src/main/resources/web/admin/configuration.html
index 8d21780..4f33d53 100644
--- a/platform/marmotta-core/src/main/resources/web/admin/configuration.html
+++ b/platform/marmotta-core/src/main/resources/web/admin/configuration.html
@@ -29,7 +29,7 @@
             var options = {
                 url : _SERVER_URL,
                 container : "lmf_configurator",
-                blacklist: ['ldcache.endpoint.','ldcache.endpoint.','prefix.','security.permission.','security.restriction.','database.','solr.cores.available','solr.cores.enabled','user.admin.']
+                blacklist: ['ldcache.endpoint.','ldcache.endpoint.','prefix.','security.permission.','security.restriction.','database.','solr.cores.available','solr.cores.enabled','user.admin.', "logging."]
             }
             var configurator = new Configurator(options);
         });

http://git-wip-us.apache.org/repos/asf/marmotta/blob/1154a3d2/platform/marmotta-core/src/main/resources/web/admin/js/logging.js
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/resources/web/admin/js/logging.js b/platform/marmotta-core/src/main/resources/web/admin/js/logging.js
new file mode 100644
index 0000000..eabceed
--- /dev/null
+++ b/platform/marmotta-core/src/main/resources/web/admin/js/logging.js
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: wastl
+ * Date: 28.11.13
+ * Time: 16:54
+ * To change this template use File | Settings | File Templates.
+ */
+var loggingApp = angular.module('logging', []);
+
+loggingApp.controller('LoggingController', function ($scope, $http) {
+    $http.get(url + 'logging/modules').success(function(data) {
+        $scope.modules = data;
+    });
+
+    $http.get(url + 'logging/appenders').success(function(data) {
+        $scope.appenders = data;
+    });
+
+    $scope.updateAppender = function(appender) {
+        $http.post(url + 'logging/appenders/' + appender.id, appender);
+    };
+
+    $scope.updateModule = function(module) {
+        $http.post(url + 'logging/modules/' + module.id, module);
+    };
+
+    $scope.removeModuleAppender = function(module,appender_id) {
+        var i = module.appenders.indexOf(appender_id);
+        if(i >= 0) {
+            module.appenders.splice(i,1);
+            $scope.updateModule(module);
+        }
+    };
+
+    $scope.addModuleAppender = function(module,appender_id) {
+        var i = module.appenders.indexOf(appender_id);
+        if(i < 0) {
+            module.appenders.push(appender_id);
+            $scope.updateModule(module);
+        }
+    };
+
+    $scope.getUnselectedModuleAppenders = function(module) {
+        var result = [];
+        for(idx in $scope.appenders) {
+            if(module.appenders.indexOf($scope.appenders[idx].id) < 0) {
+                result.push($scope.appenders[idx]);
+            }
+        }
+        return result;
+    };
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/marmotta/blob/1154a3d2/platform/marmotta-core/src/main/resources/web/admin/logging.html
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/resources/web/admin/logging.html b/platform/marmotta-core/src/main/resources/web/admin/logging.html
new file mode 100644
index 0000000..dd4ab0d
--- /dev/null
+++ b/platform/marmotta-core/src/main/resources/web/admin/logging.html
@@ -0,0 +1,219 @@
+<!--
+
+    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.
+
+-->
+<html>
+<head>
+    <!--###BEGIN_HEAD###-->
+    <title>Logging Configuration</title>
+    <script type="text/javascript" src="../../webjars/jquery/1.8.2/jquery.min.js"></script>
+    <script type="text/javascript" src="../../webjars/angularjs/1.2.2/angular.min.js"></script>
+    <script type="text/javascript">
+        var url = _SERVER_URL;
+    </script>
+    <script type="text/javascript" src="js/logging.js"></script>
+
+    <style>
+        table.appenders {
+            width: 80%;
+            border-collapse: collapse;
+        }
+
+        th {
+            text-align: left;
+            background-color: darkgray;
+            color: white;
+        }
+
+        td {
+            vertical-align: top;
+        }
+
+        table.appenders .name {
+            width: 20%;
+        }
+        table.appenders .pattern {
+            width: 30%;
+        }
+        table.appenders .level {
+            width: 10%;
+        }
+        table.appenders .additional {
+            width: 20%;
+        }
+
+
+        table.modules {
+            width: 80%;
+            border-collapse: collapse;
+        }
+        table.modules .name {
+            width: 20%;
+        }
+        table.modules .level {
+            width: 10%;
+        }
+        table.modules .appenders {
+            width: 50%;
+        }
+        table.modules .actions {
+            width: 20%;
+        }
+
+        .odd td {
+            background-color: lightgray;
+        }
+
+    </style>
+
+    <!--###END_HEAD###-->
+</head>
+<body>
+<div id="main">
+    <div id="contents">
+        <!--###BEGIN_CONTENT###-->
+
+        <h1>Marmotta Logging Configuration</h1>
+
+        <div ng-app="logging" ng-controller="LoggingController">
+
+            <h2>Log Appenders</h2>
+
+
+            <h3>Console</h3>
+            <table class="appenders">
+                <tr>
+                    <th>Name</th><th>Level</th><th>Pattern</th><th></th><th></th>
+                </tr>
+                <tr ng-repeat="appender in appenders | filter:{type:'console'}" ng-class-even="'even'" ng-class-odd="'odd'">
+                    <td class="name">{{appender.name}}</td>
+                    <td class="level">
+                        <select ng-model="appender.level" ng-change="updateAppender(appender)">
+                            <option>ERROR</option>
+                            <option>WARN</option>
+                            <option>INFO</option>
+                            <option>DEBUG</option>
+                            <option>TRACE</option>
+                        </select>
+                    </td>
+                    <td class="pattern">{{appender.pattern}}</td>
+                    <td class="additional"></td>
+                    <td class="additional"></td>
+                </tr>
+            </table>
+
+            <h3>Logfile</h3>
+            <table class="appenders">
+                <tr>
+                    <th>Name</th><th>Level</th><th>Pattern</th><th>Filename</th><th>Keep Days</th>
+                </tr>
+                <tr ng-repeat="appender in appenders | filter:{type:'logfile'}" ng-class-even="'even'" ng-class-odd="'odd'">
+                    <td class="name">{{appender.name}}</td>
+                    <td class="level">
+                        <select ng-model="appender.level" ng-change="updateAppender(appender)">
+                            <option>ERROR</option>
+                            <option>WARN</option>
+                            <option>INFO</option>
+                            <option>DEBUG</option>
+                            <option>TRACE</option>
+                        </select>
+                    </td>
+                    <td class="pattern">{{appender.pattern}}</td>
+                    <td class="additional">{{appender.file}}</td>
+                    <td class="additional">{{appender.keep}}</td>
+                </tr>
+            </table>
+
+            <h3>Syslog</h3>
+            <table class="appenders">
+                <tr>
+                    <th>Name</th><th>Level</th><th>Pattern</th><th>Host</th><th>Facility</th>
+                </tr>
+                <tr ng-repeat="appender in appenders | filter:{type:'syslog'}" ng-class-even="'even'" ng-class-odd="'odd'">
+                    <td class="name">{{appender.name}}</td>
+                    <td class="level">
+                        <select ng-model="appender.level" ng-change="updateAppender(appender)">
+                            <option>ERROR</option>
+                            <option>WARN</option>
+                            <option>INFO</option>
+                            <option>DEBUG</option>
+                            <option>TRACE</option>
+                        </select>
+                    </td>
+                    <td class="pattern">{{appender.pattern}}</td>
+                    <td class="additional">{{appender.host}}</td>
+                    <td class="additional">
+                        <select ng-model="appender.facility" ng-change="updateAppender(appender)">
+                            <option>USER</option>
+                            <option>DAEMON</option>
+                            <option>SYSLOG</option>
+                            <option>LOCAL0</option>
+                            <option>LOCAL1</option>
+                            <option>LOCAL2</option>
+                            <option>LOCAL3</option>
+                            <option>LOCAL4</option>
+                            <option>LOCAL5</option>
+                            <option>LOCAL6</option>
+                            <option>LOCAL7</option>
+                        </select>
+                    </td>
+                </tr>
+            </table>
+
+
+
+            <h2>Log Modules</h2>
+
+            <table class="modules">
+                <tr>
+                    <th>Name</th><th>Level</th><th>Appenders</th><th>Actions</th>
+                </tr>
+                <tr ng-repeat="module in modules" ng-class-even="'even'" ng-class-odd="'odd'">
+                    <td class="name">{{module.name}}</td>
+                    <td class="level">
+                        <select ng-model="module.level" ng-change="updateModule(module)">
+                            <option>ERROR</option>
+                            <option>WARN</option>
+                            <option>INFO</option>
+                            <option>DEBUG</option>
+                            <option>TRACE</option>
+                        </select>
+                    </td>
+                    <td class="appenders">
+                        <span ng-repeat="appender in module.appenders">
+                            {{ (appenders | filter:{id: appender})[0].name }}
+                            <button ng-click="removeModuleAppender(module,appender)">-</button>
+                        </span>
+                    </td>
+                    <td class="actions">
+                        <select ng-model="module.new_appender" style="width: 80%">
+                            <option ng-repeat="appender in getUnselectedModuleAppenders(module)" value="{{appender.id}}">{{appender.name}}</option>
+                        </select>
+                        <button ng-click="addModuleAppender(module,module.new_appender)">+</button>
+                    </td>
+                </tr>
+            </table>
+
+
+        </div>
+
+        <!--###END_CONTENT###-->
+    </div>
+</div>
+</body>
+</html>