admin-system.vue 8.76 KB
Newer Older
1
<template lang='pug'>
2
  v-container.admin-system(fluid, grid-list-lg)
3 4
    v-layout(row, wrap)
      v-flex(xs12)
5
        .admin-header
6
          img.animated.fadeInUp(src='/_assets/svg/icon-tune.svg', alt='System Info', style='width: 80px;')
7
          .admin-header-title
Nick's avatar
Nick committed
8
            .headline.primary--text.animated.fadeInLeft {{ $t('admin:system.title') }}
9
            .subtitle-1.grey--text.animated.fadeInLeft.wait-p2s {{ $t('admin:system.subtitle') }}
10 11
        v-layout.mt-3(row wrap)
          v-flex(lg6 xs12)
Nick's avatar
Nick committed
12
            v-card.animated.fadeInUp
13
              v-btn.animated.fadeInLeft.wait-p2s.btn-animate-rotate(fab, absolute, :right='!$vuetify.rtl', :left='$vuetify.rtl', top, small, light, @click='refresh'): v-icon(color='grey') mdi-refresh
14
              v-subheader Wiki.js
15
              v-list(two-line, dense)
16
                v-list-item
17
                  v-list-item-avatar
18
                    v-icon.blue.white--text mdi-application-export
19 20
                  v-list-item-content
                    v-list-item-title {{ $t('admin:system.currentVersion') }}
21
                    v-list-item-subtitle {{ info.currentVersion }}
22
                v-list-item
23
                  v-list-item-avatar
24
                    v-icon.blue.white--text mdi-inbox-arrow-up
25 26
                  v-list-item-content
                    v-list-item-title {{ $t('admin:system.latestVersion') }}
27
                    v-list-item-subtitle {{ info.latestVersion }}
28 29
                  v-list-item-action
                    v-list-item-action-text {{ $t('admin:system.published') }} {{ info.latestVersionReleaseDate | moment('from') }}
30
              v-card-actions(v-if='info.upgradeCapable && !isLatestVersion && info.platform === `docker`', :class='$vuetify.theme.dark ? `grey darken-3-d5` : `indigo lighten-5`')
Nick's avatar
Nick committed
31 32 33 34 35 36 37 38 39
                .caption.indigo--text.pl-3(:class='$vuetify.theme.dark ? `text--lighten-4` : ``') Wiki.js can perform the upgrade to the latest version for you.
                v-spacer
                v-btn.px-3(
                  color='indigo'
                  dark
                  @click='performUpgrade'
                  )
                  v-icon(left) mdi-upload
                  span Perform Upgrade
40

Nick's avatar
Nick committed
41
            v-card.mt-4.animated.fadeInUp.wait-p2s
42 43
              v-subheader {{ $t('admin:system.hostInfo') }}
              v-list(two-line, dense)
44
                v-list-item
45
                  v-list-item-avatar
46
                    v-avatar.blue-grey(size='40')
47
                      v-icon(color='white') {{platformLogo}}
48 49
                  v-list-item-content
                    v-list-item-title {{ $t('admin:system.os') }}
50
                    v-list-item-subtitle {{ (info.platform === 'docker') ? 'Docker Container (Linux)' : info.operatingSystem }}
51
                v-list-item
52
                  v-list-item-avatar
53
                    v-icon.blue-grey.white--text mdi-desktop-classic
54 55
                  v-list-item-content
                    v-list-item-title {{ $t('admin:system.hostname') }}
56
                    v-list-item-subtitle {{ info.hostname }}
57
                v-list-item
58
                  v-list-item-avatar
59
                    v-icon.blue-grey.white--text mdi-cpu-64-bit
60 61
                  v-list-item-content
                    v-list-item-title {{ $t('admin:system.cpuCores') }}
62
                    v-list-item-subtitle {{ info.cpuCores }}
63
                v-list-item
64
                  v-list-item-avatar
65
                    v-icon.blue-grey.white--text mdi-memory
66 67
                  v-list-item-content
                    v-list-item-title {{ $t('admin:system.totalRAM') }}
68
                    v-list-item-subtitle {{ info.ramTotal }}
69
                v-list-item
70
                  v-list-item-avatar
71
                    v-icon.blue-grey.white--text mdi-iframe-outline
72 73
                  v-list-item-content
                    v-list-item-title {{ $t('admin:system.workingDirectory') }}
74
                    v-list-item-subtitle {{ info.workingDirectory }}
75
                v-list-item
76
                  v-list-item-avatar
77
                    v-icon.blue-grey.white--text mdi-card-bulleted-settings-outline
78 79
                  v-list-item-content
                    v-list-item-title {{ $t('admin:system.configFile') }}
80
                    v-list-item-subtitle {{ info.configFile }}
81 82

          v-flex(lg6 xs12)
Nick's avatar
Nick committed
83
            v-card.pb-3.animated.fadeInUp.wait-p4s
84
              v-subheader Node.js
85
              v-list(dense)
86
                v-list-item
87
                  v-list-item-avatar
88
                    v-avatar.light-green(size='40')
89
                      v-icon(color='white') mdi-nodejs
90 91
                  v-list-item-content
                    v-list-item-title {{ info.nodeVersion }}
92

93 94 95
              v-divider.mt-3
              v-subheader {{ info.dbType }}
              v-list(dense)
96
                v-list-item
97
                  v-list-item-avatar
98
                    v-avatar.indigo.darken-1(size='40')
99
                      v-icon(color='white') mdi-database
100 101
                  v-list-item-content
                    v-list-item-title(v-html='dbVersion')
102
                    v-list-item-subtitle {{ info.dbHost }}
103

104
                v-alert.mt-3.mx-4(:value='isDbLimited', color='deep-orange darken-2', icon='mdi-alert', dark) {{ $t('admin:system.dbPartialSupport') }}
Nick's avatar
Nick committed
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129

    v-dialog(
      v-model='isUpgrading'
      persistent
      width='450'
      )
      v-card.blue.darken-5(dark)
        v-card-text.text-center.pa-10
          self-building-square-spinner(
            :animation-duration='4000'
            :size='40'
            color='#FFF'
            style='margin: 0 auto;'
            )
          .body-2.mt-5.blue--text.text--lighten-4 Your Wiki.js container is being upgraded...
          .caption.blue--text.text--lighten-2 Please wait
          v-progress-linear.mt-5(
            color='blue lighten-2'
            :value='upgradeProgress'
            :buffer-value='upgradeProgress'
            rounded
            :stream='isUpgradingStarted'
            query
            :indeterminate='!isUpgradingStarted'
          )
130 131 132
</template>

<script>
133 134
import _ from 'lodash'

Nick's avatar
Nick committed
135 136
import { SelfBuildingSquareSpinner } from 'epic-spinners'

137
import systemInfoQuery from 'gql/admin/system/system-query-info.gql'
Nick's avatar
Nick committed
138
import performUpgradeMutation from 'gql/admin/system/system-mutation-upgrade.gql'
139

140
export default {
Nick's avatar
Nick committed
141 142 143 144
  components: {
    SelfBuildingSquareSpinner
  },
  data () {
NGPixel's avatar
NGPixel committed
145
    return {
Nick's avatar
Nick committed
146 147 148
      isUpgrading: false,
      isUpgradingStarted: false,
      upgradeProgress: 0,
149
      info: {}
NGPixel's avatar
NGPixel committed
150 151
    }
  },
152
  computed: {
Nick's avatar
Nick committed
153
    dbVersion () {
154
      return _.get(this.info, 'dbVersion', '').replace(/(?:\r\n|\r|\n)/g, '<br />')
155
    },
Nick's avatar
Nick committed
156
    platformLogo () {
157 158
      switch (this.info.platform) {
        case 'docker':
159
          return 'mdi-docker'
160
        case 'darwin':
161
          return 'mdi-apple'
162
        case 'linux':
163 164 165 166 167
          if (this.info.operatingSystem.indexOf('Ubuntu')) {
            return 'mdi-ubuntu'
          } else {
            return 'mdi-linux'
          }
168
        case 'win32':
169
          return 'mdi-microsoft-windows'
170 171 172
        default:
          return ''
      }
173
    },
Nick's avatar
Nick committed
174
    isDbLimited () {
175
      return this.info.dbType === 'MySQL' && this.dbVersion.indexOf('5.') === 0
Nick's avatar
Nick committed
176 177 178
    },
    isLatestVersion () {
      return this.info.currentVersion === this.info.latestVersion
179 180
    }
  },
NGPixel's avatar
NGPixel committed
181
  methods: {
Nick's avatar
Nick committed
182
    async refresh () {
NGPixel's avatar
NGPixel committed
183
      await this.$apollo.queries.info.refetch()
184
      this.$store.commit('showNotification', {
185
        message: this.$t('admin:system.refreshSuccess'),
186 187 188
        style: 'success',
        icon: 'cached'
      })
Nick's avatar
Nick committed
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
    },
    async performUpgrade () {
      this.isUpgrading = true
      this.isUpgradingStarted = false
      this.upgradeProgress = 0
      this.$store.commit(`loadingStart`, 'admin-system-upgrade')
      try {
        const respRaw = await this.$apollo.mutate({
          mutation: performUpgradeMutation
        })
        const resp = _.get(respRaw, 'data.system.performUpgrade.responseResult', {})
        if (resp.succeeded) {
          this.isUpgradingStarted = true
          let progressInterval = setInterval(() => {
            this.upgradeProgress += 0.83
          }, 500)
          _.delay(() => {
            clearInterval(progressInterval)
            window.location.reload(true)
          }, 60000)
        } else {
          throw new Error(resp.message)
        }
      } catch (err) {
        this.$store.commit('pushGraphError', err)
        this.$store.commit(`loadingStop`, 'admin-system-upgrade')
        this.isUpgrading = false
      }
217 218 219 220 221
    }
  },
  apollo: {
    info: {
      query: systemInfoQuery,
NGPixel's avatar
NGPixel committed
222
      fetchPolicy: 'network-only',
223 224 225 226
      update: (data) => data.system.info,
      watchLoading (isLoading) {
        this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-system-refresh')
      }
NGPixel's avatar
NGPixel committed
227
    }
228 229 230 231 232
  }
}
</script>

<style lang='scss'>
233
.admin-system {
234
  .v-list-item-title, .v-list-item__subtitle {
235 236 237
    user-select: text;
  }
}
238
</style>