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.

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