modules and payments management, bug fixes
This commit is contained in:
178
index.js
178
index.js
@@ -557,7 +557,7 @@ app.get("/project/:name/settings", checkAuthorization, async (req, res) => {
|
||||
};
|
||||
|
||||
const source = fs.readFileSync(
|
||||
"static/templates/project/settings.html",
|
||||
"static/templates/project/settings/settings.html",
|
||||
"utf8"
|
||||
);
|
||||
const template = handlebars.compile(source);
|
||||
@@ -574,6 +574,182 @@ app.get("/project/:name/settings", checkAuthorization, async (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
app.get(
|
||||
"/project/:name/settings/modules",
|
||||
checkAuthorization,
|
||||
async (req, res) => {
|
||||
const token = req.cookies.token;
|
||||
const name = req.params.name;
|
||||
console.log(token);
|
||||
|
||||
if (!req.isAuth) {
|
||||
res.redirect("/");
|
||||
return;
|
||||
}
|
||||
|
||||
var options = {
|
||||
method: "GET",
|
||||
url: process.env.API_SERVER + "/modules?name=" + name,
|
||||
headers: {
|
||||
Authorization: req.cookies.token,
|
||||
},
|
||||
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="searchText"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="page"\r\n\r\n\r\n-----011000010111000001101001--\r\n',
|
||||
};
|
||||
|
||||
axios
|
||||
.request(options)
|
||||
.then(function (response) {
|
||||
var templateData = {
|
||||
API_SERVER: process.env.API_SERVER,
|
||||
SITE_DOMAIN: process.env.SITE_DOMAIN,
|
||||
IsAdmin: req.apiResponse.isadmin,
|
||||
Name: name,
|
||||
User: response.data.user,
|
||||
Modules: response.data.data,
|
||||
Project: response.data.project,
|
||||
Projects: response.data.projects,
|
||||
Tests: response.data.tests,
|
||||
isAuth: req.isAuth,
|
||||
};
|
||||
|
||||
const source = fs.readFileSync(
|
||||
"static/templates/project/settings/modules.html",
|
||||
"utf8"
|
||||
);
|
||||
const template = handlebars.compile(source);
|
||||
const resultT = template(templateData);
|
||||
res.send(resultT);
|
||||
})
|
||||
.catch(function (error) {
|
||||
if (error.response && error.response.status === 401) {
|
||||
res.redirect("/");
|
||||
} else {
|
||||
console.error("Ошибка при отправке GET-запроса:", error);
|
||||
res.status(500).send("Произошла ошибка при выполнении запроса.");
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
app.get(
|
||||
"/project/:name/settings/payments",
|
||||
checkAuthorization,
|
||||
async (req, res) => {
|
||||
const token = req.cookies.token;
|
||||
const name = req.params.name;
|
||||
|
||||
console.log(token);
|
||||
|
||||
if (!req.isAuth) {
|
||||
res.redirect("/");
|
||||
return;
|
||||
}
|
||||
|
||||
var options = {
|
||||
method: "GET",
|
||||
url: process.env.API_SERVER + "/payments?name=" + name,
|
||||
headers: {
|
||||
"Content-Type":
|
||||
"multipart/form-data; boundary=---011000010111000001101001",
|
||||
Authorization: req.cookies.token,
|
||||
},
|
||||
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="searchText"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="page"\r\n\r\n\r\n-----011000010111000001101001--\r\n',
|
||||
};
|
||||
|
||||
axios
|
||||
.request(options)
|
||||
.then(function (response) {
|
||||
var templateData = {
|
||||
API_SERVER: process.env.API_SERVER,
|
||||
SITE_DOMAIN: process.env.SITE_DOMAIN,
|
||||
IsAdmin: req.apiResponse.isadmin,
|
||||
Name: name,
|
||||
Project: response.data.data,
|
||||
Projects: response.data.projects,
|
||||
User: response.data.user,
|
||||
Payments: response.data.payments,
|
||||
isAuth: req.isAuth,
|
||||
};
|
||||
|
||||
const source = fs.readFileSync(
|
||||
"static/templates/project/settings/payments.html",
|
||||
"utf8"
|
||||
);
|
||||
const template = handlebars.compile(source);
|
||||
const resultT = template(templateData);
|
||||
res.send(resultT);
|
||||
})
|
||||
.catch(function (error) {
|
||||
if (error.response && error.response.status === 401) {
|
||||
res.redirect("/");
|
||||
} else {
|
||||
console.error("Ошибка при отправке GET-запроса:", error);
|
||||
res.status(500).send("Произошла ошибка при выполнении запроса.");
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
app.get(
|
||||
"/project/:name/settings/payment/:id",
|
||||
checkAuthorization,
|
||||
async (req, res) => {
|
||||
const token = req.cookies.token;
|
||||
const name = req.params.name;
|
||||
const id = req.params.id;
|
||||
|
||||
console.log(token);
|
||||
|
||||
if (!req.isAuth) {
|
||||
res.redirect("/");
|
||||
return;
|
||||
}
|
||||
|
||||
var options = {
|
||||
method: "GET",
|
||||
url: process.env.API_SERVER + "/payment?name=" + name + "&id=" + id,
|
||||
headers: {
|
||||
"Content-Type":
|
||||
"multipart/form-data; boundary=---011000010111000001101001",
|
||||
Authorization: req.cookies.token,
|
||||
},
|
||||
data: '-----011000010111000001101001\r\nContent-Disposition: form-data; name="searchText"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name="page"\r\n\r\n\r\n-----011000010111000001101001--\r\n',
|
||||
};
|
||||
|
||||
axios
|
||||
.request(options)
|
||||
.then(function (response) {
|
||||
var templateData = {
|
||||
API_SERVER: process.env.API_SERVER,
|
||||
SITE_DOMAIN: process.env.SITE_DOMAIN,
|
||||
IsAdmin: req.apiResponse.isadmin,
|
||||
Name: name,
|
||||
Payment: response.data.data,
|
||||
Project: response.data.project,
|
||||
Projects: response.data.projects,
|
||||
User: response.data.user,
|
||||
isAuth: req.isAuth,
|
||||
};
|
||||
|
||||
const source = fs.readFileSync(
|
||||
"static/templates/project/settings/payment.html",
|
||||
"utf8"
|
||||
);
|
||||
const template = handlebars.compile(source);
|
||||
const resultT = template(templateData);
|
||||
res.send(resultT);
|
||||
})
|
||||
.catch(function (error) {
|
||||
if (error.response && error.response.status === 401) {
|
||||
res.redirect("/");
|
||||
} else {
|
||||
res.redirect("/project/" + name + "/settings/payments");
|
||||
console.error("Ошибка при отправке GET-запроса:", error);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
app.get("/project/yandexauth", async (req, res) => {
|
||||
const name = req.params.name;
|
||||
var templateData = {
|
||||
|
||||
Reference in New Issue
Block a user