You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

197 lines
7.0 KiB

  1. <template lang='pug'>
  2. v-container(fluid, grid-list-lg)
  3. v-layout(row, wrap)
  4. v-flex(xs12)
  5. .admin-header
  6. img(src='/svg/icon-registry-editor.svg', alt='Logging', style='width: 80px;')
  7. .admin-header-title
  8. .headline.primary--text Logging
  9. .subheading.grey--text Configure the system logger(s) #[v-chip(label, color='primary', small).white--text coming soon]
  10. v-spacer
  11. v-btn(outline, color='grey', @click='refresh', large)
  12. v-icon refresh
  13. v-btn(color='black', disabled, depressed, @click='toggleConsole', large)
  14. ConsoleLineIcon.mr-3
  15. span Live Trail
  16. v-btn(color='success', @click='save', depressed, large)
  17. v-icon(left) check
  18. span {{$t('common:actions.apply')}}
  19. v-card.mt-3
  20. v-tabs(color='grey darken-2', fixed-tabs, slider-color='white', show-arrows, dark)
  21. v-tab(key='settings'): v-icon settings
  22. v-tab(v-for='logger in activeLoggers', :key='logger.key') {{ logger.title }}
  23. v-tab-item(key='settings', :transition='false', :reverse-transition='false')
  24. v-card.pa-3(flat, tile)
  25. .body-2.grey--text.text--darken-1 Select which logging service to enable:
  26. .caption.grey--text.pb-2 Some loggers require additional configuration in their dedicated tab (when selected).
  27. v-form
  28. v-checkbox.my-0(
  29. v-for='(logger, n) in loggers'
  30. v-model='logger.isEnabled'
  31. :key='logger.key'
  32. :label='logger.title'
  33. color='primary'
  34. hide-details
  35. disabled
  36. )
  37. v-tab-item(v-for='(logger, n) in activeLoggers', :key='logger.key', :transition='false', :reverse-transition='false')
  38. v-card.wiki-form.pa-3(flat, tile)
  39. v-form
  40. .loggerlogo
  41. img(:src='logger.logo', :alt='logger.title')
  42. v-subheader.pl-0 {{logger.title}}
  43. .caption {{logger.description}}
  44. .caption: a(:href='logger.website') {{logger.website}}
  45. v-divider.mt-3
  46. v-subheader.pl-0 Logger Configuration
  47. .body-1.ml-3(v-if='!logger.config || logger.config.length < 1') This logger has no configuration options you can modify.
  48. template(v-else, v-for='cfg in logger.config')
  49. v-select(
  50. v-if='cfg.value.type === "string" && cfg.value.enum'
  51. outline
  52. background-color='grey lighten-2'
  53. :items='cfg.value.enum'
  54. :key='cfg.key'
  55. :label='cfg.value.title'
  56. v-model='cfg.value.value'
  57. prepend-icon='settings_applications'
  58. :hint='cfg.value.hint ? cfg.value.hint : ""'
  59. persistent-hint
  60. :class='cfg.value.hint ? "mb-2" : ""'
  61. )
  62. v-switch(
  63. v-else-if='cfg.value.type === "boolean"'
  64. :key='cfg.key'
  65. :label='cfg.value.title'
  66. v-model='cfg.value.value'
  67. color='primary'
  68. prepend-icon='settings_applications'
  69. :hint='cfg.value.hint ? cfg.value.hint : ""'
  70. persistent-hint
  71. )
  72. v-text-field(
  73. v-else
  74. outline
  75. background-color='grey lighten-2'
  76. :key='cfg.key'
  77. :label='cfg.value.title'
  78. v-model='cfg.value.value'
  79. prepend-icon='settings_applications'
  80. :hint='cfg.value.hint ? cfg.value.hint : ""'
  81. persistent-hint
  82. :class='cfg.value.hint ? "mb-2" : ""'
  83. )
  84. v-divider.mt-3
  85. v-subheader.pl-0 Log Level
  86. .body-1.ml-3 Select the minimum error level that will be reported to this logger.
  87. v-layout(row)
  88. v-flex(xs12, md6, lg4)
  89. .pt-3
  90. v-select(
  91. single-line
  92. outline
  93. background-color='grey lighten-2'
  94. :items='levels'
  95. label='Level'
  96. v-model='logger.level'
  97. prepend-icon='graphic_eq'
  98. hint='Default: warn'
  99. persistent-hint
  100. )
  101. logging-console(v-model='showConsole')
  102. </template>
  103. <script>
  104. import _ from 'lodash'
  105. import LoggingConsole from './admin-logging-console.vue'
  106. import loggersQuery from 'gql/admin/logging/logging-query-loggers.gql'
  107. import loggersSaveMutation from 'gql/admin/logging/logging-mutation-save-loggers.gql'
  108. import ConsoleLineIcon from 'mdi/ConsoleLine'
  109. export default {
  110. components: {
  111. LoggingConsole,
  112. ConsoleLineIcon
  113. },
  114. data() {
  115. return {
  116. showConsole: false,
  117. loggers: [],
  118. levels: ['error', 'warn', 'info', 'debug', 'verbose']
  119. }
  120. },
  121. computed: {
  122. activeLoggers() {
  123. return _.filter(this.loggers, 'isEnabled')
  124. }
  125. },
  126. methods: {
  127. async refresh() {
  128. await this.$apollo.queries.loggers.refetch()
  129. this.$store.commit('showNotification', {
  130. message: 'List of loggers has been refreshed.',
  131. style: 'success',
  132. icon: 'cached'
  133. })
  134. },
  135. async save() {
  136. this.$store.commit(`loadingStart`, 'admin-logging-saveloggers')
  137. await this.$apollo.mutate({
  138. mutation: loggersSaveMutation,
  139. variables: {
  140. loggers: this.loggers.map(tgt => _.pick(tgt, [
  141. 'isEnabled',
  142. 'key',
  143. 'config',
  144. 'level'
  145. ])).map(str => ({...str, config: str.config.map(cfg => ({...cfg, value: JSON.stringify({ v: cfg.value.value })}))}))
  146. }
  147. })
  148. this.$store.commit('showNotification', {
  149. message: 'Logging configuration saved successfully.',
  150. style: 'success',
  151. icon: 'check'
  152. })
  153. this.$store.commit(`loadingStop`, 'admin-logging-saveloggers')
  154. },
  155. toggleConsole() {
  156. this.showConsole = !this.showConsole
  157. }
  158. },
  159. apollo: {
  160. loggers: {
  161. query: loggersQuery,
  162. fetchPolicy: 'network-only',
  163. update: (data) => _.cloneDeep(data.logging.loggers).map(str => ({...str, config: str.config.map(cfg => ({...cfg, value: JSON.parse(cfg.value)}))})),
  164. watchLoading (isLoading) {
  165. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-logging-refresh')
  166. }
  167. }
  168. }
  169. }
  170. </script>
  171. <style lang='scss' scoped>
  172. .loggerlogo {
  173. width: 250px;
  174. height: 85px;
  175. float:right;
  176. display: flex;
  177. justify-content: flex-end;
  178. align-items: center;
  179. img {
  180. max-width: 100%;
  181. max-height: 50px;
  182. }
  183. }
  184. </style>