Skip to content

Commit f761c3c

Browse files
committed
Merge changes from log-employee-form
2 parents ca25bb9 + c28cb51 commit f761c3c

File tree

8 files changed

+61
-0
lines changed

8 files changed

+61
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/dist/

WebApi/Hubs/BroadcastHub.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Threading.Tasks;
2+
using Microsoft.AspNetCore.SignalR;
3+
4+
namespace Hubs.BroadcastHub
5+
{
6+
public class BroadcastHub : Hub
7+
{
8+
public async Task SendMessage(string message)
9+
{
10+
await Clients.All.SendAsync("send", message);
11+
}
12+
}
13+
}

WebApi/Startup.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
using WebApi.Services;
3030
using WebApi.Repositories;
3131
using WebApi.Helpers;
32+
using Hubs.BroadcastHub;
3233

3334
namespace WebApi
3435
{
@@ -127,6 +128,7 @@ public void ConfigureServices(IServiceCollection services)
127128

128129
services.AddAntiforgery(options => options.HeaderName = "X-XSRF-TOKEN");
129130
services.AddCors();
131+
services.AddSignalR();
130132

131133
services.AddSwaggerGen(c =>
132134
{
@@ -203,6 +205,11 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, IService
203205
app.UseDefaultFiles();
204206
app.UseStaticFiles();
205207

208+
app.UseSignalR(routes =>
209+
{
210+
routes.MapHub<BroadcastHub>("/broadcast");
211+
});
212+
206213
CreateUsersAndRoles(services).Wait();
207214
AttendanceConfiguration(services).Wait();
208215
}

WebApi/WebApi.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<ItemGroup>
1313
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="3.2.0" />
1414
<PackageReference Include="Microsoft.AspNetCore.All" />
15+
<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.0.2" />
1516
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.0" />
1617
<PackageReference Include="Swashbuckle.AspNetCore" Version="2.5.0" />
1718
</ItemGroup>

WebClient/package-lock.json

Lines changed: 10 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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
"build": "node build/build.js"
1414
},
1515
"dependencies": {
16+
"@aspnet/signalr": "^1.0.2",
1617
"axios": "^0.18.0",
1718
"lodash": "^4.17.10",
1819
"moment": "^2.22.2",
1920
"nprogress": "^0.2.0",
21+
"tslib": "^1.9.3",
2022
"vue": "^2.5.2",
2123
"vue-notification": "^1.3.10",
2224
"vue-router": "^3.0.1",

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import { mapGetters } from 'vuex'
2626
import { LOG_EMPLOYEE } from '@/store/actions-type'
2727
import { EventBus } from '@/event-bus.js'
28+
import * as signalR from "@aspnet/signalr";
2829
2930
export default {
3031
data () {
@@ -64,6 +65,18 @@ export default {
6465
6566
created () {
6667
EventBus.$emit('toggle-drawer')
68+
},
69+
70+
mounted () {
71+
const connection = new signalR.HubConnectionBuilder()
72+
.withUrl("http://localhost:5000/broadcast")
73+
.build();
74+
75+
connection.on("send", (data) => {
76+
console.log(data)
77+
})
78+
79+
connection.start().catch(err => document.write(err));
6780
}
6881
}
6982
</script>

scripts/publish.bat

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@ECHO OFF
2+
3+
cd ..
4+
cd WebApi
5+
CMD /C dotnet publish --output ../dist
6+
7+
cd ..
8+
cd WebClient
9+
CMD /C npm run build
10+
xcopy /s /y "dist" "..\dist\wwwroot"
11+
12+
cls
13+
echo Web Application has been succesfully published in /dist folder...
14+
@pause

0 commit comments

Comments
 (0)