-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
submit & add some feature to finish the end of project
- Loading branch information
Showing
47 changed files
with
301 additions
and
230 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 |
---|---|---|
|
@@ -28,3 +28,6 @@ node_modules | |
|
||
# Debug log from npm | ||
npm-debug.log | ||
|
||
# csv | ||
*.csv |
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,75 @@ | ||
var Thekey = require('../models/thekey'); | ||
var uuid = require('node-uuid'); | ||
|
||
exports.setCancel = function(req, res){ | ||
var id = req.body.kid; | ||
Thekey.update({_id:id}, {$inc:{issue:2}}, function(err){ | ||
if (err) {console.log(err);} | ||
return res.json({success:1}); | ||
}) | ||
} | ||
|
||
exports.setAccept = function(req, res){ | ||
var id = req.body.kid; | ||
Thekey.update({_id:id}, {$inc:{issue:1}}, function(err){ | ||
if (err) {console.log(err);} | ||
return res.json({success:1}); | ||
}) | ||
} | ||
|
||
exports.keyList = function(req, res){ | ||
Thekey | ||
.find({}) | ||
.populate('user', 'name') | ||
.exec(function(err, thekeys){ | ||
console.log(thekeys); | ||
res.render('keyList', { | ||
isSub: true, | ||
keylistjs: true, | ||
baseurl: req.url, | ||
thekeys: thekeys, | ||
}); | ||
}) | ||
} | ||
|
||
exports.applyKey = function(req, res){ | ||
Thekey.findOne({user: req.session.user._id}, function(err, thekey){ | ||
if (err) {console.log(err);} | ||
console.log(thekey); | ||
if (thekey==null) { | ||
var thekey = { | ||
newkey: '这里不要求您填入', | ||
}; | ||
} | ||
res.render('applyKey', { | ||
isSub: true, | ||
applykeyjs: true, | ||
baseurl: req.url, | ||
thekey: thekey, | ||
}); | ||
|
||
}) | ||
} | ||
|
||
exports.genUuid = function(req, res){ | ||
Thekey.remove({user: req.session.user._id}, function(err){ | ||
console.log('---clean db ---------------------------------------'); | ||
if (err) { | ||
console.log('Thekey remove all occur a error:', err); | ||
} else { | ||
console.log('Thekey remove all success.'); | ||
} | ||
}) | ||
var newkey = uuid.v1(); | ||
var uid = req.body.uid; | ||
var _thekey = { | ||
newkey: newkey, | ||
user: uid, | ||
issue: 0, | ||
}; | ||
var thekey = new Thekey(_thekey); | ||
thekey.save(function(err, thekey){ | ||
if (err) {console.log(err);} | ||
return res.json({success:1}); | ||
}) | ||
} |
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,5 @@ | ||
var mongoose = require('mongoose'); | ||
var thekeySchema = require('../schemas/thekey'); | ||
var thekey = mongoose.model('Thekey', thekeySchema); | ||
|
||
module.exports = thekey |
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,50 @@ | ||
var mongoose = require('mongoose'); | ||
var Schema = mongoose.Schema; | ||
var ObjectId = Schema.Types.ObjectId; | ||
var ThekeySchema = new Schema({ | ||
newkey: { | ||
type: String, | ||
}, | ||
issue: { | ||
type: Number, | ||
default: 0, | ||
}, | ||
user:{ | ||
type: ObjectId, | ||
ref:'User' | ||
}, | ||
meta:{ | ||
createAt:{ | ||
type:Date, | ||
default:Date.now() | ||
}, | ||
updateAt:{ | ||
type:Date, | ||
default:Date.now() | ||
} | ||
} | ||
}); | ||
ThekeySchema.pre('save', function (next) { | ||
if (this.isNew) { | ||
this.meta.createAt = this.meta.updateAt = Date.now() | ||
} else { | ||
this.meta.updateAt = Date.now(); | ||
} | ||
next() | ||
}) | ||
ThekeySchema.statics = { | ||
fetch:function(cb){ | ||
return this | ||
.find({}) | ||
.sort('meta.updateAt') | ||
.exec(cb); | ||
}, | ||
findById:function(id, cb){ | ||
return this | ||
.findOne({ | ||
_id:id | ||
}) | ||
.exec(cb); | ||
} | ||
} | ||
module.exports = ThekeySchema; |
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,43 @@ | ||
extends ../layout | ||
|
||
block content | ||
.row | ||
.col-md-12.mt | ||
.content-panel | ||
table.table.table-hover | ||
h4 | ||
i.fa.fa-angle-right | ||
| Keys | ||
hr | ||
thead | ||
tr | ||
th # | ||
th NewKey | ||
th Name | ||
th Status | ||
th 操作 | ||
tbody | ||
each item, idx in thekeys | ||
tr | ||
td #{idx} | ||
td #{item.newkey} | ||
td #{item.user.name} | ||
td | ||
case item.issue | ||
when 0 | ||
span.label.label-warning 申请中 | ||
when 1 | ||
span.label.label-info 可使用 | ||
when 2 | ||
span.label.label-danger 失效 | ||
default | ||
span.label.label-danger 失效 | ||
td | ||
if item.issue==0 | ||
button.btn.btn-info.btn-xs.accept(data-kid=item._id) | ||
i.fa.fa-file-o | ||
| Accept | ||
button.btn.btn-danger.btn-xs.cancel(data-kid=item._id) | ||
i.fa.fa-trash-o | ||
| Cancel | ||
// /col-md-12 |
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
Empty file.
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 @@ | ||
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"msgweb.members"}]} |
Empty file.
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 @@ | ||
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"msgweb.messages"},{"v":2,"unique":true,"key":{"groupid":1},"name":"groupid_1","ns":"msgweb.messages","background":true}]} |
Empty file.
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 @@ | ||
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"msgweb.msgtemplates"}]} |
Empty file.
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 @@ | ||
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"msgweb.sessions"},{"v":2,"key":{"expires":1},"name":"expires_1","ns":"msgweb.sessions","expireAfterSeconds":0}]} |
Binary file not shown.
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 @@ | ||
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"msgweb.smstemplates"}]} |
Empty file.
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 @@ | ||
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"msgweb.thekeys"}]} |
Binary file not shown.
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 @@ | ||
{"options":{},"indexes":[{"v":2,"key":{"_id":1},"name":"_id_","ns":"msgweb.users"},{"v":2,"unique":true,"key":{"name":1},"name":"name_1","ns":"msgweb.users","background":true}]} |
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 |
---|---|---|
|
@@ -6200,4 +6200,3 @@ button.close { | |
display: none !important; | ||
} | ||
} | ||
/*# sourceMappingURL=bootstrap.css.map */ |
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,17 @@ | ||
$(function(){ | ||
$('.apply').click(function(e){ | ||
var target = $(e.target); | ||
var uid = target.data('uid'); | ||
var url = '/genUuid'; | ||
var data = { | ||
uid: uid, | ||
} | ||
var success = function(res){ | ||
if (res.success === 1) { | ||
alert('申请成功,请等待Root同意'); | ||
window.location.href="/applyKey "; | ||
} | ||
} | ||
$.post( url, data, success, 'json'); | ||
}) | ||
}) |
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
Oops, something went wrong.