Browser: Update UI with new components and elements (#5671)

This commit is contained in:
Rushan
2018-03-21 23:39:23 +05:30
committed by Harshavardhana
parent 384b4fdf28
commit 1459c4be1e
199 changed files with 10549 additions and 4702 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,31 +54,34 @@ 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)