Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion mocks/waves-client-config/master/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
]
}
6 changes: 5 additions & 1 deletion src/modules/app/initialize/AppRun.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
* @param {ModalRouter} ModalRouter
* @param {ConfigService} configService
* @param {INotification} userNotification
* @param {ShutdownService} shutdownService
* @return {AppRun}
*/
// eslint-disable-next-line max-params
Expand All @@ -97,7 +98,8 @@
multiAccount,
ModalRouter,
configService,
userNotification
userNotification,
shutdownService
) {

const phone = WavesApp.device.phone();
Expand Down Expand Up @@ -158,6 +160,7 @@
this._initializeLogin();
this._initializeOutLinks();
this._openMigrationModal();
shutdownService.run();

if (WavesApp.isDesktop()) {
window.listenMainProcessEvent((type, url) => {
Expand Down Expand Up @@ -809,6 +812,7 @@
'ModalRouter',
'configService',
'userNotification',
'shutdownService',
'whatsNew'
];

Expand Down
69 changes: 69 additions & 0 deletions src/modules/app/services/ShutdownService.js
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 => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А что будет если configService еще не прогрузил конфиг из сети?

Copy link
Contributor

Choose a reason for hiding this comment

The 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
*/
33 changes: 33 additions & 0 deletions src/modules/utils/modals/ModalManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,39 @@
return this._getModal(tsUtils.merge({}, DEFAULT_OPTIONS, options, { contentUrl, controller }));
}

showShutdownFirstModal() {
localStorage.setItem('shutdownFirstShown', true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А зачем локал сторадж?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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);
Copy link
Contributor

Choose a reason for hiding this comment

The 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}
Expand Down
8 changes: 8 additions & 0 deletions src/modules/utils/modals/shutdownFirst/shutdownFirst.html
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>
20 changes: 20 additions & 0 deletions src/modules/utils/modals/shutdownFirst/shutdownFirst.js
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);
})();
Empty file.
8 changes: 8 additions & 0 deletions src/modules/utils/modals/shutdownLast/shutdownLast.html
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>
21 changes: 21 additions & 0 deletions src/modules/utils/modals/shutdownLast/shutdownLast.js
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what?

Copy link
Contributor

Choose a reason for hiding this comment

The 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);
})();
Empty file.
8 changes: 8 additions & 0 deletions src/modules/utils/modals/shutdownSecond/shutdownSecond.html
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>
20 changes: 20 additions & 0 deletions src/modules/utils/modals/shutdownSecond/shutdownSecond.js
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);
})();
Empty file.