Commit 317b1abf authored by Alain Takoudjou's avatar Alain Takoudjou

Fix utf-8 encoding problèm

parent 28be25ee
# -*- coding: utf-8 -*-
import slapos.slap
import time
import subprocess
......@@ -34,7 +36,7 @@ def cloneRepo(data):
config_writer = repo.config_writer()
config_writer.add_section("user")
if data["user"] != "":
config_writer.set_value("user", "name", data["user"])
config_writer.set_value("user", "name", data["user"].encode("utf-8"))
if data["email"] != "":
config_writer.set_value("user", "email", data["email"])
code = 1
......
......@@ -9,12 +9,9 @@
#tabContaier textarea {
width:702px;
resize: none;
white-space: pre-wrap;
word-wrap: break-word;
}
#tabContaier textarea.slap{color: #6F6F6F;width:430px; max-height:120px; height:18px;padding:3px;}
#tabContaier textarea.slap{white-space: pre-wrap;word-wrap: break-word;overflow: hidden;color: #6F6F6F;width:430px; max-height:120px;
resize: none; height:18px;padding:3px;min-height:18px;}
#tabContaier > ul{
overflow:hidden;
height:34px;
......
......@@ -44,6 +44,7 @@ $(document).ready( function() {
"</td><td valign='middle'><span style='margin-left: 10px;' id='btn_"+size+"' class='close'></span></td></tr>";
$("#partitionParameter").append(row);
setInput($("input#txt_"+size));
setupTextarea($("textarea#value_"+size));
$("#btn_"+size).click(function(){
var index = $(this).attr('id').split('_')[1];
$("tr#row_"+index).remove();
......@@ -101,6 +102,12 @@ $(document).ready( function() {
});
//Load previous instance parameters
loadParameter();
$("a#parameterTab").click(function(){
var size = $("#partitionParameter > tbody > tr").length;
for(var i=2; i<=size; i++){
$("textarea#value_"+i).keyup();
}
});
function setupFileTree(path){
var root = $("input#root").val();
......@@ -214,6 +221,20 @@ $(document).ready( function() {
}
});
}
function setupTextarea($txt){
var size = Number($txt.attr('id').split('_')[1]);
var hiddenDiv = $(document.createElement('div')),
content = null;
hiddenDiv.attr('id', 'div_'+size);
hiddenDiv.addClass('hiddendiv');
$('div#parameterkw').append(hiddenDiv);
$txt.keyup(function() {
content = $txt.val().replace(/\n/g, '<br>');
hiddenDiv.html(content);
if(hiddenDiv.height() > $txt.height() && hiddenDiv.height() > 120){return}
$txt.css('height', hiddenDiv.height()+"px");
});
}
function loadParameter(){
$.ajax({
type: "GET",
......@@ -226,6 +247,7 @@ $(document).ready( function() {
var size = Number($("#partitionParameter > tbody > tr").last().attr('id').split('_')[1]);
$("input#txt_"+size).val(propertie);
$("textarea#value_"+size).val(dict[propertie]);
$("textarea#value_"+size).keyup();
}
}
else{
......
......@@ -20,7 +20,7 @@
<ul>
<li><a href="#tab1" class="active">Slapgrid Supervisor</a></li>
<li><a href="#tab2">SLAP Response</a></li>
<li><a href="#tab3">Parameters</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">
......@@ -57,7 +57,7 @@
<div id="box{{item[0]}}" style="display:none;">
{% if item[1] %}
<h2><span style="float:left; margin-left:10px;" id="{{item[0]}}title">Slap Response for {{item[0]}}</span>
<a href="#" id="{{item[0]}}Parameter" rel="{{item[0]}}" class="lshare simple" style="float:right">Parameters</a>
<a href="#" id="{{item[0]}}Parameter" rel="{{item[0]}}" class="lshare simple" style="float:right" title='Restart all partition process'>Restart</a>
<a href="#" id="{{item[0]}}Files" rel="{{item[0]}}" class="lshare simple no-right-border" style="float:right">Files</a>
</h2>
<div class="clear"></div><br/>
......@@ -124,7 +124,7 @@
</div><!-- end tab3 -->
<div id="tab4" class="tabContents">
<h2>File content for all your partitions</h2>
<div id="fileTree" class="file_tree_tabs" alt="Double click to open file"></div>
<div id="fileTree" class="file_tree_tabs" title="Double click to open file"></div>
<br/>
<a href="#" id="reloadfiles" class="lshare simple">Reload Files</a>
</div><!-- end tab4 -->
......@@ -137,4 +137,5 @@
</div>
</div>
{{instance}}
{% endblock %}
# -*- coding: iso-8859-1 -*-
# -*- coding: utf-8 -*-
import slapos.slap
import time
......@@ -95,6 +95,8 @@ def updateProxy(config):
xml_result = readParameters(param_path)
partition_parameter_kw = None
if type(xml_result) != type('') and xml_result.has_key('instance'):
for item in xml_result['instance'].keys():
xml_result['instance'][item] = xml_result['instance'][item].decode('utf-8')
partition_parameter_kw = xml_result['instance']
computer.updateConfiguration(xml_marshaller.dumps(slap_config))
sr_request = slap.registerOpenOrder().request(profile, partition_reference=getSoftwareReleaseName(config),
......@@ -133,6 +135,8 @@ def updateInstanceParameter(config, software_type=None):
xml_result = readParameters(param_path)
partition_parameter_kw = None
if type(xml_result) != type('') and xml_result.has_key('instance'):
#for item in xml_result['instance'].keys():
# xml_result['instance'][item] = xml_result['instance'][item].decode('utf-8')
partition_parameter_kw = xml_result['instance']
slap.registerOpenOrder().request(profile, partition_reference=getSoftwareReleaseName(config),
partition_parameter_kw=partition_parameter_kw, software_type=software_type,
......@@ -634,8 +638,7 @@ def readParameters(path):
sub_object = {}
for subnode in elt.childNodes:
if subnode.nodeType != subnode.TEXT_NODE:
sub_object[str(subnode.getAttribute('id'))] = str(subnode.
childNodes[0].data)
sub_object[str(subnode.getAttribute('id'))] = subnode.childNodes[0].data #.decode('utf-8').decode('utf-8')
object[str(elt.tagName)] = sub_object
return object
except Exception, e:
......
......@@ -6,7 +6,6 @@ from utils import *
import os
import shutil
import md5
import codecs
from gittools import cloneRepo, gitStatus, switchBranch, addBranch, getDiff, \
gitPush, gitPull
......@@ -14,7 +13,8 @@ app = Flask(__name__)
@app.before_request
def before_request():
if not session.has_key('account') and request.path != '/login' \
if (not session.has_key('account') or not session['account']) \
and request.path != '/login' \
and request.path != '/doLogin' and not request.path.startswith('/static'):
return redirect(url_for('login'))
session['title'] = getProjectTitle(app.config)
......@@ -30,6 +30,16 @@ def home():
def login():
return render_template('login.html')
@app.route("/myAccount")
def myAccount():
return render_template('account.html', username=session['account'][0],
email=session['account'][2], name=session['account'][3])
@app.route("/logout")
def logout():
session['account'] = None
return redirect(url_for('login'))
@app.route('/configRepo')
def configRepo():
public_key = open(app.config['public_key'], 'r').read()
......@@ -290,7 +300,7 @@ def getFileContent():
def saveFileContent():
file_path = realpath(app.config, request.form['file'])
if file_path:
open(file_path, 'w').write(request.form['content'])
open(file_path, 'w').write(request.form['content'].encode("utf-8"))
return jsonify(code=1, result="")
else:
return jsonify(code=0, result="Error: No such file!")
......@@ -398,7 +408,7 @@ def saveParameterXml():
project = os.path.join(app.config['runner_workdir'], ".project")
if not os.path.exists(project):
return jsonify(code=0, result="Please first open a Software Release")
content = request.form['parameter']
content = request.form['parameter'].encode("utf-8")
param_path = os.path.join(app.config['runner_workdir'], ".parameter.xml")
try:
f = open(param_path, 'w')
......
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