sirius-common-utils 1.0.16 → 1.0.18

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() {
@@ -248,6 +247,9 @@ function init$1(pAxios, pSpinHandlerInstance, pDialogUtilsInstance, pLoginServic
248
247
  globalSpinHandlerInstance = pSpinHandlerInstance;
249
248
  loginServiceInstance = pLoginServiceInstance;
250
249
  }
250
+ function getHostName() {
251
+ return window.location.hostname;
252
+ }
251
253
  function loadParamFromLocationSearch(paramKey) {
252
254
  var paramsStr = window.location.search;
253
255
  if (paramsStr.indexOf("?") === 0) {
@@ -342,6 +344,36 @@ function downloadExcelData(url, data, headers, options = {}) {
342
344
  }
343
345
  });
344
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.blob();
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
+ }
345
377
  function downloadServerData(url) {
346
378
  return new Promise(function(resolve, reject) {
347
379
  const hyperlink = document.createElement("a");
@@ -532,6 +564,7 @@ async function appSessionExit(resultCode, forceCloseFlag) {
532
564
  }
533
565
  const AxiosUtils = {
534
566
  init: init$1,
567
+ getHostName,
535
568
  loadParamFromLocationSearch,
536
569
  getPath,
537
570
  getUrlParam,
@@ -540,6 +573,7 @@ const AxiosUtils = {
540
573
  getJsonData,
541
574
  postJsonData,
542
575
  downloadExcelData,
576
+ downloadImageData,
543
577
  downloadServerData,
544
578
  uploadFile,
545
579
  getStaticTextFile,
@@ -919,6 +953,11 @@ function convertTimestampToDateTimeText(timestamp) {
919
953
  let text = convertMomentToDateTimeText(moments);
920
954
  return text;
921
955
  }
956
+ function convertTimestampToTimeText(timestamp) {
957
+ let moments = convertTimestampToMoment(timestamp);
958
+ let text = convertMomentToTimeText(moments);
959
+ return text;
960
+ }
922
961
  function convertDateToMoment(date) {
923
962
  if (!date) {
924
963
  return null;
@@ -963,6 +1002,7 @@ const DateUtils = {
963
1002
  convertTimestampToMoment,
964
1003
  convertTimestampToDateText,
965
1004
  convertTimestampToDateTimeText,
1005
+ convertTimestampToTimeText,
966
1006
  convertDateToMoment,
967
1007
  convertDateToDateText,
968
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() {
@@ -249,6 +248,9 @@
249
248
  globalSpinHandlerInstance = pSpinHandlerInstance;
250
249
  loginServiceInstance = pLoginServiceInstance;
251
250
  }
251
+ function getHostName() {
252
+ return window.location.hostname;
253
+ }
252
254
  function loadParamFromLocationSearch(paramKey) {
253
255
  var paramsStr = window.location.search;
254
256
  if (paramsStr.indexOf("?") === 0) {
@@ -343,6 +345,36 @@
343
345
  }
344
346
  });
345
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.blob();
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
+ }
346
378
  function downloadServerData(url) {
347
379
  return new Promise(function(resolve, reject) {
348
380
  const hyperlink = document.createElement("a");
@@ -533,6 +565,7 @@
533
565
  }
534
566
  const AxiosUtils = {
535
567
  init: init$1,
568
+ getHostName,
536
569
  loadParamFromLocationSearch,
537
570
  getPath,
538
571
  getUrlParam,
@@ -541,6 +574,7 @@
541
574
  getJsonData,
542
575
  postJsonData,
543
576
  downloadExcelData,
577
+ downloadImageData,
544
578
  downloadServerData,
545
579
  uploadFile,
546
580
  getStaticTextFile,
@@ -920,6 +954,11 @@
920
954
  let text = convertMomentToDateTimeText(moments);
921
955
  return text;
922
956
  }
957
+ function convertTimestampToTimeText(timestamp) {
958
+ let moments = convertTimestampToMoment(timestamp);
959
+ let text = convertMomentToTimeText(moments);
960
+ return text;
961
+ }
923
962
  function convertDateToMoment(date) {
924
963
  if (!date) {
925
964
  return null;
@@ -964,6 +1003,7 @@
964
1003
  convertTimestampToMoment,
965
1004
  convertTimestampToDateText,
966
1005
  convertTimestampToDateTimeText,
1006
+ convertTimestampToTimeText,
967
1007
  convertDateToMoment,
968
1008
  convertDateToDateText,
969
1009
  convertDateToDateTimeText,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sirius-common-utils",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "",
5
5
  "main": "./dist/sirius-common-utils.umd.cjs",
6
6
  "module": "./dist/sirius-common-utils.js",