This repository has been archived by the owner on Aug 18, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.js
105 lines (91 loc) · 3 KB
/
configure.js
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
var ipc = require('ipc')
var Ractive = require('ractive')
var page = require('page')
var fs = require('fs')
var pluginParser = require('./plugin-parser.js');
var exec = require('./exec.js');
var libplugin = require('./plugin.js');
var handler = require('./handler.js');
Ractive.DEBUG = false
var state = {}
exports.getState = function() {
return state
}
exports.init = function() {
var templates = {
status_: fs.readFileSync(__dirname + '/templates/status.tmpl').toString(),
install: fs.readFileSync(__dirname + '/templates/install.tmpl').toString(),
run: fs.readFileSync(__dirname + '/templates/run.tmpl').toString(),
settings: fs.readFileSync(__dirname + '/templates/settings.tmpl').toString()
}
var routes = {
status_: function configure (ctx, next) {
ctx.template = templates.status_
state.status_ = render(ctx, {})
handler.updateTests(state)
},
install: function configure (ctx, next) {
ctx.template = templates.install
state.install = render(ctx, {})
pluginParser.loadPlugins(function(data){
// actions can only be bound to grid after full initialization
var temp_plugins;
temp_plugins = state.install.get("plugins");
if (temp_plugins == undefined) {
temp_plugins = [];
}
temp_plugins.push(data);
state.install.set("plugins", temp_plugins).then(libplugin.bindDeleteButtons(state));
});
},
run: function detail (ctx, next) {
ctx.template = templates.run
state.run = render(ctx, {})
pluginParser.loadPlugins(function(data){
// actions can only be bound to grid after full initialization
var temp_plugins;
temp_plugins = state.run.get("plugins");
if (temp_plugins == undefined) {
temp_plugins = [];
}
temp_plugins.push(data);
state.run.set("plugins", temp_plugins).then(exec.bindPluginGrid(state));
});
},
settings: function about (ctx, next) {
ctx.template = templates.settings
state.settings = render(ctx, {})
}
}
var events = {
processAction: function (e) {
var action = e.node.attributes['data-action'].value
var procNameAttr = e.node.attributes['data-name']
var data = {task: action}
if (procNameAttr) data.name = procNameAttr.value
ipc.send('task', data)
},
quit: function () {
ipc.send('terminate')
}
}
// set up routes
page('/', routes.status_)
page('/status', routes.status_)
page('/install', routes.install)
page('/run', routes.run)
page('/settings', routes.settings)
// initialize router
page.start()
page('/status')
state.page = page;
function render (ctx) {
var ract = new Ractive({
el: '#container',
template: ctx.template,
data: ctx.data
})
ract.on(events)
return ract
}
}