Skip to content
Snippets Groups Projects
Commit 506c0cbb authored by Nick Anton Christoph Kleine-Tebbe's avatar Nick Anton Christoph Kleine-Tebbe
Browse files

Added stubs for the CMD commands

parent 649e1b5b
No related branches found
No related tags found
No related merge requests found
...@@ -88,3 +88,5 @@ sw.* ...@@ -88,3 +88,5 @@ sw.*
# Vim swap files # Vim swap files
*.swp *.swp
Kolloquiums
\ No newline at end of file
const { Router } = require('express') const { Router } = require('express')
const router = Router() const router = Router();
var fs = require("fs") var fs = require("fs");
var exec = require('child_process').exec;
const kolloquiumDirectory = 'Kolloquiums' const kolloquiumDirectory = 'Kolloquiums'
function getDirectories(path) { function getDirectories(path) {
...@@ -52,7 +54,7 @@ fs.mkdir(kolloquiumDirectory,function(err) { ...@@ -52,7 +54,7 @@ fs.mkdir(kolloquiumDirectory,function(err) {
return console.error(err); return console.error(err);
} }
else { else {
console.log("Directory created successfully!"); console.log("Directory created successfully");
} }
}); });
...@@ -81,7 +83,7 @@ router.use('/getAbgaben', (req, res) => { ...@@ -81,7 +83,7 @@ router.use('/getAbgaben', (req, res) => {
}) })
} }
var directories = getDirectories(kolloquiumDirectory + '/' + safeKolloquium) var directories = getDirectories(kolloquiumDirectory + '/' + safeKolloquium + '/Abgaben')
return res.json({ return res.json({
success: true, success: true,
abgaben: directories abgaben: directories
...@@ -155,10 +157,6 @@ router.use('/createKolloquium', (req, res) => { ...@@ -155,10 +157,6 @@ router.use('/createKolloquium', (req, res) => {
fs.mkdir(kolloquiumDirectory + '/' + safeTitle, function(err) { fs.mkdir(kolloquiumDirectory + '/' + safeTitle, function(err) {
if (err && err.code === "EEXIST") { if (err && err.code === "EEXIST") {
console.warn('Directory "' + safeTitle + '" already existed') console.warn('Directory "' + safeTitle + '" already existed')
return res.json({
success: true,
message: 'Directory "' + safeTitle + '" already existed'
})
} }
else if (err) { else if (err) {
console.error(err); console.error(err);
...@@ -169,11 +167,42 @@ router.use('/createKolloquium', (req, res) => { ...@@ -169,11 +167,42 @@ router.use('/createKolloquium', (req, res) => {
} }
else { else {
console.log('Directory "' + safeTitle + '" created successfully'); console.log('Directory "' + safeTitle + '" created successfully');
}
fs.mkdir(kolloquiumDirectory + '/' + safeTitle + '/Mods', function(err) {
if (err && err.code === "EEXIST") {
console.log('Mods Directory already existed')
}
else if (err) {
return res.json({
success: false,
message: err
})
}
else {
console.log("Mods Directory created successfully");
}
});
fs.mkdir(kolloquiumDirectory + '/' + safeTitle + '/Abgaben', function(err) {
if (err && err.code === "EEXIST") {
console.log('Abgaben Directory already existed')
}
else if (err) {
return res.json({
success: false,
message: err
})
}
else {
console.log("Abgaben Directory created successfully");
}
});
return res.json({ return res.json({
success: true, success: true,
message: 'Directory "' + safeTitle + '" created successfully' message: 'Directory "' + safeTitle + '" created successfully'
}) })
}
}); });
}) })
...@@ -231,7 +260,7 @@ router.use('/submitAbgabe', (req, res) => { ...@@ -231,7 +260,7 @@ router.use('/submitAbgabe', (req, res) => {
message: 'Matrikelnummer, Name or Kolloquium was empty' message: 'Matrikelnummer, Name or Kolloquium was empty'
}) })
} }
let directory = kolloquiumDirectory + '/' + safeKolloquium + '/' + safeMatrikelnummer + '_' + safeName; let directory = kolloquiumDirectory + '/' + safeKolloquium + '/Abgaben/' + safeMatrikelnummer + '_' + safeName;
fs.mkdir(directory, function(err) { fs.mkdir(directory, function(err) {
if (err && err.code === "EEXIST") { if (err && err.code === "EEXIST") {
console.warn('Directory "' + directory + '" already existed') console.warn('Directory "' + directory + '" already existed')
...@@ -248,9 +277,50 @@ router.use('/submitAbgabe', (req, res) => { ...@@ -248,9 +277,50 @@ router.use('/submitAbgabe', (req, res) => {
} }
file.mv(directory + '/' + filename); file.mv(directory + '/' + filename);
console.log('saved file ' + filename) console.log('saved file ' + filename)
});
// Change the name of the mod and location of Datasmith file in the editor.init...
exec('echo Change the name of the mod and location of Datasmith file in the editor.init...',
function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
if (!isEmpty(stderr)){
console.log('stderr: ' + stderr);
}
if (error !== null) {
console.log('exec error: ' + error);
}
// Run the python script that starts the unreal engine with the editor utility...
exec('echo Run the python script that starts the unreal engine with the editor utility... ',
function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
if (!isEmpty(stderr)){
console.log('stderr: ' + stderr);
}
if (error !== null) {
console.log('exec error: ' + error);
}
});
});
}) })
})
// Submit Abgabe
router.use('/activateKolloquium', (req, res) => {
let { kolloquium } = req.body
console.log('Activate ' + kolloquium)
// Remove the contents of the mod folder and move the .pak folders to the mod folder
exec('echo Remove the contents of the mod folder and move the .pak folders to the mod folder',
function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
if (!isEmpty(stderr)){
console.log('stderr: ' + stderr);
}
if (error !== null) {
console.log('exec error: ' + error);
}
});
})
module.exports = router module.exports = router
...@@ -52,7 +52,10 @@ ...@@ -52,7 +52,10 @@
Keine Abgaben Keine Abgaben
</div> </div>
<div class="flex flex-row justify-between"> <div class="flex flex-row justify-between">
<button class="border rounded mt-4 p-2 font-semibold text-white bg-green-500 hover:bg-green-600 focus:bg-green-700"> <button
class="border rounded mt-4 p-2 font-semibold text-white bg-green-500 hover:bg-green-600 focus:bg-green-700"
@click="activateKolloquium(selectedKolloquium)"
>
Aktivieren Aktivieren
</button> </button>
<n-link :to="'/abgabe/' + selectedKolloquium"> <n-link :to="'/abgabe/' + selectedKolloquium">
...@@ -156,7 +159,9 @@ export default { ...@@ -156,7 +159,9 @@ export default {
inEdit: false inEdit: false
}) })
}) })
},
activateKolloquium(kolloquium) {
this.$axios.post('api/activateKolloquium', { kolloquium: kolloquium })
} }
}, },
async asyncData ({ $axios }) { async asyncData ({ $axios }) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment