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.

power.vue 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <template>
  2. <div class="wizard-project">
  3. <PageHeader>
  4. <h2 class="title">
  5. <span class="icon"><font-awesome-icon icon="sync-alt" /></span>
  6. <span>Updater</span>
  7. </h2>
  8. <h3 class="subtitle">
  9. {{ $dreampower.name }}. Algorithm for nudification.
  10. </h3>
  11. <template v-slot:right>
  12. <button class="button" @click="$dreamtime.openAppDataFolder()">
  13. <span class="icon"><font-awesome-icon icon="folder-open" /></span>
  14. <span>{{ $dreamtime.name }} Folder</span>
  15. </button>
  16. </template>
  17. </PageHeader>
  18. <div class="project__content">
  19. <div v-if="!requirements.power.installed" class="notification notification--warning">
  20. This component needs to be installed to continue.
  21. </div>
  22. <div v-else-if="requirements.power.error" class="notification notification--danger">
  23. <h5>CHECK ERROR!</h5>
  24. Failed to get the installed {{ $dreampower.name }} version. Please fix this problem before continuing.<br>
  25. You can visit our <a href="https://chat.dreamnet.tech" target="_blank">chat</a> to get support.
  26. <br><br>
  27. <pre>{{ requirements.power.error.stack }}</pre>
  28. </div>
  29. <div v-else-if="!requirements.power.compatible" class="notification notification--danger">
  30. <h5>OUTDATED</h5>
  31. This component requires an update to continue.
  32. </div>
  33. <div v-if="$dreampower.version" class="notification">
  34. Installed version: <strong>{{ $dreampower.version }}</strong>
  35. </div>
  36. <div v-if="updater.error" class="notification notification--danger">
  37. <h5>CONNECTION ERROR!</h5>
  38. <span>A problem has occurred when trying to get the information from Github, please make sure you have a stable internet connection and restart the application.</span>
  39. <br><br>
  40. <pre>
  41. <span v-if="updater.errorResponse">{{ updater.errorResponse }}</span>
  42. {{ updater.error.stack }}
  43. </pre>
  44. </div>
  45. <AppBox>
  46. <ProjectUpdate project="dreampower" />
  47. </AppBox>
  48. <AppBox title="Settings.">
  49. <!-- Download protocol. -->
  50. <MenuItem
  51. label="Download protocol.">
  52. <template v-slot:description>
  53. <span class="item__description">Select the protocol that will be used to download the file. <AppTip tooltip="- <strong>Any</strong>: Use all protocols if necessary.<br>- <strong>HTTP</strong>: Download the file from verified servers. Fastest and most reliable for most connections.<br>- <strong>Torrent & IPFS</strong>: Download the file from other computers with the option to cancel at any time and resume later. More reliable for unstable and low speed connections. May require a few minutes of preparation before starting the download." /></span>
  54. </template>
  55. <select v-model="updater.downloadMethod" class="input">
  56. <option :value="0">
  57. Any
  58. </option>
  59. <option :value="1">
  60. HTTP
  61. </option>
  62. <option v-if="updater.hasTorrentUrls" :value="3">
  63. Torrent
  64. </option>
  65. <option v-if="updater.hasIPFSUrls" :value="2">
  66. IPFS
  67. </option>
  68. </select>
  69. </MenuItem>
  70. <SettingsField v-if="!isMacOS"
  71. field-id="preferences.advanced.device"
  72. ignore-hardcoded
  73. @change="$dreampower.updater.refresh()" />
  74. <SettingsField v-else field-id="preferences.advanced.device" description="Mac only supports CPU.">
  75. <select class="input" disabled>
  76. <option value="CPU" selected>
  77. CPU
  78. </option>
  79. </select>
  80. </SettingsField>
  81. <SettingsField v-if="!$dreamtime.isPortable" label="Location" field-id="folders.cli">
  82. <input
  83. v-model="$settings.folders.cli"
  84. :title="$settings.folders.cli"
  85. readonly
  86. class="input"
  87. :style="{ cursor: 'pointer' }"
  88. @click.prevent="changePower">
  89. </SettingsField>
  90. </AppBox>
  91. </div>
  92. </div>
  93. </template>
  94. <script>
  95. import { isNil } from 'lodash'
  96. import { requirements } from '~/modules/system'
  97. import { dreampower } from '~/modules/projects'
  98. const { dialog } = $provider.api
  99. const { existsSync } = $provider.fs
  100. export default {
  101. layout: 'wizard',
  102. middleware({ redirect, route }) {
  103. if (!route.query.forced) {
  104. if (requirements.power.installed && requirements.power.compatible && !dreampower.updater.available) {
  105. redirect('/wizard/checkpoints')
  106. }
  107. }
  108. },
  109. data: () => ({
  110. requirements,
  111. }),
  112. computed: {
  113. isMacOS() {
  114. return process.platform === 'darwin'
  115. },
  116. updating() {
  117. return this.$dreampower.updater.update.active
  118. },
  119. updater() {
  120. return dreampower.updater
  121. },
  122. },
  123. methods: {
  124. showOpenDialog(path) {
  125. const dir = dialog.showOpenDialogSync({
  126. defaultPath: path,
  127. properties: ['openDirectory'],
  128. })
  129. if (isNil(dir)) {
  130. return path
  131. }
  132. if (!existsSync(dir[0])) {
  133. // ???
  134. return path
  135. }
  136. return dir[0]
  137. },
  138. changePower() {
  139. const dir = this.showOpenDialog(this.$settings.folders.cli)
  140. this.$settings.folders.cli = dir
  141. },
  142. },
  143. }
  144. </script>