Skip to content

Commit

Permalink
Merge branch 'prerelease' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
erkkitervoOY committed Nov 3, 2023
2 parents 13eb9a1 + 415585c commit c3574d1
Show file tree
Hide file tree
Showing 11 changed files with 3,193 additions and 9,592 deletions.
2 changes: 1 addition & 1 deletion UKK-tiketit
Submodule UKK-tiketit updated 75 files
+4 −7 .eslintrc.json
+1 −0 .gitignore
+104 −34 documentation/kuvaus/kuvaus.md
+2,568 −1,975 package-lock.json
+52 −52 package.json
+2 −1 src/app/app.component.html
+6 −0 src/app/app.component.ts
+1 −1 src/app/app.module.ts
+5 −0 src/app/core/core.models.ts
+6 −1 src/app/core/data-consent/data-consent.component.html
+10 −4 src/app/core/data-consent/data-consent.component.ts
+0 −1 src/app/core/footer/footer.component.html
+0 −1 src/app/core/footer/footer.component.scss
+367 −176 src/app/core/footer/privacy-modal/privacy-modal.component.html
+9 −2 src/app/core/footer/privacy-modal/privacy-modal.component.ts
+2 −0 src/app/core/header/header.component.html
+10 −6 src/app/core/header/header.component.ts
+1 −0 src/app/core/home/home.component.html
+0 −2 src/app/core/home/home.component.ts
+0 −2 src/app/core/no-privileges/no-privileges.component.ts
+0 −4 src/app/core/page-not-found/page-not-found.component.ts
+18 −29 src/app/core/services/auth.service.ts
+1 −1 src/app/core/services/error.service.ts
+1 −1 src/app/core/services/store.service.ts
+4 −4 src/app/core/services/utils.service.ts
+0 −2 src/app/course/course-routing.module.ts
+124 −20 src/app/course/course.service.ts
+0 −2 src/app/course/edit-field/edit-field.component.html
+0 −3 src/app/course/edit-field/edit-field.component.scss
+1 −1 src/app/course/edit-field/edit-field.component.ts
+0 −4 src/app/course/join/join.component.html
+9 −28 src/app/course/join/join.component.ts
+2 −3 src/app/course/settings/settings.component.html
+3 −3 src/app/course/settings/settings.component.scss
+0 −3 src/app/shared/components/beginning-button/beginning-button.component.scss
+10 −2 src/app/shared/components/error/error.component.ts
+2 −2 src/app/shared/components/headline/headline.component.scss
+2 −1 src/app/shared/components/headline/headline.component.ts
+1 −2 src/app/shared/components/refresh-dialog/refresh-dialog.component.scss
+2 −1 src/app/shared/components/refresh-dialog/refresh-dialog.component.ts
+2 −9 src/app/shared/components/search-bar/search-bar.component.scss
+2 −2 src/app/shared/components/search-bar/search-bar.component.ts
+0 −1 src/app/shared/components/sender-info/sender-info.component.html
+4 −7 src/app/shared/components/sender-info/sender-info.component.ts
+0 −1 src/app/shared/components/sender-info/sender-info.constants.ts
+8 −4 src/app/shared/editor/menu-link/menu-link.component.html
+1 −2 src/app/shared/material.module.ts
+2 −1 src/app/ticket/components/comment/comment.component.html
+14 −2 src/app/ticket/components/comment/comment.component.spec.ts
+3 −3 src/app/ticket/components/edit-attachments/edit-attachments.component.ts
+2 −3 src/app/ticket/faq-view/faq-view.component.html
+2 −1 src/app/ticket/faq-view/faq-view.component.spec.ts
+5 −3 src/app/ticket/faq-view/faq-view.component.ts
+9 −11 src/app/ticket/listing/listing.component.html
+4 −5 src/app/ticket/listing/listing.component.ts
+115 −120 src/app/ticket/listing/ticket-list/ticket-list.component.html
+38 −6 src/app/ticket/listing/ticket-list/ticket-list.component.spec.ts
+9 −13 src/app/ticket/listing/ticket-list/ticket-list.component.ts
+2 −1 src/app/ticket/submit-faq/submit-faq.component.spec.ts
+8 −12 src/app/ticket/submit-faq/submit-faq.component.ts
+0 −1 src/app/ticket/submit-ticket/submit-ticket.component.html
+13 −12 src/app/ticket/submit-ticket/submit-ticket.component.spec.ts
+7 −7 src/app/ticket/submit-ticket/submit-ticket.component.ts
+2 −2 src/app/ticket/ticket-view/ticket-view.component.html
+2 −1 src/app/ticket/ticket-view/ticket-view.component.spec.ts
+6 −5 src/app/ticket/ticket-view/ticket-view.component.ts
+38 −3 src/app/ticket/ticket.dummydata.ts
+4 −3 src/app/ticket/ticket.models.ts
+2 −1 src/app/ticket/ticket.service.spec.ts
+163 −34 src/app/ticket/ticket.service.ts
+1 −3 src/app/user/login/login.component.ts
+8 −17 src/app/user/register/register.component.html
+11 −21 src/app/user/register/register.component.ts
+85 −83 src/assets/i18n/en-US.json
+1 −1 tsconfig.json
12,666 changes: 3,118 additions & 9,548 deletions package-lock.json

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@
"test": "mocha --reporter spec --exit"
},
"dependencies": {
"chai": "^4.3.7",
"chai-http": "^4.4.0",
"connect-pg-simple": "^8.0.0",
"cookie-parser": "~1.4.4",
"cors": "^2.8.5",
"dotenv": "^16.0.3",
"express": "~4.16.1",
"express-fileupload": "^1.4.0",
"express-session": "^1.17.3",
"http-errors": "~1.6.3",
"ims-lti": "^3.0.2",
"jszip": "^3.10.1",
"ltijs": "^5.9.0",
"ltijs-sequelize": "^2.4.4",
"mocha": "^10.2.0",
"morgan": "~1.9.1",
"node-cron": "^3.0.2",
"nodemailer": "^6.9.1",
"pg": "^8.8.0",
"postgrator": "^7.2.0",
"request": "^2.88.2"
"chai": "~4.3.10",
"chai-http": "~4.4.0",
"connect-pg-simple": "~9.0.1",
"cookie-parser": "~1.4.6",
"cors": "~2.8.5",
"dotenv": "~16.3.1",
"express": "~4.18.2",
"express-fileupload": "~1.4.2",
"express-session": "~1.17.3",
"http-errors": "~2.0.0",
"ims-lti": "~3.0.2",
"jszip": "~3.10.1",
"ltijs": "~5.9.3",
"ltijs-sequelize": "~2.4.4",
"mocha": "~10.2.0",
"morgan": "~1.10.0",
"node-cron": "~3.0.2",
"nodemailer": "~6.9.7",
"pg": "~8.11.3",
"postgrator": "~7.2.0",
"request": "~2.88.2"
}
}
2 changes: 1 addition & 1 deletion public/javascripts/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ module.exports = {
//TODO: Toteuta oikea client secret -hallintamekanismi tietokantaan.
return new Promise(function(resolve, reject) {

console.log(request.body);
//console.log(request.body);

let consumerKey = request.body.oauth_consumer_key;
if (consumerKey !== process.env.TEMP_CLIENT_KEY) {
Expand Down
30 changes: 19 additions & 11 deletions public/javascripts/mailer.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = {
});

let receiverIdList = arrayTools.extractAttributes(receiverList, 'id');
return { recipients: receiverIdList, ticket: storedTicketData, course: storedCourseData };
return { recipients: receiverIdList, ticket: storedTicketData, course: storedCourseData, creator: storedCreator };
})

},
Expand Down Expand Up @@ -97,8 +97,8 @@ module.exports = {

let subject = 'TUKKI viesti - message: ' + storedCourseName;
let message = '<h1>' + storedCourseName + '</h1> \
<p>Kysymykseen <b>' + storedTicketTitle + '</b> on tullut viesti:<br>\
Question <b>' + storedTicketTitle + '</b> has received a comment:</b></p> \
<p>' + storedCreator.nimi + ' on lisännyt viestin kysymykseen <b>' + storedTicketTitle + '</b>:<br>\
' + storedCreator.nimi + ' has added a comment to question <b>' + storedTicketTitle + '</b>:</p> \
<p>' + content + '</p><hr> \
<p>Voit käydä vastaamassa siihen osoitteessa:<br>\
You may answer it in the following address:<br>\
Expand Down Expand Up @@ -150,8 +150,8 @@ module.exports = {

let subject = 'TUKKI Uusi kysymys - New question: ' + storedNotificationData.course.nimi;
let message = '<h1>' + storedNotificationData.course.nimi + '</h1> \
<p>Tukissa on uusi kysymys:<br>\
Tukki has a new question:</p> \
<p>Tukissa on uusi kysymys käyttäjältä ' + storedNotificationData.creator.nimi + ':<br>\
Tukki has a new question from ' + storedNotificationData.creator.nimi + ':</p> \
<h2>' + storedNotificationData.ticket.otsikko + '</h2>\
<p>' + commentDataList[0].viesti + '</p><hr> \
<p>Voit käydä vastaamassa siihen osoitteessa:<br>\
Expand Down Expand Up @@ -366,15 +366,15 @@ module.exports = {
return sql.courses.getCourseInfo(courseId)
.then((courseData) => {
content = content + title.replace('[Kurssi]', courseData.nimi);
return sql.tickets.getAllCommentsFromCourseSinceYesterday(courseId, [profileId])
return sql.tickets.getAllCommentsFromCourseSinceYesterdayWithFaqs(courseId, [profileId])
})
.then((commentList) => {
let ticketIds = arrayTools.extractAttributes(commentList, 'tiketti');
return sql.tickets.getAllTicketsFromList(ticketIds);
})
.then((ticketList) => {
return ticketList.filter((value, index, array) => {
return value.aloittaja == profileId;
return value.aloittaja == profileId || value.ukk == true;
})
})
.then((ticketList) => {
Expand All @@ -388,7 +388,6 @@ module.exports = {
content = content + newRow;
}
}

content += "<h3>Uusia usein kysyttyjä kysymyksiä:<br>Frequently asked questions</h3>"

for (ticket of ticketList) {
Expand All @@ -409,6 +408,9 @@ module.exports = {
}
return { contentCount: contentCount, rowCount: rowCount, message: message };
})
.catch(() => {
return oldContent;
})
},

createTeacherAggregateForCourse: function(courseId, profileId, oldContent) {
Expand All @@ -420,14 +422,17 @@ module.exports = {
let rowCount = 0;
let content = '';

return sql.courses.getCourseInfo(courseId)
return sql.courses.isCourseActive(courseId)
.then((isActive) => {
return sql.courses.getCourseInfo(courseId);
})
.then((courseData) => {
content = content + title.replace('[Kurssi]', courseData.nimi);
return sql.tickets.getAllTickets(courseId);
})
.then((ticketList) => {
ticketList = ticketList.filter((value, index, array) => {
return value.tila == TicketState.sent || value.tila == TicketState.read;
return (value.tila == TicketState.sent || value.tila == TicketState.read);
})
if (ticketList.length > 0) {
content += ingress1;
Expand Down Expand Up @@ -461,8 +466,11 @@ module.exports = {
}
return { contentCount: contentCount, rowCount: rowCount,
message: message };
})
.catch(() => {
console.log('Opettajan sähköpostin luonnissa virhe ' + profileId + ' ' + courseId);
return oldContent;
});

}

}
19 changes: 18 additions & 1 deletion public/javascripts/sqlcourses.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { countReset } = require('console');
const { countReset, error } = require('console');
const crypto = require('crypto');
const { Pool, Client } = require('pg');

Expand All @@ -25,6 +25,23 @@ module.exports = {
return connection.queryOne(query, [courseId]);
},

isCourseActive: function(courseId) {
const query = 'SELECT kurssi \
FROM core.tiketti t INNER JOIN core.kommentti k \
ON t.id = k.tiketti \
WHERE t.kurssi = $1 AND k.aikaleima >= NOW() - INTERVAL \'14 days\'';
return connection.queryAll(query, [courseId])
.then((courseIdList) => {
if (courseIdList.length > 0) {
return Promise.resolve(true);
} else {
return Promise.reject();
}
});

},


getLtiCourseInfo: function(ltiClientId, ltiCourseId) {
const query = 'SELECT k.id, k.nimi \
FROM core.kurssi k INNER JOIN core.lti_kurssi lk\
Expand Down
4 changes: 2 additions & 2 deletions public/javascripts/sqltickets.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ module.exports = {
return connection.queryAll(query, [courseId, profileBlackList]);
},

getAllCommentsFromCourseSinceYesterday: function(courseId, profileBlackList) {
getAllCommentsFromCourseSinceYesterdayWithFaqs: function(courseId, profileBlackList) {
const query = 'SELECT * \
FROM core.kommentti k \
INNER JOIN core.tiketti t \
ON k.tiketti = t.id \
WHERE t.kurssi=$1 AND k.aikaleima>= NOW() - INTERVAL \'24 hours\' AND NOT k.lahettaja=ANY($2) AND t.ukk=false';
WHERE t.kurssi=$1 AND k.aikaleima>= NOW() - INTERVAL \'24 hours\' AND NOT k.lahettaja=ANY($2)';
return connection.queryAll(query, [courseId, profileBlackList]);
},

Expand Down
3 changes: 3 additions & 0 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ router.post('/luotili/', function(req, res, next) {
});
});

/*
router.post('/testi-cron/', function(req, res, next) {
//timedJobs.archiveOldTickets();
//timedJobs.deletePendingLtiLogins();
Expand All @@ -121,6 +122,7 @@ router.post('/testi-cron/', function(req, res, next) {
res.send({ success: true });
})
.catch((error) => {
console.log('ERROR ' + error);
errorFactory.createError(res, error);
})
})
Expand Down Expand Up @@ -181,6 +183,7 @@ router.get('/hash/:password', function(req, res) {
res.send(array);
});
*/


router.get('/minun/', function(req, res, next) {
Expand Down
1 change: 0 additions & 1 deletion routes/lti.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ router.post('/gdpr-lupa-ok/', function(req, res, next) {
res.send({ success: true, kurssi: data.courseId });
})
.catch((error) => {
console.log('error: ' + error);
errorFactory.createError(req, res, error);
});
});
Expand Down
Loading

0 comments on commit c3574d1

Please sign in to comment.