oldj 8 years ago
parent
commit
fdf44689e4
7 changed files with 10566 additions and 10188 deletions
  1. 10538 10175
      app/bundle.js
  2. 12 9
      ui/app.js
  3. 4 1
      ui/events/order.js
  4. 3 1
      ui/events/save.js
  5. 0 1
      ui/events/top_toggle.js
  6. 2 0
      ui/frame/group.js
  7. 7 1
      ui/panel/list.js

File diff suppressed because it is too large
+ 10538 - 10175
app/bundle.js


+ 12 - 9
ui/app.js

@@ -38,21 +38,24 @@ export default class App extends React.Component {
       let list = this.state.list
       if (!list || list.length === 0) return
 
-      Agent.pact('checkNeedRemoteRefresh', list)
-        .then(list => {
-          if (!list) return
-          Agent.emit('list_updated', list)
-        })
+      //Agent.pact('checkNeedRemoteRefresh', list)
+      //  .then(list => {
+      //    if (!list) return
+      //    Agent.emit('list_updated', list)
+      //  })
     }, 3000)
   }
 
   loadHosts () {
     Agent.pact('getHosts').then(data => {
-      this.setState({
+      let state = {
         list: data.list,
-        sys_hosts: data.sys_hosts,
-        current: data.sys_hosts
-      })
+        sys_hosts: data.sys_hosts
+      }
+      let current = this.state.current
+      state.current = data.list.find(item => item.id === current.id) || data.sys_hosts
+
+      this.setState(state)
     })
   }
 

+ 4 - 1
ui/events/order.js

@@ -6,6 +6,7 @@
 'use strict'
 
 import Agent from '../Agent'
+import updated from './list_updated'
 
 module.exports = (app, ids) => {
   let list = app.state.list
@@ -18,6 +19,8 @@ module.exports = (app, ids) => {
   })
 
   Agent.pact('saveHosts', new_list)
-    .then(() => app.setState({list}))
+    .then(list => {
+      updated(app, list)
+    })
     .catch(e => console.log(e))
 }

+ 3 - 1
ui/events/save.js

@@ -13,5 +13,7 @@ module.exports = (app, list, hosts = null) => {
     .then(new_list => {
       updated(app, new_list, hosts)
     })
-    .catch(e => console.log(e))
+    .catch(e => {
+      console.log(e)
+    })
 }

+ 0 - 1
ui/events/top_toggle.js

@@ -9,7 +9,6 @@ import Agent from '../Agent'
 
 module.exports = (app, on, on_ids, callback) => {
   let list = app.state.list
-  console.log(on_ids)
 
   let new_list = list.map(item => {
     let new_item = Object.assign({}, item)

+ 2 - 0
ui/frame/group.js

@@ -91,11 +91,13 @@ export default class Group extends React.Component {
   componentDidMount () {
     Sortable.create(this.refs.group_valid, {
       group: 'sorting'
+      , animation: 150
       , sort: false
     })
 
     Sortable.create(this.refs.group_current, {
       group: 'sorting'
+      , animation: 150
       , sort: true
       , onSort: () => {
         this.getCurrentListFromDOM()

+ 7 - 1
ui/panel/list.js

@@ -65,9 +65,15 @@ export default class List extends React.Component {
     Sortable.create(this.refs.items, {
       group: 'list-sorting'
       , sort: true
-      , onSort: evt => {
+      , animation: 150
+      , onStart: () => {
+        console.log('drag start..')
+      }
+      , onSort: (evt) => {
         this.getCurrentListFromDOM()
         //console.log(evt)
+        console.log(evt.item)
+        console.log(evt.oldIndex, evt.newIndex)
       }
     })
   }

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