Commit bb93deea2a58afab5c4ee1d857aaba6405f6b7e9

Authored by totoro
1 parent b8aa6172

add import

controller/hk_controller.anubis
@@ -8,3 +8,4 @@ @@ -8,3 +8,4 @@
8 8
9 9
10 transmit hayamiki_lib/controller/hk_delete.anubis 10 transmit hayamiki_lib/controller/hk_delete.anubis
  11 + transmit kayamiki_lib/controller/hk_rows_import.anubis
controller/hk_rows_import.anubis 0 → 100644
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 09/05/2017
  5 + * Time: 15:27
  6 + * © Calexium
  7 + */
  8 +
  9 +read data_base/sqlite.anubis
  10 +read data_base/read_csv.anubis
  11 +read tools/function.anubis
  12 +
  13 +read hayamiki_lib/model/types/hk_database.anubis
  14 +read calexium_lib/web/CXM_web_arg_utils.anubis
  15 +read calexium_lib/web/CXM_web_session.anubis
  16 +read calexium_lib/database/csv_import_status.anubis
  17 +read lexical_analysis/fast_lexer_4.anubis
  18 +
  19 +
  20 +define Maybe(SQLite3Bind)
  21 + bind_column_value
  22 + (
  23 + String col,
  24 + String value
  25 + ) =
  26 + if col = "" then
  27 + failure
  28 + else
  29 + success(bind_String(":"+col, value)).
  30 +
  31 +define List(Int)
  32 +/* return a list of column index to get from CSV
  33 + */
  34 + get_csv_columns
  35 + (
  36 + List((Int, String)) columns,
  37 + List(Int) so_far
  38 + )=
  39 + map(((Int, String) col) |-> since col is (idx, _), idx, columns)
  40 +.
  41 +
  42 +define String
  43 + dump_csv_db_col
  44 + (
  45 + List((Int, String)) columns,
  46 + String so_far
  47 + )=
  48 + if columns is
  49 + {
  50 + [] then so_far,
  51 + [h . t] then
  52 + if h is (csv_col, db_col) then
  53 + dump_csv_db_col(t, so_far + "csv_col : "+csv_col+" db col name : "+db_col+"\r\n")
  54 + }.
  55 +
  56 +define List(String)
  57 + get_db_columns
  58 + (
  59 + List((Int, String)) columns,
  60 + List(String) so_far
  61 + )=
  62 + if columns is
  63 + {
  64 + [] then reverse(so_far),
  65 + [h . t] then
  66 + if h is (_, db_col) then
  67 + get_db_columns(t, [db_col . so_far])
  68 + }.
  69 +
  70 +
  71 +define List((Int csv_col, String db_col))
  72 + _get_columns_list
  73 + (
  74 + List(Web_arg) lwa,
  75 + Int max_col, //maximum columns in source side
  76 + Int index, //current checking idx
  77 + List((Int, String)) so_far
  78 + ) =
  79 + if index >= max_col then
  80 + reverse(so_far)
  81 + else if get_String(lwa, "col_" + index) is
  82 + {
  83 + failure then _get_columns_list(lwa, max_col, index + 1, so_far),
  84 + success(db_col_name) then _get_columns_list(lwa, max_col, index + 1, [(index, db_col_name) . so_far])
  85 + }
  86 +.
  87 +
  88 +
  89 +define List((Int csv_col, String db_col))
  90 +/* get the list of source columns selected for importation process
  91 + */
  92 + get_columns_list
  93 + (
  94 + List(Web_arg) lwa
  95 + ) =
  96 + with max_col = get_Int(lwa, "hk_source_col", 0),
  97 + _get_columns_list(lwa, max_col, 0, [])
  98 +.
  99 +
  100 +define (Int, List(List(String)))
  101 + extract_lines
  102 + (
  103 + One -> ReadCsvResult cvs_line_reader,
  104 + Int max_count, //number of line to extract
  105 + List(String) columns,
  106 + Int offset,
  107 + List(List(String)) so_far
  108 + ) =
  109 + if max_count =< 0 then
  110 + (offset, so_far)
  111 + else
  112 + if cvs_line_reader(unique) is
  113 + {
  114 + end_of_input then (offset, so_far)
  115 + error(e) then
  116 + //TODO report that error in importation report
  117 + println("error ["+e+"]\n"); (offset, so_far),
  118 + ok(_offset, all_values) then
  119 + //if line_data is (line, all_values) then
  120 + extract_lines(cvs_line_reader, max_count - 1, columns, _offset, [all_values . so_far])
  121 + }
  122 +.
  123 +
  124 +define Result(String, One)
  125 + insert_data_to_table
  126 + (
  127 + SQLite3Stmt insert_data_stmt,
  128 + List(String) columns,
  129 + List(String) values
  130 + )=
  131 + if sqlite3_reset(insert_data_stmt) is
  132 + {
  133 + error(err) then println(db_error(err, "Error reseting insert data statement")); error("DB Error"),
  134 + ok then
  135 + if sqlite3_bind(insert_data_stmt, map2_select(bind_column_value, columns, values)) is
  136 + {
  137 + error(err) then println(db_error(err, "Error binding insert data statement"));error("DB Error"),
  138 + ok then
  139 + if sqlite3_step(insert_data_stmt) is
  140 + {
  141 + error(err) then println(db_error(err, "Error executing insert data statement")); error("DB Error"),
  142 + no_more_row then ok(unique),
  143 + row(_) then ok(unique)
  144 + }
  145 + }
  146 + }.
  147 +
  148 +define Maybe(One)
  149 + store_data
  150 + (
  151 + SQLite3Stmt insert_data_stmt,
  152 + SQLite3Stmt update_data_stmt,
  153 +// SQLite3Stmt select_contact_id_opt_out_stmt,
  154 +// SQLite3Stmt select_stmt,
  155 +// SQLite3Stmt insert_list_contact_stmt,
  156 +// SQLite3Stmt count_stmt,
  157 + List(String) columns, //list of column's name
  158 + List(List(String)) rows //list of list of real data to store
  159 + ) =
  160 + if rows is
  161 + {
  162 + [] then success(unique),
  163 + [row . t] then
  164 + if insert_data_to_table(insert_data_stmt, columns, row) is
  165 + {
  166 + error(msg) then
  167 + println("data can't be added "+msg);
  168 + //TODO as Julien's idea, copy error line in new csv file
  169 + store_data(insert_data_stmt, update_data_stmt, columns, t),
  170 +
  171 + ok(_) then
  172 + store_data(insert_data_stmt, update_data_stmt, columns, t)
  173 + }
  174 + }
  175 +.
  176 +
  177 +define CSV_Import_Status
  178 + main_loop
  179 + (
  180 + SQLite3DataBase db,
  181 +// Int import_id, */
  182 + SQLite3Stmt insert_data_stmt,
  183 + SQLite3Stmt update_data_stmt,
  184 +
  185 + One -> ReadCsvResult csv_line_reader,
  186 + //One -> Int progression,
  187 + UTime start_time,
  188 + List(String) columns,
  189 + Int line_num,
  190 + Int _offset,
  191 + Int offset_base
  192 + ) =
  193 +// with prog = progression(unique),
  194 +// logDebug(debug_log, "Importing contacts into mailing in progress... " + abs_to_decimal(prog) + " Bytes");
  195 +// logDebug(debug_log, "Importing contacts into mailing in progress... Lines:" + line_num + " "+ (offset_base + offset) + " Bytes read");
  196 + //import_csv_set_status(db, list_id, csv_in_progress);
  197 + with new_time = unow,
  198 + since new_time - start_time is utime(seconds, _),
  199 +//! import_task_update_progress(db, import_id, seconds, line_num, offset_base + offset);
  200 +
  201 + //get 500 lines from cvs
  202 + since extract_lines(csv_line_reader, 500, columns, _offset, []) is (offset, so_far),
  203 + with extract_length = length(so_far),
  204 + println("Extracted lines : "+extract_length);
  205 +
  206 + if extract_length = 0 then
  207 + csv_finished
  208 + else
  209 + if db_do_transaction(
  210 + db,
  211 + (One _) |-> store_data(insert_data_stmt, update_data_stmt, columns, so_far),
  212 + success((SQLite3Error err) |-> println(db_error(err,"import_csv_to_db"))),
  213 + //success((SQLite3Error err) |-> logError("DB", db_error(err,"import_csv_to_db"))),
  214 + 60000, // max 60s
  215 + 100 // retry every 100 ms
  216 + ) is
  217 + {
  218 + error(_) then csv_db_error,
  219 + ok(_) then main_loop(db, insert_data_stmt, update_data_stmt, csv_line_reader, new_time, columns, line_num + extract_length, offset, offset_base)
  220 + }
  221 +.
  222 +
  223 +define CSV_Import_Status
  224 + import_csv_to_db_transaction
  225 + (
  226 + SQLite3DataBase db,
  227 + String table_name,
  228 +// Import_Task import_task,
  229 + One -> ReadCsvResult csv_line_reader,
  230 + //(One) -> Int progression,
  231 + List(String) columns, //columns selected for importation in same order from CSV file
  232 + UTime start_time,
  233 + Int offset_base
  234 + )=
  235 + //since import_task is import_task(import_task_id, list_id, filename, file_size, csv_db_columns, separator, charset, amount_time, offset, current_line, lines_count, status, status_details, update_contact, opt_out_import),
  236 + with current_line = (Int)0,
  237 + with offset = (Int)0,
  238 +// if get_domain_id_from_mailing(db, list_id) is
  239 +// {
  240 +// failure then logError(debug_log, "domain_id not found in import_csv_to_mailing_list"); csv_error,
  241 +// success(domain_id) then
  242 + with filter_columns = map_select((String s) |-> if s = "" then failure else success(s), columns),
  243 + sql_columns = join(", ", filter_columns),
  244 + sql_values = join(", ", map((String s) |-> ":"+s, filter_columns)),
  245 + with sql_update_values = join(", ", map((String s) |-> s+"=:"+s, filter_columns)),
  246 +
  247 + if sqlite3_prepare(db, "INSERT INTO "+table_name+" ("+sql_columns+") VALUES ("+sql_values+");") is
  248 + {
  249 + error(err) then //logError(debug_log, db_error(err, "preparing insert contact statement for import_csv_to_mailing_list"));
  250 + println(db_error(err, "preparing insert data statement for import_csv_to_mailing_list"));
  251 + csv_db_error,
  252 + ok(insert_data_stmt) then
  253 +
  254 + if sqlite3_prepare(db, "UPDATE "+table_name+" SET " + sql_update_values + " WHERE id=:id;") is
  255 + {
  256 + error(err) then //logError(debug_log, db_error(err, "preparing update contact statement for import_csv_to_mailing_list"));
  257 + println(db_error(err, "preparing update data statement for import_csv_to_db_transaction"));
  258 + csv_db_error,
  259 + ok(update_data_stmt) then
  260 + /* run the main loop */
  261 + main_loop(db, /*import_task_id, */ insert_data_stmt, update_data_stmt, csv_line_reader, start_time, columns, current_line, offset, offset_base)
  262 + }
  263 + }
  264 +// }
  265 +.
  266 +
  267 +
  268 +public define Result(String, String)
  269 + hkc_import_execute
  270 + (
  271 + WEB_Session _session,
  272 + SQLite3DataBase db,
  273 + HK_Database hk_db
  274 + )=
  275 + //arguments list
  276 + //table_name
  277 + //file
  278 + //csv_sep
  279 + //col_x = 'target_col', where x is the column number in csv file and target_col is name of the column in the table
  280 + //with _T = make_translate_function(_session.language),
  281 + with lwa = _session.web_request.lwa,
  282 + with separator = get_String(lwa, "csv_sep", ";"),
  283 + with csv_db_columns = get_columns_list(lwa),
  284 + with columns = get_db_columns(csv_db_columns, []),
  285 + table_name = get_String(lwa, "table_name", ""),
  286 + with start_time = unow,
  287 + offset_base = (Int)0,
  288 + skip_first_line = get_Bool(lwa, "hk_remove_csv_header", true),
  289 +
  290 + file_name_full_path = get_String(_session.fields, "upl_file", ""),
  291 + println(dump_csv_db_col(csv_db_columns,""));
  292 +
  293 + if file(file_name_full_path, read) is
  294 + {
  295 + failure then
  296 + error("Can't open CSV file '" + file_name_full_path + "'")
  297 + //import_task_set_status(db, import_id, csv_file_not_found),
  298 + success(f) then
  299 + //with file_size = file_size(f),
  300 + if make_lexing_stream("", f, 65536, 10) is
  301 + {
  302 + failure then error("csv_error Error while reading file"),
  303 + success(ls) then
  304 + with csv_line_reader = make_read_csv_line(ls, separator, get_csv_columns(csv_db_columns, [])),
  305 + (if skip_first_line then
  306 + forget(csv_line_reader(unique))
  307 + else
  308 + unique);
  309 + with status = import_csv_to_db_transaction(db, table_name, csv_line_reader, columns, start_time, offset_base),
  310 + ok("imported")
  311 +
  312 + }
  313 + }
  314 +.
model/utils.anubis 0 → 100644
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 07/05/2017
  5 + * Time: 00:39
  6 + * © Calexium
  7 + */
  8 +
  9 +read hayamiki_lib/model/types/hk_database.anubis
  10 +read hayamiki_lib/model/types/hk_app.anubis
  11 +read hayamiki_lib/model/types/hk_table.anubis
  12 +read hayamiki_lib/model/types/hk_model.anubis
  13 +read hayamiki_lib/model/types/hk_model_column.anubis
  14 +
  15 +define Maybe(HK_Table)
  16 + get_table
  17 + (
  18 + String prefix, //the prefix is app name if exists else nothing
  19 + List(HK_Table) tables,
  20 + String table_name
  21 + )=
  22 + if tables is
  23 + {
  24 + [] then failure, //table not found
  25 + [h. t] then
  26 + since h is hk_table(name, _, _, _),
  27 + println("testing "+table_name+" "+prefix+name);
  28 + if table_name = prefix+name then
  29 + success(h)
  30 + else
  31 + get_table(prefix, t, table_name)
  32 + }
  33 +.
  34 +
  35 +define Maybe(HK_Table)
  36 + get_table
  37 + (
  38 + List(HK_App) apps,
  39 + String table_name
  40 + )=
  41 + if apps is
  42 + {
  43 + [] then failure,
  44 + [app . t] then
  45 + since app is hk_app(app_name, _, _, tables),
  46 + with prefix = if length(app_name) > 0 then app_name+"_" else "",
  47 + if get_table(prefix, tables, table_name) is
  48 + {
  49 + failure then get_table(t, table_name),
  50 + success(table) then success(table)
  51 + }
  52 + }
  53 +.
  54 +
  55 +public define Maybe(HK_Table)
  56 + get_table
  57 + (
  58 + HK_Database hk_db,
  59 + String table_name
  60 + )=
  61 + since hk_db is hk_database(_, apps),
  62 + get_table(apps, table_name)
  63 +.
  64 +
  65 +public define List((String, String))
  66 + get_columns_name_and_TAG
  67 + (
  68 + HK_Table table
  69 + )=
  70 + [ ("id","ID") .
  71 + map((HK_Model_Column column) |->
  72 + since column is hk_column(name, type, attributes, help),
  73 + (name, to_upper(name))
  74 + ,
  75 + table.model.columns
  76 + )
  77 + ]
  78 +.
  79 +
view/view_apps_renderer.anubis
@@ -25,7 +25,7 @@ define List(HTML_Row(HTML_Off_Form)) @@ -25,7 +25,7 @@ define List(HTML_Row(HTML_Off_Form))
25 (String) -> String _T, 25 (String) -> String _T,
26 )= 26 )=
27 map_append((HK_App app) |-> since app is hk_app(app_name, icon, help, tables), 27 map_append((HK_App app) |-> since app is hk_app(app_name, icon, help, tables),
28 - [ (HTML_Row(HTML_Off_Form))row([core_attrs([class("hk_app_title")])],cell([columns(5)],text(app_name)))]+ //APP name line 28 + [ (HTML_Row(HTML_Off_Form))row([core_attrs([class("hk_app_title")])],cell([columns(6)],text(app_name)))]+ //APP name line
29 //here map for each table 29 //here map for each table
30 map((HK_Table table) |-> since table is hk_table(_table_name, short_name, model, display), 30 map((HK_Table table) |-> since table is hk_table(_table_name, short_name, model, display),
31 //construct the real name of the table (app + table_name) 31 //construct the real name of the table (app + table_name)
@@ -44,6 +44,12 @@ define List(HTML_Row(HTML_Off_Form)) @@ -44,6 +44,12 @@ define List(HTML_Row(HTML_Off_Form))
44 text(_T("LIST")) 44 text(_T("LIST"))
45 ]) 45 ])
46 ), 46 ),
  47 + cell(
  48 + sequence([
  49 + partial(img_button("icons/16x16/table_import.png", hkc_import_dropzone, [("table_name",table_name)])),
  50 + text(_T("CSV_IMPORT"))
  51 + ])
  52 + ),
47 cell(text(_T("RECORDS_COUNT")+" ")), 53 cell(text(_T("RECORDS_COUNT")+" ")),
48 cell([right], text(get_count(db, table_name))) 54 cell([right], text(get_count(db, table_name)))
49 ]) 55 ])
view/view_rows_import.anubis 0 → 100644
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 06/05/2017
  5 + * Time: 10:33
  6 + * © Calexium
  7 + */
  8 +
  9 +read locale/L3.anubis
  10 +read locale/L3LanguageInfo.anubis //date and time formating
  11 +read system/data_io.anubis
  12 +read tools/line_reader.anubis
  13 +
  14 +read calexium_lib/database/csv_tools.anubis
  15 +read calexium_lib/web/CXM_making_a_web_site.anubis
  16 +read calexium_lib/web/CXM_jquery.anubis
  17 +read calexium_lib/web/jQuery/CXM_jquery_button.anubis
  18 +read calexium_lib/web/widgets/css_helper.anubis
  19 +read calexium_lib/web/widgets/icons_set.anubis
  20 +
  21 +read hayamiki_lib/view/web_action.anubis
  22 +
  23 +read web_pages/desktop.anubis
  24 +read app/app_constants.anubis
  25 +read version.anubis
  26 +
  27 +public define List((List(CoreAttrs), WebArgValue, String))
  28 + csv_delimiter_combo
  29 + (
  30 + (String) -> String _T
  31 + )
  32 + =
  33 + (List((List(CoreAttrs), WebArgValue, String)))[
  34 + ([],wav(","), _T("COMA_SEP")),
  35 + ([],wav(";"), _T("SEMICOLON_SEP"))].
  36 +
  37 +
  38 +
  39 +public define HTML_Partial_Content
  40 + import_zone
  41 + (
  42 + String table_name,
  43 + (String) -> String _T
  44 + )=
  45 + html_wave_box(_T("CONTROL_PANEL"),
  46 + partial_content(
  47 + [ js(js_file("js/dropzone.js")),
  48 + js_inline(jquery_ready("Dropzone.options.myAwesomeDropzone = {
  49 + maxFiles: 1,
  50 + dictDefaultMessage : \""+_T("DROP_FILE_HERE")+"\",
  51 + dictFileTooBig : \""+_T("FILE_TOO_BIG")+"\",
  52 + };
  53 + $('#my-awesome-dropzone').dropzone(); ")),
  54 + ],
  55 +
  56 + sequence([
  57 + text([], _T("CSV_IMPORT_FOR")+" "+table_name),
  58 + form("my-awesome-dropzone",[class("dropzone")], hkc_import_file,
  59 + [("format","csv"), ("table_name",table_name)],
  60 + empty),
  61 + partial(jquery_button(jquery_img_button(icn16_cross, _T("CANCEL"), "", jQuery_actioner(same, jqlink(hkc_cancel)), left))),
  62 + partial(jquery_button(jquery_img_button(icn16_check, _T("IMPORT"), "", jQuery_actioner(same, jqlink(hkc_import_choose_col, [("format","csv"), ("table_name",table_name)])), left)))
  63 + ])
  64 + )
  65 + )
  66 +.
  67 +
  68 +define List(HTML_Row(HTML_In_Form))
  69 + source_lines
  70 + (
  71 + List(String) cols,
  72 + List(HTML_Row(HTML_In_Form)) so_far,
  73 + Int index,
  74 + (String) -> String _T
  75 + )=
  76 + if cols is
  77 + {
  78 + [] then reverse(so_far),
  79 + [ h . t ] then
  80 + source_lines( t, [ row([cell([style("display:none")], literal("")),
  81 + cell([core_attrs([id("col_"+index), class("dnd-src")])], text(_T("COLUMN")+ " "+index+" ("+h+")"))]) . so_far], index+1, _T)
  82 + }
  83 + .
  84 +
  85 +public define HTML_In_Form
  86 + source_file_column_table
  87 + (
  88 + Word8 separator,
  89 + String uploaded_file,
  90 + (String) -> String _T
  91 + )=
  92 + if file(uploaded_file, read) is
  93 + {
  94 + failure then
  95 + //logError(debug_log, "Can't open CSV file '" + f_name + "'"); text(_T("CANT_OPEN_FILE")),
  96 + println("Can't open CSV file '" + uploaded_file + "'");
  97 + text(_T("CANT_OPEN_FILE"))
  98 + success(f) then
  99 + //logDebug(debug_log, "file opened, make_line_reader");
  100 + //Parse the first line
  101 + if csv_read_line(make_data_io(f), separator, false, "", [], []) is
  102 + {
  103 + failure then
  104 + //logError(debug_log, "Can't parse 1st line of CSV file '" + f_name + "'");
  105 + text(_T("PARSE_ERROR")),
  106 + success(col_data) then
  107 + //logDebug(debug_log, "read_line: read");
  108 +
  109 + if col_data is (line, cols) then
  110 + sequence([
  111 + hidden(html_Id("hk_source_col"), wan("hk_source_col"), wav(to_String(length(cols)))),
  112 + table([core_attrs([class("changelist small"), id("table-src")])],
  113 + header_row([ header_cell([style("display:none")], literal("")),
  114 + header_cell(literal("CSV_FILE_FIELDS"))]),
  115 + source_lines(cols, [], 0, _T)
  116 + )
  117 + ])
  118 + }
  119 + }.
  120 +.
  121 +
  122 +define List(HTML_Row(HTML_In_Form))
  123 + target_lines
  124 + (
  125 + List((String,String)) cols,
  126 + List(HTML_Row(HTML_In_Form)) so_far,
  127 + Int index,
  128 + (String) -> String _T
  129 + )=
  130 + //if tb is tool_box(lang, _, _T, _, db, user, _, _) then
  131 + if cols is
  132 + {
  133 + [] then reverse(so_far),
  134 + [ h . t ] then
  135 + since h is (hidden_name, text_field),
  136 + target_lines( t,[ row([
  137 + cell([style("display:none")], empty),
  138 + cell([class("dnd-text ")], text(_T(text_field))),
  139 + cell([class("dnd-dst")], sequence([
  140 + text(_T("IGNORED_COLUMN")),
  141 + hidden(html_Id("hk_"+hidden_name+"_input"), wan(""), wav(hidden_name))
  142 + ])),
  143 + cell([class("icon ")],image([class("dnd-dst-btn")],"/icons/16x16/delete_cross.png",""))
  144 + ])
  145 + . so_far], index+1, _T)
  146 + }.
  147 +
  148 +define HTML_In_Form
  149 + target_column_table
  150 + (
  151 + List((String,String)) choices,
  152 + (String) -> String _T
  153 + )=
  154 + //since tb is tool_box(lang, _, _T, _, db, user, _, _),
  155 +
  156 + table([core_attrs([class("changelist small"), id("table-dst")])],
  157 + header_row([ header_cell([style("display:none")], empty),
  158 + header_cell(text(_T("TABLE_FIELDS"))),
  159 + header_cell(text(_T("IMPORTED_FIELDS"))),
  160 + header_cell(literal("&nbsp"))]),
  161 + target_lines(choices, [], 0, _T)
  162 + )
  163 +.
  164 +
  165 +public define HTML_Partial_Content
  166 + import_choose_col
  167 + (
  168 + String target_table_name,
  169 + List((String,String)) target_columns_choices,
  170 + String separator,
  171 + String uploaded_file,
  172 + WEB_Action_Name cancel_action,
  173 + (String) -> String _T,
  174 + )=
  175 + partial_content([css(css_file("css/cxm/cxm_dnd.css")),
  176 + js(js_file("js/cxm/cxm_dnd.js")),
  177 + js(js_file("js/data_import.js"))
  178 + ],
  179 + sequence([
  180 + form("import_csv_form",[], hkc_import_execute, [("table_name", target_table_name), ("file",uploaded_file)], sequence([
  181 + table([class("changelist small")],
  182 + header_row([ header_cell(literal("&nbsp;")),
  183 + header_cell(text(_T("INFORMATION_OF_SOURCE_FILE"))),
  184 + header_cell(literal("&nbsp;")),
  185 + ]),
  186 + [row([], [cell(image(icn16_mime_csv)), cell(text(_T("FILE_FORMAT"))), cell(text(_T("CSV_FILE")))]),
  187 + row([], [cell(image(icn16_mime_unknown)), cell(text(_T("SOURCE_FILE_TO_IMPORT"))), cell(text(uploaded_file))]),
  188 + row([], [cell(empty), cell(text(_T("DELIMITER"))), cell(selector_c([], no_label, html_Id("import_delimiter"), wan("csv_sep"), 1, csv_delimiter_combo(_T), init(separator)),)]),
  189 + row([], [cell(empty), cell(text(_T("FILE_ENCODING"))), cell(text("choose encoding"))]),
  190 + row([], [cell(empty), cell(text(_T("REMOVE_CSV_HEADER"))), cell(check_box([], no_label, html_Id(""), wan("hk_remove_csv_header"), wav("1"), true))]),
  191 +// row([], [cell(empty), cell(text(_T("OPT_OUT"))), cell(check_box([], no_label, html_Id(""), wan("import_opt_out"), wav("1"), false))])] //end of row
  192 + ]),
  193 + br,
  194 + div([id("dragLists")],
  195 + sequence([
  196 + //SOURCE column
  197 + div([style("float: left; margin: 5px;")], div([class("dndContainer ")],
  198 + source_file_column_table(if explode(separator) is { [] then ';', [h . _] then h }, uploaded_file, _T))),
  199 + //TARGET column
  200 + div([style("float: left; margin: 5px;")], div([class("dndContainer ")],
  201 + target_column_table(target_columns_choices, _T))),
  202 +
  203 + div_empty([class("clear")])
  204 + ])),
  205 + //partial(jquery_button(jquery_img_button(icn16_cross, _T("CANCEL"), "", jQuery_actioner(same, jqlink, "go_edit_mailing_list&list_id="+list_id.id), left))),
  206 + //partial(jquery_button(jquery_img_button(icn16_check, _T("IMPORT"), "", jQuery_actioner(same, jqform, "import_csv_form"), left)))
  207 +
  208 + ])), //end of sequence in form
  209 + // )])
  210 + partial(jquery_button(jquery_img_button(icn16_cross, _T("CANCEL"), "", jQuery_actioner(same, jqlink(cancel_action)), left))),
  211 + partial(jquery_button(jquery_img_button(icn16_check, _T("IMPORT"), "", jQuery_actioner(same, jqform("import_csv_form")), left)))
  212 + ]) //end of sequence
  213 + )
  214 +.
view/web_action.anubis
@@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
9 read calexium_lib/web/CXM_making_a_web_site.anubis 9 read calexium_lib/web/CXM_making_a_web_site.anubis
10 10
11 here are defined all action managed by Hayamiki Controller 11 here are defined all action managed by Hayamiki Controller
12 - 12 +
13 public define WEB_Action_Name hkc_edit_table = controller_action("hk_c", "edit_table"). 13 public define WEB_Action_Name hkc_edit_table = controller_action("hk_c", "edit_table").
14 public define WEB_Action_Name hkc_view_editor = controller_action("hk_c", "view_editor"). 14 public define WEB_Action_Name hkc_view_editor = controller_action("hk_c", "view_editor").
15 public define WEB_Action_Name hkc_grid_view = controller_action("hk_c", "grid_view"). 15 public define WEB_Action_Name hkc_grid_view = controller_action("hk_c", "grid_view").
@@ -23,3 +23,7 @@ public define WEB_Action_Name hkc_delete_row = controller_action(&quot;hk_c&quot; @@ -23,3 +23,7 @@ public define WEB_Action_Name hkc_delete_row = controller_action(&quot;hk_c&quot;
23 public define WEB_Action_Name hkc_cancel = controller_action("hk_c", "cancel"). 23 public define WEB_Action_Name hkc_cancel = controller_action("hk_c", "cancel").
24 public define WEB_Action_Name hkc_ajax_edit_table = controller_action("hk_c", "ajax_edit_table"). 24 public define WEB_Action_Name hkc_ajax_edit_table = controller_action("hk_c", "ajax_edit_table").
25 public define WEB_Action_Name hkc_show_apps = controller_action("hk_c", "show_apps"). 25 public define WEB_Action_Name hkc_show_apps = controller_action("hk_c", "show_apps").
  26 +public define WEB_Action_Name hkc_import_dropzone = controller_action("hk_c", "hkc_import_dz").
  27 +public define WEB_Action_Name hkc_import_file = controller_action("hk_c", "hkc_import_file").
  28 +public define WEB_Action_Name hkc_import_choose_col = controller_action("hk_c", "hkc_import_col").
  29 +public define WEB_Action_Name hkc_import_execute = controller_action("hk_c", "hkc_import_exec").