瀏覽代碼

自定义命令出错时显示提示。

oldj 8 年之前
父節點
當前提交
83da6a0237
共有 4 個文件被更改,包括 17 次插入2 次删除
  1. 0 1
      app/bundle.js
  2. 1 1
      app/version.js
  3. 1 0
      package.json
  4. 15 0
      ui/app.jsx

文件差異過大導致無法顯示
+ 0 - 1
app/bundle.js


+ 1 - 1
app/version.js

@@ -1 +1 @@
-exports.version = [3,3,3,5208];
+exports.version = [3,3,3,5210];

+ 1 - 0
package.json

@@ -76,6 +76,7 @@
     "ora": "^1.1.0",
     "react": "^15.4.2",
     "react-dom": "^15.4.2",
+    "react-notification-system": "^0.2.14",
     "rimraf": "^2.6.0",
     "semver": "^5.3.0",
     "sortablejs": "^1.5.1",

+ 15 - 0
ui/app.jsx

@@ -11,6 +11,7 @@ import Content from './content/content'
 import SudoPrompt from './frame/sudo'
 import EditPrompt from './frame/edit'
 import PreferencesPrompt from './frame/preferences'
+import NotificationSystem from 'react-notification-system'
 import Agent from './Agent'
 import { reg as events_reg } from './events/index'
 import './app.less'
@@ -28,6 +29,7 @@ export default class App extends React.Component {
     }
 
     this.is_dragging = false
+    this._notificationSystem = null
     this.loadHosts()
 
     Agent.pact('getPref')
@@ -52,6 +54,16 @@ export default class App extends React.Component {
       console.log('drag_end')
     })
 
+    Agent.on('err', e => {
+      console.log(e)
+      this._notificationSystem.addNotification({
+        title: e.title,
+        message: e.content,
+        position: 'tr',
+        level: 'error'
+      })
+    })
+
     setInterval(() => {
       let list = this.state.list
       if (this.is_dragging || !list || list.length === 0) return
@@ -138,6 +150,8 @@ export default class App extends React.Component {
   }
 
   componentDidMount () {
+    this._notificationSystem = this.refs.notificationSystem
+
     window.addEventListener('keydown', (e) => {
       if (e.keyCode === 27) {
         Agent.emit('esc')
@@ -153,6 +167,7 @@ export default class App extends React.Component {
     let current = this.state.current
     return (
       <div id="app" className={'platform-' + Agent.platform}>
+        <NotificationSystem ref="notificationSystem"/>
         <Panel
           list={this.state.list}
           sys_hosts={this.state.sys_hosts}

部分文件因文件數量過多而無法顯示