aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2015-10-07 10:48:05 +0200
committerStas Vilchik <vilchiks@gmail.com>2015-10-07 10:48:05 +0200
commit27377cc2cc94aab30700a380f40b3035d14e5535 (patch)
treeab50dd1223eb43b7ee7dcc6f1271be988b8f9ea0 /server/sonar-web
parentd999545733b0f53d9a726c5c83256cc8e881dd83 (diff)
downloadsonarqube-27377cc2cc94aab30700a380f40b3035d14e5535.tar.gz
sonarqube-27377cc2cc94aab30700a380f40b3035d14e5535.zip
SONAR-6830 make it possible to change server log level from UI
Diffstat (limited to 'server/sonar-web')
-rw-r--r--server/sonar-web/Gruntfile.coffee1
-rw-r--r--server/sonar-web/src/main/js/api/system.js6
-rw-r--r--server/sonar-web/src/main/js/apps/system/app.js41
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/views/system/index.html.erb8
4 files changed, 56 insertions, 0 deletions
diff --git a/server/sonar-web/Gruntfile.coffee b/server/sonar-web/Gruntfile.coffee
index 8a51cadc0fb..2c60d3da7f7 100644
--- a/server/sonar-web/Gruntfile.coffee
+++ b/server/sonar-web/Gruntfile.coffee
@@ -161,6 +161,7 @@ module.exports = (grunt) ->
'build-app:quality-gates'
'build-app:quality-profiles'
'build-app:source-viewer'
+ 'build-app:system'
'build-app:users'
'build-app:update-center'
# widgets
diff --git a/server/sonar-web/src/main/js/api/system.js b/server/sonar-web/src/main/js/api/system.js
new file mode 100644
index 00000000000..59ef364d9ee
--- /dev/null
+++ b/server/sonar-web/src/main/js/api/system.js
@@ -0,0 +1,6 @@
+import $ from 'jquery';
+
+export function setLogLevel (level) {
+ let url = baseUrl + '/api/system/change_log_level';
+ return $.post(url, { level });
+}
diff --git a/server/sonar-web/src/main/js/apps/system/app.js b/server/sonar-web/src/main/js/apps/system/app.js
new file mode 100644
index 00000000000..3b535550657
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/system/app.js
@@ -0,0 +1,41 @@
+import $ from 'jquery';
+import {setLogLevel} from '../../api/system';
+
+const LOG_LEVELS = ['INFO', 'DEBUG', 'TRACE'];
+
+let cell = document.querySelector('#sonarqube-logs-level td:last-child');
+if (cell) {
+ let currentValue = cell.textContent.trim();
+
+ while (cell.hasChildNodes()) {
+ cell.removeChild(cell.lastChild);
+ }
+
+ let select = document.createElement('select');
+ cell.appendChild(select);
+
+ LOG_LEVELS.forEach(logLevel => {
+ let option = document.createElement('option');
+ option.value = logLevel;
+ option.text = logLevel;
+ option.selected = logLevel === currentValue;
+ select.appendChild(option);
+ });
+
+ let format = (state) => {
+ let className = state.id !== 'INFO' ? 'text-danger' : '';
+ return `<span class="${className}">${state.id}</span>`;
+ };
+
+ $(select)
+ .select2({
+ width: '120px',
+ minimumResultsForSearch: 999,
+ formatResult: format,
+ formatSelection: format
+ })
+ .on('change', () => {
+ let newValue = select.value;
+ setLogLevel(newValue);
+ });
+}
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/system/index.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/system/index.html.erb
index 51e1c98c663..9b3301cde48 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/system/index.html.erb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/system/index.html.erb
@@ -14,3 +14,11 @@
<% end %>
</div>
+
+
+<% content_for :extra_script do %>
+ <script>
+ require(['apps/system/app']);
+ </script>
+<% end %>
+