Bladeren bron

Settings page UI + npm installation fixes

NGPixel 8 jaren geleden
bovenliggende
commit
b2e693b1e4
10 gewijzigde bestanden met toevoegingen van 146 en 53 verwijderingen
  1. 14 1
      CHANGELOG.md
  2. 0 1
      app/data.yml
  3. 0 0
      assets/js/app.js
  4. 47 0
      client/js/pages/admin.js
  5. 17 14
      controllers/admin.js
  6. 2 2
      npm/install.js
  7. 1 1
      npm/package.json
  8. 4 1
      package.json
  9. 25 0
      views/modals/admin-upgrade.pug
  10. 36 33
      views/pages/admin/settings.pug

+ 14 - 1
CHANGELOG.md

@@ -4,9 +4,22 @@ This project adheres to [Semantic Versioning](http://semver.org/).
 
 
 ## [Unreleased]
 ## [Unreleased]
 
 
+## [v1.0.0-beta.8] - 2017-02-19
+### Added
+- Automated Upgrade / Re-install feature UI only
+- npm installation improvements
+
+# Fixed
+- wiki executable shortcut on linux
+- Settings page is now displaying the correct current version
+
+## [v1.0.0-beta.7] - 2017-02-14
+### Fixed
+- npm installation fixes
+
 ## [v1.0.0-beta.6] - 2017-02-14
 ## [v1.0.0-beta.6] - 2017-02-14
 ### Added
 ### Added
-- Automated Upgrade / Re-install feature
+- Settings page UI
 - Automated process management
 - Automated process management
 - npm automatic site installation
 - npm automatic site installation
 
 

+ 0 - 1
app/data.yml

@@ -3,7 +3,6 @@
 # This is reserved for system use!
 # This is reserved for system use!
 # ---------------------------------
 # ---------------------------------
 name: Wiki.js
 name: Wiki.js
-version: v1.0.0-beta.6
 capabilities:
 capabilities:
   guest: true
   guest: true
   rights: true
   rights: true

File diff suppressed because it is too large
+ 0 - 0
assets/js/app.js


+ 47 - 0
client/js/pages/admin.js

@@ -98,4 +98,51 @@ if ($('#page-type-admin-profile').length) {
   /* eslint-disable spaced-comment */
   /* eslint-disable spaced-comment */
   //=include ../modals/admin-users-delete.js
   //=include ../modals/admin-users-delete.js
   /* eslint-enable spaced-comment */
   /* eslint-enable spaced-comment */
+} else if ($('#page-type-admin-settings').length) {
+  let vueSettings = new Vue({ // eslint-disable-line no-unused-vars
+    el: '#page-type-admin-settings',
+    data: {
+      upgradeModal: {
+        state: false,
+        step: 'confirm',
+        mode: 'upgrade',
+        error: 'Something went wrong.'
+      }
+    },
+    methods: {
+      upgrade: (ev) => {
+        vueSettings.upgradeModal.mode = 'upgrade'
+        vueSettings.upgradeModal.step = 'confirm'
+        vueSettings.upgradeModal.state = true
+      },
+      reinstall: (ev) => {
+        vueSettings.upgradeModal.mode = 're-install'
+        vueSettings.upgradeModal.step = 'confirm'
+        vueSettings.upgradeModal.state = true
+      },
+      upgradeCancel: (ev) => {
+        vueSettings.upgradeModal.state = false
+      },
+      upgradeStart: (ev) => {
+        vueSettings.upgradeModal.step = 'running'
+        $.post('/admin/settings/install', {
+          mode: vueSettings.upgradeModal.mode
+        }).done((resp) => {
+          // todo
+        }).fail((jqXHR, txtStatus, resp) => {
+          vueSettings.upgradeModal.step = 'error'
+          vueSettings.upgradeModal.error = jqXHR.responseText
+        })
+      },
+      flushcache: (ev) => {
+        window.alert('Coming soon!')
+      },
+      resetaccounts: (ev) => {
+        window.alert('Coming soon!')
+      },
+      flushsessions: (ev) => {
+        window.alert('Coming soon!')
+      }
+    }
+  })
 }
 }

+ 17 - 14
controllers/admin.js

@@ -7,6 +7,7 @@ const validator = require('validator')
 const _ = require('lodash')
 const _ = require('lodash')
 const axios = require('axios')
 const axios = require('axios')
 const path = require('path')
 const path = require('path')
+const fs = Promise.promisifyAll(require('fs-extra'))
 
 
 /**
 /**
  * Admin
  * Admin
@@ -220,28 +221,30 @@ router.get('/settings', (req, res) => {
     return res.render('error-forbidden')
     return res.render('error-forbidden')
   }
   }
 
 
-  axios.get('https://api.github.com/repos/Requarks/wiki/releases/latest').then(resp => {
-    let sysversion = {
-      current: appdata.version,
-      latest: resp.data.tag_name,
-      latestPublishedAt: resp.data.published_at
-    }
+  fs.readJsonAsync(path.join(ROOTPATH, 'package.json')).then(packageObj => {
+    axios.get('https://api.github.com/repos/Requarks/wiki/releases/latest').then(resp => {
+      let sysversion = {
+        current: 'v' + packageObj.version,
+        latest: resp.data.tag_name,
+        latestPublishedAt: resp.data.published_at
+      }
 
 
-    res.render('pages/admin/settings', { adminTab: 'settings', sysversion })
-  }).catch(err => {
-    winston.warn(err)
-    res.render('pages/admin/settings', { adminTab: 'settings', sysversion: { current: appdata.version } })
+      res.render('pages/admin/settings', { adminTab: 'settings', sysversion })
+    }).catch(err => {
+      winston.warn(err)
+      res.render('pages/admin/settings', { adminTab: 'settings', sysversion: { current: 'v' + packageObj.version } })
+    })
   })
   })
 })
 })
 
 
-router.get('/settings/install', (req, res) => {
+router.post('/settings/install', (req, res) => {
   if (!res.locals.rights.manage) {
   if (!res.locals.rights.manage) {
     return res.render('error-forbidden')
     return res.render('error-forbidden')
   }
   }
 
 
-  let sysLib = require(path.join(ROOTPATH, 'libs/system.js'))
-  sysLib.install('v1.0-beta.5')
-  res.status(200).end()
+  // let sysLib = require(path.join(ROOTPATH, 'libs/system.js'))
+  // sysLib.install('v1.0-beta.7')
+  res.status(400).send('Sorry, Upgrade/Re-Install via the web UI is not yet ready. You must use the npm upgrade method in the meantime.').end()
 })
 })
 
 
 module.exports = router
 module.exports = router

+ 2 - 2
npm/install.js

@@ -1,6 +1,6 @@
 'use strict'
 'use strict'
 
 
-const ora = require('ora')('Initializing...').start()
+const ora = require('ora')({ text: 'Initializing...', spinner: 'dots12' }).start()
 const Promise = require('bluebird')
 const Promise = require('bluebird')
 const exec = require('child_process').exec
 const exec = require('child_process').exec
 const fs = Promise.promisifyAll(require('fs-extra'))
 const fs = Promise.promisifyAll(require('fs-extra'))
@@ -16,7 +16,7 @@ let installDir = path.resolve(__dirname, '../..')
 ora.text = 'Looking for running instances...'
 ora.text = 'Looking for running instances...'
 pm2.connectAsync().then(() => {
 pm2.connectAsync().then(() => {
   return pm2.describeAsync('wiki').then(() => {
   return pm2.describeAsync('wiki').then(() => {
-    ora.text = 'Stopping and deleting from pm2...'
+    ora.text = 'Stopping and deleting process from pm2...'
     return pm2.deleteAsync('wiki')
     return pm2.deleteAsync('wiki')
   }).catch(err => { // eslint-disable-line handle-callback-err
   }).catch(err => { // eslint-disable-line handle-callback-err
     return true
     return true

+ 1 - 1
npm/package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "wiki.js",
   "name": "wiki.js",
-  "version": "1.0.0-beta.7",
+  "version": "1.0.0-beta.8",
   "description": "A modern, lightweight and powerful wiki app built on NodeJS, Git and Markdown",
   "description": "A modern, lightweight and powerful wiki app built on NodeJS, Git and Markdown",
   "main": "install.js",
   "main": "install.js",
   "scripts": {
   "scripts": {

+ 4 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "wiki",
   "name": "wiki",
-  "version": "1.0.0-beta.7",
+  "version": "1.0.0-beta.8",
   "description": "A modern, lightweight and powerful wiki app built on NodeJS, Git and Markdown",
   "description": "A modern, lightweight and powerful wiki app built on NodeJS, Git and Markdown",
   "main": "server.js",
   "main": "server.js",
   "scripts": {
   "scripts": {
@@ -11,6 +11,9 @@
     "snyk-protect": "snyk protect",
     "snyk-protect": "snyk protect",
     "__prepublish": "npm run snyk-protect"
     "__prepublish": "npm run snyk-protect"
   },
   },
+  "bin": {
+    "wiki": "wiki.js"
+  },
   "repository": {
   "repository": {
     "type": "git",
     "type": "git",
     "url": "git+https://github.com/Requarks/wiki.git"
     "url": "git+https://github.com/Requarks/wiki.git"

+ 25 - 0
views/modals/admin-upgrade.pug

@@ -0,0 +1,25 @@
+.modal(v-bind:class='{ "is-active": upgradeModal.state }')
+  .modal-background
+  .modal-container
+    .modal-content
+      template(v-if='upgradeModal.step === "running"')
+        header.is-blue Install
+        section.modal-loading
+          i
+          span Wiki.js {{ upgradeModal.mode }} in progress...
+          em Please wait
+      template(v-if='upgradeModal.step === "error"')
+        header.is-red Installation Error
+        section.modal-loading
+          span {{ upgradeModal.error }}
+        footer
+          a.button.is-grey.is-outlined(v-on:click='upgradeCancel') Abort
+          a.button.is-deep-orange(v-on:click='upgradeStart') Try Again
+      template(v-if='upgradeModal.step === "confirm"')
+        header.is-deep-orange Are you sure?
+        section
+          label.label You are about to {{ upgradeModal.mode }} Wiki.js.
+          span.note You will not be able to access your wiki during the operation. Content will not be affected. However, it is your responsability to ensure you have a backup in the unexpected event content gets lost or corrupted.
+        footer
+          a.button.is-grey.is-outlined(v-on:click='upgradeCancel') Abort
+          a.button.is-deep-orange(v-on:click='upgradeStart') Start

+ 36 - 33
views/pages/admin/settings.pug

@@ -1,36 +1,39 @@
 extends ./_layout.pug
 extends ./_layout.pug
 
 
 block adminContent
 block adminContent
-  .hero
-    h1.title#title System Settings
-    h2.subtitle Manage site configuration
-  .form-sections
-    section
-      label.label System Version
-      .section-block
-        p Current Version: #[strong= sysversion.current]
-        if sysversion.latest
-          p Latest Version: #[strong= sysversion.latest] #[em (Published #{userMoment(sysversion.latestPublishedAt).fromNow()})]
-          p
-            if sysversion.current !== sysversion.latest
-              button.button.is-deep-orange Upgrade
-            else
-              button.button.is-disabled Upgrade
-            button.button.is-deep-orange.is-outlined Re-install current version
-        else
-          p: em Unable to query latest version. Try again later.
-    section
-      label.label Administrative Tools
-      .section-block
-        h6 Flush cache and rebuild indexes:
-        p.is-small If content or search results seems out-of-date or do not include latest content, flushing the cache can help resolve these issues.
-        p: button.button.is-teal.is-outlined Flush and Rebuild
-        h6 Reset the root administrator and guest accounts to defaults:
-        p.is-small
-          | The root administrator account will be reset to the email address in the configuration file and the password will be reinitialized to #[strong admin123].
-          br
-          | The guest account will be recreated with its access rights set to defaults.
-        p: button.button.is-teal.is-outlined Reset System Accounts
-        h6 Flush all active user sessions:
-        p.is-small All users will be logged out and forced to login again. Your current session will also be affected!
-        p: button.button.is-teal.is-outlined Flush Sessions
+  #page-type-admin-settings
+    .hero
+      h1.title#title System Settings
+      h2.subtitle Manage site configuration
+    .form-sections
+      section
+        label.label System Version
+        .section-block
+          p Current Version: #[strong= sysversion.current]
+          if sysversion.latest
+            p Latest Version: #[strong= sysversion.latest] #[em (Published #{userMoment(sysversion.latestPublishedAt).fromNow()})]
+            p
+              if sysversion.current !== sysversion.latest
+                button.button.is-deep-orange(v-on:click='upgrade') Upgrade
+              else
+                button.button.is-disabled Upgrade
+              button.button.is-deep-orange.is-outlined(v-on:click='reinstall') Re-install current version
+          else
+            p: em Unable to query latest version. Try again later.
+      section
+        label.label Administrative Tools
+        .section-block
+          h6 Flush cache and rebuild indexes:
+          p.is-small If content or search results seems out-of-date or do not include latest content, flushing the cache can help resolve these issues.
+          p: button.button.is-teal.is-outlined(v-on:click='flushcache') Flush and Rebuild
+          h6 Reset the root administrator and guest accounts to defaults:
+          p.is-small
+            | The root administrator account will be reset to the email address in the configuration file and the password will be reinitialized to #[strong admin123].
+            br
+            | The guest account will be recreated with its access rights set to defaults.
+          p: button.button.is-teal.is-outlined(v-on:click='resetaccounts') Reset System Accounts
+          h6 Flush all active user sessions:
+          p.is-small All users will be logged out and forced to login again. Your current session will also be affected!
+          p: button.button.is-teal.is-outlined(v-on:click='flushsessions') Flush Sessions
+
+    include ../../modals/admin-upgrade.pug

Some files were not shown because too many files changed in this diff