Skip to content

Commit

Permalink
Big fixes
Browse files Browse the repository at this point in the history
Frontend:
  - Fixed adaptivity on the home page

Backend:
  - Fixed get full list method for the applications
  - Added database.sql files for the database migration
  • Loading branch information
fet1sov committed May 29, 2024
1 parent db57ef7 commit be82d49
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 20 deletions.
43 changes: 43 additions & 0 deletions database.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
CREATE TABLE IF NOT EXISTS `role` (
`id` int NOT NULL COMMENT 'Role ID' AUTO_INCREMENT,
`name` varchar(255) NOT NULL COMMENT 'Role name',
`admin_rights` int COMMENT 'Admin rights',
`applications_list` int COMMENT 'Access to applications list',
PRIMARY KEY (`id`)
);

CREATE TABLE IF NOT EXISTS `user` (
`id` int NOT NULL COMMENT 'User ID' AUTO_INCREMENT,
`username` varchar(32) NOT NULL UNIQUE COMMENT 'Username',
`password` varchar(255) NOT NULL COMMENT 'Password MD5 Hash',
`company` varchar(255) DEFAULT NULL COMMENT 'Company name',
`email` varchar(128) NOT NULL UNIQUE COMMENT 'Contact e-mail',
`role_id` int DEFAULT NULL COMMENT 'Role ID',
FOREIGN KEY (`role_id`) REFERENCES `role`(`id`),
PRIMARY KEY (`id`)
);

CREATE TABLE IF NOT EXISTS `application_statuses` (
`id` int NOT NULL COMMENT 'Status ID' AUTO_INCREMENT,
`name` varchar(255) COMMENT 'Status name',
`color` int COMMENT 'Status',
PRIMARY KEY (`id`)
);

START TRANSACTION;
CREATE INDEX `idx_username` ON `user` (`username`);
CREATE INDEX `idx_email` ON `user` (`email`);
CREATE INDEX `idx_company` ON `user` (`company`);
COMMIT;

CREATE TABLE IF NOT EXISTS `applications` (
`id` int NOT NULL AUTO_INCREMENT,
`author_id` int DEFAULT NULL,
`manager_id` int DEFAULT NULL,
`status` int DEFAULT NULL,
`text` VARCHAR(2048),
FOREIGN KEY (`author_id`) REFERENCES `user`(`id`),
FOREIGN KEY (`manager_id`) REFERENCES `user`(`id`),
FOREIGN KEY (`status`) REFERENCES `application_statuses`(`id`),
PRIMARY KEY (`id`)
);
11 changes: 10 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ services:
depends_on:
- database
container_name: catalyst-server
restart: always
volumes:
- ./www:/var/www/html
- ./apache-conf.conf:/etc/apache2/sites-enabled/000-default.conf
Expand All @@ -21,10 +22,18 @@ services:
ports:
- "3306:3306"
container_name: catalyst-db

restart: always
environment:
MYSQL_DATABASE: catalyst
MYSQL_ALLOW_EMPTY_PASSWORD: true

phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
restart: always
ports:
- "8080:80"
environment:
PMA_HOST: database

volumes:
apache-logs:
Expand Down
3 changes: 1 addition & 2 deletions www/backend/models/application.mdl.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ public function __construct($id = 0, $applicationData = array()) {
}

public static function getFullList() {
$stmt = $GLOBALS["dbAdapter"]->prepare("SELECT * FROM `applications` INNER JOIN `applications_statuses` ON `applications`.`status` = `applications_statuses`.`id`");
$stmt = $GLOBALS["dbAdapter"]->prepare("SELECT * FROM `applications` INNER JOIN `application_statuses` ON `applications`.`status` = `application_statuses`.`id`");
$stmt->execute();
$stmt->store_result();

$applicationsResult = $stmt->get_result();
$applicationsRows = $applicationsResult->fetch_array(MYSQLI_ASSOC);
Expand Down
10 changes: 10 additions & 0 deletions www/backend/routes/index/index.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@
}

@media (max-width: 600px) {
section {
height: 120vh;
}

#contactForm {
display: flex;
flex-direction: column;
Expand All @@ -120,6 +124,12 @@
#aboutusBlock div.offers-block {
flex-direction: column;
}

.companies-list {
display: flex;
justify-content: center;
flex-direction: column;
}
}
</style>

Expand Down
35 changes: 18 additions & 17 deletions www/includes/wtframework/database/db_connect.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@
');
$stmt->execute();

$stmt = $GLOBALS["dbAdapter"]->prepare('
CREATE TABLE IF NOT EXISTS `application_statuses` (
`id` int NOT NULL COMMENT \'Status ID\' AUTO_INCREMENT,
`name` int COMMENT \'Status name\',
`color` int COMMENT \'Status\',
PRIMARY KEY (`id`)
);
');
$stmt->execute();

$stmt = $GLOBALS["dbAdapter"]->prepare('
CREATE TABLE IF NOT EXISTS `user` (
`id` int NOT NULL COMMENT \'User ID\' AUTO_INCREMENT,
Expand All @@ -45,7 +35,17 @@
`company` varchar(255) DEFAULT NULL COMMENT \'Company name\',
`email` varchar(128) NOT NULL UNIQUE COMMENT \'Contact e-mail\',
`role_id` int DEFAULT NULL COMMENT \'Role ID\',
FOREIGN KEY (`role_id`) REFERENCES `role`(`id`),
FOREIGN KEY (`role_id`) REFERENCES `role`(`id`),
PRIMARY KEY (`id`)
);
');
$stmt->execute();

$stmt = $GLOBALS["dbAdapter"]->prepare('
CREATE TABLE IF NOT EXISTS `application_statuses` (
`id` int NOT NULL COMMENT \'Status ID\' AUTO_INCREMENT,
`name` varchar(255) COMMENT \'Status name\',
`color` int COMMENT \'Status\',
PRIMARY KEY (`id`)
);
');
Expand All @@ -60,21 +60,22 @@
');
$stmt->execute();

$stmt = $GLOBALS["dbAdapter"]->prepare('
$GLOBALS["dbAdapter"]->query('
CREATE TABLE IF NOT EXISTS `applications` (
`id` int NOT NULL COMMENT \'Application ID\' AUTO_INCREMENT,
`author_id` int NOT NULL COMMENT \'Application author ID\',
`manager_id` int DEFAULT NULL COMMENT \'Manager ID\',
`status` int DEFAULT NULL COMMENT \'Status\',
`id` int NOT NULL AUTO_INCREMENT,
`author_id` int DEFAULT NULL,
`manager_id` int DEFAULT NULL,
`status` int DEFAULT NULL,
`text` VARCHAR(2048),
FOREIGN KEY (`author_id`) REFERENCES `user`(`id`),
FOREIGN KEY (`manager_id`) REFERENCES `user`(`id`),
FOREIGN KEY (`status`) REFERENCES `application_statuses`(`id`),
PRIMARY KEY (`id`)
);
');
$stmt->execute();

/* Creating admin role */

$stmt = $GLOBALS["dbAdapter"]->prepare('INSERT INTO `role`(`name`, `admin_right`, `applications_list`) VALUES(\'administrator\', \'1\', \'1\')');
$stmt->execute();

Expand Down

0 comments on commit be82d49

Please sign in to comment.