Merge commit 'a224a0b88859e4ec984cafa65f0d704acea19ad5' into production
This commit is contained in:
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@ -144,5 +144,8 @@
|
||||
"components/x-date-pickers/locales"
|
||||
],
|
||||
"i18n-ally.keystyle": "nested",
|
||||
"i18n-ally.sourceLanguage": "bg"
|
||||
"i18n-ally.sourceLanguage": "bg",
|
||||
"[shellscript]": {
|
||||
"editor.defaultFormatter": "foxundermoon.shell-format"
|
||||
}
|
||||
}
|
@ -3,19 +3,72 @@
|
||||
if [ "$UPDATE_CODE_FROM_GIT" = "true" ]; then
|
||||
# Install necessary packages
|
||||
apk add git nano rsync
|
||||
echo "Updating code from git.d-popov.com...(as '$GIT_USERNAME')"
|
||||
echo "Updating code from git.d-popov.com...(as '$GIT_USERNAME')" > /app/logs/deploy.txt
|
||||
|
||||
# Create a temporary directory for the new clone
|
||||
rm -rf /tmp/clone
|
||||
mkdir /tmp/clone
|
||||
mkdir -p /app/logs
|
||||
|
||||
# Clear previous log
|
||||
echo "Starting sync process at $(date)" > /app/logs/deploy.txt
|
||||
# Clone the repository
|
||||
git clone -b ${GIT_BRANCH:-main} --depth 1 https://$GIT_USERNAME:${GIT_PASSWORD//@/%40}@git.d-popov.com/popov/mwitnessing.git /tmp/clone || exit 1
|
||||
echo "\r\n\r\n Cloning repository..." | tee -a logs/deploy.txt
|
||||
git clone -b ${GIT_BRANCH:main} --depth 1 https://$GIT_USERNAME:${GIT_PASSWORD//@/%40}@git.d-popov.com/popov/mwitnessing.git /tmp/clone || exit 1
|
||||
|
||||
# Synchronize all files except package.json and package-lock.json to /app. alo exclude '/app/public/content/uploads' to avoid deleting uploaded files
|
||||
rsync -av --delete --exclude 'package.json' --exclude 'package-lock.json' --exclude '/app/public/content/uploads'
|
||||
/tmp/clone/ /app/ || echo "Rsync failed: Issue synchronizing files"
|
||||
# Synchronize all files except package.json, package-lock.json, and the contents of /public/content
|
||||
# rsync -av --filter='P /public/content/' --exclude 'package.json' --exclude 'package-lock.json' /tmp/clone/ /app/ || echo "Rsync failed: Issue synchronizing files"
|
||||
echo "\r\n\r\n Synchronizing files..."
|
||||
rsync -av /tmp/clone/_deploy/entrypoint.sh /app/entrypoint.sh || echo "Rsync failed: Issue copying entrypoint.sh"
|
||||
|
||||
|
||||
|
||||
# rsync -av --update --exclude '/public/content' --exclude 'package.json' --exclude 'package-lock.json' /tmp/clone/ /app/ || echo "Rsync failed: Issue synchronizing files" | tee -a /app/logs/deploy.txt
|
||||
|
||||
|
||||
########################################################################################
|
||||
if [ -d "/app/public/content/permits" ]; then
|
||||
mv /app/public/content/permits /tmp/content/permits
|
||||
echo "Permits folder backed up successfully." | tee -a /app/logs/deploy.txt
|
||||
else
|
||||
echo "Permits folder not found, skipping backup." | tee -a /app/logs/deploy.txt
|
||||
fi
|
||||
|
||||
# Run rsync with verbose output and itemize-changes
|
||||
echo "Running rsync..." | tee -a /app/logs/deploy.txt
|
||||
rsync -av --itemize-changes \
|
||||
--exclude='package.json' \
|
||||
--exclude='package-lock.json' \
|
||||
/tmp/clone/ /app/ >> /app/logs/deploy.txt 2>&1
|
||||
|
||||
# Check rsync exit status
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Rsync failed: Issue synchronizing files" | tee -a /app/logs/deploy.txt
|
||||
cat /app/logs/deploy.txt # Display the log contents
|
||||
else
|
||||
echo "Rsync completed successfully" | tee -a /app/logs/deploy.txt
|
||||
echo "Last few lines of rsync log:" | tee -a /app/logs/deploy.txt
|
||||
tail -n 20 /app/logs/deploy.txt # Display the last 20 lines of the log
|
||||
fi
|
||||
|
||||
# Restore permits folder
|
||||
echo "Restoring permits folder..." | tee -a /app/logs/deploy.txt
|
||||
if [ -d "/tmp/content/permits" ]; then
|
||||
# Ensure the destination directory exists
|
||||
mkdir -p /app/public/content
|
||||
mv /tmp/content/permits /app/public/content/permits
|
||||
echo "Permits folder restored successfully." | tee -a /app/logs/deploy.txt
|
||||
else
|
||||
echo "No permits folder to restore." | tee -a /app/logs/deploy.txt
|
||||
fi
|
||||
|
||||
# Check contents after restoration
|
||||
echo "Contents of /app/public/content after restoration:" >> /app/logs/deploy.txt
|
||||
ls -la /app/public/content >> /app/logs/deploy.txt 2>&1
|
||||
########################################################################################
|
||||
|
||||
|
||||
echo "\r\n\r\n Checking for changes in package files..."
|
||||
# Determine if package.json or package-lock.json has changed
|
||||
PACKAGE_CHANGE=0
|
||||
if ! cmp -s /tmp/clone/package.json /app/package.json || ! cmp -s /tmp/clone/package-lock.json /app/package-lock.json; then
|
||||
@ -38,7 +91,7 @@ if [ "$UPDATE_CODE_FROM_GIT" = "true" ]; then
|
||||
npx next build
|
||||
|
||||
# Clean up
|
||||
rm -rf /tmp/clone
|
||||
# rm -rf /tmp/clone
|
||||
echo "Update process completed."
|
||||
fi
|
||||
|
||||
|
43
_deploy/entrypoint.staging.sh
Normal file
43
_deploy/entrypoint.staging.sh
Normal file
@ -0,0 +1,43 @@
|
||||
# Check if the environment variable to update code from git is set to true
|
||||
if [ "$UPDATE_CODE_FROM_GIT" = "true" ]; then
|
||||
# Install necessary packages
|
||||
apk add git nano rsync
|
||||
echo "Updating code from git.d-popov.com...(as '$GIT_USERNAME')"
|
||||
|
||||
# Remove the previous clone directory to ensure a fresh start
|
||||
rm -rf /tmp/clone
|
||||
mkdir /tmp/clone
|
||||
|
||||
# Clone the specific branch of the new repository
|
||||
git clone -b ${GIT_BRANCH:-main} --depth 1 https://$GIT_USERNAME:${GIT_PASSWORD//@/%40}@git.d-popov.com/popov/mwitnessing.git /tmp/clone || exit 1
|
||||
# Fetch the latest commit ID and message from the cloned repository
|
||||
GIT_COMMIT_ID=$(git -C /tmp/clone rev-parse HEAD)
|
||||
LAST_COMMIT_MESSAGE=$(git -C /tmp/clone log -1 --pretty=%B)
|
||||
echo "Current Git Commit: $LAST_COMMIT_MESSAGE: $GIT_COMMIT_ID"
|
||||
export GIT_COMMIT_ID
|
||||
|
||||
# Use rsync to synchronize the files to /app, including deletion of files not in the source
|
||||
rsync -av --delete --exclude '/public/content' /tmp/clone/ /app/ || echo "Rsync failed: Issue synchronizing files"
|
||||
# Copy .env files
|
||||
rsync -av /tmp/clone/.env* /app/ || echo "Rsync failed: Issue copying .env files"
|
||||
# Copy the entrypoint.sh if exists in the new structure
|
||||
[ -f /tmp/clone/entrypoint.sh ] && rsync -av /tmp/clone/entrypoint.sh /app/entrypoint.sh || echo "Rsync failed: Issue copying entrypoint.sh"
|
||||
chmod +x /app/entrypoint.sh
|
||||
|
||||
# Clean up the temporary clone directory
|
||||
rm -rf /tmp/clone
|
||||
|
||||
cd /app
|
||||
echo "Installing packages in /app"
|
||||
npm install --no-audit --no-fund --no-optional --omit=optional
|
||||
yes | npx prisma generate
|
||||
# Uncomment the next line if database migrations are necessary
|
||||
# npx prisma migrate deploy
|
||||
echo "Done cloning. Current Git Commit ID: $GIT_COMMIT_ID"
|
||||
# Uncomment the following lines for production deployment
|
||||
# npx next build
|
||||
# npx next start
|
||||
fi
|
||||
|
||||
echo "Running the main process"
|
||||
exec "$@"
|
@ -25,8 +25,8 @@ apt install nodejs -y
|
||||
|
||||
##### ----------------- compose/deploy ----------------- ###
|
||||
# install docker if inside docker (vscode-server)# apt-get update && apt-get install -y docker.io
|
||||
# .10 > /mnt/apps/DEV/SSS/next-cart-app/next-cart-app/
|
||||
#.11 > cd /mnt/storage/DEV/workspace/repos/git.d-popov.com/next-cart-app/next-cart-app
|
||||
# !!! .10 > /mnt/apps/DEV/SSS/next-cart-app/next-cart-app/
|
||||
# !!! .11 > cd /mnt/storage/DEV/workspace/repos/git.d-popov.com/next-cart-app/next-cart-app
|
||||
|
||||
# using dockerfile and image:
|
||||
docker build -t jwpw:latest -f _deploy/prod.Dockerfile .
|
||||
@ -46,9 +46,9 @@ docker push docker.d-popov.com/jwpw:test
|
||||
--LATEST/
|
||||
cd /mnt/storage/DEV/workspace/repos/git.d-popov.com/mwhitnessing
|
||||
docker build -t docker.d-popov.com/jwpw:latest -f _deploy/prod.Dockerfile .
|
||||
docker tag docker.d-popov.com/jwpw:latest docker.d-popov.com/jwpw:0.9.95
|
||||
docker tag docker.d-popov.com/jwpw:latest docker.d-popov.com/jwpw:1.3.5
|
||||
docker push docker.d-popov.com/jwpw:latest
|
||||
docker push docker.d-popov.com/jwpw:0.9.95
|
||||
docker push docker.d-popov.com/jwpw:1.3.5
|
||||
|
||||
#---
|
||||
|
||||
|
@ -22,7 +22,7 @@ const fetchConfig = async () => {
|
||||
return config.default;
|
||||
};
|
||||
|
||||
export default function AvailabilityForm({ publisherId, existingItems, inline, onDone, date, cartEvent, datePicker = false }) {
|
||||
export default function AvailabilityForm({ publisherId, existingItems, inline, onDone, date, cartEvent, datePicker = false, lockedBeforeDate }) {
|
||||
|
||||
const router = useRouter();
|
||||
const urls = {
|
||||
@ -31,14 +31,15 @@ export default function AvailabilityForm({ publisherId, existingItems, inline, o
|
||||
};
|
||||
|
||||
const id = parseInt(router.query.id);
|
||||
//coalsce existingItems to empty array
|
||||
existingItems = existingItems || [];
|
||||
|
||||
const originalAvailabilities = existingItems || [];
|
||||
|
||||
const [editMode, setEditMode] = useState(existingItems.length > 0);
|
||||
const [publisher, setPublisher] = useState({ id: publisherId });
|
||||
const [day, setDay] = useState(new Date(date));
|
||||
const [canUpdate, setCanUpdate] = useState(true);
|
||||
|
||||
|
||||
const [timeSlots, setTimeSlots] = useState([]);
|
||||
const [availabilities, setAvailabilities] = useState(existingItems && existingItems.length > 0 ? existingItems : [{
|
||||
publisherId: publisher.id,
|
||||
@ -143,6 +144,35 @@ export default function AvailabilityForm({ publisherId, existingItems, inline, o
|
||||
setAvailabilities(avs);
|
||||
}
|
||||
|
||||
|
||||
// Handle repetition logic
|
||||
// const parentAvailabilityId = avs[0].id;
|
||||
// originalAvailabilities.forEach(async av => {
|
||||
// if (av.repeatWeekly && av.startTime < lockedBeforeDate) {
|
||||
// const newDate = av.startTime;
|
||||
// while (newDate < lockedBeforeDate) {
|
||||
// const newAvailability = {
|
||||
// ...av,
|
||||
// startTime: newDate,
|
||||
// parentAvailability: { connect: { id: parentAvailabilityId } },
|
||||
// publisher: { connect: { id: publisher.id } },
|
||||
// dateOfEntry: new Date(),
|
||||
// type: "OneTime"
|
||||
// };
|
||||
|
||||
// delete newAvailability.id;
|
||||
// delete newAvailability.title;
|
||||
// delete newAvailability.date;
|
||||
// delete newAvailability.publisherId
|
||||
|
||||
// await axiosInstance.post(urls.apiUrl, newAvailability);
|
||||
// newDate.setDate(newDate.getDate() + 7); // Repeat weekly
|
||||
// }
|
||||
// }
|
||||
// console.log("Updated availability: ", av)
|
||||
// }
|
||||
// );
|
||||
|
||||
handleCompletion({ updated: true });
|
||||
} catch (error) {
|
||||
alert("Нещо се обърка. Моля, опитайте отново по-късно.");
|
||||
@ -220,9 +250,9 @@ export default function AvailabilityForm({ publisherId, existingItems, inline, o
|
||||
availability.dateOfEntry = new Date();
|
||||
}
|
||||
|
||||
function createAvailabilityFromGroup(group) {
|
||||
function createAvailabilityFromGroup(group, publisherId) {
|
||||
let availability = {
|
||||
publisherId: publisher.id,
|
||||
publisherId: publisherId,
|
||||
dayofweek: common.getDayOfWeekNameEnEnumForDate(day),
|
||||
};
|
||||
|
||||
|
@ -556,6 +556,7 @@ const AvCalendar = ({ publisherId, events, selectedDate, cartEvents, lastPublish
|
||||
onDone={handleDialogClose}
|
||||
inline={true}
|
||||
cartEvent={cartEvent}
|
||||
lockedBeforeDate={editLockedBefore}
|
||||
// Pass other props as needed
|
||||
/>
|
||||
</div>
|
||||
|
@ -3,8 +3,9 @@ import Link from 'next/link';
|
||||
import common from 'src/helpers/common';
|
||||
import axiosInstance from 'src/axiosSecure';
|
||||
|
||||
const PublisherShiftsModal = ({ publisher, shifts, onClose, date }) => {
|
||||
const PublisherShiftsModal = ({ publisher, _shifts, onClose, date, onAssignmentChange }) => {
|
||||
|
||||
const [shifts, setShifts] = React.useState([..._shifts]);
|
||||
//Refactor ToDo: show the whole month instead of just the current week by showing the shift start time in front of the rows, and show all shifts in the month from the first to the last week in the cell where we show one shift now
|
||||
|
||||
const monthInfo = common.getMonthDatesInfo(new Date(date));
|
||||
@ -156,15 +157,13 @@ const addAssignment = async (publisher, shiftId) => {
|
||||
isConfirmed: true
|
||||
};
|
||||
const { data } = await axiosInstance.post("/api/data/assignments", newAssignment);
|
||||
if (selectedShiftId == shiftId) {
|
||||
handleShiftSelection(shifts.find(shift => shift.id === shiftId));
|
||||
}
|
||||
|
||||
// Update the 'publisher' property of the returned data with the full publisher object
|
||||
data.publisher = publisher;
|
||||
data.shift = shifts.find(shift => shift.id === shiftId);
|
||||
publisher.assignments = [...publisher.assignments, data];
|
||||
handleAssignmentChange(publisher.id, 'add');
|
||||
// handleAssignmentChange(publisher.id, 'add');
|
||||
if (onAssignmentChange) { onAssignmentChange(publisher.id, 'add'); }
|
||||
} catch (error) {
|
||||
console.error("Error adding assignment:", error);
|
||||
}
|
||||
@ -177,10 +176,14 @@ const removeAssignment = async (publisher, shiftId) => {
|
||||
//remove from local assignments:
|
||||
publisher.assignments = publisher.assignments.filter(a => a.id !== assignment.id)
|
||||
//
|
||||
handleAssignmentChange(publisher.id, 'remove')
|
||||
// handleAssignmentChange(publisher.id, 'remove')
|
||||
if (onAssignmentChange) {
|
||||
onAssignmentChange(publisher.id, 'remove')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error removing assignment:", error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default PublisherShiftsModal;
|
@ -158,7 +158,7 @@ export default function ReportForm({ shiftId, existingItem, onDone }) {
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<div className="mb-4">
|
||||
{/* <div className="mb-4">
|
||||
<label className="block text-gray-700 text-sm font-bold mb-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
@ -168,7 +168,7 @@ export default function ReportForm({ shiftId, existingItem, onDone }) {
|
||||
/>
|
||||
за целия ден
|
||||
</label>
|
||||
</div>
|
||||
</div> */}
|
||||
</div>
|
||||
|
||||
<div className="mb-4">
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "smws",
|
||||
"version": "1.3.0",
|
||||
"version": "1.3.5",
|
||||
"private": true,
|
||||
"description": "SMWS | ССОМ | Специално Свидетелстване София",
|
||||
"repository": "http://git.d-popov.com/popov/next-cart-app.git",
|
||||
|
@ -77,6 +77,10 @@ export const authOptions: NextAuthOptions = {
|
||||
{ id: "1", name: "admin", email: "admin@example.com", password: process.env.ADMIN_PASSWORD, role: "ADMIN", static: true }
|
||||
];
|
||||
|
||||
if (process.env.ADMIN_PASSWORD !== credentials.password) {
|
||||
throw new Error('невалидна парола');
|
||||
}
|
||||
|
||||
const user = users.find(user =>
|
||||
user.name === credentials.username && user.password === credentials.password
|
||||
);
|
||||
|
@ -882,9 +882,10 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
|
||||
{isModalOpen && (
|
||||
<PublisherShiftsModal
|
||||
publisher={modalPub}
|
||||
shifts={allShifts}
|
||||
_shifts={allShifts}
|
||||
onClose={() => setIsModalOpen(false)}
|
||||
date={value}
|
||||
onAssignmentChange={handleAssignmentChange}
|
||||
/>
|
||||
)}
|
||||
</ProtectedRoute >
|
||||
|
@ -9,7 +9,7 @@ import ProtectedRoute from '../../../components/protectedRoute';
|
||||
function NewPage(loc: Location) {
|
||||
return (
|
||||
<Layout>
|
||||
<ProtectedRoute allowedRoles={[UserRole.POWERUSER, UserRole.ADMIN]}>
|
||||
<ProtectedRoute allowedRoles={[UserRole.USER, UserRole.POWERUSER, UserRole.ADMIN]}>
|
||||
<div className="h-5/6 grid place-items-center">
|
||||
<ExperienceForm />
|
||||
</div></ProtectedRoute>
|
||||
|
@ -105,7 +105,12 @@ export default PDFViewerPage;
|
||||
|
||||
|
||||
export const getServerSideProps = async (context) => {
|
||||
const permitsFolder = '/public/content/permits/';
|
||||
const permitsFolder = path.join('public', 'content', 'permits');
|
||||
|
||||
// Create folders if they do not exist
|
||||
if (!fs.existsSync(permitsFolder)) {
|
||||
fs.mkdirSync(permitsFolder, { recursive: true });
|
||||
}
|
||||
//get all the files in the permits folder order them by date desc and display them
|
||||
const pdfFiles = fs.readdirSync(path.join(process.cwd(), permitsFolder)).map(file => {
|
||||
return {
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user