Freelancer Template base Managment page
This commit is contained in:
42
src/main.cpp
42
src/main.cpp
@ -625,7 +625,7 @@ int main(int argc, char *argv[]) {
|
||||
});
|
||||
|
||||
/*
|
||||
* Page for freelancer to sign up
|
||||
* Freelancer Profile page
|
||||
*/
|
||||
CROW_ROUTE(app, "/freelancer/profile")
|
||||
([&, configuration](const crow::request& getRequest ) {
|
||||
@ -638,6 +638,46 @@ int main(int argc, char *argv[]) {
|
||||
return page.render(ctx);
|
||||
});
|
||||
|
||||
/*
|
||||
* Page for freelancer to create/delete/edit Templates
|
||||
*/
|
||||
CROW_ROUTE(app, "/freelancer/templateManagement")
|
||||
([&, configuration](const crow::request& getRequest ) {
|
||||
auto& cookieCtx = app.get_context<crow::CookieParser>(getRequest);
|
||||
crow::mustache::context ctx;
|
||||
string templateHTML = TEMPLATE_FREELANCER_TEMPLATE_MANAGEMENT;
|
||||
if (Utilities::checkCookieLoginState(configuration, cookieCtx)) {
|
||||
ctx = Utilities::getFreelancerTemplates(configuration, cookieCtx.get_cookie(COOKIE_FREELANCER_EMAIL));
|
||||
ctx[MUSTACHE_COOKIE_LOGGED_IN] = true;
|
||||
}
|
||||
auto page = crow::mustache::load(templateHTML);
|
||||
return page.render(ctx);
|
||||
});
|
||||
|
||||
/*
|
||||
* Page for freelancer to create/delete/edit Templates
|
||||
*/
|
||||
CROW_ROUTE(app, "/freelancer/templateManagement/template/<string>").methods("POST"_method)
|
||||
([&, configuration](const crow::request& getRequest, string templateName ) {
|
||||
auto& cookieCtx = app.get_context<crow::CookieParser>(getRequest);
|
||||
crow::mustache::context ctx;
|
||||
string templateHTML = TEMPLATE_FREELANCER_TEMPLATE_MANAGEMENT;
|
||||
if (Utilities::checkCookieLoginState(configuration, cookieCtx))
|
||||
ctx[MUSTACHE_COOKIE_LOGGED_IN] = true;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
auto page = crow::mustache::load(templateHTML);
|
||||
return page.render(ctx);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -24,6 +24,7 @@ namespace TemplateConstCollection {
|
||||
const static std::string TEMPLATE_PASSWORD_RESET_FULFILMENT = "passwordReset_Fulfilment.html";
|
||||
const static std::string TEMPLATE_FREELANCER_REDIRECT_PROFILE = "freelancer_Redirect_Profile.html";
|
||||
const static std::string TEMPLATE_FREELANCER_PROFILE = "freelancer_Profile.html";
|
||||
const static std::string TEMPLATE_FREELANCER_TEMPLATE_MANAGEMENT = "freelancer_Template_Management.html";
|
||||
|
||||
//Mustache Error/Success variable names
|
||||
const static std::string MUSTACHE_ERROR_COMMISSIONS_CLOSED = "ERROR_COMMISSIONS_CLOSED";
|
||||
|
@ -504,5 +504,23 @@ namespace Utilities {
|
||||
Database::executePreparedStatement_UPDATE_EXPIRATION_LOGIN_LOCK_OUT(connection, emailAddress, configuration.bruteForceMitigationLockSeconds);
|
||||
}
|
||||
}
|
||||
|
||||
crow::json::wvalue getFreelancerTemplates(const Utilities::config& configuration, const std::string& emailAddress) {
|
||||
crow::json::wvalue resultJsonFreelancerTemplate;
|
||||
|
||||
pqxx::connection databaseConnection(configuration.databaseConnectionString);
|
||||
Database::prepareStatements(databaseConnection, {
|
||||
ID_SELECT_FREELANCER_ID,
|
||||
ID_SELECT_FREELANCER_TEMPLATES
|
||||
});
|
||||
pqxx::result idResult = Database::executePreparedStatement_SELECT_FREELANCER_ID(databaseConnection, emailAddress);
|
||||
if (!idResult.empty())
|
||||
{
|
||||
int freelancerID = std::stoi(idResult.at(0).at(0).c_str());
|
||||
pqxx::result resultFreelancerTemplates = Database::executePreparedStatement_SELECT_FREELANCER_TEMPLATES(databaseConnection, freelancerID);
|
||||
resultJsonFreelancerTemplate = Database::convertResultToJSON(resultFreelancerTemplates, "templates");
|
||||
}
|
||||
return resultJsonFreelancerTemplate;
|
||||
}
|
||||
}
|
||||
#endif
|
@ -9,15 +9,21 @@
|
||||
Please Log in.
|
||||
{{/COOKIE_LOGGED_IN}}
|
||||
{{#COOKIE_LOGGED_IN}}
|
||||
<div>
|
||||
<form action="/freelancer/inbox" method="get">
|
||||
<button type="submit" class="button">Commission Inbox</button>
|
||||
</form>
|
||||
<form action="/freelancer/createInvoice" method="get">
|
||||
<button type="submit" class="button">Create Invoice</button>
|
||||
</form>
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
<form action="/freelancer/inbox" method="get">
|
||||
<button type="submit" class="button">Commission Inbox</button>
|
||||
</form>
|
||||
<form action="/freelancer/createInvoice" method="get">
|
||||
<button type="submit" class="button">Create Invoice</button>
|
||||
</form>
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
<form action="/freelancer/templateManagement" method="get">
|
||||
<button type="submit" class="button">Template Management</button>
|
||||
</form>
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
<form action="/freelancer/settings" method="get">
|
||||
<button type="submit" class="button">Change Account Settings</button>
|
||||
|
41
templates/freelancer_Template_Management.html
Normal file
41
templates/freelancer_Template_Management.html
Normal file
@ -0,0 +1,41 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
{{> templateIncludes/style.css.html}}
|
||||
</head>
|
||||
<body>
|
||||
{{^COOKIE_LOGGED_IN}}
|
||||
Please Log in.
|
||||
{{/COOKIE_LOGGED_IN}}
|
||||
{{#COOKIE_LOGGED_IN}}
|
||||
<h2>Freelancer: {{freelancername}}</h2>
|
||||
<div>Basic Profile:</div>
|
||||
<div>{{freelancerbasicinformation}}</div>
|
||||
<br>
|
||||
<div>Detailed Profile:</div>
|
||||
<div>{{freelancergeneralinformation}}</div>
|
||||
<br>
|
||||
{{> templateIncludes/returnToIndexButton.html.html}}
|
||||
<br>
|
||||
<table>
|
||||
{{#templates}}
|
||||
<tr>
|
||||
<th>{{name}}</th>
|
||||
<th>
|
||||
<form action="/freelancer/templateManagement/template/{{name}}" name="templateid" value="{{id}}" method="post">
|
||||
<button type="submit" name="templateaction" value="{{view}}" class="button">View</button>
|
||||
<button type="submit" name="templateaction" value="{{edit}}" class="button">Edit</button>
|
||||
<button type="submit" name="templateaction" value="{{delete}}" class="button">Delete</button>
|
||||
</form>
|
||||
</th>
|
||||
</tr>
|
||||
{{/templates}}
|
||||
</table>
|
||||
{{/COOKIE_LOGGED_IN}}
|
||||
{{> templateIncludes/freelancerLoginSignupProfileLogoutInterface.html.html}}
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user