Skip to content

Commit f628abd

Browse files
author
Michał Czyż
committed
after pause display time as separate message and reset timer
1 parent ce33574 commit f628abd

File tree

10 files changed

+58
-18
lines changed

10 files changed

+58
-18
lines changed

app/components/msg-show/component.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ const {
77
export default Ember.Component.extend({
88
lastMessage: service(),
99
show: alias('lastMessage.present'),
10-
messages: computed('lastMessage.msg.{numberPresent,numberListening,comment}', function () {
11-
let {numberPresent, numberListening, comment} = this.get('lastMessage.msg');
10+
messages: computed('lastMessage.msg.{numberPresent,numberListening,lastDuration,comment}', function () {
11+
let {numberPresent, numberListening, lastDuration, comment} = this.get('lastMessage.msg');
12+
console.log(lastDuration);
1213
return [
1314
{text: numberPresent, suffix: 'obecnych', icon: 'person', component: 'msg-show/people'},
1415
{text: numberListening, suffix: 'przez łącza tel.', icon: 'phone', component: 'msg-show/people'},
16+
{text: lastDuration, icon: 'timer', component: 'msg-show/time'},
1517
{text: comment, component: 'msg-show/pre'},
1618
];
1719
})
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{{#paper-item class="md-3-line msg-show-time"}}
2+
{{paper-icon item.icon classNames="big"}}
3+
<div class="md-list-item-text">
4+
<strong>
5+
{{item.text}}
6+
</strong>
7+
</div>
8+
{{paper-divider inset=true}}
9+
{{/paper-item}}

app/controllers/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ const {
88
export default Ember.Controller.extend({
99
lastMessage: service(),
1010
showMessage: alias('lastMessage.present')
11+
1112
});

app/services/last-message.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,28 @@ export default Ember.Service.extend({
2323
},
2424
_setMsg(info) {
2525
this._scheduleClear();
26+
console.log(this.get('msg'));
2627
for (let property in info) this.get('msg').set(property, info[property]);
28+
console.log(this.get('msg'));
2729
},
2830

29-
present: computed('msg.{numberPresent,comment}', function() {
30-
return (this.get('msg.numberPresent') != null) || (this.get('msg.comment') != null)
31+
present: computed('msg.{numberPresent,comment,lastDuration}', function() {
32+
return (this.get('msg.numberPresent') != null) || (this.get('msg.comment') != null) || (this.get('msg.lastDuration') != null);
3133
}),
3234

3335
clear() {
3436
this.set('msg', new Object({
3537
numberPresent: null,
3638
numberListening: null,
39+
lastDuration: null,
3740
comment: null,
3841
}));
3942
},
4043
_scheduleClear() {
4144
if (this.get('nextClear')) {
4245
cancel(this.get('nextClear'));
4346
}
44-
this.set('nextClear', later(this, this.clear, 30*1000));
47+
this.set('nextClear', later(this, this.clear, 60*1000));
4548
}
4649

4750
});

app/services/timer.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import Ember from 'ember';
2-
import { padStart } from 'lodash/string';
2+
import {padStart} from 'lodash/string';
33

44
const {
55
computed,
6-
computed: { notEmpty },
6+
computed: {notEmpty},
77
run: {cancel, later},
8-
inject: { service }
8+
inject: {service}
99
} = Ember;
1010

1111
export default Ember.Service.extend({
1212
ipcRenderer: service(),
13+
lastMessage: service(),
1314
minutes: 0,
1415
seconds: 0,
1516
firstTick: null,
@@ -21,11 +22,11 @@ export default Ember.Service.extend({
2122
return this._format(this.get('duration') / 60);
2223
}),
2324

24-
second: computed('duration', function() {
25+
second: computed('duration', function () {
2526
return this._format(this.get('duration') % 60);
2627
}),
2728

28-
duration: computed('lastTick', function() {
29+
duration: computed('lastTick', function () {
2930
let start = this.get('firstTick'),
3031
end = this.get('lastTick');
3132

@@ -47,8 +48,7 @@ export default Ember.Service.extend({
4748
},
4849

4950
pause() {
50-
cancel(this.get('nextTick'));
51-
this.set('nextTick', null);
51+
this._pause();
5252
this.get('ipcRenderer').setLastTick(this.get('lastTick'));
5353
},
5454

@@ -86,8 +86,15 @@ export default Ember.Service.extend({
8686
_pause() {
8787
cancel(this.get('nextTick'));
8888
this.set('nextTick', null);
89+
this._notifyLastTick({minute: this.get('minute'), second: this.get('second')});
90+
this.reset();
91+
8992
},
9093
_currentTime() {
91-
return new Date(Math.floor(new Date() / 1000)*1000)
94+
return new Date(Math.floor(new Date() / 1000) * 1000)
95+
},
96+
97+
_notifyLastTick(lastDuration) {
98+
this.get('lastMessage').setMsg({lastDuration: `${lastDuration.minute}:${lastDuration.second}`})
9299
}
93100
});

app/styles/invert.sass

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
.msg-show-people
55
md-icon.big
66
color: white
7+
.msg-show-time
8+
md-icon.big
9+
color: white

app/styles/msg.sass

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@
1010
width: 2.25em
1111
padding-right: .25em
1212

13+
.msg-show-time
14+
font-size: 10vh
15+
md-icon.big
16+
font-size: 16vh
17+
strong
18+
font-weight: 600
19+
font-size: 18vh
20+
text-align: right
21+
display: inline-block
22+
width: 3.25em
23+
padding-right: .25em
24+
1325
.msg-show-pre
1426
p
1527
text-align: center

app/templates/external-screen.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{title "Ekran"}}
22

3-
<div class="inverted">
3+
<div class="inverted" style="-webkit-app-region: drag">
44

55
<div class="flex no-select">
66
{{msg-show}}

electron.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,20 @@ app.on('window-all-closed', function onWindowAllClosed() {
4242

4343
app.on('ready', function onReady() {
4444
mainWindow = new BrowserWindow({
45-
title: 'Zegar - Panel',
45+
title: 'ZegarPanel',
4646
width: 1200,
4747
height: 800
4848
});
4949

5050
delete mainWindow.module;
5151

5252
sideWindow = new BrowserWindow({
53-
title: 'Zegar - Ekran',
53+
title: 'ZegarEkran',
5454
width: 1200,
5555
height: 800,
56+
x: 10,
57+
y: 10,
58+
closable: false,
5659
frame: false
5760
});
5861

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nat-app",
3-
"version": "0.0.0",
3+
"version": "0.2.0",
44
"description": "Small description for nat-app goes here",
55
"license": "MIT",
66
"author": "",
@@ -62,7 +62,7 @@
6262
"name": null,
6363
"platform": "win32",
6464
"arch": "x64",
65-
"version": null,
65+
"version": "0.2.0",
6666
"app-bundle-id": null,
6767
"app-category-type": null,
6868
"app-copyright": null,

0 commit comments

Comments
 (0)