Browse Source

statusbar as module in epesi.js

experimental
Paweł Jedwabny 4 years ago
parent
commit
d274b6be5c
4 changed files with 46 additions and 55 deletions
  1. +0
    -51
      src/StatusBar/main.js
  2. +20
    -2
      src/epesi.js
  3. +0
    -2
      src/index.js
  4. +26
    -0
      src/statusBar.js

+ 0
- 51
src/StatusBar/main.js View File

@@ -1,51 +0,0 @@
class StatusBar {
indicator = 'Base_StatusBar';
indicator_text = 'statusbar_text';

fadeOut = () => {
NProgress.configure({parent: '#nano-bar'});
NProgress.start();
let statbar = document.getElementById(this.indicator);
jQuery(statbar).fadeOut();
NProgress.done();
};

fadeIn = () => {
document.getElementById('dismiss').style.display = 'none';
let statbar = document.getElementById(this.indicator);
jQuery(statbar).fadeIn();
};

showMessage = (message) => {
document.getElementById('dismiss').style.display = '';
document.getElementById(this.indicator_text).innerHTML = message;
}
}

let status = new StatusBar();

window.statusbar_message_t='';
window.statusbar_message=function(text){
statusbar_message_t=text;
};

window.updateEpesiIndicatorFunction=function(){
let statbar = document.getElementById('Base_StatusBar');

statbar.addEventListener('click', () => {if(!Epesi.procOn)status.fadeOut()});
statbar.style.display='none';

Epesi.updateIndicator=function(){
if(Epesi.procOn){
status.fadeIn();
}else{
if(statusbar_message_t !== '') {
status.showMessage(statusbar_message_t);
statusbar_message('');
setTimeout(status.fadeOut,5000);
}else{
status.fadeOut()
};
};
};
};

+ 20
- 2
src/epesi.js View File

@@ -9,6 +9,7 @@ import Loader from './loader';
import axios from 'axios';
import qs from 'qs';
import ConfirmLeave from './confirmLeave';
import StatusBar from './statusBar';

class Epesi {
loader = new Loader();
@@ -19,6 +20,8 @@ class Epesi {
process_file = 'process.php';
indicator = 'Base_StatusBar';
indicator_text = 'statusbar_text';
statusBar = new StatusBar();
message = null;

constructor(client_id, process_file_path, params = '') {
this.client_id=client_id;
@@ -33,7 +36,12 @@ class Epesi {
this.history_add(0);

if(!params) params = '';
setTimeout(updateEpesiIndicatorFunction);

window.statusbar_message = message => this.message = message;
let statbar = document.getElementById('Base_StatusBar');
statbar.addEventListener('click', () => {if(!this.procOn)this.statusBar.fadeOut()});
statbar.style.display='none';

this.request(params,0).then(() => {
document.getElementById('epesi_loader').style.display = 'none';
document.getElementById('main_content').style.display = '';
@@ -44,7 +52,17 @@ class Epesi {
};

updateIndicator = () => {
if(this.indicator) document.getElementById(this.indicator).style.display = this.procOn ? '' : 'none';
if(this.procOn){
this.statusBar.fadeIn();
}else{
if(this.message) {
this.statusBar.showMessage(this.message);
this.message = null;
setTimeout(this.statusBar.fadeOut,5000);
}else{
this.statusBar.fadeOut()
};
};
};

updateIndicatorText = (text) => {


+ 0
- 2
src/index.js View File

@@ -22,8 +22,6 @@ import 'font-awesome/css/font-awesome.css';
import 'script-loader!../libs/nprogress/nprogress';
import '../libs/nprogress/nprogress.css';

import './StatusBar/main';

import Epesi from './epesi';

window.EpesiClass = Epesi;


+ 26
- 0
src/statusBar.js View File

@@ -0,0 +1,26 @@
class StatusBar {
indicator = 'Base_StatusBar';
indicator_text = 'statusbar_text';

fadeOut = () => {
if (document.getElementById('nano-bar') !== null) NProgress.configure({parent: '#nano-bar'});

NProgress.start();
let statbar = document.getElementById(this.indicator);
jQuery(statbar).fadeOut();
NProgress.done();
};

fadeIn = () => {
document.getElementById('dismiss').style.display = 'none';
let statbar = document.getElementById(this.indicator);
jQuery(statbar).fadeIn();
};

showMessage = (message) => {
document.getElementById('dismiss').style.display = '';
document.getElementById(this.indicator_text).innerHTML = message;
}
}

export default StatusBar

Loading…
Cancel
Save