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):
if name == current_branch:
json = "This is already your active branch for this project"
else:
i = 0
json = "Error: Can not found branch '" + name + "'"
repo.heads.master.checkout()
for b in branches:
if b.name == name:
repo.heads[i].checkout()
code = 1
json = ""
break
i = i + 1
git = repo.git
git.checkout(name)
except Exception, e:
json = str(e)
return jsonify(code=code, result=json)
......@@ -84,7 +77,8 @@ def createBranch(project, name):
json = ""
try:
repo = Repo(project)
b = repo.create_head(name)
git = repo.git
git.checkout('-b', name)
code = 1
except Exception, e:
json = str(e)
......@@ -101,25 +95,22 @@ def getDiff(project):
result = str(e)
return result
def gitPush(project, msg, fetch=False):
def gitPush(project, msg):
code = 0
json = ""
commit = False
undo_commit = False
try:
repo = Repo(project)
if repo.is_dirty:
git = repo.git
current_branch = repo.active_branch.name
current_branch = repo.active_branch.name
#add file to be commited
files = repo.untracked_files
for f in files:
git.add(f)
#Commit all modified and untracked files
git.commit('-a', '-m', msg)
commit = True
if fetch:
git.fetch('--all')
git.rebase('origin/' + current_branch)
undo_commit = True
#push changes to repo
git.push('origin', current_branch)
code = 1
......@@ -127,7 +118,20 @@ def gitPush(project, msg, fetch=False):
json = "Nothing to be commited"
code = 1
except Exception, e:
if commit:
if undo_commit:
git.reset("HEAD^1") #undo previous commit
json = str(e)
return jsonify(code=code, result=json)
\ No newline at end of file
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
......@@ -454,7 +454,8 @@ body {
margin: 5px;
}
#contentInfo h2, .hight{
#contentInfo h2, .hight{
background: #e4e4e4;
width: 100%;
height: 25px;
padding-top:2px;
......@@ -463,11 +464,11 @@ body {
text-shadow: 0px 1px #FFF;
}
#contentInfo h2, .show{
.show{
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;
}
......
......@@ -67,7 +67,7 @@ $(document).ready( function() {
$.ajax({
type: "POST",
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){
if(data.code == 1){
if (data.result != ""){
......@@ -88,6 +88,40 @@ $(document).ready( function() {
});
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(){
var project = $("#project").val();
$("#status").empty();
......
......@@ -78,7 +78,7 @@ $(document).ready( function() {
$.ajax({
type: "POST",
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){
if(data.code == 1){
$("#flash").fadeOut('normal');
......
......@@ -28,7 +28,7 @@
{{public_key}}
</textarea>
<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">
<h2>Your project folder</h2>
<div id="fileTree" class="file_tree"></div>
......
......@@ -27,18 +27,22 @@
<div id="branchlist" style="margin-bottom:20px;">
<h2>Your Repository Branches</h2>
<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>
&nbsp;&nbsp;&nbsp;<label for='branchname'>Branch Name: </label>
<input type="text" name="branchname" id="branchname" size='20' value="Enter the branch name..." />
&nbsp;&nbsp;<label for='branchname'>Branch Name: </label>
<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"/>
<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 id="push" style="margin-bottom:20px;">
<h2>Commit All your changes (On active branch)</h2>
<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="submit" name="commit" id ="commit" value="Commit" class="button"/>
<img class="waitting" id="imgwaitting" src="{{ url_for('static', filename='images/waiting.gif') }}" alt="" />
......
......@@ -10,7 +10,6 @@
{% block body %}
<form method=post class=add-entry>
<dl>
<dt><strong>Note:</strong> Url of instance.cfg is <tt>{{ instance_url }}</tt></dt>
<dd><h2>Software Profile:</h2></dd>
<dd>
<div class="main_content">
......
......@@ -185,7 +185,7 @@ def getProfile(peojectDir, profileName):
if os.path.exists(profile):
return open(profile).read()
else:
return ''
return None
def getProfilePath(peojectDir, profile):
if not os.path.exists(os.path.join(peojectDir, ".project")):
......@@ -297,7 +297,8 @@ def getFolder(folder):
def getProjectList(folder):
project = []
for elt in os.listdir(folder):
project_list = sorted(os.listdir(folder), key=str.lower)
for elt in project_list:
project.append(elt)
return project
......
......@@ -31,8 +31,7 @@ def editSoftwareProfile():
if profile == "":
flash('Error: can not open profile, please select your project first')
return render_template('updateSoftwareProfile.html',
profile=profile,
instance_url=url_for('getInstance', _external=True))
profile=profile)
@app.route('/software.cfg', methods=['GET', 'POST'])
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