@@ -132,7 +132,7 @@ F{% extends "base.hbs" %}
132132
133133 <div class =" col-4 card" style =" padding: 0pt;" >
134134 <ul class =" list-group list-group-flush" >
135- <a class =" list-group-item" href =" #" onclick =" $('#modal_load_bom').modal('show' )" ><i class =" bi bi-cloud-upload" ></i > Nahrát data (BOM)</a >
135+ <a class =" list-group-item" href =" #" onclick =" openUploadModal( )" ><i class =" bi bi-cloud-upload" ></i > Nahrát data (BOM)</a >
136136 <a class =" list-group-item" href =" ./../print/" ><i class =" bi bi-printer" ></i > Tisknout osazovák</a >
137137 <a class =" list-group-item text-muted" href =" #" ><i class =" bi bi-display" ></i > Zobrazit gerber</a >
138138 <a class =" list-group-item" href =" #" ><i class =" bi bi-question-square" ></i > Nastavit počet kusů <input type =" number" id =" production_multiplication" value =" 1" min =" 1" step =" 1" style =" border: solid gray 1px;width: 5em;text-align: center;padding: 0pt;margin-left: 2em;" onchange =" count_validation($(this).val())" ></a >
@@ -203,7 +203,7 @@ F{% extends "base.hbs" %}
203203 <h5 class =" modal-title" >Importování BOMu (.xml netlist)</h5 >
204204 </div >
205205 <div class =" modal-body" >
206- <div id =" bom_import_step_1 " >
206+ <div id =" bom_import_step_select " class = " bom_import_step " >
207207 <label for =" formFile" class =" form-label" >Vyberte soubor:</label >
208208
209209 <div class =" input-group mb-3" >
@@ -216,12 +216,21 @@ F{% extends "base.hbs" %}
216216 </div >
217217 </div >
218218
219- <div id =" bom_import_step_2" style =" display: none" >
220- Loading
219+ <div id =" bom_import_step_loading" class =" bom_import_step" >
220+ <div class =" spinner-border" role =" status" >
221+ <span class =" visually-hidden" >Loading...</span >
222+ </div >
221223 </div >
222224
223- <div id =" bom_import_step_3" style =" display: none" >
224- Loading
225+ <div id =" bom_import_step_success" class =" bom_import_step" >
226+ <div class =" alert alert-success" role =" alert" >
227+ Nahrání BOMu bylo úsěšné. Stránka bude automaticky obnovena.
228+ </div >
229+ </div >
230+ <div id =" bom_import_step_failed" class =" bom_import_step" >
231+ <div class =" alert alert-danger" role =" alert" >
232+ Nahrání se nezdařilo...
233+ </div >
225234 </div >
226235 </div >
227236<!-- <div class="modal-footer">
@@ -532,129 +541,18 @@ var ust_id_autocomplete = function(cell, onRendered, success, cancel){
532541 return value* $ (" #production_multiplication" ).val ();
533542 };
534543
535- // var table = new Tabulator("#component-table",{
536- // layout:"fitColumns",
537- // columns:[
538- // {title:"#", field:"row", sorter:"number", width:25, editor:"input", editable:false},
539- // {title:"počet", field: "count", sorter:"number", width: 80, editor:"input", editable:false, topCalc:"sum"},
540- // {title:"Pro výrobu", field: "count_multiply", formatter: multiplication, sorter:"number", width: 80, editor:"input", editable:false, topCalc:"sum"},
541- // // {title:"Sklad",
542- // // columns:[
543- // // {title: "Celkem", field:"stock_count", editable: false, width: 80, topCalc:"sum"},
544- // // ]
545- // // },
546- // // {title:"Cena",
547- // // columns:[
548- // // {title: "pol", field:"price_item", editable: false, width: 80},
549- // // {title: "cel", field:"price_row", editable: false, width: 80, topCalc:"sum"},
550- // // ]
551- // // },
552- // {title:"Link", field:"link", formatter:"link", formatterParams: {labelField:"link", urlPrefix:"/store/component/", target:"_blank"}, width: 50},
553- // {title:"Značka", field:"Ref", editor:"input", editable:true, cellDblClick:editf, sorter:"string"},
554- // {title:"Položka", field:"Value", editor:"input", editable:true, cellDblClick:editf},
555- // {title:"MFPN", field:"MFPN", editor:"input", editable:true, cellDblClick:editf},
556- // //{title:"Distributor", field:"Distributor", editor:"input", editable:true, cellDblClick:editf},
557- // {title:"Odkaz", field:"Datasheet", editor:"input", formatter:"link", editable:true, cellDblClick:editf},
558- // {title:"Pouzdro", field:"Footprint", editor:"input", cellClick:function(e, cell){}, cellDblClick:editf},
559- // {title:"UST id", field:"UST_ID", editor: ust_id_autocomplete},
560- // //{title:"Cena",
561- // // columns:[
562- // // {title:"Sklad", field:"price_store", editable:false, topCalc:"avg", width: 95},
563- // // {title:"Použitá", field:"price", editor:"input", topCalc:"avg", editable:true, cellDblClick:editf, width: 95},
564- // // {title:"Cena", field:"price_group", topCalc: "sum", editable:false, width: 95},
565- // // ]
566- // // },
567- // {title:"Poznámka", field:"note", editor:"textarea", editable:true, cellDblClick:function(e, cell){ cell.edit(true);} },
568- // {title:"Dodavatele", field:"supplier", editable:false, formatter: supplier_url},
569- // ],
570- // addRowPos:"bottom",
571- // cellEdited:function(cell){
572- // if(cell._cell.value !== null){
573- // console.log("EDITED");
574- // //console.log(cell);
575- // //console.log(cell._cell.row.cells[7].value);
576- // update_component_parameter(cell._cell.row.cells[7].value, cell._cell.column.field, cell._cell.value);
577- // }
578- // },
579- // ajaxResponse:function(url, params, response){
580- // console.log("AJAX RESPONSE");
581- // console.log(url);
582- // console.log(params);
583- // console.log(response);
584- // //url - the URL of the request
585- // //params - the parameters passed with the request
586- // //response - the JSON object returned in the body of the response.
587-
588- // response = $.map(response, function( val, i ) {
589- // // Do something
590- // console.log(val, i);
591-
592- // var usttext = undefined;
593- // var price = null;
594- // var supplier = [];
595-
596-
597- // if (val['stock'].length > 0){
598-
599- // console.log("PRED SUPPLIER");
600- // supplier = val['stock'][0].supplier;
601-
602- // usttext = val['stock'][0]['name'];
603- // console.log("StockName", val['stock'][0]['name']);
604-
605- // var history = val['stock'][0]['history'];
606-
607- // console.log("Historie:", history);
608- // for(j in history){
609- // if(history[j]['operation'] == 'buy' || history[j]['operation'] == 'inventory'){
610- // console.log("Cena za nakup je", history[j]['price']);
611- // price = history[j]['price'];
612- // break;
613- // }
614- // }
615- // //}
616- // }
617-
618- // var uid = val["_id"]['UST_ID'];
619-
620- // if(typeof uid == 'object'){
621- // uid = val['_id']['UST_ID']['$oid'];
622- // }
623-
624- // return{
625- // row: i,
626- // Ref: val['Ref'],
627- // Value: val['_id']['Value'],
628- // MFPN: val['_id']['MFPN'],
629- // Distributor: val['_id']['Distributor'],
630- // Datasheet: val['_id']['Datasheet'],
631- // stock_count: val['_id']['stock_count'],
632- // count: val['Ref'].length,
633- // count_multiply: val['Ref'].length*1,
634-
635- // price_item: price,
636- // price_row: val['Ref'].length*price,
637- // link: uid,
638- // Footprint: val['_id']['Footprint'],
639- // note: val['_id']['note'],
640- // UST_ID: usttext,
641- // supplier: supplier
642- // }
643- // });
644-
645- // return response; //return the tableData property of a response json object
646- // },
647- // });
648- // table.setData('./?operation=get_components_grouped', {operation:"get_components_grouped"}, 'POST');
649-
650544
651545// Konec tabulky pro seznam polozek
652546
653547
548+ function openUploadModal (){
549+ $ (' .bom_import_step' ).hide ();
550+ $ (' #bom_import_step_select' ).show ();
551+ $ (' #modal_load_bom' ).modal (' show' );
552+ }
654553
655554function startUpload () {
656555 var fileInput = document .getElementById (" ust_bom_file" );
657- // console.log(fileInput.files[0])
658556
659557 var fd = new FormData ();
660558 fd .append (' remove_obsolete' , Number ($ (" #ust_bom_remove_obsolete" ).is (' :checked' )) );
@@ -669,24 +567,26 @@ function startUpload() {
669567 var xhr = new XMLHttpRequest ();
670568 xhr .withCredentials = true ;
671569
570+ xhr .onloadstart = function (){
571+ $ (' .bom_import_step' ).hide ();
572+ $ (' #bom_import_step_loading' ).show ();
573+ };
574+
672575 xhr .onload = function () {
673- if (xhr .status == 200 ) {
674- console .log (" Úspěch - nahráno" );
675- load_components ();
676- } else {
677- alert (" Error! Upload failed" );
678- }
576+ $ (' .bom_import_step' ).hide ();
577+ $ (' #bom_import_step_success' ).show ();
578+ console .log (" Úspěch - nahráno" );
579+ setTimeout (function (){window .location .reload (1 );}, 2000 );
679580 };
581+
680582 xhr .onerror = function () {
681583 alert (" Error! Upload failed. Can not connect to server." );
584+ $ (' .bom_import_step' ).hide ();
585+ $ (' #bom_import_step_failed' ).show ();
682586 };
683587
684588 xhr .open (" POST" , " /production/{{id}}/upload/bom/ust/" , true );
685- // xhr.setRequestHeader("Content-Type", "multipart/form-data");
686589 xhr .send (fd);
687- // xhr.send(fileInput.files[0]+"&remove_obsolete="+$("#ust_bom_remove_obsolete").is(':checked'));
688-
689- load_components ();
690590}
691591
692592
0 commit comments