admin-logging.vue 6.3 KB

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