Merge branch 'gajuexpress' of ssh://git.qpq.swiss:21203/QPQ-AG/GajuDesk into gajuexpress
This commit is contained in:
+94
-2
@@ -72,6 +72,7 @@
|
|||||||
sign = none :: none | wx:wx_object(),
|
sign = none :: none | wx:wx_object(),
|
||||||
size = none :: none | wx:wx_object(),
|
size = none :: none | wx:wx_object(),
|
||||||
cost = none :: none | wx:wx_object(),
|
cost = none :: none | wx:wx_object(),
|
||||||
|
quote = none :: none | pos_integer(),
|
||||||
ul = none :: none | wx:wx_object()}).
|
ul = none :: none | wx:wx_object()}).
|
||||||
|
|
||||||
%-record(mochila,
|
%-record(mochila,
|
||||||
@@ -200,7 +201,7 @@ init({Prefs, {Selected, Keys}}) ->
|
|||||||
CostT = wxStaticText:new(CostBox, ?wxID_ANY, "[N/A]"),
|
CostT = wxStaticText:new(CostBox, ?wxID_ANY, "[N/A]"),
|
||||||
_ = wxStaticBoxSizer:add(CostSz, CostT, zxw:flags({wide,5})),
|
_ = wxStaticBoxSizer:add(CostSz, CostT, zxw:flags({wide,5})),
|
||||||
_ = wxStaticBoxSizer:add(UploadSz, CostSz, zxw:flags({wide,5})),
|
_ = wxStaticBoxSizer:add(UploadSz, CostSz, zxw:flags({wide,5})),
|
||||||
UploadB = #w{wx = UploadW} = make_button(UploadBox, ul, J("Upload")),
|
UploadB = #w{wx = UploadW} = make_button(UploadBox, ul, J("Check Quote")),
|
||||||
_ = wxButton:disable(UploadW),
|
_ = wxButton:disable(UploadW),
|
||||||
_ = wxStaticBoxSizer:add(UploadSz, UploadW, zxw:flags({base,5})),
|
_ = wxStaticBoxSizer:add(UploadSz, UploadW, zxw:flags({base,5})),
|
||||||
|
|
||||||
@@ -227,6 +228,7 @@ init({Prefs, {Selected, Keys}}) ->
|
|||||||
end,
|
end,
|
||||||
ok = gd_v:safe_size(Frame, NewPrefs),
|
ok = gd_v:safe_size(Frame, NewPrefs),
|
||||||
|
|
||||||
|
ok = wxTextCtrl:connect(DestT, command_text_updated),
|
||||||
ok = wxPanel:dragAcceptFiles(Panel, true),
|
ok = wxPanel:dragAcceptFiles(Panel, true),
|
||||||
ok = wxPanel:connect(Panel, drop_files),
|
ok = wxPanel:connect(Panel, drop_files),
|
||||||
ok = wxFrame:connect(Frame, command_button_clicked),
|
ok = wxFrame:connect(Frame, command_button_clicked),
|
||||||
@@ -299,6 +301,9 @@ handle_event(#wx{event = #wxCommand{type = command_choice_selected}}, State) ->
|
|||||||
handle_event(#wx{event = #wxCommand{type = command_listbox_doubleclicked}}, State) ->
|
handle_event(#wx{event = #wxCommand{type = command_listbox_doubleclicked}}, State) ->
|
||||||
NewState = do_dl(State),
|
NewState = do_dl(State),
|
||||||
{noreply, NewState};
|
{noreply, NewState};
|
||||||
|
handle_event(#wx{event = #wxCommand{type = command_text_updated}}, State) ->
|
||||||
|
NewState = do_check_ul_button(State),
|
||||||
|
{noreply, NewState};
|
||||||
handle_event(#wx{event = #wxDropFiles{files = Files}}, State) ->
|
handle_event(#wx{event = #wxDropFiles{files = Files}}, State) ->
|
||||||
NewState = do_drop(Files, State),
|
NewState = do_drop(Files, State),
|
||||||
{noreply, NewState};
|
{noreply, NewState};
|
||||||
@@ -437,19 +442,106 @@ do_dl(State) ->
|
|||||||
State.
|
State.
|
||||||
|
|
||||||
|
|
||||||
do_drop([Path], State) ->
|
do_check_ul_button(State = #s{ul = #w{wx = UL_B}}) ->
|
||||||
|
_ = wxButton:enable(UL_B, [{enable, should_enable_quote(State)}]),
|
||||||
|
State.
|
||||||
|
|
||||||
|
|
||||||
|
do_drop([Path], State = #s{path = PathP, ul = #w{wx = UL_B}}) ->
|
||||||
ok = tell(info, "Path: ~ts", [Path]),
|
ok = tell(info, "Path: ~ts", [Path]),
|
||||||
|
ok =
|
||||||
|
case filelib:is_file(Path) of
|
||||||
|
true ->
|
||||||
|
ok = wxFilePickerCtrl:setPath(PathP, Path),
|
||||||
|
_ = wxButton:enable(UL_B, [{enable, should_enable_quote(State)}]),
|
||||||
|
ok;
|
||||||
|
false ->
|
||||||
|
tell(warning, "Thank you, Mario! But our file is in a different path.")
|
||||||
|
end,
|
||||||
State;
|
State;
|
||||||
do_drop(Paths, State) ->
|
do_drop(Paths, State) ->
|
||||||
ok = tell(info, "Paths: ~tp", [Paths]),
|
ok = tell(info, "Paths: ~tp", [Paths]),
|
||||||
|
ok = tell(info, "THIS IS A NO NO"),
|
||||||
State.
|
State.
|
||||||
|
|
||||||
|
should_enable_quote(#s{dest = DestT, path = PathP}) ->
|
||||||
|
DestKey = wxTextCtrl:getValue(DestT),
|
||||||
|
Path = wxFilePickerCtrl:getPath(PathP),
|
||||||
|
length(DestKey) > 0 andalso length(Path) > 0.
|
||||||
|
|
||||||
|
|
||||||
|
do_ul(State = #s{quote = none, rider = none}) ->
|
||||||
|
check_quote(State);
|
||||||
do_ul(State) ->
|
do_ul(State) ->
|
||||||
ok = tell(info, "Would do_ul."),
|
ok = tell(info, "Would do_ul."),
|
||||||
State.
|
State.
|
||||||
|
|
||||||
|
|
||||||
|
check_quote(State = #s{dest = DestT}) ->
|
||||||
|
Dest = wxTextCtrl:getValue(DestT),
|
||||||
|
case gmser_api_encoder:safe_decode(account_pubkey, list_to_binary(Dest)) of
|
||||||
|
{ok, PubKey} ->
|
||||||
|
check_quote2(State, PubKey);
|
||||||
|
{error, Reason} ->
|
||||||
|
tell(warning, "Destination Key decode failed with: ~p", [Reason]),
|
||||||
|
State
|
||||||
|
end.
|
||||||
|
|
||||||
|
check_quote2(State = #s{path = PathP}, PubKey) ->
|
||||||
|
Path = wxFilePickerCtrl:getPath(PathP),
|
||||||
|
case filelib:is_file(Path) of
|
||||||
|
true ->
|
||||||
|
check_quote3(State, PubKey, Path);
|
||||||
|
false ->
|
||||||
|
tell(info, "File path isn't a file"),
|
||||||
|
State
|
||||||
|
end.
|
||||||
|
|
||||||
|
check_quote3(State = #s{ttl = TTL_T}, PubKey, Path) ->
|
||||||
|
TTL_S = wxTextCtrl:getValue(TTL_T),
|
||||||
|
case string_to_int(TTL_S) of
|
||||||
|
{ok, TTL} ->
|
||||||
|
check_quote4(State, PubKey, Path, TTL);
|
||||||
|
error ->
|
||||||
|
tell(info, "TTL isn't an integer"),
|
||||||
|
State
|
||||||
|
end.
|
||||||
|
|
||||||
|
check_quote4(State = #s{sign = SigC}, PubKey, Path, TTL) ->
|
||||||
|
SigYN = wxCheckBox:is_checked(SigC),
|
||||||
|
check_quote5(State, PubKey, Path, TTL, SigYN).
|
||||||
|
|
||||||
|
check_quote5(State, PubKey, Path, TTL, SigYN) ->
|
||||||
|
Tar = tar_path(),
|
||||||
|
case erl_tar:create(TarPath, Path, [compressed, dereference]) of
|
||||||
|
ok ->
|
||||||
|
check_quote6(State, PubKey, TTL, SigYN, Tar);
|
||||||
|
{error, Reason} ->
|
||||||
|
tell(warning, "Tar operation failed with: ~p", [Reason]),
|
||||||
|
State
|
||||||
|
end.
|
||||||
|
|
||||||
|
check_quote6(State, PubKey, TTL, SigYN, Tar) ->
|
||||||
|
|
||||||
|
|
||||||
|
tar_path() ->
|
||||||
|
TarFile = integer_to_list(erlang:system_time(seconds)) ++ "tar.gz",
|
||||||
|
filename:join(zx_lib:path(tmp, "otpr", "gajudesk"), TarFile).
|
||||||
|
|
||||||
|
check_quote6(State, PubKey, Path, TTL, SigYN, Tar) ->
|
||||||
|
|
||||||
|
% PID = spawn_link(gd_n_rider, init, [PubKey, {"localhost", 7777}]),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
string_to_int(S) ->
|
||||||
|
try
|
||||||
|
{ok, list_to_integer(S)}
|
||||||
|
catch
|
||||||
|
error:bad_arg -> error
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
do_close(#s{frame = Frame, prefs = Prefs}) ->
|
do_close(#s{frame = Frame, prefs = Prefs}) ->
|
||||||
Geometry =
|
Geometry =
|
||||||
case wxTopLevelWindow:isMaximized(Frame) of
|
case wxTopLevelWindow:isMaximized(Frame) of
|
||||||
|
|||||||
Reference in New Issue
Block a user