Skip to content

Commit

Permalink
added log activity
Browse files Browse the repository at this point in the history
  • Loading branch information
anurag6569201 committed Jul 28, 2024
1 parent 4bcea35 commit 24d4dfb
Show file tree
Hide file tree
Showing 26 changed files with 338 additions and 62 deletions.
6 changes: 0 additions & 6 deletions .env
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
GOOGLE_API_KEY=AIzaSyAh5HbTtCHsO_ZWAtCtn_q5h2_Jw7tEfe8
HUGGING_FACE_API_KEY=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

SMS_ACCOUNT_SSID_API_KEY=AC954136eee66cc8ba187c7722f5840d13
SMS_ACCOUNT_AUTH_API_KEY=d1501d7b07f1625cce8b4c46c1d5a8f1
SMS_FROM_NUMBER=+12085516281
Binary file modified db.sqlite3
Binary file not shown.
Binary file modified db/058716e8-2d51-48ec-abb6-cf4d1b0bf163/data_level0.bin
Binary file not shown.
Binary file modified db/058716e8-2d51-48ec-abb6-cf4d1b0bf163/header.bin
Binary file not shown.
Binary file modified db/058716e8-2d51-48ec-abb6-cf4d1b0bf163/index_metadata.pickle
Binary file not shown.
Binary file modified db/058716e8-2d51-48ec-abb6-cf4d1b0bf163/length.bin
Binary file not shown.
Binary file modified db/058716e8-2d51-48ec-abb6-cf4d1b0bf163/link_lists.bin
Binary file not shown.
Binary file modified db/chroma.sqlite3
Binary file not shown.
72 changes: 21 additions & 51 deletions dummy.csv
Original file line number Diff line number Diff line change
@@ -1,51 +1,21 @@
id,registration_number,type,available,condition,last_maintenance
1,MP01AB1234,Standard,True,Good,2024-06-15
2,MP02CD5678,Advanced Life Support,True,Good,2024-07-01
3,MP03EF9101,Standard,False,Needs Repair,2024-06-20
4,MP04GH2345,Advanced Life Support,True,Good,2024-07-05
5,MP05IJ6789,Standard,True,Good,2024-06-25
6,MP06KL0123,Advanced Life Support,False,Needs Repair,2024-06-30
7,MP07MN4567,Standard,True,Good,2024-07-01
8,MP08OP8901,Advanced Life Support,True,Good,2024-07-10
9,MP09QR2345,Standard,True,Needs Repair,2024-06-22
10,MP10ST6789,Advanced Life Support,True,Good,2024-07-03
11,MP11UV0123,Standard,False,Needs Repair,2024-06-28
12,MP12WX4567,Advanced Life Support,True,Good,2024-07-12
13,MP13YZ8901,Standard,True,Good,2024-07-08
14,MP14AB2345,Advanced Life Support,True,Good,2024-07-04
15,MP15CD6789,Standard,True,Needs Repair,2024-06-26
16,MP16EF0123,Advanced Life Support,True,Good,2024-07-09
17,MP17GH4567,Standard,False,Needs Repair,2024-07-02
18,MP18IJ8901,Advanced Life Support,True,Good,2024-07-07
19,MP19KL2345,Standard,True,Good,2024-06-29
20,MP20MN6789,Advanced Life Support,True,Needs Repair,2024-07-11
21,MP21OP0123,Standard,True,Good,2024-06-24
22,MP22QR4567,Advanced Life Support,False,Needs Repair,2024-07-06
23,MP23ST8901,Standard,True,Good,2024-07-02
24,MP24UV2345,Advanced Life Support,True,Good,2024-07-08
25,MP25WX6789,Standard,False,Needs Repair,2024-07-10
26,MP26YZ0123,Advanced Life Support,True,Good,2024-07-12
27,MP27AB4567,Standard,True,Good,2024-06-23
28,MP28CD8901,Advanced Life Support,True,Needs Repair,2024-07-01
29,MP29EF2345,Standard,True,Good,2024-07-05
30,MP30GH6789,Advanced Life Support,True,Good,2024-07-07
31,MP31IJ0123,Standard,False,Needs Repair,2024-07-03
32,MP32KL4567,Advanced Life Support,True,Good,2024-07-09
33,MP33MN8901,Standard,True,Good,2024-06-27
34,MP34OP2345,Advanced Life Support,True,Needs Repair,2024-07-11
35,MP35QR6789,Standard,True,Good,2024-06-28
36,MP36ST0123,Advanced Life Support,False,Needs Repair,2024-07-12
37,MP37UV4567,Standard,True,Good,2024-07-01
38,MP38WX8901,Advanced Life Support,True,Good,2024-07-10
39,MP39YZ2345,Standard,False,Needs Repair,2024-06-30
40,MP40AB6789,Advanced Life Support,True,Good,2024-07-08
41,MP41CD0123,Standard,True,Good,2024-07-05
42,MP42EF4567,Advanced Life Support,False,Needs Repair,2024-07-01
43,MP43GH8901,Standard,True,Good,2024-06-29
44,MP44IJ2345,Advanced Life Support,True,Good,2024-07-11
45,MP45KL6789,Standard,True,Needs Repair,2024-06-27
46,MP46MN0123,Advanced Life Support,True,Good,2024-07-03
47,MP47OP4567,Standard,False,Needs Repair,2024-06-25
48,MP48QR8901,Advanced Life Support,True,Good,2024-07-12
49,MP49ST2345,Standard,True,Good,2024-07-07
50,MP50UV6789,Advanced Life Support,True,Needs Repair,2024-07-10
id,machinery,hours_of_operation,description,status,due_date
1,Excavator,120,Routine maintenance check.,N,2024-07-28 01:37:17
2,Bulldozer,350,Oil change and filter replacement.,g,2024-07-29 10:15:00
3,Crane,5000,Complete overhaul.,N,2024-07-30 09:00:00
4,Loader,450,General maintenance.,g,2024-08-01 11:30:00
5,Dump Truck,1500,Brake inspection.,N,2024-08-03 14:20:00
6,Excavator,200,Hydraulic system check.,g,2024-08-05 13:25:00
7,Bulldozer,300,Engine tune-up.,N,2024-08-07 08:10:00
8,Crane,4200,Structural inspection.,g,2024-08-09 16:00:00
9,Loader,800,Transmission service.,N,2024-08-12 10:40:00
10,Dump Truck,2200,Exhaust system repair.,g,2024-08-15 12:00:00
11,Excavator,250,Undercarriage inspection.,N,2024-08-17 09:50:00
12,Bulldozer,350,Filter change.,g,2024-08-20 15:00:00
13,Crane,4800,Electrical system check.,N,2024-08-22 14:10:00
14,Loader,600,Coolant system service.,g,2024-08-25 11:30:00
15,Dump Truck,1800,Tire replacement.,N,2024-08-28 08:00:00
16,Excavator,300,Engine repair.,g,2024-08-30 10:15:00
17,Bulldozer,400,Hydraulic fluid change.,N,2024-09-02 13:00:00
18,Crane,4900,Maintenance and calibration.,g,2024-09-05 12:30:00
19,Loader,700,General inspection.,N,2024-09-08 15:00:00
20,Dump Truck,1600,Brake system check.,g,2024-09-10 09:45:00
Binary file modified maintain/__pycache__/admin.cpython-312.pyc
Binary file not shown.
Binary file modified maintain/__pycache__/models.cpython-312.pyc
Binary file not shown.
Binary file added maintain/__pycache__/sms_utility.cpython-312.pyc
Binary file not shown.
Binary file modified maintain/__pycache__/urls.cpython-312.pyc
Binary file not shown.
Binary file modified maintain/__pycache__/views.cpython-312.pyc
Binary file not shown.
8 changes: 7 additions & 1 deletion maintain/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
from django.contrib import admin
from .models import MaintenanceTask

# Register your models here.
from import_export.admin import ImportExportModelAdmin


class MaintenanceTaskAdmin(ImportExportModelAdmin):
list_display=['machinery','hours_of_operation','status']
admin.site.register(MaintenanceTask,MaintenanceTaskAdmin)
25 changes: 25 additions & 0 deletions maintain/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 5.0.7 on 2024-07-28 01:25

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='MaintenanceTask',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('machinery', models.CharField(max_length=100)),
('hours_of_operation', models.IntegerField()),
('description', models.TextField()),
('status', models.CharField(max_length=1)),
('due_date', models.DateTimeField()),
],
),
]
Binary file not shown.
12 changes: 11 additions & 1 deletion maintain/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
from django.db import models
from django.utils import timezone

# Create your models here.
class MaintenanceTask(models.Model):
machinery = models.CharField(max_length=100)
hours_of_operation = models.IntegerField()
description = models.TextField()
status = models.CharField(max_length=1)
due_date = models.DateTimeField()

def should_send_alert(self):
return self.due_date.date() == timezone.now().date()

18 changes: 18 additions & 0 deletions maintain/sms_utility.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from twilio.rest import Client
import os
from dotenv import load_dotenv
load_dotenv()
def send_sms_alert(task):
account_sid = os.getenv('SMS_ACCOUNT_SSID_API_KEY')
auth_token = os.getenv('SMS_ACCOUNT_AUTH_API_KEY')
client = Client(account_sid, auth_token)

message_body = f"Maintenance Alert: {task.machinery} requires attention. Task: {task.description}. Hours of Operation: {task.hours_of_operation}."

message = client.messages.create(
body=message_body,
from_='+1234567890',
to='+0987654321'
)

return message.sid
58 changes: 57 additions & 1 deletion maintain/static/maintain/css/maintain.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,60 @@
display: flex;
justify-content: right;
align-items: baseline;
}
}

/* timeline css */
/* Add this to your CSS file */
.timeline {
position: relative;
max-width: 1200px;
margin: 0 auto;
padding: 0 10px;
}

.timeline-item {
position: relative;
margin: 20px 0;
padding: 20px;
background: #f9f9f9;
border-radius: 5px;
}

.timeline-item::before {
content: '';
position: absolute;
left: 15px;
top: 20px;
width: 10px;
height: 10px;
border-radius: 50%;
background: #3498db;
}

.timeline-icon {
display: inline-block;
width: 40px;
height: 40px;
background: #3498db;
border-radius: 50%;
text-align: center;
line-height: 40px;
color: white;
margin-right: 15px;
}

.timeline-content {
display: inline-block;
vertical-align: top;
max-width: calc(100% - 70px);
}

.timeline-content h5 {
margin: 0;
font-size: 18px;
font-weight: bold;
}

.timeline-content p {
margin: 5px 0;
}
53 changes: 53 additions & 0 deletions maintain/templates/maintain/app/activity.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{% extends 'maintain/partial/base.html' %}
{% load static %}
{% block index %}

<div class="container-fluid">
<!-- Log Repair Activities Table Section -->
<div class="row">
<div class="col-md-12">
<div class="vehicle_para">
<h3>Log Repair Activities</h3>
<p>Track all repair activities including costs and downtime. Maintain records of repairs to monitor asset performance and costs.</p>

<!-- Table Display -->
<table class="table table-bordered">
<thead>
<tr>
<th>Machinery</th>
<th>Date</th>
<th>Hours of Operation</th>
<th>Description</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{% for repair in repair_activities %}
<tr>
<td>{{ repair.machinery }}</td>
<td>{{ repair.due_date }}</td>
<td>{{ repair.hours_of_operation }}</td>
<td>{{ repair.description }}</td>
<td>
{% if repair.status == 'Completed' %}
<span class="text-success">Completed</span>
{% elif repair.status == 'Pending' %}
<span class="text-warning">Pending</span>
{% else %}
<span class="text-muted">Unknown</span>
{% endif %}
</td>
</tr>
{% empty %}
<tr>
<td colspan="5">No repair activities logged.</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>

{% endblock index %}
4 changes: 2 additions & 2 deletions maintain/templates/maintain/app/maintain.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div class="vehicle_para">
<h3>Automated Reminders</h3>
<p>Set up automated reminders for routine maintenance tasks. Schedule periodic checks and alerts to ensure timely maintenance.</p>
<a class="view_list" href="">View Reminders</a>
<a class="view_list" href="{% url 'maintain:remainder' %}">View Reminders</a>
</div>
</div>
<div class="col-md-6 vehicle_para_img p-0" style="justify-content: center;">
Expand All @@ -23,7 +23,7 @@ <h3>Automated Reminders</h3>
<div class="vehicle_para">
<h3>Log Repair Activities</h3>
<p>Track all repair activities including costs and downtime.Maintain records of repairs to monitor asset performance and costs.</p>
<a class="view_list" href="">View Activities</a>
<a class="view_list" href="{% url 'maintain:repair' %}">View Activities</a>
</div>
</div>
</div>
Expand Down
78 changes: 78 additions & 0 deletions maintain/templates/maintain/app/remainder.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{% extends 'maintain/partial/base.html' %}
{% load static %}
{% block index %}
<!-- Reminders Section -->
<div class="row">
<div class="col-md-12">
<div class="vehicle_para">
<h3>Today's Tasks</h3>
<table class="table table-striped">
<thead>
<tr>
<th>Machinery</th>
<th>Hours of Operation</th>
<th>Description</th>
<th>Due Date</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{% for task in maintenance_tasks %}
<tr>
<td>{{ task.machinery }}</td>
<td>{{ task.hours_of_operation }}</td>
<td>{{ task.description }}</td>
<td>{{ task.due_date }}</td>
<td>
{% if task.status == 'N' %}
<span class="text-warning">Needs Attention</span>
{% elif task.status == 'g' %}
<span class="text-success">Good Condition</span>
{% endif %}
</td>
</tr>
{% empty %}
<tr>
<td colspan="4">No upcoming tasks.</td>
</tr>
{% endfor %}
</tbody>
</table>
<h3>Upcoming Maintenance Tasks</h3>
<table class="table table-striped">
<thead>
<tr>
<th>Machinery</th>
<th>Hours of Operation</th>
<th>Description</th>
<th>Due Date</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{% for task in future_tasks %}
<tr>
<td>{{ task.machinery }}</td>
<td>{{ task.hours_of_operation }}</td>
<td>{{ task.description }}</td>
<td>{{ task.due_date }}</td>
<td>
{% if task.status == 'N' %}
<span class="text-warning">Needs Attention</span>
{% elif task.status == 'g' %}
<span class="text-success">Good Condition</span>
{% endif %}
</td>
</tr>
{% empty %}
<tr>
<td colspan="4">No upcoming tasks.</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>

{% endblock index %}
Loading

0 comments on commit 24d4dfb

Please sign in to comment.