Best JavaScript code snippet using playwright-internal
synclocaltoserver.js
Source:synclocaltoserver.js
1angular.module('starter')2.factory('SyncPollingFac',['PPOBFac','OfflineLiteFac','OpenCloseBookLiteFac','OpenCloseBookFac','MerchantsFac','MerchantsLiteFac','StoresLiteFac','StoresFac','CustomersLiteFac','CustomersFac','KaryawansLiteFac','KaryawansFac','ShopCartLiteFac','TransaksiCombFac','TransaksisFac','TransaksisLiteFac','ProductStockLiteFac','ProductsFac','ProductsLiteFac','$rootScope','$q','UtilService', 3function(PPOBFac,OfflineLiteFac,OpenCloseBookLiteFac,OpenCloseBookFac,MerchantsFac,MerchantsLiteFac,StoresLiteFac,StoresFac,CustomersLiteFac,CustomersFac,KaryawansLiteFac,KaryawansFac,ShopCartLiteFac,TransaksiCombFac,TransaksisFac,TransaksisLiteFac,ProductStockLiteFac,ProductsFac,ProductsLiteFac,$rootScope,$q,UtilService) 4{5 var SyncOfflineToServer = function()6 {7 var deferred = $q.defer();8 OfflineLiteFac.GetOffline()9 .then(function(responseoffline)10 {11 var promises = [];12 angular.forEach(responseoffline,function(valueoffline,key)13 {14 if(valueoffline.NAMA_TABEL == 'Tbl_Transaksis')15 {16 var promise = TransaksisLiteFac.GetTransaksiHeaderByTransID(valueoffline.PRIMARY_KEY)17 .then(function(responselite)18 {19 TransaksisFac.CreateTransaksiHeaders(responselite[0])20 .then(function(ressavetoserver)21 {22 $rootScope.$broadcast('syncofflinetoserver',valueoffline);23 OfflineLiteFac.UpdateOffline(valueoffline)24 .then(function(response)25 {26 deferred.resolve(response)27 },28 function(error)29 {30 deferred.reject(error)31 }); 32 },33 function(error)34 {35 if(error == 'data-exist')36 {37 OfflineLiteFac.UpdateOffline(valueoffline)38 .then(function(response)39 {40 deferred.resolve(response)41 },42 function(error)43 {44 deferred.reject(error)45 }) 46 }47 else48 {49 deferred.reject(error);50 }51 });52 },53 function(errorlite)54 {55 deferred.reject(errorlite);56 });57 promises.push(promise);58 }59 60 else if(valueoffline.NAMA_TABEL == 'Tbl_ShopCart')61 {62 var promise = ShopCartLiteFac.GetShopCartByIDLocal(valueoffline.PRIMARY_KEY)63 .then(function(responselite)64 {65 var datatosave = responselite[0];66 datatosave.PRODUCT_QTY = datatosave.QTY_INCART;67 datatosave.STATUS = 1;68 TransaksisFac.CreateTranskasiDetails(datatosave)69 .then(function(ressavetoserver)70 {71 $rootScope.$broadcast('syncofflinetoserver',valueoffline);72 OfflineLiteFac.UpdateOffline(valueoffline)73 .then(function(response)74 {75 deferred.resolve(response)76 },77 function(error)78 {79 deferred.reject(error)80 });81 },82 function(error)83 {84 deferred.reject(error);85 });86 },87 function(error)88 {89 deferred.reject(error);90 })91 promises.push(promise);92 }93 else if(valueoffline.NAMA_TABEL == 'Tbl_ShopCartRefund')94 {95 var promise = ShopCartLiteFac.GetShopCartRefundByIDLocal(valueoffline.PRIMARY_KEY)96 .then(function(responselite)97 {98 var datatosave = responselite[0];99 datatosave.PRODUCT_QTY = datatosave.QTY_INCART;100 datatosave.STATUS = 1;101 TransaksisFac.CreateTranskasiDetails(datatosave)102 .then(function(ressavetoserver)103 {104 $rootScope.$broadcast('syncofflinetoserver',valueoffline);105 OfflineLiteFac.UpdateOffline(valueoffline)106 .then(function(response)107 {108 deferred.resolve(response)109 },110 function(error)111 {112 deferred.reject(error)113 });114 },115 function(error)116 {117 deferred.reject(error);118 });119 },120 function(error)121 {122 deferred.reject(error);123 })124 promises.push(promise);125 }126 else if(valueoffline.NAMA_TABEL == 'Tbl_Product_Stocks')127 {128 var promise = ProductStockLiteFac.GetProductStockByIDLocal(valueoffline.PRIMARY_KEY)129 .then(function(responselite)130 {131 var datatosave = responselite[0];132 ProductsFac.CreateProductStocks(datatosave)133 .then(function(ressavetoserver)134 {135 $rootScope.$broadcast('syncofflinetoserver',valueoffline);136 OfflineLiteFac.UpdateOffline(valueoffline)137 .then(function(response)138 {139 deferred.resolve(response)140 },141 function(error)142 {143 deferred.reject(error)144 });145 },146 function(error)147 {148 deferred.reject(error);149 });150 },151 function(error)152 {153 deferred.reject(error)154 });155 promises.push(promise);156 }157 else if(valueoffline.NAMA_TABEL == 'Tbl_Product_Hargas')158 {159 var promise = ProductStockLiteFac.GetProductHargaByIDLocal(valueoffline.PRIMARY_KEY)160 .then(function(responselite)161 {162 var datatosave = responselite[0];163 ProductsFac.CreateProductHargas(datatosave)164 .then(function(ressavetoserver)165 {166 $rootScope.$broadcast('syncofflinetoserver',valueoffline);167 OfflineLiteFac.UpdateOffline(valueoffline)168 .then(function(response)169 {170 deferred.resolve(response)171 },172 function(error)173 {174 deferred.reject(error)175 });176 },177 function(error)178 {179 deferred.reject(error);180 });181 },182 function(error)183 {184 deferred.reject(error)185 });186 promises.push(promise);187 }188 else if(valueoffline.NAMA_TABEL == 'Tbl_KaryawanAbsensis')189 {190 var promise = KaryawansLiteFac.GetKaryawanAbsensisByIDLocal(valueoffline.PRIMARY_KEY)191 .then(function(responselite)192 {193 var datatosave = responselite[0];194 KaryawansFac.CreateKaryawanAbsensis(datatosave)195 .then(function(ressavetoserver)196 {197 $rootScope.$broadcast('syncofflinetoserver',valueoffline);198 OfflineLiteFac.UpdateOffline(valueoffline)199 .then(function(response)200 {201 deferred.resolve(response)202 },203 function(error)204 {205 deferred.reject(error)206 });207 },208 function(error)209 {210 deferred.reject(error);211 });212 },213 function(error)214 {215 deferred.reject(error)216 });217 promises.push(promise);218 }219 else if(valueoffline.NAMA_TABEL == 'Tbl_Products')220 {221 var promise = ProductsLiteFac.GetProductByIDLocal(valueoffline.PRIMARY_KEY)222 .then(function(responselite)223 {224 var datatosave = responselite[0];225 datatosave.CURRENT_PRICE = datatosave.HARGA_JUAL;226 if(valueoffline.TYPE_ACTION == 1)227 {228 ProductsFac.CreateProducts(datatosave)229 .then(function(ressavetoserver)230 {231 $rootScope.$broadcast('syncofflinetoserver',valueoffline);232 OfflineLiteFac.UpdateOffline(valueoffline)233 .then(function(response)234 {235 deferred.resolve(response)236 },237 function(error)238 {239 deferred.reject(error)240 });241 },242 function(error)243 {244 deferred.reject(error);245 });246 }247 else if(valueoffline.TYPE_ACTION == 2)248 {249 ProductsFac.UpdateProducts(datatosave)250 .then(function(responseupdatetoserver)251 {252 OfflineLiteFac.UpdateOffline(valueoffline)253 .then(function(response)254 {255 deferred.resolve(response)256 },257 function(error)258 {259 deferred.reject(error)260 });261 },262 function(error)263 {264 deferred.reject(error)265 });266 }267 else268 {269 ProductsFac.DeleteProducts(datatosave)270 .then(function(responseupdatetoserver)271 {272 OfflineLiteFac.UpdateOffline(valueoffline)273 .then(function(response)274 {275 deferred.resolve(response)276 },277 function(error)278 {279 deferred.reject(error)280 });281 },282 function(error)283 {284 deferred.reject(error)285 });286 }287 },288 function(error)289 {290 deferred.reject(error)291 });292 promises.push(promise);293 }294 else if(valueoffline.NAMA_TABEL == 'Tbl_Product_Groups')295 {296 var promise = ProductsLiteFac.GetProductGroupsByIDLocal(valueoffline.PRIMARY_KEY)297 .then(function(responselite)298 {299 var datatosave = responselite[0];300 if(valueoffline.TYPE_ACTION == 1)301 {302 ProductsFac.CreateProductGroups(datatosave)303 .then(function(ressavetoserver)304 {305 $rootScope.$broadcast('syncofflinetoserver',valueoffline);306 OfflineLiteFac.UpdateOffline(valueoffline)307 .then(function(response)308 {309 deferred.resolve(response)310 },311 function(error)312 {313 deferred.reject(error)314 });315 },316 function(error)317 {318 deferred.reject(error);319 });320 }321 else if (valueoffline.TYPE_ACTION == 2)322 {323 ProductsFac.UpdateProductGroups(datatosave)324 .then(function(ressavetoserver)325 {326 $rootScope.$broadcast('syncofflinetoserver',valueoffline);327 OfflineLiteFac.UpdateOffline(valueoffline)328 .then(function(response)329 {330 deferred.resolve(response)331 },332 function(error)333 {334 deferred.reject(error)335 });336 },337 function(error)338 {339 deferred.reject(error);340 });341 }342 else343 {344 ProductsFac.DeleteProductGroups(datatosave)345 .then(function(ressavetoserver)346 {347 $rootScope.$broadcast('syncofflinetoserver',valueoffline);348 OfflineLiteFac.UpdateOffline(valueoffline)349 .then(function(response)350 {351 deferred.resolve(response)352 },353 function(error)354 {355 deferred.reject(error)356 });357 },358 function(error)359 {360 deferred.reject(error);361 });362 }363 },364 function(error)365 {366 deferred.reject(error)367 });368 promises.push(promise);369 }370 371 else if(valueoffline.NAMA_TABEL == 'Tbl_Product_Images')372 {373 var promise = ProductsLiteFac.GetProductImagesByIDLocal(valueoffline.PRIMARY_KEY)374 .then(function(responselite)375 {376 var datatosave = responselite[0];377 if(valueoffline.TYPE_ACTION == 1)378 {379 ProductsFac.CreateProductImages(datatosave)380 .then(function(ressavetoserver)381 {382 $rootScope.$broadcast('syncofflinetoserver',valueoffline);383 OfflineLiteFac.UpdateOffline(valueoffline)384 .then(function(response)385 {386 deferred.resolve(response)387 },388 function(error)389 {390 deferred.reject(error)391 });392 },393 function(error)394 {395 deferred.reject(error);396 });397 }398 else if (valueoffline.TYPE_ACTION == 2)399 {400 ProductsFac.UpdateProductImages(datatosave)401 .then(function(ressavetoserver)402 {403 $rootScope.$broadcast('syncofflinetoserver',valueoffline);404 OfflineLiteFac.UpdateOffline(valueoffline)405 .then(function(response)406 {407 deferred.resolve(response)408 },409 function(error)410 {411 deferred.reject(error)412 });413 },414 function(error)415 {416 deferred.reject(error);417 });418 }419 else420 {421 ProductsFac.DeleteProductGroups(datatosave)422 .then(function(ressavetoserver)423 {424 $rootScope.$broadcast('syncofflinetoserver',valueoffline);425 OfflineLiteFac.UpdateOffline(valueoffline)426 .then(function(response)427 {428 deferred.resolve(response)429 },430 function(error)431 {432 deferred.reject(error)433 });434 },435 function(error)436 {437 deferred.reject(error);438 });439 }440 },441 function(error)442 {443 deferred.reject(error)444 });445 promises.push(promise);446 }447 else if(valueoffline.NAMA_TABEL == 'Tbl_Karyawans')448 {449 var promise = KaryawansLiteFac.GetKaryawanByIDLocal(valueoffline.PRIMARY_KEY)450 .then(function(responselite)451 {452 var datatosave = responselite[0];453 if(valueoffline.TYPE_ACTION == 1)454 {455 KaryawansFac.CreateKaryawans(datatosave)456 .then(function(ressavetoserver)457 {458 OfflineLiteFac.UpdateOffline(valueoffline)459 .then(function(response)460 {461 deferred.resolve(response)462 },463 function(error)464 {465 deferred.reject(error)466 });467 },468 function(error)469 {470 deferred.reject(error);471 });472 }473 else if(valueoffline.TYPE_ACTION == 2)474 {475 KaryawansFac.UpdateKaryawans(datatosave)476 .then(function(ressavetoserver)477 {478 OfflineLiteFac.UpdateOffline(valueoffline)479 .then(function(response)480 {481 deferred.resolve(response)482 },483 function(error)484 {485 deferred.reject(error)486 });487 },488 function(error)489 {490 deferred.reject(error);491 });492 }493 else494 {495 KaryawansFac.DeleteKaryawans(datatosave)496 .then(function(ressavetoserver)497 {498 OfflineLiteFac.UpdateOffline(valueoffline)499 .then(function(response)500 {501 deferred.resolve(response)502 },503 function(error)504 {505 deferred.reject(error)506 });507 },508 function(error)509 {510 deferred.reject(error);511 });512 }513 },514 function(error)515 {516 deferred.reject(error)517 });518 promises.push(promise);519 }520 else if(valueoffline.NAMA_TABEL == 'Tbl_Customers')521 {522 var promise = CustomersLiteFac.GetCustomerByIDLocal(valueoffline.PRIMARY_KEY)523 .then(function(responselite)524 {525 var datatosave = responselite[0];526 if(valueoffline.TYPE_ACTION == 1)527 {528 CustomersFac.CreateCustomers(datatosave)529 .then(function(ressavetoserver)530 {531 OfflineLiteFac.UpdateOffline(valueoffline)532 .then(function(response)533 {534 deferred.resolve(response)535 },536 function(error)537 {538 deferred.reject(error)539 });540 },541 function(error)542 {543 deferred.reject(error);544 });545 }546 else if(valueoffline.TYPE_ACTION == 2)547 {548 CustomersFac.UpdateCustomers(datatosave)549 .then(function(ressavetoserver)550 {551 OfflineLiteFac.UpdateOffline(valueoffline)552 .then(function(response)553 {554 deferred.resolve(response)555 },556 function(error)557 {558 deferred.reject(error)559 });560 },561 function(error)562 {563 deferred.reject(error);564 });565 }566 else567 {568 CustomersFac.DeleteCustomers(datatosave)569 .then(function(ressavetoserver)570 {571 OfflineLiteFac.UpdateOffline(valueoffline)572 .then(function(response)573 {574 deferred.resolve(response)575 },576 function(error)577 {578 deferred.reject(error)579 });580 },581 function(error)582 {583 deferred.reject(error);584 });585 }586 },587 function(error)588 {589 deferred.reject(error)590 });591 promises.push(promise);592 }593 else if(valueoffline.NAMA_TABEL == 'Tbl_Stores')594 {595 var promise = StoresLiteFac.GetStoreByIDLocal(valueoffline.PRIMARY_KEY)596 .then(function(responselite)597 {598 var datatosave = responselite[0];599 if(valueoffline.TYPE_ACTION == 1)600 {601 StoresFac.CreateStores(datatosave)602 .then(function(ressavetoserver)603 {604 OfflineLiteFac.UpdateOffline(valueoffline)605 .then(function(response)606 {607 deferred.resolve(response)608 },609 function(error)610 {611 deferred.reject(error)612 });613 },614 function(error)615 {616 deferred.reject(error);617 });618 }619 else if(valueoffline.TYPE_ACTION == 2)620 {621 StoresFac.UpdateStores(datatosave)622 .then(function(ressavetoserver)623 {624 OfflineLiteFac.UpdateOffline(valueoffline)625 .then(function(response)626 {627 deferred.resolve(response)628 },629 function(error)630 {631 deferred.reject(error)632 });633 },634 function(error)635 {636 deferred.reject(error);637 });638 }639 else640 {641 StoresFac.DeleteStores(datatosave)642 .then(function(ressavetoserver)643 {644 OfflineLiteFac.UpdateOffline(valueoffline)645 .then(function(response)646 {647 deferred.resolve(response)648 },649 function(error)650 {651 deferred.reject(error)652 });653 },654 function(error)655 {656 deferred.reject(error);657 });658 }659 },660 function(error)661 {662 deferred.reject(error)663 });664 promises.push(promise);665 }666 else if(valueoffline.NAMA_TABEL == 'Tbl_Merchants')667 {668 var promise = MerchantsLiteFac.GetMerchantByIDLocal(valueoffline.PRIMARY_KEY)669 .then(function(responselite)670 {671 var datatosave = responselite[0];672 if(valueoffline.TYPE_ACTION == 1)673 {674 MerchantsFac.CreateMerchants(datatosave)675 .then(function(ressavetoserver)676 {677 OfflineLiteFac.UpdateOffline(valueoffline)678 .then(function(response)679 {680 deferred.resolve(response)681 },682 function(error)683 {684 deferred.reject(error)685 });686 },687 function(error)688 {689 deferred.reject(error);690 });691 }692 else if(valueoffline.TYPE_ACTION == 2)693 {694 MerchantsFac.UpdateMerchants(datatosave)695 .then(function(ressavetoserver)696 {697 OfflineLiteFac.UpdateOffline(valueoffline)698 .then(function(response)699 {700 deferred.resolve(response)701 },702 function(error)703 {704 deferred.reject(error)705 });706 },707 function(error)708 {709 deferred.reject(error);710 });711 }712 else713 {714 MerchantsFac.DeleteMerchants(datatosave)715 .then(function(ressavetoserver)716 {717 OfflineLiteFac.UpdateOffline(valueoffline)718 .then(function(response)719 {720 deferred.resolve(response)721 },722 function(error)723 {724 deferred.reject(error)725 });726 },727 function(error)728 {729 deferred.reject(error);730 });731 }732 },733 function(error)734 {735 deferred.reject(error)736 });737 promises.push(promise);738 }739 740 else if(valueoffline.NAMA_TABEL == 'Tbl_MerchantTypes')741 {742 var promise = MerchantsLiteFac.GetMerchantTypeByIDLocal(valueoffline.PRIMARY_KEY)743 .then(function(responselite)744 {745 var datatosave = responselite[0];746 if(valueoffline.TYPE_ACTION == 1)747 {748 MerchantsFac.CreateMerchantTypes(datatosave)749 .then(function(ressavetoserver)750 {751 OfflineLiteFac.UpdateOffline(valueoffline)752 .then(function(response)753 {754 deferred.resolve(response)755 },756 function(error)757 {758 deferred.reject(error)759 });760 },761 function(error)762 {763 deferred.reject(error);764 });765 }766 else if(valueoffline.TYPE_ACTION == 2)767 {768 MerchantsFac.UpdateMerchantTypes(datatosave)769 .then(function(ressavetoserver)770 {771 OfflineLiteFac.UpdateOffline(valueoffline)772 .then(function(response)773 {774 deferred.resolve(response)775 },776 function(error)777 {778 deferred.reject(error)779 });780 },781 function(error)782 {783 deferred.reject(error);784 });785 }786 else787 {788 MerchantsFac.DeleteMerchantTypes(datatosave)789 .then(function(ressavetoserver)790 {791 OfflineLiteFac.UpdateOffline(valueoffline)792 .then(function(response)793 {794 deferred.resolve(response)795 },796 function(error)797 {798 deferred.reject(error)799 });800 },801 function(error)802 {803 deferred.reject(error);804 });805 }806 },807 function(error)808 {809 deferred.reject(error)810 });811 promises.push(promise);812 }813 else if(valueoffline.NAMA_TABEL == 'Tbl_OpenCloseBook')814 {815 var promise = OpenCloseBookLiteFac.GetOpenCloseBookByIDLocal(valueoffline.PRIMARY_KEY)816 .then(function(responselite)817 {818 var datatosave = responselite[0];819 if(valueoffline.TYPE_ACTION == 1)820 {821 OpenCloseBookFac.CreateOpenCloseBook(datatosave)822 .then(function(ressavetoserver)823 {824 OfflineLiteFac.UpdateOffline(valueoffline)825 .then(function(response)826 {827 deferred.resolve(response)828 },829 function(error)830 {831 deferred.reject(error)832 });833 },834 function(error)835 {836 deferred.reject(error);837 });838 }839 else if(valueoffline.TYPE_ACTION == 2)840 {841 OpenCloseBookFac.UpdateOpenCloseBook(datatosave)842 .then(function(ressavetoserver)843 {844 OfflineLiteFac.UpdateOffline(valueoffline)845 .then(function(response)846 {847 deferred.resolve(response)848 },849 function(error)850 {851 deferred.reject(error)852 });853 },854 function(error)855 {856 deferred.reject(error);857 });858 }859 },860 function(error)861 {862 deferred.reject(error)863 });864 promises.push(promise);865 }866 else if(valueoffline.NAMA_TABEL == 'Tbl_Setoran')867 {868 var promise = OpenCloseBookLiteFac.GetSetoranBookByIDLocal(valueoffline.PRIMARY_KEY)869 .then(function(responselite)870 {871 var datatosave = responselite[0];872 if(valueoffline.TYPE_ACTION == 1)873 {874 OpenCloseBookFac.CreateSetoranBook(datatosave)875 .then(function(ressavetoserver)876 {877 OfflineLiteFac.UpdateOffline(valueoffline)878 .then(function(response)879 {880 deferred.resolve(response)881 },882 function(error)883 {884 deferred.reject(error)885 });886 },887 function(error)888 {889 deferred.reject(error);890 });891 }892 else if(valueoffline.TYPE_ACTION == 2)893 {894 OpenCloseBookFac.UpdateSetoranBook(datatosave)895 .then(function(ressavetoserver)896 {897 OfflineLiteFac.UpdateOffline(valueoffline)898 .then(function(response)899 {900 deferred.resolve(response)901 },902 function(error)903 {904 deferred.reject(error)905 });906 },907 function(error)908 {909 deferred.reject(error);910 });911 }912 },913 function(error)914 {915 deferred.reject(error)916 });917 promises.push(promise);918 }919 else if(valueoffline.NAMA_TABEL == 'Tbl_ShopCartPPOB')920 {921 var promise = ShopCartLiteFac.GetShopCartPPOBByIDLocal(valueoffline.PRIMARY_KEY)922 .then(function(responselite)923 {924 var datatosave = responselite[0];925 if(valueoffline.TYPE_ACTION == 1)926 {927 PPOBFac.CreateTransaksi(datatosave)928 .then(function(ressavetoserver)929 {930 OfflineLiteFac.UpdateOffline(valueoffline)931 .then(function(response)932 {933 deferred.resolve(response)934 },935 function(error)936 {937 deferred.reject(error)938 });939 },940 function(error)941 {942 deferred.reject(error);943 });944 }945 },946 function(error)947 {948 deferred.reject(error)949 });950 promises.push(promise);951 }952 });953 $q.all(promises).then(function(result)954 {955 deferred.resolve("Sukses")956 },957 function(error)958 {959 deferred.resolve("Gagal");960 })961 },962 function(error)963 {964 deferred.reject(error)965 });966 return deferred.promise;967 }968 return {969 SyncOfflineToServer:SyncOfflineToServer970 };...
syncpolling.js
Source:syncpolling.js
1angular.module('starter')2.factory('SyncPollingFac',['PPOBFac','OfflineLiteFac','OpenCloseBookLiteFac','OpenCloseBookFac','MerchantsFac','MerchantsLiteFac','StoresLiteFac','StoresFac','CustomersLiteFac','CustomersFac','KaryawansLiteFac','KaryawansFac','ShopCartLiteFac','TransaksiCombFac','TransaksisFac','TransaksisLiteFac','ProductStockLiteFac','ProductsFac','ProductsLiteFac','$rootScope','$q','UtilService', 3function(PPOBFac,OfflineLiteFac,OpenCloseBookLiteFac,OpenCloseBookFac,MerchantsFac,MerchantsLiteFac,StoresLiteFac,StoresFac,CustomersLiteFac,CustomersFac,KaryawansLiteFac,KaryawansFac,ShopCartLiteFac,TransaksiCombFac,TransaksisFac,TransaksisLiteFac,ProductStockLiteFac,ProductsFac,ProductsLiteFac,$rootScope,$q,UtilService) 4{5 var SyncOfflineToServer = function()6 {7 var deferred = $q.defer();8 OfflineLiteFac.GetOffline()9 .then(function(responseoffline)10 {11 var promises = [];12 angular.forEach(responseoffline,function(valueoffline,key)13 {14 if(valueoffline.NAMA_TABEL == 'Tbl_Transaksis')15 {16 var promise = TransaksisLiteFac.GetTransaksiHeaderByTransID(valueoffline.PRIMARY_KEY)17 .then(function(responselite)18 {19 TransaksisFac.CreateTransaksiHeaders(responselite[0])20 .then(function(ressavetoserver)21 {22 $rootScope.$broadcast('syncofflinetoserver',valueoffline);23 OfflineLiteFac.UpdateOffline(valueoffline)24 .then(function(response)25 {26 deferred.resolve(response)27 },28 function(error)29 {30 deferred.reject(error)31 }); 32 },33 function(error)34 {35 if(error == 'data-exist')36 {37 OfflineLiteFac.UpdateOffline(valueoffline)38 .then(function(response)39 {40 deferred.resolve(response)41 },42 function(error)43 {44 deferred.reject(error)45 }) 46 }47 else48 {49 deferred.reject(error);50 }51 });52 },53 function(errorlite)54 {55 deferred.reject(errorlite);56 });57 promises.push(promise);58 }59 60 else if(valueoffline.NAMA_TABEL == 'Tbl_ShopCart')61 {62 var promise = ShopCartLiteFac.GetShopCartByIDLocal(valueoffline.PRIMARY_KEY)63 .then(function(responselite)64 {65 var datatosave = responselite[0];66 datatosave.PRODUCT_QTY = datatosave.QTY_INCART;67 datatosave.STATUS = 1;68 TransaksisFac.CreateTranskasiDetails(datatosave)69 .then(function(ressavetoserver)70 {71 $rootScope.$broadcast('syncofflinetoserver',valueoffline);72 OfflineLiteFac.UpdateOffline(valueoffline)73 .then(function(response)74 {75 deferred.resolve(response)76 },77 function(error)78 {79 deferred.reject(error)80 });81 },82 function(error)83 {84 deferred.reject(error);85 });86 },87 function(error)88 {89 deferred.reject(error);90 })91 promises.push(promise);92 }93 else if(valueoffline.NAMA_TABEL == 'Tbl_ShopCartRefund')94 {95 var promise = ShopCartLiteFac.GetShopCartRefundByIDLocal(valueoffline.PRIMARY_KEY)96 .then(function(responselite)97 {98 var datatosave = responselite[0];99 datatosave.PRODUCT_QTY = datatosave.QTY_INCART;100 datatosave.STATUS = 1;101 TransaksisFac.CreateTranskasiDetails(datatosave)102 .then(function(ressavetoserver)103 {104 $rootScope.$broadcast('syncofflinetoserver',valueoffline);105 OfflineLiteFac.UpdateOffline(valueoffline)106 .then(function(response)107 {108 deferred.resolve(response)109 },110 function(error)111 {112 deferred.reject(error)113 });114 },115 function(error)116 {117 deferred.reject(error);118 });119 },120 function(error)121 {122 deferred.reject(error);123 })124 promises.push(promise);125 }126 else if(valueoffline.NAMA_TABEL == 'Tbl_Product_Stocks')127 {128 var promise = ProductStockLiteFac.GetProductStockByIDLocal(valueoffline.PRIMARY_KEY)129 .then(function(responselite)130 {131 var datatosave = responselite[0];132 ProductsFac.CreateProductStocks(datatosave)133 .then(function(ressavetoserver)134 {135 $rootScope.$broadcast('syncofflinetoserver',valueoffline);136 OfflineLiteFac.UpdateOffline(valueoffline)137 .then(function(response)138 {139 deferred.resolve(response)140 },141 function(error)142 {143 deferred.reject(error)144 });145 },146 function(error)147 {148 deferred.reject(error);149 });150 },151 function(error)152 {153 deferred.reject(error)154 });155 promises.push(promise);156 }157 else if(valueoffline.NAMA_TABEL == 'Tbl_Product_Hargas')158 {159 var promise = ProductStockLiteFac.GetProductHargaByIDLocal(valueoffline.PRIMARY_KEY)160 .then(function(responselite)161 {162 var datatosave = responselite[0];163 ProductsFac.CreateProductHargas(datatosave)164 .then(function(ressavetoserver)165 {166 $rootScope.$broadcast('syncofflinetoserver',valueoffline);167 OfflineLiteFac.UpdateOffline(valueoffline)168 .then(function(response)169 {170 deferred.resolve(response)171 },172 function(error)173 {174 deferred.reject(error)175 });176 },177 function(error)178 {179 deferred.reject(error);180 });181 },182 function(error)183 {184 deferred.reject(error)185 });186 promises.push(promise);187 }188 else if(valueoffline.NAMA_TABEL == 'Tbl_KaryawanAbsensis')189 {190 var promise = KaryawansLiteFac.GetKaryawanAbsensisByIDLocal(valueoffline.PRIMARY_KEY)191 .then(function(responselite)192 {193 var datatosave = responselite[0];194 KaryawansFac.CreateKaryawanAbsensis(datatosave)195 .then(function(ressavetoserver)196 {197 $rootScope.$broadcast('syncofflinetoserver',valueoffline);198 OfflineLiteFac.UpdateOffline(valueoffline)199 .then(function(response)200 {201 deferred.resolve(response)202 },203 function(error)204 {205 deferred.reject(error)206 });207 },208 function(error)209 {210 deferred.reject(error);211 });212 },213 function(error)214 {215 deferred.reject(error)216 });217 promises.push(promise);218 }219 else if(valueoffline.NAMA_TABEL == 'Tbl_Products')220 {221 var promise = ProductsLiteFac.GetProductByIDLocal(valueoffline.PRIMARY_KEY)222 .then(function(responselite)223 {224 var datatosave = responselite[0];225 datatosave.CURRENT_PRICE = datatosave.HARGA_JUAL;226 if(valueoffline.TYPE_ACTION == 1)227 {228 ProductsFac.CreateProducts(datatosave)229 .then(function(ressavetoserver)230 {231 $rootScope.$broadcast('syncofflinetoserver',valueoffline);232 OfflineLiteFac.UpdateOffline(valueoffline)233 .then(function(response)234 {235 deferred.resolve(response)236 },237 function(error)238 {239 deferred.reject(error)240 });241 },242 function(error)243 {244 deferred.reject(error);245 });246 }247 else if(valueoffline.TYPE_ACTION == 2)248 {249 ProductsFac.UpdateProducts(datatosave)250 .then(function(responseupdatetoserver)251 {252 OfflineLiteFac.UpdateOffline(valueoffline)253 .then(function(response)254 {255 deferred.resolve(response)256 },257 function(error)258 {259 deferred.reject(error)260 });261 },262 function(error)263 {264 deferred.reject(error)265 });266 }267 else268 {269 ProductsFac.DeleteProducts(datatosave)270 .then(function(responseupdatetoserver)271 {272 OfflineLiteFac.UpdateOffline(valueoffline)273 .then(function(response)274 {275 deferred.resolve(response)276 },277 function(error)278 {279 deferred.reject(error)280 });281 },282 function(error)283 {284 deferred.reject(error)285 });286 }287 },288 function(error)289 {290 deferred.reject(error)291 });292 promises.push(promise);293 }294 else if(valueoffline.NAMA_TABEL == 'Tbl_Product_Groups')295 {296 var promise = ProductsLiteFac.GetProductGroupsByIDLocal(valueoffline.PRIMARY_KEY)297 .then(function(responselite)298 {299 var datatosave = responselite[0];300 if(valueoffline.TYPE_ACTION == 1)301 {302 ProductsFac.CreateProductGroups(datatosave)303 .then(function(ressavetoserver)304 {305 $rootScope.$broadcast('syncofflinetoserver',valueoffline);306 OfflineLiteFac.UpdateOffline(valueoffline)307 .then(function(response)308 {309 deferred.resolve(response)310 },311 function(error)312 {313 deferred.reject(error)314 });315 },316 function(error)317 {318 deferred.reject(error);319 });320 }321 else if (valueoffline.TYPE_ACTION == 2)322 {323 ProductsFac.UpdateProductGroups(datatosave)324 .then(function(ressavetoserver)325 {326 $rootScope.$broadcast('syncofflinetoserver',valueoffline);327 OfflineLiteFac.UpdateOffline(valueoffline)328 .then(function(response)329 {330 deferred.resolve(response)331 },332 function(error)333 {334 deferred.reject(error)335 });336 },337 function(error)338 {339 deferred.reject(error);340 });341 }342 else343 {344 ProductsFac.DeleteProductGroups(datatosave)345 .then(function(ressavetoserver)346 {347 $rootScope.$broadcast('syncofflinetoserver',valueoffline);348 OfflineLiteFac.UpdateOffline(valueoffline)349 .then(function(response)350 {351 deferred.resolve(response)352 },353 function(error)354 {355 deferred.reject(error)356 });357 },358 function(error)359 {360 deferred.reject(error);361 });362 }363 },364 function(error)365 {366 deferred.reject(error)367 });368 promises.push(promise);369 }370 else if(valueoffline.NAMA_TABEL == 'Tbl_Karyawans')371 {372 var promise = KaryawansLiteFac.GetKaryawanByIDLocal(valueoffline.PRIMARY_KEY)373 .then(function(responselite)374 {375 var datatosave = responselite[0];376 if(valueoffline.TYPE_ACTION == 1)377 {378 KaryawansFac.CreateKaryawans(datatosave)379 .then(function(ressavetoserver)380 {381 OfflineLiteFac.UpdateOffline(valueoffline)382 .then(function(response)383 {384 deferred.resolve(response)385 },386 function(error)387 {388 deferred.reject(error)389 });390 },391 function(error)392 {393 deferred.reject(error);394 });395 }396 else if(valueoffline.TYPE_ACTION == 2)397 {398 KaryawansFac.UpdateKaryawans(datatosave)399 .then(function(ressavetoserver)400 {401 OfflineLiteFac.UpdateOffline(valueoffline)402 .then(function(response)403 {404 deferred.resolve(response)405 },406 function(error)407 {408 deferred.reject(error)409 });410 },411 function(error)412 {413 deferred.reject(error);414 });415 }416 else417 {418 KaryawansFac.DeleteKaryawans(datatosave)419 .then(function(ressavetoserver)420 {421 OfflineLiteFac.UpdateOffline(valueoffline)422 .then(function(response)423 {424 deferred.resolve(response)425 },426 function(error)427 {428 deferred.reject(error)429 });430 },431 function(error)432 {433 deferred.reject(error);434 });435 }436 },437 function(error)438 {439 deferred.reject(error)440 });441 promises.push(promise);442 }443 else if(valueoffline.NAMA_TABEL == 'Tbl_Customers')444 {445 var promise = CustomersLiteFac.GetCustomerByIDLocal(valueoffline.PRIMARY_KEY)446 .then(function(responselite)447 {448 var datatosave = responselite[0];449 if(valueoffline.TYPE_ACTION == 1)450 {451 CustomersFac.CreateCustomers(datatosave)452 .then(function(ressavetoserver)453 {454 OfflineLiteFac.UpdateOffline(valueoffline)455 .then(function(response)456 {457 deferred.resolve(response)458 },459 function(error)460 {461 deferred.reject(error)462 });463 },464 function(error)465 {466 deferred.reject(error);467 });468 }469 else if(valueoffline.TYPE_ACTION == 2)470 {471 CustomersFac.UpdateCustomers(datatosave)472 .then(function(ressavetoserver)473 {474 OfflineLiteFac.UpdateOffline(valueoffline)475 .then(function(response)476 {477 deferred.resolve(response)478 },479 function(error)480 {481 deferred.reject(error)482 });483 },484 function(error)485 {486 deferred.reject(error);487 });488 }489 else490 {491 CustomersFac.DeleteCustomers(datatosave)492 .then(function(ressavetoserver)493 {494 OfflineLiteFac.UpdateOffline(valueoffline)495 .then(function(response)496 {497 deferred.resolve(response)498 },499 function(error)500 {501 deferred.reject(error)502 });503 },504 function(error)505 {506 deferred.reject(error);507 });508 }509 },510 function(error)511 {512 deferred.reject(error)513 });514 promises.push(promise);515 }516 else if(valueoffline.NAMA_TABEL == 'Tbl_Stores')517 {518 var promise = StoresLiteFac.GetStoreByIDLocal(valueoffline.PRIMARY_KEY)519 .then(function(responselite)520 {521 var datatosave = responselite[0];522 if(valueoffline.TYPE_ACTION == 1)523 {524 StoresFac.CreateStores(datatosave)525 .then(function(ressavetoserver)526 {527 OfflineLiteFac.UpdateOffline(valueoffline)528 .then(function(response)529 {530 deferred.resolve(response)531 },532 function(error)533 {534 deferred.reject(error)535 });536 },537 function(error)538 {539 deferred.reject(error);540 });541 }542 else if(valueoffline.TYPE_ACTION == 2)543 {544 StoresFac.UpdateStores(datatosave)545 .then(function(ressavetoserver)546 {547 OfflineLiteFac.UpdateOffline(valueoffline)548 .then(function(response)549 {550 deferred.resolve(response)551 },552 function(error)553 {554 deferred.reject(error)555 });556 },557 function(error)558 {559 deferred.reject(error);560 });561 }562 else563 {564 StoresFac.DeleteStores(datatosave)565 .then(function(ressavetoserver)566 {567 OfflineLiteFac.UpdateOffline(valueoffline)568 .then(function(response)569 {570 deferred.resolve(response)571 },572 function(error)573 {574 deferred.reject(error)575 });576 },577 function(error)578 {579 deferred.reject(error);580 });581 }582 },583 function(error)584 {585 deferred.reject(error)586 });587 promises.push(promise);588 }589 else if(valueoffline.NAMA_TABEL == 'Tbl_Merchants')590 {591 var promise = MerchantsLiteFac.GetMerchantByIDLocal(valueoffline.PRIMARY_KEY)592 .then(function(responselite)593 {594 var datatosave = responselite[0];595 if(valueoffline.TYPE_ACTION == 1)596 {597 MerchantsFac.CreateMerchants(datatosave)598 .then(function(ressavetoserver)599 {600 OfflineLiteFac.UpdateOffline(valueoffline)601 .then(function(response)602 {603 deferred.resolve(response)604 },605 function(error)606 {607 deferred.reject(error)608 });609 },610 function(error)611 {612 deferred.reject(error);613 });614 }615 else if(valueoffline.TYPE_ACTION == 2)616 {617 MerchantsFac.UpdateMerchants(datatosave)618 .then(function(ressavetoserver)619 {620 OfflineLiteFac.UpdateOffline(valueoffline)621 .then(function(response)622 {623 deferred.resolve(response)624 },625 function(error)626 {627 deferred.reject(error)628 });629 },630 function(error)631 {632 deferred.reject(error);633 });634 }635 else636 {637 MerchantsFac.DeleteMerchants(datatosave)638 .then(function(ressavetoserver)639 {640 OfflineLiteFac.UpdateOffline(valueoffline)641 .then(function(response)642 {643 deferred.resolve(response)644 },645 function(error)646 {647 deferred.reject(error)648 });649 },650 function(error)651 {652 deferred.reject(error);653 });654 }655 },656 function(error)657 {658 deferred.reject(error)659 });660 promises.push(promise);661 }662 663 else if(valueoffline.NAMA_TABEL == 'Tbl_MerchantTypes')664 {665 var promise = MerchantsLiteFac.GetMerchantTypeByIDLocal(valueoffline.PRIMARY_KEY)666 .then(function(responselite)667 {668 var datatosave = responselite[0];669 if(valueoffline.TYPE_ACTION == 1)670 {671 MerchantsFac.CreateMerchantTypes(datatosave)672 .then(function(ressavetoserver)673 {674 OfflineLiteFac.UpdateOffline(valueoffline)675 .then(function(response)676 {677 deferred.resolve(response)678 },679 function(error)680 {681 deferred.reject(error)682 });683 },684 function(error)685 {686 deferred.reject(error);687 });688 }689 else if(valueoffline.TYPE_ACTION == 2)690 {691 MerchantsFac.UpdateMerchantTypes(datatosave)692 .then(function(ressavetoserver)693 {694 OfflineLiteFac.UpdateOffline(valueoffline)695 .then(function(response)696 {697 deferred.resolve(response)698 },699 function(error)700 {701 deferred.reject(error)702 });703 },704 function(error)705 {706 deferred.reject(error);707 });708 }709 else710 {711 MerchantsFac.DeleteMerchantTypes(datatosave)712 .then(function(ressavetoserver)713 {714 OfflineLiteFac.UpdateOffline(valueoffline)715 .then(function(response)716 {717 deferred.resolve(response)718 },719 function(error)720 {721 deferred.reject(error)722 });723 },724 function(error)725 {726 deferred.reject(error);727 });728 }729 },730 function(error)731 {732 deferred.reject(error)733 });734 promises.push(promise);735 }736 else if(valueoffline.NAMA_TABEL == 'Tbl_OpenCloseBook')737 {738 var promise = OpenCloseBookLiteFac.GetOpenCloseBookByIDLocal(valueoffline.PRIMARY_KEY)739 .then(function(responselite)740 {741 var datatosave = responselite[0];742 if(valueoffline.TYPE_ACTION == 1)743 {744 OpenCloseBookFac.CreateOpenCloseBook(datatosave)745 .then(function(ressavetoserver)746 {747 OfflineLiteFac.UpdateOffline(valueoffline)748 .then(function(response)749 {750 deferred.resolve(response)751 },752 function(error)753 {754 deferred.reject(error)755 });756 },757 function(error)758 {759 deferred.reject(error);760 });761 }762 else if(valueoffline.TYPE_ACTION == 2)763 {764 OpenCloseBookFac.UpdateOpenCloseBook(datatosave)765 .then(function(ressavetoserver)766 {767 OfflineLiteFac.UpdateOffline(valueoffline)768 .then(function(response)769 {770 deferred.resolve(response)771 },772 function(error)773 {774 deferred.reject(error)775 });776 },777 function(error)778 {779 deferred.reject(error);780 });781 }782 },783 function(error)784 {785 deferred.reject(error)786 });787 promises.push(promise);788 }789 else if(valueoffline.NAMA_TABEL == 'Tbl_Setoran')790 {791 var promise = OpenCloseBookLiteFac.GetSetoranBookByIDLocal(valueoffline.PRIMARY_KEY)792 .then(function(responselite)793 {794 var datatosave = responselite[0];795 if(valueoffline.TYPE_ACTION == 1)796 {797 OpenCloseBookFac.CreateSetoranBook(datatosave)798 .then(function(ressavetoserver)799 {800 OfflineLiteFac.UpdateOffline(valueoffline)801 .then(function(response)802 {803 deferred.resolve(response)804 },805 function(error)806 {807 deferred.reject(error)808 });809 },810 function(error)811 {812 deferred.reject(error);813 });814 }815 else if(valueoffline.TYPE_ACTION == 2)816 {817 OpenCloseBookFac.UpdateSetoranBook(datatosave)818 .then(function(ressavetoserver)819 {820 OfflineLiteFac.UpdateOffline(valueoffline)821 .then(function(response)822 {823 deferred.resolve(response)824 },825 function(error)826 {827 deferred.reject(error)828 });829 },830 function(error)831 {832 deferred.reject(error);833 });834 }835 },836 function(error)837 {838 deferred.reject(error)839 });840 promises.push(promise);841 }842 else if(valueoffline.NAMA_TABEL == 'Tbl_ShopCartPPOB')843 {844 var promise = ShopCartLiteFac.GetShopCartPPOBByIDLocal(valueoffline.PRIMARY_KEY)845 .then(function(responselite)846 {847 var datatosave = responselite[0];848 if(valueoffline.TYPE_ACTION == 1)849 {850 PPOBFac.CreateTransaksi(datatosave)851 .then(function(ressavetoserver)852 {853 OfflineLiteFac.UpdateOffline(valueoffline)854 .then(function(response)855 {856 deferred.resolve(response)857 },858 function(error)859 {860 deferred.reject(error)861 });862 },863 function(error)864 {865 deferred.reject(error);866 });867 }868 },869 function(error)870 {871 deferred.reject(error)872 });873 promises.push(promise);874 }875 });876 $q.all(promises).then(function(result)877 {878 deferred.resolve("Sukses")879 },880 function(error)881 {882 deferred.resolve("Gagal");883 })884 },885 function(error)886 {887 deferred.reject(error)888 });889 return deferred.promise;890 }891 return {892 SyncOfflineToServer:SyncOfflineToServer893 };...
offline-time-limit.js
Source:offline-time-limit.js
1(function () {2 const name = 'offline-time-limit';3 const title = 'Remove 12 hour offline limit (Beta)';4 const desc = 'Removes the 12 hour time limit when processing offline time';5 const imgSrc = 'assets/media/main/milestones_header.svg';6 const origUpdateOffline = updateOffline;7 // We can load before everything else so we verify which character id to use8 function getCharacterId() {9 if (localStorage.getItem('MI-forceReload-')) {10 return localStorage.getItem('MI-forceReload-');11 }12 return currentCharacter;13 }14 /**15 Alters the updateOffline function if this plugin is enabled16 */17 function injectSelf() {18 if (!Boolean(SEMI.getItem(`${name}-status`, getCharacterId()))) {19 updateOffline = origUpdateOffline;20 return;21 }22 if (typeof updateOffline === 'undefined') {23 return;24 }25 console.log('Attempting to modify Main.js updateOffline');26 var UpdateOfflineNew = updateOffline.toString();27 UpdateOfflineNew = UpdateOfflineNew.replace(28 'if (timeDiff > 43200000) timeDiff = 43200000;',29 'let hoursGone = (timeDiff / 1000 / 60 / 60);'30 );31 if (UpdateOfflineNew == updateOffline.toString()) {32 console.error('Failed to find 12 hour limit');33 return;34 }35 UpdateOfflineNew = UpdateOfflineNew.replace(/if \(timeGone >= 12\) goneFor \+= .+?\r\n/i, '');36 UpdateOfflineNew = UpdateOfflineNew.replace(/if \(timeGone >= 12\) goneFor \+= .+?\n/i, '');37 if (UpdateOfflineNew == updateOffline.toString()) {38 console.error('Failed to find 12 hour message for removal.');39 }40 UpdateOfflineNew = UpdateOfflineNew.replace(41 'Loading your offline progress.',42 'Loading \' + ((hoursGone > 1) ? (Math.floor(hoursGone) + " hours") : Math.floor(hoursGone * 60) + " minutes") + \' of offline progress.'43 );44 if (UpdateOfflineNew == updateOffline.toString()) {45 console.error('Failed to find 12 hour message for removal.');46 }47 // updateOffline = eval('(' + UpdateOfflineNew + ')');48 SEMI.replaceGameFunc('updateOffline', UpdateOfflineNew);49 console.log('Successfully removed 12 hour limit.');50 if (!Boolean(SEMI.getItem('remember-state'))) {51 SEMIUtils.customNotify(52 imgSrc,53 'You enabled the 12 hour time limit remover, but do not have plugins auto-enable when SEMI loads. We suggest enabling that in the SEMI settings for this script to be useful.',54 { duration: 5000 }55 );56 }57 }58 // We load before SEMI is ready, we have to wait to add the plugin in otherwise currentCharacter is not valid.59 const addSelfToSemi = () => {60 if (typeof SEMIUtils === 'undefined' || !SEMIUtils.utilsReady()) {61 return;62 }63 clearInterval(semiLoader);64 // Add to SEMI65 SEMI.add(name, {66 title,67 desc,68 imgSrc,69 pluginType: SEMI.PLUGIN_TYPE.TWEAK,70 onEnable: injectSelf,71 onDisable: injectSelf,72 });73 };74 function waitForLoad() {75 if (!SEMI) return;76 clearInterval(semiLoaderInject);77 injectSelf();78 }79 const semiLoaderInject = setInterval(waitForLoad, 50);80 const semiLoader = setInterval(addSelfToSemi, 200);...
order-caching.router.js
Source:order-caching.router.js
1import { Router } from 'express';2import orderCachingController from './order-caching.controller';3import { auth, isValid } from '../../commons/middlewares';4import orderCachingValidation from './order-caching.validation';5import sanitizeRequestBody from '../../commons/middlewares/sanitize-request-body';6const router = Router();7const userRouter = Router();8const companyRouter = Router();9const mallRouter = Router();10const adminRouter = Router();11// USER ROUTES --12userRouter.get(13 '/id/:id',14 isValid(orderCachingValidation.getById),15 orderCachingController.user.getById16);17userRouter.get(18 '/code/:code',19 isValid(orderCachingValidation.getByCode),20 orderCachingController.user.getByCode21);22userRouter.get(23 '/refresh/:id',24 isValid(orderCachingValidation.user.getRefresh),25 orderCachingController.user.getRefresh26);27userRouter.post(28 '/offline/create',29 sanitizeRequestBody,30 isValid(orderCachingValidation.user.createOffline),31 orderCachingController.user.createOffline32);33userRouter.put(34 '/offline/:id',35 sanitizeRequestBody,36 isValid(orderCachingValidation.user.updateOffline),37 orderCachingController.user.updateOffline38);39// --40// COMPANY ROUTES --41companyRouter.get(42 '/id/:id',43 isValid(orderCachingValidation.getById),44 orderCachingController.company.getById45);46companyRouter.get(47 '/code/:code',48 isValid(orderCachingValidation.getByCode),49 orderCachingController.company.getByCode50);51companyRouter.get(52 '/refresh/:id',53 isValid(orderCachingValidation.company.getRefresh),54 orderCachingController.company.getRefresh55);56companyRouter.get('/', isValid(orderCachingValidation.get), orderCachingController.company.get);57companyRouter.post(58 '/offline/create',59 // auth.canCompanyEnter(['approved']),60 sanitizeRequestBody,61 isValid(orderCachingValidation.company.createOffline),62 orderCachingController.company.createOffline63);64companyRouter.put(65 '/offline/:id',66 // auth.canCompanyEnter(['approved']),67 sanitizeRequestBody,68 isValid(orderCachingValidation.company.updateOffline),69 orderCachingController.company.updateOffline70);71// --72// MALL ROUTES --73// pending...74// --75// ADMIN ROUTES --76adminRouter.get(77 '/id/:id',78 isValid(orderCachingValidation.getById),79 orderCachingController.admin.getById80);81adminRouter.get(82 '/code/:code',83 isValid(orderCachingValidation.getByCode),84 orderCachingController.admin.getByCode85);86adminRouter.get('/', isValid(orderCachingValidation.get), orderCachingController.admin.get);87// --88router.use('/user', auth.isAuthorized, userRouter);89router.use('/company', auth.isAuthorized, auth.isCompanyModPermission, companyRouter);90// router.use('/mall', auth.isAuthorized, auth.isMallModPermission, mallRouter);91router.use('/admin', auth.isAdminAuthorized, auth.isAdminPermission, adminRouter);92export { router as orderCachingRouter };...
operations.js
Source:operations.js
1import * as types from "./types.js";2const navigate = path => dispatch => {3 // Extract the page name from path.4 const page = path === "/" ? "view1" : path.slice(1);5 // Any other info you might want to extract from the path (like page type),6 // you can do here7 dispatch(loadPage(page));8 // Close the drawer - in case the *path* change came from a link in the drawer.9 dispatch(updateDrawerState(false));10};11const loadPage = page => async dispatch => {12 switch (page) {13 case "view1":14 await import("../../pages/marsfarm-view1.js");15 // Put code here that you want it to run every time when16 // navigate to view1 page and my-view1.js is loaded17 break;18 default:19 page = "view404";20 await import("../../pages/marsfarm-view404.js");21 }22 dispatch(updatePage(page));23};24const updatePage = page => {25 return {26 type: types.UPDATE_PAGE,27 page28 };29};30let snackbarTimer;31const showSnackbar = () => dispatch => {32 dispatch({33 type: types.OPEN_SNACKBAR34 });35 clearTimeout(snackbarTimer);36 snackbarTimer = setTimeout(37 () => dispatch({ type: types.CLOSE_SNACKBAR }),38 300039 );40};41const updateOffline = offline => (dispatch, getState) => {42 // Show the snackbar, unless this is the first load of the page.43 if (getState().app.offline !== undefined) {44 dispatch(showSnackbar());45 }46 dispatch({47 type: types.UPDATE_OFFLINE,48 offline49 });50};51const updateLayout = wide => (dispatch, getState) => {52 if (getState().app.drawerOpened) {53 dispatch(updateDrawerState(false));54 }55};56const updateDrawerState = opened => (dispatch, getState) => {57 if (getState().app.drawerOpened !== opened) {58 dispatch({59 type: types.UPDATE_DRAWER_STATE,60 opened61 });62 }63};64export {65 navigate,66 updatePage,67 showSnackbar,68 updateOffline,69 updateLayout,70 updateDrawerState...
index.js
Source:index.js
1import { useEffect, useContext } from 'react';2import { connect } from 'react-redux';3import { setOnline, setOffline } from '../../../../redux/actions';4import { AppContext } from '../provider';5function Connectivity(props) {6 const { addNotification } = useContext(AppContext);7 const updateOnline = () => {8 props.setOnline();9 addNotification("You're back online!", 'success', 'online');10 };11 const updateOffline = () => {12 props.setOffline();13 addNotification('Uh oh! You seem to be offline!', 'error', 'offline');14 };15 useEffect(() => {16 window.addEventListener('offline', updateOffline);17 window.addEventListener('online', updateOnline);18 return () => {19 window.removeEventListener('offline', updateOffline);20 window.removeEventListener('online', updateOnline);21 };22 });23 return null;24}25const mapStateToProps = ({ root }) => ({26 online: root.online,27});28const mapDispatchToProps = {29 setOnline,30 setOffline,31};32export default connect(33 mapStateToProps,34 mapDispatchToProps,...
StatusPicker.js
Source:StatusPicker.js
1import React from "react";2class StatusPicker extends React.Component {3 constructor() {4 super();5 this.state = {6 sign: "Active"7 };8 }9 updateAway = () => {10 this.setState({11 sign: "Away"12 });13 };14 updateActive = () => {15 this.setState({16 sign: "Active"17 });18 };19 updateOffline = () => {20 this.setState({21 sign: "Offline"22 });23 };24 render() {25 return (26 <div>27 <h2>{this.state.sign}</h2>28 <button onClick={this.updateActive}>Active</button>29 <button onClick={this.updateAway}>Away</button>30 <button onClick={this.updateOffline}>Offline</button>31 </div>32 );33 }34}...
useOffline.js
Source:useOffline.js
1import { useState, useEffect } from "react";2export function useOffline() {3 const [offline, setOffline] = useState(4 "onLine" in navigator ? !navigator.onLine : true5 );6 useEffect(() => {7 const updateOffline = () => setOffline(true);8 const updateOnline = () => setOffline(false);9 window.addEventListener("offline", updateOffline);10 window.addEventListener("online", updateOnline);11 return () => {12 window.removeEventListener("offline", updateOffline);13 window.removeEventListener("online", updateOnline);14 };15 }, []);16 return offline;...
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.evaluate(() => {7 return window.__playwright__updateOffline(true);8 });9 await browser.close();10})();11const { chromium } = require('playwright');12(async () => {13 const browser = await chromium.launch();14 const context = await browser.newContext();15 const page = await context.newPage();16 await page.evaluate(() => {17 return window.__playwright__updateOffline(true);18 });19 await browser.close();20})();
Using AI Code Generation
1const { chromium } = require('playwright');2const { updateOffline } = require('playwright/lib/server/browserContext');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 await updateOffline(context, true);7 const page = await context.newPage();8 await page.screenshot({ path: 'google.png' });9 await browser.close();10})();11import { BrowserContext } from '../browserContext';12import { BrowserContextChannel } from '../channels';13import { ChannelOwner } from './channelOwner';14import { Page } from '../page';15import { PageChannel } from '../channels';16import { PageInitializer } from '../server/page';17import { assert } from '../utils/utils';18import { Events } from '../events';19import { PageDispatcher } from './pageDispatcher';20import { DispatcherScope } from './dispatcher';21import { serializeResult } from '../protocol/serializers';22import { BrowserContextBase } from '../browserContextBase';23import { BrowserContextDispatcher } from './browserContextDispatcher';24import { FrameDispatcher } from './frameDispatcher';25import { Frame } from '../frames';26import { FrameChannel } from '../channels';27import { FrameInitializer } from '../server/frame';28import { FrameBase } from '../frames';29import { FrameOwner } from '../frames';30import { BrowserContextOptions, BrowserContextInitializer } from '../../types/types';31import { BrowserContextEvents } from '../../types/types';32import { BrowserContext } from '../browserContext';33import { BrowserContextChannel } from '../channels';34import { ChannelOwner } from './channelOwner';35import { Page } from '../page';36import { PageChannel } from '../channels';37import { PageInitializer } from '../server/page';38import { assert } from '../utils/utils';39import { Events } from '../events';40import { PageDispatcher } from './pageDispatcher';41import { DispatcherScope } from './dispatcher';42import { serializeResult } from '../protocol/serializers';43import { BrowserContextBase } from '../browserContextBase';44import { BrowserContextDispatcher } from './browserContextDispatcher';45import { FrameDispatcher } from './frameDispatcher';46import { Frame } from '../frames';47import { FrameChannel } from '../channels';48import { FrameInitializer } from '../server/frame';49import { FrameBase } from '../frames';50import { FrameOwner } from '../frames';
Using AI Code Generation
1const { chromium } = require('playwright');2const { updateOffline } = require('playwright/lib/server/browserContext');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 await updateOffline(context, true);7 const page = await context.newPage();8 await page.screenshot({ path: 'example.png' });9 await browser.close();10})();
Using AI Code Generation
1const playwright = require('playwright');2(async () => {3 const browser = await playwright.chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.evaluate(() => {7 window.__playwright__updateOffline(true);8 });9 await page.screenshot({ path: 'offline.png' });10 await browser.close();11})();12const playwright = require('playwright');13(async () => {14 const browser = await playwright.chromium.launch({headless: false});15 const context = await browser.newContext();16 const page = await context.newPage();17 await page.evaluate(() => {18 window.__playwright__updateOffline(true);19 });20 await page.pdf({ path: 'offline.pdf' });21 await browser.close();22})();
Using AI Code Generation
1const playwright = require('playwright');2(async () => {3 const browser = await playwright.chromium.launch();4 const page = await browser.newPage();5 await page.updateOffline(true);6 await browser.close();7})();8const playwright = require('playwright');9(async () => {10 const browser = await playwright.webkit.launch();11 const page = await browser.newPage();12 await page.updateOffline(true);13 await browser.close();14})();15const playwright = require('playwright');16(async () => {17 const browser = await playwright.firefox.launch();18 const page = await browser.newPage();19 await page.updateOffline(true);20 await browser.close();21})();22const playwright = require('playwright');23(async () => {24 const browser = await playwright.chromium.launch();25 const context = await browser.newContext();26 const page = await context.newPage();27 await page.updateOffline(true);28 await browser.close();29})();30const playwright = require('playwright');31(async () => {32 const browser = await playwright.webkit.launch();33 const context = await browser.newContext();34 const page = await context.newPage();35 await page.updateOffline(true);36 await browser.close();37})();38const playwright = require('playwright');39(async () => {40 const browser = await playwright.firefox.launch();41 const context = await browser.newContext();42 const page = await context.newPage();43 await page.updateOffline(true);44 await browser.close();45})();46const playwright = require('playwright');47(async () => {48 const browser = await playwright.chromium.launch();
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 await page.updateOffline(true);6 await page.screenshot({ path: 'example.png' });7 await browser.close();8})();9await page.updateOffline(false);
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 await page.evaluate(async () => {6 await window.playwright.updateOffline(true);7 });8 await page.waitForSelector('text=Offline');9 await page.close();10 await browser.close();11})();12const { chromium } = require('playwright');13describe('Playwright Test', () => {14 it('should work for chromium', async () => {15 const browser = await chromium.launch();16 const page = await browser.newPage();17 await page.evaluate(async () => {18 await window.playwright.updateOffline(true);19 });20 await page.waitForSelector('text=Offline');21 await page.close();22 await browser.close();23 });24});
Using AI Code Generation
1 16 | it('should work for chromium', async () => {2 > 17 | await page.waitForSelector('text=Offline');3 18 | await page.close();4 19 | await browser.close();5 20 | });6 at Object.<anonymous> (test.spec.js:17:11)
Using AI Code Generation
1const {chromium} = require('playwright');2const {updateOffline} = require('playwright/lib/server/browserType');3(async () => {4 const browser = await chromium.launch();5 await updateOffline(browser, true);6 const context = await browser.newContext();7 const page = await context.newPage();8 await browser.close();9})();
Using AI Code Generation
1import { updateOffline } from 'playwright/lib/server/browserType';2updateOffline(false);3import { updateOffline } from 'playwright/lib/server/browserType';4updateOffline(true);5import { updateOffline } from 'playwright/lib/server/browserType';6updateOffline(false);7import { updateOffline } from 'playwright/lib/server/browserType';8updateOffline(true);9import { updateOffline } from 'playwright/lib/server/browserType';10updateOffline(false);11import { updateOffline } from 'playwright/lib/server/browserType';12updateOffline(true);13import { updateOffline } from 'playwright/lib/server/browserType';14updateOffline(false);15import { updateOffline } from 'playwright/lib/server/browserType';16updateOffline(true);17import { updateOffline } from 'playwright/lib/server/browserType';18updateOffline(false);19import { updateOffline } from 'playwright/lib/server/browserType';20updateOffline(true);21import { updateOffline } from 'playwright/lib/server/browserType';22updateOffline(false);23import { updateOffline } from 'playwright/lib/server/browserType';24updateOffline(true);25import { updateOffline } from 'playwright/lib/server/browserType';26updateOffline(false);27import { updateOffline } from 'playwright/lib/server/browserType';28updateOffline(true);29import { updateOffline } from 'playwright/lib/server/browserType';30updateOffline(false);31import { updateOffline } from 'playwright/lib/server/browserType';32updateOffline(true);33import
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!