Skip to content

Commit cac8955

Browse files
Gourav DwivediGourav Dwivedi
authored andcommitted
added mute notification button and ui bug fix
1 parent ebb6a9e commit cac8955

File tree

5 files changed

+45
-43
lines changed

5 files changed

+45
-43
lines changed

src/Index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ <h1>SignalR Web Client</h1>
4444
<li class="mdl-menu__item">
4545
<a target="_blank" href="https://github.com/gourav-d/SignalR-Web-Client">Github</a>
4646
</li>
47+
<li class="mdl-menu__item">
48+
<span class="">Mute</span>
49+
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="chk-mute-notification">
50+
<input type="checkbox" id="chk-mute-notification" class="mdl-switch__input">
51+
</label>
52+
</li>
4753
</ul>
4854

4955
<!-- Add spacer, to align navigation to the right -->

src/js/components/logic/lib/app.signalr.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ class SignalRApp {
107107
var jsonObj = JSON.parse(e);
108108

109109
if(jsonObj !== null && jsonObj.hasOwnProperty('target')) {
110-
debugger;
111110
AppEvents.emit('ReceivedData', { "ClientMethod": jsonObj.target, "Data": jsonObj.arguments });
112111
}
113112
});

src/js/components/srform.component.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@ class SrFormComponent extends HTMLElement {
4040
<span class="error" aria-live="polite"><span>
4141
</div>
4242
43-
<div class="col-sm-1 checkbox-container float-left" id="logger-chk-container">
44-
<label class="col-sm-1 col-form-label mdl-switch mdl-js-switch mdl-js-ripple-effect" for="chk-loggerView">
43+
<div class="form-group row col-sm-1 checkbox-container float-left" id="logger-chk-container">
44+
<label class="col-sm-2 col-form-label mdl-switch mdl-js-switch mdl-js-ripple-effect" for="chk-loggerView">
4545
<input type="checkbox" id="chk-loggerView" class="col-sm-1 col-form-label mdl-switch__input" value="Logger View">
46-
<span class="mdl-switch__label"></span>
46+
<!--<span class="mdl-switch__label">Logging</span> -->
4747
</label>
48-
<div class="mdl-tooltip" for="logger-chk-container">Logging</div>
48+
<!-- If we add tool tip, then extra border will appear on click
49+
<div class="mdl-tooltip" data-mdl-for="logger-chk-container">Logging</div> -->
4950
</div>
5051
</div>
5152

src/js/components/srform.js

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import deleteImg from '../../images/delete.png';
2-
import soundfile from '../../assets/Notification.wav';
2+
import notificationSound from '../../assets/Notification.wav';
33
import { AppLogic } from './logic/app.logic';
44
import * as AppCommon from './logic/lib/app.common';
55
import * as Test from '../components/dialogbox/custompopup';
@@ -55,6 +55,23 @@ export function Init() {
5555
}
5656
});
5757

58+
const muteNotifcationElement = document.getElementById('chk-mute-notification');
59+
const notifcationMute = window.localStorage.getItem('muteNotification');
60+
61+
if((!!notifcationMute) === false) {
62+
window.localStorage.setItem('muteNotification', 1);
63+
}
64+
65+
muteNotifcationElement.checked = parseInt(notifcationMute) === 1;
66+
67+
muteNotifcationElement.addEventListener('change', (event) => {
68+
if (event.target.checked) {
69+
window.localStorage.setItem('muteNotification', 0);
70+
} else {
71+
window.localStorage.setItem('muteNotification', 1);
72+
}
73+
});
74+
5875
document.getElementById('btn-clearlogs')
5976
.addEventListener('click', (event) => {
6077
document.getElementById("app-logs").innerHTML = "";
@@ -324,7 +341,6 @@ function TextboxValidation(element, errorMessage) {
324341
export function OnConnect() {
325342

326343
//Add validation
327-
debugger;
328344
if(!UrlValidation()) {
329345
return;
330346
}
@@ -357,9 +373,20 @@ export function OnConnected() {
357373
}
358374

359375
export function HandleResponse(data) {
360-
document.querySelector("#inputResponseData").value += JSON.stringify(data) + '\n';
361-
let sound = new Audio(soundfile);
362-
sound.play();
376+
document.querySelector("#inputResponseData").value += JSON.stringify(data) + '\n';
377+
var isNotificationMute = window.localStorage.getItem('muteNotification');
378+
379+
// if((!!isNotificationMute) === false) {
380+
// window.localStorage.setItem('muteNotification', 1);
381+
// isNotificationMute = 1
382+
// }
383+
384+
debugger;
385+
if(parseInt(isNotificationMute) === 1) {
386+
let sound = new Audio(notificationSound);
387+
sound.play();
388+
}
389+
363390
}
364391

365392
export function SetConnectionProtocol() {
@@ -414,8 +441,7 @@ export function Disconnect() {
414441
export function SendPayload() {
415442

416443
const methodNameElement = document.getElementById("inputServerMethod");
417-
var methodName = methodNameElement.value;
418-
debugger;
444+
var methodName = methodNameElement.value;
419445
if(!TextboxValidation(methodNameElement, "Please enter the Hub method name")) {
420446
return false;
421447
}

src/js/main.js

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,4 @@ import 'bootstrap/dist/js/bootstrap.js'
77
import '../css/main.css';
88
// import './components/custom.alertbox';
99
import './components/srform.component';
10-
import './components/app.component';
11-
12-
13-
// class HelloComponent extends HTMLElement {
14-
// static get observedAttributes() {
15-
// return ['data-name'];
16-
// }
17-
18-
// // custom methods
19-
// render() {
20-
// this.innerHTML = `Hello ${this.name}`;
21-
// }
22-
23-
// get name() {
24-
// return this.getAttribute('data-name');
25-
// }
26-
27-
// // lifecycle hooks
28-
// connectedCallback() {
29-
// this.render();
30-
// }
31-
32-
// attributeChangedCallback(attrName, oldVal, newVal) {
33-
// this.render();
34-
// }
35-
// }
36-
37-
// if(!window.customElements.get('hello-component')){
38-
// // add into the 'real' dom as a valid tag
39-
// window.customElements.define('hello-component', HelloComponent);
40-
// }
10+
import './components/app.component';

0 commit comments

Comments
 (0)