diff --git a/mocks/waves-client-config/master/config.json b/mocks/waves-client-config/master/config.json
index a3e753fbda..87665af0da 100644
--- a/mocks/waves-client-config/master/config.json
+++ b/mocks/waves-client-config/master/config.json
@@ -80,5 +80,10 @@
"GATEWAYS_SOON": [
"5dJj4Hn9t2Ve3tRpNGirUHy4yBK6qdJRAJYV21yPPuGz"
],
- "DEXW_LOCKED": false
+ "DEXW_LOCKED": false,
+ "SHUTDOWN_NOTIFICATION_TIMERS": [
+ { "start": "2019-12-01T15:00:00+03:00", "end": "2019-12-01T15:01:00+03:00", "action": "showShutdownFirstModal" },
+ { "start": "2019-12-02T08:00:00+03:00", "end": "2019-12-02T08:01:00+03:00", "action": "showShutdownSecondModal" },
+ { "start": "2019-12-02T10:00:00+03:00", "action": "showShutdownLastModal" }
+ ]
}
diff --git a/src/modules/app/initialize/AppRun.js b/src/modules/app/initialize/AppRun.js
index 1f703a61c9..2f62dc0641 100644
--- a/src/modules/app/initialize/AppRun.js
+++ b/src/modules/app/initialize/AppRun.js
@@ -78,6 +78,7 @@
* @param {ModalRouter} ModalRouter
* @param {ConfigService} configService
* @param {INotification} userNotification
+ * @param {ShutdownService} shutdownService
* @return {AppRun}
*/
// eslint-disable-next-line max-params
@@ -97,7 +98,8 @@
multiAccount,
ModalRouter,
configService,
- userNotification
+ userNotification,
+ shutdownService
) {
const phone = WavesApp.device.phone();
@@ -158,6 +160,7 @@
this._initializeLogin();
this._initializeOutLinks();
this._openMigrationModal();
+ shutdownService.run();
if (WavesApp.isDesktop()) {
window.listenMainProcessEvent((type, url) => {
@@ -809,6 +812,7 @@
'ModalRouter',
'configService',
'userNotification',
+ 'shutdownService',
'whatsNew'
];
diff --git a/src/modules/app/services/ShutdownService.js b/src/modules/app/services/ShutdownService.js
new file mode 100644
index 0000000000..f81b335446
--- /dev/null
+++ b/src/modules/app/services/ShutdownService.js
@@ -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 => {
+ 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
+ */
diff --git a/src/modules/utils/modals/ModalManager.js b/src/modules/utils/modals/ModalManager.js
index ed0afd2c52..3e7ac784c8 100644
--- a/src/modules/utils/modals/ModalManager.js
+++ b/src/modules/utils/modals/ModalManager.js
@@ -755,6 +755,39 @@
return this._getModal(tsUtils.merge({}, DEFAULT_OPTIONS, options, { contentUrl, controller }));
}
+ showShutdownFirstModal() {
+ localStorage.setItem('shutdownFirstShown', true);
+ return this._getModal({
+ id: 'shutdownFirstModal',
+ templateUrl: 'modules/utils/modals/shutdownFirst/shutdownFirst.html',
+ controller: 'ShutdownFirstCtrl',
+ clickOutsideToClose: false,
+ escapeToClose: false
+ });
+ }
+
+ showShutdownSecondModal() {
+ localStorage.setItem('shutdownSecondShown', true);
+ 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}
diff --git a/src/modules/utils/modals/shutdownFirst/shutdownFirst.html b/src/modules/utils/modals/shutdownFirst/shutdownFirst.html
new file mode 100644
index 0000000000..9030d3a40d
--- /dev/null
+++ b/src/modules/utils/modals/shutdownFirst/shutdownFirst.html
@@ -0,0 +1,8 @@
+
+
+
+ modal day before
+
+
+
+
diff --git a/src/modules/utils/modals/shutdownFirst/shutdownFirst.js b/src/modules/utils/modals/shutdownFirst/shutdownFirst.js
new file mode 100644
index 0000000000..a2daf15d1b
--- /dev/null
+++ b/src/modules/utils/modals/shutdownFirst/shutdownFirst.js
@@ -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);
+})();
diff --git a/src/modules/utils/modals/shutdownFirst/shutdownFirst.less b/src/modules/utils/modals/shutdownFirst/shutdownFirst.less
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/src/modules/utils/modals/shutdownLast/shutdownLast.html b/src/modules/utils/modals/shutdownLast/shutdownLast.html
new file mode 100644
index 0000000000..b1eacff07f
--- /dev/null
+++ b/src/modules/utils/modals/shutdownLast/shutdownLast.html
@@ -0,0 +1,8 @@
+
+
+
+ modal hour x
+
+
+
+
diff --git a/src/modules/utils/modals/shutdownLast/shutdownLast.js b/src/modules/utils/modals/shutdownLast/shutdownLast.js
new file mode 100644
index 0000000000..36568739e5
--- /dev/null
+++ b/src/modules/utils/modals/shutdownLast/shutdownLast.js
@@ -0,0 +1,21 @@
+(function () {
+ 'use strict';
+
+ const controller = function (Base, $mdDialog) {
+
+ class ShutdownLastCtrl extends Base {
+
+ confirm() {
+ window.history.go(0);
+ $mdDialog.hide();
+ }
+
+ }
+
+ return new ShutdownLastCtrl();
+ };
+
+ controller.$inject = ['Base', '$mdDialog'];
+
+ angular.module('app.utils').controller('ShutdownLastCtrl', controller);
+})();
diff --git a/src/modules/utils/modals/shutdownLast/shutdownLast.less b/src/modules/utils/modals/shutdownLast/shutdownLast.less
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/src/modules/utils/modals/shutdownSecond/shutdownSecond.html b/src/modules/utils/modals/shutdownSecond/shutdownSecond.html
new file mode 100644
index 0000000000..97bc738c0f
--- /dev/null
+++ b/src/modules/utils/modals/shutdownSecond/shutdownSecond.html
@@ -0,0 +1,8 @@
+
+
+
+ modal hour before
+
+
+
+
diff --git a/src/modules/utils/modals/shutdownSecond/shutdownSecond.js b/src/modules/utils/modals/shutdownSecond/shutdownSecond.js
new file mode 100644
index 0000000000..9a6b281eca
--- /dev/null
+++ b/src/modules/utils/modals/shutdownSecond/shutdownSecond.js
@@ -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);
+})();
diff --git a/src/modules/utils/modals/shutdownSecond/shutdownSecond.less b/src/modules/utils/modals/shutdownSecond/shutdownSecond.less
new file mode 100644
index 0000000000..e69de29bb2