-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dexw 2439 shutdown service #1798
base: dev
Are you sure you want to change the base?
Changes from 8 commits
ae7851a
a180f16
760172b
f0015d0
59a7077
7329027
702ed70
d184a10
2c522c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
/** | ||
* @param {Base} Base | ||
* @param {IPollCreate} createPoll | ||
* @param {ConfigService} configService | ||
* @param {ModalManager} modalManager | ||
* @return {ShutdownService} | ||
*/ | ||
const factory = function (Base, createPoll, configService, modalManager) { | ||
|
||
class ShutdownService extends Base { | ||
|
||
/** | ||
* @private | ||
*/ | ||
_timeOutTimerId; | ||
|
||
/** | ||
* @public | ||
*/ | ||
run() { | ||
this._handleTimers(this._getTimers()); | ||
window.clearTimeout(this._timeOutTimerId); | ||
this._timeOutTimerId = setTimeout(() => this.run(), 1000); | ||
} | ||
|
||
/** | ||
* @return {*} | ||
* @private | ||
*/ | ||
_getTimers() { | ||
return configService.get('SHUTDOWN_NOTIFICATION_TIMERS') || []; | ||
} | ||
|
||
/** | ||
* @param {[{ start: string, end: ?string, action: string }]} timers | ||
* @private | ||
*/ | ||
_handleTimers(timers) { | ||
const now = Date.now(); | ||
|
||
timers.forEach(timer => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. А что будет если configService еще не прогрузил конфиг из сети? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Такого не может быть |
||
const start = new Date(timer.start).getTime(); | ||
const end = timer.end ? new Date(timer.end).getTime() : Date.now(); | ||
|
||
if (now >= start && now <= end) { | ||
if (!sessionStorage.getItem(timer.action)) { | ||
sessionStorage.setItem(timer.action, 'true'); | ||
modalManager[timer.action](); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
} | ||
|
||
return new ShutdownService(); | ||
}; | ||
|
||
factory.$inject = ['Base', 'createPoll', 'configService', 'modalManager']; | ||
|
||
angular.module('app').factory('shutdownService', factory); | ||
})(); | ||
|
||
/** | ||
* @name ShutdownService | ||
*/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -755,6 +755,39 @@ | |
return this._getModal(tsUtils.merge({}, DEFAULT_OPTIONS, options, { contentUrl, controller })); | ||
} | ||
|
||
showShutdownFirstModal() { | ||
localStorage.setItem('shutdownFirstShown', true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. А зачем локал сторадж? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Это Виктор исправит в своей ветке |
||
return this._getModal({ | ||
id: 'shutdownFirstModal', | ||
templateUrl: 'modules/utils/modals/shutdownFirst/shutdownFirst.html', | ||
controller: 'ShutdownFirstCtrl', | ||
clickOutsideToClose: false, | ||
escapeToClose: false | ||
}); | ||
} | ||
|
||
showShutdownSecondModal() { | ||
localStorage.setItem('shutdownSecondShown', true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Аналогично |
||
return this._getModal({ | ||
id: 'shutdownSecondModal', | ||
templateUrl: 'modules/utils/modals/shutdownSecond/shutdownSecond.html', | ||
controller: 'ShutdownSecondCtrl', | ||
clickOutsideToClose: false, | ||
escapeToClose: false | ||
}); | ||
} | ||
|
||
showShutdownLastModal() { | ||
return this._getModal({ | ||
id: 'shutdownLastModal', | ||
templateUrl: 'modules/utils/modals/shutdownLast/shutdownLast.html', | ||
controller: 'ShutdownLastCtrl', | ||
clickOutsideToClose: false, | ||
escapeToClose: false | ||
}); | ||
} | ||
|
||
|
||
/** | ||
* @param {IModalOptions} options | ||
* @return {$q.resolve} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<md-dialog w-i18n-ns="app.utils" aria-label="modal"> | ||
<md-dialog-content> | ||
<w-button class="submit long big" on-click="$ctrl.confirm()"> | ||
<span>modal day before</span> | ||
<!-- <span w-i18n="modal.termsAccept.body.ok"></span> --> | ||
</w-button> | ||
</md-dialog-content> | ||
</md-dialog> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
const controller = function (Base, $mdDialog) { | ||
|
||
class ShutdownFirstCtrl extends Base { | ||
|
||
confirm() { | ||
$mdDialog.hide(); | ||
} | ||
|
||
} | ||
|
||
return new ShutdownFirstCtrl(); | ||
}; | ||
|
||
controller.$inject = ['Base', '$mdDialog']; | ||
|
||
angular.module('app.utils').controller('ShutdownFirstCtrl', controller); | ||
})(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<md-dialog w-i18n-ns="app.utils" aria-label="modal"> | ||
<md-dialog-content> | ||
<w-button class="submit long big" on-click="$ctrl.confirm()"> | ||
<span>modal hour x</span> | ||
<!-- <span w-i18n="modal.termsAccept.body.ok"></span> --> | ||
</w-button> | ||
</md-dialog-content> | ||
</md-dialog> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
const controller = function (Base, $mdDialog) { | ||
|
||
class ShutdownLastCtrl extends Base { | ||
|
||
confirm() { | ||
window.history.go(0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. location.reload(); |
||
$mdDialog.hide(); | ||
} | ||
|
||
} | ||
|
||
return new ShutdownLastCtrl(); | ||
}; | ||
|
||
controller.$inject = ['Base', '$mdDialog']; | ||
|
||
angular.module('app.utils').controller('ShutdownLastCtrl', controller); | ||
})(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<md-dialog w-i18n-ns="app.utils" aria-label="modal"> | ||
<md-dialog-content> | ||
<w-button class="submit long big" on-click="$ctrl.confirm()"> | ||
<span>modal hour before</span> | ||
<!-- <span w-i18n="modal.termsAccept.body.ok"></span> --> | ||
</w-button> | ||
</md-dialog-content> | ||
</md-dialog> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
const controller = function (Base, $mdDialog) { | ||
|
||
class ShutdownSecondCtrl extends Base { | ||
|
||
confirm() { | ||
$mdDialog.hide(); | ||
} | ||
|
||
} | ||
|
||
return new ShutdownSecondCtrl(); | ||
}; | ||
|
||
controller.$inject = ['Base', '$mdDialog']; | ||
|
||
angular.module('app.utils').controller('ShutdownSecondCtrl', controller); | ||
})(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
нам точно нужен метод? можно же сразу shutdownService.run();