menambah field anggota pada tb_penelitian dan tb_laporan, memperbaiki tampilan untuk melihat penelitian, menambah tampilan mahasiswa, memperbaiki proses menampilkan gambar profil
This commit is contained in:
1 parent
400e05adec
commit
4b7b08400a
19 files changed
+2332
-232
No files matched your search
+6
-1
@@ -6,4 +6,9 @@ be/uploads/*
|
|||||||
# Ignore all files in uploads
|
# Ignore all files in uploads
|
||||||
be/images/dosen/*
|
be/images/dosen/*
|
||||||
# But do NOT ignore the .gitkeep file
|
# But do NOT ignore the .gitkeep file
|
||||||
!be/images/dosen/.gitkeep
|
!be/images/dosen/.gitkeep
|
||||||
|
|
||||||
|
# Ignore all files in uploads
|
||||||
|
be/images/mahasiswa/*
|
||||||
|
# But do NOT ignore the .gitkeep file
|
||||||
|
!be/images/mahasiswa/.gitkeep
|
||||||
Whitespace-only changes.
+146
-15
@@ -64,6 +64,38 @@ const uploadImage = multer({
|
|||||||
});
|
});
|
||||||
// end of dosen image upload
|
// end of dosen image upload
|
||||||
|
|
||||||
|
// Below is for mahasiswa image upload
|
||||||
|
const mahasiswaImageDir = path.join(__dirname, 'images/mahasiswa');
|
||||||
|
if (!fs.existsSync(mahasiswaImageDir)) {
|
||||||
|
fs.mkdirSync(mahasiswaImageDir, { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Multer Config for Image Uploads (Max 1MB, Only Images)
|
||||||
|
const mahasiswaImageStorage = multer.diskStorage({
|
||||||
|
destination: (req, file, cb) => cb(null, mahasiswaImageDir),
|
||||||
|
filename: (req, file, cb) => {
|
||||||
|
const ext = path.extname(file.originalname);
|
||||||
|
const uniqueName = `${Date.now()}-${req.body.mahasiswa_id}${ext}`;
|
||||||
|
cb(null, uniqueName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const uploadMahasiswaImage = multer({
|
||||||
|
storage: mahasiswaImageStorage,
|
||||||
|
limits: { fileSize: 1024 * 1024 }, // 1 MB limit
|
||||||
|
fileFilter: (req, file, cb) => {
|
||||||
|
if (file.mimetype.startsWith('image/')) {
|
||||||
|
cb(null, true);
|
||||||
|
} else {
|
||||||
|
cb(new Error('Hanya file gambar yang diizinkan!'), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// end of mahasiswa image upload
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Multer Config for CSV Uploads (Store in Memory)
|
// Multer Config for CSV Uploads (Store in Memory)
|
||||||
const csvUpload = multer({
|
const csvUpload = multer({
|
||||||
storage: multer.memoryStorage(),
|
storage: multer.memoryStorage(),
|
||||||
@@ -109,6 +141,7 @@ const initDB = () => {
|
|||||||
tahun_penelitian YEAR NOT NULL,
|
tahun_penelitian YEAR NOT NULL,
|
||||||
status_penelitian ENUM('Berjalan', 'Selesai') NOT NULL,
|
status_penelitian ENUM('Berjalan', 'Selesai') NOT NULL,
|
||||||
keterangan TEXT DEFAULT NULL,
|
keterangan TEXT DEFAULT NULL,
|
||||||
|
anggota JSON DEFAULT NULL,
|
||||||
hasil_publikasi JSON,
|
hasil_publikasi JSON,
|
||||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
@@ -126,6 +159,7 @@ const initDB = () => {
|
|||||||
tahun_penelitian YEAR NOT NULL,
|
tahun_penelitian YEAR NOT NULL,
|
||||||
status_penelitian ENUM('Berjalan', 'Selesai') NOT NULL,
|
status_penelitian ENUM('Berjalan', 'Selesai') NOT NULL,
|
||||||
keterangan TEXT DEFAULT NULL,
|
keterangan TEXT DEFAULT NULL,
|
||||||
|
anggota JSON DEFAULT NULL,
|
||||||
hasil_publikasi JSON,
|
hasil_publikasi JSON,
|
||||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
FOREIGN KEY (penelitian_id) REFERENCES tb_penelitian(id) ON DELETE CASCADE
|
FOREIGN KEY (penelitian_id) REFERENCES tb_penelitian(id) ON DELETE CASCADE
|
||||||
@@ -138,6 +172,7 @@ const initDB = () => {
|
|||||||
id_mahasiswa VARCHAR(50) PRIMARY KEY,
|
id_mahasiswa VARCHAR(50) PRIMARY KEY,
|
||||||
nama_mahasiswa VARCHAR(255) NOT NULL,
|
nama_mahasiswa VARCHAR(255) NOT NULL,
|
||||||
password VARCHAR(255) NOT NULL DEFAULT '1234567',
|
password VARCHAR(255) NOT NULL DEFAULT '1234567',
|
||||||
|
mahasiswa_image VARCHAR(255) DEFAULT NULL,
|
||||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||||
)
|
)
|
||||||
@@ -372,6 +407,19 @@ app.get('/dosen', (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Get Single Dosen by ID (Fast check for session validity)
|
||||||
|
app.get('/dosen/cek/:dosen_id', (req, res) => {
|
||||||
|
const dosenId = req.params.dosen_id;
|
||||||
|
// Select only the necessary columns
|
||||||
|
db.query("SELECT dosen_id, dosen_name , dosen_image FROM tb_dosen WHERE dosen_id = ?", [dosenId], (err, results) => {
|
||||||
|
if (err) return res.status(500).json({ valid: false, error: err.message });
|
||||||
|
if (results.length === 0) return res.status(404).json({ valid: false, error: "Dosen tidak ditemukan" });
|
||||||
|
|
||||||
|
// Return the single object, along with valid: true
|
||||||
|
res.json( results[0] );
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
app.get('/dosen/verify', (req, res) => {
|
app.get('/dosen/verify', (req, res) => {
|
||||||
const { dosen_id, dosen_name } = req.query;
|
const { dosen_id, dosen_name } = req.query;
|
||||||
if (!dosen_id || !dosen_name) return res.status(400).json({ valid: false, message: "Missing parameters" });
|
if (!dosen_id || !dosen_name) return res.status(400).json({ valid: false, message: "Missing parameters" });
|
||||||
@@ -577,13 +625,24 @@ app.get('/dosen/export-csv', (req, res) => {
|
|||||||
|
|
||||||
// ================= MAHASISWA ENDPOINTS =================
|
// ================= MAHASISWA ENDPOINTS =================
|
||||||
app.get('/mahasiswa', (req, res) => {
|
app.get('/mahasiswa', (req, res) => {
|
||||||
// Update this query
|
// Update this query to include mahasiswa_image
|
||||||
db.query("SELECT id_mahasiswa, nama_mahasiswa, created_at, updated_at FROM tb_mahasiswa", (err, results) => {
|
db.query("SELECT id_mahasiswa, nama_mahasiswa, mahasiswa_image, created_at, updated_at FROM tb_mahasiswa", (err, results) => {
|
||||||
if (err) return res.status(500).json({ error: err.message });
|
if (err) return res.status(500).json({ error: err.message });
|
||||||
res.json(results);
|
res.json(results);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Get Single Mahasiswa by ID (Fast)
|
||||||
|
app.get('/mahasiswa/cek/:id_mahasiswa', (req, res) => {
|
||||||
|
const mhsId = req.params.id_mahasiswa;
|
||||||
|
// Select specific columns needed for the profile page
|
||||||
|
db.query("SELECT id_mahasiswa, nama_mahasiswa, mahasiswa_image FROM tb_mahasiswa WHERE id_mahasiswa = ?", [mhsId], (err, results) => {
|
||||||
|
if (err) return res.status(500).json({ error: err.message });
|
||||||
|
if (results.length === 0) return res.status(404).json({ error: "Mahasiswa tidak ditemukan" });
|
||||||
|
res.json(results[0]); // Return just the single object, not an array
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
app.post('/mahasiswa', (req, res) => {
|
app.post('/mahasiswa', (req, res) => {
|
||||||
const { id_mahasiswa, nama_mahasiswa } = req.body;
|
const { id_mahasiswa, nama_mahasiswa } = req.body;
|
||||||
if (!id_mahasiswa || !nama_mahasiswa) return res.status(400).json({ error: "ID dan Nama wajib diisi!" });
|
if (!id_mahasiswa || !nama_mahasiswa) return res.status(400).json({ error: "ID dan Nama wajib diisi!" });
|
||||||
@@ -598,6 +657,19 @@ app.post('/mahasiswa', (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.get('/mahasiswa/verify', (req, res) => {
|
||||||
|
const { id_mahasiswa, nama_mahasiswa } = req.query;
|
||||||
|
if (!id_mahasiswa || !nama_mahasiswa) return res.status(400).json({ valid: false, message: "Missing parameters" });
|
||||||
|
|
||||||
|
const query = "SELECT id_mahasiswa, nama_mahasiswa FROM tb_mahasiswa WHERE id_mahasiswa = ? AND nama_mahasiswa = ?";
|
||||||
|
db.query(query, [id_mahasiswa, nama_mahasiswa], (err, results) => {
|
||||||
|
if (err) return res.status(500).json({ valid: false, error: err.message });
|
||||||
|
|
||||||
|
if (results.length > 0) return res.json({ valid: true, message: "Session valid" });
|
||||||
|
return res.status(401).json({ valid: false, message: "Invalid session" });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Import Mahasiswa from CSV
|
// Import Mahasiswa from CSV
|
||||||
app.post('/mahasiswa/import-csv', csvUpload.single('csv_file'), (req, res) => {
|
app.post('/mahasiswa/import-csv', csvUpload.single('csv_file'), (req, res) => {
|
||||||
if (!req.file) return res.status(400).json({ error: "File CSV tidak ditemukan." });
|
if (!req.file) return res.status(400).json({ error: "File CSV tidak ditemukan." });
|
||||||
@@ -660,6 +732,29 @@ app.get('/mahasiswa/export-csv', (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.put('/mahasiswa/change-password', (req, res) => {
|
||||||
|
const { mahasiswa_id, current_password, new_password } = req.body; // Change to mahasiswa_id, current_password, new_password } = req.body;
|
||||||
|
|
||||||
|
if (!mahasiswa_id || !current_password || !new_password) {
|
||||||
|
return res.status(400).json({ error: "Semua field wajib diisi!" });
|
||||||
|
}
|
||||||
|
|
||||||
|
const verifyQuery = "SELECT id_mahasiswa FROM tb_mahasiswa WHERE id_mahasiswa = ? AND password = ?";
|
||||||
|
db.query(verifyQuery, [mahasiswa_id, current_password], (err, results) => {
|
||||||
|
if (err) return res.status(500).json({ error: err.message });
|
||||||
|
|
||||||
|
if (results.length === 0) {
|
||||||
|
return res.status(401).json({ error: "Password saat ini salah!" });
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateQuery = "UPDATE tb_mahasiswa SET password = ? WHERE id_mahasiswa = ?";
|
||||||
|
db.query(updateQuery, [new_password, mahasiswa_id], (err) => {
|
||||||
|
if (err) return res.status(500).json({ error: err.message });
|
||||||
|
res.json({ message: "Password berhasil diubah!" });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Reset Mahasiswa Password
|
// Reset Mahasiswa Password
|
||||||
app.put('/mahasiswa/reset-password/:id_mahasiswa', (req, res) => {
|
app.put('/mahasiswa/reset-password/:id_mahasiswa', (req, res) => {
|
||||||
const mhsId = req.params.id_mahasiswa;
|
const mhsId = req.params.id_mahasiswa;
|
||||||
@@ -672,6 +767,41 @@ app.put('/mahasiswa/reset-password/:id_mahasiswa', (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.put('/mahasiswa/upload-image', uploadMahasiswaImage.single('image'), (req, res) => {
|
||||||
|
const { mahasiswa_id } = req.body;
|
||||||
|
|
||||||
|
if (!req.file) {
|
||||||
|
return res.status(400).json({ error: "File gambar tidak ditemukan." });
|
||||||
|
}
|
||||||
|
|
||||||
|
const newImageName = req.file.filename;
|
||||||
|
|
||||||
|
const getOldImageQuery = "SELECT mahasiswa_image FROM tb_mahasiswa WHERE id_mahasiswa = ?";
|
||||||
|
db.query(getOldImageQuery, [mahasiswa_id], (err, results) => {
|
||||||
|
if (err) return res.status(500).json({ error: err.message });
|
||||||
|
|
||||||
|
const oldImageName = results.length > 0 ? results[0].mahasiswa_image : null;
|
||||||
|
|
||||||
|
if (oldImageName) {
|
||||||
|
const oldFilePath = path.join(mahasiswaImageDir, oldImageName);
|
||||||
|
if (fs.existsSync(oldFilePath)) {
|
||||||
|
fs.unlink(oldFilePath, (unlinkErr) => {
|
||||||
|
if (unlinkErr) console.error("Gagal menghapus gambar lama:", unlinkErr);
|
||||||
|
else console.log("Gambar lama dihapus:", oldImageName);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateQuery = "UPDATE tb_mahasiswa SET mahasiswa_image = ? WHERE id_mahasiswa = ?";
|
||||||
|
db.query(updateQuery, [newImageName, mahasiswa_id], (errUpdate) => {
|
||||||
|
if (errUpdate) return res.status(500).json({ error: errUpdate.message });
|
||||||
|
res.json({ message: "Foto profil berhasil diperbarui!", image: newImageName });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
app.use('/images/mahasiswa', express.static(mahasiswaImageDir));
|
||||||
|
|
||||||
// ================= PENELITIAN ENDPOINTS =================
|
// ================= PENELITIAN ENDPOINTS =================
|
||||||
|
|
||||||
app.get('/penelitian', (req, res) => {
|
app.get('/penelitian', (req, res) => {
|
||||||
@@ -704,7 +834,8 @@ app.get('/penelitian/dosen/:dosen_id', (req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.post('/penelitian', upload.array('files', 3), (req, res) => {
|
app.post('/penelitian', upload.array('files', 3), (req, res) => {
|
||||||
const { dosen_id, judul_penelitian, tahun_penelitian, status_penelitian, keterangan } = req.body;
|
const { dosen_id, judul_penelitian, tahun_penelitian, status_penelitian, keterangan , anggota} = req.body;
|
||||||
|
// let anggota_string = anggota ? JSON.stringify(anggota) : null;
|
||||||
|
|
||||||
let hasilPublikasiJson = null;
|
let hasilPublikasiJson = null;
|
||||||
if (req.files && req.files.length > 0) {
|
if (req.files && req.files.length > 0) {
|
||||||
@@ -712,20 +843,20 @@ app.post('/penelitian', upload.array('files', 3), (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const insertPenelitian = `
|
const insertPenelitian = `
|
||||||
INSERT INTO tb_penelitian (dosen_id, judul_penelitian, tahun_penelitian, status_penelitian, keterangan, hasil_publikasi)
|
INSERT INTO tb_penelitian (dosen_id, judul_penelitian, tahun_penelitian, status_penelitian, keterangan, anggota, hasil_publikasi)
|
||||||
VALUES (?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
`;
|
`;
|
||||||
|
|
||||||
db.query(insertPenelitian, [dosen_id, judul_penelitian, tahun_penelitian, status_penelitian, keterangan, hasilPublikasiJson], (err, result) => {
|
db.query(insertPenelitian, [dosen_id, judul_penelitian, tahun_penelitian, status_penelitian, keterangan, anggota, hasilPublikasiJson], (err, result) => {
|
||||||
if (err) return res.status(500).json({ error: err.message });
|
if (err) return res.status(500).json({ error: err.message });
|
||||||
|
|
||||||
const newId = result.insertId;
|
const newId = result.insertId;
|
||||||
|
|
||||||
const insertLaporan = `
|
const insertLaporan = `
|
||||||
INSERT INTO tb_laporan (penelitian_id, dosen_id, judul_penelitian, tahun_penelitian, status_penelitian, keterangan, hasil_publikasi)
|
INSERT INTO tb_laporan (penelitian_id, dosen_id, judul_penelitian, tahun_penelitian, status_penelitian, keterangan, anggota, hasil_publikasi)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
`;
|
`;
|
||||||
db.query(insertLaporan, [newId, dosen_id, judul_penelitian, tahun_penelitian, status_penelitian, keterangan, hasilPublikasiJson], (err) => {
|
db.query(insertLaporan, [newId, dosen_id, judul_penelitian, tahun_penelitian, status_penelitian, keterangan, anggota, hasilPublikasiJson], (err) => {
|
||||||
if (err) console.error("Gagal insert history laporan:", err);
|
if (err) console.error("Gagal insert history laporan:", err);
|
||||||
res.json({ message: "Data berhasil disimpan!", id: newId });
|
res.json({ message: "Data berhasil disimpan!", id: newId });
|
||||||
});
|
});
|
||||||
@@ -734,7 +865,7 @@ app.post('/penelitian', upload.array('files', 3), (req, res) => {
|
|||||||
|
|
||||||
app.put('/penelitian/:id', upload.array('files', 3), (req, res) => {
|
app.put('/penelitian/:id', upload.array('files', 3), (req, res) => {
|
||||||
const { id } = req.params;
|
const { id } = req.params;
|
||||||
const { status_penelitian, keterangan, existing_files } = req.body;
|
const { status_penelitian, keterangan, anggota, existing_files } = req.body;
|
||||||
|
|
||||||
db.query("SELECT dosen_id, judul_penelitian, tahun_penelitian, hasil_publikasi FROM tb_penelitian WHERE id = ?", [id], (err, results) => {
|
db.query("SELECT dosen_id, judul_penelitian, tahun_penelitian, hasil_publikasi FROM tb_penelitian WHERE id = ?", [id], (err, results) => {
|
||||||
if (err) return res.status(500).json({ error: err.message });
|
if (err) return res.status(500).json({ error: err.message });
|
||||||
@@ -753,17 +884,17 @@ app.put('/penelitian/:id', upload.array('files', 3), (req, res) => {
|
|||||||
|
|
||||||
const updateQuery = `
|
const updateQuery = `
|
||||||
UPDATE tb_penelitian
|
UPDATE tb_penelitian
|
||||||
SET status_penelitian = ?, keterangan = ?, hasil_publikasi = ?
|
SET status_penelitian = ?, keterangan = ?, anggota = ?, hasil_publikasi = ?
|
||||||
WHERE id = ?
|
WHERE id = ?
|
||||||
`;
|
`;
|
||||||
db.query(updateQuery, [status_penelitian, keterangan, hasilPublikasiJson, id], (err) => {
|
db.query(updateQuery, [status_penelitian, keterangan, anggota, hasilPublikasiJson, id], (err) => {
|
||||||
if (err) return res.status(500).json({ error: err.message });
|
if (err) return res.status(500).json({ error: err.message });
|
||||||
|
|
||||||
const logQuery = `
|
const logQuery = `
|
||||||
INSERT INTO tb_laporan (penelitian_id, dosen_id, judul_penelitian, tahun_penelitian, status_penelitian, keterangan, hasil_publikasi)
|
INSERT INTO tb_laporan (penelitian_id, dosen_id, judul_penelitian, tahun_penelitian, status_penelitian, keterangan, anggota, hasil_publikasi)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
`;
|
`;
|
||||||
db.query(logQuery, [id, dosen_id, judul_penelitian, tahun_penelitian, status_penelitian, keterangan, hasilPublikasiJson], (errLog) => {
|
db.query(logQuery, [id, dosen_id, judul_penelitian, tahun_penelitian, status_penelitian, keterangan, anggota, hasilPublikasiJson], (errLog) => {
|
||||||
if (errLog) return res.status(500).json({ error: "Gagal membuat laporan update: " + errLog.message });
|
if (errLog) return res.status(500).json({ error: "Gagal membuat laporan update: " + errLog.message });
|
||||||
res.json({ message: "Data berhasil diupdate dan laporan baru dibuat!" });
|
res.json({ message: "Data berhasil diupdate dan laporan baru dibuat!" });
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||||
<title>Aplikasi Penelitian Dosen - Halaman Utama Admin</title>
|
<title>Aplikasi Penelitian Dosen - Halaman Utama Admin</title>
|
||||||
|
|
||||||
|
<link rel="icon" href="assets/images/icon.png" type="image/x-icon">
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
if (localStorage.getItem('admin_auth') !== 'true') {
|
if (localStorage.getItem('admin_auth') !== 'true') {
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
@@ -374,6 +376,7 @@
|
|||||||
<h5 style="margin-top: 0; font-weight: bold; color: #333;">${latestUpdateItem.judul_penelitian}</h5>
|
<h5 style="margin-top: 0; font-weight: bold; color: #333;">${latestUpdateItem.judul_penelitian}</h5>
|
||||||
<p class="text-muted" style="margin-bottom: 5px; font-size: 13px;">
|
<p class="text-muted" style="margin-bottom: 5px; font-size: 13px;">
|
||||||
<i class="fa fa-user"></i> ${latestUpdateItem.dosen_name} <br>
|
<i class="fa fa-user"></i> ${latestUpdateItem.dosen_name} <br>
|
||||||
|
<i class="fa fa-users"></i> ${latestUpdateItem.anggota ? JSON.parse(latestUpdateItem.anggota).join(', ') : '-'} <br>
|
||||||
<i class="fa fa-calendar"></i> ${formatDate(latestUpdateItem.updated_at)}
|
<i class="fa fa-calendar"></i> ${formatDate(latestUpdateItem.updated_at)}
|
||||||
</p>
|
</p>
|
||||||
<span class="label ${badge}" style="font-size: 12px;">${latestUpdateItem.status_penelitian}</span>
|
<span class="label ${badge}" style="font-size: 12px;">${latestUpdateItem.status_penelitian}</span>
|
||||||
|
|||||||
+154
-67
@@ -7,6 +7,8 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||||
<title>Aplikasi Penelitian Dosen - Halaman List Penelitian</title>
|
<title>Aplikasi Penelitian Dosen - Halaman List Penelitian</title>
|
||||||
|
|
||||||
|
<link rel="icon" href="assets/images/icon.png" type="image/x-icon">
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
if (localStorage.getItem('admin_auth') !== 'true') {
|
if (localStorage.getItem('admin_auth') !== 'true') {
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
@@ -84,6 +86,23 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Detail table used in Lihat Penelitian */
|
||||||
|
.detail-table td {
|
||||||
|
vertical-align: top;
|
||||||
|
padding: 6px 4px;
|
||||||
|
border-top: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-table td:first-child {
|
||||||
|
width: 150px;
|
||||||
|
color: #555;
|
||||||
|
}
|
||||||
|
|
||||||
|
#v_anggota {
|
||||||
|
margin: 0;
|
||||||
|
padding-left: 18px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
@@ -246,7 +265,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Modal View Penelitian -->
|
<!-- Modal Lihat Penelitian (Read-Only, Text Only) -->
|
||||||
<div class="modal fade" id="modalPenelitian" tabindex="-1" role="dialog" aria-labelledby="modalLabel">
|
<div class="modal fade" id="modalPenelitian" tabindex="-1" role="dialog" aria-labelledby="modalLabel">
|
||||||
<div class="modal-dialog" role="document">
|
<div class="modal-dialog" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
@@ -255,35 +274,51 @@
|
|||||||
<h4 class="modal-title" id="modalLabel">Lihat Penelitian</h4>
|
<h4 class="modal-title" id="modalLabel">Lihat Penelitian</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<form id="formPenelitian">
|
<table class="table table-condensed detail-table" style="margin-bottom: 0;">
|
||||||
<div class="form-group">
|
<tr>
|
||||||
<label>Nama Dosen</label>
|
<td><strong>Nama Dosen</strong></td>
|
||||||
<input type="text" class="form-control" id="view_dosen_name" readonly>
|
<td>: <span id="v_dosen_name"></span></td>
|
||||||
</div>
|
</tr>
|
||||||
<div class="form-group">
|
<tr>
|
||||||
<label>Judul Penelitian</label>
|
<td><strong>Judul Penelitian</strong></td>
|
||||||
<input type="text" class="form-control" id="view_judul" readonly>
|
<td>: <span id="v_judul"></span></td>
|
||||||
</div>
|
</tr>
|
||||||
<div class="form-group">
|
<tr>
|
||||||
<label>Tahun Penelitian</label>
|
<td><strong>Tahun</strong></td>
|
||||||
<input type="text" class="form-control" id="view_tahun" readonly>
|
<td>: <span id="v_tahun"></span></td>
|
||||||
</div>
|
</tr>
|
||||||
<div class="form-group">
|
<tr>
|
||||||
<label>Status Penelitian</label>
|
<td><strong>Status</strong></td>
|
||||||
<input type="text" class="form-control" id="view_status" readonly>
|
<td>: <span id="v_status"></span></td>
|
||||||
</div>
|
</tr>
|
||||||
<div class="form-group">
|
<tr>
|
||||||
<label>Keterangan</label>
|
<td><strong>Anggota</strong></td>
|
||||||
<textarea class="form-control" id="view_keterangan" rows="3" readonly></textarea>
|
<td>
|
||||||
</div>
|
<ul id="v_anggota"></ul>
|
||||||
<div class="form-group" id="fileListSection" style="display: none;">
|
</td>
|
||||||
<label>Daftar File Publikasi:</label>
|
</tr>
|
||||||
<div id="existingFilesContainer" class="mt-2"></div>
|
<tr>
|
||||||
</div>
|
<td><strong>Keterangan</strong></td>
|
||||||
</form>
|
<td>: <span id="v_keterangan"></span></td>
|
||||||
|
</tr>
|
||||||
|
<tr id="v_files_row">
|
||||||
|
<td><strong>File Publikasi</strong></td>
|
||||||
|
<td>
|
||||||
|
<div id="v_files"></div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Dibuat</strong></td>
|
||||||
|
<td>: <span id="v_created"></span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Terakhir Diubah</strong></td>
|
||||||
|
<td>: <span id="v_updated"></span></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-info pull-left" id="btnHistory" onclick="viewHistory()"><i class="fa fa-history"></i> Riwayat Laporan</button>
|
<button type="button" class="btn btn-info pull-left" id="btnHistory" onclick="viewHistoryFromView()"><i class="fa fa-history"></i> Riwayat Laporan</button>
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">Tutup</button>
|
<button type="button" class="btn btn-default" data-dismiss="modal">Tutup</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -344,6 +379,24 @@
|
|||||||
let dataTable;
|
let dataTable;
|
||||||
let currentViewId = null;
|
let currentViewId = null;
|
||||||
|
|
||||||
|
// --- HELPERS ---
|
||||||
|
function escapeHtml(value) {
|
||||||
|
return String(value ?? '').replace(/[&<>"']/g, char => ({
|
||||||
|
'&': '&', '<': '<', '>': '>', '"': '"', "'": '''
|
||||||
|
})[char]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseAnggota(value) {
|
||||||
|
if (Array.isArray(value)) return value;
|
||||||
|
if (typeof value === 'string' && value.trim()) {
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(value);
|
||||||
|
return Array.isArray(parsed) ? parsed : [];
|
||||||
|
} catch (error) { return []; }
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
// --- DATE FORMATTER (ISO String to "DD Mon YYYY, HH.mm") ---
|
// --- DATE FORMATTER (ISO String to "DD Mon YYYY, HH.mm") ---
|
||||||
function formatDateOnly(dateString) {
|
function formatDateOnly(dateString) {
|
||||||
if (!dateString) return '-';
|
if (!dateString) return '-';
|
||||||
@@ -492,14 +545,19 @@
|
|||||||
container.empty();
|
container.empty();
|
||||||
if (latestUpdateItem) {
|
if (latestUpdateItem) {
|
||||||
let badge = latestUpdateItem.status_penelitian === 'Berjalan' ? 'label-warning' : 'label-success';
|
let badge = latestUpdateItem.status_penelitian === 'Berjalan' ? 'label-warning' : 'label-success';
|
||||||
|
const anggotaCard = parseAnggota(latestUpdateItem.anggota);
|
||||||
|
const anggotaCardHtml = anggotaCard.length
|
||||||
|
? anggotaCard.map(n => escapeHtml(n)).join(', ')
|
||||||
|
: '-';
|
||||||
container.append(`
|
container.append(`
|
||||||
<div style="margin-bottom: 15px;">
|
<div style="margin-bottom: 15px;">
|
||||||
<h5 style="margin-top: 0; font-weight: bold; color: #333;">${latestUpdateItem.judul_penelitian}</h5>
|
<h5 style="margin-top: 0; font-weight: bold; color: #333;">${escapeHtml(latestUpdateItem.judul_penelitian)}</h5>
|
||||||
<p class="text-muted" style="margin-bottom: 5px; font-size: 13px;">
|
<p class="text-muted" style="margin-bottom: 5px; font-size: 13px;">
|
||||||
<i class="fa fa-user"></i> ${latestUpdateItem.dosen_name} <br>
|
<i class="fa fa-user"></i> ${escapeHtml(latestUpdateItem.dosen_name)} <br>
|
||||||
|
<i class="fa fa-users"></i> ${anggotaCardHtml} <br>
|
||||||
<i class="fa fa-calendar"></i> ${formatDateOnly(latestUpdateItem.updated_at)}
|
<i class="fa fa-calendar"></i> ${formatDateOnly(latestUpdateItem.updated_at)}
|
||||||
</p>
|
</p>
|
||||||
<span class="label ${badge}" style="font-size: 12px;">${latestUpdateItem.status_penelitian}</span>
|
<span class="label ${badge}" style="font-size: 12px;">${escapeHtml(latestUpdateItem.status_penelitian)}</span>
|
||||||
</div>
|
</div>
|
||||||
`);
|
`);
|
||||||
} else {
|
} else {
|
||||||
@@ -546,51 +604,73 @@
|
|||||||
|
|
||||||
function viewPenelitian(id) {
|
function viewPenelitian(id) {
|
||||||
currentViewId = id;
|
currentViewId = id;
|
||||||
// Find the data by making an AJAX call (or we can find it in DataTable data)
|
|
||||||
$.get(`/api/penelitian`, function (allData) {
|
$.get(`/api/penelitian`, function (allData) {
|
||||||
const item = allData.find(p => p.id === id);
|
const item = allData.find(p => p.id === id);
|
||||||
if (item) {
|
if (!item) return;
|
||||||
$('#view_dosen_name').val(item.dosen_name);
|
|
||||||
$('#view_judul').val(item.judul_penelitian);
|
// Basic fields
|
||||||
$('#view_tahun').val(item.tahun_penelitian);
|
$('#v_dosen_name').text(item.dosen_name || '-');
|
||||||
$('#view_status').val(item.status_penelitian);
|
$('#v_judul').text(item.judul_penelitian || '-');
|
||||||
$('#view_keterangan').val(item.keterangan || '');
|
$('#v_tahun').text(item.tahun_penelitian || '-');
|
||||||
|
|
||||||
renderExistingFilesView(item.hasil_publikasi);
|
// Status badge
|
||||||
$('#modalPenelitian').modal('show');
|
const badge = item.status_penelitian === 'Berjalan' ? 'label-warning' : 'label-success';
|
||||||
|
$('#v_status').html(`<span class="label ${badge}">${escapeHtml(item.status_penelitian)}</span>`);
|
||||||
|
|
||||||
|
// Anggota list
|
||||||
|
const anggota = parseAnggota(item.anggota);
|
||||||
|
const $anggota = $('#v_anggota').empty();
|
||||||
|
if (anggota.length) {
|
||||||
|
anggota.forEach(nama => $anggota.append(`<li>${escapeHtml(nama)}</li>`));
|
||||||
|
} else {
|
||||||
|
$anggota.append('<li class="text-muted">-</li>');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Keterangan
|
||||||
|
$('#v_keterangan').text(item.keterangan || '-');
|
||||||
|
|
||||||
|
// Files
|
||||||
|
const $files = $('#v_files').empty();
|
||||||
|
let filesArr = [];
|
||||||
|
try {
|
||||||
|
filesArr = typeof item.hasil_publikasi === 'string'
|
||||||
|
? JSON.parse(item.hasil_publikasi)
|
||||||
|
: (item.hasil_publikasi || []);
|
||||||
|
} catch (e) { filesArr = []; }
|
||||||
|
|
||||||
|
if (filesArr.length) {
|
||||||
|
$('#v_files_row').show();
|
||||||
|
filesArr.forEach(f => {
|
||||||
|
const displayName = f.substring(f.indexOf('-') + 1);
|
||||||
|
$files.append(`
|
||||||
|
<div class="file-item">
|
||||||
|
<a href="/api/uploads/${f}" target="_blank">
|
||||||
|
<i class="fa fa-file-pdf-o text-danger"></i> ${displayName}
|
||||||
|
</a>
|
||||||
|
</div>`);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$('#v_files_row').show();
|
||||||
|
$files.append('<span class="text-muted">-</span>');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Timestamps
|
||||||
|
$('#v_created').text(formatDateOnly(item.created_at));
|
||||||
|
$('#v_updated').text(formatDateOnly(item.updated_at));
|
||||||
|
|
||||||
|
$('#modalPenelitian').modal('show');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderExistingFilesView(filesData) {
|
function viewHistoryFromView() {
|
||||||
let currentFiles = [];
|
$('#modalPenelitian').modal('hide');
|
||||||
if (Array.isArray(filesData)) currentFiles = filesData;
|
setTimeout(() => viewHistory(), 300);
|
||||||
else if (typeof filesData === 'string') {
|
|
||||||
try { currentFiles = JSON.parse(filesData); } catch (e) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
const container = $('#existingFilesContainer');
|
|
||||||
container.empty();
|
|
||||||
|
|
||||||
if (currentFiles.length > 0) {
|
|
||||||
$('#fileListSection').show();
|
|
||||||
currentFiles.forEach((filename) => {
|
|
||||||
let displayName = filename.substring(filename.indexOf('-') + 1);
|
|
||||||
container.append(`
|
|
||||||
<div class="file-item">
|
|
||||||
<a href="/api/uploads/${filename}" target="_blank"><i class="fa fa-file-pdf-o text-danger"></i> ${displayName}</a>
|
|
||||||
</div>
|
|
||||||
`);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
$('#fileListSection').hide();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function viewHistory() {
|
function viewHistory() {
|
||||||
if (!currentViewId) return;
|
if (!currentViewId) return;
|
||||||
$('#historyContainer').empty();
|
$('#historyContainer').empty();
|
||||||
$('#modalPenelitian').modal('hide');
|
|
||||||
$('#modalHistory').modal('show');
|
$('#modalHistory').modal('show');
|
||||||
|
|
||||||
$.get(`/api/laporan/${currentViewId}`, function (data) {
|
$.get(`/api/laporan/${currentViewId}`, function (data) {
|
||||||
@@ -600,6 +680,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
data.forEach((log, index) => {
|
data.forEach((log, index) => {
|
||||||
|
// Anggota per-version
|
||||||
|
const anggotaList = parseAnggota(log.anggota);
|
||||||
|
const anggotaHtml = anggotaList.length
|
||||||
|
? anggotaList.map(nama => `<li>${escapeHtml(nama)}</li>`).join('')
|
||||||
|
: '<span class="text-muted">-</span>';
|
||||||
|
|
||||||
let filesHtml = '';
|
let filesHtml = '';
|
||||||
if (log.hasil_publikasi) {
|
if (log.hasil_publikasi) {
|
||||||
try {
|
try {
|
||||||
@@ -623,8 +709,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="history-body">
|
<div class="history-body">
|
||||||
<table class="table table-condensed" style="margin-bottom: 0;">
|
<table class="table table-condensed" style="margin-bottom: 0;">
|
||||||
<tr><td width="120"><strong>Status</strong></td><td>: <span class="label ${log.status_penelitian === 'Berjalan' ? 'label-warning' : 'label-success'}">${log.status_penelitian}</span></td></tr>
|
<tr><td width="120"><strong>Status</strong></td><td>: <span class="label ${log.status_penelitian === 'Berjalan' ? 'label-warning' : 'label-success'}">${escapeHtml(log.status_penelitian)}</span></td></tr>
|
||||||
<tr><td><strong>Keterangan</strong></td><td>: ${log.keterangan || '-'}</td></tr>
|
<tr><td><strong>Anggota</strong></td><td><ul style="margin:0; padding-left:20px;">${anggotaHtml}</ul></td></tr>
|
||||||
|
<tr><td><strong>Keterangan</strong></td><td>: ${escapeHtml(log.keterangan || '-')}</td></tr>
|
||||||
<tr><td><strong>File</strong></td><td>${filesHtml || '-'}</td></tr>
|
<tr><td><strong>File</strong></td><td>${filesHtml || '-'}</td></tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||||
<title>Aplikasi Penelitian Dosen - Manajemen Dosen</title>
|
<title>Aplikasi Penelitian Dosen - Manajemen Dosen</title>
|
||||||
|
|
||||||
|
<link rel="icon" href="assets/images/icon.png" type="image/x-icon">
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
if (localStorage.getItem('admin_auth') !== 'true') {
|
if (localStorage.getItem('admin_auth') !== 'true') {
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||||
<title>Aplikasi Penelitian Dosen - Manajemen Mahasiswa</title>
|
<title>Aplikasi Penelitian Dosen - Manajemen Mahasiswa</title>
|
||||||
|
|
||||||
|
<link rel="icon" href="assets/images/icon.png" type="image/x-icon">
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
if (localStorage.getItem('admin_auth') !== 'true') {
|
if (localStorage.getItem('admin_auth') !== 'true') {
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||||
<title>Aplikasi Penelitian Dosen - Profil Admin</title>
|
<title>Aplikasi Penelitian Dosen - Profil Admin</title>
|
||||||
|
|
||||||
|
<link rel="icon" href="assets/images/icon.png" type="image/x-icon">
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
if (localStorage.getItem('admin_auth') !== 'true') {
|
if (localStorage.getItem('admin_auth') !== 'true') {
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
@@ -168,6 +170,7 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// ============ CHANGE PASSWORD AJAX ============
|
// ============ CHANGE PASSWORD AJAX ============
|
||||||
$('#changePasswordForm').on('submit', function (e) {
|
$('#changePasswordForm').on('submit', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
+227
-43
@@ -6,6 +6,7 @@
|
|||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||||
<title>Aplikasi Penelitian Dosen - Halaman Penelitian Dosen</title>
|
<title>Aplikasi Penelitian Dosen - Halaman Penelitian Dosen</title>
|
||||||
|
<link rel="icon" href="assets/images/icon.png" type="image/x-icon">
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
(async function checkAuth() {
|
(async function checkAuth() {
|
||||||
@@ -217,8 +218,7 @@
|
|||||||
<div class="box-content">
|
<div class="box-content">
|
||||||
<div class="statistics-box with-icon">
|
<div class="statistics-box with-icon">
|
||||||
<i class="ico fa fa-area-chart text-info"></i>
|
<i class="ico fa fa-area-chart text-info"></i>
|
||||||
<h2 class="counter text-info" id="h_terakhir_update"
|
<h2 class="counter text-info" id="h_terakhir_update" style="font-size: 15px;">...</h2>
|
||||||
style="font-size: 20px;">...</h2>
|
|
||||||
<p class="text">Terakhir Update</p>
|
<p class="text">Terakhir Update</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -295,7 +295,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Modal Penelitian (Add/Edit/View) -->
|
<!-- Modal Penelitian (Add/Edit) -->
|
||||||
<div class="modal fade" id="modalPenelitian" tabindex="-1" role="dialog" aria-labelledby="modalLabel">
|
<div class="modal fade" id="modalPenelitian" tabindex="-1" role="dialog" aria-labelledby="modalLabel">
|
||||||
<div class="modal-dialog" role="document">
|
<div class="modal-dialog" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
@@ -321,6 +321,15 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Anggota Penelitian (Opsional)</label>
|
||||||
|
<div id="anggotaContainer"></div>
|
||||||
|
<button type="button" class="btn btn-default btn-xs" id="btnTambahAnggota"
|
||||||
|
onclick="addAnggotaInput()"><i class="fa fa-plus"></i> Tambah Anggota</button>
|
||||||
|
<small class="help-block">Isi nama anggota jika ada. Kosongkan jika penelitian dikerjakan
|
||||||
|
sendiri.</small>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="status_penelitian">Status Penelitian</label>
|
<label for="status_penelitian">Status Penelitian</label>
|
||||||
<select class="form-control" id="status_penelitian" required>
|
<select class="form-control" id="status_penelitian" required>
|
||||||
@@ -357,8 +366,6 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-info pull-left" id="btnHistory" style="display: none;"
|
|
||||||
onclick="viewHistory()"><i class="fa fa-history"></i> Riwayat Laporan</button>
|
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">Tutup</button>
|
<button type="button" class="btn btn-default" data-dismiss="modal">Tutup</button>
|
||||||
<button type="button" class="btn btn-primary" id="btnSave"
|
<button type="button" class="btn btn-primary" id="btnSave"
|
||||||
onclick="savePenelitian()">Simpan</button>
|
onclick="savePenelitian()">Simpan</button>
|
||||||
@@ -367,6 +374,66 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Modal Lihat Penelitian (Read-Only) -->
|
||||||
|
<div class="modal fade" id="modalViewPenelitian" tabindex="-1" role="dialog" aria-labelledby="modalViewLabel">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
<h4 class="modal-title" id="modalViewLabel">Lihat Penelitian</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<table class="table table-condensed" style="margin-bottom: 0;">
|
||||||
|
<tr>
|
||||||
|
<td width="140"><strong>Judul Penelitian</strong></td>
|
||||||
|
<td>: <span id="v_judul"></span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Tahun</strong></td>
|
||||||
|
<td>: <span id="v_tahun"></span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Status</strong></td>
|
||||||
|
<td>: <span id="v_status"></span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Anggota</strong></td>
|
||||||
|
<td>
|
||||||
|
<ul id="v_anggota" style="margin:0; padding-left:20px;"></ul>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Keterangan</strong></td>
|
||||||
|
<td>: <span id="v_keterangan"></span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>File Publikasi</strong></td>
|
||||||
|
<td>
|
||||||
|
<div id="v_files"></div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Dibuat</strong></td>
|
||||||
|
<td>: <span id="v_created"></span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Terakhir Diubah</strong></td>
|
||||||
|
<td>: <span id="v_updated"></span></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-info pull-left" onclick="viewHistoryFromView()">
|
||||||
|
<i class="fa fa-history"></i> Riwayat Laporan
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Tutup</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Modal History / Laporan -->
|
<!-- Modal History / Laporan -->
|
||||||
<div class="modal fade" id="modalHistory" tabindex="-1" role="dialog">
|
<div class="modal fade" id="modalHistory" tabindex="-1" role="dialog">
|
||||||
<div class="modal-dialog modal-lg" role="document">
|
<div class="modal-dialog modal-lg" role="document">
|
||||||
@@ -413,23 +480,35 @@
|
|||||||
const dosenName = localStorage.getItem('dosen_name');
|
const dosenName = localStorage.getItem('dosen_name');
|
||||||
if (dosenName) document.getElementById('dosenName').textContent = dosenName;
|
if (dosenName) document.getElementById('dosenName').textContent = dosenName;
|
||||||
|
|
||||||
// Fetch current profile image
|
// Fetch current profile image using the FAST single-record API
|
||||||
$.get(`/api/dosen`, function (data) {
|
if (dosenId) {
|
||||||
const dosen = data.find(d => d.dosen_id === dosenId);
|
$.get(`/api/dosen/cek/${dosenId}`, function (dosen) {
|
||||||
if (dosen && dosen.dosen_image) {
|
console.log("Fetched dosen data:", dosen);
|
||||||
const imgUrl = `/api/images/dosen/${dosen.dosen_image}`;
|
console.log("Dosen Image:", dosen.dosen_image);
|
||||||
|
if (dosen && dosen.dosen_image) {
|
||||||
|
const imgUrl = `/api/images/dosen/${dosen.dosen_image}?t=${new Date().getTime()}`;
|
||||||
|
$('#profileImagePreview').attr('src', imgUrl);
|
||||||
|
$('#foto_dosen').attr('src', imgUrl);
|
||||||
|
}
|
||||||
|
}).fail(function (xhr) {
|
||||||
|
console.error("Gagal memuat data dosen:", xhr.responseJSON?.error);
|
||||||
|
// If the ID is invalid, log them out
|
||||||
|
if (xhr.status === 404) {
|
||||||
|
swal("Sesi Berakhir", "Data dosen tidak ditemukan. Silakan login kembali.", "warning");
|
||||||
|
setTimeout(() => {
|
||||||
|
localStorage.clear();
|
||||||
|
window.location.href = 'index.html';
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$('#profileImagePreview').attr('src', imgUrl);
|
|
||||||
$('#foto_dosen').attr('src', imgUrl);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
let dataTable;
|
let dataTable;
|
||||||
let currentEditFiles = [];
|
let currentEditFiles = [];
|
||||||
let isViewMode = false;
|
|
||||||
let currentViewId = null;
|
let currentViewId = null;
|
||||||
|
|
||||||
// --- DATE FORMATTER (ISO String to "DD Mon YYYY, HH.mm") ---
|
// --- DATE FORMATTER (ISO String to "DD Mon YYYY, HH.mm") ---
|
||||||
@@ -633,6 +712,74 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- ANGGOTA PENELITIAN ---
|
||||||
|
function escapeHtml(value) {
|
||||||
|
return String(value ?? '').replace(/[&<>"']/g, char => ({
|
||||||
|
'&': '&', '<': '<', '>': '>', '"': '"', "'": '''
|
||||||
|
})[char]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseAnggota(value) {
|
||||||
|
if (Array.isArray(value)) return value;
|
||||||
|
if (typeof value === 'string' && value.trim()) {
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(value);
|
||||||
|
return Array.isArray(parsed) ? parsed : [];
|
||||||
|
} catch (error) { return []; }
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderAnggota(data = []) {
|
||||||
|
const anggota = parseAnggota(data);
|
||||||
|
const rows = anggota.length ? anggota : [''];
|
||||||
|
const container = $('#anggotaContainer').empty();
|
||||||
|
|
||||||
|
rows.forEach((nama, index) => {
|
||||||
|
const removeButton = index === 0 ? '' : `
|
||||||
|
<button type="button" class="btn btn-danger" title="Hapus anggota"
|
||||||
|
onclick="removeAnggotaInput(this)"><i class="fa fa-trash"></i></button>`;
|
||||||
|
container.append(`
|
||||||
|
<div class="input-group anggota-row" style="margin-bottom:8px;">
|
||||||
|
<span class="input-group-addon">Anggota ${index + 1}</span>
|
||||||
|
<input type="text" class="form-control anggota-input"
|
||||||
|
placeholder="Nama anggota ${index + 1}" value="${escapeHtml(nama)}">
|
||||||
|
${removeButton}
|
||||||
|
</div>`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function addAnggotaInput() {
|
||||||
|
const index = $('#anggotaContainer .anggota-row').length + 1;
|
||||||
|
$('#anggotaContainer').append(`
|
||||||
|
<div class="input-group anggota-row" style="margin-bottom:8px;">
|
||||||
|
<span class="input-group-addon">Anggota ${index}</span>
|
||||||
|
<input type="text" class="form-control anggota-input" placeholder="Nama anggota ${index}">
|
||||||
|
<button type="button" class="btn btn-danger" title="Hapus anggota"
|
||||||
|
onclick="removeAnggotaInput(this)"><i class="fa fa-trash"></i></button>
|
||||||
|
</div>`);
|
||||||
|
renumberAnggota();
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeAnggotaInput(button) {
|
||||||
|
$(button).closest('.anggota-row').remove();
|
||||||
|
if (!$('#anggotaContainer .anggota-row').length) renderAnggota([]);
|
||||||
|
else renumberAnggota();
|
||||||
|
}
|
||||||
|
|
||||||
|
function renumberAnggota() {
|
||||||
|
$('#anggotaContainer .anggota-row').each(function (index) {
|
||||||
|
$(this).find('.input-group-addon').text(`Anggota ${index + 1}`);
|
||||||
|
$(this).find('.anggota-input').attr('placeholder', `Nama anggota ${index + 1}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAnggotaValues() {
|
||||||
|
return $('#anggotaContainer .anggota-input').map(function () {
|
||||||
|
return $(this).val().trim();
|
||||||
|
}).get().filter(Boolean);
|
||||||
|
}
|
||||||
|
|
||||||
// --- MODAL FUNCTIONS ---
|
// --- MODAL FUNCTIONS ---
|
||||||
|
|
||||||
function resetModal() {
|
function resetModal() {
|
||||||
@@ -642,10 +789,8 @@
|
|||||||
$('#existingFilesContainer').empty();
|
$('#existingFilesContainer').empty();
|
||||||
$('#fileListSection').hide();
|
$('#fileListSection').hide();
|
||||||
$('#timestampInfo').hide();
|
$('#timestampInfo').hide();
|
||||||
$('#btnHistory').hide();
|
|
||||||
currentEditFiles = [];
|
currentEditFiles = [];
|
||||||
isViewMode = false;
|
renderAnggota([]);
|
||||||
currentViewId = null;
|
|
||||||
|
|
||||||
$('#formPenelitian input, #formPenelitian select, #formPenelitian textarea').prop('disabled', false);
|
$('#formPenelitian input, #formPenelitian select, #formPenelitian textarea').prop('disabled', false);
|
||||||
$('#btnSave').show();
|
$('#btnSave').show();
|
||||||
@@ -659,34 +804,69 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function viewPenelitian(id) {
|
function viewPenelitian(id) {
|
||||||
resetModal();
|
|
||||||
isViewMode = true;
|
|
||||||
currentViewId = id;
|
currentViewId = id;
|
||||||
$('#modalLabel').text('Lihat Penelitian');
|
|
||||||
|
|
||||||
$('#formPenelitian input, #formPenelitian select, #formPenelitian textarea').prop('disabled', true);
|
|
||||||
$('#btnSave').hide();
|
|
||||||
$('#uploadSection').hide();
|
|
||||||
$('#btnHistory').show();
|
|
||||||
|
|
||||||
$('#modalPenelitian').modal('show');
|
|
||||||
|
|
||||||
$.get(`/api/penelitian/dosen/${localStorage.getItem('dosen_id')}`, function (data) {
|
$.get(`/api/penelitian/dosen/${localStorage.getItem('dosen_id')}`, function (data) {
|
||||||
const item = data.find(p => p.id === id);
|
const item = data.find(p => p.id === id);
|
||||||
if (item) {
|
if (!item) return;
|
||||||
$('#judul_penelitian').val(item.judul_penelitian);
|
|
||||||
$('#tahun_penelitian').val(item.tahun_penelitian);
|
|
||||||
$('#status_penelitian').val(item.status_penelitian);
|
|
||||||
$('#keterangan').val(item.keterangan || '');
|
|
||||||
renderExistingFiles(item.hasil_publikasi);
|
|
||||||
|
|
||||||
$('#lblCreated').text(formatDateOnly(item.created_at));
|
// Judul & Tahun
|
||||||
$('#lblUpdated').text(formatDateOnly(item.updated_at));
|
$('#v_judul').text(item.judul_penelitian);
|
||||||
$('#timestampInfo').show();
|
$('#v_tahun').text(item.tahun_penelitian);
|
||||||
|
|
||||||
|
// Status badge
|
||||||
|
const badge = item.status_penelitian === 'Berjalan' ? 'label-warning' : 'label-success';
|
||||||
|
$('#v_status').html(`<span class="label ${badge}">${item.status_penelitian}</span>`);
|
||||||
|
|
||||||
|
// Anggota
|
||||||
|
const anggota = parseAnggota(item.anggota);
|
||||||
|
const $anggota = $('#v_anggota').empty();
|
||||||
|
if (anggota.length) {
|
||||||
|
anggota.forEach(nama => $anggota.append(`<li>${escapeHtml(nama)}</li>`));
|
||||||
|
} else {
|
||||||
|
$anggota.append('<li class="text-muted">-</li>');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Keterangan
|
||||||
|
$('#v_keterangan').text(item.keterangan || '-');
|
||||||
|
|
||||||
|
// Files
|
||||||
|
const $files = $('#v_files').empty();
|
||||||
|
let filesArr = [];
|
||||||
|
try {
|
||||||
|
filesArr = typeof item.hasil_publikasi === 'string'
|
||||||
|
? JSON.parse(item.hasil_publikasi)
|
||||||
|
: (item.hasil_publikasi || []);
|
||||||
|
} catch (e) { filesArr = []; }
|
||||||
|
|
||||||
|
if (filesArr.length) {
|
||||||
|
filesArr.forEach(f => {
|
||||||
|
const displayName = f.substring(f.indexOf('-') + 1);
|
||||||
|
$files.append(`
|
||||||
|
<div class="file-item">
|
||||||
|
<a href="/api/uploads/${f}" target="_blank">
|
||||||
|
<i class="fa fa-file-pdf-o text-danger"></i> ${displayName}
|
||||||
|
</a>
|
||||||
|
</div>`);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$files.append('<span class="text-muted">-</span>');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Timestamps
|
||||||
|
$('#v_created').text(formatDateOnly(item.created_at));
|
||||||
|
$('#v_updated').text(formatDateOnly(item.updated_at));
|
||||||
|
|
||||||
|
$('#modalViewPenelitian').modal('show');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function viewHistoryFromView() {
|
||||||
|
$('#modalViewPenelitian').modal('hide');
|
||||||
|
// Small delay so the first modal fully closes before the next opens
|
||||||
|
setTimeout(() => viewHistory(), 300);
|
||||||
|
}
|
||||||
|
|
||||||
function editPenelitian(id) {
|
function editPenelitian(id) {
|
||||||
resetModal();
|
resetModal();
|
||||||
$('#modalLabel').text('Update Penelitian');
|
$('#modalLabel').text('Update Penelitian');
|
||||||
@@ -703,6 +883,7 @@
|
|||||||
$('#tahun_penelitian').val(item.tahun_penelitian);
|
$('#tahun_penelitian').val(item.tahun_penelitian);
|
||||||
$('#status_penelitian').val(item.status_penelitian);
|
$('#status_penelitian').val(item.status_penelitian);
|
||||||
$('#keterangan').val(item.keterangan || '');
|
$('#keterangan').val(item.keterangan || '');
|
||||||
|
renderAnggota(item.anggota);
|
||||||
renderExistingFiles(item.hasil_publikasi);
|
renderExistingFiles(item.hasil_publikasi);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -730,10 +911,7 @@
|
|||||||
currentEditFiles.forEach((filename, index) => {
|
currentEditFiles.forEach((filename, index) => {
|
||||||
let displayName = filename.substring(filename.indexOf('-') + 1);
|
let displayName = filename.substring(filename.indexOf('-') + 1);
|
||||||
|
|
||||||
let actionBtn = '';
|
let actionBtn = `<button type="button" class="btn btn-danger btn-xs" onclick="removeExistingFile(${index})">Hapus</button>`;
|
||||||
if (!isViewMode) {
|
|
||||||
actionBtn = `<button type="button" class="btn btn-danger btn-xs" onclick="removeExistingFile(${index})">Hapus</button>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
container.append(`
|
container.append(`
|
||||||
<div class="file-item">
|
<div class="file-item">
|
||||||
@@ -756,7 +934,6 @@
|
|||||||
function viewHistory() {
|
function viewHistory() {
|
||||||
if (!currentViewId) return;
|
if (!currentViewId) return;
|
||||||
$('#historyContainer').empty();
|
$('#historyContainer').empty();
|
||||||
$('#modalPenelitian').modal('hide');
|
|
||||||
$('#modalHistory').modal('show');
|
$('#modalHistory').modal('show');
|
||||||
|
|
||||||
$.get(`/api/laporan/${currentViewId}`, function (data) {
|
$.get(`/api/laporan/${currentViewId}`, function (data) {
|
||||||
@@ -766,6 +943,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
data.forEach((log, index) => {
|
data.forEach((log, index) => {
|
||||||
|
const anggotaList = parseAnggota(log.anggota);
|
||||||
|
const anggotaHtml = anggotaList.length
|
||||||
|
? anggotaList.map(nama => `<li>${escapeHtml(nama)}</li>`).join('')
|
||||||
|
: '<span class="text-muted">-</span>';
|
||||||
|
|
||||||
let filesHtml = '';
|
let filesHtml = '';
|
||||||
if (log.hasil_publikasi) {
|
if (log.hasil_publikasi) {
|
||||||
try {
|
try {
|
||||||
@@ -790,7 +972,8 @@
|
|||||||
<div class="history-body">
|
<div class="history-body">
|
||||||
<table class="table table-condensed" style="margin-bottom: 0;">
|
<table class="table table-condensed" style="margin-bottom: 0;">
|
||||||
<tr><td width="120"><strong>Status</strong></td><td>: <span class="label ${log.status_penelitian === 'Berjalan' ? 'label-warning' : 'label-success'}">${log.status_penelitian}</span></td></tr>
|
<tr><td width="120"><strong>Status</strong></td><td>: <span class="label ${log.status_penelitian === 'Berjalan' ? 'label-warning' : 'label-success'}">${log.status_penelitian}</span></td></tr>
|
||||||
<tr><td><strong>Keterangan</strong></td><td>: ${log.keterangan || '-'}</td></tr>
|
<tr><td><strong>Anggota</strong></td><td><ul style="margin:0; padding-left:20px;">${anggotaHtml}</ul></td></tr>
|
||||||
|
<tr><td><strong>Keterangan</strong></td><td>: ${escapeHtml(log.keterangan || '-')}</td></tr>
|
||||||
<tr><td><strong>File</strong></td><td>${filesHtml || '-'}</td></tr>
|
<tr><td><strong>File</strong></td><td>${filesHtml || '-'}</td></tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@@ -850,6 +1033,7 @@
|
|||||||
formData.append('tahun_penelitian', tahun);
|
formData.append('tahun_penelitian', tahun);
|
||||||
formData.append('status_penelitian', status);
|
formData.append('status_penelitian', status);
|
||||||
formData.append('keterangan', keterangan);
|
formData.append('keterangan', keterangan);
|
||||||
|
formData.append('anggota', JSON.stringify(getAnggotaValues()));
|
||||||
|
|
||||||
if (id) {
|
if (id) {
|
||||||
formData.append('existing_files', JSON.stringify(currentEditFiles));
|
formData.append('existing_files', JSON.stringify(currentEditFiles));
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||||
<title>Aplikasi Penelitian Dosen - Halaman List Penelitian</title>
|
<title>Aplikasi Penelitian Dosen - Halaman List Penelitian</title>
|
||||||
|
|
||||||
|
<link rel="icon" href="assets/images/icon.png" type="image/x-icon">
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
(async function checkAuth() {
|
(async function checkAuth() {
|
||||||
const dosenId = localStorage.getItem('dosen_id');
|
const dosenId = localStorage.getItem('dosen_id');
|
||||||
@@ -118,6 +120,23 @@
|
|||||||
max-height: calc(100vh - 210px);
|
max-height: calc(100vh - 210px);
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Detail table used in Lihat Penelitian */
|
||||||
|
.detail-table td {
|
||||||
|
vertical-align: top;
|
||||||
|
padding: 6px 4px;
|
||||||
|
border-top: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-table td:first-child {
|
||||||
|
width: 150px;
|
||||||
|
color: #555;
|
||||||
|
}
|
||||||
|
|
||||||
|
#v_anggota {
|
||||||
|
margin: 0;
|
||||||
|
padding-left: 18px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
@@ -140,7 +159,7 @@
|
|||||||
<li><a class="waves-effect" href="dosen_index.html"><i
|
<li><a class="waves-effect" href="dosen_index.html"><i
|
||||||
class="menu-icon fa fa-home"></i><span>Halaman
|
class="menu-icon fa fa-home"></i><span>Halaman
|
||||||
Utama</span></a></li>
|
Utama</span></a></li>
|
||||||
<li class="current"><a class="waves-effect" href="dosen_halaman_penelitian.html"><i
|
<li class="current"><a class="waves-effect" href="dosen_halaman_penelitian.html"><i
|
||||||
class="menu-icon fa fa-file-text"></i><span>Halaman
|
class="menu-icon fa fa-file-text"></i><span>Halaman
|
||||||
Penelitian</span></a></li>
|
Penelitian</span></a></li>
|
||||||
<li><a class="waves-effect" href="dosen.html"><i class="menu-icon fa fa-list"></i><span>Managemen
|
<li><a class="waves-effect" href="dosen.html"><i class="menu-icon fa fa-list"></i><span>Managemen
|
||||||
@@ -292,7 +311,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Modal View Penelitian -->
|
<!-- Modal Lihat Penelitian (Read-Only, Text Only) -->
|
||||||
<div class="modal fade" id="modalPenelitian" tabindex="-1" role="dialog" aria-labelledby="modalLabel">
|
<div class="modal fade" id="modalPenelitian" tabindex="-1" role="dialog" aria-labelledby="modalLabel">
|
||||||
<div class="modal-dialog" role="document">
|
<div class="modal-dialog" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
@@ -302,36 +321,52 @@
|
|||||||
<h4 class="modal-title" id="modalLabel">Lihat Penelitian</h4>
|
<h4 class="modal-title" id="modalLabel">Lihat Penelitian</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<form id="formPenelitian">
|
<table class="table table-condensed detail-table" style="margin-bottom: 0;">
|
||||||
<div class="form-group">
|
<tr>
|
||||||
<label>Nama Dosen</label>
|
<td><strong>Nama Dosen</strong></td>
|
||||||
<input type="text" class="form-control" id="view_dosen_name" readonly>
|
<td>: <span id="v_dosen_name"></span></td>
|
||||||
</div>
|
</tr>
|
||||||
<div class="form-group">
|
<tr>
|
||||||
<label>Judul Penelitian</label>
|
<td><strong>Judul Penelitian</strong></td>
|
||||||
<input type="text" class="form-control" id="view_judul" readonly>
|
<td>: <span id="v_judul"></span></td>
|
||||||
</div>
|
</tr>
|
||||||
<div class="form-group">
|
<tr>
|
||||||
<label>Tahun Penelitian</label>
|
<td><strong>Tahun</strong></td>
|
||||||
<input type="text" class="form-control" id="view_tahun" readonly>
|
<td>: <span id="v_tahun"></span></td>
|
||||||
</div>
|
</tr>
|
||||||
<div class="form-group">
|
<tr>
|
||||||
<label>Status Penelitian</label>
|
<td><strong>Status</strong></td>
|
||||||
<input type="text" class="form-control" id="view_status" readonly>
|
<td>: <span id="v_status"></span></td>
|
||||||
</div>
|
</tr>
|
||||||
<div class="form-group">
|
<tr>
|
||||||
<label>Keterangan</label>
|
<td><strong>Anggota</strong></td>
|
||||||
<textarea class="form-control" id="view_keterangan" rows="3" readonly></textarea>
|
<td>
|
||||||
</div>
|
<ul id="v_anggota"></ul>
|
||||||
<div class="form-group" id="fileListSection" style="display: none;">
|
</td>
|
||||||
<label>Daftar File Publikasi:</label>
|
</tr>
|
||||||
<div id="existingFilesContainer" class="mt-2"></div>
|
<tr>
|
||||||
</div>
|
<td><strong>Keterangan</strong></td>
|
||||||
</form>
|
<td>: <span id="v_keterangan"></span></td>
|
||||||
|
</tr>
|
||||||
|
<tr id="v_files_row">
|
||||||
|
<td><strong>File Publikasi</strong></td>
|
||||||
|
<td>
|
||||||
|
<div id="v_files"></div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Dibuat</strong></td>
|
||||||
|
<td>: <span id="v_created"></span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Terakhir Diubah</strong></td>
|
||||||
|
<td>: <span id="v_updated"></span></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-info pull-left" id="btnHistory" onclick="viewHistory()"><i
|
<button type="button" class="btn btn-info pull-left" id="btnHistory"
|
||||||
class="fa fa-history"></i> Riwayat Laporan</button>
|
onclick="viewHistoryFromView()"><i class="fa fa-history"></i> Riwayat Laporan</button>
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">Tutup</button>
|
<button type="button" class="btn btn-default" data-dismiss="modal">Tutup</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -380,26 +415,57 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
const dosenName = localStorage.getItem('dosen_name');
|
|
||||||
const dosenId = localStorage.getItem('dosen_id');
|
const dosenId = localStorage.getItem('dosen_id');
|
||||||
|
const dosenName = localStorage.getItem('dosen_name');
|
||||||
if (dosenName) document.getElementById('dosenName').textContent = dosenName;
|
if (dosenName) document.getElementById('dosenName').textContent = dosenName;
|
||||||
|
|
||||||
// Fetch current profile image
|
// Fetch current profile image using the FAST single-record API
|
||||||
$.get(`/api/dosen`, function (data) {
|
if (dosenId) {
|
||||||
const dosen = data.find(d => d.dosen_id === dosenId);
|
$.get(`/api/dosen/cek/${dosenId}`, function (dosen) {
|
||||||
if (dosen && dosen.dosen_image) {
|
console.log("Fetched dosen data:", dosen);
|
||||||
const imgUrl = `/api/images/dosen/${dosen.dosen_image}`;
|
console.log("Dosen Image:", dosen.dosen_image);
|
||||||
$('#profileImagePreview').attr('src', imgUrl);
|
if (dosen && dosen.dosen_image) {
|
||||||
$('#foto_dosen').attr('src', imgUrl);
|
const imgUrl = `/api/images/dosen/${dosen.dosen_image}?t=${new Date().getTime()}`;
|
||||||
}
|
$('#profileImagePreview').attr('src', imgUrl);
|
||||||
});
|
$('#foto_dosen').attr('src', imgUrl);
|
||||||
|
}
|
||||||
|
}).fail(function (xhr) {
|
||||||
|
console.error("Gagal memuat data dosen:", xhr.responseJSON?.error);
|
||||||
|
// If the ID is invalid, log them out
|
||||||
|
if (xhr.status === 404) {
|
||||||
|
swal("Sesi Berakhir", "Data dosen tidak ditemukan. Silakan login kembali.", "warning");
|
||||||
|
setTimeout(() => {
|
||||||
|
localStorage.clear();
|
||||||
|
window.location.href = 'index.html';
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
let dataTable;
|
let dataTable;
|
||||||
let currentViewId = null;
|
let currentViewId = null;
|
||||||
|
|
||||||
|
// --- HELPERS ---
|
||||||
|
function escapeHtml(value) {
|
||||||
|
return String(value ?? '').replace(/[&<>"']/g, char => ({
|
||||||
|
'&': '&', '<': '<', '>': '>', '"': '"', "'": '''
|
||||||
|
})[char]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseAnggota(value) {
|
||||||
|
if (Array.isArray(value)) return value;
|
||||||
|
if (typeof value === 'string' && value.trim()) {
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(value);
|
||||||
|
return Array.isArray(parsed) ? parsed : [];
|
||||||
|
} catch (error) { return []; }
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
// --- DATE FORMATTER (ISO String to "DD Mon YYYY, HH.mm") ---
|
// --- DATE FORMATTER (ISO String to "DD Mon YYYY, HH.mm") ---
|
||||||
function formatDateOnly(dateString) {
|
function formatDateOnly(dateString) {
|
||||||
if (!dateString) return '-';
|
if (!dateString) return '-';
|
||||||
@@ -550,12 +616,13 @@
|
|||||||
let badge = latestUpdateItem.status_penelitian === 'Berjalan' ? 'label-warning' : 'label-success';
|
let badge = latestUpdateItem.status_penelitian === 'Berjalan' ? 'label-warning' : 'label-success';
|
||||||
container.append(`
|
container.append(`
|
||||||
<div style="margin-bottom: 15px;">
|
<div style="margin-bottom: 15px;">
|
||||||
<h5 style="margin-top: 0; font-weight: bold; color: #333;">${latestUpdateItem.judul_penelitian}</h5>
|
<h5 style="margin-top: 0; font-weight: bold; color: #333;">${escapeHtml(latestUpdateItem.judul_penelitian)}</h5>
|
||||||
<p class="text-muted" style="margin-bottom: 5px; font-size: 13px;">
|
<p class="text-muted" style="margin-bottom: 5px; font-size: 13px;">
|
||||||
<i class="fa fa-user"></i> ${latestUpdateItem.dosen_name} <br>
|
<i class="fa fa-user"></i> ${escapeHtml(latestUpdateItem.dosen_name)} <br>
|
||||||
|
<i class="fa fa-users"></i> ${escapeHtml(latestUpdateItem.anggota ? JSON.parse(latestUpdateItem.anggota).join(', ') : '-')} <br>
|
||||||
<i class="fa fa-calendar"></i> ${formatDateOnly(latestUpdateItem.updated_at)}
|
<i class="fa fa-calendar"></i> ${formatDateOnly(latestUpdateItem.updated_at)}
|
||||||
</p>
|
</p>
|
||||||
<span class="label ${badge}" style="font-size: 12px;">${latestUpdateItem.status_penelitian}</span>
|
<span class="label ${badge}" style="font-size: 12px;">${escapeHtml(latestUpdateItem.status_penelitian)}</span>
|
||||||
</div>
|
</div>
|
||||||
`);
|
`);
|
||||||
} else {
|
} else {
|
||||||
@@ -602,51 +669,73 @@
|
|||||||
|
|
||||||
function viewPenelitian(id) {
|
function viewPenelitian(id) {
|
||||||
currentViewId = id;
|
currentViewId = id;
|
||||||
// Find the data by making an AJAX call (or we can find it in DataTable data)
|
|
||||||
$.get(`/api/penelitian`, function (allData) {
|
$.get(`/api/penelitian`, function (allData) {
|
||||||
const item = allData.find(p => p.id === id);
|
const item = allData.find(p => p.id === id);
|
||||||
if (item) {
|
if (!item) return;
|
||||||
$('#view_dosen_name').val(item.dosen_name);
|
|
||||||
$('#view_judul').val(item.judul_penelitian);
|
|
||||||
$('#view_tahun').val(item.tahun_penelitian);
|
|
||||||
$('#view_status').val(item.status_penelitian);
|
|
||||||
$('#view_keterangan').val(item.keterangan || '');
|
|
||||||
|
|
||||||
renderExistingFilesView(item.hasil_publikasi);
|
// Basic fields
|
||||||
$('#modalPenelitian').modal('show');
|
$('#v_dosen_name').text(item.dosen_name || '-');
|
||||||
|
$('#v_judul').text(item.judul_penelitian || '-');
|
||||||
|
$('#v_tahun').text(item.tahun_penelitian || '-');
|
||||||
|
|
||||||
|
// Status badge
|
||||||
|
const badge = item.status_penelitian === 'Berjalan' ? 'label-warning' : 'label-success';
|
||||||
|
$('#v_status').html(`<span class="label ${badge}">${escapeHtml(item.status_penelitian)}</span>`);
|
||||||
|
|
||||||
|
// Anggota list
|
||||||
|
const anggota = parseAnggota(item.anggota);
|
||||||
|
const $anggota = $('#v_anggota').empty();
|
||||||
|
if (anggota.length) {
|
||||||
|
anggota.forEach(nama => $anggota.append(`<li>${escapeHtml(nama)}</li>`));
|
||||||
|
} else {
|
||||||
|
$anggota.append('<li class="text-muted">-</li>');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Keterangan
|
||||||
|
$('#v_keterangan').text(item.keterangan || '-');
|
||||||
|
|
||||||
|
// Files
|
||||||
|
const $files = $('#v_files').empty();
|
||||||
|
let filesArr = [];
|
||||||
|
try {
|
||||||
|
filesArr = typeof item.hasil_publikasi === 'string'
|
||||||
|
? JSON.parse(item.hasil_publikasi)
|
||||||
|
: (item.hasil_publikasi || []);
|
||||||
|
} catch (e) { filesArr = []; }
|
||||||
|
|
||||||
|
if (filesArr.length) {
|
||||||
|
$('#v_files_row').show();
|
||||||
|
filesArr.forEach(f => {
|
||||||
|
const displayName = f.substring(f.indexOf('-') + 1);
|
||||||
|
$files.append(`
|
||||||
|
<div class="file-item">
|
||||||
|
<a href="/api/uploads/${f}" target="_blank">
|
||||||
|
<i class="fa fa-file-pdf-o text-danger"></i> ${displayName}
|
||||||
|
</a>
|
||||||
|
</div>`);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$('#v_files_row').show();
|
||||||
|
$files.append('<span class="text-muted">-</span>');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Timestamps
|
||||||
|
$('#v_created').text(formatDateOnly(item.created_at));
|
||||||
|
$('#v_updated').text(formatDateOnly(item.updated_at));
|
||||||
|
|
||||||
|
$('#modalPenelitian').modal('show');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderExistingFilesView(filesData) {
|
function viewHistoryFromView() {
|
||||||
let currentFiles = [];
|
$('#modalPenelitian').modal('hide');
|
||||||
if (Array.isArray(filesData)) currentFiles = filesData;
|
setTimeout(() => viewHistory(), 300);
|
||||||
else if (typeof filesData === 'string') {
|
|
||||||
try { currentFiles = JSON.parse(filesData); } catch (e) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
const container = $('#existingFilesContainer');
|
|
||||||
container.empty();
|
|
||||||
|
|
||||||
if (currentFiles.length > 0) {
|
|
||||||
$('#fileListSection').show();
|
|
||||||
currentFiles.forEach((filename) => {
|
|
||||||
let displayName = filename.substring(filename.indexOf('-') + 1);
|
|
||||||
container.append(`
|
|
||||||
<div class="file-item">
|
|
||||||
<a href="/api/uploads/${filename}" target="_blank"><i class="fa fa-file-pdf-o text-danger"></i> ${displayName}</a>
|
|
||||||
</div>
|
|
||||||
`);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
$('#fileListSection').hide();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function viewHistory() {
|
function viewHistory() {
|
||||||
if (!currentViewId) return;
|
if (!currentViewId) return;
|
||||||
$('#historyContainer').empty();
|
$('#historyContainer').empty();
|
||||||
$('#modalPenelitian').modal('hide');
|
|
||||||
$('#modalHistory').modal('show');
|
$('#modalHistory').modal('show');
|
||||||
|
|
||||||
$.get(`/api/laporan/${currentViewId}`, function (data) {
|
$.get(`/api/laporan/${currentViewId}`, function (data) {
|
||||||
@@ -656,6 +745,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
data.forEach((log, index) => {
|
data.forEach((log, index) => {
|
||||||
|
// Anggota per-version
|
||||||
|
const anggotaList = parseAnggota(log.anggota);
|
||||||
|
const anggotaHtml = anggotaList.length
|
||||||
|
? anggotaList.map(nama => `<li>${escapeHtml(nama)}</li>`).join('')
|
||||||
|
: '<span class="text-muted">-</span>';
|
||||||
|
|
||||||
let filesHtml = '';
|
let filesHtml = '';
|
||||||
if (log.hasil_publikasi) {
|
if (log.hasil_publikasi) {
|
||||||
try {
|
try {
|
||||||
@@ -679,8 +774,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="history-body">
|
<div class="history-body">
|
||||||
<table class="table table-condensed" style="margin-bottom: 0;">
|
<table class="table table-condensed" style="margin-bottom: 0;">
|
||||||
<tr><td width="120"><strong>Status</strong></td><td>: <span class="label ${log.status_penelitian === 'Berjalan' ? 'label-warning' : 'label-success'}">${log.status_penelitian}</span></td></tr>
|
<tr><td width="120"><strong>Status</strong></td><td>: <span class="label ${log.status_penelitian === 'Berjalan' ? 'label-warning' : 'label-success'}">${escapeHtml(log.status_penelitian)}</span></td></tr>
|
||||||
<tr><td><strong>Keterangan</strong></td><td>: ${log.keterangan || '-'}</td></tr>
|
<tr><td><strong>Anggota</strong></td><td><ul style="margin:0; padding-left:20px;">${anggotaHtml}</ul></td></tr>
|
||||||
|
<tr><td><strong>Keterangan</strong></td><td>: ${escapeHtml(log.keterangan || '-')}</td></tr>
|
||||||
<tr><td><strong>File</strong></td><td>${filesHtml || '-'}</td></tr>
|
<tr><td><strong>File</strong></td><td>${filesHtml || '-'}</td></tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+29
-13
@@ -7,6 +7,8 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||||
<title>Aplikasi Penelitian Dosen - Halaman Utama Dosen</title>
|
<title>Aplikasi Penelitian Dosen - Halaman Utama Dosen</title>
|
||||||
|
|
||||||
|
<link rel="icon" href="assets/images/icon.png" type="image/x-icon">
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
(async function checkAuth() {
|
(async function checkAuth() {
|
||||||
const dosenId = localStorage.getItem('dosen_id');
|
const dosenId = localStorage.getItem('dosen_id');
|
||||||
@@ -312,20 +314,34 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
const dosenName = localStorage.getItem('dosen_name');
|
|
||||||
const dosenId = localStorage.getItem('dosen_id');
|
const dosenId = localStorage.getItem('dosen_id');
|
||||||
|
const dosenName = localStorage.getItem('dosen_name');
|
||||||
if (dosenName) document.getElementById('dosenName').textContent = dosenName;
|
if (dosenName) document.getElementById('dosenName').textContent = dosenName;
|
||||||
|
|
||||||
// Fetch current profile image
|
console.log("Dosen ID:", dosenId, "Dosen Name:", dosenName);
|
||||||
$.get(`/api/dosen`, function (data) {
|
|
||||||
const dosen = data.find(d => d.dosen_id === dosenId);
|
// Fetch current profile image using the FAST single-record API
|
||||||
if (dosen && dosen.dosen_image) {
|
if (dosenId) {
|
||||||
const imgUrl = `/api/images/dosen/${dosen.dosen_image}`;
|
$.get(`/api/dosen/cek/${dosenId}`, function (dosen) {
|
||||||
$('#profileImagePreview').attr('src', imgUrl);
|
console.log("Fetched dosen data:", dosen);
|
||||||
$('#foto_dosen').attr('src', imgUrl);
|
console.log("Dosen Image:", dosen.dosen_image);
|
||||||
}
|
if (dosen && dosen.dosen_image) {
|
||||||
});
|
const imgUrl = `/api/images/dosen/${dosen.dosen_image}?t=${new Date().getTime()}`;
|
||||||
|
$('#profileImagePreview').attr('src', imgUrl);
|
||||||
|
$('#foto_dosen').attr('src', imgUrl);
|
||||||
|
}
|
||||||
|
}).fail(function (xhr) {
|
||||||
|
console.error("Gagal memuat data dosen:", xhr.responseJSON?.error);
|
||||||
|
// If the ID is invalid, log them out
|
||||||
|
if (xhr.status === 404) {
|
||||||
|
swal("Sesi Berakhir", "Data dosen tidak ditemukan. Silakan login kembali.", "warning");
|
||||||
|
setTimeout(() => {
|
||||||
|
localStorage.clear();
|
||||||
|
window.location.href = 'index.html';
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Fetch Data for Stats and Last Update
|
// Fetch Data for Stats and Last Update
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -374,8 +390,8 @@
|
|||||||
container.append(`
|
container.append(`
|
||||||
<div style="margin-bottom: 15px;">
|
<div style="margin-bottom: 15px;">
|
||||||
<h5 style="margin-top: 0; font-weight: bold; color: #333; line-height: 1.4;">${latestUpdateItem.judul_penelitian}</h5>
|
<h5 style="margin-top: 0; font-weight: bold; color: #333; line-height: 1.4;">${latestUpdateItem.judul_penelitian}</h5>
|
||||||
|
<i class="fa fa-users"></i> ${latestUpdateItem.anggota ? JSON.parse(latestUpdateItem.anggota).join(', ') : '-'} <br>
|
||||||
<p style="font-size: 13px; color: #555; text-align: justify; margin-bottom: 10px;">
|
<p style="font-size: 13px; color: #555; text-align: justify; margin-bottom: 10px; margin-top: 5px;">
|
||||||
${keteranganText}
|
${keteranganText}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|||||||
+24
-9
@@ -7,6 +7,8 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||||
<title>Aplikasi Penelitian Dosen - Profil Dosen</title>
|
<title>Aplikasi Penelitian Dosen - Profil Dosen</title>
|
||||||
|
|
||||||
|
<link rel="icon" href="assets/images/icon.png" type="image/x-icon">
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
(async function checkAuth() {
|
(async function checkAuth() {
|
||||||
const dosenId = localStorage.getItem('dosen_id');
|
const dosenId = localStorage.getItem('dosen_id');
|
||||||
@@ -208,16 +210,29 @@
|
|||||||
const dosenName = localStorage.getItem('dosen_name');
|
const dosenName = localStorage.getItem('dosen_name');
|
||||||
if (dosenName) document.getElementById('dosenName').textContent = dosenName;
|
if (dosenName) document.getElementById('dosenName').textContent = dosenName;
|
||||||
|
|
||||||
// Fetch current profile image
|
// Fetch current profile image using the FAST single-record API
|
||||||
$.get(`/api/dosen`, function (data) {
|
if (dosenId) {
|
||||||
const dosen = data.find(d => d.dosen_id === dosenId);
|
$.get(`/api/dosen/cek/${dosenId}`, function (dosen) {
|
||||||
if (dosen && dosen.dosen_image) {
|
console.log("Fetched dosen data:", dosen);
|
||||||
const imgUrl = `/api/images/dosen/${dosen.dosen_image}`;
|
console.log("Dosen Image:", dosen.dosen_image);
|
||||||
|
if (dosen && dosen.dosen_image) {
|
||||||
|
const imgUrl = `/api/images/dosen/${dosen.dosen_image}?t=${new Date().getTime()}`;
|
||||||
|
$('#profileImagePreview').attr('src', imgUrl);
|
||||||
|
$('#foto_dosen').attr('src', imgUrl);
|
||||||
|
}
|
||||||
|
}).fail(function (xhr) {
|
||||||
|
console.error("Gagal memuat data dosen:", xhr.responseJSON?.error);
|
||||||
|
// If the ID is invalid, log them out
|
||||||
|
if (xhr.status === 404) {
|
||||||
|
swal("Sesi Berakhir", "Data dosen tidak ditemukan. Silakan login kembali.", "warning");
|
||||||
|
setTimeout(() => {
|
||||||
|
localStorage.clear();
|
||||||
|
window.location.href = 'index.html';
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$('#profileImagePreview').attr('src', imgUrl);
|
|
||||||
$('#foto_dosen').attr('src', imgUrl);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// ============ CHANGE PASSWORD AJAX ============
|
// ============ CHANGE PASSWORD AJAX ============
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
<title>Aplikasi Penelitian Dosen - Halaman Utama</title>
|
<title>Aplikasi Penelitian Dosen - Halaman Utama</title>
|
||||||
|
|
||||||
|
<link rel="icon" href="assets/images/icon.png" type="image/x-icon">
|
||||||
|
|
||||||
<!-- Main Styles -->
|
<!-- Main Styles -->
|
||||||
<link rel="stylesheet" href="assets/styles/style.min.css">
|
<link rel="stylesheet" href="assets/styles/style.min.css">
|
||||||
<link rel="stylesheet" href="assets/plugin/mCustomScrollbar/jquery.mCustomScrollbar.min.css">
|
<link rel="stylesheet" href="assets/plugin/mCustomScrollbar/jquery.mCustomScrollbar.min.css">
|
||||||
@@ -262,6 +264,7 @@
|
|||||||
<h5 style="margin-top: 0; font-weight: bold; color: #333;">${latestUpdateItem.judul_penelitian}</h5>
|
<h5 style="margin-top: 0; font-weight: bold; color: #333;">${latestUpdateItem.judul_penelitian}</h5>
|
||||||
<p class="text-muted" style="margin-bottom: 5px; font-size: 13px;">
|
<p class="text-muted" style="margin-bottom: 5px; font-size: 13px;">
|
||||||
<i class="fa fa-user"></i> ${latestUpdateItem.dosen_name} <br>
|
<i class="fa fa-user"></i> ${latestUpdateItem.dosen_name} <br>
|
||||||
|
<i class="fa fa-users"></i> ${latestUpdateItem.anggota ? JSON.parse(latestUpdateItem.anggota).join(', ') : '-'} <br>
|
||||||
<i class="fa fa-calendar"></i> ${formatDateOnly(latestUpdateItem.updated_at)}
|
<i class="fa fa-calendar"></i> ${formatDateOnly(latestUpdateItem.updated_at)}
|
||||||
</p>
|
</p>
|
||||||
<span class="label ${badge}" style="font-size: 12px;">${latestUpdateItem.status_penelitian}</span>
|
<span class="label ${badge}" style="font-size: 12px;">${latestUpdateItem.status_penelitian}</span>
|
||||||
|
|||||||
+7
-4
@@ -4,6 +4,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Laporan Penelitian Dosen</title>
|
<title>Laporan Penelitian Dosen</title>
|
||||||
|
<link rel="icon" href="assets/images/icon.png" type="image/x-icon">
|
||||||
<style>
|
<style>
|
||||||
/* Base Styles */
|
/* Base Styles */
|
||||||
body {
|
body {
|
||||||
@@ -215,13 +216,14 @@
|
|||||||
<th width="5%">No</th>
|
<th width="5%">No</th>
|
||||||
<th width="20%">Tanggal Update</th>
|
<th width="20%">Tanggal Update</th>
|
||||||
<th width="15%">Status</th>
|
<th width="15%">Status</th>
|
||||||
|
<th width="15%">Anggota</th>
|
||||||
<th width="25%">Keterangan</th>
|
<th width="25%">Keterangan</th>
|
||||||
<th width="35%">File Publikasi</th>
|
<th width="20%">File Publikasi</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="printDataBody">
|
<tbody id="printDataBody">
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" style="text-align: center;">Memuat data...</td>
|
<td colspan="6" style="text-align: center;">Memuat data...</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@@ -302,7 +304,7 @@
|
|||||||
tbody.innerHTML = '';
|
tbody.innerHTML = '';
|
||||||
|
|
||||||
if (data.length === 0) {
|
if (data.length === 0) {
|
||||||
tbody.innerHTML = '<tr><td colspan="5" style="text-align: center;">Tidak ada riwayat.</td></tr>';
|
tbody.innerHTML = '<tr><td colspan="6" style="text-align: center;">Tidak ada riwayat.</td></tr>';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,6 +329,7 @@
|
|||||||
<td style="text-align: center;">${index + 1}</td>
|
<td style="text-align: center;">${index + 1}</td>
|
||||||
<td>${formatDateWIB(log.created_at)}</td>
|
<td>${formatDateWIB(log.created_at)}</td>
|
||||||
<td style="text-align: center;">${log.status_penelitian}</td>
|
<td style="text-align: center;">${log.status_penelitian}</td>
|
||||||
|
<td>${log.anggota || '-'}</td>
|
||||||
<td>${log.keterangan || '-'}</td>
|
<td>${log.keterangan || '-'}</td>
|
||||||
<td>${filesHtml}</td>
|
<td>${filesHtml}</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -335,7 +338,7 @@
|
|||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
document.getElementById('printDataBody').innerHTML = '<tr><td colspan="5" style="text-align: center; color: red;">Gagal memuat data.</td></tr>';
|
document.getElementById('printDataBody').innerHTML = '<tr><td colspan="6" style="text-align: center; color: red;">Gagal memuat data.</td></tr>';
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
+7
-1
@@ -5,6 +5,7 @@
|
|||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||||
<title>Login - Aplikasi Penelitian Dosen</title>
|
<title>Login - Aplikasi Penelitian Dosen</title>
|
||||||
|
<link rel="icon" href="assets/images/icon.png" type="image/x-icon">
|
||||||
<link rel="stylesheet" href="assets/styles/style.min.css">
|
<link rel="stylesheet" href="assets/styles/style.min.css">
|
||||||
<link rel="stylesheet" href="assets/plugin/waves/waves.min.css">
|
<link rel="stylesheet" href="assets/plugin/waves/waves.min.css">
|
||||||
</head>
|
</head>
|
||||||
@@ -64,6 +65,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
console.log('Login response:', data);
|
||||||
|
|
||||||
if (response.ok && data.success) {
|
if (response.ok && data.success) {
|
||||||
// Clear previous auth data
|
// Clear previous auth data
|
||||||
@@ -77,7 +79,11 @@
|
|||||||
localStorage.setItem('dosen_id', data.dosen_id);
|
localStorage.setItem('dosen_id', data.dosen_id);
|
||||||
localStorage.setItem('dosen_name', data.dosen_name);
|
localStorage.setItem('dosen_name', data.dosen_name);
|
||||||
window.location.href = 'dosen_index.html';
|
window.location.href = 'dosen_index.html';
|
||||||
}
|
} else if (data.role === 'mahasiswa') {
|
||||||
|
localStorage.setItem('id_mahasiswa', data.id_mahasiswa);
|
||||||
|
localStorage.setItem('nama_mahasiswa', data.nama_mahasiswa);
|
||||||
|
window.location.href = 'mahasiswa_index.html';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
alert(data.message || 'Login gagal!');
|
alert(data.message || 'Login gagal!');
|
||||||
document.getElementById('password').value = '';
|
document.getElementById('password').value = '';
|
||||||
|
|||||||
@@ -0,0 +1,384 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||||
|
<meta name="description" content="Sistem Informasi Penelitian Dosen Universitas Handayani Makassar">
|
||||||
|
<meta name="author" content="">
|
||||||
|
|
||||||
|
<title>Aplikasi Penelitian Dosen - Halaman Utama Mahasiswa</title>
|
||||||
|
|
||||||
|
<!-- setup ico -->
|
||||||
|
<link rel="icon" href="assets/images/icon.png" type="image/x-icon">
|
||||||
|
|
||||||
|
<!-- Main Styles -->
|
||||||
|
<link rel="stylesheet" href="assets/styles/style.min.css">
|
||||||
|
<link rel="stylesheet" href="assets/plugin/mCustomScrollbar/jquery.mCustomScrollbar.min.css">
|
||||||
|
<link rel="stylesheet" href="assets/plugin/waves/waves.min.css">
|
||||||
|
<link rel="stylesheet" href="assets/plugin/sweet-alert/sweetalert.css">
|
||||||
|
<link rel="stylesheet" href="assets/color-switcher/color-switcher.min.css">
|
||||||
|
<link rel="stylesheet" href="assets/plugin/datatables/media/css/dataTables.bootstrap.min.css">
|
||||||
|
<link rel="stylesheet" href="assets/plugin/datatables/extensions/Responsive/css/responsive.bootstrap.min.css">
|
||||||
|
|
||||||
|
<script>
|
||||||
|
(async function checkAuth() {
|
||||||
|
const mahasiswaId = localStorage.getItem('id_mahasiswa');
|
||||||
|
const mahasiswaName = localStorage.getItem('nama_mahasiswa');
|
||||||
|
|
||||||
|
if (!mahasiswaId || !mahasiswaName) {
|
||||||
|
localStorage.clear();
|
||||||
|
window.location.href = 'index.html';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch(`/api/mahasiswa/verify?id_mahasiswa=${encodeURIComponent(mahasiswaId)}&nama_mahasiswa=${encodeURIComponent(mahasiswaName)}`);
|
||||||
|
const data = await response.json();
|
||||||
|
console.log("Auth check response:", data);
|
||||||
|
|
||||||
|
if (response.ok && data.valid) {
|
||||||
|
document.body.style.display = 'block';
|
||||||
|
} else {
|
||||||
|
localStorage.clear();
|
||||||
|
window.location.href = 'index.html';
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Auth check failed:", error);
|
||||||
|
localStorage.clear();
|
||||||
|
window.location.href = 'index.html';
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header .avatar {
|
||||||
|
width: 65px;
|
||||||
|
height: 65px;
|
||||||
|
display: inline-block;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: 50%;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header .avatar img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="main-menu">
|
||||||
|
<header class="header">
|
||||||
|
<a href="mahasiswa_index.html" class="logo">UHM</a>
|
||||||
|
<button type="button" class="button-close fa fa-times js__menu_close"></button>
|
||||||
|
<div class="user">
|
||||||
|
<a href="#" class="avatar"><img src="assets/images/person.png" id="foto_mahasiswa" alt=""><span
|
||||||
|
class="status online"></span></a>
|
||||||
|
<h5 class="name"><a href="#" id="mahasiswaName">Mahasiswa</a></h5>
|
||||||
|
<h5 class="position">Mahasiswa</h5>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<div class="content">
|
||||||
|
<div class="navigation">
|
||||||
|
<h5 class="title">Navigasi</h5>
|
||||||
|
<ul class="menu js__accordion">
|
||||||
|
<li class="current">
|
||||||
|
<a class="waves-effect" href="mahasiswa_index.html"><i
|
||||||
|
class="menu-icon fa fa-home"></i><span>Halaman Utama</span></a>
|
||||||
|
</li>
|
||||||
|
<li><a class="waves-effect" href="mahasiswa_list_penelitian.html"><i
|
||||||
|
class="menu-icon fa fa-list"></i><span>List Penelitian</span></a></li>
|
||||||
|
|
||||||
|
<li><a class="waves-effect" href="mahasiswa_profile.html"><i
|
||||||
|
class="menu-icon fa fa-user"></i><span>Profil</span></a></li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<a class="waves-effect" href="#" onclick="logout()"><i
|
||||||
|
class="menu-icon fa fa-sign-out"></i><span>Logout</span></a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="fixed-navbar">
|
||||||
|
<div class="pull-left">
|
||||||
|
<button type="button"
|
||||||
|
class="menu-mobile-button glyphicon glyphicon-menu-hamburger js__menu_mobile"></button>
|
||||||
|
<h1 class="page-title">Halaman Utama</h1>
|
||||||
|
</div>
|
||||||
|
<div class="pull-right">
|
||||||
|
<div class="ico-item fa fa-arrows-alt js__full_screen"></div>
|
||||||
|
<a href="#" class="ico-item fa fa-sign-out" onclick="logout()" title="Logout"></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="wrapper">
|
||||||
|
<div class="main-content">
|
||||||
|
|
||||||
|
<!-- STATISTICS -->
|
||||||
|
<div class="row small-spacing">
|
||||||
|
<div class="col-lg-3 col-md-6 col-xs-12">
|
||||||
|
<div class="box-content">
|
||||||
|
<div class="statistics-box with-icon">
|
||||||
|
<i class="ico fa fa-wpforms text-inverse"></i>
|
||||||
|
<h2 class="counter text-inverse" id="h_jumlah_penelitian">...</h2>
|
||||||
|
<p class="text">Jumlah Penelitian</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-3 col-md-6 col-xs-12">
|
||||||
|
<div class="box-content">
|
||||||
|
<div class="statistics-box with-icon">
|
||||||
|
<i class="ico fa fa-check text-success"></i>
|
||||||
|
<h2 class="counter text-success" id="h_penelitian_selesai">...</h2>
|
||||||
|
<p class="text">Penelitian Selesai</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-3 col-md-6 col-xs-12">
|
||||||
|
<div class="box-content">
|
||||||
|
<div class="statistics-box with-icon">
|
||||||
|
<i class="ico fa fa-clock-o text-primary"></i>
|
||||||
|
<h2 class="counter text-primary" id="h_penelitian_berjalan">...</h2>
|
||||||
|
<p class="text">Penelitian Berjalan</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-3 col-md-6 col-xs-12">
|
||||||
|
<div class="box-content">
|
||||||
|
<div class="statistics-box with-icon">
|
||||||
|
<i class="ico fa fa-users text-info"></i>
|
||||||
|
<h2 class="counter text-info" id="h_jumlah_dosen">...</h2>
|
||||||
|
<p class="text">Jumlah Dosen</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- CHART SECTION -->
|
||||||
|
<div class="row small-spacing">
|
||||||
|
<div class="col-lg-12 col-xs-12">
|
||||||
|
<div class="box-content card">
|
||||||
|
<h4 class="box-title">Statistik Penelitian</h4>
|
||||||
|
<div class="card-content">
|
||||||
|
<canvas id="penelitianChart" style="width: 100%; height: 400px;"></canvas>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- INFO AND LAST UPDATE -->
|
||||||
|
<div class="row small-spacing">
|
||||||
|
<div class="col-lg-7 col-xs-12">
|
||||||
|
<div class="box-content card">
|
||||||
|
<h4 class="box-title">Keterangan</h4>
|
||||||
|
<div class="card-content">
|
||||||
|
<p style="text-align: justify;">Selamat datang sistem penelitian dosen. Pada sistem ini
|
||||||
|
siswa dapat melihat dan mengunduh data penelitian yang dilakukan oleh dosen. Sila
|
||||||
|
gunakan menu navigasi di kiri untuk berpindah halaman.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-5 col-xs-12">
|
||||||
|
<div class="box-content card">
|
||||||
|
<h4 class="box-title">Last Updated</h4>
|
||||||
|
<div class="card-content" id="lastUpdateContainer">
|
||||||
|
<p class="text-center text-muted">Memuat data...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer class="footer">
|
||||||
|
<ul class="list-inline">
|
||||||
|
<li>2026 © Sistem Penelitian Dosen | Universitas Handayani Makassar.</li>
|
||||||
|
</ul>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Scripts -->
|
||||||
|
<script src="assets/scripts/jquery.min.js"></script>
|
||||||
|
<script src="assets/scripts/modernizr.min.js"></script>
|
||||||
|
<script src="assets/plugin/bootstrap/js/bootstrap.min.js"></script>
|
||||||
|
<script src="assets/plugin/mCustomScrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
|
||||||
|
<script src="assets/plugin/nprogress/nprogress.js"></script>
|
||||||
|
<script src="assets/plugin/sweet-alert/sweetalert.min.js"></script>
|
||||||
|
<script src="assets/plugin/waves/waves.min.js"></script>
|
||||||
|
<script src="assets/plugin/fullscreen/jquery.fullscreen-min.js"></script>
|
||||||
|
<script src="assets/plugin/chart/chartjs/Chart.bundle.min.js"></script>
|
||||||
|
<script src="assets/scripts/main.min.js"></script>
|
||||||
|
<script src="assets/color-switcher/color-switcher.min.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready(function () {
|
||||||
|
const mahasiswaName = localStorage.getItem('nama_mahasiswa');
|
||||||
|
const mahasiswaId = localStorage.getItem('id_mahasiswa');
|
||||||
|
|
||||||
|
if (mahasiswaName) document.getElementById('mahasiswaName').textContent = mahasiswaName;
|
||||||
|
|
||||||
|
// Fetch current profile image using the FAST single-record API
|
||||||
|
if (mahasiswaId) {
|
||||||
|
$.get(`/api/mahasiswa/cek/${mahasiswaId}`, function (mahasiswa) {
|
||||||
|
if (mahasiswa && mahasiswa.mahasiswa_image) {
|
||||||
|
const imgUrl = `/api/images/mahasiswa/${mahasiswa.mahasiswa_image}?t=${new Date().getTime()}`;
|
||||||
|
$('#profileImagePreview').attr('src', imgUrl);
|
||||||
|
$('#foto_mahasiswa').attr('src', imgUrl);
|
||||||
|
}
|
||||||
|
}).fail(function (xhr) {
|
||||||
|
console.error("Gagal memuat data mahasiswa:", xhr.responseJSON?.error);
|
||||||
|
// Optional: If the ID is invalid, log them out
|
||||||
|
if (xhr.status === 404) {
|
||||||
|
swal("Sesi Berakhir", "Data mahasiswa tidak ditemukan. Silakan login kembali.", "warning");
|
||||||
|
setTimeout(() => {
|
||||||
|
localStorage.clear();
|
||||||
|
window.location.href = 'index.html';
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// --- DATE FORMATTER (ISO String to "DD Mon YYYY, HH.mm") ---
|
||||||
|
function formatDateOnly(dateString) {
|
||||||
|
if (!dateString) return '-';
|
||||||
|
if (!dateString.includes('T')) {
|
||||||
|
let cleanStr = dateString.replace('T', ' ');
|
||||||
|
return cleanStr.substring(0, 16).replace(/-/g, ' ').replace(':', '.');
|
||||||
|
}
|
||||||
|
const date = new Date(dateString);
|
||||||
|
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun', 'Jul', 'Agu', 'Sep', 'Okt', 'Nov', 'Des'];
|
||||||
|
const day = String(date.getUTCDate()).padStart(2, '0');
|
||||||
|
const month = months[date.getUTCMonth()];
|
||||||
|
const year = date.getUTCFullYear();
|
||||||
|
const hours = String(date.getUTCHours()).padStart(2, '0');
|
||||||
|
const minutes = String(date.getUTCMinutes()).padStart(2, '0');
|
||||||
|
return `${day} ${month} ${year}, ${hours}.${minutes}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- CHART RENDERING ---
|
||||||
|
function renderChart() {
|
||||||
|
$.get('/api/laporan/stats/daily', function (data) {
|
||||||
|
const labels = [];
|
||||||
|
const counts = [];
|
||||||
|
|
||||||
|
data.forEach(item => {
|
||||||
|
const dateObj = new Date(item.date);
|
||||||
|
const formattedDate = dateObj.toLocaleDateString('id-ID', { day: '2-digit', month: 'short' });
|
||||||
|
labels.push(formattedDate);
|
||||||
|
counts.push(item.total);
|
||||||
|
});
|
||||||
|
|
||||||
|
const ctx = document.getElementById('penelitianChart').getContext('2d');
|
||||||
|
new Chart(ctx, {
|
||||||
|
type: 'line',
|
||||||
|
data: {
|
||||||
|
labels: labels,
|
||||||
|
datasets: [{
|
||||||
|
label: 'Jumlah Aktivitas Penelitian',
|
||||||
|
data: counts,
|
||||||
|
backgroundColor: 'rgba(54, 162, 235, 0.2)',
|
||||||
|
borderColor: 'rgba(54, 162, 235, 1)',
|
||||||
|
borderWidth: 2,
|
||||||
|
pointBackgroundColor: 'rgba(54, 162, 235, 1)',
|
||||||
|
pointRadius: 4,
|
||||||
|
fill: true,
|
||||||
|
tension: 0.3
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
responsive: true,
|
||||||
|
maintainAspectRatio: false,
|
||||||
|
scales: { y: { beginAtZero: true, ticks: { stepSize: 1 } } }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
document.body.style.display = 'block';
|
||||||
|
|
||||||
|
// 1. Fetch Penelitian for Stats and Last Update
|
||||||
|
$.get('/api/penelitian', function (data) {
|
||||||
|
let total = data.length;
|
||||||
|
let selesai = 0;
|
||||||
|
let berjalan = 0;
|
||||||
|
let latestUpdateItem = null;
|
||||||
|
|
||||||
|
data.forEach(item => {
|
||||||
|
if (item.status_penelitian === 'Selesai') selesai++;
|
||||||
|
if (item.status_penelitian === 'Berjalan') berjalan++;
|
||||||
|
|
||||||
|
if (item.updated_at) {
|
||||||
|
const itemDate = new Date(item.updated_at);
|
||||||
|
if (!latestUpdateItem || itemDate > new Date(latestUpdateItem.updated_at)) {
|
||||||
|
latestUpdateItem = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#h_jumlah_penelitian').text(total);
|
||||||
|
$('#h_penelitian_selesai').text(selesai);
|
||||||
|
$('#h_penelitian_berjalan').text(berjalan);
|
||||||
|
|
||||||
|
const container = $('#lastUpdateContainer');
|
||||||
|
container.empty();
|
||||||
|
|
||||||
|
if (latestUpdateItem) {
|
||||||
|
let badge = latestUpdateItem.status_penelitian === 'Berjalan' ? 'label-warning' : 'label-success';
|
||||||
|
container.append(`
|
||||||
|
<div style="margin-bottom: 15px;">
|
||||||
|
<h5 style="margin-top: 0; font-weight: bold; color: #333;">${latestUpdateItem.judul_penelitian}</h5>
|
||||||
|
<p class="text-muted" style="margin-bottom: 5px; font-size: 13px;">
|
||||||
|
<i class="fa fa-user"></i> ${latestUpdateItem.dosen_name} <br>
|
||||||
|
<i class="fa fa-users"></i> ${latestUpdateItem.anggota ? JSON.parse(latestUpdateItem.anggota).join(', ') : '-'} <br>
|
||||||
|
<i class="fa fa-calendar"></i> ${formatDateOnly(latestUpdateItem.updated_at)}
|
||||||
|
</p>
|
||||||
|
<span class="label ${badge}" style="font-size: 12px;">${latestUpdateItem.status_penelitian}</span>
|
||||||
|
</div>
|
||||||
|
`);
|
||||||
|
} else {
|
||||||
|
container.append('<p class="text-center text-muted">Belum ada penelitian.</p>');
|
||||||
|
}
|
||||||
|
}).fail(function () {
|
||||||
|
$('#lastUpdateContainer').html('<p class="text-center text-danger">Gagal memuat data.</p>');
|
||||||
|
});
|
||||||
|
|
||||||
|
// 2. Fetch Dosen Count
|
||||||
|
$.get('/api/dosen', function (data) {
|
||||||
|
$('#h_jumlah_dosen').text(data.length);
|
||||||
|
}).fail(function () {
|
||||||
|
$('#h_jumlah_dosen').text('0');
|
||||||
|
});
|
||||||
|
|
||||||
|
// 3. Render Chart
|
||||||
|
renderChart();
|
||||||
|
});
|
||||||
|
|
||||||
|
function logout() {
|
||||||
|
swal({
|
||||||
|
title: "Logout?",
|
||||||
|
text: "Anda akan keluar dari halaman admin.",
|
||||||
|
type: "warning",
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonColor: "#DD6B55",
|
||||||
|
confirmButtonText: "Ya, Logout!",
|
||||||
|
closeOnConfirm: true
|
||||||
|
}, function () {
|
||||||
|
localStorage.removeItem('admin_auth');
|
||||||
|
window.location.href = 'index.html';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,801 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||||
|
<title>Aplikasi Penelitian Dosen - Halaman List Penelitian</title>
|
||||||
|
|
||||||
|
<link rel="icon" href="assets/images/icon.png" type="image/x-icon">
|
||||||
|
|
||||||
|
<script>
|
||||||
|
(async function checkAuth() {
|
||||||
|
const mahasiswaId = localStorage.getItem('id_mahasiswa');
|
||||||
|
const mahasiswaName = localStorage.getItem('nama_mahasiswa');
|
||||||
|
|
||||||
|
if (!mahasiswaId || !mahasiswaName) {
|
||||||
|
localStorage.clear();
|
||||||
|
window.location.href = 'index.html';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch(`/api/mahasiswa/verify?id_mahasiswa=${encodeURIComponent(mahasiswaId)}&nama_mahasiswa=${encodeURIComponent(mahasiswaName)}`);
|
||||||
|
const data = await response.json();
|
||||||
|
console.log("Auth check response:", data);
|
||||||
|
|
||||||
|
if (response.ok && data.valid) {
|
||||||
|
document.body.style.display = 'block';
|
||||||
|
} else {
|
||||||
|
localStorage.clear();
|
||||||
|
window.location.href = 'index.html';
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Auth check failed:", error);
|
||||||
|
localStorage.clear();
|
||||||
|
window.location.href = 'index.html';
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="assets/styles/style.min.css">
|
||||||
|
<link rel="stylesheet" href="assets/plugin/mCustomScrollbar/jquery.mCustomScrollbar.min.css">
|
||||||
|
<link rel="stylesheet" href="assets/plugin/waves/waves.min.css">
|
||||||
|
<link rel="stylesheet" href="assets/plugin/sweet-alert/sweetalert.css">
|
||||||
|
<link rel="stylesheet" href="assets/color-switcher/color-switcher.min.css">
|
||||||
|
<link rel="stylesheet" href="assets/plugin/datatables/media/css/dataTables.bootstrap.min.css">
|
||||||
|
<link rel="stylesheet" href="assets/plugin/datatables/extensions/Responsive/css/responsive.bootstrap.min.css">
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dataTables_filter {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fix for the top-left profile image to be a perfect circle */
|
||||||
|
.header .avatar {
|
||||||
|
width: 65px;
|
||||||
|
height: 65px;
|
||||||
|
display: inline-block;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: 50%;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header .avatar img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
/* This ensures the image fills the circle without stretching */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* File list styles for the View Modal */
|
||||||
|
.file-item {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
padding: 8px;
|
||||||
|
background: #f9f9f9;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 4px;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.file-item a {
|
||||||
|
color: #333;
|
||||||
|
text-decoration: none;
|
||||||
|
font-weight: 500;
|
||||||
|
word-break: break-all;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.file-item a:hover {
|
||||||
|
color: #007bff;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-panel {
|
||||||
|
margin-bottom: 15px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-header {
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
padding: 10px 15px;
|
||||||
|
border-bottom: 1px solid #ddd;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-body {
|
||||||
|
padding: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#modalHistory .modal-body {
|
||||||
|
max-height: calc(100vh - 210px);
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Detail table used in Lihat Penelitian */
|
||||||
|
.detail-table td {
|
||||||
|
vertical-align: top;
|
||||||
|
padding: 6px 4px;
|
||||||
|
border-top: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-table td:first-child {
|
||||||
|
width: 150px;
|
||||||
|
color: #555;
|
||||||
|
}
|
||||||
|
|
||||||
|
#v_anggota {
|
||||||
|
margin: 0;
|
||||||
|
padding-left: 18px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="main-menu">
|
||||||
|
<header class="header">
|
||||||
|
<a href="mahasiswa_index.html" class="logo">UHM</a>
|
||||||
|
<button type="button" class="button-close fa fa-times js__menu_close"></button>
|
||||||
|
<div class="user">
|
||||||
|
<a href="#" class="avatar"><img src="assets/images/person.png" id="foto_mahasiswa" alt=""><span
|
||||||
|
class="status online"></span></a>
|
||||||
|
<h5 class="name"><a href="#" id="mahasiswaName">Mahasiswa</a></h5>
|
||||||
|
<h5 class="position">Mahasiswa</h5>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<div class="content">
|
||||||
|
<div class="navigation">
|
||||||
|
<h5 class="title">Navigasi</h5>
|
||||||
|
<ul class="menu js__accordion">
|
||||||
|
<li>
|
||||||
|
<a class="waves-effect" href="mahasiswa_index.html"><i
|
||||||
|
class="menu-icon fa fa-home"></i><span>Halaman Utama</span></a>
|
||||||
|
</li>
|
||||||
|
<li class="current"><a class="waves-effect" href="mahasiswa_list_penelitian.html"><i
|
||||||
|
class="menu-icon fa fa-list"></i><span>List Penelitian</span></a></li>
|
||||||
|
|
||||||
|
<li><a class="waves-effect" href="mahasiswa_profile.html"><i
|
||||||
|
class="menu-icon fa fa-user"></i><span>Profil</span></a></li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<a class="waves-effect" href="#" onclick="logout()"><i
|
||||||
|
class="menu-icon fa fa-sign-out"></i><span>Logout</span></a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="fixed-navbar">
|
||||||
|
<div class="pull-left">
|
||||||
|
<button type="button"
|
||||||
|
class="menu-mobile-button glyphicon glyphicon-menu-hamburger js__menu_mobile"></button>
|
||||||
|
<h1 class="page-title">Daftar Semua Penelitian</h1>
|
||||||
|
</div>
|
||||||
|
<div class="pull-right">
|
||||||
|
<div class="ico-item fa fa-arrows-alt js__full_screen"></div>
|
||||||
|
<a href="#" class="ico-item fa fa-sign-out" onclick="logout()"></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="wrapper">
|
||||||
|
<div class="main-content">
|
||||||
|
<div class="row small-spacing">
|
||||||
|
<div class="col-lg-3 col-md-6 col-xs-12">
|
||||||
|
<div class="box-content">
|
||||||
|
<div class="statistics-box with-icon">
|
||||||
|
<i class="ico fa fa-wpforms text-inverse"></i>
|
||||||
|
<h2 class="counter text-inverse" id="h_jumlah_penelitian">...</h2>
|
||||||
|
<p class="text">Jumlah Penelitian</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-3 col-md-6 col-xs-12">
|
||||||
|
<div class="box-content">
|
||||||
|
<div class="statistics-box with-icon">
|
||||||
|
<i class="ico fa fa-check text-success"></i>
|
||||||
|
<h2 class="counter text-success" id="h_penelitian_selesai">...</h2>
|
||||||
|
<p class="text">Penelitian Selesai</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-3 col-md-6 col-xs-12">
|
||||||
|
<div class="box-content">
|
||||||
|
<div class="statistics-box with-icon">
|
||||||
|
<i class="ico fa fa-users text-info"></i>
|
||||||
|
<h2 class="counter text-info" id="h_jumlah_dosen">...</h2>
|
||||||
|
<p class="text">Jumlah Dosen</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-3 col-md-6 col-xs-12">
|
||||||
|
<div class="box-content">
|
||||||
|
<div class="statistics-box with-icon">
|
||||||
|
<i class="ico fa fa-history text-primary"></i>
|
||||||
|
<h2 class="counter text-primary" id="h_update" style="font-size: 20px;">...</h2>
|
||||||
|
<p class="text">Update Terakhir</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row small-spacing">
|
||||||
|
<div class="col-lg-7 col-xs-12">
|
||||||
|
<div class="box-content card">
|
||||||
|
<h4 class="box-title">Statistik Penelitian</h4>
|
||||||
|
<div class="card-content">
|
||||||
|
<canvas id="penelitianChart" style="width: 100%; height: 400px;"></canvas>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-5 col-xs-12">
|
||||||
|
<div class="box-content card">
|
||||||
|
<h4 class="box-title">Penelitian Update Terakhir</h4>
|
||||||
|
<div class="card-content" id="lastUpdateContainer">
|
||||||
|
<p class="text-center text-muted">Memuat data...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- TABLE SECTION -->
|
||||||
|
<div class="row small-spacing">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="box-content">
|
||||||
|
<header class="panel-heading"
|
||||||
|
style="display: flex; flex-direction: column; gap: 15px; overflow: hidden;">
|
||||||
|
<div style="display: flex; justify-content: space-between; align-items: center;">
|
||||||
|
<h4 class="box-title" style="margin: 0;">Daftar Seluruh Penelitian</h4>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<label>Judul Penelitian</label>
|
||||||
|
<input type="text" id="searchJudul" class="form-control"
|
||||||
|
placeholder="Cari judul...">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3">
|
||||||
|
<label>Tahun Dari</label>
|
||||||
|
<select id="searchTahunFrom" class="form-control">
|
||||||
|
<option value="">-- Pilih --</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3">
|
||||||
|
<label>Tahun Sampai</label>
|
||||||
|
<select id="searchTahunTo" class="form-control">
|
||||||
|
<option value="">-- Pilih --</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-2"
|
||||||
|
style="display: flex; align-items: flex-end; gap: 5px; margin-top: 24px;">
|
||||||
|
<button class="btn btn-info" onclick="applyCustomFilter()" style="flex: 1;"><i
|
||||||
|
class="fa fa-search"></i> Cari</button>
|
||||||
|
<button class="btn btn-default" onclick="resetCustomFilter()"><i
|
||||||
|
class="fa fa-refresh"></i></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="panel-body" style="overflow-x: auto;">
|
||||||
|
<table id="tablePenelitian" class="table table-striped table-bordered dt-responsive nowrap"
|
||||||
|
style="width:100%">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>No</th>
|
||||||
|
<th>Nama Dosen</th>
|
||||||
|
<th>Judul Penelitian</th>
|
||||||
|
<th>Tahun</th>
|
||||||
|
<th>Status</th>
|
||||||
|
<th>Terakhir Update</th>
|
||||||
|
<th>Aksi</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="tbodyPenelitian"></tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer class="footer">
|
||||||
|
<ul class="list-inline">
|
||||||
|
<li>2026 © Sistem Penelitian Dosen | Universitas Handayani Makassar.</li>
|
||||||
|
</ul>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modal Lihat Penelitian (Read-Only, Text Only) -->
|
||||||
|
<div class="modal fade" id="modalPenelitian" tabindex="-1" role="dialog" aria-labelledby="modalLabel">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
|
||||||
|
aria-hidden="true">×</span></button>
|
||||||
|
<h4 class="modal-title" id="modalLabel">Lihat Penelitian</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<table class="table table-condensed detail-table" style="margin-bottom: 0;">
|
||||||
|
<tr>
|
||||||
|
<td><strong>Nama Dosen</strong></td>
|
||||||
|
<td>: <span id="v_dosen_name"></span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Judul Penelitian</strong></td>
|
||||||
|
<td>: <span id="v_judul"></span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Tahun</strong></td>
|
||||||
|
<td>: <span id="v_tahun"></span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Status</strong></td>
|
||||||
|
<td>: <span id="v_status"></span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Anggota</strong></td>
|
||||||
|
<td>
|
||||||
|
<ul id="v_anggota"></ul>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Keterangan</strong></td>
|
||||||
|
<td>: <span id="v_keterangan"></span></td>
|
||||||
|
</tr>
|
||||||
|
<tr id="v_files_row">
|
||||||
|
<td><strong>File Publikasi</strong></td>
|
||||||
|
<td>
|
||||||
|
<div id="v_files"></div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Dibuat</strong></td>
|
||||||
|
<td>: <span id="v_created"></span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Terakhir Diubah</strong></td>
|
||||||
|
<td>: <span id="v_updated"></span></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-info pull-left" id="btnHistory"
|
||||||
|
onclick="viewHistoryFromView()"><i class="fa fa-history"></i> Riwayat Laporan</button>
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Tutup</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modal History / Laporan -->
|
||||||
|
<div class="modal fade" id="modalHistory" tabindex="-1" role="dialog">
|
||||||
|
<div class="modal-dialog modal-lg" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal"><span>×</span></button>
|
||||||
|
<h4 class="modal-title">Riwayat Perubahan Penelitian</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div id="historyContainer"></div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-primary pull-left" onclick="printLaporan()"><i
|
||||||
|
class="fa fa-print"></i> Cetak Laporan PDF</button>
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Tutup</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Scripts -->
|
||||||
|
<script src="assets/scripts/jquery.min.js"></script>
|
||||||
|
<script src="assets/scripts/modernizr.min.js"></script>
|
||||||
|
<script src="assets/plugin/bootstrap/js/bootstrap.min.js"></script>
|
||||||
|
<script src="assets/plugin/mCustomScrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
|
||||||
|
<script src="assets/plugin/nprogress/nprogress.js"></script>
|
||||||
|
<script src="assets/plugin/sweet-alert/sweetalert.min.js"></script>
|
||||||
|
<script src="assets/plugin/waves/waves.min.js"></script>
|
||||||
|
<script src="assets/plugin/fullscreen/jquery.fullscreen-min.js"></script>
|
||||||
|
|
||||||
|
<script src="assets/plugin/datatables/media/js/jquery.dataTables.min.js"></script>
|
||||||
|
<script src="assets/plugin/datatables/media/js/dataTables.bootstrap.min.js"></script>
|
||||||
|
<script src="assets/plugin/datatables/extensions/Responsive/js/dataTables.responsive.min.js"></script>
|
||||||
|
<script src="assets/plugin/datatables/extensions/Responsive/js/responsive.bootstrap.min.js"></script>
|
||||||
|
|
||||||
|
<script src="assets/plugin/chart/chartjs/Chart.bundle.min.js"></script>
|
||||||
|
|
||||||
|
<script src="assets/scripts/main.min.js"></script>
|
||||||
|
<script src="assets/color-switcher/color-switcher.min.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready(function () {
|
||||||
|
const mahasiswaName = localStorage.getItem('nama_mahasiswa');
|
||||||
|
const mahasiswaId = localStorage.getItem('id_mahasiswa');
|
||||||
|
|
||||||
|
if (mahasiswaName) document.getElementById('mahasiswaName').textContent = mahasiswaName;
|
||||||
|
|
||||||
|
// Fetch current profile image using the FAST single-record API
|
||||||
|
if (mahasiswaId) {
|
||||||
|
$.get(`/api/mahasiswa/cek/${mahasiswaId}`, function (mahasiswa) {
|
||||||
|
if (mahasiswa && mahasiswa.mahasiswa_image) {
|
||||||
|
const imgUrl = `/api/images/mahasiswa/${mahasiswa.mahasiswa_image}?t=${new Date().getTime()}`;
|
||||||
|
$('#profileImagePreview').attr('src', imgUrl);
|
||||||
|
$('#foto_mahasiswa').attr('src', imgUrl);
|
||||||
|
}
|
||||||
|
}).fail(function (xhr) {
|
||||||
|
console.error("Gagal memuat data mahasiswa:", xhr.responseJSON?.error);
|
||||||
|
// Optional: If the ID is invalid, log them out
|
||||||
|
if (xhr.status === 404) {
|
||||||
|
swal("Sesi Berakhir", "Data mahasiswa tidak ditemukan. Silakan login kembali.", "warning");
|
||||||
|
setTimeout(() => {
|
||||||
|
localStorage.clear();
|
||||||
|
window.location.href = 'index.html';
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
let dataTable;
|
||||||
|
let currentViewId = null;
|
||||||
|
|
||||||
|
// --- HELPERS ---
|
||||||
|
function escapeHtml(value) {
|
||||||
|
return String(value ?? '').replace(/[&<>"']/g, char => ({
|
||||||
|
'&': '&', '<': '<', '>': '>', '"': '"', "'": '''
|
||||||
|
})[char]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseAnggota(value) {
|
||||||
|
if (Array.isArray(value)) return value;
|
||||||
|
if (typeof value === 'string' && value.trim()) {
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(value);
|
||||||
|
return Array.isArray(parsed) ? parsed : [];
|
||||||
|
} catch (error) { return []; }
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- DATE FORMATTER (ISO String to "DD Mon YYYY, HH.mm") ---
|
||||||
|
function formatDateOnly(dateString) {
|
||||||
|
if (!dateString) return '-';
|
||||||
|
if (!dateString.includes('T')) {
|
||||||
|
let cleanStr = dateString.replace('T', ' ');
|
||||||
|
return cleanStr.substring(0, 16).replace(/-/g, ' ').replace(':', '.');
|
||||||
|
}
|
||||||
|
const date = new Date(dateString);
|
||||||
|
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun', 'Jul', 'Agu', 'Sep', 'Okt', 'Nov', 'Des'];
|
||||||
|
const day = String(date.getUTCDate()).padStart(2, '0');
|
||||||
|
const month = months[date.getUTCMonth()];
|
||||||
|
const year = date.getUTCFullYear();
|
||||||
|
const hours = String(date.getUTCHours()).padStart(2, '0');
|
||||||
|
const minutes = String(date.getUTCMinutes()).padStart(2, '0');
|
||||||
|
return `${day} ${month} ${year}, ${hours}.${minutes}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Custom Search Logic
|
||||||
|
$.fn.dataTable.ext.search.push(
|
||||||
|
function (settings, data, dataIndex) {
|
||||||
|
const judul = data[2].toLowerCase(); // Index 2 is Judul now
|
||||||
|
const tahun = parseInt(data[3]); // Index 3 is Tahun now
|
||||||
|
|
||||||
|
const searchJudul = $('#searchJudul').val().toLowerCase();
|
||||||
|
const searchFrom = $('#searchTahunFrom').val();
|
||||||
|
const searchTo = $('#searchTahunTo').val();
|
||||||
|
|
||||||
|
if (searchJudul && !judul.includes(searchJudul)) return false;
|
||||||
|
if (searchFrom && tahun < parseInt(searchFrom)) return false;
|
||||||
|
if (searchTo && tahun > parseInt(searchTo)) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
function applyCustomFilter() { dataTable.draw(); }
|
||||||
|
function resetCustomFilter() {
|
||||||
|
$('#searchJudul').val('');
|
||||||
|
$('#searchTahunFrom').val('');
|
||||||
|
$('#searchTahunTo').val('');
|
||||||
|
dataTable.draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
function logout() {
|
||||||
|
swal({
|
||||||
|
title: "Logout?",
|
||||||
|
text: "Anda akan keluar dari halaman admin.",
|
||||||
|
type: "warning",
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonColor: "#DD6B55",
|
||||||
|
confirmButtonText: "Ya, Logout!",
|
||||||
|
closeOnConfirm: true
|
||||||
|
}, function () {
|
||||||
|
localStorage.removeItem('admin_auth');
|
||||||
|
window.location.href = 'index.html';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- CHART RENDERING ---
|
||||||
|
function renderChart() {
|
||||||
|
$.get('/api/laporan/stats/daily', function (data) {
|
||||||
|
const labels = [];
|
||||||
|
const counts = [];
|
||||||
|
|
||||||
|
data.forEach(item => {
|
||||||
|
const dateObj = new Date(item.date);
|
||||||
|
const formattedDate = dateObj.toLocaleDateString('id-ID', { day: '2-digit', month: 'short' });
|
||||||
|
labels.push(formattedDate);
|
||||||
|
counts.push(item.total);
|
||||||
|
});
|
||||||
|
|
||||||
|
const ctx = document.getElementById('penelitianChart').getContext('2d');
|
||||||
|
new Chart(ctx, {
|
||||||
|
type: 'line',
|
||||||
|
data: {
|
||||||
|
labels: labels,
|
||||||
|
datasets: [{
|
||||||
|
label: 'Jumlah Submit/Update Penelitian',
|
||||||
|
data: counts,
|
||||||
|
backgroundColor: 'rgba(54, 162, 235, 0.2)',
|
||||||
|
borderColor: 'rgba(54, 162, 235, 1)',
|
||||||
|
borderWidth: 2,
|
||||||
|
pointBackgroundColor: 'rgba(54, 162, 235, 1)',
|
||||||
|
pointRadius: 4,
|
||||||
|
fill: true,
|
||||||
|
tension: 0.3
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
responsive: true,
|
||||||
|
maintainAspectRatio: false,
|
||||||
|
scales: { y: { beginAtZero: true, ticks: { stepSize: 1 } } },
|
||||||
|
plugins: { legend: { display: true, position: 'top' } }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
document.body.style.display = 'block';
|
||||||
|
|
||||||
|
// 1. Populate "Tahun Dari" and "Tahun Sampai"
|
||||||
|
const fromSelect = document.getElementById('searchTahunFrom');
|
||||||
|
const toSelect = document.getElementById('searchTahunTo');
|
||||||
|
for (let y = 2010; y <= 2026; y++) {
|
||||||
|
fromSelect.appendChild(new Option(y, y));
|
||||||
|
}
|
||||||
|
toSelect.disabled = true;
|
||||||
|
toSelect.innerHTML = '<option value="">-- Pilih Tahun Dari --</option>';
|
||||||
|
|
||||||
|
$('#searchTahunFrom').on('change', function () {
|
||||||
|
const selectedFrom = $(this).val();
|
||||||
|
toSelect.innerHTML = '';
|
||||||
|
if (selectedFrom) {
|
||||||
|
toSelect.disabled = false;
|
||||||
|
toSelect.innerHTML = '<option value="">-- Pilih --</option>';
|
||||||
|
for (let y = parseInt(selectedFrom); y <= 2026; y++) {
|
||||||
|
toSelect.appendChild(new Option(y, y));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
toSelect.disabled = true;
|
||||||
|
toSelect.innerHTML = '<option value="">-- Pilih Tahun Dari Dulu --</option>';
|
||||||
|
}
|
||||||
|
applyCustomFilter();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 2. Render Chart & Fetch Last Update
|
||||||
|
renderChart();
|
||||||
|
$.get('/api/penelitian', function (data) {
|
||||||
|
let total = data.length;
|
||||||
|
let selesai = 0;
|
||||||
|
let latestUpdateItem = null;
|
||||||
|
data.forEach(item => {
|
||||||
|
if (item.status_penelitian === 'Selesai') selesai++;
|
||||||
|
if (item.updated_at) {
|
||||||
|
const itemDate = new Date(item.updated_at);
|
||||||
|
if (!latestUpdateItem || itemDate > new Date(latestUpdateItem.updated_at)) {
|
||||||
|
latestUpdateItem = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('#h_jumlah_penelitian').text(total);
|
||||||
|
$('#h_penelitian_selesai').text(selesai);
|
||||||
|
$('#h_update').text(latestUpdateItem ? formatDateOnly(latestUpdateItem.updated_at) : '-');
|
||||||
|
|
||||||
|
const container = $('#lastUpdateContainer');
|
||||||
|
container.empty();
|
||||||
|
if (latestUpdateItem) {
|
||||||
|
let badge = latestUpdateItem.status_penelitian === 'Berjalan' ? 'label-warning' : 'label-success';
|
||||||
|
container.append(`
|
||||||
|
<div style="margin-bottom: 15px;">
|
||||||
|
<h5 style="margin-top: 0; font-weight: bold; color: #333;">${escapeHtml(latestUpdateItem.judul_penelitian)}</h5>
|
||||||
|
<p class="text-muted" style="margin-bottom: 5px; font-size: 13px;">
|
||||||
|
<i class="fa fa-user"></i> ${escapeHtml(latestUpdateItem.dosen_name)} <br>
|
||||||
|
<i class="fa fa-users"></i> ${escapeHtml(latestUpdateItem.anggota ? JSON.parse(latestUpdateItem.anggota).join(', ') : '-')} <br>
|
||||||
|
<i class="fa fa-calendar"></i> ${formatDateOnly(latestUpdateItem.updated_at)}
|
||||||
|
</p>
|
||||||
|
<span class="label ${badge}" style="font-size: 12px;">${escapeHtml(latestUpdateItem.status_penelitian)}</span>
|
||||||
|
</div>
|
||||||
|
`);
|
||||||
|
} else {
|
||||||
|
container.append('<p class="text-center text-muted">Belum ada penelitian.</p>');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 3. Fetch Mahasiswa & Dosen Count
|
||||||
|
$.get('/api/mahasiswa', function (data) { $('#h_jumlah_mahasiswa').text(data.length); });
|
||||||
|
$.get('/api/dosen', function (data) { $('#h_jumlah_dosen').text(data.length); });
|
||||||
|
|
||||||
|
// 4. Initialize DataTable
|
||||||
|
dataTable = $('#tablePenelitian').DataTable({
|
||||||
|
ajax: { url: `/api/penelitian`, dataSrc: '' },
|
||||||
|
columns: [
|
||||||
|
{ data: null, render: (data, type, row, meta) => meta.row + 1 },
|
||||||
|
{ data: 'dosen_name' },
|
||||||
|
{ data: 'judul_penelitian' },
|
||||||
|
{ data: 'tahun_penelitian' },
|
||||||
|
{
|
||||||
|
data: 'status_penelitian',
|
||||||
|
render: function (data) {
|
||||||
|
let badge = data === 'Berjalan' ? 'label-warning' : 'label-success';
|
||||||
|
return `<span class="label ${badge}">${data}</span>`;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: 'updated_at',
|
||||||
|
render: function (data) { return formatDateOnly(data); }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: null,
|
||||||
|
render: function (data, type, row) {
|
||||||
|
// Only show the View (Eye) button
|
||||||
|
return `<button class="btn btn-info btn-xs" title="Lihat" onclick="viewPenelitian(${row.id})"><i class="fa fa-eye"></i> Lihat</button>`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
order: [[5, "desc"]]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// --- MODAL FUNCTIONS ---
|
||||||
|
|
||||||
|
function viewPenelitian(id) {
|
||||||
|
currentViewId = id;
|
||||||
|
|
||||||
|
$.get(`/api/penelitian`, function (allData) {
|
||||||
|
const item = allData.find(p => p.id === id);
|
||||||
|
if (!item) return;
|
||||||
|
|
||||||
|
// Basic fields
|
||||||
|
$('#v_dosen_name').text(item.dosen_name || '-');
|
||||||
|
$('#v_judul').text(item.judul_penelitian || '-');
|
||||||
|
$('#v_tahun').text(item.tahun_penelitian || '-');
|
||||||
|
|
||||||
|
// Status badge
|
||||||
|
const badge = item.status_penelitian === 'Berjalan' ? 'label-warning' : 'label-success';
|
||||||
|
$('#v_status').html(`<span class="label ${badge}">${escapeHtml(item.status_penelitian)}</span>`);
|
||||||
|
|
||||||
|
// Anggota list
|
||||||
|
const anggota = parseAnggota(item.anggota);
|
||||||
|
const $anggota = $('#v_anggota').empty();
|
||||||
|
if (anggota.length) {
|
||||||
|
anggota.forEach(nama => $anggota.append(`<li>${escapeHtml(nama)}</li>`));
|
||||||
|
} else {
|
||||||
|
$anggota.append('<li class="text-muted">-</li>');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Keterangan
|
||||||
|
$('#v_keterangan').text(item.keterangan || '-');
|
||||||
|
|
||||||
|
// Files
|
||||||
|
const $files = $('#v_files').empty();
|
||||||
|
let filesArr = [];
|
||||||
|
try {
|
||||||
|
filesArr = typeof item.hasil_publikasi === 'string'
|
||||||
|
? JSON.parse(item.hasil_publikasi)
|
||||||
|
: (item.hasil_publikasi || []);
|
||||||
|
} catch (e) { filesArr = []; }
|
||||||
|
|
||||||
|
if (filesArr.length) {
|
||||||
|
$('#v_files_row').show();
|
||||||
|
filesArr.forEach(f => {
|
||||||
|
const displayName = f.substring(f.indexOf('-') + 1);
|
||||||
|
$files.append(`
|
||||||
|
<div class="file-item">
|
||||||
|
<a href="/api/uploads/${f}" target="_blank">
|
||||||
|
<i class="fa fa-file-pdf-o text-danger"></i> ${displayName}
|
||||||
|
</a>
|
||||||
|
</div>`);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$('#v_files_row').show();
|
||||||
|
$files.append('<span class="text-muted">-</span>');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Timestamps
|
||||||
|
$('#v_created').text(formatDateOnly(item.created_at));
|
||||||
|
$('#v_updated').text(formatDateOnly(item.updated_at));
|
||||||
|
|
||||||
|
$('#modalPenelitian').modal('show');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function viewHistoryFromView() {
|
||||||
|
$('#modalPenelitian').modal('hide');
|
||||||
|
setTimeout(() => viewHistory(), 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
function viewHistory() {
|
||||||
|
if (!currentViewId) return;
|
||||||
|
$('#historyContainer').empty();
|
||||||
|
$('#modalHistory').modal('show');
|
||||||
|
|
||||||
|
$.get(`/api/laporan/${currentViewId}`, function (data) {
|
||||||
|
if (data.length === 0) {
|
||||||
|
$('#historyContainer').html('<p class="text-center text-muted">Belum ada riwayat.</p>');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
data.forEach((log, index) => {
|
||||||
|
// Anggota per-version
|
||||||
|
const anggotaList = parseAnggota(log.anggota);
|
||||||
|
const anggotaHtml = anggotaList.length
|
||||||
|
? anggotaList.map(nama => `<li>${escapeHtml(nama)}</li>`).join('')
|
||||||
|
: '<span class="text-muted">-</span>';
|
||||||
|
|
||||||
|
let filesHtml = '';
|
||||||
|
if (log.hasil_publikasi) {
|
||||||
|
try {
|
||||||
|
const files = typeof log.hasil_publikasi === 'string' ? JSON.parse(log.hasil_publikasi) : log.hasil_publikasi;
|
||||||
|
files.forEach(f => {
|
||||||
|
let displayName = f.substring(f.indexOf('-') + 1);
|
||||||
|
filesHtml += `<div class="file-item" style="margin-top:5px;">
|
||||||
|
<a href="/api/uploads/${f}" target="_blank"><i class="fa fa-file-pdf-o text-danger"></i> ${displayName}</a>
|
||||||
|
</div>`;
|
||||||
|
});
|
||||||
|
} catch (e) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#historyContainer').append(`
|
||||||
|
<div class="history-panel">
|
||||||
|
<div class="history-header">
|
||||||
|
Update #${data.length - index}
|
||||||
|
<span class="pull-right text-muted" style="font-size: 12px; font-weight: normal;">
|
||||||
|
${formatDateOnly(log.created_at)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="history-body">
|
||||||
|
<table class="table table-condensed" style="margin-bottom: 0;">
|
||||||
|
<tr><td width="120"><strong>Status</strong></td><td>: <span class="label ${log.status_penelitian === 'Berjalan' ? 'label-warning' : 'label-success'}">${escapeHtml(log.status_penelitian)}</span></td></tr>
|
||||||
|
<tr><td><strong>Anggota</strong></td><td><ul style="margin:0; padding-left:20px;">${anggotaHtml}</ul></td></tr>
|
||||||
|
<tr><td><strong>Keterangan</strong></td><td>: ${escapeHtml(log.keterangan || '-')}</td></tr>
|
||||||
|
<tr><td><strong>File</strong></td><td>${filesHtml || '-'}</td></tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function printLaporan() {
|
||||||
|
if (currentViewId) {
|
||||||
|
window.open(`laporan.html?id=${currentViewId}`, '_blank');
|
||||||
|
} else {
|
||||||
|
swal("Gagal", "ID Penelitian tidak ditemukan.", "error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,359 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||||
|
<title>Aplikasi Penelitian Dosen - Profil Mahasiswa</title>
|
||||||
|
|
||||||
|
<link rel="icon" href="assets/images/icon.png" type="image/x-icon">
|
||||||
|
|
||||||
|
<script>
|
||||||
|
(async function checkAuth() {
|
||||||
|
const mahasiswaId = localStorage.getItem('id_mahasiswa');
|
||||||
|
const mahasiswaName = localStorage.getItem('nama_mahasiswa');
|
||||||
|
|
||||||
|
if (!mahasiswaId || !mahasiswaName) {
|
||||||
|
localStorage.clear();
|
||||||
|
window.location.href = 'index.html';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch(`/api/mahasiswa/verify?id_mahasiswa=${encodeURIComponent(mahasiswaId)}&nama_mahasiswa=${encodeURIComponent(mahasiswaName)}`);
|
||||||
|
const data = await response.json();
|
||||||
|
console.log("Auth check response:", data);
|
||||||
|
|
||||||
|
if (response.ok && data.valid) {
|
||||||
|
document.body.style.display = 'block';
|
||||||
|
} else {
|
||||||
|
localStorage.clear();
|
||||||
|
window.location.href = 'index.html';
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Auth check failed:", error);
|
||||||
|
localStorage.clear();
|
||||||
|
window.location.href = 'index.html';
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="assets/styles/style.min.css">
|
||||||
|
<link rel="stylesheet" href="assets/plugin/mCustomScrollbar/jquery.mCustomScrollbar.min.css">
|
||||||
|
<link rel="stylesheet" href="assets/plugin/waves/waves.min.css">
|
||||||
|
<link rel="stylesheet" href="assets/plugin/sweet-alert/sweetalert.css">
|
||||||
|
<link rel="stylesheet" href="assets/color-switcher/color-switcher.min.css">
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Image Preview Style */
|
||||||
|
.profile-img-container {
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile-img-preview {
|
||||||
|
width: 150px;
|
||||||
|
height: 150px;
|
||||||
|
object-fit: cover;
|
||||||
|
border-radius: 50%;
|
||||||
|
border: 4px solid #fff;
|
||||||
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fix for the top-left profile image to be a perfect circle */
|
||||||
|
.header .avatar {
|
||||||
|
width: 65px;
|
||||||
|
height: 65px;
|
||||||
|
display: inline-block;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: 50%;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header .avatar img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
/* This ensures the image fills the circle without stretching */
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="main-menu">
|
||||||
|
<header class="header">
|
||||||
|
<a href="mahasiswa_index.html" class="logo">UHM</a>
|
||||||
|
<button type="button" class="button-close fa fa-times js__menu_close"></button>
|
||||||
|
<div class="user">
|
||||||
|
<a href="#" class="avatar"><img src="assets/images/person.png" id="foto_mahasiswa" alt=""><span
|
||||||
|
class="status online"></span></a>
|
||||||
|
<h5 class="name"><a href="#" id="mahasiswaName">Mahasiswa</a></h5>
|
||||||
|
<h5 class="position">Mahasiswa</h5>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<div class="content">
|
||||||
|
<div class="navigation">
|
||||||
|
<h5 class="title">Navigasi</h5>
|
||||||
|
<ul class="menu js__accordion">
|
||||||
|
<li>
|
||||||
|
<a class="waves-effect" href="mahasiswa_index.html"><i
|
||||||
|
class="menu-icon fa fa-home"></i><span>Halaman Utama</span></a>
|
||||||
|
</li>
|
||||||
|
<li><a class="waves-effect" href="mahasiswa_list_penelitian.html"><i
|
||||||
|
class="menu-icon fa fa-list"></i><span>List Penelitian</span></a></li>
|
||||||
|
|
||||||
|
<li class="current"><a class="waves-effect" href="mahasiswa_profile.html"><i
|
||||||
|
class="menu-icon fa fa-user"></i><span>Profil</span></a></li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<a class="waves-effect" href="#" onclick="logout()"><i
|
||||||
|
class="menu-icon fa fa-sign-out"></i><span>Logout</span></a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="fixed-navbar">
|
||||||
|
<div class="pull-left">
|
||||||
|
<button type="button"
|
||||||
|
class="menu-mobile-button glyphicon glyphicon-menu-hamburger js__menu_mobile"></button>
|
||||||
|
<h1 class="page-title">Profil Dosen</h1>
|
||||||
|
</div>
|
||||||
|
<div class="pull-right">
|
||||||
|
<div class="ico-item fa fa-arrows-alt js__full_screen"></div>
|
||||||
|
<a href="#" class="ico-item fa fa-sign-out" onclick="logout()"></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="wrapper">
|
||||||
|
<div class="main-content">
|
||||||
|
<div class="row small-spacing">
|
||||||
|
|
||||||
|
<!-- CHANGE PASSWORD -->
|
||||||
|
<div class="col-lg-7 col-xs-12">
|
||||||
|
<div class="box-content card">
|
||||||
|
<h4 class="box-title">Ganti Password</h4>
|
||||||
|
<div class="card-content">
|
||||||
|
<form id="changePasswordForm">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="currentPassword">Password Saat Ini</label>
|
||||||
|
<input type="password" class="form-control" id="currentPassword"
|
||||||
|
placeholder="Masukkan Password Saat Ini" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="newPassword">Password Baru</label>
|
||||||
|
<input type="password" class="form-control" id="newPassword"
|
||||||
|
placeholder="Masukkan Password Baru" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="confirmNewPassword">Konfirmasi Password Baru</label>
|
||||||
|
<input type="password" class="form-control" id="confirmNewPassword"
|
||||||
|
placeholder="Konfirmasi Password Baru" required>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary">Ganti Password</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- PROFILE IMAGE -->
|
||||||
|
<div class="col-lg-5 col-xs-12">
|
||||||
|
<div class="box-content card">
|
||||||
|
<h4 class="box-title">Gambar Profil</h4>
|
||||||
|
<div class="card-content">
|
||||||
|
<div class="profile-img-container">
|
||||||
|
<!-- Image Preview -->
|
||||||
|
<img id="profileImagePreview" src="assets/images/person.png" alt="Profile Image"
|
||||||
|
class="profile-img-preview">
|
||||||
|
</div>
|
||||||
|
<form id="uploadImageForm">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="imageInput">Pilih Foto Baru (Max 1 MB, Format: JPG/PNG)</label>
|
||||||
|
<input type="file" class="form-control" id="imageInput" accept="image/*" required>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-success btn-block">Simpan Foto Profil</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer class="footer">
|
||||||
|
<ul class="list-inline">
|
||||||
|
<li>2026 © Sistem Penelitian Dosen | Universitas Handayani Makassar.</li>
|
||||||
|
</ul>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Scripts -->
|
||||||
|
<script src="assets/scripts/jquery.min.js"></script>
|
||||||
|
<script src="assets/scripts/modernizr.min.js"></script>
|
||||||
|
<script src="assets/plugin/bootstrap/js/bootstrap.min.js"></script>
|
||||||
|
<script src="assets/plugin/mCustomScrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
|
||||||
|
<script src="assets/plugin/nprogress/nprogress.js"></script>
|
||||||
|
<script src="assets/plugin/sweet-alert/sweetalert.min.js"></script>
|
||||||
|
<script src="assets/plugin/waves/waves.min.js"></script>
|
||||||
|
<script src="assets/plugin/fullscreen/jquery.fullscreen-min.js"></script>
|
||||||
|
<script src="assets/block/jquery.blockUI.js"></script>
|
||||||
|
<script src="assets/scripts/main.min.js"></script>
|
||||||
|
<script src="assets/color-switcher/color-switcher.min.js"></script>
|
||||||
|
<script src="assets/block.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready(function () {
|
||||||
|
const mahasiswaName = localStorage.getItem('nama_mahasiswa');
|
||||||
|
const mahasiswaId = localStorage.getItem('id_mahasiswa');
|
||||||
|
|
||||||
|
if (mahasiswaName) document.getElementById('mahasiswaName').textContent = mahasiswaName;
|
||||||
|
|
||||||
|
// Fetch current profile image using the FAST single-record API
|
||||||
|
if (mahasiswaId) {
|
||||||
|
$.get(`/api/mahasiswa/cek/${mahasiswaId}`, function (mahasiswa) {
|
||||||
|
if (mahasiswa && mahasiswa.mahasiswa_image) {
|
||||||
|
const imgUrl = `/api/images/mahasiswa/${mahasiswa.mahasiswa_image}?t=${new Date().getTime()}`;
|
||||||
|
$('#profileImagePreview').attr('src', imgUrl);
|
||||||
|
$('#foto_mahasiswa').attr('src', imgUrl);
|
||||||
|
}
|
||||||
|
}).fail(function (xhr) {
|
||||||
|
console.error("Gagal memuat data mahasiswa:", xhr.responseJSON?.error);
|
||||||
|
// Optional: If the ID is invalid, log them out
|
||||||
|
if (xhr.status === 404) {
|
||||||
|
swal("Sesi Berakhir", "Data mahasiswa tidak ditemukan. Silakan login kembali.", "warning");
|
||||||
|
setTimeout(() => {
|
||||||
|
localStorage.clear();
|
||||||
|
window.location.href = 'index.html';
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// ============ CHANGE PASSWORD AJAX ============
|
||||||
|
$('#changePasswordForm').on('submit', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
const currentPass = $('#currentPassword').val();
|
||||||
|
const newPass = $('#newPassword').val();
|
||||||
|
const confirmPass = $('#confirmNewPassword').val();
|
||||||
|
const mahasiswaId = localStorage.getItem('id_mahasiswa'); // FIX: Use mahasiswaId
|
||||||
|
|
||||||
|
if (newPass !== confirmPass) {
|
||||||
|
swal("Gagal", "Password baru dan konfirmasi tidak cocok!", "error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newPass.length < 6) {
|
||||||
|
swal("Peringatan", "Password baru minimal 6 karakter!", "warning");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
blockUI({ message: 'Menyimpan...' });
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: '/api/mahasiswa/change-password',
|
||||||
|
method: 'PUT',
|
||||||
|
contentType: 'application/json',
|
||||||
|
data: JSON.stringify({
|
||||||
|
mahasiswa_id: mahasiswaId,
|
||||||
|
current_password: currentPass,
|
||||||
|
new_password: newPass
|
||||||
|
}),
|
||||||
|
success: function (response) {
|
||||||
|
$.unblockUI();
|
||||||
|
swal("Berhasil!", response.message, "success");
|
||||||
|
$('#changePasswordForm')[0].reset();
|
||||||
|
},
|
||||||
|
error: function (xhr) {
|
||||||
|
$.unblockUI();
|
||||||
|
swal("Gagal", xhr.responseJSON?.error || "Terjadi kesalahan", "error");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// ============ IMAGE PREVIEW & UPLOAD ============
|
||||||
|
$('#imageInput').on('change', function () {
|
||||||
|
const file = this.files[0];
|
||||||
|
if (file) {
|
||||||
|
if (!file.type.startsWith('image/')) {
|
||||||
|
swal("Peringatan", "Hanya file gambar yang diizinkan!", "warning");
|
||||||
|
$(this).val('');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (file.size > 1024 * 1024) {
|
||||||
|
swal("Peringatan", "Ukuran file maksimal 1MB!", "warning");
|
||||||
|
$(this).val('');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.onload = function (e) {
|
||||||
|
$('#profileImagePreview').attr('src', e.target.result);
|
||||||
|
}
|
||||||
|
reader.readAsDataURL(file);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#uploadImageForm').on('submit', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
const fileInput = $('#imageInput')[0];
|
||||||
|
if (!fileInput.files.length) return;
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('mahasiswa_id', localStorage.getItem('id_mahasiswa'));
|
||||||
|
formData.append('image', fileInput.files[0]);
|
||||||
|
|
||||||
|
blockUI({ message: 'Mengunggah...' });
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: '/api/mahasiswa/upload-image',
|
||||||
|
method: 'PUT',
|
||||||
|
data: formData,
|
||||||
|
processData: false,
|
||||||
|
contentType: false,
|
||||||
|
success: function (response) {
|
||||||
|
$.unblockUI();
|
||||||
|
swal("Berhasil!", response.message, "success");
|
||||||
|
|
||||||
|
const newImageUrl = `/api/images/mahasiswa/${response.image}?t=${new Date().getTime()}`;
|
||||||
|
$('#profileImagePreview').attr('src', newImageUrl);
|
||||||
|
$('#foto_mahasiswa').attr('src', newImageUrl);
|
||||||
|
|
||||||
|
$('#uploadImageForm')[0].reset();
|
||||||
|
},
|
||||||
|
error: function (xhr) {
|
||||||
|
$.unblockUI();
|
||||||
|
swal("Gagal", xhr.responseJSON?.error || "Terjadi kesalahan", "error");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function logout() {
|
||||||
|
swal({
|
||||||
|
title: "Logout?",
|
||||||
|
text: "Anda akan keluar dari halaman mahasiswa.",
|
||||||
|
type: "warning",
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonColor: "#DD6B55",
|
||||||
|
confirmButtonText: "Ya, Logout!",
|
||||||
|
closeOnConfirm: true
|
||||||
|
}, function () {
|
||||||
|
localStorage.clear();
|
||||||
|
window.location.href = 'index.html';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
Reference in new issue
Block a user