-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.ts
62 lines (54 loc) · 1.62 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import packageInfo from '../package.json';
import {TimeEntry} from "./modules/timeentry/timeentry";
import {TimeSheet} from "./modules/timesheet/timesheet";
import { Timesheetactions } from './modules/timesheetactions/timesheetactions';
import {Global} from "./modules/global/global";
import {Configuration} from "./configuration";
import { Timesheetimport } from './modules/timesheetimport/timesheetimport';
import { AbstractModule } from './modules/AbstractModule';
class Unit4Enhancer {
// list of modules to use
private static modules = [
TimeEntry,
TimeSheet,
Timesheetactions,
Timesheetimport,
Global
];
async main () {
const version = packageInfo.version;
var active = false;
var initialization: Promise<any>[] = [];
var modules: AbstractModule[] = [];
Unit4Enhancer.modules.forEach(m => {
const module = new m();
initialization.push(module.initModule());
modules.push(module);
});
if(window.parent == window.self) {
// only show config button on top level
Configuration.getInstance().addConfigUI();
}
Promise.all(initialization).then(() => {
// check if we have active modules at all
modules.forEach(module => {
if (module.isActive()) {
active = true;
}
});
// execute all active modules
if (active) {
console.log("Unit4 enhancements " + version + " active ... ");
modules.forEach(m => {
if (m.isActive()) {
m.executeModule();
}
});
}
});
}
}
const inst = new Unit4Enhancer();
inst.main().catch((e) => {
console.error(e);
})