-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex1.html
More file actions
327 lines (299 loc) · 11.9 KB
/
index1.html
File metadata and controls
327 lines (299 loc) · 11.9 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Geb Config © 2018 Xmplar.in All right reserved</title>
<link rel = "stylesheet"
type = "text/css"
href = "style.css" />
</head>
<body>
<div class="head">
<h2>GEB Config</h2>
<div class="nav">
<button class= "button" id = "but3"><a href="./index1.html">Build-Config</a></button>
<button class= "but1" id= "but2"><a href="./index2.html">Schedule</a></button>
<button class= "button" id = "but1"><a class = "link1" href="./index.html">Home</a></button>
</div>
</div>
<div class="container-fluid">
<div class="container">
<input type="text" name="Name" id="name" class="inputFiled" placeholder="Name"><br><br>
<input type="text" name="" id="email" class="inputFiled" placeholder="Email"><br><br>
<input type="password" name="" id="password" class="inputFiled" placeholder="Password"><br><br>
<input type="text" name="" id="toSize" class="inputFiled" placeholder="Number of People on TO List"><br><br>
<input type="text" name="" id="ccSize" class="inputFiled" placeholder="Number of People on CC List"><br><br>
<input type="text" name="" id="reportSize" class="inputFiled" placeholder="Number of Reports to be Sent"><br><br>
<input type="submit" name="" id="submitConfig" class="button" value="Submit">
</div>
</div>
</body>
<script>
// const bcrypt = require('bcrypt');
// const saltRounds = 10;
// Command to Create a scheduled task from command line:schtasks /Create /tn "mytask5" /sc ONCE /st 17:49:00 /tr "C:\Users\Xmplar\Desktop\UnitTestCases.bat"
function handleClick(event){
console.log(event.target)
var element = event.target.firstChild;
element.click();
}
document.querySelector('#but1').addEventListener('click',function(event){
handleClick(event)
});
document.querySelector('#but2').addEventListener('click',function(event){
handleClick(event)
});
document.querySelector('#but3').addEventListener('click',function(event){
handleClick(event)
});
var fs = require('fs');
// Or with ECMAScript 6
var app = require('electron').remote;
var dialog = app.dialog;
// var dialogs = require('dialogs')
var fileName = ""
function extractFileName() {
}
function writeToFile(filename, con) {
// let con = "\r\nHi there"
// con = con +"\r\n"
fs.writeFile(filename, con, (err) => {
});
}
var name;
var emailAddress;
var password;
var toSize;
var toList = [];
var ccSize;
var ccList = [];
var reportSize;
var reportList = [];
var dir = "";
var taskName;
var time;
var frequency;
var jarName;
var testCaseName;
var data = function (flagBefore, flagAfter, limit, id) {
this.flagBefore = flagBefore;
this.flagAfter = flagAfter;
this.limit = limit;
this.id = id;
}
var ccObject = new data(0, 0, 0, '#ccSize');
var toObject = new data(0, 0, 0, '#toSize');
var reportObject = new data(0, 0, 0, '#reportSize')
function emailList(Size, element, Flag, obj) {
console.log("ccBefore value :" + obj.flagBefore)
for (var i = Size; i > Flag; i--) {
if (obj.id != '#reportSize')
html = '<span class = " email_%cls%"><br><br><input type="text" name="" class="inputFiled" id="%ID% %id%" placeholder="Email ID %id%"></span>';
else
html = '<span class = " report_%cls%"><br><br><input type="text" name="" class="inputFiled" id="%ID% %id%" placeholder="Report Name %id%"></span>';
html = html.replace('%id%', i)
html = html.replace('%id%', i)
if (element == '#ccSize') {
html = html.replace('%ID%', "CC")
html = html.replace('%cls%', "CC")
}
else if (element == '#toSize') {
html = html.replace('%ID%', "TO")
html = html.replace('%cls%', "TO")
} else {
html = html.replace('%ID%', "REPORT")
html = html.replace('%cls%', "REPORT")
}
if (obj.flagBefore > 0) {
if (obj.id == "#ccSize")
var ele = "CC " + obj.flagBefore
else if (obj.id == "#toSize")
var ele = "TO " + obj.flagBefore
else
var ele = "REPORT " + obj.flagBefore
document.getElementById(ele).insertAdjacentHTML('afterend', html);
} else
document.querySelector(element).insertAdjacentHTML('afterend', html);
}
}
function del(object) {
console.log("Flag Before " + object.flagBefore)
for (var i = 0; i < object.flagBefore; i++) {
if (object.id === '#ccSize')
var elem = '.email_CC'
else if (object.id === '#toSize')
var elem = '.email_TO'
else
var elem = ".report_REPORT"
var elem = document.querySelector(elem)
elem.parentNode.removeChild(elem);
}
object.flagBefore = 0
object.limit = 0
return
}
function update(object) {
if (document.querySelector(object.id).value != '') {
var size = parseInt(document.querySelector(object.id).value);
if (size > object.flagBefore && object.flagBefore != 0) {
object.limit = object.flagBefore
emailList(size, object.id, object.limit, object);
object.flagBefore = object.flagBefore + (size - object.limit)
} else {
emailList(size, object.id, object.limit, object);
object.flagBefore = size
}
}
}
function ccUpdate(event) {
del(ccObject);
update(ccObject);
}
function toUpdate(event) {
del(toObject)
update(toObject);
}
function reportUpdate(event) {
del(reportObject)
update(reportObject);
}
document.getElementById('ccSize').addEventListener('keydown', function (event) {
ccUpdate(event)
})
document.getElementById('ccSize').addEventListener('keyup', function (event) {
ccUpdate(event)
})
document.getElementById('toSize').addEventListener('keydown', function (event) {
toUpdate(event);
})
document.getElementById('toSize').addEventListener('keyup', function (event) {
toUpdate(event);
})
document.getElementById('reportSize').addEventListener('keydown', function (event) {
reportUpdate(event);
})
document.getElementById('reportSize').addEventListener('keyup', function (event) {
reportUpdate(event);
})
function getSchedulerValues(){
time = document.querySelector('#time').value;
var e = document.querySelector("#freq");
frequency = e.options[e.selectedIndex].value;
jarName = document.querySelector('#jarName').value;
testCaseName = document.querySelector('#testCaseName').value;
taskName = document.querySelector('#taskName').value;
}
function getConfigValues(){
name = document.querySelector('#name').value;
emailAddress = document.querySelector('#email').value;;
password = document.querySelector('#password').value;
toSize = document.querySelector('#toSize').value;
for (var i = 0; i < toSize; i++) {
toList.push(document.getElementById('TO ' + (i + 1)).value);
}
ccSize = document.querySelector('#ccSize').value;
for (var i = 0; i < ccSize; i++) {
ccList.push(document.getElementById('CC ' + (i + 1)).value);
}
reportSize = document.querySelector('#reportSize').value;
for (var i = 0; i < reportSize; i++) {
reportList.push(document.getElementById('REPORT ' + (i + 1)).value);
}
}
function configBuilder(){
var fileName1 = null;
fileName = dialog.showSaveDialog({})
console.log("Name :" + name)
console.log("Email :" + emailAddress)
console.log("Password :" + password)
console.log("To Email List")
for (var i = 0; i < toSize; i++)
console.log("Email " + (i + 1) + ":" + toList[i])
console.log("CC Email List")
for (var i = 0; i < ccSize; i++)
console.log("Email " + (i + 1) + ":" + ccList[i])
console.log("Report Names List")
for (var i = 0; i < reportSize; i++)
console.log("Report Name " + (i + 1) + ":" + reportList[i])
let space = "\r\n"
var cont = name + space + emailAddress + space + password + space + toSize + space
fs.truncate(fileName, 0, function () { console.log('done') })
for (var i = 0; i < toSize; i++)
cont = cont + toList[i] + space
cont = cont + ccSize + space
// writeToFile(fileName,ccSize);
for (var i = 0; i < ccSize; i++)
cont = cont + ccList[i] + space
cont = cont + reportSize + space
for (var i = 0; i < reportSize; i++)
cont = cont + reportList[i] + space
console.log(cont)
writeToFile(fileName, cont);
}
document.querySelector('#submitConfig').addEventListener('click',function(){
getConfigValues();
configBuilder();
const dialogOptions = { type: 'info', buttons: ['OK', 'Cancel'], message: fileName }
dialog.showMessageBox(dialogOptions, i => console.log(i))
window.location.reload();
});
/* document.querySelector('#submitButton').addEventListener('click', function () {
// var hash = bcrypt.hashSync(password, saltRounds);
getSchedulerValues()
getConfigValues();
configBuilder();
var flName = fileName;
flName = flName.toString();
flName = flName.replace(/\\/g, '\\\\');
cont = `cd ${dir} && java -jar ${jarName} ${testCaseName} ${flName}`;
let arr = fileName.split('\\');
arr.splice(arr.length -1,1);
fileName1 = arr.join('\\');
fileName1 += "\\TestCase.bat";
writeToFile(fileName1, cont);
// window.location.reload();
const dialogOptions = { type: 'info', buttons: ['OK', 'Cancel'], message: cont }
const execSync = require('child_process').execSync;
//schtasks /Create /tn "mytask5" /sc ONCE /st 17:49:00 /tr "C:\Users\Xmplar\Desktop\UnitTestCases.bat"
code = execSync(`schtasks /Create /tn ${taskName.toString()} /sc ${frequency.toString()} /st ${time.toString()} /tr ${fileName1}`);
dialog.showMessageBox(dialogOptions, i => console.log(i))
window.location.reload();
}) */
</script>
</html>
<!--
Important Commands:
Geb>electron-packager . geb --platform=win32 --arch=x64 --out=Geb Config --prune=truelabels -->
<!-- Runtime.getRuntime().addShutdownHook(new Thread()
{
public void run()
{
try {
Thread.sleep(5000);
zipfile();
SendMail(args[1],status,sub);
}catch(Exception e) {
System.out.println("Message"+e.getMessage());
System.out.println(e.getStackTrace());
System.out.println("Failed to send the Email");
System.out.println("Message :"+e.getMessage());
}
}
});
System.exit(0); -->
<!-- Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
try {
Thread.sleep(5000);
zipfile();
SendMail(args[1], status, sub);
} catch (Exception e) {
System.out.println("Message" + e.getMessage());
System.out.println(e.getStackTrace());
System.out.println("Failed to send the Email");
System.out.println("Message :" + e.getMessage());
}
}
}); -->