apply new formattinh
parent
b52c5fc484
commit
46642aea4d
|
@ -12,8 +12,16 @@ let check = (requiredPermission, actualPermission, res, next) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
checkSql: (req, res, next) => { check(1, req.user.permission, res, next) },
|
checkSql: (req, res, next) => {
|
||||||
checkHl: (req, res, next) => { check(2, req.user.permission, res, next) },
|
check(1, req.user.permission, res, next)
|
||||||
checkMT: (req, res, next) => { check(3, req.user.permission, res, next) },
|
},
|
||||||
checkAdmin: (req, res, next) => { check(4, req.user.permission, res, next) }
|
checkHl: (req, res, next) => {
|
||||||
|
check(2, req.user.permission, res, next)
|
||||||
|
},
|
||||||
|
checkMT: (req, res, next) => {
|
||||||
|
check(3, req.user.permission, res, next)
|
||||||
|
},
|
||||||
|
checkAdmin: (req, res, next) => {
|
||||||
|
check(4, req.user.permission, res, next)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -45,7 +45,8 @@ account.route('/:id')
|
||||||
req.body.updatedAt = new Date();
|
req.body.updatedAt = new Date();
|
||||||
req.body.$inc = {__v: 1};
|
req.body.$inc = {__v: 1};
|
||||||
|
|
||||||
// PATCH is easier with mongoose than PUT. You simply update by all data that comes from outside. no need to reset attributes that are missing.
|
// PATCH is easier with mongoose than PUT. You simply update by all data that comes from outside. no need to
|
||||||
|
// reset attributes that are missing.
|
||||||
AppUserModel.findByIdAndUpdate(req.params.id, req.body, {new: true}).populate('squad').exec((err, item) => {
|
AppUserModel.findByIdAndUpdate(req.params.id, req.body, {new: true}).populate('squad').exec((err, item) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
err.status = codes.wrongrequest;
|
err.status = codes.wrongrequest;
|
||||||
|
@ -70,7 +71,8 @@ account.route('/:id')
|
||||||
err = new Error("item not found");
|
err = new Error("item not found");
|
||||||
err.status = codes.notfound;
|
err.status = codes.notfound;
|
||||||
}
|
}
|
||||||
// we don't set res.locals.items and thus it will send a 204 (no content) at the end. see last handler user.use(..)
|
// we don't set res.locals.items and thus it will send a 204 (no content) at the end. see last handler
|
||||||
|
// user.use(..)
|
||||||
res.locals.processed = true;
|
res.locals.processed = true;
|
||||||
next(err); // this works because err is in normal case undefined and that is the same as no parameter
|
next(err); // this works because err is in normal case undefined and that is the same as no parameter
|
||||||
});
|
});
|
||||||
|
|
|
@ -44,8 +44,8 @@ awarding.route('/')
|
||||||
if (err) {
|
if (err) {
|
||||||
err.status = codes.servererror;
|
err.status = codes.servererror;
|
||||||
return next(err);
|
return next(err);
|
||||||
// with return before (or after) the next(err) we prevent that the code continues here after next(err) has finished.
|
// with return before (or after) the next(err) we prevent that the code continues here after next(err)
|
||||||
// this saves an extra else {..}
|
// has finished. this saves an extra else {..}
|
||||||
}
|
}
|
||||||
// if the collection is empty we do not send empty arrays back.
|
// if the collection is empty we do not send empty arrays back.
|
||||||
if (items && items.length > 0) {
|
if (items && items.length > 0) {
|
||||||
|
@ -60,8 +60,8 @@ awarding.route('/')
|
||||||
if (err) {
|
if (err) {
|
||||||
err.status = codes.servererror;
|
err.status = codes.servererror;
|
||||||
return next(err);
|
return next(err);
|
||||||
// with return before (or after) the next(err) we prevent that the code continues here after next(err) has finished.
|
// with return before (or after) the next(err) we prevent that the code continues here after next(err)
|
||||||
// this saves an extra else {..}
|
// has finished. this saves an extra else {..}
|
||||||
}
|
}
|
||||||
let results = [];
|
let results = [];
|
||||||
if (req.query.fractFilter) {
|
if (req.query.fractFilter) {
|
||||||
|
@ -118,7 +118,8 @@ awarding.route('/:id')
|
||||||
req.body.updatedAt = new Date();
|
req.body.updatedAt = new Date();
|
||||||
req.body.$inc = {__v: 1};
|
req.body.$inc = {__v: 1};
|
||||||
|
|
||||||
// PATCH is easier with mongoose than PUT. You simply update by all data that comes from outside. no need to reset attributes that are missing.
|
// PATCH is easier with mongoose than PUT. You simply update by all data that comes from outside. no need to
|
||||||
|
// reset attributes that are missing.
|
||||||
AwardingModel.findByIdAndUpdate(req.params.id, req.body, {new: true}, (err, item) => {
|
AwardingModel.findByIdAndUpdate(req.params.id, req.body, {new: true}, (err, item) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
err.status = codes.wrongrequest;
|
err.status = codes.wrongrequest;
|
||||||
|
@ -143,7 +144,8 @@ awarding.route('/:id')
|
||||||
err = new Error("item not found");
|
err = new Error("item not found");
|
||||||
err.status = codes.notfound;
|
err.status = codes.notfound;
|
||||||
}
|
}
|
||||||
// we don't set res.locals.items and thus it will send a 204 (no content) at the end. see last handler user.use(..)
|
// we don't set res.locals.items and thus it will send a 204 (no content) at the end. see last handler
|
||||||
|
// user.use(..)
|
||||||
res.locals.processed = true;
|
res.locals.processed = true;
|
||||||
next(err); // this works because err is in normal case undefined and that is the same as no parameter
|
next(err); // this works because err is in normal case undefined and that is the same as no parameter
|
||||||
});
|
});
|
||||||
|
|
|
@ -34,7 +34,14 @@ decoration.route('/')
|
||||||
if (req.query.q) {
|
if (req.query.q) {
|
||||||
filter.name = {$regex: req.query.q, $options: 'i'}
|
filter.name = {$regex: req.query.q, $options: 'i'}
|
||||||
}
|
}
|
||||||
DecorationModel.find(filter, {}, {sort: {fraction: 'asc', isMedal: 'asc', sortingNumber: 'asc', name: 'asc'}}, (err, items) => {
|
DecorationModel.find(filter, {}, {
|
||||||
|
sort: {
|
||||||
|
fraction: 'asc',
|
||||||
|
isMedal: 'asc',
|
||||||
|
sortingNumber: 'asc',
|
||||||
|
name: 'asc'
|
||||||
|
}
|
||||||
|
}, (err, items) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
err.status = codes.servererror;
|
err.status = codes.servererror;
|
||||||
return next(err);
|
return next(err);
|
||||||
|
@ -112,7 +119,8 @@ decoration.route('/:id')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// PATCH is easier with mongoose than PUT. You simply update by all data that comes from outside. no need to reset attributes that are missing.
|
// PATCH is easier with mongoose than PUT. You simply update by all data that comes from outside. no need
|
||||||
|
// to reset attributes that are missing.
|
||||||
DecorationModel.findByIdAndUpdate(req.params.id, req.body, {new: true}, (err, item) => {
|
DecorationModel.findByIdAndUpdate(req.params.id, req.body, {new: true}, (err, item) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
err.status = codes.wrongrequest;
|
err.status = codes.wrongrequest;
|
||||||
|
@ -147,7 +155,8 @@ decoration.route('/:id')
|
||||||
if (err) next(err);
|
if (err) next(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
// we don't set res.locals.items and thus it will send a 204 (no content) at the end. see last handler user.use(..)
|
// we don't set res.locals.items and thus it will send a 204 (no content) at the end. see last handler
|
||||||
|
// user.use(..)
|
||||||
res.locals.processed = true;
|
res.locals.processed = true;
|
||||||
next(err); // this works because err is in normal case undefined and that is the same as no parameter
|
next(err); // this works because err is in normal case undefined and that is the same as no parameter
|
||||||
});
|
});
|
||||||
|
|
|
@ -35,7 +35,15 @@ campaignPlayer.route('/ranking/:campaignId')
|
||||||
const rankingItems = [];
|
const rankingItems = [];
|
||||||
new Set(items.map(x => x.name)).forEach(playerName => {
|
new Set(items.map(x => x.name)).forEach(playerName => {
|
||||||
const playerInstances = items.filter(p => p.name === playerName);
|
const playerInstances = items.filter(p => p.name === playerName);
|
||||||
const resItem = {name: playerName, kill: 0, death: 0, friendlyFire: 0, revive: 0, respawn: 0, flagTouch: 0};
|
const resItem = {
|
||||||
|
name: playerName,
|
||||||
|
kill: 0,
|
||||||
|
death: 0,
|
||||||
|
friendlyFire: 0,
|
||||||
|
revive: 0,
|
||||||
|
respawn: 0,
|
||||||
|
flagTouch: 0
|
||||||
|
};
|
||||||
for (let i = 0; i < playerInstances.length; i++) {
|
for (let i = 0; i < playerInstances.length; i++) {
|
||||||
resItem.kill += playerInstances[i].kill;
|
resItem.kill += playerInstances[i].kill;
|
||||||
resItem.death += playerInstances[i].death;
|
resItem.death += playerInstances[i].death;
|
||||||
|
|
|
@ -114,7 +114,8 @@ ranks.route('/:id')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// PATCH is easier with mongoose than PUT. You simply update by all data that comes from outside. no need to reset attributes that are missing.
|
// PATCH is easier with mongoose than PUT. You simply update by all data that comes from outside. no need to
|
||||||
|
// reset attributes that are missing.
|
||||||
RankModel.findByIdAndUpdate(req.params.id, req.body, {new: true}, (err, item) => {
|
RankModel.findByIdAndUpdate(req.params.id, req.body, {new: true}, (err, item) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
err.status = codes.wrongrequest;
|
err.status = codes.wrongrequest;
|
||||||
|
@ -139,7 +140,8 @@ ranks.route('/:id')
|
||||||
err = new Error("item not found");
|
err = new Error("item not found");
|
||||||
err.status = codes.notfound;
|
err.status = codes.notfound;
|
||||||
}
|
}
|
||||||
// we don't set res.locals.items and thus it will send a 204 (no content) at the end. see last handler user.use(..)
|
// we don't set res.locals.items and thus it will send a 204 (no content) at the end. see last handler
|
||||||
|
// user.use(..)
|
||||||
res.locals.processed = true;
|
res.locals.processed = true;
|
||||||
next(err); // this works because err is in normal case undefined and that is the same as no parameter
|
next(err); // this works because err is in normal case undefined and that is the same as no parameter
|
||||||
})
|
})
|
||||||
|
|
|
@ -141,7 +141,8 @@ request.route('/promotion/:id')
|
||||||
req.body.updatedAt = new Date();
|
req.body.updatedAt = new Date();
|
||||||
req.body.$inc = {__v: 1};
|
req.body.$inc = {__v: 1};
|
||||||
|
|
||||||
// PATCH is easier with mongoose than PUT. You simply update by all data that comes from outside. no need to reset attributes that are missing.
|
// PATCH is easier with mongoose than PUT. You simply update by all data that comes from outside. no need to
|
||||||
|
// reset attributes that are missing.
|
||||||
PromotionModel.findByIdAndUpdate(req.params.id, req.body, {new: true}, (err, item) => {
|
PromotionModel.findByIdAndUpdate(req.params.id, req.body, {new: true}, (err, item) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
err.status = codes.wrongrequest;
|
err.status = codes.wrongrequest;
|
||||||
|
|
|
@ -116,7 +116,8 @@ squads.route('/:id')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// PATCH is easier with mongoose than PUT. You simply update by all data that comes from outside. no need to reset attributes that are missing.
|
// PATCH is easier with mongoose than PUT. You simply update by all data that comes from outside. no need to
|
||||||
|
// reset attributes that are missing.
|
||||||
SquadModel.findByIdAndUpdate(req.params.id, req.body, {new: true}, (err, item) => {
|
SquadModel.findByIdAndUpdate(req.params.id, req.body, {new: true}, (err, item) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
err.status = codes.wrongrequest;
|
err.status = codes.wrongrequest;
|
||||||
|
@ -147,7 +148,8 @@ squads.route('/:id')
|
||||||
if (err) next(err);
|
if (err) next(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
// we don't set res.locals.items and thus it will send a 204 (no content) at the end. see last handler user.use(..)
|
// we don't set res.locals.items and thus it will send a 204 (no content) at the end. see last handler
|
||||||
|
// user.use(..)
|
||||||
res.locals.processed = true;
|
res.locals.processed = true;
|
||||||
next(err); // this works because err is in normal case undefined and that is the same as no parameter
|
next(err); // this works because err is in normal case undefined and that is the same as no parameter
|
||||||
});
|
});
|
||||||
|
|
|
@ -118,7 +118,8 @@ users.route('/:id')
|
||||||
req.body.updatedAt = new Date();
|
req.body.updatedAt = new Date();
|
||||||
req.body.$inc = {__v: 1};
|
req.body.$inc = {__v: 1};
|
||||||
|
|
||||||
// PATCH is easier with mongoose than PUT. You simply update by all data that comes from outside. no need to reset attributes that are missing.
|
// PATCH is easier with mongoose than PUT. You simply update by all data that comes from outside. no need to
|
||||||
|
// reset attributes that are missing.
|
||||||
UserModel.findByIdAndUpdate(req.params.id, req.body, {new: true}, (err, item) => {
|
UserModel.findByIdAndUpdate(req.params.id, req.body, {new: true}, (err, item) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
err.status = codes.wrongrequest;
|
err.status = codes.wrongrequest;
|
||||||
|
@ -156,7 +157,8 @@ users.route('/:id')
|
||||||
// main difference of PUT and PATCH is that PUT expects all data in request: checked by using the schema
|
// main difference of PUT and PATCH is that PUT expects all data in request: checked by using the schema
|
||||||
const user = new UserModel(req.body);
|
const user = new UserModel(req.body);
|
||||||
UserModel.findById(req.params.id, req.body, {new: true}, function (err, item) {
|
UserModel.findById(req.params.id, req.body, {new: true}, function (err, item) {
|
||||||
// with parameter {new: true} the TweetNModel will return the new and changed object from the DB and not the old one.
|
// with parameter {new: true} the TweetNModel will return the new and changed object from the DB and not the
|
||||||
|
// old one.
|
||||||
if (err) {
|
if (err) {
|
||||||
err.status = codes.wrongrequest;
|
err.status = codes.wrongrequest;
|
||||||
return next(err);
|
return next(err);
|
||||||
|
@ -225,7 +227,8 @@ users.route('/:id')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// we don't set res.locals.items and thus it will send a 204 (no content) at the end. see last handler user.use(..)
|
// we don't set res.locals.items and thus it will send a 204 (no content) at the end. see last handler
|
||||||
|
// user.use(..)
|
||||||
res.locals.processed = true;
|
res.locals.processed = true;
|
||||||
next(err); // this works because err is in normal case undefined and that is the same as no parameter
|
next(err); // this works because err is in normal case undefined and that is the same as no parameter
|
||||||
});
|
});
|
||||||
|
|
|
@ -207,7 +207,8 @@ wars.route('/:id')
|
||||||
fs.rmdir(warDir, (err) => {
|
fs.rmdir(warDir, (err) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// we don't set res.locals.items and thus it will send a 204 (no content) at the end. see last handler user.use(..)
|
// we don't set res.locals.items and thus it will send a 204 (no content) at the end. see last handler
|
||||||
|
// user.use(..)
|
||||||
res.locals.processed = true;
|
res.locals.processed = true;
|
||||||
next();
|
next();
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
<div class="army-member-view-container">
|
<div class="army-member-view-container">
|
||||||
<div class="return-button">
|
<div class="return-button">
|
||||||
<span class="btn btn-default" style="position:absolute;" (click)="backToOverview()">< zurück zur Übersicht</span>
|
<span class="btn btn-default" style="position:absolute;" (click)="backToOverview()">< zurück zur Übersicht</span>
|
||||||
<h3 class="text-center" style="font-weight: 600" [style.color]="user.squadId?.fraction === 'BLUFOR' ? fraction.COLOR_BLUFOR : fraction.COLOR_OPFOR">
|
<h3 class="text-center" style="font-weight: 600"
|
||||||
|
[style.color]="user.squadId?.fraction === 'BLUFOR' ? fraction.COLOR_BLUFOR : fraction.COLOR_OPFOR">
|
||||||
Auszeichnungen von {{user.username}}
|
Auszeichnungen von {{user.username}}
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -38,7 +38,8 @@ export class UserService {
|
||||||
}
|
}
|
||||||
}).map(res => res.json()).do((users) => {
|
}).map(res => res.json()).do((users) => {
|
||||||
this.userStore.dispatch({type: action, data: users});
|
this.userStore.dispatch({type: action, data: users});
|
||||||
}).subscribe(_ => {});
|
}).subscribe(_ => {
|
||||||
|
});
|
||||||
|
|
||||||
return this.users$;
|
return this.users$;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,10 +38,11 @@ export class ScoreboardComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
this.elRef.nativeElement.querySelector('.datatable-body').scrollTo(0, 0);
|
|
||||||
|
|
||||||
if (changes.war) {
|
if (changes.war) {
|
||||||
this.rows = changes.war.currentValue.players;
|
this.rows = changes.war.currentValue.players;
|
||||||
|
this.elRef.nativeElement
|
||||||
|
.querySelector('.datatable-body')
|
||||||
|
.scrollTo(0, 0);
|
||||||
}
|
}
|
||||||
if (changes.fractionFilterSelected) {
|
if (changes.fractionFilterSelected) {
|
||||||
this.filterPlayersByFraction(this.fractionFilterSelected)
|
this.filterPlayersByFraction(this.fractionFilterSelected)
|
||||||
|
|
Loading…
Reference in New Issue