Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { AuthGuard } from './guard/auth.guard';
import { OrganizationDetailsComponent } from "./pages/organization-details/organization-details.component"
import { ProductOrdersComponent } from './pages/product-orders/product-orders.component';
import {AboutDomeComponent} from "src/app/pages/about-dome/about-dome.component"
import { UsageSpecsComponent } from "src/app/pages/usage-specs/usage-specs.component"

const routes: Routes = [
{
Expand Down Expand Up @@ -77,6 +78,10 @@ const routes: Routes = [
component: ProductOrdersComponent,
canActivate: [AuthGuard], data: { roles: [] }
},
{ path: 'usage-spec',
component: UsageSpecsComponent,
canActivate: [AuthGuard], data: { roles: ['seller'] }
},
{ path: '**', redirectTo: 'dashboard', pathMatch: 'full' },
]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<div>
<!-- Breadcrumb -->
<div class="pb-4">
<nav class="flex px-5 py-3 text-gray-700 border border-gray-200 rounded-lg bg-secondary-50 dark:bg-secondary-100 dark:border-gray-800 dark:text-white" aria-label="Breadcrumb">
<ol class="inline-flex items-center space-x-1 md:space-x-2 rtl:space-x-reverse">
<li class="inline-flex items-center">
<button (click)="goBack()" class="inline-flex items-center text-sm font-medium text-gray-500 dark:text-white hover:text-primary-100 dark:hover:text-primary-50">
<svg class="w-3 h-3 mr-2 text-gray-400" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 12 10">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M5 1 1 5l4 4m6-8L7 5l4 4"/>
</svg>
{{ 'USAGE_SPECS._back' | translate }}
</button>
</li>
<li aria-current="page">
<div class="flex items-center">
<svg class="rtl:rotate-180 w-3 h-3 mx-1 text-gray-400 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 9 4-4-4-4"/>
</svg>
<span class="ms-1 text-sm font-medium text-gray-500 dark:text-white md:ms-2 ">{{ 'USAGE_SPECS._create' | translate }}</span>
</div>
</li>
</ol>
</nav>
</div>
<!-- End Breadcrumb -->

<usage-spec-form [partyId]="partyId" [formType]="'create'"></usage-spec-form>
</div>

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { CreateUsageSpecComponent } from './create-usage-spec.component';

describe('CreateUsageSpecComponent', () => {
let component: CreateUsageSpecComponent;
let fixture: ComponentFixture<CreateUsageSpecComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [CreateUsageSpecComponent]
})
.compileComponents();

fixture = TestBed.createComponent(CreateUsageSpecComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Component, OnInit, ChangeDetectorRef, HostListener, ElementRef, ViewChild } from '@angular/core';
import { UsageSpecComponent } from 'src/app/shared/forms/usage-spec/usage-spec.component'
import {FormBuilder, FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms";
import {TranslateModule} from "@ngx-translate/core";
import {NgClass, NgIf} from "@angular/common";
import { lastValueFrom } from 'rxjs';
import {components} from "src/app/models/product-catalog";
import {EventMessageService} from "src/app/services/event-message.service";
import { LocalStorageService } from 'src/app/services/local-storage.service';
import { LoginInfo } from 'src/app/models/interfaces';
import * as moment from 'moment';

@Component({
selector: 'create-usage-spec',
standalone: true,
imports: [
UsageSpecComponent,
TranslateModule,
ReactiveFormsModule,
NgClass],
templateUrl: './create-usage-spec.component.html',
styleUrl: './create-usage-spec.component.css'
})

export class CreateUsageSpecComponent implements OnInit {
partyId:any='';

constructor(
private cdr: ChangeDetectorRef,
private el: ElementRef,
private localStorage: LocalStorageService,
private eventMessage: EventMessageService,
){}

ngOnInit() {
this.initPartyInfo();
}

initPartyInfo(){
let aux = this.localStorage.getObject('login_items') as LoginInfo;
if(JSON.stringify(aux) != '{}' && (((aux.expire - moment().unix())-4) > 0)) {
if(aux.logged_as==aux.id){
this.partyId = aux.partyId;
} else {
let loggedOrg = aux.organizations.find((element: { id: any; }) => element.id == aux.logged_as)
this.partyId = loggedOrg.partyId
}
}
}

goBack() {
this.eventMessage.emitUsageSpecList(true);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<div>
<!-- Breadcrumb -->
<div class="pb-4">
<nav class="flex px-5 py-3 text-gray-700 border border-gray-200 rounded-lg bg-secondary-50 dark:bg-secondary-100 dark:border-gray-800 dark:text-white" aria-label="Breadcrumb">
<ol class="inline-flex items-center space-x-1 md:space-x-2 rtl:space-x-reverse">
<li class="inline-flex items-center">
<button (click)="goBack()" class="inline-flex items-center text-sm font-medium text-gray-500 dark:text-white hover:text-primary-100 dark:hover:text-primary-50">
<svg class="w-3 h-3 mr-2 text-gray-400" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 12 10">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M5 1 1 5l4 4m6-8L7 5l4 4"/>
</svg>
{{ 'USAGE_SPECS._back' | translate }}
</button>
</li>
<li aria-current="page">
<div class="flex items-center">
<svg class="rtl:rotate-180 w-3 h-3 mx-1 text-gray-400 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 9 4-4-4-4"/>
</svg>
<span class="ms-1 text-sm font-medium text-gray-500 dark:text-white md:ms-2 ">{{ 'USAGE_SPECS._update' | translate }}</span>
</div>
</li>
</ol>
</nav>
</div>
<!-- End Breadcrumb -->

<usage-spec-form [partyId]="partyId" [formType]="'update'" [usageSpec]="usageSpec"></usage-spec-form>
</div>

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { UpdateUsageSpecComponent } from './update-usage-spec.component';

describe('UpdateUsageSpecComponent', () => {
let component: UpdateUsageSpecComponent;
let fixture: ComponentFixture<UpdateUsageSpecComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [UpdateUsageSpecComponent]
})
.compileComponents();

fixture = TestBed.createComponent(UpdateUsageSpecComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Component, OnInit, ChangeDetectorRef, HostListener, ElementRef, ViewChild, Input } from '@angular/core';
import { UsageSpecComponent } from 'src/app/shared/forms/usage-spec/usage-spec.component'
import {FormBuilder, FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms";
import {TranslateModule} from "@ngx-translate/core";
import {NgClass, NgIf} from "@angular/common";
import { lastValueFrom } from 'rxjs';
import {components} from "src/app/models/product-catalog";
import {EventMessageService} from "src/app/services/event-message.service";
import { LocalStorageService } from 'src/app/services/local-storage.service';
import { LoginInfo } from 'src/app/models/interfaces';
import * as moment from 'moment';

@Component({
selector: 'update-usage-spec',
standalone: true,
imports: [
UsageSpecComponent,
TranslateModule,
ReactiveFormsModule,
NgClass
],
templateUrl: './update-usage-spec.component.html',
styleUrl: './update-usage-spec.component.css'
})
export class UpdateUsageSpecComponent implements OnInit {
partyId:any='';
@Input() usageSpec: any;

constructor(
private cdr: ChangeDetectorRef,
private el: ElementRef,
private localStorage: LocalStorageService,
private eventMessage: EventMessageService,
){}

ngOnInit() {
this.initPartyInfo();
}

initPartyInfo(){
let aux = this.localStorage.getObject('login_items') as LoginInfo;
if(JSON.stringify(aux) != '{}' && (((aux.expire - moment().unix())-4) > 0)) {
if(aux.logged_as==aux.id){
this.partyId = aux.partyId;
} else {
let loggedOrg = aux.organizations.find((element: { id: any; }) => element.id == aux.logged_as)
this.partyId = loggedOrg.partyId
}
}
}

goBack() {
this.eventMessage.emitUsageSpecList(true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@

<div>
<div class="w-full h-fit mb-4 bg-secondary-50 rounded-lg dark:bg-secondary-100 dark:border-gray-800 border-gray-300 border-secondary-50 border flex flex-col shadow-lg">
<div class="flex w-full flex-cols items-center md:flex-row justify-between">
<div class="mb-4 md:mb-0 md:w-1/4 p-8">
<h2 class="text-2xl font-bold mb-4 dark:text-white">{{ 'USAGE_SPECS._list' | translate }}</h2>
</div>

<div class="flex flex-row w-full justify-end">
<button type="button" (click)="goToCreate()" class="ml-2 mr-8 mb-4 text-white bg-primary-100 hover:bg-primary-50 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-full text-sm p-2.5 text-center inline-flex items-center align-middle me-2">
<p class="pl-2 pr-2">{{ 'USAGE_SPECS._add_new' | translate }}</p>
<svg class="w-[18px] h-[18px] text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h14m-7 7V5"/>
</svg>
</button>
</div>

</div>

</div>

@if(loading){
<div role="status" class="w-full h-full flex justify-center align-middle">
<svg aria-hidden="true" class="w-12 h-12 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
</svg>
<span class="sr-only">Loading...</span>
</div>
} @else {
<div class="bg-secondary-50 dark:bg-secondary-100 border dark:border-gray-800 mt-8 p-4 rounded-lg">
<div class="relative overflow-x-auto shadow-md sm:rounded-lg w-full bg-white dark:bg-secondary-300">
<table class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-200">
<thead class="text-xs text-gray-700 uppercase bg-gray-100 dark:bg-secondary-200 dark:text-white">
<tr>
<th scope="col" class="px-6 py-3">
{{ 'USAGE_SPECS._name' | translate }}
</th>
<th scope="col" class="px-6 py-3">
{{ 'USAGE_SPECS._description' | translate }}
</th>
<th scope="col" class="px-6 py-3">
{{ 'USAGE_SPECS._actions' | translate }}
</th>
</tr>
</thead>
<tbody>
@for (usage of usageSpecs; track usage.id) {
<tr class="border-b hover:bg-gray-200 dark:bg-secondary-300 dark:border-gray-700 dark:hover:bg-secondary-200">
<td class="px-6 py-4 text-wrap break-all">
{{usage.name}}
</td>
<td class="hidden md:table-cell px-6 py-4">
{{usage.description}}
</td>
<td class="px-6 py-4">
<button type="button" (click)="goToUpdate(usage)" class="text-white bg-primary-100 hover:bg-primary-50 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-full text-sm p-2.5 text-center inline-flex items-center me-2">
<svg class="w-[18px] h-[18px] text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
<path fill-rule="evenodd" d="M14 4.182A4.136 4.136 0 0 1 16.9 3c1.087 0 2.13.425 2.899 1.182A4.01 4.01 0 0 1 21 7.037c0 1.068-.43 2.092-1.194 2.849L18.5 11.214l-5.8-5.71 1.287-1.31.012-.012Zm-2.717 2.763L6.186 12.13l2.175 2.141 5.063-5.218-2.141-2.108Zm-6.25 6.886-1.98 5.849a.992.992 0 0 0 .245 1.026 1.03 1.03 0 0 0 1.043.242L10.282 19l-5.25-5.168Zm6.954 4.01 5.096-5.186-2.218-2.183-5.063 5.218 2.185 2.15Z" clip-rule="evenodd"/>
</svg>
</button>
</td>
</tr>
} @empty {
<div class="flex justify-center w-full m-4">
<div class="flex w-full items-center p-4 text-sm text-primary-100 rounded-lg bg-blue-50 dark:bg-secondary-200 dark:text-primary-50" role="alert">
<svg class="flex-shrink-0 inline w-4 h-4 me-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"/>
</svg>
<div>
{{ 'USAGE_SPECS._no_usage' | translate }}
</div>
</div>
</div>
}
</tbody>
</table>
</div>
@if (!loading_more) {
@if (page_check) {
<div class="flex pt-6 pb-2 justify-center align-middle">
<button (click)="next()" class="flex cursor-pointer shadow-lg items-center justify-center px-3 h-8 text-sm font-medium text-gray-500 dark:text-white bg-white dark:bg-primary-100 dark:hover:bg-secondary-100 border border-gray-300 dark:border-secondary-200 rounded-lg hover:bg-gray-200">
{{ 'USAGE_SPECS._load_more' | translate }}
<svg class="w-3.5 h-3.5 ms-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h14m-7 7V5"/>
</svg>
</button>
</div>
}
} @else {
<div role="status" class="w-full h-full flex justify-center align-middle mt-2">
<svg aria-hidden="true" class="w-12 h-12 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
</svg>
<span class="sr-only">Loading...</span>
</div>
}
</div>
}
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { UsageListComponent } from './usage-list.component';

describe('UsageListComponent', () => {
let component: UsageListComponent;
let fixture: ComponentFixture<UsageListComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [UsageListComponent]
})
.compileComponents();

fixture = TestBed.createComponent(UsageListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Loading
Loading