-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/1request/weixin into feat…
…ure/connect_rails Conflicts: both/controllers/staffs.js client/components/header/header.html client/pages/staffs/chat.coffee resolved
- Loading branch information
Showing
10 changed files
with
241 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.8.1.3 | ||
0.8.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
db.accounts = new Meteor.Collection 'accounts' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
############################ | ||
# Local Functions | ||
############################ | ||
@validateAccountInfo = -> | ||
if (!document.getElementById('gh_id').value) | ||
throw new Meteor.Error(422, 'Please fill in GH ID') | ||
if (!Session.get('accountSelected')?) | ||
account = db.accounts.findOne({gh_id: document.getElementById('gh_id').value}) | ||
throw new Meteor.Error(422, 'GH ID is already in use') if account? | ||
if (!document.getElementById('weixin_id').value) | ||
throw new Meteor.Error(422, 'Please fill in WeChat ID') | ||
if (!document.getElementById('account_name').value) | ||
throw new Meteor.Error(422, 'Please fill in Account name') | ||
if (!document.getElementById('app_id').value) | ||
throw new Meteor.Error(422, 'Please fill in App ID') | ||
if (!document.getElementById('app_secret').value) | ||
throw new Meteor.Error(422, 'Please fill in App Secret') | ||
|
||
############################ | ||
# Template: accountList | ||
############################ | ||
Template.accountList.helpers | ||
accounts: -> | ||
db.accounts.find() | ||
|
||
Template.accountList.events | ||
'click li': (e) -> | ||
Session.set('accountSelected', @gh_id) | ||
|
||
############################ | ||
# Template: accountModal | ||
############################ | ||
Template.accountModal.helpers | ||
account: -> | ||
db.accounts.findOne({gh_id: Session.get('accountSelected')}) | ||
accountSelected: -> | ||
Session.get('accountSelected')? | ||
|
||
Template.accountModal.events | ||
'submit .form': (e) -> | ||
e.preventDefault() | ||
|
||
try | ||
validateAccountInfo() | ||
|
||
HTTP.post('http://api.xin.io/accounts', | ||
params: | ||
gh_id: document.getElementById('gh_id').value | ||
weixin_id: document.getElementById('weixin_id').value | ||
name: document.getElementById('account_name').value | ||
app_id: document.getElementById('app_id').value | ||
app_secret: document.getElementById('app_secret').value | ||
headers: | ||
'Content-Type': 'application/x-www-form-urlencoded' | ||
(error, result) -> console.log result | ||
) | ||
|
||
Session.set('accountSelected', document.getElementById('gh_id').value) | ||
|
||
$('.form')[0].reset() | ||
$('#accountModal').modal('toggle') | ||
catch error | ||
alert(error.reason) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# customer = db.customers.find() | ||
# customer.forEach (eachCustomer) -> | ||
# msg = db.messages.find(customer_id: eachCustomer._id) | ||
# msg.forEach (message) -> | ||
# if !message.created_at | ||
# message.created_at = new Date() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Meteor.publish 'accounts', -> | ||
db.accounts.find() |