Commit 542c66ae by ratuaryella

Initial commit

parents
node_modules
config/config.js
\ No newline at end of file
## Configuration
File directory:
```diff
-- api
-- config
-- -- config.js
-- app.js
-- package.json
-- README.md
-- sequelize.js
-- server.js
```
Example configuration. Add file '.js' with name: **config.js** to folder config.
```diff
module.exports = {
}
```
### Get Package
```diff
npm install
```
### Running
```diff
npm run start
```
\ No newline at end of file
const globalVarible = require('../helper/globalVarible');
const RoleServices = require('../services/roles');
const getAllRole = (req, res, next) => {
try {
if (req.userData.role.id == globalVarible.ROLE_ADMIN) {
RoleServices.getAllRole(req)
.then(docs => {
if (docs.data.rows.length > 0) {
const response = {
message: 'Get All Roles',
total: docs.data.count,
nextPage: docs.pagination.nextPage,
prevPage: docs.pagination.prevPage,
results: docs.data.rows.map(doc => {
return {
id: doc.id,
name: doc.name,
description: doc.description
}
}),
request: {
type: 'GET',
url: '/get-roles'
}
}
res.status(200).json(response);
} else {
res.status(404).json({
message: 'No records found'
});
}
}).catch(err => {
console.log(err);
next(err);
});
} else {
return res.status(403).json({
status: 'Forbidden',
message: 'Only admin can access!'
});
}
} catch(err) {
next(err);
}
}
module.exports = {
getAllRole
}
\ No newline at end of file
const moment = require('moment-timezone');
const currentDate = () => {
let date_ob = new Date();
let date = ('0' + date_ob.getDate()).slice(-2);
let month = ('0' + (date_ob.getMonth() + 1)).slice(-2);
let years = date_ob.getFullYear();
let hours = ('0' + date_ob.getHours()).slice(-2);
let minutes = ('0' + date_ob.getMinutes()).slice(-2);
let seconds = ('0' + date_ob.getSeconds()).slice(-2);
let timestampNow = years + '-' + month + '-' + date + ' ' + hours + ':' + minutes + ':' + seconds;
let dateAsiaJakarta = moment().tz('Asia/Jakarta').format();
return {
date: date,
month: month,
years: years,
hours: hours,
minutes: minutes,
seconds: seconds,
timestampNow: timestampNow,
dateAsiaJakarta: dateAsiaJakarta
}
}
module.exports = currentDate;
\ No newline at end of file
module.exports = {
ROLE_ADMIN: 1,
ROLE_USER: 2,
ROLE_UMUM: 3 // untuk user seperti petugas, masyarakat
}
\ No newline at end of file
const paginator = (reqPage, pageSize) => {
const page = !reqPage || reqPage <= 0 ? 0 : reqPage - 1;
const nextPage = page + 2;
const prevPage = page;
const offset = page * pageSize;
const limit = pageSize;
const currentPage = reqPage;
return {
page: page,
nextPage: nextPage,
prevPage: prevPage,
offset: offset,
limit: limit,
currentPage: currentPage
}
}
module.exports = paginator;
\ No newline at end of file
const jwt = require('jsonwebtoken');
const config = require('../../config/config');
const TokenServices = require('../services/token');
const checkAuth = async (req, res, next) => {
try {
const token = req.headers.authorization.split(' ')[1];
const checkToken = await TokenServices.checkToken(token);
if (checkToken.length > 0) {
const decoded = jwt.verify(token, config.JWT_KEY);
req.userData = decoded;
next();
} else {
return res.status(401).json({
message: 'Auth failed'
});
}
} catch(error) {
return res.status(401).json({
message: 'Auth failed'
});
}
}
module.exports = {
checkAuth,
}
\ No newline at end of file
module.exports = (sequelize, type) => {
return sequelize.define('roles', {
id: {
type: type.INTEGER,
primaryKey: true,
autoIncrement: true,
},
description: type.STRING,
name: type.STRING
}, {
timestamps: false,
freezeTableName: true,
});
}
\ No newline at end of file
module.exports = (sequelize, type) => {
return sequelize.define('token', {
id: {
type: type.INTEGER,
primaryKey: true,
autoIncrement: true
},
id_user: {
type: type.INTEGER,
references: {
models: 'users',
key: 'id',
},
},
token: type.STRING,
status_is_valid: type.BOOLEAN,
created_at: {
type: 'TIMESTAMP',
defaultValue: type.NOW,
allowNull: true,
}
}, {
freezeTableName: true,
timestamps: false
});
}
\ No newline at end of file
module.exports = (sequelize, type) => {
return sequelize.define('users', {
id: {
type: type.INTEGER,
primaryKey: true,
autoIncrement: true,
},
id_role: {
type: type.INTEGER,
references: {
models: 'roles',
key: 'id'
},
},
email: {
type: type.STRING,
allowNull: false,
validate: {
isEmail: true,
notNull: true,
notEmpty: {
msg: 'Email cannot be empty!'
},
},
unique: {
args: true,
msg: 'Email address already in use!'
}
},
password: {
type: type.STRING,
is: /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{8,})/,
allowNull: false,
validate: {
notNull: true,
notEmpty: true,
len: {
args: 5,
msg: 'Password must be atleast 5 characters in length'
}
}
},
username: {
type: type.STRING,
allowNull: false,
validate: {
notNull: true,
notEmpty: true,
len: [5, 100]
},
unique: {
args: true,
msg: 'Username already in use!'
}
},
firstname: {
type: type.STRING,
allowNull: false,
validate: {
notNull: true,
notEmpty: {
msg: 'Firstname cannot be empty!'
},
},
},
lastname: {
type: type.STRING,
allowNull: true,
},
mobile_number: type.NUMBER,
status: type.BOOLEAN,
kode_wilayah: type.JSONB,
created_at: {
type: 'TIMESTAMP',
defaultValue: type.NOW,
allowNull: true,
},
deleted_at: {
type: 'TIMESTAMP',
allowNull: true,
},
created_by: type.INTEGER,
deleted_by: type.INTEGER
}, {
freezeTableName: true,
timestamps: false,
indexes: [{
unique: true,
fields: ['email', 'username']
}],
});
}
\ No newline at end of file
const express = require('express');
const router = express.Router();
const { getAllRole } = require('../controllers/roles');
const UserControllers = require('../controllers/users');
const { checkAuth } = require('../middleware/check-auth');
// Authorization
router.post('/login', UserControllers.doLogin);
router.get('/check-token', UserControllers.checkToken);
router.post('/logout', UserControllers.doLogout);
router.get('/get-roles', checkAuth, getAllRole);
router.post('/create-user', checkAuth, UserControllers.createUser);
router.get('/get-all-users', checkAuth, UserControllers.getAllUser);
router.patch('/edit-user', checkAuth, UserControllers.updateUser);
router.get('/detail-user', UserControllers.getDetailUser);
router.patch('/delete-user', checkAuth, UserControllers.deleteUser);
module.exports = router;
\ No newline at end of file
const { Role } = require('../../sequelize');
const paginator = require('../helper/pagination');
const getAllRole = (req) => {
const pagination = paginator(req.query.page, 10); // set 1 page = 10 length data
const limit = pagination.limit;
const offset = pagination.offset;
return Role.findAndCountAll({
limit,
offset,
order: [['id', 'ASC']]
}).then(docs => {
return {
data: docs,
pagination: pagination
}
});
}
module.exports = {
getAllRole
}
\ No newline at end of file
const { Op } = require('sequelize');
const { Token } = require('../../sequelize');
const createUpdate = (id, dataInsert) => {
return Token.findAll({
where: {
[Op.and]: [
{ status_is_valid: true },
{ id_user: id }
],
},
}).then(isExist => {
if (isExist.length > 0) {
Token.update(
{ status_is_valid: false },
{
where: {
[Op.and]: [
{ status_is_valid: true },
{ id_user: id }
],
},
}
);
return 'Success Invalidate Token';
} else {
return Token.create(dataInsert);
}
}).then(nextStep => {
if (nextStep === 'Success Invalidate Token') {
return Token.create(dataInsert);
}
});
}
const changeStatus = async (token) => {
return await Token.update(
{ status_is_valid: false },
{
where: {
token: token
}
}
);
}
const checkToken = (token) => {
return Token.findAll({
where: {
[Op.and]: [
{ status_is_valid: true },
{ token: token }
]
}
}).then(result => {
return result;
});
}
module.exports = {
createUpdate,
changeStatus,
checkToken
}
\ No newline at end of file
const { Op } = require('sequelize');
const { User, Role } = require('../../sequelize');
const paginator = require('../helper/pagination');
// Create User
const createUser = (dataInsert) => {
return User.create(dataInsert);
}
// Check User Registered
const checkUserRegistered = (req) => {
return User.findAll({
where: {
[Op.or]: [
{ email: req.body.email },
{ username: req.body.username }
],
},
order: [['created_at', 'DESC']],
limit: 1,
include: [
{
model: Role,
as: 'role'
}
]
}).then(user => {
return user;
});
}
// Check Username to Login
const checkUsername = (username) => {
return User.findAll({
where: {
username: username
},
order: [['created_at', 'DESC']],
limit: 1,
include: [
{
model: Role,
as: 'role'
}
]
}).then(user => {
return user;
});
}
// Get All User
const getAllUser = (req) => {
const pagination = paginator(req.query.page, 10); // set 1 page = 10 length data
const limit = pagination.limit;
const offset = pagination.offset;
return User.findAndCountAll({
where: { deleted_at: null },
attributes: { exclude: ['password'] },
limit,
offset,
order: [['created_at', 'DESC']],
include: {
model: Role,
as: 'role'
}
}).then(docs => {
return {
data: docs,
pagination: pagination
}
});
}
// Get Detail User
const getDetailUser = (id) => {
return User.findAll({
where: {
id: id,
deleted_at: null
},
attributes: { exclude: ['password'] },
limit: 1,
include: [
{
model: Role,
as: 'role'
}
]
}).then(docs => {
return docs;
});
}
// Delete User
const deleteUser = (id, deleteData) => {
return User.update(deleteData, {
where: { id: id }
});
}
// Update User
const updateUser = (id, updateUser) => {
return User.update(updateUser, {
where: { id: id }
});
}
module.exports = {
createUser,
checkUserRegistered,
checkUsername,
getAllUser,
getDetailUser,
deleteUser,
updateUser
}
\ No newline at end of file
const express = require('express');
const app = express();
const morgan = require('morgan');
const bodyParser = require('body-parser');
const webRoutes = require('./api/router/router');
const cors = require('cors');
app.use(morgan('dev'));
app.use(bodyParser.urlencoded({
extended: false
}));
app.use(bodyParser.json());
app.use(cors());
app.use('/', webRoutes);
app.use((req, res, next) => {
req.header('Access-Control-Allow-Origin', '*');
req.header(
'Access-Control-Allow-Origin',
'Origin, X-Requested-With, Content-Type, Accept, Authorization'
);
if (req.method === 'OPTIONS') {
req.header('Access-Control-Allow-Method', 'PUT, POST, DELETE, PATCH, GET');
return res.status(200).json({});
}
next();
});
app.use((req, res, next) => {
const error = new Error('Not Found');
error.status = 404;
next(error);
});
app.use((error, req, res, next) => {
res.status(error.status || 500);
res.json({
error: {
message: error.message
}
});
});
module.exports = app;
\ No newline at end of file
{
"name": "api_authentication",
"version": "1.0.0",
"description": "API Authentication Lokasi City",
"main": "app.js",
"scripts": {
"start": "nodemon server.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"API",
"Lokasi",
"City"
],
"author": "Intern Del 2021",
"license": "ISC",
"dependencies": {
"bcrypt": "^5.0.1",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"jsonwebtoken": "^8.5.1",
"moment-timezone": "^0.5.33",
"morgan": "^1.10.0",
"pg": "^8.6.0",
"sequelize": "^6.6.2"
},
"devDependencies": {
"nodemon": "^2.0.7"
}
}
const config = require('./config/config');
const Sequelize = require('sequelize');
const UserModel = require('./api/model/users');
const RoleModel = require('./api/model/roles');
const TokenModel = require('./api/model/token');
const sequelize = new Sequelize(config.dbConnectionString, {
logging: false,
});
const User = UserModel(sequelize, Sequelize);
const Role = RoleModel(sequelize, Sequelize);
const Token = TokenModel(sequelize, Sequelize);
User.belongsTo(Role, {
foreignKey: 'id_role'
});
Token.belongsTo(User, {
foreignKey: 'id_user'
});
module.exports = {
User,
Role,
Token
}
\ No newline at end of file
const http = require('http');
const app = require('./app');
const port = 8082;
const server = http.createServer(app);
server.listen(port, () => {
console.log(`Running server on port ${port}...`);
});
\ No newline at end of file
node_modules
config/config.js
\ No newline at end of file
## Configuration
File directory:
```diff
-- api
-- config
-- -- config.js
-- app.js
-- package.json
-- README.md
-- sequelize.js
-- server.js
```
Example configuration. Add file '.js' with name: **config.js** to folder config.
```diff
module.exports = {
}
```
### Get Package
```diff
npm install
```
### Running
```diff
npm run start
```
const fetch = require('node-fetch');
const config = require('../../config/config');
const fetchAuth = (token) => {
let status;
return fetch(`${config.API_URL_AUTH}/check-token`, {
method: 'GET',
headers: {
"Authorization": "Bearer " + token,
"Content-Type": "application/json",
"Accept": "application/json",
"Accept-Charset": "UTF-8"
}
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
});
}
module.exports = {
fetchAuth
}
\ No newline at end of file
const moment = require('moment-timezone');
const currentDate = () => {
let date_ob = new Date();
let date = ('0' + date_ob.getDate()).slice(-2);
let month = ('0' + (date_ob.getMonth() + 1)).slice(-2);
let years = date_ob.getFullYear();
let hours = ('0' + date_ob.getHours()).slice(-2);
let minutes = ('0' + date_ob.getMinutes()).slice(-2);
let seconds = ('0' + date_ob.getSeconds()).slice(-2);
let timestampNow = years + '-' + month + '-' + date + ' ' + hours + ':' + minutes + ':' + seconds;
let dateAsiaJakarta = moment().tz('Asia/Jakarta').format();
return {
date: date,
month: month,
years: years,
hours: hours,
minutes: minutes,
seconds: seconds,
timestampNow: timestampNow,
dateAsiaJakarta: dateAsiaJakarta
}
}
module.exports = currentDate;
\ No newline at end of file
module.exports = {
ROLE_ADMIN: 1,
ROLE_USER: 2,
ROLE_UMUM: 3 // untuk user seperti petugas, masyarakat
}
\ No newline at end of file
const paginator = (reqPage, pageSize) => {
const page = !reqPage || reqPage <= 0 ? 0 : reqPage - 1;
const nextPage = page + 2;
const prevPage = page;
const offset = page * pageSize;
const limit = pageSize;
const currentPage = reqPage;
return {
page: page,
nextPage: nextPage,
prevPage: prevPage,
offset: offset,
limit: limit,
currentPage: currentPage
}
}
module.exports = paginator;
\ No newline at end of file
const jwt = require('jsonwebtoken');
const config = require('../../config/config');
const authFetch = require('../fetch/auth');
const isAuth = (token) => {
return authFetch.fetchAuth(token)
.then(response => {
if (response.status == 200) {
return response.data.data
} else {
return false;
}
}).catch(error => {
console.log(error);
});
}
const checkAuth = async (req, res, next) => {
try {
const token = req.headers.authorization.split(' ')[1];
const validToken = await isAuth(token);
if (validToken == false) {
return res.status(401).json({
message: 'Auth failed'
});
} else {
const decoded = jwt.verify(token, config.JWT_KEY);
req.userData = decoded;
next();
}
} catch (error) {
return res.status(401).json({
message: 'Auth failed'
});
}
}
module.exports = {
checkAuth
}
\ No newline at end of file
module.exports = (sequelize, type) => {
return sequelize.define('kegiatan', {
id: {
type: type.INTEGER,
primaryKey: true,
autoIncrement: true,
},
id_tatanan: {
type: type.INTEGER,
references: {
models: 'tatanan',
key: 'id'
}
},
nama_kegiatan: {
type: type.STRING,
allowNull: false
},
nama_tatanan: {
type: type.STRING,
allowNull: false
},
jenis_indikator: {
type: type.STRING,
allowNull: false
},
kategori: {
type: type.STRING,
},
nama_indikator: {
type: type.STRING,
allowNull: false
},
subindikator: {
type: type.STRING
},
pelaksana: {
type: type.STRING
},
tanggal_kegiatan: {
type: 'TIMESTAMP'
},
longitude: {
type: type.STRING
},
latitude: {
type: type.STRING
},
deskripsi: {
type: type.STRING
},
alamat: {
type: type.STRING
},
gambar: {
type: type.STRING
},
created_at: {
type: 'TIMESTAMP',
// defaultValue: Sequelize.NOW,
allowNull: true,
},
updated_at: {
type: 'TIMESTAMP',
// defaultValue: Sequelize.NOW,
allowNull: true,
},
deleted_at: {
type: 'TIMESTAMP',
// defaultValue: Sequelize.NOW,
allowNull: true,
},
created_by: type.INTEGER,
creator_role: type.INTEGER,
updated_by: type.INTEGER,
deleted_by: type.INTEGER
}, {
freezeTableName: true,
timestamps: false,
});
}
\ No newline at end of file
module.exports = (sequelize, type) => {
return sequelize.define('tatanan', {
id: {
type: type.INTEGER,
primaryKey: true,
autoIncrement: true,
},
nama_tatanan: {
type: type.STRING,
allowNull: false
},
jenis_indikator: {
type: type.STRING,
allowNull: false
},
kategori: {
type: type.STRING,
},
nama_indikator: {
type: type.STRING,
allowNull: false
},
subindikator: {
type: type.STRING
},
created_at: {
type: 'TIMESTAMP',
// defaultValue: Sequelize.NOW,
allowNull: true,
},
updated_at: {
type: 'TIMESTAMP',
// defaultValue: Sequelize.NOW,
allowNull: true,
},
deleted_at: {
type: 'TIMESTAMP',
// defaultValue: Sequelize.NOW,
allowNull: true,
},
created_by: type.INTEGER,
updated_by: type.INTEGER,
deleted_by: type.INTEGER
}, {
freezeTableName: true,
timestamps: false,
});
}
\ No newline at end of file
const express = require('express');
const router = express.Router();
const KegiatanController = require('../controllers/kegiatan');
const TatananController = require('../controllers/tatanan');
const KegiatanService = require('../services/kegiatan');
const { checkAuth } = require('../middleware/check-auth');
router.get('/welcome', checkAuth, (req, res) => {
res.status(200).json({
message: 'Sample endpoint With Check Auth'
})
})
router.post('/create-kegiatan', checkAuth, KegiatanController.uploadImg.single("gambar"), KegiatanController.createKegiatan);
router.post('/create-kegiatan-non', checkAuth, KegiatanController.createKegiatanNon);
router.get('/get-all-kegiatan', KegiatanController.getKegiatan);
router.get('/get-full-kegiatan', KegiatanController.getAllKegiatan);
router.get('/get-role-kegiatan', checkAuth, KegiatanController.getKegiatanByRole);
router.get('/get-user-kegiatan', checkAuth, KegiatanController.getKegiatanByUser);
router.get('/get-kegiatan', KegiatanController.getKegiatanById);
router.get('/kegiatan', KegiatanController.downloadFiles)
router.patch('/delete-kegiatan', checkAuth, KegiatanController.deleteKegiatan);
router.patch('/update-kegiatan', checkAuth, KegiatanController.updateKegiatan);
router.post('/create-tatanan', checkAuth, TatananController.createTatanan);
router.get('/get-all-tatanan', checkAuth, TatananController.getTatanan);
router.get('/get-full-tatanan', checkAuth, TatananController.getAllTatanan);
router.get('/get-tatanan-nama', checkAuth, TatananController.getNamaTatanan);
router.get('/get-tatanan-nama-jenis', checkAuth, TatananController.getNamaJenisTatanan);
router.get('/get-tatanan-nama-jenis-kategori', checkAuth, TatananController.getNamaJenisKategori);
router.get('/get-tatanan-nama-jenis-kategori-indikator', checkAuth, TatananController.getNamaJenisKategoriIndikator);
router.get('/get-tatanan', checkAuth, TatananController.getTatananById);
router.patch('/update-tatanan', checkAuth, TatananController.updateTatanan);
router.patch('/delete-tatanan', checkAuth, TatananController.deleteTatanan);
router.get('/get-id-tatanan', KegiatanService.createKegiatan);
module.exports = router;
\ No newline at end of file
const { Op } = require('sequelize');
const { Kegiatan, Tatanan } = require('../../sequelize');
const { User } = require('../../../api_authentication/sequelize');
const paginator = require('../helper/pagination');
// Get All Kegiatan
const getKegiatan = (req) => {
const pagination = paginator(req.query.page, 5); // set 1 page = 5 length data
const limit = pagination.limit;
const offset = pagination.offset;
return Kegiatan.findAndCountAll({
where: { deleted_at: null },
limit,
offset,
order: [['created_at', 'DESC']]
}).then(docs => {
return {
data: docs,
pagination: pagination
}
});
}
// Get Kegiatan by Id
const getKegiatanById = (id, req, res) => {
return Kegiatan.findAll({
where: {
id: id,
deleted_at: null
},
limit: 1,
})
.then(docs => {
return docs;
});
}
// Create Kegiatan
const createKegiatan = (dataKegiatan) => {
return Tatanan.findOne({
raw: true,
where: {
nama_tatanan: dataKegiatan.nama_tatanan,
jenis_indikator: dataKegiatan.jenis_indikator,
kategori: dataKegiatan.kategori,
nama_indikator: dataKegiatan.nama_indikator,
subindikator: dataKegiatan.subindikator
},
attributes: ['id']
})
.then((data)=> {
dataKegiatan.id_tatanan = Object.values(data);
return Kegiatan.create(dataKegiatan)
.then(docs => {
return {
docs: docs,
}
})
})
.catch(error => {
console.log(error);
})
}
// Update Kegiatan
const updateKegiatan = (id, updateKegiatan) => {
return Kegiatan.update(updateKegiatan, {
where: { id: id }
});
}
// Delete Kegiatan
const deleteKegiatan = (id, deleteKegiatan) => {
return Kegiatan.update(deleteKegiatan, {
where: { id: id }
});
}
// Get All Kegiatan (No Paging)
const getAllKegiatan = (req) => {
return Kegiatan.findAndCountAll({
where: { deleted_at: null },
order: [['created_at', 'DESC']]
}).then(docs => {
return {
data: docs
}
});
}
// Create Kegiatan
const createKegiatanNon = (dataKegiatanNon) => {
return Tatanan.findOne({
raw: true,
where: {
nama_tatanan: dataKegiatanNon.nama_tatanan,
jenis_indikator: dataKegiatanNon.jenis_indikator,
kategori: dataKegiatanNon.kategori,
nama_indikator: dataKegiatanNon.nama_indikator,
subindikator: dataKegiatanNon.subindikator
},
attributes: ['id']
})
.then((data)=> {
dataKegiatanNon.id_tatanan = Object.values(data);
return Kegiatan.create(dataKegiatanNon)
.then(docs => {
return {
docs: docs,
}
})
})
.catch(error => {
console.log(error);
})
}
//Get Kegiatan by Role
const getKegiatanByRole = (role, req) => {
const pagination = paginator(req.query.page, 5); // set 1 page = 5 length data
const limit = pagination.limit;
const offset = pagination.offset;
return Kegiatan.findAndCountAll({
where: {
creator_role: role,
deleted_at: null },
limit,
offset,
order: [['created_at', 'DESC']]
}).then(docs => {
return {
data: docs,
pagination: pagination
}
});
}
const getKegiatanByUser = (user_id, req) => {
const pagination = paginator(req.query.page, 5); // set 1 page = 5 length data
const limit = pagination.limit;
const offset = pagination.offset;
return Kegiatan.findAndCountAll({
where: {
created_by: user_id,
deleted_at: null },
limit,
offset,
order: [['created_at', 'DESC']]
}).then(docs => {
return {
data: docs,
pagination: pagination
}
});
}
module.exports = {
createKegiatan,
getKegiatan,
getKegiatanById,
updateKegiatan,
deleteKegiatan,
getAllKegiatan,
createKegiatanNon,
getKegiatanByRole,
getKegiatanByUser
}
\ No newline at end of file
const { Op } = require('sequelize');
const { Kegiatan, Tatanan } = require('../../sequelize');
const paginator = require('../helper/pagination');
// Get All Tatanan
const getTatanan = (req) => {
const pagination = paginator(req.query.page, 10); // set 1 page = 10 length data
const limit = pagination.limit;
const offset = pagination.offset;
return Tatanan.findAndCountAll({
where: { deleted_at: null },
limit,
offset,
order: [['created_at', 'DESC']]
}).then(docs => {
return {
data: docs,
pagination: pagination
}
});
}
// Get Tatanan by Id
const getTatananById = (id) => {
return Tatanan.findAll({
where: {
id: id,
deleted_at: null
},
limit: 1
}).then(docs => {
return docs;
});
}
// Create Tatanan
const createTatanan = (dataTatanan) => {
return Tatanan.create(dataTatanan)
.then(docs => {
return {
docs: docs,
}
})
.catch(error => {
console.log(error);
})
}
// Update Tatanan
const updateTatanan = (id, updateTatanan) => {
return Tatanan.update(updateTatanan, {
where: { id: id }
});
}
// Delete Tatanan
const deleteTatanan = (id, deleteTatanan) => {
return Tatanan.update(deleteTatanan, {
where: { id: id }
});
}
// Get All Tatanan (No Paging)
const getAllTatanan = (req) => {
return Tatanan.findAndCountAll({
where: { deleted_at: null },
order: [['created_at', 'DESC']]
}).then(docs => {
return {
data: docs
}
});
}
// Get All Tatanan (No Paging)
const getNamaTatanan = (nama_tatanan) => {
return Tatanan.findAndCountAll({
where: { nama_tatanan: nama_tatanan,
deleted_at: null },
order: [['created_at', 'DESC']]
}).then(docs => {
return {
data: docs
}
});
}
// Get All Tatanan (No Paging)
const getNamaJenisTatanan = (nama_tatanan, jenis_indikator) => {
return Tatanan.findAndCountAll({
where: { nama_tatanan: nama_tatanan,
jenis_indikator: jenis_indikator,
deleted_at: null },
order: [['created_at', 'DESC']]
}).then(docs => {
return {
data: docs
}
});
}
// Get All Tatanan (No Paging)
const getNamaJenisKategori = (nama_tatanan, jenis_indikator, kategori) => {
return Tatanan.findAndCountAll({
where: { nama_tatanan: nama_tatanan,
jenis_indikator: jenis_indikator,
kategori: kategori,
deleted_at: null },
order: [['created_at', 'DESC']]
}).then(docs => {
return {
data: docs
}
});
}
// Get All Tatanan (No Paging)
const getNamaJenisKategoriIndikator = (nama_tatanan, jenis_indikator, kategori, nama_indikator) => {
return Tatanan.findAndCountAll({
where: { nama_tatanan: nama_tatanan,
jenis_indikator: jenis_indikator,
kategori: kategori,
nama_indikator: nama_indikator,
deleted_at: null },
order: [['created_at', 'DESC']]
}).then(docs => {
return {
data: docs
}
});
}
module.exports = {
createTatanan,
getTatanan,
getTatananById,
updateTatanan,
deleteTatanan,
getAllTatanan,
getNamaTatanan,
getNamaJenisTatanan,
getNamaJenisKategori,
getNamaJenisKategoriIndikator
}
\ No newline at end of file
const express = require('express');
const app = express();
const morgan = require('morgan');
const bodyParser = require('body-parser');
const webRoutes = require('./api/router/router');
const cors = require('cors');
app.use(morgan('dev'));
app.use(express.json());
app.use(express.urlencoded({
extended: true
}));
app.use(cors());
app.use('/', webRoutes);
app.use((req, res, next) => {
req.header('Access-Control-Allow-Origin', '*');
req.header(
'Access-Control-Allow-Origin',
'Origin, X-Requested-With, Content-Type, Accept, Authorization'
);
if (req.method === 'OPTIONS') {
req.header('Access-Control-Allow-Method', 'PUT, POST, DELETE, PATCH, GET');
return res.status(200).json({});
}
next();
});
app.use((req, res, next) => {
const error = new Error('Not Found');
error.status = 404;
next(error);
});
app.use((error, req, res, next) => {
res.status(error.status || 500);
res.json({
error: {
message: error.message
}
});
});
app.use(express.static('./api_services/api/uploads'));
module.exports = app;
\ No newline at end of file
{
"name": "api_services",
"version": "1.0.0",
"description": "API Kegiatan Tatanan",
"main": "app.js",
"scripts": {
"start": "nodemon server.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"API",
"Lokasi",
"City",
"Kegiatan",
"Tatanan"
],
"author": "Intern Del 2021",
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"jsonwebtoken": "^8.5.1",
"moment-timezone": "^0.5.33",
"morgan": "^1.10.0",
"multer": "^1.4.2",
"node-fetch": "^2.6.1",
"pg": "^8.6.0",
"sequelize": "^6.6.2",
"stream": "0.0.2"
},
"devDependencies": {
"nodemon": "^2.0.7"
}
}
const config = require('./config/config');
const Sequelize = require('sequelize');
const KegiatanModel = require('./api/model/kegiatan');
const TatananModel = require('./api/model/tatanan');
const sequelize = new Sequelize(config.dbConnectionString, {
logging: false,
});
const Kegiatan = KegiatanModel(sequelize, Sequelize);
const Tatanan = TatananModel(sequelize, Sequelize);
Kegiatan.belongsTo(Tatanan, {
foreignKey: 'id_tatanan'
});
module.exports = {
Kegiatan,
Tatanan
}
\ No newline at end of file
const http = require('http');
const app = require('./app');
const port = 8083;
const server = http.createServer(app);
server.listen(port, () => {
console.log(`Running server on port ${port}...`);
});
\ No newline at end of file
node_modules
config.js
\ No newline at end of file
## Configuration
File directory:
```diff
-- controllers
-- fetch
-- middleware
-- public
-- router
-- validator
-- views
-- app.js
-- package.json
-- README.md
-- sequelize.js
```
Example configuration. Add file '.js' with name: **config.js** to root folder.
```diff
module.exports = {
}
```
### Get Package
```diff
npm install
```
### Running
```diff
npm run start
```
\ No newline at end of file
const express = require('express');
const app = express();
const cors = require('cors');
const cookieParser = require('cookie-parser');
const logger = require('morgan');
const bodyParser = require('body-parser');
const path = require('path');
const engine = require('ejs-mate');
const config = require('./config');
const webRoutes = require('./router/router');
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({
extended: true
}));
app.use(cors());
app.use(cookieParser());
// view engine setup
app.engine('ejs', engine);
app.set('views', path.join(__dirname, '/views'));
app.set('view engine', 'ejs');
//Assets Public (css, JS)
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', webRoutes);
app.use(function(req, res, next){
res.status(404);
if (req.accepts('html')) {
res.render('errors/404', { url: req.url });
return;
}
if (req.accepts('json')) {
res.send({ error: 'Not found' });
return;
}
res.type('txt').send('Not found');
});
app.use(function(req, res, next){
res.status(403);
if (req.accepts('html')) {
res.render('errors/403', { url: req.url});
return;
}
if (req.accepts('json')) {
res.send({ error: 'Access Denied' });
return;
}
res.type('txt').send('Access Denied');
});
app.listen(config.port, () => console.log(`App listening on port ${config.port}`));
module.exports = app;
\ No newline at end of file
const index = (req, res, next) => {
let param = {
active: 'home',
role: req.cookies.role,
username: req.cookies.username
}
res.render('./pages/admin/home', param);
}
module.exports = {
index,
}
\ No newline at end of file
const fetchAdministrasi = require('../../fetch/administrasi/administrasi');
// GET ALL ADMINISTRASI
const getAllKecamatan = async (req, res) => {
return await fetchAdministrasi.getAllKecamatan(req)
.then(responseJson => {
res.json(responseJson);
}).catch(error => {
console.log(error);
});
}
const getAllDesa = async (req, res) => {
return await fetchAdministrasi.getAllDesa(req)
.then(responseJson => {
res.json(responseJson);
}).catch(error => {
console.log(error);
});
}
// GET GEOMETRI ADMINISTRASI
const getKecamatanGeometri = async (req, res) => {
return await fetchAdministrasi.getKecamatanGeometri(req)
.then(responseJson => {
res.json(responseJson);
}).catch(error => {
console.log(error);
});
}
const getDesaGeometri = async (req, res) => {
return await fetchAdministrasi.getDesaGeometri(req)
.then(responseJson => {
res.json(responseJson);
}).catch(error => {
console.log(error);
});
}
module.exports = {
getAllKecamatan,
getAllDesa,
getKecamatanGeometri,
getDesaGeometri
}
\ No newline at end of file
const authFetch = require("../../fetch/auth/auth");
const { validationResult } = require("express-validator");
const index = (req, res) => {
res.render("./pages/login/index");
};
const login = (req, res) => {
const valResult = validationResult(req);
var errors = valResult.errors;
if (!valResult.isEmpty()) {
res.render("./pages/login/index", {
errors: errors,
});
} else {
authFetch
.loginFetch(req)
.then((response) => {
if (response.status == 200) {
res.cookie("username", response.data.username, { httpOnly: true });
res.cookie("id", response.data.id, { httpOnly: true });
res.cookie("role", response.data.role.id, { httpOnly: true });
res.cookie("user_token", response.data.token, {
httpOnly: true,
});
res.redirect("/");
} else {
res.render("./pages/login/index", {
auth_failed: "Wrong Credential",
});
}
})
.catch((err) => {
console.log(err);
});
}
};
const logout = (req, res) => {
res.clearCookie("username");
res.clearCookie("user_token");
res.clearCookie("role");
res.redirect("/");
res.clearCookie("id");
res.redirect("/login");
};
module.exports = {
index,
login,
logout,
};
const index = (req, res, next) => {
let param = {
active: 'home',
role: req.cookies.role,
username: req.cookies.username
}
if(req.cookies.role == 1){
res.render('./pages/admin/home', param);
}else if(req.cookies.role == 2){
res.render('./pages/petugas/home_petugas', param);
}else if(req.cookies.role == 3){
res.render('./pages/petugas/home_petugas', param);
}else{
res.render('./pages/guest/home', param);
}
}
module.exports = {
index,
}
\ No newline at end of file
const fetchKegiatan = require('../../fetch/kegiatan/kegiatan');
const getAllKegiatan = (req, res) => {
const statusCode = [200, 201, 400, 401, 403, 404, 500];
return fetchKegiatan.getAllKegiatan(req)
.then(responseJson => {
if(statusCode.includes(responseJson.status)){
res.json(responseJson);
} else {
return false;
}
}).catch(error =>{
console.log(error);
})
}
const getKegiatanById = (req, res) => {
const statusCode = [200, 201, 400, 401, 403, 404, 500];
return fetchKegiatan.getKegiatanById(req)
.then(responseJson => {
if(statusCode.includes(responseJson.status)){
res.json(responseJson);
} else {
return false;
}
}).catch(error =>{
console.log(error);
})
}
const getFullKegiatan = (req, res) => {
const statusCode = [200, 201, 400, 401, 403, 404, 500];
return fetchKegiatan.getFullKegiatan(req)
.then(responseJson => {
if(statusCode.includes(responseJson.status)){
res.json(responseJson);
} else {
return false;
}
}).catch(error =>{
console.log(error);
})
}
const createKegiatan = (req, res) => {
const statusCode = [200, 201, 400, 401, 403, 404, 500];
return fetchKegiatan.createKegiatan(req)
.then(responseJson => {
if(responseJson.status == 201){
} else {
return false;
}
}).catch(error =>{
console.log(error);
})
}
const createKegiatanNon = (req, res) => {
const statusCode = [200, 201, 400, 401, 403, 404, 500];
return fetchKegiatan.createKegiatanNon(req)
.then(responseJson => {
if(responseJson.status == 201){
} else {
return false;
}
}).catch(error =>{
console.log(error);
})
}
const getKegiatanByRole = (req, res) => {
const statusCode = [200, 201, 400, 401, 403, 404, 500];
return fetchKegiatan.getKegiatanByRole(req)
.then(responseJson => {
if(statusCode.includes(responseJson.status)){
res.json(responseJson);
} else {
return false;
}
}).catch(error =>{
console.log(error);
})
}
const deleteKegiatan = (req, res) => {
const statusCode = [200, 201, 400, 401, 403, 404, 500];
return fetchKegiatan.deleteKegiatan(req)
.then(responseJson => {
if(statusCode.includes(responseJson.status)){
res.json(responseJson);
} else {
return false;
}
}).catch(error =>{
console.log(error);
})
}
const editKegiatan = (req, res) => {
const statusCode = [200, 201, 400, 401, 403, 404, 500];
return fetchKegiatan.editKegiatan(req)
.then(responseJson => {
if(statusCode.includes(responseJson.status)){
res.json(responseJson);
} else {
return false;
}
}).catch(error =>{
console.log(error);
})
}
const getKegiatanByUser = (req, res) => {
const statusCode = [200, 201, 400, 401, 403, 404, 500];
return fetchKegiatan.getKegiatanByUser(req)
.then(responseJson => {
if(statusCode.includes(responseJson.status)){
res.json(responseJson);
} else {
return false;
}
}).catch(error =>{
console.log(error);
})
}
module.exports = {
getAllKegiatan,
getKegiatanById,
getFullKegiatan,
createKegiatan,
createKegiatanNon,
getKegiatanByRole,
deleteKegiatan,
editKegiatan,
getKegiatanByUser
}
\ No newline at end of file
const kelolaLokasi = (req, res, next) => {
let param = {
active: 'lokasi',
role: req.cookies.role,
username: req.cookies.username
}
res.render('./pages/maps/kelola-lokasi',param);
}
module.exports = {
kelolaLokasi,
}
\ No newline at end of file
const fetchPoi = require("../../fetch/poi/poi-bvarta");
const getPoiRegion = (req, res) => {
return fetchPoi
.getPoiRegion(req)
.then((responseJson) => {
res.json(responseJson);
})
.catch((error) => {
console.log(error);
});
};
module.exports = {
getPoiRegion,
};
const fetchTatanan = require('../../fetch/tatanan/tatanan')
const index = (req, res) => {
let param = {
active: 'tatanan',
role: req.cookies.role,
username: req.cookies.username
}
res.render('./pages/admin/tatanan', param);
}
const getAllTatanan = (req, res) => {
const statusCode = [200, 201, 400, 401, 403, 404, 500];
return fetchTatanan.getAllTatanan(req)
.then(responseJson => {
if(statusCode.includes(responseJson.status)){
res.json(responseJson);
} else {
return false;
}
}).catch(error =>{
console.log(error);
})
}
const getFullTatanan = (req, res) => {
const statusCode = [200, 201, 400, 401, 403, 404, 500];
return fetchTatanan.getFullTatanan(req)
.then(responseJson => {
if(statusCode.includes(responseJson.status)){
res.json(responseJson);
} else {
return false;
}
}).catch(error =>{
console.log(error);
})
}
const getTatananNama = (req, res) => {
const statusCode = [200, 201, 400, 401, 403, 404, 500];
return fetchTatanan.getTatananNama(req)
.then(responseJson => {
if(statusCode.includes(responseJson.status)){
res.json(responseJson);
} else {
return false;
}
}).catch(error =>{
console.log(error);
})
}
const getNamaJenis = (req, res) => {
const statusCode = [200, 201, 400, 401, 403, 404, 500];
return fetchTatanan.getNamaJenis(req)
.then(responseJson => {
if(statusCode.includes(responseJson.status)){
res.json(responseJson);
} else {
return false;
}
}).catch(error =>{
console.log(error);
})
}
const getNamaJenisKategori = (req, res) => {
const statusCode = [200, 201, 400, 401, 403, 404, 500];
return fetchTatanan.getNamaJenisKategori(req)
.then(responseJson => {
if(statusCode.includes(responseJson.status)){
res.json(responseJson);
} else {
return false;
}
}).catch(error =>{
console.log(error);
})
}
const getNamaJenisKategoriIndikator = (req, res) => {
const statusCode = [200, 201, 400, 401, 403, 404, 500];
return fetchTatanan.getNamaJenisKategoriIndikator(req)
.then(responseJson => {
if(statusCode.includes(responseJson.status)){
res.json(responseJson);
} else {
return false;
}
}).catch(error =>{
console.log(error);
})
}
const createTatanan = (req, res) => {
const statusCode = [200, 201, 400, 401, 403, 404, 500];
return fetchTatanan.createTatanan(req)
.then(responseJson => {
if(responseJson.status == 201){
} else {
return false;
}
}).catch(error =>{
console.log(error);
})
}
const deleteTatanan = (req, res) => {
const statusCode = [200, 201, 400, 401, 403, 404, 500];
return fetchTatanan.deleteTatanan(req)
.then(responseJson => {
if(statusCode.includes(responseJson.status)){
res.json(responseJson);
} else {
return false;
}
}).catch(error =>{
console.log(error);
})
}
const getTatananById = (req, res) => {
const statusCode = [200, 201, 400, 401, 403, 404, 500];
return fetchTatanan.getTatananById(req)
.then(responseJson => {
if(statusCode.includes(responseJson.status)){
res.json(responseJson);
} else {
return false;
}
}).catch(error =>{
console.log(error);
})
}
const editTatanan = (req, res) => {
const statusCode = [200, 201, 400, 401, 403, 404, 500];
return fetchTatanan.editTatanan(req)
.then(responseJson => {
if(statusCode.includes(responseJson.status)){
res.json(responseJson);
} else {
return false;
}
}).catch(error =>{
console.log(error);
})
}
module.exports = {
index,
getAllTatanan,
createTatanan,
deleteTatanan,
getTatananById,
editTatanan,
getFullTatanan,
getTatananNama,
getNamaJenis,
getNamaJenisKategori,
getNamaJenisKategoriIndikator
}
\ No newline at end of file
const fetchUser = require('../../fetch/user/user')
const index = (req, res) => {
let param = {
active: 'home',
role: req.cookies.role,
username: req.cookies.username
}
res.render('./pages/admin/datauser', param);
}
const getAllUsers = (req, res) => {
const statusCode = [200, 201, 400, 401, 403, 404, 500];
return fetchUser.getAllUsers(req)
.then(responseJson => {
if(statusCode.includes(responseJson.status)){
res.json(responseJson);
} else {
return false;
}
}).catch(error =>{
console.log(error);
})
}
const getAllRoles = (req, res) => {
const statusCode = [200, 201, 400, 401, 403, 404, 500];
return fetchUser.getAllRoles(req)
.then(responseJson => {
if(statusCode.includes(responseJson.status)){
res.json(responseJson);
} else {
return false;
}
}).catch(error =>{
console.log(error);
})
}
const createUser = (req, res) => {
const statusCode = [200, 201, 400, 401, 403, 404, 500];
return fetchUser.createUser(req)
.then(responseJson => {
if(responseJson.status == 201){
} else {
return false;
}
}).catch(error =>{
console.log(error);
})
}
const deleteUser = (req, res) => {
const statusCode = [200, 201, 400, 401, 403, 404, 500];
return fetchUser.deleteUser(req)
.then(responseJson => {
if(statusCode.includes(responseJson.status)){
res.json(responseJson);
} else {
return false;
}
}).catch(error =>{
console.log(error);
})
}
const getUserById = (req, res) => {
const statusCode = [200, 201, 400, 401, 403, 404, 500];
return fetchUser.getUserById(req)
.then(responseJson => {
if(statusCode.includes(responseJson.status)){
res.json(responseJson);
} else {
return false;
}
}).catch(error =>{
console.log(error);
})
}
const getUserByIdLogin = (req, res) => {
const statusCode = [200, 201, 400, 401, 403, 404, 500];
return fetchUser.getUserByIdLogin(req)
.then(responseJson => {
if(statusCode.includes(responseJson.status)){
res.json(responseJson);
} else {
return false;
}
}).catch(error =>{
console.log(error);
})
}
const editUser = (req, res) => {
const statusCode = [200, 201, 400, 401, 403, 404, 500];
return fetchUser.editUser(req)
.then(responseJson => {
if(statusCode.includes(responseJson.status)){
res.json(responseJson);
} else {
return false;
}
}).catch(error =>{
console.log(error);
})
}
module.exports = {
index,
getAllUsers,
getAllRoles,
createUser,
deleteUser,
getUserById,
getUserByIdLogin,
editUser
}
\ No newline at end of file
const fetch = require('node-fetch');
const config = require('.././../config');
// GET ALL ADMINITRASI
const getAllKecamatan = (req) => {
let queryParams = new URLSearchParams(req.query).toString();
return fetch(`${config.API_URL_BVT}:4002/api/pu/maps/v1.0/get-kecamatan?${queryParams}`, {
method: 'GET',
headers: {
'Authorization': `Beaerer ${req.query.user_token}`,
'Content-Type': 'application/json',
'Accept': 'application/json',
'Accept-Charset': 'UTF-8'
}
}).then(response => {
return response.json();
}).then(responseJson => {
return responseJson;
});
}
const getAllDesa = (req) => {
let queryParams = new URLSearchParams(req.query).toString();
return fetch(`${config.API_URL_BVT}:4002/api/pu/maps/v1.0/get-desa?${queryParams}`, {
method: 'GET',
headers: {
'Authorization': `Beaerer ${req.query.user_token}`,
'Content-Type': 'application/json',
'Accept': 'application/json',
'Accept-Charset': 'UTF-8'
}
}).then(response => {
return response.json();
}).then(responseJson => {
return responseJson;
});
}
// GET GEOMETRI ADMINISTRASI
const getKecamatanGeometri = (req) => {
let queryParams = new URLSearchParams(req.query).toString();
return fetch(`${config.API_URL_BVT}:4002/api/pu/maps/v1.0/geom/get-kecamatan?${queryParams}`, {
method: 'GET',
headers: {
'Authorization': `Beaerer ${req.query.user_token}`,
'Content-Type': 'application/json',
'Accept': 'application/json',
'Accept-Charset': 'UTF-8'
}
}).then(response => {
return response.json();
}).then(responseJson => {
return responseJson;
});
}
const getDesaGeometri = (req) => {
let queryParams = new URLSearchParams(req.query).toString();
return fetch(`${config.API_URL_BVT}:4002/api/pu/maps/v1.0/geom/get-desa?${queryParams}`, {
method: 'GET',
headers: {
'Authorization': `Beaerer ${req.query.user_token}`,
'Content-Type': 'application/json',
'Accept': 'application/json',
'Accept-Charset': 'UTF-8'
}
}).then(response => {
return response.json();
}).then(responseJson => {
return responseJson;
});
}
module.exports = {
getAllKecamatan,
getAllDesa,
getKecamatanGeometri,
getDesaGeometri
}
\ No newline at end of file
const fetch = require('node-fetch');
const config = require('../../config');
const loginFetch = (req) => {
let status;
return fetch(`${config.API_URL_AUTH}/login`, {
method: "POST",
headers: {
"Content-type": "application/json",
"Accept": "application/json",
"Accept-Charset": "utf-8"
},
body: JSON.stringify({
username: req.body.username,
password: req.body.password
})
})
.then(res => {
status = res.status;
return res.json();
})
.then(json => {
return {
status: status,
data: json
}
});
}
const checkTokenFetch = (token) => {
let status;
return fetch(`${config.API_URL_AUTH}/check-token`, {
method: 'GET',
headers: {
"Authorization": "Bearer " + token,
"Content-Type": "application/json",
"Accept": "application/json",
"Accept-Charset": "UTF-8"
}
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
});
}
module.exports = {
loginFetch,
checkTokenFetch
}
\ No newline at end of file
const fetch = require('node-fetch');
const config = require('../../config');
var FormData = require('form-data');
const URL = "http://localhost:8083/kegiatan?name=";
const getCurrentDate = require('../../helper/current-date');
const currentDate = getCurrentDate();
const globalVariable = require('../../helper/globalVarible');
const multer = require('multer');
const storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, '../lokasi_city/pics');
},
filename: function (req, file, cb) {
cb(null, file.originalname);
}
});
var uploadImg = multer({storage: storage});
const getAllKegiatan = (req) => {
let status;
var params = new URLSearchParams(req.query);
var url = `${config.API_URL_SERVICES}/get-all-kegiatan?`
return fetch(url + params, {
method: 'GET',
headers: {
"Authorization": "Bearer " + req.cookies.user_token,
"Content-type": "application/json",
"Accept": "application/json",
"Accept-Charset": "utf-8"
}
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
})
}
const getKegiatanById = (req) => {
let status;
var params = new URLSearchParams(req.query);
var url = `${config.API_URL_SERVICES}/get-kegiatan?`
return fetch(url + params, {
method: 'GET',
headers: {
"Authorization": "Bearer " + req.cookies.user_token,
"Content-type": "application/json",
"Accept": "application/json",
"Accept-Charset": "utf-8"
}
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
})
}
const getFullKegiatan = (req) => {
let status;
var url = `${config.API_URL_SERVICES}/get-full-kegiatan`
return fetch(url, {
method: 'GET',
headers: {
"Authorization": "Bearer " + req.cookies.user_token,
"Content-type": "application/json",
"Accept": "application/json",
"Accept-Charset": "utf-8"
}
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
})
}
const createKegiatan = (req) => {
let status;
var formData = new FormData();
formData.append("id_tatanan", "");
formData.append("nama_kegiatan", req.body.nama_kegiatan);
formData.append("nama_tatanan", req.body.nama_tatanan);
formData.append("jenis_indikator", req.body.jenis_indikator);
formData.append("kategori", req.body.kategori);
formData.append("nama_indikator", req.body.nama_indikator);
formData.append("subindikator", req.body.subindikator);
formData.append("pelaksana", req.body.pelaksana);
formData.append("tanggal_kegiatan", req.body.tanggal_kegiatan);
formData.append("longitude", req.body.longitude);
formData.append("latitude", req.body.latitude);
formData.append("deskripsi", req.body.deskripsi);
formData.append("created_at", currentDate.dateAsiaJakarta);
formData.append("created_by", req.userData.id);
formData.append("gambar", URL + req.body.gambar.filename);
return fetch(`${config.API_URL_SERVICES}/create-kegiatan`, {
method: 'POST',
headers: {
"Authorization": "Bearer " + req.cookies.user_token,
"Content-Type": "multipart/form-data"
},
body: formData,
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
})
}
const createKegiatanNon = (req) => {
let status;
return fetch(`${config.API_URL_SERVICES}/create-kegiatan-non`, {
method: 'POST',
headers: {
"Authorization": "Bearer " + req.cookies.user_token,
"Content-type": "application/json",
"Accept": "application/json",
"Accept-Charset": "utf-8"
},
body: JSON.stringify({
id_tatanan: "",
nama_kegiatan: req.body.nama_kegiatan,
nama_tatanan: req.body.nama_tatanan,
jenis_indikator: req.body.jenis_indikator,
kategori: req.body.kategori,
nama_indikator: req.body.nama_indikator,
subindikator: req.body.subindikator,
pelaksana: req.body.pelaksana,
tanggal_kegiatan: req.body.tanggal_kegiatan,
longitude: req.body.longitude,
latitude: req.body.latitude,
deskripsi: req.body.deskripsi,
alamat: req.body.alamat,
created_at: currentDate.dateAsiaJakarta,
created_by: req.userData.id
}),
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
})
}
const getKegiatanByRole = (req) => {
let status;
var params = new URLSearchParams(req.query);
var url = `${config.API_URL_SERVICES}/get-role-kegiatan?`
return fetch(url + params, {
method: 'GET',
headers: {
"Authorization": "Bearer " + req.cookies.user_token,
"Content-type": "application/json",
"Accept": "application/json",
"Accept-Charset": "utf-8"
}
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
})
}
const getKegiatanByUser = (req) => {
let status;
var params = new URLSearchParams(req.query);
var url = `${config.API_URL_SERVICES}/get-user-kegiatan?user_id=`+req.cookies.id+`&`
return fetch(url + params, {
method: 'GET',
headers: {
"Authorization": "Bearer " + req.cookies.user_token,
"Content-type": "application/json",
"Accept": "application/json",
"Accept-Charset": "utf-8"
}
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
})
}
const deleteKegiatan = (req) => {
let status;
var params = new URLSearchParams(req.query);
var url = `${config.API_URL_SERVICES}/delete-kegiatan?`
return fetch(url + params, {
method: 'PATCH',
headers: {
"Authorization": "Bearer " + req.cookies.user_token,
"Content-type": "application/json",
"Accept": "application/json",
"Accept-Charset": "utf-8"
},
body: JSON.stringify({
deleted_at: currentDate.dateAsiaJakarta,
status: 0,
deleted_by: req.userData.id
})
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
})
}
const editKegiatan = (req) => {
let status;
var params = new URLSearchParams(req.query);
var url = `${config.API_URL_SERVICES}/update-kegiatan?`
return fetch(url + params, {
method: 'PATCH',
headers: {
"Authorization": "Bearer " + req.cookies.user_token,
"Content-type": "application/json",
"Accept": "application/json",
"Accept-Charset": "utf-8"
},
body: JSON.stringify({
id: req.query.id,
id_tatanan: req.body.id_tatanan,
nama_kegiatan: req.body.nama_kegiatan,
nama_tatanan: req.body.nama_tatanan,
jenis_indikator: req.body.jenis_indikator,
kategori: req.body.kategori,
nama_indikator: req.body.nama_indikator,
subindikator: req.body.subindikator,
pelaksana: req.body.pelaksana,
tanggal_kegiatan: req.body.tanggal_kegiatan,
longitude: req.body.longitude,
latitude: req.body.latitude,
deskripsi: req.body.deskripsi,
updated_at: currentDate.dateAsiaJakarta,
updated_by: req.userData.id
})
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
})
}
module.exports = {
getAllKegiatan,
getKegiatanById,
getFullKegiatan,
createKegiatan,
uploadImg,
createKegiatanNon,
getKegiatanByRole,
deleteKegiatan,
editKegiatan,
getKegiatanByUser
}
\ No newline at end of file
const fetch = require("node-fetch");
const getPoiRegion = (req) => {
return fetch('http://52.221.250.46:5020/api/v1.0/find-poi/basic-3', {
method: "POST",
headers: {
"Content-type": "application/json",
Accept: "application/json",
"Accept-Charset": "utf-8",
},
body: JSON.stringify(req.body),
})
.then((response) => {
return response.json();
})
.then((responseJson) => {
return responseJson;
});
};
module.exports = {
getPoiRegion
};
const fetch = require('node-fetch');
const config = require('../../config');
const getCurrentDate = require('../../helper/current-date');
const currentDate = getCurrentDate();
const globalVariable = require('../../helper/globalVarible');
const getAllTatanan = (req) => {
let status;
var params = new URLSearchParams(req.query);
var url = `${config.API_URL_SERVICES}/get-all-tatanan?`
return fetch(url + params, {
method: 'GET',
headers: {
"Authorization": "Bearer " + req.cookies.user_token,
"Content-type": "application/json",
"Accept": "application/json",
"Accept-Charset": "utf-8"
}
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
})
}
const getFullTatanan = (req) => {
let status;
var url = `${config.API_URL_SERVICES}/get-full-tatanan`
return fetch(url, {
method: 'GET',
headers: {
"Authorization": "Bearer " + req.cookies.user_token,
"Content-type": "application/json",
"Accept": "application/json",
"Accept-Charset": "utf-8"
}
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
})
}
const getTatananNama = (req) => {
let status;
var params = new URLSearchParams(req.query);
var url = `${config.API_URL_SERVICES}/get-tatanan-nama?`
return fetch(url + params, {
method: 'GET',
headers: {
"Authorization": "Bearer " + req.cookies.user_token,
"Content-type": "application/json",
"Accept": "application/json",
"Accept-Charset": "utf-8"
}
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
})
}
const getNamaJenis = (req) => {
let status;
var params = new URLSearchParams(req.query);
var url = `${config.API_URL_SERVICES}/get-tatanan-nama-jenis?`
return fetch(url + params, {
method: 'GET',
headers: {
"Authorization": "Bearer " + req.cookies.user_token,
"Content-type": "application/json",
"Accept": "application/json",
"Accept-Charset": "utf-8"
}
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
})
}
const getNamaJenisKategori = (req) => {
let status;
var params = new URLSearchParams(req.query);
var url = `${config.API_URL_SERVICES}/get-tatanan-nama-jenis-kategori?`
return fetch(url + params, {
method: 'GET',
headers: {
"Authorization": "Bearer " + req.cookies.user_token,
"Content-type": "application/json",
"Accept": "application/json",
"Accept-Charset": "utf-8"
}
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
})
}
const getNamaJenisKategoriIndikator = (req) => {
let status;
var params = new URLSearchParams(req.query);
var url = `${config.API_URL_SERVICES}/get-tatanan-nama-jenis-kategori-indikator?`
return fetch(url + params, {
method: 'GET',
headers: {
"Authorization": "Bearer " + req.cookies.user_token,
"Content-type": "application/json",
"Accept": "application/json",
"Accept-Charset": "utf-8"
}
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
})
}
const createTatanan = (req) => {
let status;
return fetch(`${config.API_URL_SERVICES}/create-tatanan`, {
method: 'POST',
headers: {
"Authorization": "Bearer " + req.cookies.user_token,
"Content-type": "application/json",
"Accept": "application/json",
"Accept-Charset": "utf-8"
},
body: JSON.stringify({
nama_tatanan: req.body.nama_tatanan,
jenis_indikator: req.body.jenis_indikator,
kategori: req.body.kategori,
nama_indikator: req.body.nama_indikator,
subindikator: req.body.subindikator,
created_at: currentDate.dateAsiaJakarta,
created_by: req.userData.id
})
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
})
}
const deleteTatanan = (req) => {
let status;
var params = new URLSearchParams(req.query);
var url = `${config.API_URL_SERVICES}/delete-tatanan?`
return fetch(url + params, {
method: 'PATCH',
headers: {
"Authorization": "Bearer " + req.cookies.user_token,
"Content-type": "application/json",
"Accept": "application/json",
"Accept-Charset": "utf-8"
},
body: JSON.stringify({
deleted_at: currentDate.dateAsiaJakarta,
status: 0,
deleted_by: req.userData.id
})
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
})
}
const getTatananById = (req) => {
let status;
var params = new URLSearchParams(req.query);
var url = `${config.API_URL_SERVICES}/get-tatanan?`
return fetch(url + params, {
method: 'GET',
headers: {
"Authorization": "Bearer " + req.cookies.user_token,
"Content-type": "application/json",
"Accept": "application/json",
"Accept-Charset": "utf-8"
}
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
})
}
const editTatanan = (req) => {
let status;
var params = new URLSearchParams(req.query);
var url = `${config.API_URL_SERVICES}/update-tatanan?`
return fetch(url + params, {
method: 'PATCH',
headers: {
"Authorization": "Bearer " + req.cookies.user_token,
"Content-type": "application/json",
"Accept": "application/json",
"Accept-Charset": "utf-8"
},
body: JSON.stringify({
nama_tatanan: req.body.nama_tatanan,
jenis_indikator: req.body.jenis_indikator,
kategori: req.body.kategori,
nama_indikator: req.body.nama_indikator,
subindikator: req.body.subindikator,
updated_at: currentDate.dateAsiaJakarta,
updated_by: req.userData.id
})
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
})
}
module.exports = {
getAllTatanan,
createTatanan,
deleteTatanan,
getTatananById,
editTatanan,
getFullTatanan,
getTatananNama,
getNamaJenis,
getNamaJenisKategori,
getNamaJenisKategoriIndikator
}
\ No newline at end of file
const fetch = require('node-fetch');
const config = require('../../config');
const getCurrentDate = require('../../helper/current-date');
const currentDate = getCurrentDate();
const globalVariable = require('../../helper/globalVarible');
const getAllUsers = (req) => {
let status;
var params = new URLSearchParams(req.query);
var url = `${config.API_URL_AUTH}/get-all-users?`
return fetch(url + params, {
method: 'GET',
headers: {
"Authorization": "Bearer " + req.cookies.user_token,
"Content-type": "application/json",
"Accept": "application/json",
"Accept-Charset": "utf-8"
}
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
})
}
const getAllRoles = (req) => {
let status;
var params = new URLSearchParams(req.query);
var url = `${config.API_URL_AUTH}/get-roles?`
return fetch(url + params, {
method: 'GET',
headers: {
"Authorization": "Bearer " + req.cookies.user_token,
"Content-type": "application/json",
"Accept": "application/json",
"Accept-Charset": "utf-8"
}
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
})
}
const createUser = (req) => {
let status;
return fetch(`${config.API_URL_AUTH}/create-user`, {
method: 'POST',
headers: {
"Authorization": "Bearer " + req.cookies.user_token,
"Content-type": "application/json",
"Accept": "application/json",
"Accept-Charset": "utf-8"
},
body: JSON.stringify({
id_role: req.body.id_role,
email: req.body.email,
password: req.body.password,
password_confirmation: req.body.password_confirmation,
username: req.body.username,
firstname: req.body.firstname,
lastname: req.body.lastname,
mobile_number: req.body.mobile_number,
status: "true",
kode_wilayah: ({
kode_prov: [req.body.kode_prov],
kode_kabkot: [req.body.kode_kabkot],
kode_kec: [req.body.kode_kec],
kode_desa: [req.body.kode_desa]
}),
created_at: currentDate.dateAsiaJakarta,
created_by: req.userData.id
})
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
})
}
const deleteUser = (req) => {
let status;
var params = new URLSearchParams(req.query);
var url = `${config.API_URL_AUTH}/delete-user?`
return fetch(url + params, {
method: 'PATCH',
headers: {
"Authorization": "Bearer " + req.cookies.user_token,
"Content-type": "application/json",
"Accept": "application/json",
"Accept-Charset": "utf-8"
},
body: JSON.stringify({
deleted_at: currentDate.dateAsiaJakarta,
status: 0,
deleted_by: req.userData.id
})
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
})
}
const getUserById = (req) => {
let status;
var params = new URLSearchParams(req.query);
var url = `${config.API_URL_AUTH}/detail-user?`
return fetch(url + params, {
method: 'GET',
headers: {
"Authorization": "Bearer " + req.cookies.user_token,
"Content-type": "application/json",
"Accept": "application/json",
"Accept-Charset": "utf-8"
}
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
})
}
const getUserByIdLogin = (req) => {
let status;
var params = req.cookies.id
var url = `${config.API_URL_AUTH}/detail-user?id=`
return fetch(url + params, {
method: 'GET',
headers: {
"Authorization": "Bearer " + req.cookies.user_token,
"Content-type": "application/json",
"Accept": "application/json",
"Accept-Charset": "utf-8"
}
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
})
}
const editUser = (req) => {
let status;
var params = new URLSearchParams(req.query);
var url = `${config.API_URL_AUTH}/edit-user?`
return fetch(url + params, {
method: 'PATCH',
headers: {
"Authorization": "Bearer " + req.cookies.user_token,
"Content-type": "application/json",
"Accept": "application/json",
"Accept-Charset": "utf-8"
},
body: JSON.stringify({
id: req.query.id,
email: req.body.email,
username: req.body.username,
firstname: req.body.firstname,
lastname: req.body.lastname,
password: req.body.password,
password_confirmation: req.body.password_confirmation,
mobile_number: req.body.mobile_number,
status: req.body.status,
kode_wilayah: req.body.kode_wilayah
})
}).then(response => {
status = response.status;
return response.json();
}).then(responseJson => {
return {
status: status,
data: responseJson
}
})
}
module.exports = {
getAllUsers,
getAllRoles,
createUser,
deleteUser,
getUserById,
getUserByIdLogin,
editUser
}
\ No newline at end of file
const moment = require('moment-timezone');
const currentDate = () => {
let date_ob = new Date();
let date = ('0' + date_ob.getDate()).slice(-2);
let month = ('0' + (date_ob.getMonth() + 1)).slice(-2);
let years = date_ob.getFullYear();
let hours = ('0' + date_ob.getHours()).slice(-2);
let minutes = ('0' + date_ob.getMinutes()).slice(-2);
let seconds = ('0' + date_ob.getSeconds()).slice(-2);
let timestampNow = years + '-' + month + '-' + date + ' ' + hours + ':' + minutes + ':' + seconds;
let dateAsiaJakarta = moment().tz('Asia/Jakarta').format();
return {
date: date,
month: month,
years: years,
hours: hours,
minutes: minutes,
seconds: seconds,
timestampNow: timestampNow,
dateAsiaJakarta: dateAsiaJakarta
}
}
module.exports = currentDate;
\ No newline at end of file
module.exports = {
ROLE_ADMIN: 1,
ROLE_USER: 2, // untuk user seperti petugas, masyarakat
}
\ No newline at end of file
const paginator = (reqPage, pageSize) => {
const page = !reqPage || reqPage <= 0 ? 0 : reqPage - 1;
const nextPage = page + 2;
const prevPage = page;
const offset = page * pageSize;
const limit = pageSize;
const currentPage = reqPage;
return {
page: page,
nextPage: nextPage,
prevPage: prevPage,
offset: offset,
limit: limit,
currentPage: currentPage
}
}
module.exports = paginator;
\ No newline at end of file
const jwt = require('jsonwebtoken');
const config = require('../config');
const { checkToken } = require('./login');
module.exports = async (req, res, next) => {
try {
const token = req.cookies.user_token;
if (token != undefined) {
jwt.verify(token, config.JWT_KEY, function(err, decoded) {
if (err) {
res.redirect('/login');
}
req.userData = decoded;
res.locals.user = decoded;
next();
});
} else {
res.redirect('/login');
}
} catch (error) {
res.redirect('/login');
}
}
\ No newline at end of file
const jwt = require("jsonwebtoken");
const config = require("../config");
const authFetch = require("../fetch/auth/auth");
const checkToken = (token) => {
return authFetch
.checkTokenFetch(token)
.then((response) => {
if (response.status == 200) {
return response.data.data;
} else {
return false;
}
})
.catch((err) => {
console.log(err);
});
};
module.exports = async (req, res, next) => {
try {
const token = req.cookies.user_token;
const validToken = await checkToken(token);
if (validToken) {
const decoded = jwt.verify(token, config.JWT_KEY);
req.userData = decoded;
res.redirect('/');
} else {
next();
}
} catch (error) {
next();
}
};
{
"name": "lokasi_city",
"version": "1.0.0",
"description": "Lokasi City",
"main": "app.js",
"scripts": {
"start": "nodemon app.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"Lokasi",
"City"
],
"author": "Intern Del 2021",
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.0",
"bootstrap-icons": "^1.5.0",
"cookie-parser": "^1.4.5",
"cors": "^2.8.5",
"ejs-mate": "^3.0.0",
"esri-leaflet-geocoder": "^3.1.0",
"express": "^4.17.1",
"express-validator": "^6.12.0",
"form-data": "^4.0.0",
"fsevents": "^2.3.2",
"jsonwebtoken": "^8.5.1",
"leaflet": "^1.7.1",
"morgan": "^1.10.0",
"multer": "^1.4.2",
"node-fetch": "^2.6.1",
"sequelize": "^6.6.2",
"sweetalert": "^2.1.2"
},
"devDependencies": {
"nodemon": "^2.0.7"
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
.wrapper-kelola-lokasi {
position: relative;
}
#map-city {
position: relative;
z-index: 1;
height: 80vh;
border-radius: 20px;
box-shadow: 0px 5px 10px 0 rgba(0, 0, 0, 0.4);
}
.card-kelola-lokasi {
position: absolute;
z-index: 2;
top: 10px;
width: 30%;
padding: 20px;
border-radius: 20px;
margin: auto;
}
.card-find-poi {
background-color: #fff;
padding: 20px;
background-clip: border-box;
border: 1px solid rgba(0,0,0,.125);
border-radius: 10px;
}
.card-kelola-kegiatan {
position: absolute;
z-index: 2;
top: 10px;
width: 40%;
padding: 20px;
border-radius: 20px;
margin: auto;
}
.grid-kelola-lokasi {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-column-gap: 50px;
padding: 20px;
background-color: #fff;
background-clip: border-box;
border: 1px solid rgba(0,0,0,.125);
border-radius: 20px;
}
.grid-kelola-kegiatan {
grid-template-columns: repeat(2, 1fr);
padding: 20px;
background-color: #fff;
background-clip: border-box;
border: 1px solid rgba(0,0,0,.125);
border-radius: 20px;
}
.btn-green {
color: #fff;
background-color: #07827c;
border-color: #07827c;
}
.btn-green:hover {
color: #fff;
font-weight: bold;
}
\ No newline at end of file
.column-login {
display: grid;
grid-column-gap: 30px;
grid-template-columns: 2fr 1fr;
}
.img-medan-city {
background-image: url(https://images.pexels.com/photos/6583407/pexels-photo-6583407.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940);
height: 109vh;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.card-login {
padding: 20px;
margin: auto 20px;
border-radius: 20px;
box-shadow: 0px 10px 20px 0 rgba(0, 0, 0, 0.4);
}
.intro-login {
text-align: center;
}
.icon-user-login i {
margin: 40px 0;
}
.intro-login h2 {
font-size: 25px;
margin: 5px 0 30px 0;
color: #1f827c;
}
.mt-20 {
margin-top: 20px;
}
section{
position: relative;
width: 105%;
height: 100vh;
display: flex;
margin: -78px;
}
section .imgBx{
position: relative;
width: 80%;
height: 100%;
}
section .imgBx:before{
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
section .imgBx img{
position: absolute;
top: 0;
left: 0;
width: 109%;
height: 109vh;
object-fit: cover;
}
section .contentBx{
display: flex;
width: 50%;
height: 100%;
justify-content: center;
align-items: center;
}
section .contentBx .formBx
{
width: 50%;
}
section .contentBx .formBx img{
display: block;
margin-left: auto;
margin-right: auto;
}
section .contentBx .formBx h3{
font-weight: 600;
font-size: 1.5em;
margin-bottom: 20px;
border-bottom: 4px solid #000000;
display: inline-block;
letter-spacing: 1px;
text-align: center;
}
section .contentBx .formBx .inputBx{
margin-bottom: 20px;
}
section .contentBx .formBx .inputBx label{
font-size: 16px;
margin-bottom: 5px;
display: inline-block;
color: #000000;
font-weight: 300;
font-size: 16px;
letter-spacing: 1px;
}
section .contentBx .formBx .inputBx input{
width: 100%;
padding: 10px 20px;
outline: none;
font-weight: 400;
border: 1px solid #8692A6;
font-size: 16px;
letter-spacing: 1px;
color: #8692A6;
background: transparent;
border-radius: 6px;
}
section .contentBx .formBx button{
width: 100%;
border-radius: 4px;
border: none;
color: #FFFFFF;
text-align: center;
font-size: 20px;
padding: 20px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
}
section .contentBx .formBx .remember {
margin-bottom: 10px;
color: black;
font-weight: 400;
font-size: 14px;
}
.container{
display: flex;
}
p{
font-size: 20px;
padding: 20px;
}
.img{
-webkit-animation: fadein 2s; /* Safari, Chrome and Opera > 12.1 */
-moz-animation: fadein 2s; /* Firefox < 16 */
-ms-animation: fadein 2s; /* Internet Explorer */
-o-animation: fadein 2s; /* Opera < 12.1 */
animation: fadein 2s;
}
.button{
border-radius: 4px;
border: none;
color: #FFFFFF;
text-align: center;
font-size: 20px;
padding: 20px;
width: 200px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
background: #00AEE1;
}
.button:hover {
background-color: #0d588e
}
.button:active {
background-color: #0d588e;
box-shadow: 0 5px #666;
transform: translateY(4px);
}
h1{
color: #455A6E;
font-size: 48px;
font-weight: bold;
}
@keyframes fadein {
from { opacity: 0; }
to { opacity: 1; }
}
/* Firefox < 16 */
@-moz-keyframes fadein {
from { opacity: 0; }
to { opacity: 1; }
}
/* Safari, Chrome and Opera > 12.1 */
@-webkit-keyframes fadein {
from { opacity: 0; }
to { opacity: 1; }
}
/* Internet Explorer */
@-ms-keyframes fadein {
from { opacity: 0; }
to { opacity: 1; }
}
/* Opera < 12.1 */
@-o-keyframes fadein {
from { opacity: 0; }
to { opacity: 1; }
}
@media (max-width: 768px)
{
section .imgBx{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
section .contentBx{
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
z-index: 1;
}
section .contentBx .formBx{
width: 100%;
padding: 40px;
background: rgba(255, 255, 255, 0.9);
margin: 50px;
}
}
\ No newline at end of file
/* Magnific Popup CSS */
.mfp-bg{top:0;left:0;width:100%;height:100%;z-index:1042;overflow:hidden;position:fixed;background:#0b0b0b;opacity:0.8}.mfp-wrap{top:0;left:0;width:100%;height:100%;z-index:1043;position:fixed;outline:none !important;-webkit-backface-visibility:hidden}.mfp-container{text-align:center;position:absolute;width:100%;height:100%;left:0;top:0;padding:0 8px;box-sizing:border-box}.mfp-container:before{content:'';display:inline-block;height:100%;vertical-align:middle}.mfp-align-top .mfp-container:before{display:none}.mfp-content{position:relative;display:inline-block;vertical-align:middle;margin:0 auto;text-align:left;z-index:1045}.mfp-inline-holder .mfp-content,.mfp-ajax-holder .mfp-content{width:100%;cursor:auto}.mfp-ajax-cur{cursor:progress}.mfp-zoom-out-cur,.mfp-zoom-out-cur .mfp-image-holder .mfp-close{cursor:-moz-zoom-out;cursor:-webkit-zoom-out;cursor:zoom-out}.mfp-zoom{cursor:pointer;cursor:-webkit-zoom-in;cursor:-moz-zoom-in;cursor:zoom-in}.mfp-auto-cursor .mfp-content{cursor:auto}.mfp-close,.mfp-arrow,.mfp-preloader,.mfp-counter{-webkit-user-select:none;-moz-user-select:none;user-select:none}.mfp-loading.mfp-figure{display:none}.mfp-hide{display:none !important}.mfp-preloader{color:#CCC;position:absolute;top:50%;width:auto;text-align:center;margin-top:-0.8em;left:8px;right:8px;z-index:1044}.mfp-preloader a{color:#CCC}.mfp-preloader a:hover{color:#FFF}.mfp-s-ready .mfp-preloader{display:none}.mfp-s-error .mfp-content{display:none}button.mfp-close,button.mfp-arrow{overflow:visible;cursor:pointer;background:transparent;border:0;-webkit-appearance:none;display:block;outline:none;padding:0;z-index:1046;box-shadow:none;touch-action:manipulation}button::-moz-focus-inner{padding:0;border:0}.mfp-close{width:44px;height:44px;line-height:44px;position:absolute;right:0;top:0;text-decoration:none;text-align:center;opacity:0.65;padding:0 0 18px 10px;color:#FFF;font-style:normal;font-size:28px;font-family:Arial, Baskerville, monospace}.mfp-close:hover,.mfp-close:focus{opacity:1}.mfp-close:active{top:1px}.mfp-close-btn-in .mfp-close{color:#333}.mfp-image-holder .mfp-close,.mfp-iframe-holder .mfp-close{color:#FFF;right:-6px;text-align:right;padding-right:6px;width:100%}.mfp-counter{position:absolute;top:0;right:0;color:#CCC;font-size:12px;line-height:18px;white-space:nowrap}.mfp-arrow{position:absolute;opacity:0.65;margin:0;top:50%;margin-top:-55px;padding:0;width:90px;height:110px;-webkit-tap-highlight-color:transparent}.mfp-arrow:active{margin-top:-54px}.mfp-arrow:hover,.mfp-arrow:focus{opacity:1}.mfp-arrow:before,.mfp-arrow:after{content:'';display:block;width:0;height:0;position:absolute;left:0;top:0;margin-top:35px;margin-left:35px;border:medium inset transparent}.mfp-arrow:after{border-top-width:13px;border-bottom-width:13px;top:8px}.mfp-arrow:before{border-top-width:21px;border-bottom-width:21px;opacity:0.7}.mfp-arrow-left{left:0}.mfp-arrow-left:after{border-right:17px solid #FFF;margin-left:31px}.mfp-arrow-left:before{margin-left:25px;border-right:27px solid #3F3F3F}.mfp-arrow-right{right:0}.mfp-arrow-right:after{border-left:17px solid #FFF;margin-left:39px}.mfp-arrow-right:before{border-left:27px solid #3F3F3F}.mfp-iframe-holder{padding-top:40px;padding-bottom:40px}.mfp-iframe-holder .mfp-content{line-height:0;width:100%;max-width:900px}.mfp-iframe-holder .mfp-close{top:-40px}.mfp-iframe-scaler{width:100%;height:0;overflow:hidden;padding-top:56.25%}.mfp-iframe-scaler iframe{position:absolute;display:block;top:0;left:0;width:100%;height:100%;box-shadow:0 0 8px rgba(0, 0, 0, 0.6);background:#000}img.mfp-img{width:auto;max-width:100%;height:auto;display:block;line-height:0;box-sizing:border-box;padding:40px 0 40px;margin:0 auto}.mfp-figure{line-height:0}.mfp-figure:after{content:'';position:absolute;left:0;top:40px;bottom:40px;display:block;right:0;width:auto;height:auto;z-index:-1;box-shadow:0 0 8px rgba(0, 0, 0, 0.6);background:#444}.mfp-figure small{color:#BDBDBD;display:block;font-size:12px;line-height:14px}.mfp-figure figure{margin:0}.mfp-bottom-bar{margin-top:-36px;position:absolute;top:100%;left:0;width:100%;cursor:auto}.mfp-title{text-align:left;line-height:18px;color:#F3F3F3;word-wrap:break-word;padding-right:36px}.mfp-image-holder .mfp-content{max-width:100%}.mfp-gallery .mfp-image-holder .mfp-figure{cursor:pointer}@media screen and (max-width:800px) and (orientation:landscape),screen and (max-height:300px){.mfp-img-mobile .mfp-image-holder{padding-left:0;padding-right:0}.mfp-img-mobile img.mfp-img{padding:0}.mfp-img-mobile .mfp-figure:after{top:0;bottom:0}.mfp-img-mobile .mfp-figure small{display:inline;margin-left:5px}.mfp-img-mobile .mfp-bottom-bar{background:rgba(0, 0, 0, 0.6);bottom:0;margin:0;top:auto;padding:3px 5px;position:fixed;box-sizing:border-box}.mfp-img-mobile .mfp-bottom-bar:empty{padding:0}.mfp-img-mobile .mfp-counter{right:5px;top:3px}.mfp-img-mobile .mfp-close{top:0;right:0;width:35px;height:35px;line-height:35px;background:rgba(0, 0, 0, 0.6);position:fixed;text-align:center;padding:0}}@media all and (max-width:900px){.mfp-arrow{-webkit-transform:scale(0.75);transform:scale(0.75)}.mfp-arrow-left{-webkit-transform-origin:0;transform-origin:0}.mfp-arrow-right{-webkit-transform-origin:100%;transform-origin:100%}.mfp-container{padding-left:6px;padding-right:6px}
}
\ No newline at end of file
* {
padding: 0;
margin: 0;
}
body {
font-family: 'Poppins', sans-serif;
background-color: white;
min-height: 100vh;
display: flex;
flex-direction: column;
}
/* Button */
.btn-dflt{
background-color: #1f827c;
border: none;
color: white;
box-shadow: 0px 8px 15px rgba(28, 128, 118, 0.483);
padding: 15px;
text-align: center;
text-decoration: none;
display: inline-block;
border-radius: 39px;
transition: all 0.3s ease 0s;
cursor: pointer;
outline: none;
width: auto;
}
.btn-dflt:hover{
background-color: #1f827c;
color: white;
}
.carousel-item{
width:100%;
max-height: 500px !important;
}
.carousel-inner{
border-radius: 25px;
}
.carousel-box{
width: 95%;
}
.inf{
padding-top: 25px;
}
.center-block {
margin-left:auto;
margin-right:auto;
display:block;
}
.pagination > .active > a
{
color: white;
background-color: #1f827c !Important;
border: solid 1px #1f827c !Important;
}
\ No newline at end of file
#map-city {
height: 180px;
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
:root {
--main-bg-color: #DDE8FC;
--main-text-color: #1E56BA;
--second-text-color: #bbbec5;
--second-bg-color: #c1efde;
}
.primary-text {
color: var(--main-text-color);
}
.second-text {
color: var(--second-text-color);
}
.primary-bg {
background-color: var(--main-bg-color);
}
.secondary-bg {
background-color: var(--second-bg-color);
}
.rounded-full {
border-radius: 100%;
}
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Poppins" , sans-serif;
}
.sidebar{
position: fixed;
left: 0;
top: 0;
height: 100%;
width: 78px;
background: #1f827c;
padding: 6px 14px;
z-index: 99;
transition: all 0.5s ease;
}
.sidebar.open{
width: 250px;
}
.sidebar .logo-details{
height: 60px;
display: flex;
align-items: center;
position: relative;
}
.sidebar .logo-details .icon{
opacity: 0;
transition: all 0.5s ease;
}
.sidebar .logo-details .logo_name{
color: #fff;
font-size: 20px;
font-weight: 600;
opacity: 0;
transition: all 0.5s ease;
}
.sidebar.open .logo-details .icon,
.sidebar.open .logo-details .logo_name{
opacity: 1;
}
.sidebar .logo-details #btn{
position: absolute;
top: 50%;
right: 0;
transform: translateY(-50%);
font-size: 22px;
transition: all 0.4s ease;
font-size: 23px;
text-align: center;
cursor: pointer;
transition: all 0.5s ease;
}
.sidebar.open .logo-details #btn{
text-align: right;
}
.sidebar i{
color: #fff;
height: 60px;
min-width: 50px;
font-size: 28px;
text-align: center;
line-height: 60px;
}
.sidebar .nav-list{
margin-top: 20px;
height: 100%;
}
.sidebar li{
position: relative;
margin: 8px 0;
list-style: none;
}
.sidebar li .tooltip{
position: absolute;
top: -20px;
left: calc(100% + 15px);
z-index: 3;
background: #fff;
box-shadow: 0 5px 10px rgba(52, 60, 209, 0.3);
padding: 6px 12px;
border-radius: 4px;
font-size: 15px;
font-weight: 400;
opacity: 0;
pointer-events: none;
transition: 0s;
}
.sidebar li:hover .tooltip{
opacity: 1;
pointer-events: auto;
transition: all 0.4s ease;
top: 50%;
transform: translateY(-50%);
}
.sidebar.open li .tooltip{
display: none;
}
.sidebar .bx-search{
position: absolute;
top: 50%;
left: 0;
transform: translateY(-50%);
font-size: 22px;
background: #1d1b31;
color: #FFF;
}
.sidebar.open .bx-search:hover{
background: #1d1b31;
color: #FFF;
}
.sidebar .bx-search:hover{
background: #FFF;
color: #11101d;
}
.sidebar li a{
display: flex;
height: 100%;
width: 100%;
border-radius: 12px;
align-items: center;
text-decoration: none;
transition: all 0.4s ease;
/* background: #1f827c; */
}
.sidebar li a:hover{
background: #669d98;
}
.sidebar li a .links_name{
color: #fff;
font-size: 15px;
font-weight: 400;
white-space: nowrap;
opacity: 0;
pointer-events: none;
transition: 0.4s;
}
.active{
background: #669d98;
}
.sidebar.open li a .links_name{
opacity: 1;
pointer-events: auto;
}
.sidebar li a:hover .links_name,
.sidebar li a:hover i{
transition: all 0.5s ease;
color: #11101D;
}
ul{
padding: 0;
}
.sidebar li i{
height: 50px;
line-height: 50px;
font-size: 18px;
border-radius: 12px;
}
.sidebar li.profile{
position: fixed;
height: 60px;
width: 78px;
left: 0;
bottom: -8px;
padding: 10px 14px;
background: #1d1b31;
transition: all 0.5s ease;
overflow: hidden;
}
.sidebar.open li.profile{
width: 250px;
}
.sidebar li .profile-details{
display: flex;
align-items: center;
flex-wrap: nowrap;
}
.sidebar li img{
height: 45px;
width: 45px;
object-fit: cover;
border-radius: 6px;
margin-right: 10px;
}
.sidebar li.profile .name,
.sidebar li.profile .job{
font-size: 15px;
font-weight: 400;
color: #fff;
white-space: nowrap;
}
.sidebar li.profile .job{
font-size: 12px;
}
.sidebar .profile #log_out{
position: absolute;
top: 50%;
right: 0;
transform: translateY(-50%);
background: #1d1b31;
width: 100%;
height: 60px;
line-height: 60px;
border-radius: 0px;
transition: all 0.5s ease;
}
.sidebar.open .profile #log_out{
width: 50px;
background: none;
}
.home-section{
position: relative;
background: #E4E9F7;
min-height: 100vh;
top: 0;
left: 78px;
width: calc(100% - 78px);
transition: all 0.5s ease;
z-index: 2;
}
.sidebar.open ~ .home-section{
left: 250px;
width: calc(100% - 250px);
}
#main {
transition: margin-left .5s;
margin-left: 78px;
width:auto;
}
.hide{
display: none;
}
.toggle-btn{
outline: none;
border-style: none;
}
.navbar{
width: 100%;
margin: 0%;
}
.dropdown-menu{
width: 50%;
}
.button-login{
background-color: white;
color: black;
border: 2px solid #1f827c;
border-radius: 5px;
padding: 5px 10px 5px 10px;
}
.button-login:hover {
background-color: #1f827c;
color: white;
}
/* On smaller screens, where height is less than 450px, change the style of the sidenav (less padding and a smaller font size) */
@media screen and (max-height: 450px) {
.sidebar {padding-top: 15px;}
.sidebar a {font-size: 18px;}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment