Skip to content

Commit

Permalink
Merge pull request #92 from navikt/afterworkPause
Browse files Browse the repository at this point in the history
adds pausing to afterwork
  • Loading branch information
mamikals authored Feb 1, 2024
2 parents a2598a8 + 4e25e15 commit db8a58a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,17 @@
<aura:attribute name="maxTimer" type="integer" />
<aura:attribute name="percentageTimer" type="integer" default="100" />
<aura:attribute name="showTimer" type="boolean" />
<aura:attribute name="stopped" type="boolean" default="false" />

<aura:if isTrue="{!v.showTimer}">
<lightning:button
variant="destructive"
label="Trusselknapp"
title="Trusselknapp"
onclick="{! c.stopTimer }"
class="slds-var-m-bottom_small slds-size_12-of-12"
disabled="{!v.stopped}"
/>
<div class="slds-card slds-p-around_x-small">
<p class="slds-text-title_bold">Automatisk lukking</p>
<div class="slds-p-bottom_medium">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@
if (recordId === eventRecordId && component.get('v.betaAccess')) {
helper.startTimer(component, eventRecordId);
}
},
stopTimer: function (component) {
component.set('v.stopped', true);
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
component.set('v.showTimer', true);
component.set('v.maxTimer', component.get('v.timer'));
const intervalId = setInterval(() => {
if (component.get('v.stopped')) clearInterval(intervalId);
let tempTimer = component.get('v.timer') - 1;
component.set('v.timer', tempTimer);
component.set('v.percentageTimer', (tempTimer * 100) / component.get('v.maxTimer'));
if (tempTimer <= 0) {
console.log('done');
clearInterval(intervalId);
this.closeTab(component, event);
}
Expand Down

0 comments on commit db8a58a

Please sign in to comment.