Commit 4e9565fa authored by Alain Takoudjou's avatar Alain Takoudjou

Solve some basic UI problems on webrunner

parent 01f5d15d
...@@ -65,16 +65,9 @@ def switchBranch(project, name): ...@@ -65,16 +65,9 @@ def switchBranch(project, name):
if name == current_branch: if name == current_branch:
json = "This is already your active branch for this project" json = "This is already your active branch for this project"
else: else:
i = 0
json = "Error: Can not found branch '" + name + "'" json = "Error: Can not found branch '" + name + "'"
repo.heads.master.checkout() git = repo.git
for b in branches: git.checkout(name)
if b.name == name:
repo.heads[i].checkout()
code = 1
json = ""
break
i = i + 1
except Exception, e: except Exception, e:
json = str(e) json = str(e)
return jsonify(code=code, result=json) return jsonify(code=code, result=json)
...@@ -84,7 +77,8 @@ def createBranch(project, name): ...@@ -84,7 +77,8 @@ def createBranch(project, name):
json = "" json = ""
try: try:
repo = Repo(project) repo = Repo(project)
b = repo.create_head(name) git = repo.git
git.checkout('-b', name)
code = 1 code = 1
except Exception, e: except Exception, e:
json = str(e) json = str(e)
...@@ -101,10 +95,10 @@ def getDiff(project): ...@@ -101,10 +95,10 @@ def getDiff(project):
result = str(e) result = str(e)
return result return result
def gitPush(project, msg, fetch=False): def gitPush(project, msg):
code = 0 code = 0
json = "" json = ""
commit = False undo_commit = False
try: try:
repo = Repo(project) repo = Repo(project)
if repo.is_dirty: if repo.is_dirty:
...@@ -116,10 +110,7 @@ def gitPush(project, msg, fetch=False): ...@@ -116,10 +110,7 @@ def gitPush(project, msg, fetch=False):
git.add(f) git.add(f)
#Commit all modified and untracked files #Commit all modified and untracked files
git.commit('-a', '-m', msg) git.commit('-a', '-m', msg)
commit = True undo_commit = True
if fetch:
git.fetch('--all')
git.rebase('origin/' + current_branch)
#push changes to repo #push changes to repo
git.push('origin', current_branch) git.push('origin', current_branch)
code = 1 code = 1
...@@ -127,7 +118,20 @@ def gitPush(project, msg, fetch=False): ...@@ -127,7 +118,20 @@ def gitPush(project, msg, fetch=False):
json = "Nothing to be commited" json = "Nothing to be commited"
code = 1 code = 1
except Exception, e: except Exception, e:
if commit: if undo_commit:
git.reset("HEAD^1") #undo previous commit git.reset("HEAD^1") #undo previous commit
json = str(e) json = str(e)
return jsonify(code=code, result=json) return jsonify(code=code, result=json)
def gitPull(project):
result = ""
code = 0
try:
repo = Repo(project)
git = repo.git
current_branch = repo.active_branch.name
git.pull()
code = 1
except Exception, e:
result = str(e)
return jsonify(code=code, result=result)
\ No newline at end of file
...@@ -455,6 +455,7 @@ body { ...@@ -455,6 +455,7 @@ body {
} }
#contentInfo h2, .hight{ #contentInfo h2, .hight{
background: #e4e4e4;
width: 100%; width: 100%;
height: 25px; height: 25px;
padding-top:2px; padding-top:2px;
...@@ -463,11 +464,11 @@ body { ...@@ -463,11 +464,11 @@ body {
text-shadow: 0px 1px #FFF; text-shadow: 0px 1px #FFF;
} }
#contentInfo h2, .show{ .show{
background: #e4e4e4 url(../images/arrow_up.png) 97% 50% no-repeat; background: #e4e4e4 url(../images/arrow_up.png) 97% 50% no-repeat;
} }
#contentInfo h2, .hide{ .hide{
background: #e4e4e4 url(../images/arrow_down.png) 97% 50% no-repeat; background: #e4e4e4 url(../images/arrow_down.png) 97% 50% no-repeat;
} }
......
...@@ -67,7 +67,7 @@ $(document).ready( function() { ...@@ -67,7 +67,7 @@ $(document).ready( function() {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: $SCRIPT_ROOT + '/pushProjectFiles', url: $SCRIPT_ROOT + '/pushProjectFiles',
data: "project=" + $("input#workdir").val() + "/" + project + "&msg=" + $("input#commitmsg").val(), data: {project: $("input#workdir").val() + "/" + project, msg: $("input#commitmsg").val()},
success: function(data){ success: function(data){
if(data.code == 1){ if(data.code == 1){
if (data.result != ""){ if (data.result != ""){
...@@ -88,6 +88,40 @@ $(document).ready( function() { ...@@ -88,6 +88,40 @@ $(document).ready( function() {
}); });
return false; return false;
}); });
/*
$("#pullbranch").click(function(){
if (send){
return false;
}
send = true;
var project = $("#project").val();
$("#pullimgwaitting").fadeIn('normal');
$("#pullbranch").empty();
$("#pullbranch").attr("value", "Wait...");
$.ajax({
type: "POST",
url: $SCRIPT_ROOT + '/pullProjectFiles',
data: "project=" + $("input#workdir").val() + "/" + project,
success: function(data){
if(data.code == 1){
if (data.result != ""){
error(data.result);
}
else
error("Pull done!");
gitStatus();
}
else{
error(data.result);
}
$("#pullimgwaitting").hide()
$("#pullbranch").empty();
$("#pullbranch").attr("value", "Git Pull");
send = false;
}
});
return false;
});*/
function gitStatus(){ function gitStatus(){
var project = $("#project").val(); var project = $("#project").val();
$("#status").empty(); $("#status").empty();
......
...@@ -78,7 +78,7 @@ $(document).ready( function() { ...@@ -78,7 +78,7 @@ $(document).ready( function() {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: $SCRIPT_ROOT + '/saveFileContent', url: $SCRIPT_ROOT + '/saveFileContent',
data: "file=" + $("input#subfolder").val() + "&content=" + editor.getSession().getValue(), data: {file: $("input#subfolder").val(), content: editor.getSession().getValue()},
success: function(data){ success: function(data){
if(data.code == 1){ if(data.code == 1){
$("#flash").fadeOut('normal'); $("#flash").fadeOut('normal');
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
{{public_key}} {{public_key}}
</textarea> </textarea>
<p>to use git with https, please enter your repository url like this <p>to use git with https, please enter your repository url like this
<strong><i>https://your_login:your_passeword@your_repository_url</i></strong></p><br/><br/> <strong><i>https://your_login:your_password@your_repository</i></strong></p><br/><br/>
<div id="file_navigation"> <div id="file_navigation">
<h2>Your project folder</h2> <h2>Your project folder</h2>
<div id="fileTree" class="file_tree"></div> <div id="fileTree" class="file_tree"></div>
......
...@@ -27,18 +27,22 @@ ...@@ -27,18 +27,22 @@
<div id="branchlist" style="margin-bottom:20px;"> <div id="branchlist" style="margin-bottom:20px;">
<h2>Your Repository Branches</h2> <h2>Your Repository Branches</h2>
<div style="margin-left:15px;"> <div style="margin-left:15px;">
<label for='activebranch'>Select the active Branch here: </label> <label for='activebranch'>Select your active Branch: </label>
<select name="activebranch" id="activebranch"> <select name="activebranch" id="activebranch">
</select> </select>
&nbsp;&nbsp;&nbsp;<label for='branchname'>Branch Name: </label> &nbsp;&nbsp;<label for='branchname'>Branch Name: </label>
<input type="text" name="branchname" id="branchname" size='20' value="Enter the branch name..." /> <input type="text" name="branchname" id="branchname" size='22' value="Enter the branch name..." />
<input type="submit" name="addbranch" id ="addbranch" value="Add" class="button"/> <input type="submit" name="addbranch" id ="addbranch" value="Add" class="button"/>
<br/>
<!--<label for='pullbranch'>Update your local repository: </label>-->
<!--<input type="submit" name="pullbranch" id ="pullbranch" value="Pull" class="button"/>-->
<!--<img class="waitting" id="pullimgwaitting" src="{{ url_for('static', filename='images/waiting.gif') }}" alt="" />-->
</div> </div>
</div> </div>
<div id="push" style="margin-bottom:20px;"> <div id="push" style="margin-bottom:20px;">
<h2>Commit All your changes (On active branch)</h2> <h2>Commit All your changes (On active branch)</h2>
<div style="margin-left:15px;"> <div style="margin-left:15px;">
<label for='commitmsg'>Enter your commit message here: </label> <label for='commitmsg'>Commit message: </label>
<input type="text" name="commitmsg" id="commitmsg" size='40' value="Enter message..." /> <input type="text" name="commitmsg" id="commitmsg" size='40' value="Enter message..." />
<input type="submit" name="commit" id ="commit" value="Commit" class="button"/> <input type="submit" name="commit" id ="commit" value="Commit" class="button"/>
<img class="waitting" id="imgwaitting" src="{{ url_for('static', filename='images/waiting.gif') }}" alt="" /> <img class="waitting" id="imgwaitting" src="{{ url_for('static', filename='images/waiting.gif') }}" alt="" />
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
{% block body %} {% block body %}
<form method=post class=add-entry> <form method=post class=add-entry>
<dl> <dl>
<dt><strong>Note:</strong> Url of instance.cfg is <tt>{{ instance_url }}</tt></dt>
<dd><h2>Software Profile:</h2></dd> <dd><h2>Software Profile:</h2></dd>
<dd> <dd>
<div class="main_content"> <div class="main_content">
......
...@@ -185,7 +185,7 @@ def getProfile(peojectDir, profileName): ...@@ -185,7 +185,7 @@ def getProfile(peojectDir, profileName):
if os.path.exists(profile): if os.path.exists(profile):
return open(profile).read() return open(profile).read()
else: else:
return '' return None
def getProfilePath(peojectDir, profile): def getProfilePath(peojectDir, profile):
if not os.path.exists(os.path.join(peojectDir, ".project")): if not os.path.exists(os.path.join(peojectDir, ".project")):
...@@ -297,7 +297,8 @@ def getFolder(folder): ...@@ -297,7 +297,8 @@ def getFolder(folder):
def getProjectList(folder): def getProjectList(folder):
project = [] project = []
for elt in os.listdir(folder): project_list = sorted(os.listdir(folder), key=str.lower)
for elt in project_list:
project.append(elt) project.append(elt)
return project return project
......
...@@ -31,8 +31,7 @@ def editSoftwareProfile(): ...@@ -31,8 +31,7 @@ def editSoftwareProfile():
if profile == "": if profile == "":
flash('Error: can not open profile, please select your project first') flash('Error: can not open profile, please select your project first')
return render_template('updateSoftwareProfile.html', return render_template('updateSoftwareProfile.html',
profile=profile, profile=profile)
instance_url=url_for('getInstance', _external=True))
@app.route('/software.cfg', methods=['GET', 'POST']) @app.route('/software.cfg', methods=['GET', 'POST'])
def getSoftware(): def getSoftware():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment