Commit 46a5ef82 authored by Nicolas Wavrant's avatar Nicolas Wavrant

Update slaprunner editor and repository layout

Conflicts:
	slapos/runner/views.py
parent 56cb1129
......@@ -17,7 +17,7 @@
overflow:hidden;
height:34px;
position:absolute;
z-index:100;
z-index:80;
}
#tabContaier > ul > li{
float:left;
......
......@@ -110,7 +110,7 @@ body {
height: 22px;
text-align: center;
color: #4c6172;
text-shadow: 0 1px 1px #fff;
text-shadow: 0 1px 1px #F1F1F1;
overflow: hidden;
}
#header .line{
......@@ -145,25 +145,6 @@ body {
margin-left: 28px;
}
#wmenu a.slapos_run{
background: url(../images/run_button.png) center no-repeat;
}
#wmenu a.slapos_run:hover{
background: #c2c2c2 url(../images/run_button2.png) center no-repeat;
}
#wmenu a.slapos_stop{
background: url(../images/stop_button.png) center no-repeat;
}
#wmenu a.slapos_stop:hover{
background: #c2c2c2 url(../images/stop_button2.png) center no-repeat;
}
#wmenu a.main_menu{
background: url(../images/main_menu.png) center no-repeat;
}
#wmenu a.main_menu:hover{
background: #c2c2c2 url(../images/main_menu_hover.png) center no-repeat;
}
#main
{
background: url(../images/main_bg_all.png) repeat-y;
......@@ -174,9 +155,9 @@ body {
.main_content{
position:relative;
width: 99.6%;
/*width: 99.6%;*/
height: 430px;
margin-top:10px;
margin-top:2px;
border:1px solid #4c6172;
overflow:auto;
}
......@@ -191,8 +172,8 @@ body {
background: url(../images/content.png) repeat-y;
width: 936px;
padding: 15px;
padding-top:0;
padding-bottom:0;
padding-top:1px;
padding-bottom:2px;
min-height: 400px;
}
......@@ -434,7 +415,7 @@ padding: 10px;height: 80px;padding-bottom:15px;}
.software_details{float: left;}
#details_box{
display:block;
margin-top:10px;
margin-top:2px;
}
#code{
float: right;
......@@ -443,7 +424,7 @@ padding: 10px;height: 80px;padding-bottom:15px;}
#details_head{margin-bottom: 10px;}
#contentInfo{
width: 926px;
width: 882px;
border: solid 1px #678dad;
background: #fff;
overflow: auto;
......@@ -599,7 +580,6 @@ h2.hight:hover{
color: #737373;
font-weight: bold;
text-shadow: 0px 1px #FFF;
margin-bottom: 9px;
font-size: 14px;
cursor:default;
word-wrap: break-word
......@@ -651,7 +631,8 @@ select {
overflow: hidden;
padding: 4px;
text-overflow: ellipsis;
white-space: nowrap;}
white-space: nowrap;
min-width: 80px;}
a.lshare{
background: #fff;
......@@ -679,6 +660,25 @@ a.no-right-border:focus{border-right:none}
a.lshare img{
margin: 5px;
}
.box_header{
background: #E4E4E4;
width: 100%;
height: 30px;
padding-top: 2px;
text-indent: 5px;
color: #737373;
text-shadow: 0px 1px #F1F1F1;
border-bottom: 3px solid #6DB9DD;
}
.box_header li{float: left;border: 1px solid #AAB8C2;padding: 1px 5px 1px 0;margin-left: 5px;}
.box_header li:last-child{border:none}
.box_header li h2{padding-top: 2px;}
.box_header li > span{cursor: pointer; height: 22px; display: block;line-height: 22px;font-weight: bold;padding: 1px;}
.box_header li:hover{border: 1px solid #57A1D6;background: #C7C7C7;}
.box_header li:last-child:hover{background:none; border: none}
.box_header li>a{font-weight: bold; font-size:15px;display: block;padding: 2px;}
.save_btn{background: url(../images/icon_save.png) center right no-repeat;width: 60px;}
.swith_btn{background: url(../images/gnome-session-switch.png) center right no-repeat;width: 105px;}
#error{
padding: 0px;
......
......@@ -42,8 +42,8 @@
}
.sf-menu ul {
box-shadow: 2px 2px 6px rgba(0,0,0,.2);
min-width: 14em; /* allow long menu items to determine submenu width */
*width: 14em; /* no auto sub width for IE7, see white-space comment below */
min-width: 16em; /* allow long menu items to determine submenu width */
*width: 16em; /* no auto sub width for IE7, see white-space comment below */
border: 1px solid #C2C2C2;
background: #E4E4E4;
border-left:none;
......@@ -70,6 +70,15 @@
width: 35px;
padding:7px;
}
.sf-menu li.main_menu{
background: url(../images/main_menu.png) center no-repeat;
}
.sf-menu li.slapos_run{
background: url(../images/run_button.png) center no-repeat;
}
.sf-menu li.slapos_stop{
background: url(../images/stop_button.png) center no-repeat;
}
.sf-menu li:hover,
.sf-menu li.sfHover {
color: #fff;/*#0271BF;*/
......@@ -78,6 +87,18 @@
-webkit-transition: none;
transition: none;
}
.sf-menu li.main_menu:hover,
.sf-menu li.main_menu.sfHover {
background: #c2c2c2 url(../images/main_menu_hover.png) center no-repeat;
}
.sf-menu li.slapos_stop:hover,
.sf-menu li.slapos_stop.sfHover{
background: #c2c2c2 url(../images/stop_button2.png) center no-repeat;
}
.sf-menu li.slapos_run:hover,
.sf-menu li.slapos_run.sfHover{
background: #c2c2c2 url(../images/run_button2.png) center no-repeat;
}
.sf-menu li a:hover{
color: #fff;
}
......
......@@ -25,6 +25,29 @@ $(document).ready(function () {
});
}
function fetchRepo(){
$("#project").empty();
$.post($SCRIPT_ROOT + "/listDirectory", {name: 'workspace'}, function (data) {
var result = data.result, i;
if (result.length > 0){
$("#repoEmpty").hide();
$("#repoContent").show();
for (i = 0; i < result.length; i += 1) {
$("#project").append("<option value='"+result[i]+"'>"+result[i]+"</option>")
}
$("#project").change();
}
else{
$("#repoEmpty").show();
$("#repoContent").hide();
}
})
.error(function () {
$("#error").Popup("unable to fetch your project list, please check your project folder", {type: 'error', duration: 5000});
})
.complete(function () {});
}
var send = false,
cloneRequest;
......@@ -39,6 +62,9 @@ $(document).ready(function () {
$("input#https").change(function () {
configRadio();
});
$("a#switchtoclone").click(function(){
$("#cloneTab").click();
});
$("#clone").click(function () {
if (send) {
cloneRequest.abort();
......@@ -130,9 +156,9 @@ $(document).ready(function () {
});
return false;
});
function selectFile(file) {
//nothing
return;
}
$("#gitTab").click(function(){
if (! $(this).hasClass('active')){
fetchRepo();
}
});
});
......@@ -42,10 +42,34 @@ $(document).ready(function () {
return;
}
function initTree(tree, path, key){
if (!key){
key = '0';
}
$(tree).fancytree({
activate: function(event, data) {
var node = data.node;
},
click: function(event, data) {
selectFile(data.node.data.path +"/");
},
source: {
url: $SCRIPT_ROOT + "/fileBrowser",
data:{opt: 20, dir: path, key: key, listfiles: ''},
cache: false
},
lazyload: function(event, data) {
var node = data.node;
data.result = {
url: $SCRIPT_ROOT + "/fileBrowser",
data: {opt: 20, dir: node.data.path , key: node.key, listfiles: ''}
}
},
});
}
if (method !== "file") {
$('#fileTree').fileTree({root: workdir, script: $SCRIPT_ROOT + '/openFolder', folderEvent: 'click', expandSpeed: 750, collapseSpeed: 750, multiFolder: false, selectFolder: true }, function (file) {
selectFile(file);
});
initTree('#fileTree', workdir);
}
$("input#subfolder").val("");
$("#create").click(function () {
......
......@@ -28,7 +28,6 @@ $(document).ready(function () {
function gitStatus() {
var project = $("#project").val(),
urldata = $("input#workdir").val() + "/" + project;
$("#status").empty();
$("#commit").hide();
$("#flash").empty();
......@@ -37,6 +36,9 @@ $(document).ready(function () {
$("#branchlist").hide();
return;
}
else if (project === undefined || project === null){
return;
}
send = true;
getStatus = $.ajax({
type: "POST",
......
......@@ -23,7 +23,7 @@ $(document).ready(function () {
selection = "",
edit_status = "",
base_path = function () {
return softwareDisplay ? projectDir : currentProject;
return softwareDisplay ? currentProject : 'workspace/';
};
......@@ -55,9 +55,9 @@ $(document).ready(function () {
if (data.code === 1) {
$("#edit_info").empty();
name = file.split('/');
if (file.length > 60) {
if (file.length > 80) {
//substring title.
start = file.length - 60;
start = file.length - 80;
path = "..." + file.substring(file.indexOf("/", (start + 1)));
}
$("#edit_info").append(" " + path);
......@@ -105,19 +105,21 @@ $(document).ready(function () {
function switchContent() {
if (!softwareDisplay) {
$("#switch").empty();
$("#switch").append("Switch to Profile&nbsp;");
$("span.swith_btn").empty();
$("span.swith_btn").append("This project");
$('#fileTreeFull').show();
$('#fileTree').hide();
} else {
$("#switch").empty();
$("#switch").append("Switch to Project");
$("span.swith_btn").empty();
$("span.swith_btn").append("Workspace");
$('#fileTree').show();
$('#fileTreeFull').hide();
}
$("#info").empty();
$("#info").append("Current work tree: " + base_path());
selection = "";
clipboardNode = null;
pasteMode = null;
}
function getmd5sum(path) {
......@@ -256,7 +258,7 @@ $(document).ready(function () {
if (data.indexOf('1') === -1) {
$("#error").Popup("Error: " + data, {type: 'error', duration: 5000});
} else {
$("#error").Popup("Operation complete!", {type: 'info', duration: 5000});
$("#error").Popup("Operation complete!", {type: 'confirm', duration: 5000});
}
},
error: function(jqXHR, exception) {
......@@ -488,16 +490,9 @@ $(document).ready(function () {
new Mode("python", "Python", require("ace/mode/python").Mode, ["py"]),
new Mode("buildout", "Python Buildout config", require("ace/mode/buildout").Mode, ["cfg"])
];
/*
$('#fileTree').fileTree({ root: projectDir, script: $SCRIPT_ROOT + script, folderEvent: 'click', expandSpeed: 750, collapseSpeed: 750, multiFolder: false, selectFolder: true }, function (file) {
selectFile(file);
}, function (file) { openFile(file); });*/
/*$("#fileTree").fancytree();*/
/*$('#fileTreeFull').fileTree({ root: currentProject, script: $SCRIPT_ROOT + script, folderEvent: 'click', expandSpeed: 750, collapseSpeed: 750, multiFolder: false, selectFolder: true }, function (file) {
selectFile(file);
}, function (file) { openFile(file); });*/
initTree('#fileTree', projectDir, 'pfolder');
initTree('#fileTreeFull', currentProject);
initTree('#fileTree', currentProject, 'pfolder');
initTree('#fileTreeFull', 'workspace');
$("#info").append("Current work tree: " + base_path());
/*setDetailBox();*/
......@@ -506,6 +501,14 @@ $(document).ready(function () {
$("span#edit_status").html("*");
}
});
editor.commands.addCommand({
name: 'myCommand',
bindKey: {win: 'Ctrl-S', mac: 'Command-S'},
exec: function(editor) {
$("#save").click();
},
readOnly: false // false if this command should not apply in readOnly mode
});
$("#save").click(function () {
if (!edit) {
......
......@@ -7,11 +7,11 @@
<script src="{{ url_for('static', filename='js/jquery/jqueryTabs.js') }}" type="text/javascript" charset="utf-8"></script>
{% endblock %}
{% block body %}
<h2>SlapOS web runner parameters</h2><br/>
<h2>Web runner parameters</h2><br/>
<div id="tabContaier">
<ul>
<li><a href="#tab1" class="active">Your personal information</a></li>
<li><a href="#tab2">Configurations</a></li>
<!--<li><a href="#tab2">Configurations</a></li>-->
</ul><!-- //Tab buttons -->
<div class="tabDetails">
<div id="tab1" class="tabContents">
......@@ -45,8 +45,8 @@
<input type="hidden" name="hasAccount" id="hasAccount" value="{{name}}"/>
</form>
</div>
<div id="tab2" class="tabContents">
</div>
<!--<div id="tab2" class="tabContents">
</div>-->
</div>
</div>
{% if username %}<div id="file_info" class="file_info">leave passwords blank to preserve your current password...
......
......@@ -4,7 +4,7 @@
<div id="home_box">
<div class="inner_box">
<div class="lmenu">
<h2><a href="{{ url_for('configRepo')}}">Clone a Repository into your local Workspace</a></h2>
<h2><a href="{{ url_for('manageRepository')}}#tab1">Clone a Repository into your local Workspace</a></h2>
<p>Your repository will be cloned into your project folder, you will need the url of the repository.
This allows you to open and edit your local project copy and synchronize content with online repository.
</p>
......@@ -18,7 +18,7 @@
<div class="clear"></div>
</div>
<div class="sright_menu">
<h2><a href="{{ url_for('manageProject')}}">Manage Repositories</a></h2>
<h2><a href="{{ url_for('manageRepository')}}#tab2">Manage Repositories</a></h2>
<p>You can view details of all repositories and commit your Software Release here.</p>
<img src="{{ url_for('static', filename='images/manage_repo.png') }}" />
</div>
......
......@@ -18,9 +18,9 @@
<h2>Instance inspection</h2><br/>
<div id="tabContaier">
<ul>
<li><a href="#tab1" class="active">Slapgrid Supervisor</a></li>
<li><a href="#tab2">SLAP Response</a></li>
<li><a href="#tab3" id="parameterTab">SLAP Parameters</a></li>
<li><a href="#tab1" class="active">Process</a></li>
<li><a href="#tab2">Connection Information</a></li>
<li><a href="#tab3" id="parameterTab">Parameters</a></li>
<li><a href="#tab4" id="instancetabfiles">Partitions Content</a></li>
</ul><!-- //Tab buttons -->
<div class="tabDetails">
......
......@@ -62,7 +62,7 @@
{% if request.path != '/login' %}
<div id="header">
<div class="block_header">
<a href="{{ url_for('home') }}" style="float:left;" id="home" {% if request.path != '/' %}rel="tooltip"{% endif %} title="Home"><img alt="" src="{{ url_for('static', filename='images/home.png') }}" /></a>
<a href="{{ url_for('home') }}" style="float:left;" id="home" title="Home"><img alt="" src="{{ url_for('static', filename='images/home.png') }}" /></a>
<div class="line"></div>
<a href="{{ url_for('dologout') }}" style="float:left" title="Close your session"><img alt="" src="{{ url_for('static', filename='images/logout.png') }}" /></a>
<h2 class="info">{% block title %}{% endblock %} - {{session.title}}</h2>
......@@ -77,16 +77,16 @@
<div id="wmenu">
<ul class="sf-menu">
<li><a href="{{ url_for('editCurrentProject') }}">Editor</a></li>
<li><a href="{{ url_for('browseWorkspace') }}">Services</a></li>
<li><a href="{{ url_for('runSoftwareProfile') }}" id="softrun">Logs</a></li>
<li><a href="{{ url_for('inspectInstance') }}">Services</a></li>
<li><a href="{{ url_for('viewInstanceLog') }}">Logs</a></li>
<li><a href="{{ url_for('viewSoftwareLog') }}">Terminal</a></li>
<li><a href="{{ url_for('inspectSoftware') }}">Git</a></li>
<li class='right_menu'><a class="main_menu" href="{{ url_for('viewInstanceLog') }}"></a>
<li><a href="{{ url_for('manageRepository')}}#tab2">Git</a></li>
<li class='right_menu main_menu'><a href="#"></a>
<ul>
<li><a href="{{ url_for('myAccount')}}">Parameters</a></li>
<li class='sep'></li>
<li><a href="#">Open Software Release</a></li>
<li><a href="#">Create Software Release</a></li>
<li><a href="{{ url_for('openProject', method='open')}}">Open Software Release</a></li>
<li><a href="{{ url_for('openProject', method='new')}}">Create Software Release</a></li>
<li class='sep'></li>
<li><a href="{{ url_for('browseWorkspace') }}">Browse Workspace</a></li>
<li><a href="{{ url_for('inspectSoftware') }}">My Softwares Releases</a></li>
......@@ -94,7 +94,8 @@
<li><a href="{{ url_for('dologout') }}">Log out</a></li>
</ul>
</li>
<li class='right_menu'><a class="slapos_run" href="{{ url_for('runInstanceProfile') }}" id="instrun"></a>
<li class='right_menu slapos_run'><a href="{{ url_for('runInstanceProfile') }}" id="instrun"></a>
<!--<li><a href="{{ url_for('viewInstanceLog') }}" id="softrun">Logs</a></li>-->
</li>
</ul>
</div>
......@@ -139,16 +140,5 @@
</tr>
</tbody></table>
</div>
<div id="tooltip-home" style="display:none">
<span style="font-weight:bold">QUICK ACCESS TO MENU</span><br/><br/>
<div style="margin-top:3px;border-bottom: 1px dashed #666666; heigth:1px"></div>
<ul class="menu">
<li><a href="{{ url_for('manageProject')}}">Manage Repositories</a></li>
<li><a href="{{ url_for('configRepo')}}" >Clone your repository</a></li>
<li><a href="{{ url_for('openProject', method='open')}}">Open Software Release</a></li>
<li><a href="{{ url_for('openProject', method='new')}}">Create Software Release</a></li>
<li style="heigth:1px"></li>
</ul>
</div>
</body>
</html>
......@@ -2,7 +2,6 @@
{% block title %}Manage your Project{% endblock %}
{% block head %}
{{ super() }}
<script src="{{ url_for('static', filename='js/jquery/jqueryFileTree.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/scripts/repo.js') }}" type="text/javascript" charset="utf-8"></script>
{% endblock %}
{% block body %}
......
......@@ -6,17 +6,18 @@
<link href="{{ url_for('static', filename='css/jqueryTabs.css', _external=False) }}" rel="stylesheet" type="text/css" media="screen" />
<link href="{{ url_for('static', filename='css/colorbox.css', _external=False) }}" rel="stylesheet" type="text/css" media="screen" />
<script src="{{ url_for('static', filename='js/jquery/gsFileManager.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/scripts/folder.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/scripts/cloneRepo.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/scripts/repo.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/jquery/jqueryTabs.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/jquery/jquery.colorbox-min.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/ace/ace.js') }}" type="text/javascript" charset="utf-8"></script>
{% endblock %}
{% block body %}
<h2>Clone a project repository into your workspace</h2><br/>
<div id="tabContaier">
<ul>
<li><a href="#tab1" class="active">Clone your repository</a></li>
<li><a href="#tab2">Manage your project folder</a></li>
<li><a href="#tab1" class="active" id="cloneTab">Clone repository</a></li>
<li><a href="#tab2" id="gitTab">Manage (GIT)</a></li>
<li><a href="#tab3">Browse</a></li>
</ul><!-- //Tab buttons -->
<div class="tabDetails">
<div id="tab1" class="tabContents">
......@@ -74,6 +75,55 @@
<!--Fin tab1-->
</div>
<div id="tab2" class="tabContents">
<form action="" method=post>
<input type="hidden" name="subfolder" id="subfolder" value="" />
<h2 style="{% if project %}display:none{% endif %}" id="repoEmpty">
Your repository folder is empty. <a id="switchtoclone">Click here</a> to create a new one!
</h2>
<div id="repoContent" style="{% if not project %}display:none{% endif %}">
<label for='project'>Current Repository: </label>
<select id="project" name="project">
{% for folder in project%}
<option value="{{folder}}">{{folder}}</option>
{% endfor %}
</select>
<a id="switchtoclone" class="lshare">&nbsp;New repository&nbsp;</a>
<br/><br/>
<div id="contentInfo">
<div id="status" style="margin-bottom:20px;">
<h2>Please select one project...</h2>
</div>
<div id="branchlist" style="margin-bottom:20px;">
<h2>Your Repository Branches</h2>
<div style="margin-left:15px;">
<label for='activebranch'>Select your active Branch: </label>
<select name="activebranch" id="activebranch">
</select>
&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" title='add new branch: git checkout -b branch'/>
<input type="submit" name="docheckout" id ="docheckout" value="Checkout" class="button" title='add existing branch: git checkout branch'/>
<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'>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="" />
</div>
</div>
<br/>
</div>
</div>
</form>
</div>
<div id="tab3" class="tabContents">
<div id="fileNavigator"></div>
</div>
</div>
......
......@@ -2,8 +2,8 @@
{% block title %}{% if method == "new" %}Adding new software{%else%}Open existing project{%endif%}{% endblock %}
{% block head %}
{{ super() }}
<link href="{{ url_for('static', filename='css/jqueryFileTree.css', _external=False) }}" rel="stylesheet" type="text/css" media="screen" />
<script src="{{ url_for('static', filename='js/jquery/jqueryFileTree.js') }}" type="text/javascript" charset="utf-8"></script>
<link href="{{ url_for('static', filename='css/ui.fancytree.css', _external=False) }}" rel="stylesheet" type="text/css" media="screen" />
<script src="{{ url_for('static', filename='js/jquery/jquery.fancytree.min.js') }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/scripts/project.js') }}" type="text/javascript" charset="utf-8"></script>
{% endblock %}
{% block body %}
......
......@@ -39,23 +39,29 @@
</ul>
<div id="software_folder">
<div>
<ul class='box_header'>
<li id="switch"><span class="swith_btn" title="Switch between differents file source">Workspace</span></li>
<li id="save"><span class="save_btn" title="Save current file. Hint: Use Ctrl+S">Save</span></li>
<li>
<h2>
<a style="display:none" id='option' href='#' rel='tooltip' title='Show more option'>[Current file]</a><span id="edit_info">No file in editor</span>
<span id="edit_status"></span>
</h2>
</li>
</ul>
<!--<a href="#" id="clearselect" class="lshare no-right-border" style="float:left">Clean</a>-->
<div class="clear"></div>
</div>
<div class="software_details">
<div>
<a href="#" id="switch" class="lshare no-right-border" style="float:left">Switch to Project</a>
<a href="#" id="clearselect" class="lshare no-right-border" style="float:left">Reset</a>
<a href="#" id="save" class="lshare" style="float:left">Save</a>
<div class="clear"></div>
</div>
<div id="details_box">
<div id="fileTree" class="file_tree_short"></div>
<div id="fileTreeFull" style='display:none' class="file_tree_short"></div>
</div>
</div>
<div id="code">
<h2 class='title'>
<a style="display:none" id='option' href='#' rel='tooltip' title='Show more option'>[Current file]</a><span id="edit_info">No file in editor</span>
<span id="edit_status"></span>
</h2>
<div class="main_content">
<pre id="editor">
......@@ -67,13 +73,12 @@
</div>
<div class="clear"></div>
<div id="file_info" class="file_info"><span id="info"></span></div>
<br/>
</form>
<div id="tooltip-option" style="display:none">
<span class="list first-list">MD5 SUM for the current file</span>
<a id='getmd5' href="#">Get or Update md5sum</a>
<div class="sep"></div>
<span class="list">Add Project to Develop</span>
<span class="list">Add project development</span>
<ul id="plist">
{% for name in projectList%}
<li><input type="checkbox" name="develop" value="{{name}}" id="{{name}}">
......
......@@ -450,94 +450,22 @@ def svcStartStopProcess(config, process, action):
cmd[action], process]).communicate()[0]
def getFolderContent(config, folder):
"""
Read all file and folder into specified directory
Args:
config: Slaprunner configuration.
folder: the directory to read.
Returns:
Html formatted string or error message when fail.
"""
r = ['<ul class="jqueryFileTree" style="display: none;">']
try:
folder = str(folder)
r = ['<ul class="jqueryFileTree" style="display: none;">']
d = urllib.unquote(folder)
realdir = realpath(config, d)
if realdir:
ldir = sorted(os.listdir(realdir), key=str.lower)
else:
r.append('Could not load directory: Permission denied')
ldir = []
for f in ldir:
if f.startswith('.'): # do not displays this file/folder
continue
ff = os.path.join(d, f)
if os.path.isdir(os.path.join(realdir, f)):
r.append('<li class="directory collapsed"><a href="#%s" rel="%s/">%s</a></li>' % (ff, ff, f))
else:
e = os.path.splitext(f)[1][1:] # get .ext and remove dot
r.append('<li class="file ext_%s"><a href="#%s" rel="%s">%s</a></li>' % (e, ff, ff, f))
r.append('</ul>')
except Exception as e:
r.append('Could not load directory: %s' % str(e))
r.append('</ul>')
return jsonify(result=''.join(r))
def getFolder(config, folder):
"""
Read list of folder for the specified directory
Args:
config: Slaprunner configuration.
folder: the directory to read.
Returns:
Html formatted string or error message when fail.
"""
r = ['<ul class="jqueryFileTree" style="display: none;">']
try:
folder = str(folder)
r = ['<ul class="jqueryFileTree" style="display: none;">']
d = urllib.unquote(folder)
realdir = realpath(config, d)
if not realdir:
r.append('Could not load directory: Permission denied')
ldir = []
else:
ldir = sorted(os.listdir(realdir), key=str.lower)
for f in ldir:
if f.startswith('.'): # do not display this file/folder
continue
ff = os.path.join(d, f)
if os.path.isdir(os.path.join(realdir, f)):
r.append('<li class="directory collapsed"><a href="#%s" rel="%s/">%s</a></li>' % (ff, ff, f))
r.append('</ul>')
except Exception as e:
r.append('Could not load directory: %s' % str(e))
r.append('</ul>')
return jsonify(result=''.join(r))
def getProjectList(folder):
"""Return the list of projet (folder) into the workspace
def listFolder(config, path):
"""Return the list of folder into path
Agrs:
folder: path of the workspace
path: path of the directory to list
Returns:
a list that contains each folder name.
"""
project = []
project_list = sorted(os.listdir(folder), key=str.lower)
for elt in project_list:
if os.path.isdir(os.path.join(folder, elt)):
project.append(elt)
return project
folderList = []
folder = realpath(config, path)
if folder:
path_list = sorted(os.listdir(folder), key=str.lower)
for elt in path_list:
if os.path.isdir(os.path.join(folder, elt)):
folderList.append(elt)
return folderList
def configNewSR(config, projectpath):
......
......@@ -13,9 +13,8 @@ from flask import (Flask, request, redirect, url_for, render_template,
g, flash, jsonify, session, abort, send_file)
from slapos.runner.process import killRunningProcess
from slapos.runner.utils import (checkSoftwareFolder, configNewSR, getFolder,
getFolderContent, getProfilePath,
getProjectList, getProjectTitle, getSession,
from slapos.runner.utils import (checkSoftwareFolder, configNewSR, getProfilePath,
listFolder, getProjectTitle, getSession,
getSlapStatus, getSvcStatus,
getSvcTailProcess, isInstanceRunning,
isSoftwareRunning, isSoftwareReleaseReady, isText,
......@@ -95,10 +94,11 @@ def dologout():
return redirect(url_for('login'))
def configRepo():
def manageRepository():
public_key = open(app.config['public_key']).read()
account = getSession(app.config)
return render_template('cloneRepository.html', workDir='workspace',
return render_template('manageRepository.html', workDir='workspace',
project=listFolder(app.config, 'workspace'),
public_key=public_key, name=account[3].decode('utf-8'),
email=account[2])
......@@ -257,12 +257,9 @@ def cloneRepository():
return cloneRepo(data)
def readFolder():
return getFolderContent(app.config, request.form['dir'])
def openFolder():
return getFolder(app.config, request.form['dir'])
def listDirectory():
folderList = listFolder(app.config, request.form['name'])
return jsonify(result=folderList)
def createSoftware():
......@@ -300,7 +297,7 @@ def editCurrentProject():
if os.path.exists(project):
return render_template('softwareFolder.html', workDir='workspace',
project=open(project).read(),
projectList=getProjectList(app.config['workspace']))
projectList=listFolder(app.config, 'workspace'))
return redirect(url_for('configRepo'))
......@@ -728,9 +725,8 @@ app.add_url_rule('/createSoftware', 'createSoftware', createSoftware,
methods=['POST'])
app.add_url_rule('/cloneRepository', 'cloneRepository', cloneRepository,
methods=['POST'])
app.add_url_rule('/openFolder', 'openFolder', openFolder, methods=['POST'])
app.add_url_rule('/readFolder', 'readFolder', readFolder, methods=['POST'])
app.add_url_rule('/configRepo', 'configRepo', configRepo)
app.add_url_rule('/listDirectory', 'listDirectory', listDirectory, methods=['POST'])
app.add_url_rule('/manageRepository', 'manageRepository', manageRepository)
app.add_url_rule("/saveParameterXml", 'saveParameterXml', saveParameterXml,
methods=['POST'])
app.add_url_rule("/getPath", 'getPath', getPath, methods=['POST'])
......
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