Compare commits
3 Commits
v0.7
..
522b6fa517
| Author | SHA1 | Date | |
|---|---|---|---|
| 522b6fa517 | |||
| bee49ee7dc | |||
| accc2a79bc |
@@ -33,6 +33,9 @@ $(OBJ_PATH)/%.o: $(SRC_PATH)/%.cpp
|
|||||||
$(CPPC) $(CPPC_FLAGS) -c $< -o $@
|
$(CPPC) $(CPPC_FLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
|
||||||
|
install:
|
||||||
|
@install -vpm 755 -o root -g root $(BIN_PATH)/bakatui /usr/bin/
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -fr build
|
rm -fr build
|
||||||
|
|
||||||
|
|||||||
+2
-11
@@ -47,8 +47,6 @@ send_curl_request(std::string endpoint, uint8_t type, std::string req_data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (curl) {
|
if (curl) {
|
||||||
// DEBUG
|
|
||||||
// std::clog << BLUE"[LOG]" << RESET" sending to endpoint: " << url << "\n";
|
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
|
||||||
@@ -124,8 +122,7 @@ void login(std::string username, std::string password) {
|
|||||||
|
|
||||||
access_token = resp_parsed["access_token"];
|
access_token = resp_parsed["access_token"];
|
||||||
|
|
||||||
// DEBUG
|
|
||||||
std::cout << "access token: " << access_token << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void refresh_access_token() {
|
void refresh_access_token() {
|
||||||
@@ -142,9 +139,7 @@ void refresh_access_token() {
|
|||||||
"token&refresh_token={}",
|
"token&refresh_token={}",
|
||||||
refresh_token);
|
refresh_token);
|
||||||
|
|
||||||
// DEBUG
|
|
||||||
std::clog << "calling send_curl_request() with folowing req_data\n"
|
|
||||||
<< req_data << std::endl;
|
|
||||||
auto [response, http_code] = send_curl_request("api/login", POST, req_data);
|
auto [response, http_code] = send_curl_request("api/login", POST, req_data);
|
||||||
if (http_code != 200) {
|
if (http_code != 200) {
|
||||||
std::cerr << RED "[ERROR] " << RESET << http_code
|
std::cerr << RED "[ERROR] " << RESET << http_code
|
||||||
@@ -176,10 +171,6 @@ json get_data_from_endpoint(std::string endpoint) {
|
|||||||
auto [response, http_code] = send_curl_request(endpoint, GET, req_data);
|
auto [response, http_code] = send_curl_request(endpoint, GET, req_data);
|
||||||
|
|
||||||
if (http_code != 200) {
|
if (http_code != 200) {
|
||||||
// DEBUG
|
|
||||||
std::clog << "Failed geting data from endpoint: " << endpoint
|
|
||||||
<< " code: " << http_code << "\nrequest: " << req_data
|
|
||||||
<< "\nresponse: " << response << std::endl;
|
|
||||||
refresh_access_token();
|
refresh_access_token();
|
||||||
goto access_token_refreshed;
|
goto access_token_refreshed;
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-1
@@ -16,7 +16,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
using nlohmann::json;
|
using nlohmann::json;
|
||||||
#define BOTTOM_PADDING 3
|
#define BOTTOM_PADDING 5
|
||||||
|
|
||||||
#define DEFAULT_OFFSET 3
|
#define DEFAULT_OFFSET 3
|
||||||
|
|
||||||
@@ -246,6 +246,10 @@ void timetable_page() {
|
|||||||
wattroff(selector_windows[i], COLOR_PAIR(COLOR_RED));
|
wattroff(selector_windows[i], COLOR_PAIR(COLOR_RED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
attron(COLOR_PAIR(COLOR_BLUE));
|
||||||
|
mvprintw(LINES - 2, 0,
|
||||||
|
"Arrows/hjkl to select | ENTER to show info | F1 to exit");
|
||||||
|
attroff(COLOR_PAIR(COLOR_BLUE));
|
||||||
|
|
||||||
update_panels();
|
update_panels();
|
||||||
doupdate();
|
doupdate();
|
||||||
@@ -402,6 +406,11 @@ void timetable_page() {
|
|||||||
mvwaddwstr(infobox_window, 6, 1, Theme.c_str());
|
mvwaddwstr(infobox_window, 6, 1, Theme.c_str());
|
||||||
wattroff(infobox_window, COLOR_PAIR(COLOR_CYAN));
|
wattroff(infobox_window, COLOR_PAIR(COLOR_CYAN));
|
||||||
|
|
||||||
|
wattron(infobox_window, COLOR_PAIR(COLOR_BLUE));
|
||||||
|
mvwaddstr(infobox_window, getmaxy(infobox_window) - 2, 1,
|
||||||
|
"Press any key to close");
|
||||||
|
wattroff(infobox_window, COLOR_PAIR(COLOR_BLUE));
|
||||||
|
|
||||||
top_panel(infobox_panel);
|
top_panel(infobox_panel);
|
||||||
update_panels();
|
update_panels();
|
||||||
doupdate();
|
doupdate();
|
||||||
|
|||||||
Reference in New Issue
Block a user