sirius-common-utils 1.0.17 → 1.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -192,7 +192,6 @@ function getCurrUserInfoCache() {
|
|
|
192
192
|
if (currUserInfoCache != null) {
|
|
193
193
|
return currUserInfoCache;
|
|
194
194
|
}
|
|
195
|
-
console.debug("Please invoke getCurrUserInfo first");
|
|
196
195
|
return null;
|
|
197
196
|
}
|
|
198
197
|
function getCurrUserId() {
|
|
@@ -345,6 +344,36 @@ function downloadExcelData(url, data, headers, options = {}) {
|
|
|
345
344
|
}
|
|
346
345
|
});
|
|
347
346
|
}
|
|
347
|
+
function downloadImageData(url, data, headers, options = {}) {
|
|
348
|
+
return new Promise(async function(resolve, reject) {
|
|
349
|
+
headers = headers || {};
|
|
350
|
+
if (headers["Content-Type"] == null) {
|
|
351
|
+
headers["Content-Type"] = "application/json";
|
|
352
|
+
}
|
|
353
|
+
await buildUserAccessToken(headers);
|
|
354
|
+
try {
|
|
355
|
+
let response = await axios({
|
|
356
|
+
method: "post",
|
|
357
|
+
url,
|
|
358
|
+
data,
|
|
359
|
+
headers,
|
|
360
|
+
responseType: "blob"
|
|
361
|
+
});
|
|
362
|
+
let imageData = response.data;
|
|
363
|
+
if (imageData != null) {
|
|
364
|
+
if (response.data.errorCode && response.data.errorCode !== RESULT.SUCCESS) {
|
|
365
|
+
let errorResult = await handlerError(url, data, response);
|
|
366
|
+
resolve(null);
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
resolve(imageData);
|
|
371
|
+
} catch (e) {
|
|
372
|
+
await handlerError(url, {}, e);
|
|
373
|
+
resolve(null);
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
}
|
|
348
377
|
function downloadServerData(url) {
|
|
349
378
|
return new Promise(function(resolve, reject) {
|
|
350
379
|
const hyperlink = document.createElement("a");
|
|
@@ -544,6 +573,7 @@ const AxiosUtils = {
|
|
|
544
573
|
getJsonData,
|
|
545
574
|
postJsonData,
|
|
546
575
|
downloadExcelData,
|
|
576
|
+
downloadImageData,
|
|
547
577
|
downloadServerData,
|
|
548
578
|
uploadFile,
|
|
549
579
|
getStaticTextFile,
|
|
@@ -923,6 +953,11 @@ function convertTimestampToDateTimeText(timestamp) {
|
|
|
923
953
|
let text = convertMomentToDateTimeText(moments);
|
|
924
954
|
return text;
|
|
925
955
|
}
|
|
956
|
+
function convertTimestampToTimeText(timestamp) {
|
|
957
|
+
let moments = convertTimestampToMoment(timestamp);
|
|
958
|
+
let text = convertMomentToTimeText(moments);
|
|
959
|
+
return text;
|
|
960
|
+
}
|
|
926
961
|
function convertDateToMoment(date) {
|
|
927
962
|
if (!date) {
|
|
928
963
|
return null;
|
|
@@ -967,6 +1002,7 @@ const DateUtils = {
|
|
|
967
1002
|
convertTimestampToMoment,
|
|
968
1003
|
convertTimestampToDateText,
|
|
969
1004
|
convertTimestampToDateTimeText,
|
|
1005
|
+
convertTimestampToTimeText,
|
|
970
1006
|
convertDateToMoment,
|
|
971
1007
|
convertDateToDateText,
|
|
972
1008
|
convertDateToDateTimeText,
|
|
@@ -193,7 +193,6 @@
|
|
|
193
193
|
if (currUserInfoCache != null) {
|
|
194
194
|
return currUserInfoCache;
|
|
195
195
|
}
|
|
196
|
-
console.debug("Please invoke getCurrUserInfo first");
|
|
197
196
|
return null;
|
|
198
197
|
}
|
|
199
198
|
function getCurrUserId() {
|
|
@@ -346,6 +345,36 @@
|
|
|
346
345
|
}
|
|
347
346
|
});
|
|
348
347
|
}
|
|
348
|
+
function downloadImageData(url, data, headers, options = {}) {
|
|
349
|
+
return new Promise(async function(resolve, reject) {
|
|
350
|
+
headers = headers || {};
|
|
351
|
+
if (headers["Content-Type"] == null) {
|
|
352
|
+
headers["Content-Type"] = "application/json";
|
|
353
|
+
}
|
|
354
|
+
await buildUserAccessToken(headers);
|
|
355
|
+
try {
|
|
356
|
+
let response = await axios({
|
|
357
|
+
method: "post",
|
|
358
|
+
url,
|
|
359
|
+
data,
|
|
360
|
+
headers,
|
|
361
|
+
responseType: "blob"
|
|
362
|
+
});
|
|
363
|
+
let imageData = response.data;
|
|
364
|
+
if (imageData != null) {
|
|
365
|
+
if (response.data.errorCode && response.data.errorCode !== RESULT.SUCCESS) {
|
|
366
|
+
let errorResult = await handlerError(url, data, response);
|
|
367
|
+
resolve(null);
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
resolve(imageData);
|
|
372
|
+
} catch (e) {
|
|
373
|
+
await handlerError(url, {}, e);
|
|
374
|
+
resolve(null);
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
}
|
|
349
378
|
function downloadServerData(url) {
|
|
350
379
|
return new Promise(function(resolve, reject) {
|
|
351
380
|
const hyperlink = document.createElement("a");
|
|
@@ -545,6 +574,7 @@
|
|
|
545
574
|
getJsonData,
|
|
546
575
|
postJsonData,
|
|
547
576
|
downloadExcelData,
|
|
577
|
+
downloadImageData,
|
|
548
578
|
downloadServerData,
|
|
549
579
|
uploadFile,
|
|
550
580
|
getStaticTextFile,
|
|
@@ -924,6 +954,11 @@
|
|
|
924
954
|
let text = convertMomentToDateTimeText(moments);
|
|
925
955
|
return text;
|
|
926
956
|
}
|
|
957
|
+
function convertTimestampToTimeText(timestamp) {
|
|
958
|
+
let moments = convertTimestampToMoment(timestamp);
|
|
959
|
+
let text = convertMomentToTimeText(moments);
|
|
960
|
+
return text;
|
|
961
|
+
}
|
|
927
962
|
function convertDateToMoment(date) {
|
|
928
963
|
if (!date) {
|
|
929
964
|
return null;
|
|
@@ -968,6 +1003,7 @@
|
|
|
968
1003
|
convertTimestampToMoment,
|
|
969
1004
|
convertTimestampToDateText,
|
|
970
1005
|
convertTimestampToDateTimeText,
|
|
1006
|
+
convertTimestampToTimeText,
|
|
971
1007
|
convertDateToMoment,
|
|
972
1008
|
convertDateToDateText,
|
|
973
1009
|
convertDateToDateTimeText,
|