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.

194 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='/_assets/svg/icon-registry-editor.svg', alt='Logging', style='width: 80px;')
  7. .admin-header-title
  8. .headline.primary--text Logging
  9. .subtitle-1.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. v-icon check
  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. export default {
  109. components: {
  110. LoggingConsole
  111. },
  112. data() {
  113. return {
  114. showConsole: false,
  115. loggers: [],
  116. levels: ['error', 'warn', 'info', 'debug', 'verbose']
  117. }
  118. },
  119. computed: {
  120. activeLoggers() {
  121. return _.filter(this.loggers, 'isEnabled')
  122. }
  123. },
  124. methods: {
  125. async refresh() {
  126. await this.$apollo.queries.loggers.refetch()
  127. this.$store.commit('showNotification', {
  128. message: 'List of loggers has been refreshed.',
  129. style: 'success',
  130. icon: 'cached'
  131. })
  132. },
  133. async save() {
  134. this.$store.commit(`loadingStart`, 'admin-logging-saveloggers')
  135. await this.$apollo.mutate({
  136. mutation: loggersSaveMutation,
  137. variables: {
  138. loggers: this.loggers.map(tgt => _.pick(tgt, [
  139. 'isEnabled',
  140. 'key',
  141. 'config',
  142. 'level'
  143. ])).map(str => ({...str, config: str.config.map(cfg => ({...cfg, value: JSON.stringify({ v: cfg.value.value })}))}))
  144. }
  145. })
  146. this.$store.commit('showNotification', {
  147. message: 'Logging configuration saved successfully.',
  148. style: 'success',
  149. icon: 'check'
  150. })
  151. this.$store.commit(`loadingStop`, 'admin-logging-saveloggers')
  152. },
  153. toggleConsole() {
  154. this.showConsole = !this.showConsole
  155. }
  156. },
  157. apollo: {
  158. loggers: {
  159. query: loggersQuery,
  160. fetchPolicy: 'network-only',
  161. update: (data) => _.cloneDeep(data.logging.loggers).map(str => ({...str, config: str.config.map(cfg => ({...cfg, value: JSON.parse(cfg.value)}))})),
  162. watchLoading (isLoading) {
  163. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-logging-refresh')
  164. }
  165. }
  166. }
  167. }
  168. </script>
  169. <style lang='scss' scoped>
  170. .loggerlogo {
  171. width: 250px;
  172. height: 85px;
  173. float:right;
  174. display: flex;
  175. justify-content: flex-end;
  176. align-items: center;
  177. img {
  178. max-width: 100%;
  179. max-height: 50px;
  180. }
  181. }
  182. </style>