-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
admin create notification page and route #160
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,4 +212,42 @@ public void testNotificationFlow() throws Exception { | |
|
||
assertEquals(0, notifDtos.size()); | ||
} | ||
|
||
@Test | ||
public void testManyNotificationsFlow() throws Exception { | ||
StudentDto studentDto1 = createTestStudent("[email protected]", "123123123"); | ||
StudentDto studentDto2 = createTestStudent("[email protected]", "321321321"); | ||
AdminDto adminDto = createTestAdmin(); | ||
|
||
String title = "Hello"; | ||
String body = "Please attend meeting."; | ||
|
||
// 1. create notification | ||
|
||
MvcResult mvcResult = | ||
mvc.perform( | ||
post("/notifications/many?admin=" | ||
+ adminDto.getId() | ||
+ "&title=" | ||
+ title | ||
+ "&body=" | ||
+ body | ||
+ "&studentIds=" | ||
+ studentDto1.getId() | ||
+ "," | ||
+ studentDto2.getId()) | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.characterEncoding("utf-8")) | ||
.andExpect(status().isOk()) | ||
.andReturn(); | ||
|
||
// get object from response | ||
List<NotificationDto> notifDtos = | ||
Arrays.asList( | ||
objectMapper.readValue( | ||
mvcResult.getResponse().getContentAsString(), | ||
NotificationDto[].class)); | ||
|
||
assertEquals(2, notifDtos.size()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
<template> | ||
<BasePage title="Send Notification"> | ||
<q-card> | ||
<div class="q-pa-md"> | ||
<q-table | ||
title="Select Students" | ||
:data="tableStudents" | ||
:columns="columns" | ||
row-key="email" | ||
selection="multiple" | ||
:selected.sync="toSendTo" | ||
/> | ||
<q-input | ||
outlined | ||
v-model="title" | ||
label="Title" | ||
class="notifPageComponents" | ||
/> | ||
<q-input | ||
v-model="body" | ||
label="Body" | ||
outlined | ||
type="textarea" | ||
class="notifPageComponents" | ||
/> | ||
<q-btn | ||
v-if="!sending" | ||
color="primary" | ||
@click="sendNotification()" | ||
label="Send Notification" | ||
class="notifPageComponents" | ||
/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a |
||
<!-- Show spinner while waiting --> | ||
<q-spinner | ||
v-else | ||
color="primary" | ||
size="2.5em" | ||
class="notifPageComponents" | ||
/> | ||
</div> | ||
</q-card> | ||
</BasePage> | ||
</template> | ||
|
||
<script> | ||
import BasePage from "../BasePage.vue"; | ||
|
||
export default { | ||
components: { | ||
BasePage | ||
}, | ||
props: { | ||
selected: { | ||
type: Array, | ||
required: false | ||
} | ||
}, | ||
name: "HomeMainInfo", | ||
|
||
data: () => ({ | ||
sending: false, | ||
tableStudents: [], | ||
toSendTo: [], | ||
body: "", | ||
title: "", | ||
selectedString: "Please select a student", | ||
columns: [ | ||
{ | ||
name: "studentLastName", | ||
required: true, | ||
label: "Student Last Name", | ||
align: "left", | ||
field: "lastName", | ||
sortable: true, | ||
classes: "my-class", | ||
style: "width: 500px" | ||
}, | ||
{ | ||
name: "studentFirstName", | ||
required: true, | ||
label: "Student First Name", | ||
align: "left", | ||
field: "firstName", | ||
sortable: true, | ||
classes: "my-class", | ||
style: "width: 500px" | ||
}, | ||
{ | ||
name: "studentID", | ||
required: true, | ||
label: "Student ID", | ||
align: "left", | ||
field: "id", | ||
sortable: true, | ||
classes: "my-class", | ||
style: "width: 500px" | ||
}, | ||
{ | ||
name: "email", | ||
required: true, | ||
label: "Email", | ||
align: "left", | ||
field: "email", | ||
sortable: true, | ||
classes: "my-class", | ||
style: "width: 500px" | ||
} | ||
] | ||
}), | ||
created: function() { | ||
this.$axios | ||
.get("/students", { | ||
headers: { | ||
Authorization: this.$store.state.token | ||
} | ||
}) | ||
.then(resp => { | ||
this.tableStudents = resp.data; | ||
}); | ||
this.toSendTo = this.selected; | ||
}, | ||
methods: { | ||
goToStudentCoop() { | ||
this.$router.push("/admin/student-coops"); | ||
}, | ||
sendNotification() { | ||
var adminId = this.$store.state.currentUser.id; | ||
var stuIds = []; | ||
for (var i = 0; i < this.toSendTo.length; i++) { | ||
stuIds.push(this.toSendTo[i].id); | ||
} | ||
this.sending = true; | ||
// create the notification | ||
this.$axios | ||
.post( | ||
"/notifications/many?admin=" + | ||
adminId + | ||
"&title=" + | ||
this.title + | ||
"&body=" + | ||
this.body + | ||
"&studentIds=" + | ||
stuIds | ||
) | ||
.then(_resp => { | ||
this.sending = false; | ||
this.body = ""; | ||
this.title = ""; | ||
this.toSendTo = []; | ||
this.$q.notify({ | ||
color: "green-4", | ||
position: "top", | ||
textColor: "white", | ||
icon: "cloud_done", | ||
message: "Notification(s) sent successfully!" | ||
}); | ||
}) | ||
.catch(_err => { | ||
this.sending = false; | ||
this.$q.notify({ | ||
color: "red-4", | ||
position: "top", | ||
textColor: "white", | ||
icon: "error", | ||
message: "Something went wrong, please try again" | ||
}); | ||
}); | ||
} | ||
} | ||
}; | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
h6 { | ||
margin: 10px; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this literally never ends up working the way i want it to so i really dont want to waste more time trying to get this shit to align properly so i dont rlly want to go down this road again There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok no worries it's not a big deal |
||
} | ||
#card { | ||
width: 100%; | ||
margin-top: 25px; | ||
margin-right: 10px; | ||
} | ||
.notifPageComponents { | ||
margin-top: 3%; | ||
} | ||
</style> |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
:disabled="sending"
here to disable the button while it's sendingThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it doesnt show up when its sending tho