Compliance list done.
Except for the cleanup of the hearing import data, This is the first version.
This commit is contained in:
parent
2b5cf93ece
commit
e4783bc64e
DB
luthor
otis/src/app
app-routing.module.ts
cause-list
compliance-list
compliance-list-datasource.tscompliance-list-item.tscompliance-list-resolver.service.spec.tscompliance-list-resolver.service.tscompliance-list-routing.module.spec.tscompliance-list-routing.module.tscompliance-list.component.csscompliance-list.component.htmlcompliance-list.component.spec.tscompliance-list.component.tscompliance-list.module.spec.tscompliance-list.module.tscompliance-list.service.spec.tscompliance-list.service.tscompliance-list.ts
nav-bar
@ -30,3 +30,8 @@ docker run -it -v /home/tanshu/Programming/luthor/DB/csv:/mnt --link postgres:db
|
||||
sed -i 's/\x0//g' /home/tanshu/Programming/luthor/DB/csv/o-hearings.csv
|
||||
docker run -it -v /home/tanshu/Programming/luthor/DB/csv:/mnt --link postgres:db --rm --env PGPASSWORD="123456" postgres:alpine bash -c 'psql -h db -U postgres luthor -c "\copy hearings(old_id, old_case_id, bench, proceedings, next_hearing_date, old_court_status_id, court_number, item_number) from /mnt/o-hearings.csv with delimiter E'\''\t'\'' null as '\'''\''"'
|
||||
alembic upgrade 87a06eaadd34
|
||||
|
||||
# To filter out bad hearings which will now not import
|
||||
# select cs.name, c.office_file_number, ch.next_hearing_date from (select case_id, next_hearing_date from hearings group by case_id, next_hearing_date having count(*) > 1) as ch inner join cases c on ch.case_id = c.id inner join case_sources cs on c.case_source_id = cs.id order by next_hearing_date desc;
|
||||
# Temp fix to delete hearings
|
||||
# delete from hearings where next_hearing_date is null;
|
@ -172,16 +172,16 @@ def upgrade():
|
||||
sa.Column("year", sa.Unicode(length=255), nullable=False),
|
||||
sa.Column("title", sa.Unicode(length=255), nullable=True),
|
||||
sa.Column("docket_number", sa.Unicode(length=255), nullable=True),
|
||||
sa.Column("receipt_date", sa.DateTime(), nullable=True),
|
||||
sa.Column("limitation_date", sa.DateTime(), nullable=True),
|
||||
sa.Column("filing_date", sa.DateTime(), nullable=True),
|
||||
sa.Column("receipt_date", sa.Date(), nullable=True),
|
||||
sa.Column("limitation_date", sa.Date(), nullable=True),
|
||||
sa.Column("filing_date", sa.Date(), nullable=True),
|
||||
sa.Column("appear_on_behalf_of", sa.Unicode(length=255), nullable=True),
|
||||
sa.Column("question_of_law", sa.Unicode(length=4000), nullable=True),
|
||||
sa.Column("aor_name", sa.Unicode(length=255), nullable=True),
|
||||
sa.Column("opposing_council_aor", sa.Unicode(length=255), nullable=True),
|
||||
sa.Column("opposing_council_detail", sa.Unicode(length=255), nullable=True),
|
||||
sa.Column("lower_court_case_number", sa.Unicode(length=2000), nullable=True),
|
||||
sa.Column("date_of_impugned_judgement", sa.DateTime(), nullable=True),
|
||||
sa.Column("date_of_impugned_judgement", sa.Date(), nullable=True),
|
||||
sa.Column("brief_description", sa.Unicode(length=10000), nullable=True),
|
||||
sa.Column("remarks", sa.Unicode(length=10000), nullable=True),
|
||||
sa.Column("slp_counter", sa.Unicode(length=255), nullable=True),
|
||||
@ -255,8 +255,9 @@ def upgrade():
|
||||
sa.Column("item_number", sa.Unicode(length=255), nullable=True),
|
||||
sa.Column("bench", sa.Unicode(length=255), nullable=True),
|
||||
sa.Column("proceedings", sa.Unicode(length=2000), nullable=True),
|
||||
sa.Column("compliance_date", sa.DateTime(), nullable=True),
|
||||
sa.Column("next_hearing_date", sa.DateTime(), nullable=False),
|
||||
sa.Column("compliance_date", sa.Date(), nullable=True),
|
||||
# sa.Column("next_hearing_date", sa.Date(), nullable=False),
|
||||
sa.Column("next_hearing_date", sa.Date(), nullable=True),
|
||||
sa.Column("court_status_id", postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.Column("old_court_status_id", sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(["case_id"], ["cases.id"], name=op.f("fk_hearings_case_id_cases")),
|
||||
@ -264,7 +265,7 @@ def upgrade():
|
||||
["court_status_id"], ["court_statuses.id"], name=op.f("fk_hearings_court_status_id_court_statuses")
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id", name=op.f("pk_hearings")),
|
||||
sa.UniqueConstraint("next_hearing_date", "case_id", name=op.f("uq_hearings_next_hearing_date")),
|
||||
# sa.UniqueConstraint("next_hearing_date", "case_id", name=op.f("uq_hearings_next_hearing_date")),
|
||||
)
|
||||
op.create_index(op.f("ix_hearings_case_id"), "hearings", ["case_id"], unique=False)
|
||||
op.create_index(op.f("ix_hearings_next_hearing_date"), "hearings", ["next_hearing_date"], unique=False)
|
||||
|
@ -13,6 +13,7 @@ from .routers import (
|
||||
case_source,
|
||||
case_type,
|
||||
cause_list,
|
||||
compliance_list,
|
||||
contact,
|
||||
court,
|
||||
court_status,
|
||||
@ -43,6 +44,7 @@ app.include_router(cause_list.router, prefix="/api/cause-list", tags=["cases"])
|
||||
app.include_router(case.router, prefix="/api/cases", tags=["cases"])
|
||||
app.include_router(case_source.router, prefix="/api/case-sources", tags=["case-sources"])
|
||||
app.include_router(case_type.router, prefix="/api/case-types", tags=["case-types"])
|
||||
app.include_router(compliance_list.router, prefix="/api/compliance-list", tags=["cases"])
|
||||
app.include_router(contact.router, prefix="/api/contacts", tags=["contacts"])
|
||||
app.include_router(court.router, prefix="/api/courts", tags=["courts"])
|
||||
app.include_router(court_status.router, prefix="/api/court-statuses", tags=["court-status"])
|
||||
|
@ -1,7 +1,7 @@
|
||||
import uuid
|
||||
|
||||
from luthor.models.hearing import Hearing
|
||||
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Unicode, desc, text
|
||||
from sqlalchemy import Boolean, Column, Date, ForeignKey, Unicode, desc, text
|
||||
from sqlalchemy.dialects.postgresql import UUID
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.sql import expression
|
||||
@ -20,16 +20,16 @@ class Case(Base):
|
||||
year = Column("year", Unicode(255), nullable=False, unique=True)
|
||||
title = Column("title", Unicode(255), nullable=False, unique=True)
|
||||
docket_number = Column("docket_number", Unicode(255), nullable=False, unique=True)
|
||||
receipt_date = Column("receipt_date", DateTime, nullable=False, index=True)
|
||||
limitation_date = Column("limitation_date", DateTime, nullable=False, index=True)
|
||||
filing_date = Column("filing_date", DateTime, nullable=False, index=True)
|
||||
receipt_date = Column("receipt_date", Date, nullable=False, index=True)
|
||||
limitation_date = Column("limitation_date", Date, nullable=False, index=True)
|
||||
filing_date = Column("filing_date", Date, nullable=False, index=True)
|
||||
appear_on_behalf_of = Column("appear_on_behalf_of", Unicode(255), nullable=False, unique=True)
|
||||
question_of_law = Column("question_of_law", Unicode(255), nullable=False, unique=True)
|
||||
aor_name = Column("aor_name", Unicode(255), nullable=False, unique=True)
|
||||
opposing_council_aor = Column("opposing_council_aor", Unicode(255), nullable=False, unique=True)
|
||||
opposing_council_detail = Column("opposing_council_detail", Unicode(255), nullable=False)
|
||||
lower_court_case_number = Column("lower_court_case_number", Unicode(255), nullable=False, unique=True)
|
||||
date_of_impugned_judgement = Column("date_of_impugned_judgement", DateTime, nullable=False, index=True)
|
||||
date_of_impugned_judgement = Column("date_of_impugned_judgement", Date, nullable=False, index=True)
|
||||
brief_description = Column("brief_description", Unicode(255), nullable=False, unique=True)
|
||||
remarks = Column("remarks", Unicode(255), nullable=False, unique=True)
|
||||
slp_counter = Column("slp_counter", Unicode(255), nullable=False, unique=True)
|
||||
|
@ -1,6 +1,6 @@
|
||||
import uuid
|
||||
|
||||
from sqlalchemy import Column, DateTime, ForeignKey, Unicode, text
|
||||
from sqlalchemy import Column, Date, ForeignKey, Unicode, text
|
||||
from sqlalchemy.dialects.postgresql import UUID
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
@ -24,8 +24,8 @@ class Hearing(Base):
|
||||
item_number = Column("item_number", Unicode(255), nullable=False, unique=True)
|
||||
bench = Column("bench", Unicode(255), nullable=False, unique=True)
|
||||
proceedings = Column("proceedings", Unicode(255), nullable=False, unique=True)
|
||||
next_hearing_date = Column("next_hearing_date", DateTime, nullable=False, index=True)
|
||||
compliance_date = Column("compliance_date", DateTime, nullable=False, index=True)
|
||||
next_hearing_date = Column("next_hearing_date", Date, nullable=False, index=True)
|
||||
compliance_date = Column("compliance_date", Date, nullable=False, index=True)
|
||||
court_status_id = Column("court_status_id", UUID(as_uuid=True), ForeignKey("court_statuses.id"), nullable=True)
|
||||
|
||||
court_status = relationship("CourtStatus", back_populates="hearings")
|
||||
|
@ -259,7 +259,7 @@ def case_info(item: Case) -> schemas.Case:
|
||||
title=item.title if item.title is not None else "",
|
||||
docketNumber=item.docket_number if item.docket_number is not None else "",
|
||||
receiptDate=item.receipt_date,
|
||||
limitation_date=item.limitation_date,
|
||||
limitationDate=item.limitation_date,
|
||||
filingDate=item.filing_date,
|
||||
appearOnBehalfOf=item.appear_on_behalf_of if item.appear_on_behalf_of is not None else "",
|
||||
questionOfLaw=item.question_of_law if item.question_of_law is not None else "",
|
||||
|
@ -3,7 +3,7 @@ from datetime import date, datetime
|
||||
import luthor.schemas.case as schemas
|
||||
import luthor.schemas.cause_list as cl_schemas
|
||||
|
||||
from fastapi import APIRouter, Depends, Request, Security
|
||||
from fastapi import APIRouter, Depends, Security
|
||||
from luthor.models.hearing import Hearing
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
@ -27,7 +27,6 @@ def get_db():
|
||||
|
||||
@router.get("", response_model=cl_schemas.CauseList)
|
||||
def report_blank(
|
||||
request: Request,
|
||||
s: str = None,
|
||||
f: str = None,
|
||||
db: Session = Depends(get_db),
|
||||
|
66
luthor/luthor/routers/compliance_list.py
Normal file
66
luthor/luthor/routers/compliance_list.py
Normal file
@ -0,0 +1,66 @@
|
||||
from datetime import date, datetime
|
||||
from typing import List
|
||||
|
||||
import luthor.schemas.compliance_list as schemas
|
||||
|
||||
from fastapi import APIRouter, Depends, Security
|
||||
from luthor.models.hearing import Hearing
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from ..core.security import get_current_active_user as get_user
|
||||
from ..db.session import SessionLocal
|
||||
from ..models.case import Case
|
||||
from ..schemas.user_token import UserToken
|
||||
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
# Dependency
|
||||
def get_db():
|
||||
try:
|
||||
db = SessionLocal()
|
||||
yield db
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
@router.get("", response_model=schemas.ComplianceList)
|
||||
def report_blank(
|
||||
d: str = None,
|
||||
db: Session = Depends(get_db),
|
||||
user: UserToken = Security(get_user, scopes=["cases"]),
|
||||
) -> schemas.ComplianceList:
|
||||
d = date.today() if d is None else datetime.strptime(d, "%d-%b-%Y").date()
|
||||
return schemas.ComplianceList(
|
||||
date=d,
|
||||
items=get_items(d, db),
|
||||
)
|
||||
|
||||
|
||||
def get_items(d: date, db: Session) -> List[schemas.ComplianceListItem]:
|
||||
items = [
|
||||
case_info(item, d)
|
||||
for item in db.query(Case)
|
||||
.join(Case.hearings)
|
||||
.filter(Hearing.compliance_date >= d)
|
||||
.order_by(Hearing.compliance_date)
|
||||
.all()
|
||||
]
|
||||
return [item for sublist in items for item in sublist]
|
||||
|
||||
|
||||
def case_info(item: Case, date_: date) -> List[schemas.ComplianceListItem]:
|
||||
return [
|
||||
schemas.ComplianceListItem(
|
||||
id=item.id,
|
||||
officeFileNumber=f"{item.case_source.prefix}-{item.office_file_number}",
|
||||
courtNumber=h.court_number if h.court_number is not None else "",
|
||||
itemNumber=h.item_number if h.item_number is not None else "",
|
||||
title=item.title,
|
||||
proceedings=h.proceedings if h.proceedings is not None else "",
|
||||
complianceDate=h.compliance_date,
|
||||
)
|
||||
for h in item.hearings
|
||||
if h.compliance_date is not None and h.compliance_date >= date_
|
||||
]
|
45
luthor/luthor/schemas/compliance_list.py
Normal file
45
luthor/luthor/schemas/compliance_list.py
Normal file
@ -0,0 +1,45 @@
|
||||
import uuid
|
||||
|
||||
from datetime import date, datetime
|
||||
from typing import List
|
||||
|
||||
from pydantic import BaseModel, validator
|
||||
|
||||
from . import to_camel
|
||||
|
||||
|
||||
class ComplianceListItem(BaseModel):
|
||||
id_: uuid.UUID
|
||||
office_file_number: str
|
||||
court_number: str
|
||||
item_number: str
|
||||
title: str
|
||||
proceedings: str
|
||||
compliance_date: date
|
||||
|
||||
class Config:
|
||||
anystr_strip_whitespace = True
|
||||
alias_generator = to_camel
|
||||
json_encoders = {date: lambda v: v.strftime("%d-%b-%Y")}
|
||||
|
||||
@validator("compliance_date", pre=True)
|
||||
def parse_compliance_date(cls, value):
|
||||
if isinstance(value, date):
|
||||
return value
|
||||
return datetime.strptime(value, "%d-%b-%Y").date()
|
||||
|
||||
|
||||
class ComplianceList(BaseModel):
|
||||
date_: date
|
||||
items: List[ComplianceListItem]
|
||||
|
||||
class Config:
|
||||
anystr_strip_whitespace = True
|
||||
alias_generator = to_camel
|
||||
json_encoders = {date: lambda v: v.strftime("%d-%b-%Y")}
|
||||
|
||||
@validator("date_", pre=True)
|
||||
def parse_date(cls, value):
|
||||
if isinstance(value, date):
|
||||
return value
|
||||
return datetime.strptime(value, "%d-%b-%Y").date()
|
@ -30,6 +30,11 @@ const routes: Routes = [
|
||||
path: 'cases',
|
||||
loadChildren: () => import('./cases/cases.module').then((mod) => mod.CasesModule),
|
||||
},
|
||||
{
|
||||
path: 'compliance-list',
|
||||
loadChildren: () =>
|
||||
import('./compliance-list/compliance-list.module').then((mod) => mod.ComplianceListModule),
|
||||
},
|
||||
{
|
||||
path: 'contacts',
|
||||
loadChildren: () => import('./contacts/contacts.module').then((mod) => mod.ContactsModule),
|
||||
|
@ -1,10 +1,6 @@
|
||||
<mat-card>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>Cases</mat-card-title>
|
||||
<a mat-button [routerLink]="['/cases', 'new']">
|
||||
<mat-icon>add_box</mat-icon>
|
||||
Add
|
||||
</a>
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<form [formGroup]="form" fxLayout="column">
|
||||
@ -15,7 +11,7 @@
|
||||
fxLayoutGap.lt-md="0px"
|
||||
fxLayoutAlign="space-around start"
|
||||
>
|
||||
<mat-form-field fxFlex="40">
|
||||
<mat-form-field fxFlex="40%">
|
||||
<input
|
||||
matInput
|
||||
[matDatepicker]="startDate"
|
||||
@ -27,7 +23,7 @@
|
||||
<mat-datepicker-toggle matSuffix [for]="startDate"></mat-datepicker-toggle>
|
||||
<mat-datepicker #startDate></mat-datepicker>
|
||||
</mat-form-field>
|
||||
<mat-form-field fxFlex="40">
|
||||
<mat-form-field fxFlex="40%">
|
||||
<input
|
||||
matInput
|
||||
[matDatepicker]="finishDate"
|
||||
@ -39,7 +35,7 @@
|
||||
<mat-datepicker-toggle matSuffix [for]="finishDate"></mat-datepicker-toggle>
|
||||
<mat-datepicker #finishDate></mat-datepicker>
|
||||
</mat-form-field>
|
||||
<button mat-raised-button color="primary" (click)="show()" fxFlex="20c">Show</button>
|
||||
<button mat-raised-button color="primary" (click)="show()" fxFlex="20%">Show</button>
|
||||
</div>
|
||||
</form>
|
||||
<mat-table #table [dataSource]="dataSource" aria-label="Elements">
|
||||
|
@ -49,7 +49,6 @@ export class CauseListComponent implements OnInit {
|
||||
const data = value as { info: CauseList };
|
||||
|
||||
this.info = data.info;
|
||||
console.log(this.info.cases);
|
||||
this.form.setValue({
|
||||
startDate: moment(this.info.startDate, 'DD-MMM-YYYY').toDate(),
|
||||
finishDate: moment(this.info.finishDate, 'DD-MMM-YYYY').toDate(),
|
||||
|
42
otis/src/app/compliance-list/compliance-list-datasource.ts
Normal file
42
otis/src/app/compliance-list/compliance-list-datasource.ts
Normal file
@ -0,0 +1,42 @@
|
||||
import { DataSource } from '@angular/cdk/collections';
|
||||
import { EventEmitter } from '@angular/core';
|
||||
import { MatPaginator, PageEvent } from '@angular/material/paginator';
|
||||
import { merge, Observable, of as observableOf } from 'rxjs';
|
||||
import { map, tap } from 'rxjs/operators';
|
||||
|
||||
import { ComplianceListItem } from './compliance-list-item';
|
||||
|
||||
export class ComplianceListDatasource extends DataSource<ComplianceListItem> {
|
||||
constructor(public data: ComplianceListItem[], private paginator?: MatPaginator) {
|
||||
super();
|
||||
}
|
||||
|
||||
connect(): Observable<ComplianceListItem[]> {
|
||||
const dataMutations: (Observable<ComplianceListItem[]> | EventEmitter<PageEvent>)[] = [
|
||||
observableOf(this.data),
|
||||
];
|
||||
if (this.paginator) {
|
||||
dataMutations.push((this.paginator as MatPaginator).page);
|
||||
}
|
||||
|
||||
return merge(...dataMutations)
|
||||
.pipe(
|
||||
tap((x: ComplianceListItem[]) => {
|
||||
if (this.paginator) {
|
||||
this.paginator.length = x.length;
|
||||
}
|
||||
}),
|
||||
)
|
||||
.pipe(map((x: ComplianceListItem[]) => this.getPagedData(this.data)));
|
||||
}
|
||||
|
||||
disconnect() {}
|
||||
|
||||
private getPagedData(data: ComplianceListItem[]) {
|
||||
if (this.paginator === undefined) {
|
||||
return data;
|
||||
}
|
||||
const startIndex = this.paginator.pageIndex * this.paginator.pageSize;
|
||||
return data.slice(startIndex, startIndex + this.paginator.pageSize);
|
||||
}
|
||||
}
|
20
otis/src/app/compliance-list/compliance-list-item.ts
Normal file
20
otis/src/app/compliance-list/compliance-list-item.ts
Normal file
@ -0,0 +1,20 @@
|
||||
export class ComplianceListItem {
|
||||
id: string;
|
||||
officeFileNumber: string;
|
||||
courtNumber: string;
|
||||
itemNumber: string;
|
||||
title: string;
|
||||
proceedings: string;
|
||||
complianceDate: string;
|
||||
|
||||
public constructor(init?: Partial<ComplianceListItem>) {
|
||||
this.id = '';
|
||||
this.officeFileNumber = '';
|
||||
this.courtNumber = '';
|
||||
this.itemNumber = '';
|
||||
this.title = '';
|
||||
this.proceedings = '';
|
||||
this.complianceDate = '';
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ComplianceListResolver } from './compliance-list-resolver.service';
|
||||
|
||||
describe('ComplianceListResolverService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [ComplianceListResolver],
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([ComplianceListResolver], (service: ComplianceListResolver) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
@ -0,0 +1,18 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
|
||||
import { ComplianceList } from './compliance-list';
|
||||
import { ComplianceListService } from './compliance-list.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ComplianceListResolver implements Resolve<ComplianceList> {
|
||||
constructor(private ser: ComplianceListService) {}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<ComplianceList> {
|
||||
const date = route.queryParamMap.get('date') || null;
|
||||
return this.ser.list(date);
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
import { ComplianceListRoutingModule } from './compliance-list-routing.module';
|
||||
|
||||
describe('ComplianceListRoutingModule', () => {
|
||||
let complianceListRoutingModule: ComplianceListRoutingModule;
|
||||
|
||||
beforeEach(() => {
|
||||
complianceListRoutingModule = new ComplianceListRoutingModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(complianceListRoutingModule).toBeTruthy();
|
||||
});
|
||||
});
|
@ -0,0 +1,29 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
|
||||
import { ComplianceListResolver } from './compliance-list-resolver.service';
|
||||
import { ComplianceListComponent } from './compliance-list.component';
|
||||
const advocatesRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: ComplianceListComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Cases',
|
||||
},
|
||||
resolve: {
|
||||
info: ComplianceListResolver,
|
||||
},
|
||||
runGuardsAndResolvers: 'always',
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [CommonModule, RouterModule.forChild(advocatesRoutes)],
|
||||
exports: [RouterModule],
|
||||
providers: [ComplianceListResolver],
|
||||
})
|
||||
export class ComplianceListRoutingModule {}
|
68
otis/src/app/compliance-list/compliance-list.component.html
Normal file
68
otis/src/app/compliance-list/compliance-list.component.html
Normal file
@ -0,0 +1,68 @@
|
||||
<mat-card>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>Compliances</mat-card-title>
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<form [formGroup]="form" fxLayout="column">
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
fxLayoutAlign="space-around start"
|
||||
>
|
||||
<mat-form-field fxFlex="60%">
|
||||
<input
|
||||
matInput
|
||||
[matDatepicker]="date"
|
||||
(focus)="date.open()"
|
||||
placeholder="Date"
|
||||
formControlName="date"
|
||||
autocomplete="off"
|
||||
/>
|
||||
<mat-datepicker-toggle matSuffix [for]="date"></mat-datepicker-toggle>
|
||||
<mat-datepicker #date></mat-datepicker>
|
||||
</mat-form-field>
|
||||
<button mat-raised-button color="primary" (click)="show()" fxFlex="40%">Show</button>
|
||||
</div>
|
||||
</form>
|
||||
<mat-table #table [dataSource]="dataSource" aria-label="Elements">
|
||||
<!-- Office File Number Column -->
|
||||
<ng-container matColumnDef="officeFileNumber">
|
||||
<mat-header-cell *matHeaderCellDef>File No.</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row"
|
||||
><a [routerLink]="['/cases', row.id]">{{ row.officeFileNumber }}</a></mat-cell
|
||||
>
|
||||
</ng-container>
|
||||
|
||||
<!-- Title Column -->
|
||||
<ng-container matColumnDef="title">
|
||||
<mat-header-cell *matHeaderCellDef>Title</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.title }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Proceedings Column -->
|
||||
<ng-container matColumnDef="proceedings">
|
||||
<mat-header-cell *matHeaderCellDef>Proceedings</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.proceedings }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Compliance Date Column -->
|
||||
<ng-container matColumnDef="complianceDate">
|
||||
<mat-header-cell *matHeaderCellDef>Compliance Date</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.complianceDate }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
|
||||
</mat-table>
|
||||
<mat-paginator
|
||||
#paginator
|
||||
[length]="0"
|
||||
[pageIndex]="0"
|
||||
[pageSize]="10"
|
||||
[pageSizeOptions]="[10, 25, 50, 100, 250]"
|
||||
>
|
||||
</mat-paginator>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
@ -0,0 +1,22 @@
|
||||
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ComplianceListComponent } from './compliance-list.component';
|
||||
|
||||
describe('ComplianceListComponent', () => {
|
||||
let component: ComplianceListComponent;
|
||||
let fixture: ComponentFixture<ComplianceListComponent>;
|
||||
|
||||
beforeEach(fakeAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ComplianceListComponent],
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(ComplianceListComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
it('should compile', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
58
otis/src/app/compliance-list/compliance-list.component.ts
Normal file
58
otis/src/app/compliance-list/compliance-list.component.ts
Normal file
@ -0,0 +1,58 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import * as moment from 'moment';
|
||||
|
||||
import { ComplianceList } from './compliance-list';
|
||||
import { ComplianceListDatasource } from './compliance-list-datasource';
|
||||
|
||||
@Component({
|
||||
selector: 'app-compliance-list',
|
||||
templateUrl: './compliance-list.component.html',
|
||||
styleUrls: ['./compliance-list.component.css'],
|
||||
})
|
||||
export class ComplianceListComponent implements OnInit {
|
||||
@ViewChild(MatPaginator, { static: true }) paginator?: MatPaginator;
|
||||
form: FormGroup;
|
||||
info: ComplianceList = new ComplianceList();
|
||||
dataSource: ComplianceListDatasource = new ComplianceListDatasource(this.info.items);
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['officeFileNumber', 'title', 'proceedings', 'complianceDate'];
|
||||
|
||||
constructor(private route: ActivatedRoute, private router: Router, private fb: FormBuilder) {
|
||||
// Create form
|
||||
this.form = this.fb.group({
|
||||
date: '',
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data.subscribe((value) => {
|
||||
const data = value as { info: ComplianceList };
|
||||
|
||||
this.info = data.info;
|
||||
this.form.setValue({
|
||||
date: moment(this.info.date, 'DD-MMM-YYYY').toDate(),
|
||||
});
|
||||
this.dataSource = new ComplianceListDatasource(this.info.items, this.paginator);
|
||||
});
|
||||
}
|
||||
|
||||
show() {
|
||||
const info = this.getInfo();
|
||||
this.router.navigate(['compliance-list'], {
|
||||
queryParams: {
|
||||
date: info.date,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
getInfo(): ComplianceList {
|
||||
const formModel = this.form.value;
|
||||
|
||||
return new ComplianceList({
|
||||
date: moment(formModel.date).format('DD-MMM-YYYY'),
|
||||
});
|
||||
}
|
||||
}
|
13
otis/src/app/compliance-list/compliance-list.module.spec.ts
Normal file
13
otis/src/app/compliance-list/compliance-list.module.spec.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { ComplianceListModule } from './compliance-list.module';
|
||||
|
||||
describe('ComplianceListModule', () => {
|
||||
let complianceListModule: ComplianceListModule;
|
||||
|
||||
beforeEach(() => {
|
||||
complianceListModule = new ComplianceListModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(complianceListModule).toBeTruthy();
|
||||
});
|
||||
});
|
63
otis/src/app/compliance-list/compliance-list.module.ts
Normal file
63
otis/src/app/compliance-list/compliance-list.module.ts
Normal file
@ -0,0 +1,63 @@
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { MomentDateAdapter } from '@angular/material-moment-adapter';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import {
|
||||
DateAdapter,
|
||||
MAT_DATE_FORMATS,
|
||||
MAT_DATE_LOCALE,
|
||||
MatNativeDateModule,
|
||||
} from '@angular/material/core';
|
||||
import { MatDatepickerModule } from '@angular/material/datepicker';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatPaginatorModule } from '@angular/material/paginator';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
|
||||
import { ComplianceListRoutingModule } from './compliance-list-routing.module';
|
||||
import { ComplianceListComponent } from './compliance-list.component';
|
||||
|
||||
export const MY_FORMATS = {
|
||||
parse: {
|
||||
dateInput: 'DD-MMM-YYYY',
|
||||
},
|
||||
display: {
|
||||
dateInput: 'DD-MMM-YYYY',
|
||||
monthYearLabel: 'MMM YYYY',
|
||||
dateA11yLabel: 'DD-MMM-YYYY',
|
||||
monthYearA11yLabel: 'MMM YYYY',
|
||||
},
|
||||
};
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
CdkTableModule,
|
||||
FlexLayoutModule,
|
||||
MatButtonModule,
|
||||
MatCardModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatTableModule,
|
||||
ReactiveFormsModule,
|
||||
ComplianceListRoutingModule,
|
||||
MatSelectModule,
|
||||
MatPaginatorModule,
|
||||
MatDatepickerModule,
|
||||
MatDialogModule,
|
||||
],
|
||||
declarations: [ComplianceListComponent],
|
||||
providers: [
|
||||
{ provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE] },
|
||||
{ provide: MAT_DATE_FORMATS, useValue: MY_FORMATS },
|
||||
],
|
||||
})
|
||||
export class ComplianceListModule {}
|
15
otis/src/app/compliance-list/compliance-list.service.spec.ts
Normal file
15
otis/src/app/compliance-list/compliance-list.service.spec.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ComplianceListService } from './compliance-list.service';
|
||||
|
||||
describe('ComplianceListService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [ComplianceListService],
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([ComplianceListService], (service: ComplianceListService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
28
otis/src/app/compliance-list/compliance-list.service.ts
Normal file
28
otis/src/app/compliance-list/compliance-list.service.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
|
||||
import { ComplianceList } from './compliance-list';
|
||||
|
||||
const url = '/api/compliance-list';
|
||||
const serviceName = 'ComplianceListService';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ComplianceListService {
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
|
||||
|
||||
list(date: string | null): Observable<ComplianceList> {
|
||||
const options = { params: new HttpParams() };
|
||||
if (date !== null) {
|
||||
options.params = options.params.set('d', date);
|
||||
}
|
||||
return this.http
|
||||
.get<ComplianceList>(url, options)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<ComplianceList>;
|
||||
}
|
||||
}
|
12
otis/src/app/compliance-list/compliance-list.ts
Normal file
12
otis/src/app/compliance-list/compliance-list.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { ComplianceListItem } from './compliance-list-item';
|
||||
|
||||
export class ComplianceList {
|
||||
date: string;
|
||||
items: ComplianceListItem[];
|
||||
|
||||
public constructor(init?: Partial<ComplianceList>) {
|
||||
this.date = '';
|
||||
this.items = [];
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
Home
|
||||
</a>
|
||||
<a mat-button [routerLink]="['/cause-list']">Cause List</a>
|
||||
<a mat-button [routerLink]="['/compliance-list']">Compliance List</a>
|
||||
<mat-menu #mastersMenu="matMenu">
|
||||
<a mat-menu-item routerLink="/acts">Acts</a>
|
||||
<a mat-menu-item routerLink="/advocates">Advocates</a>
|
||||
|
Loading…
x
Reference in New Issue
Block a user