filter emails
This commit is contained in:
2
dist/qmi-cloud/index.html
vendored
2
dist/qmi-cloud/index.html
vendored
@@ -11,5 +11,5 @@
|
||||
<link rel="stylesheet" href="styles.fc71de1623889098932b.css"></head>
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
<script src="runtime.c51bd5b1c616d9ffddc1.js" defer></script><script src="polyfills-es5.6fef7e679f78bcc42760.js" nomodule defer></script><script src="polyfills.51f5cc3d1309de3a873d.js" defer></script><script src="scripts.1af868998801499c8755.js" defer></script><script src="main.e13b3485a90ddde0782b.js" defer></script></body>
|
||||
<script src="runtime.c51bd5b1c616d9ffddc1.js" defer></script><script src="polyfills-es5.6fef7e679f78bcc42760.js" nomodule defer></script><script src="polyfills.51f5cc3d1309de3a873d.js" defer></script><script src="scripts.1af868998801499c8755.js" defer></script><script src="main.218d6e84dad1df871bda.js" defer></script></body>
|
||||
</html>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -50,13 +50,16 @@ const schema = new mongoose.Schema({
|
||||
passwd: {
|
||||
type: String,
|
||||
default: function() {
|
||||
return crypto.randomBytes(8).toString('hex');
|
||||
return crypto.randomBytes(4).toString('hex');
|
||||
}
|
||||
},
|
||||
studentsCount: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
},
|
||||
studentEmailFilter: {
|
||||
type: String // qlik.com,talend.com,gmail.com
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -22,7 +22,8 @@ const qa = require('../training/automations');
|
||||
*/
|
||||
router.get('/sessions', passport.ensureAuthenticatedAndAdmin, async (req, res, next) => {
|
||||
try {
|
||||
const result = await db.trainingSession.get();
|
||||
const filter = req.query.filter? JSON.parse(req.query.filter) : {};
|
||||
const result = await db.trainingSession.get(filter);
|
||||
return res.json(result);
|
||||
} catch (error) {
|
||||
next(error);
|
||||
@@ -43,7 +44,8 @@ router.get('/sessions', passport.ensureAuthenticatedAndAdmin, async (req, res, n
|
||||
*/
|
||||
router.get('/templates', passport.ensureAuthenticated, async (req, res, next) => {
|
||||
try {
|
||||
const result = await db.trainingTemplate.get();
|
||||
const filter = req.query.filter? JSON.parse(req.query.filter) : {};
|
||||
const result = await db.trainingTemplate.get(filter);
|
||||
return res.json(result);
|
||||
} catch (error) {
|
||||
next(error);
|
||||
|
||||
@@ -12,8 +12,10 @@ export class TrainingService {
|
||||
|
||||
}
|
||||
|
||||
getTrainingSessionsAdmin() : Observable<any> {
|
||||
return this.httpClient.get(`${environment.apiVersionPath}/training/sessions`);
|
||||
getTrainingSessionsAdmin(filter) : Observable<any> {
|
||||
let params = new HttpParams();
|
||||
params = params.append("filter", JSON.stringify(filter));
|
||||
return this.httpClient.get(`${environment.apiVersionPath}/training/sessions`, { params: params });
|
||||
}
|
||||
|
||||
getTrainingSessions(userId) : Observable<any> {
|
||||
|
||||
@@ -70,10 +70,10 @@
|
||||
<p for="email">
|
||||
Your email:
|
||||
</p>
|
||||
<input mdbInput class="form-control" id="email" name="email" [(ngModel)]="email" required="required" type="text" placeholder="name@company.com"
|
||||
<input mdbInput class="form-control" id="email" name="email" [(ngModel)]="email" required="required" type="email" placeholder="name@company.com"
|
||||
style="width:300px" />
|
||||
<div id="invalidemail" class="lui-text-danger" style="display:none;">
|
||||
Invalid email, please try again.
|
||||
Email not allowed, please try again.
|
||||
</div>
|
||||
<br>
|
||||
<div id="captcha" style="height: 50px">
|
||||
|
||||
@@ -81,6 +81,16 @@ export class SessionFormComponent implements AfterViewInit, OnInit {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.session.studentEmailFilter) {
|
||||
let filter = this.session.studentEmailFilter.toLowerCase();
|
||||
let emailDomain = this.email.split("@")[1].toLowerCase();
|
||||
if ( !filter.includes(emailDomain) ) {
|
||||
this.email = null;
|
||||
this.forms[0].classList.add('was-validated');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.captcha !== this.code) {
|
||||
this.captcha = null;
|
||||
}
|
||||
@@ -89,6 +99,8 @@ export class SessionFormComponent implements AfterViewInit, OnInit {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.wait = true;
|
||||
this._trainingService.submit(this.session._id, {email: this.email}).subscribe(result=>{
|
||||
this.wait = false;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
<br>
|
||||
<mdb-checkbox [inline]="true" [checked]="true" [default]="true" [(ngModel)]="filter.active" (change)="onCheckValue()">Show terminated sessions</mdb-checkbox>
|
||||
<div class="md-form">
|
||||
<input type="text" class="form-control w-25" [(ngModel)]="searchText" (keyup)="searchItems()" id="search-input2"
|
||||
mdbInput>
|
||||
|
||||
@@ -24,6 +24,9 @@ export class TableSessionsComponent implements OnInit, AfterViewInit {
|
||||
|
||||
loading: boolean = false;
|
||||
elements = [];
|
||||
filter = {
|
||||
active: false
|
||||
}
|
||||
|
||||
@HostListener('input') oninput() {
|
||||
this.mdbTablePagination.searchText = this.searchText;
|
||||
@@ -45,7 +48,11 @@ export class TableSessionsComponent implements OnInit, AfterViewInit {
|
||||
refreshData() {
|
||||
this.loading = true;
|
||||
this.searchText = "";
|
||||
var sub = this._trainingService.getTrainingSessionsAdmin().subscribe( res => {
|
||||
let actualFilter = {};
|
||||
if ( !this.filter.active ) {
|
||||
actualFilter["status"] = {"$ne": "terminated"};
|
||||
}
|
||||
var sub = this._trainingService.getTrainingSessionsAdmin(actualFilter).subscribe( res => {
|
||||
sub.unsubscribe();
|
||||
this.elements = res.results;
|
||||
this.loading = false;
|
||||
@@ -137,6 +144,10 @@ export class TableSessionsComponent implements OnInit, AfterViewInit {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
onCheckValue() : void {
|
||||
this.refreshData();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -92,6 +92,12 @@
|
||||
<input mdbInput type="text" name="text" [(ngModel)]="sendData.cloudshareClass" id="title2" class="form-control" required>
|
||||
<label for="title2" class="">CloudShare ClassID*:</label>
|
||||
</div>
|
||||
|
||||
<div class="md-form">
|
||||
<input mdbInput type="text" name="text" [(ngModel)]="sendData.studentEmailFilter" id="allowedemails" class="form-control">
|
||||
<label for="allowedemails" class="">Student email filter:</label>
|
||||
<i>Comma separated allowed email domains, ie: qlik.com,talend.com,gmail.com. Leave empty to allow all emails.</i>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user