瀏覽代碼

System Settings UI + code cleanup

NGPixel 8 年之前
父節點
當前提交
5223368e37
共有 10 個文件被更改,包括 52 次插入42 次删除
  1. 1 2
      .eslintrc.json
  2. 1 0
      app/data.yml
  3. 0 0
      assets/css/app.css
  4. 14 1
      controllers/admin.js
  5. 4 5
      libs/entries.js
  6. 0 26
      libs/internalAuth.js
  7. 2 2
      package.json
  8. 0 3
      server.js
  9. 1 1
      views/pages/admin/_layout.pug
  10. 29 2
      views/pages/admin/settings.pug

+ 1 - 2
.eslintrc.json

@@ -40,8 +40,7 @@
     "CORE_PATH": true,
     "ROOTPATH": true,
     "IS_DEBUG": true,
-    "PROCNAME": true,
-    "WSInternalKey": true
+    "PROCNAME": true
   },
 
   "rules": {

+ 1 - 0
app/data.yml

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

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


+ 14 - 1
controllers/admin.js

@@ -5,6 +5,8 @@ var router = express.Router()
 const Promise = require('bluebird')
 const validator = require('validator')
 const _ = require('lodash')
+const axios = require('axios')
+const moment = require('moment')
 
 /**
  * Admin
@@ -218,7 +220,18 @@ router.get('/settings', (req, res) => {
     return res.render('error-forbidden')
   }
 
-  res.render('pages/admin/settings', { adminTab: 'settings' })
+  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
+    }
+
+    res.render('pages/admin/settings', { adminTab: 'settings', sysversion })
+  }).catch(err => {
+    winston.warn(err)
+    res.render('pages/admin/settings', { adminTab: 'settings', sysversion: { current: appdata.version } })
+  })
 })
 
 module.exports = router

+ 4 - 5
libs/entries.js

@@ -371,14 +371,13 @@ module.exports = {
 
         // Delete old index entry
 
-        ws.emit('searchDel', {
-          auth: WSInternalKey,
-          entryPath
-        })
+        search.delete(entryPath)
 
         // Create cache for new entry
 
-        return self.updateCache(newEntryPath)
+        return self.updateCache(newEntryPath).then(entry => {
+          return search.add(entry)
+        })
       })
     })
   },

+ 0 - 26
libs/internalAuth.js

@@ -1,26 +0,0 @@
-'use strict'
-
-const crypto = require('crypto')
-
-/**
- * Internal Authentication
- */
-module.exports = {
-
-  _curKey: false,
-
-  init (inKey) {
-    this._curKey = inKey
-
-    return this
-  },
-
-  generateKey () {
-    return crypto.randomBytes(20).toString('hex')
-  },
-
-  validateKey (inKey) {
-    return inKey === this._curKey
-  }
-
-}

+ 2 - 2
package.json

@@ -33,6 +33,7 @@
   },
   "dependencies": {
     "auto-load": "^2.1.0",
+    "axios": "^0.15.3",
     "bcryptjs-then": "^1.0.1",
     "bluebird": "^3.4.7",
     "body-parser": "^1.15.2",
@@ -156,8 +157,7 @@
       "CORE_PATH",
       "ROOTPATH",
       "IS_DEBUG",
-      "PROCNAME",
-      "WSInternalKey"
+      "PROCNAME"
     ],
     "ignore": [
       "assets/**/*",

+ 0 - 3
server.js

@@ -64,9 +64,6 @@ const socketio = require('socket.io')
 
 var mw = autoload(CORE_PATH + '/core-middlewares')
 var ctrl = autoload(path.join(ROOTPATH, '/controllers'))
-var libInternalAuth = require('./libs/internalAuth')
-
-global.WSInternalKey = libInternalAuth.generateKey()
 
 // ----------------------------------------
 // Define Express App

+ 1 - 1
views/pages/admin/_layout.pug

@@ -49,7 +49,7 @@ block content
                 li
                   a(href='/admin/settings')
                     i.icon-cog
-                    span Site Settings
+                    span System Settings
               li
                 a(href='/logout')
                   i.icon-delete2

+ 29 - 2
views/pages/admin/settings.pug

@@ -2,8 +2,35 @@ extends ./_layout.pug
 
 block adminContent
   .hero
-    h1.title#title Site Settings
+    h1.title#title System Settings
     h2.subtitle Manage site configuration
   .form-sections
     section
-      | Coming soon
+      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

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