-
Notifications
You must be signed in to change notification settings - Fork 2
/
NewSolution.html
252 lines (222 loc) · 11.9 KB
/
NewSolution.html
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
<!DOCTYPE html>
<html>
<head>
<meta content="text/html" charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<title>New Solution</title>
<link rel="stylesheet" href="./css/shkwak.css" type="text/css" />
<script language="JavaScript" type="text/javascript" src="./js/jquery-1.8.2.min.js"></script>
<script language="JavaScript" type="text/javascript" src="./js/base64.js"></script>
<script language="JavaScript" type="text/javascript" src="./js/shkwak.js"></script>
<script language="JavaScript" type="text/javascript" src="./js/shortcut.js"></script>
<script language="javascript">
/*-- Sign in Button Shortcut 설정--*/
shortcut.add("Enter", function() {
SolutionCreate(); //2014-04-18_shkwak
});
var pre_content; //수정 전 content base64 값
function GetFileList()
{
if (owner == "" || repo == "")
{
alert("Insert Owner value and Repository value!");
}
else
{
jQuery.support.cors = true;
$.ajax({
url: "https://api.github.com/repos/" + owner + "/" + repo + "/contents",
type: "GET",
dataType: "json",
success: function (data) {
//jsonData = eval(data); //eval() : json 타입으로 변환해줌
//alert(data.length); //2!!! Good
for (var i=0;i<data.length;i++)
{
alert(data[i].name);
} s
},
error: function (x, y, z) {
alert(x + "\n" + y + "\n" + z);
}
});
}
}
function GetData(fileName)
{
var owner = document.getElementById('gitUser').value;
var repo = document.getElementById('gitRepo').value;
if (owner == "" || repo == "")
{
alert("Insert Owner value and Repository value!");
}
else
{
jQuery.support.cors = true;
$.ajax({
url: "https://api.github.com/repos/" + owner + "/" + repo + "/contents/" + fileName,
type: "GET",
dataType: "json",
success: function (data) {
//jsonData = eval(data); //eval() : json 타입으로 변환해줌
document.getElementById('box1').value = data.content;
pre_content = data.content;
//document.getElementById('box1').value = data.sha;
},
error: function (x, y, z) {
alert(x + "\n" + y + "\n" + z);
}
});
}
}
/*============= Creat new solution ==============*/
var i = 0;
var timer;
function SolutionCreate()
{ //Required : message, content
/*--GitHub 사용자 정보--*/
var owner = document.getElementById('gitUser').value;
var repo = document.getElementById('gitRepo').value;
var box_result = document.getElementById('box_result');
if (i==0) {box_result.value = "";}
/*--access_token--*/
var access_token = localStorage.getItem("access_token");
if (access_token == null)
{
alert("로그인을 하여야 솔루션 생성이 가능합니다.");
}
else
{
/*--생성될 솔루션 파일명(임시)--*///solution은 생성할 솔루션명이랑 같아야 할듯
var fileName = ["concert.launch", "solution.services", "package.xml", "CMakeLists.txt"];
var solutionName = document.getElementById('solutionName').value;
var box = [document.getElementById('box1').value, document.getElementById('box2').value, document.getElementById('box3').value, document.getElementById('box4').value];
//alert(box[0]); //for Test
// for (var i=0;i<fileName.length;i++)
// {
var msg = "Create new solution ";
var content = box[i];
var cmds = {message : msg, content : content};
jQuery.support.cors = true;
$.ajax({
url: "https://api.github.com/repos/" + owner + "/" + repo + "/contents/" + solutionName + "/" + fileName[i] + "?access_token=" + access_token,
type: "PUT",
data: JSON.stringify(cmds),
contentType: "application/json;charset=utf-8",
success: function (data) {
console.log("fileName : " + fileName[i] + ", i : " + i);
box_result.value += fileName[i] + " is created.\n";
i++;
if (i==4)
{
i = 0;
//var text = "https://api.github.com/repos/" + owner + "/" + repo + "/contents/" + solutionName;
var text = "https://github.com/" + owner + "/" + repo + "/tree/master/" + solutionName; //api, repos, contents 항목 삭제!, tree/master/ 추가★
box_result.value += text + "\n";
//box.value = solutionName + " 솔루션 파일이 생성되었습니다.\n" + text + "\n";
//box.innerHTML = "<a href='" + text + "'>" + text; //2014-04-18, result report : text -> link //x
clearTimeout(timer);
}
else
{
timer = setTimeout('SolutionCreate()',500);
}
console.log(timer);
},
error: function (x, y, z) {
//alert(x + " " + y + " : " + z + "\n\n솔루션 생성 중 오류가 발생했습니다. 다시 시도해 주세요.");
console.log(x + " " + y + " : " + z + ", i : " + i + "\n\n솔루션 생성 중 오류가 발생했습니다. 다시 시도해 주세요.");
if (z == "Unprocessable Entity")
{
console.log("이미 동일한 솔루션이 존재합니다.");
box_result.value = "이미 동일한 솔루션이 존재합니다. \n";
}
else if (z == "Not Found")
{
console.log("gitInfo(gitUser, gitRepo) 값이 올바르지 않습니다. 다시 확인해 주세요.");
box_result.value = "gitInfo(gitUser, gitRepo) 값이 올바르지 않습니다. 다시 확인해 주세요. \n";
}
i = 0;
clearTimeout(timer);
}
});
// }
}
}
function base64encode1(data)
{
var output = Base64.encode(data);
return output;
}
function SigninCheck()
{
/*--access_token--*/
var access_token = localStorage.getItem("access_token");
var signin_msg = document.getElementById('signin_msg');
if (access_token == null)
{
document.getElementById('signin').value = "Sign in";
signin_msg.innerHTML = "* 로그인을 하여야 솔루션 생성이 가능합니다.";
}
else
{
document.getElementById('signin').value = "Sign out";
signin_msg.innerHTML = "* ";
}
}
var ShowHide_status = false;
</script>
</head>
<body onLoad="SigninCheck()">
<div style="font-size:24px; color:#6699cc;">Create New Solution</div>
<hr><br>
<div>Solution Create</div>
<span style="font-size:12px; color:">GitHub Repository에 새로운 솔루션을 생성합니다.<br>
생성할 솔루션명을 입력하세요.<br>
Name :
<input type="text" id="solutionName" style="font-size:11px; width:210px" placeholder="ex) my_solution" spellcheck="false">
<span id="gitInfo" style="font-size:12px; color:;">gitInfo</span>
<span id="gitUserRepo" style="display:none;">
gitUser <input type="text" id="gitUser" value="meddugi723" style="width:100px; font-size:12px;" spellcheck="false">
gitRepo <input type="text" id="gitRepo" value="ROStest1" style="width:150px; font-size:12px;" spellcheck="false">
</span>
<input type="image" src="./img/settings-1.png" onclick="ShowHide();" style="vertical-align:middle;"/>
<br>
</span>
<input type="button" id="" value="Create new solution" onclick="SolutionCreate();" class="button" title="솔루션 파일을 생성합니다."/>
<span id="signin_msg" style="font-size:11px; color:#cc3366;">* 로그인을 하여야 솔루션 생성이 가능합니다.</span>
<input type="button" id="signin" onclick="javascript:top.document.getElementById('subframe').src='Signin.html', top.document.getElementById('BreadcrumbTitle').innerHTML='Sign in', top.document.getElementById('pageTitle').innerHTML='';top.ChangeSigninTitle('OUT');" value="Sign in" class="button2"/> <br><br>
<div>Created Solution Files Description<br><span style="font-size:12px;" >
새로운 솔루션을 생성하면 기본 구성파일로 아래와 같이 4개의 파일 생성됩니다.<br>
- <strong>concert.launch</strong> : 솔루션 실행 설정 파일<br>
- <strong>solution.services</strong> : 솔루션 내에서 사용되는 서비스 목록 및 Custom 설정 파일<br>
- <strong>package.xml</strong> : 솔루션에 대한 메타 정보 및 의존성 설정 파일<br>
- <strong>CMakeLists.txt</strong> : 설치 시 필요한 의존성 정보 검색을 위한 설정 파일</span>
</div><br>
<div>Result Report<br><span style="font-size:12px;" >
솔루션 생성 결과를 보여줍니다.<br>
<textarea id="box_result" style="width:90%; margin-top:5px;" rows="5" title="source" spellcheck="false"></textarea>
</span><br>
</div><br>
<div>Other Page Link<br><span style="font-size:12px;" >
이동하고자 하는 페이지 버튼을 클릭하면 해당 페이지로 이동합니다..<br>
<input type="button" onclick="javascript:top.document.getElementById('subframe').src='NewSolution.html', top.document.getElementById('BreadcrumbTitle').innerHTML='Solution Manager', top.document.getElementById('pageTitle').innerHTML='Solution Configuration Manager';" value="Solution Manager" class="button2"/>
<input type="button" onclick="javascript:top.document.getElementById('subframe').src='Webgraphviz.html', top.document.getElementById('BreadcrumbTitle').innerHTML='Data Visualizer', top.document.getElementById('pageTitle').innerHTML='Data Visualizer';" value="Data Visualizer" class="button2"/>
<input type="button" onclick="javascript:top.document.getElementById('subframe').src='Scheduler.html', top.document.getElementById('BreadcrumbTitle').innerHTML='Service Scheduler', top.document.getElementById('pageTitle').innerHTML='Service Scheduler';" value="Service Scheduler" class="button2"/>
<input type="button" onclick="javascript:top.document.getElementById('subframe').src='TemplateEdit.html', top.document.getElementById('BreadcrumbTitle').innerHTML='Template Editor', top.document.getElementById('pageTitle').innerHTML='Template Editor';" value="Template Editor" class="button2"/>
<!-- <input type="button" onclick="ReadValue()" value="v" class="button2"/> -->
</span><br>
</div><br>
<!-- <textarea id="graphviz_data" wrap=on style="width:100%;" rows=14></textarea> display:none;-->
<!-- concert.launch -->
<textarea id="box1" style="width:45%; display:none;" rows="12" title="">PGxhdW5jaD4KICAgIDxpbmNsdWRlIGZpbGU9IiQoZmluZCBjb25jZXJ0X21hc3RlcikvIj4KICAgICAgICA8YXJnIG5hbWU9ImNvbmNlcnRfbmFtZSIgdmFsdWU9IiIvPgogICAgICAgIDxhcmcgbmFtZT0ic2VydmljZXMiIHZhbHVlPSIiLz4KICAgICAgICA8YXJnIG5hbWU9ImNvbmR1Y3Rvcl9hdXRvX2ludml0ZSIgdmFsdWU9IiIvPgogICAgICAgIDxhcmcgbmFtZT0iY29uZHVjdG9yX2xvY2FsX2NsaWVudHNfb25seSIgdmFsdWU9IiIvPgogICAgICAgIDxhcmcgbmFtZT0iYXV0b19lbmFibGVfc2VydmljZXMiIHZhbHVlPSIiLz4KICAgICAgICA8YXJnIG5hbWU9InNjaGVkdWxlcl90eXBlIiB2YWx1ZT0iIi8+CiAgICA8L2luY2x1ZGU+CjwvbGF1bmNoPgo=</textarea>
<!-- solution.services -->
<textarea id="box2" style="width:45%; display:none;" rows="12" title="">LSByZXNvdXJjZToKICBvdmVycmlkZToKICAgIHByaW9yaXR5OgotIHJlc291cmNlOgogIG92ZXJyaWRlOgogICAgbmFtZToKICAgIGRlc2NyaXB0aW9uOgotIHJlc291cmNlOgogIG92ZXJyaWRlOgogICAgZGVzY3JpcHRpb246Ci0gcmVzb3VyY2U6Cg==</textarea>
<!-- package.xml -->
<textarea id="box3" style="width:45%; display:none;" rows="12" title="">PHBhY2thZ2U+CiAgPG5hbWU+PC9uYW1lPgogIDx2ZXJzaW9uPjwvdmVyc2lvbj4KICA8ZGVzY3JpcHRpb24+PC9kZXNjcmlwdGlvbj4KICA8bWFpbnRhaW5lciBlbWFpbD0iIj48L21haW50YWluZXI+CiAgPGxpY2Vuc2U+QlNEPC9saWNlbnNlPgogIDxhdXRob3I+PC9hdXRob3I+CgogIDxidWlsZHRvb2xfZGVwZW5kPmNhdGtpbjwvYnVpbGR0b29sX2RlcGVuZD4KICA8cnVuX2RlcGVuZD48L3J1bl9kZXBlbmQ+CiAKPC9wYWNrYWdlPgoK</textarea>
<!-- CMakeLists.txt -->
<textarea id="box4" style="width:45%; display:none;" rows="12" title="">IyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIwojIENNYWtlCiMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMKCmNtYWtlX21pbmltdW1fcmVxdWlyZWQoVkVSU0lPTiAyLjguMykKcHJvamVjdCgpCgojIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjCiMgQ2F0a2luCiMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMKCmZpbmRfcGFja2FnZShjYXRraW4gUkVRVUlSRUQpCmNhdGtpbl9wYWNrYWdlKCkK</textarea>
<!------------------------------------------------------------------>
</body>
</html>