feat(monitors): added auto-refresh feature to ticket monitors
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
9986d4eb03
commit
5ea014aeff
|
@ -1,4 +1,4 @@
|
||||||
<vn-horizontal>
|
<vn-horizontal ng-class="{'hidden': $ctrl.isTopPanelHidden}">
|
||||||
<vn-monitor-sales-clients class="vn-mb-sm"></vn-monitor-sales-clients>
|
<vn-monitor-sales-clients class="vn-mb-sm"></vn-monitor-sales-clients>
|
||||||
<vn-monitor-sales-orders></vn-monitor-sales-orders>
|
<vn-monitor-sales-orders></vn-monitor-sales-orders>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
|
|
@ -3,14 +3,25 @@ import Section from 'salix/components/section';
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
|
||||||
export default class Controller extends Section {
|
export default class Controller extends Section {
|
||||||
|
constructor($element, $) {
|
||||||
|
super($element, $);
|
||||||
|
|
||||||
|
const isTopPanelHidden = localStorage.getItem('ticketTopPanelHidden');
|
||||||
|
if (isTopPanelHidden === 'true')
|
||||||
|
this.isTopPanelHidden = true;
|
||||||
|
}
|
||||||
|
|
||||||
toggle() {
|
toggle() {
|
||||||
const monitor = this.element.querySelector('vn-horizontal');
|
const monitor = this.element.querySelector('vn-horizontal');
|
||||||
const isHidden = monitor.classList.contains('hidden');
|
const isHidden = monitor.classList.contains('hidden');
|
||||||
|
|
||||||
if (!isHidden)
|
if (!isHidden) {
|
||||||
monitor.classList.add('hidden');
|
monitor.classList.add('hidden');
|
||||||
else
|
localStorage.setItem('ticketTopPanelHidden', true);
|
||||||
|
} else {
|
||||||
monitor.classList.remove('hidden');
|
monitor.classList.remove('hidden');
|
||||||
|
localStorage.setItem('ticketTopPanelHidden', false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
import './index.js';
|
||||||
|
describe('Component vnMonitorIndex', () => {
|
||||||
|
let controller;
|
||||||
|
let $element;
|
||||||
|
|
||||||
|
beforeEach(ngModule('monitor'));
|
||||||
|
|
||||||
|
beforeEach(inject(($compile, $rootScope) => {
|
||||||
|
$element = $compile('<vn-monitor-index></vn-monitor-index>')($rootScope);
|
||||||
|
controller = $element.controller('vnMonitorIndex');
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('toggle()', () => {
|
||||||
|
it('should add the hidden class to the horizontal contaning the panel to hide', () => {
|
||||||
|
controller.toggle();
|
||||||
|
|
||||||
|
const targetElement = $element[0].querySelector('vn-horizontal');
|
||||||
|
const firstClass = targetElement.classList[0];
|
||||||
|
|
||||||
|
const isTopPanelHidden = localStorage.getItem('ticketTopPanelHidden');
|
||||||
|
|
||||||
|
expect(firstClass).toEqual('hidden');
|
||||||
|
expect(isTopPanelHidden).toEqual('true');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should remove the hidden class to the horizontal contaning the panel to hide', () => {
|
||||||
|
const targetElement = $element[0].querySelector('vn-horizontal');
|
||||||
|
targetElement.classList.add('hidden');
|
||||||
|
controller.toggle();
|
||||||
|
const firstClass = targetElement.classList[0];
|
||||||
|
|
||||||
|
const isTopPanelHidden = localStorage.getItem('ticketTopPanelHidden');
|
||||||
|
|
||||||
|
expect(firstClass).toBeUndefined();
|
||||||
|
expect(isTopPanelHidden).toEqual('false');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -9,3 +9,5 @@ Minimize/Maximize: Minimizar/Maximizar
|
||||||
Problems: Problemas
|
Problems: Problemas
|
||||||
Theoretical: Teórica
|
Theoretical: Teórica
|
||||||
Practical: Práctica
|
Practical: Práctica
|
||||||
|
Auto-refresh: Auto-refresco
|
||||||
|
Toggle auto-refresh every 2 minutes: Conmuta el refresco automático cada 2 minutos
|
|
@ -22,6 +22,11 @@
|
||||||
Tickets monitor
|
Tickets monitor
|
||||||
</vn-one>
|
</vn-one>
|
||||||
<vn-none>
|
<vn-none>
|
||||||
|
<vn-check
|
||||||
|
label="Auto-refresh"
|
||||||
|
vn-tooltip="Toggle auto-refresh every 2 minutes"
|
||||||
|
on-change="$ctrl.autoRefresh(value)">
|
||||||
|
</vn-check>
|
||||||
<vn-icon
|
<vn-icon
|
||||||
icon="refresh"
|
icon="refresh"
|
||||||
vn-tooltip="Refresh"
|
vn-tooltip="Refresh"
|
||||||
|
|
|
@ -95,6 +95,15 @@ export default class Controller extends Section {
|
||||||
this.selectedTicket = ticket;
|
this.selectedTicket = ticket;
|
||||||
this.$.summary.show();
|
this.$.summary.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
autoRefresh(value) {
|
||||||
|
if (value)
|
||||||
|
this.refreshTimer = setInterval(() => this.$.model.refresh(), 120000);
|
||||||
|
else {
|
||||||
|
clearInterval(this.refreshTimer);
|
||||||
|
this.refreshTimer = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngModule.vnComponent('vnMonitorSalesTickets', {
|
ngModule.vnComponent('vnMonitorSalesTickets', {
|
||||||
|
|
Loading…
Reference in New Issue