revert browser newux changes (#5714)

This commit is contained in:
Kanagaraj M
2018-03-27 01:19:12 +05:30
committed by Dee Koder
parent 35e64573fa
commit 19451e374a
186 changed files with 4507 additions and 16033 deletions

View File

@@ -14,37 +14,37 @@
* limitations under the License.
*/
import SuperAgent from "superagent-es6-promise"
import url from "url"
import Moment from "moment"
import SuperAgent from 'superagent-es6-promise';
import url from 'url'
import Moment from 'moment'
export default class JSONrpc {
constructor(params) {
this.endpoint = params.endpoint
this.namespace = params.namespace
this.version = "2.0"
this.version = '2.0';
const parsedUrl = url.parse(this.endpoint)
this.host = parsedUrl.hostname
this.path = parsedUrl.path
this.port = parsedUrl.port
switch (parsedUrl.protocol) {
case "http:": {
this.scheme = "http"
case 'http:': {
this.scheme = 'http'
if (parsedUrl.port === 0) {
this.port = 80
}
break
}
case "https:": {
this.scheme = "https"
case 'https:': {
this.scheme = 'https'
if (parsedUrl.port === 0) {
this.port = 443
}
break
}
default: {
throw new Error("Unknown protocol: " + parsedUrl.protocol)
throw new Error('Unknown protocol: ' + parsedUrl.protocol)
}
}
}
@@ -54,34 +54,31 @@ export default class JSONrpc {
options = {}
}
if (!options.id) {
options.id = 1
options.id = 1;
}
if (!options.params) {
options.params = {}
options.params = {};
}
const dataObj = {
id: options.id,
jsonrpc: this.version,
params: options.params ? options.params : {},
method: this.namespace ? this.namespace + "." + method : method
method: this.namespace ? this.namespace + '.' + method : method
}
let requestParams = {
host: this.host,
port: this.port,
path: this.path,
scheme: this.scheme,
method: "POST",
method: 'POST',
headers: {
"Content-Type": "application/json",
"x-amz-date":
Moment()
.utc()
.format("YYYYMMDDTHHmmss") + "Z"
'Content-Type': 'application/json',
'x-amz-date': Moment().utc().format('YYYYMMDDTHHmmss') + 'Z'
}
}
if (token) {
requestParams.headers.Authorization = "Bearer " + token
requestParams.headers.Authorization = 'Bearer ' + token
}
let req = SuperAgent.post(this.endpoint)