Skip to content

Commit

Permalink
more porting work in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Peck committed Sep 12, 2016
1 parent 29fef66 commit e4d71ad
Show file tree
Hide file tree
Showing 6 changed files with 196 additions and 6 deletions.
98 changes: 98 additions & 0 deletions html/ui/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -3532,3 +3532,101 @@ body > .header .navbar {
padding-top: 15px;
padding-bottom: 15px;
}

.grayadder{
background-color: rgb(235, 235, 235);
color: rgb(179, 179, 179) !important;
padding-top: 15px;
}
.hb2 {
margin-bottom: 16px !important;
margin-top: 0px !important;
}
.updowngap {
padding-top:7px;
padding-bottom:7px;
}
.sparkcell {
width: 200px; text-align: center;line-height: 16px;
}
.sparkbeautycell
{
font-size: small;
padding: 10px;
margin-top: 20px;
}
.statetable {
width:300px; padding: 10px;
}



.work-image-type {
float: left;
padding-right: 15px;
height:68px;
}

.larger-sidebar-element {
height: 100px;
}

.betterh4 {
font-family: sans-serif;
font-size: 14px;

}

.agopullright {
float: right !important;
padding-top: 0px;
line-height: 1.1;
box-sizing: border-box;
}

.middletext_list {
display: block;
color: #999;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
height: 100%;
padding-top: 14px;
}

.label12px{
font-size: 12px;
}

.smsm {
width: 150px;
margin-left: 201px;
margin-top: -8px;
}

.margin5px {
margin-right: 5px;
}

.padding10 {
padding-left: 10px;
}
.misalignedbutton {
margin-top: 9px;
line-height: 7px;
padding-top: 10px;
padding-bottom: 12px;
height: 31px;

}
.linkfloater{
float:left;
margin-right: 4px;
}
.padtop7{
padding-top: 7px !important;
}
.composelabel{
padding-top: 20px;
margin-left: 90px;
}
9 changes: 9 additions & 0 deletions html/ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<link href="css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="css/ionicons.min.css" rel="stylesheet" type="text/css" />
<link href="css/app.css" rel="stylesheet" type="text/css" />
<link href="css/fileinput.css" rel="stylesheet" type="text/css" />
<style id="user_header_style" type="text/css"></style>
<style id="user_sidebar_style" type="text/css"></style>
<style id="user_boxes_style" type="text/css"></style>
Expand Down Expand Up @@ -81,6 +82,11 @@
<script src="js/3rdparty/date.format.js" type="text/javascript"></script>
<script src="js/3rdparty/async.js" type="text/javascript"></script>
<script src="js/3rdparty/html5-qrcode.js" type="text/javascript"></script>
<script src="js/fileinput.min.js" type="text/javascript"></script>
<script src="js/jquery.flot.min.js" type="text/javascript"></script>
<script src="js/jquery.flot.resize.min.js" type="text/javascript"></script>
<script src="js/jquery.flot.time.min.js" type="text/javascript"></script>
<script src="js/jquery.sparkline.min.js" type="text/javascript"></script>
<script src="js/sha1.js"></script>
<script src="js/jdenticon-1.3.2.min.js" type="text/javascript"></script>
<script src="js/nrs.constants.js" type="text/javascript"></script>
Expand All @@ -98,6 +104,7 @@
NRS.loadPageHTML("html/pages/transactions.html");
NRS.loadPageHTML("html/pages/contacts.html");
NRS.loadPageHTML("html/pages/messages.html");
NRS.loadPageHTML("html/pages/myownwork.html");
NRS.loadPageHTML("html/pages/blocks.html");
NRS.loadPageHTML("html/pages/peers.html");
NRS.loadPageHTML("html/pages/news.html");
Expand All @@ -111,6 +118,7 @@
NRS.loadModalHTML("html/modals/contacts.html");
NRS.loadModalHTML("html/modals/messages.html");
NRS.loadModalHTML("html/modals/peers.html");
NRS.loadModalHTML("html/modals/work.html");
NRS.loadModalHTML("html/modals/account_control.html");
NRS.loadModalHTML("html/modals/monitors.html");
NRS.loadModalHTMLTemplates();
Expand All @@ -137,6 +145,7 @@
<script src="js/nrs.blocks.js" type="text/javascript"></script>
<script src="js/nrs.transactions.types.js" type="text/javascript"></script>
<script src="js/nrs.transactions.js" type="text/javascript"></script>
<script src="js/nrs.myownwork.js" type="text/javascript"></script>
<script src="js/nrs.notifications.js" type="text/javascript"></script>
<script src="js/nrs.peers.js" type="text/javascript"></script>
<script src="js/nrs.contacts.js" type="text/javascript"></script>
Expand Down
14 changes: 14 additions & 0 deletions html/ui/js/nrs.forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,20 @@ var NRS = (function(NRS, $) {
}
}

// handle file upload in create work function
if (requestType == "createWork"){
var files = $('#source_code').fileinput('getFileStack'); // returns file list selected
if(files.length!=1){
$form.find(".error_message").html($.t("no_source_code")).show();
if (formErrorFunction) {
formErrorFunction(false, data);
}
NRS.unlockForm($modal, $btn);
return;
}
// add source code to data object
data["source_code"] = files[0];
}
if (requestType == "sendMoney" || requestType == "transferAsset") {
var merchantInfo = $modal.find("input[name=merchant_info]").val();
if (merchantInfo) {
Expand Down
67 changes: 62 additions & 5 deletions html/ui/js/nrs.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,60 @@
/**
* @depends {nrs.js}
*/
function parseFormData(model){
var formData = new FormData();

function parseArray(arrayKey, arrayValue){
if ($.type(arrayValue) !== undefined) {
if($.type(arrayValue[0]) === 'string'){
parseAttribute(arrayKey, arrayValue)
} else {
$.each(arrayValue, function loopArray(attributeKey, attributeValue) {
parseModel(arrayKey+'['+attributeKey+']', attributeValue);
});
}
}
}

function parseObject(objectKey, objectValue){
if ($.type(objectValue) !== undefined) {
$.each(objectValue, function loopObject(attributeKey, attributeValue) {
parseAttribute(objectKey+'['+attributeKey+']', attributeValue);
});
}
}

function parseAttribute(attributeKey, attributeValue){

if (attributeValue !== undefined ) {
if($.type(attributeValue) === 'array' && $.type(attributeValue[0]) !== 'string'){
parseArray(attributeKey, attributeValue)
}
else if($.isPlainObject(attributeValue) ){
parseObject(attributeKey, attributeValue)
}
else {
formData.append(attributeKey, attributeValue);
}
}
}

function parseModel(keyString, model){
$.each(model, function loopModel(inputKey, inputValue) {
parseAttribute(keyString !== '' ? keyString+'['+inputKey+']' : inputKey, inputValue);
});
}

parseModel('', model);

return formData;
}

var NRS = (function (NRS, $, undefined) {
var _password;



NRS.setServerPassword = function (password) {
_password = password;
};
Expand Down Expand Up @@ -274,13 +325,15 @@ var NRS = (function (NRS, $, undefined) {
currentSubPage = NRS.currentSubPage;
}

var type = (NRS.isRequirePost(requestType) || "secretPhrase" in data || "doNotSign" in data || "adminPassword" in data ? "POST" : "GET");
var type = (NRS.isRequirePost(requestType) || "secretPhrase" in data || "doNotSign" in data || "adminPassword" in data || ("source_code" in data) ? "POST" : "GET");
var url = NRS.getRequestPath();
if (noProxy) {
url = "/nxt";
}
url += "?requestType=" + requestType;

var subtype = ("source_code" in data) ? "MULTIPART" : "";

if (type == "GET") {
if (typeof data == "string") {
data += "&random=" + Math.random();
Expand Down Expand Up @@ -385,8 +438,7 @@ var NRS = (function (NRS, $, undefined) {
contentType = "application/x-www-form-urlencoded; charset=UTF-8";
processData = true;
}

$.ajax({
var callDict = {
url: url,
crossDomain: true,
dataType: "json",
Expand All @@ -397,10 +449,15 @@ var NRS = (function (NRS, $, undefined) {
currentSubPage: currentSubPage,
shouldRetry: (type == "GET" ? 2 : undefined),
traditional: true,
data: (formData != null ? formData : data),
data: (formData != null ? (type=="POST" && subtype=="MULTIPART")?parseFormData(formData):formData : (type=="POST" && subtype=="MULTIPART")?parseFormData(data):data),
contentType: contentType,
processData: processData
}).done(function (response) {
};
if (type=="POST" && subtype=="MULTIPART"){
callDict["contentType"]=false;
callDict["cache"]=false;
}
$.ajax(callDict).done(function (response) {
NRS.escapeResponseObjStrings(response);
if (NRS.console) {
NRS.addToConsole(this.url, this.type, this.data, response);
Expand Down
5 changes: 5 additions & 0 deletions html/ui/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@
"Currency Distribution": "Currency Distribution",
"Date": "Date",
"Initial_supply": "Initial Supply",
"no_source_code": "You have to provide a source code file containing your work",
"Not Connected": "Not Connected",
"Price": "Price",
"Quantity": "Quantity",
"Rate": "Rate",
"Refund Note": "Refund Note",
"Send Currency": "Send Currency",
"deadline_blocks":"WORK DEADLINE (BLOCKS)",
"Total": "Total",
"Transfer Currency": "Transfer Currency",
"Type": "Type",
"Units": "Units",
"account": "Account",
"work_status": "Work Status",
"work_control": "Work Control",
"work_author": "Work Management",
"work_worker" : "Mining Overview",
"account_balance": "Account Balance",
"account_details": "Account Details",
"account_has_no_assets": "Account has no assets",
Expand Down
9 changes: 8 additions & 1 deletion src/java/nxt/http/APIEnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,14 @@ public enum APIEnum {
SET_API_PROXY_PEER("setAPIProxyPeer", SetAPIProxyPeer.instance),
SEND_TRANSACTION("sendTransaction", SendTransaction.instance),
BLACKLIST_API_PROXY_PEER("blacklistAPIProxyPeer", BlacklistAPIProxyPeer.instance),
GET_NEXT_BLOCK_GENERATORS("getNextBlockGenerators", GetNextBlockGeneratorsTemp.instance);
GET_NEXT_BLOCK_GENERATORS("getNextBlockGenerators", GetNextBlockGeneratorsTemp.instance),
CREATE_WORK("createWork", CreateWork.instance),
CANCEL_WORK("cancelWork", CancelWork.instance),
CREATE_POX("createPoX", ProofOfX.instance),
GET_ACCOUNT_WORK("getAccountWork", GetAccountWork.instance),
GET_ACCOUNT_EFFICIENCY("getAccountWorkEfficiencyPlot", GetAccountWorkEfficiencyPlot.instance),
GET_MINEABLE_WORK("getMineableWork", GetMineableWork.instance),
GET_POW_BOUNDS("getPowPayoutBounds", GetPowPayoutBounds.instance);

private static final Map<String, APIEnum> apiByName = new HashMap<>();

Expand Down

0 comments on commit e4d71ad

Please sign in to comment.