Skip to content

Commit 9ba6b54

Browse files
committed
Merged conflict files
2 parents 5c25f90 + 8845578 commit 9ba6b54

File tree

13 files changed

+38
-25
lines changed

13 files changed

+38
-25
lines changed

WebApi/Controllers/LogController.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
using WebApi.ViewModels;
1313
using WebApi.Helpers;
1414
using WebApi.Services;
15+
using Microsoft.AspNetCore.SignalR;
16+
using Hubs.BroadcastHub;
1517

1618
namespace WebApi.Controllers
1719
{
@@ -22,10 +24,12 @@ public class LogController : ControllerBase
2224
{
2325
private JsonSerializerSettings settings = new JsonSerializerSettings { Formatting = Formatting.Indented, ReferenceLoopHandling = ReferenceLoopHandling.Ignore };
2426
private readonly ILogService _service;
27+
private readonly IHubContext<BroadcastHub> _hubContext;
2528

26-
public LogController(ILogService service)
29+
public LogController(ILogService service, IHubContext<BroadcastHub> hubContext)
2730
{
2831
_service = service;
32+
_hubContext = hubContext;
2933
}
3034

3135
// GET api/log
@@ -48,6 +52,7 @@ public async Task<IActionResult> Log([FromBody] LogInOutViewModel model)
4852
}
4953

5054
var res = await _service.Log(user);
55+
await _hubContext.Clients.All.SendAsync("employee-logged"); // broadcast to web client
5156
return new OkObjectResult(JsonConvert.SerializeObject(res, settings));
5257
}
5358

WebApi/Hubs/BroadcastHub.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ namespace Hubs.BroadcastHub
55
{
66
public class BroadcastHub : Hub
77
{
8-
public async Task SendMessage(string message)
8+
public async Task SendMessage()
99
{
10-
await Clients.All.SendAsync("send", message);
10+
await Clients.All.SendAsync("employee-logged");
1111
}
1212
}
1313
}

WebClient/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width,initial-scale=1.0">
66
<title>BDF Attendance System</title>
7-
<link href='https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons' rel="stylesheet">
87
</head>
98
<body>
109
<div id="app"></div>

WebClient/package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WebClient/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"@aspnet/signalr": "^1.0.2",
1717
"axios": "^0.18.0",
1818
"lodash": "^4.17.10",
19+
"material-design-icons-iconfont": "^3.0.3",
1920
"moment": "^2.22.2",
2021
"nprogress": "^0.2.0",
2122
"tslib": "^1.9.3",

WebClient/src/components/log-employee-form.vue

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
</template>
2323

2424
<script>
25-
import { LOG_EMPLOYEE } from '@/store/actions-type'
2625
import { mapGetters } from 'vuex'
2726
import * as signalR from "@aspnet/signalr";
28-
27+
import { LOG_EMPLOYEE } from '@/store/actions-type'
28+
import { EventBus } from '@/event-bus.js'
2929
3030
export default {
3131
data () {
@@ -63,16 +63,8 @@ export default {
6363
}
6464
},
6565
66-
mounted () {
67-
const connection = new signalR.HubConnectionBuilder()
68-
.withUrl("http://localhost:5000/broadcast")
69-
.build();
70-
71-
connection.on("send", (data) => {
72-
console.log(data)
73-
})
74-
75-
connection.start().catch(err => document.write(err));
66+
created () {
67+
EventBus.$emit('toggle-drawer')
7668
}
7769
}
7870
</script>

WebClient/src/components/log-list.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import { mapGetters } from "vuex";
3939
import { FETCH_LOGS } from '@/store/actions-type'
4040
import { EventBus } from '@/event-bus.js'
41+
import BroadcastConnection from '@/services/broadcast-service'
4142
import moment from 'moment'
4243
4344
export default {
@@ -148,6 +149,10 @@ export default {
148149
async mounted () {
149150
await this.initialize()
150151
this.initSettings()
152+
153+
BroadcastConnection.on("employee-logged", () => {
154+
this.initialize()
155+
})
151156
}
152157
}
153158
</script>

WebClient/src/components/nav-bar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ import { EventBus } from '@/event-bus.js'
9090
export default {
9191
data() {
9292
return {
93-
drawer: false,
93+
drawer: true,
9494
items: [
9595
{ icon: "home", title: "Home", to: "home", visible: true },
9696
{ icon: "supervisor_account", title: "Login", to: "login", visible: !this.isAuthenticated }

WebClient/src/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const BASE_URL = "http://localhost:5000/api/"
1+
export const BASE_URL = "http://localhost:5000/"

WebClient/src/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { sync } from 'vuex-router-sync'
99
import store from '@/store'
1010
import ApiService from '@/services/api-service'
1111
import 'vuetify/dist/vuetify.min.css'
12+
import 'material-design-icons-iconfont/dist/material-design-icons.css'
1213

1314
Vue.config.productionTip = false
1415

0 commit comments

Comments
 (0)