admin-logging.vue 6.2 KB

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