Skip to content

Commit

Permalink
fix: in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
raronpxcsw committed Nov 4, 2024
1 parent 4464509 commit b98aa44
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
4 changes: 3 additions & 1 deletion projects/aas-core/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ export type AASAbbreviation =
| 'SME'
| 'SML';

export type AASEndpointScheduleType = 'never' | 'once' | 'every' | 'daily' | 'weekly';

/** The schedule type. */
export interface AASEndpointSchedule {
type: 'never' | 'once' | 'every' | 'daily' | 'weekly';
type: AASEndpointScheduleType;
values?: (string | number)[];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,30 @@ <h4 class="modal-title">
</button>
<div #collapse="ngbCollapse" [(ngbCollapse)]="isCollapsed">
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="scheduleType" id="scheduleTypeNever" value="never">
<input class="form-check-input" type="radio" name="scheduleType" id="scheduleTypeNever" value="never"
[(ngModel)]="schedule">
<label class="form-check-label" for="scheduleTypeNever">Never</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="scheduleType" id="scheduleTypeOnce" value="once">
<input class="form-check-input" type="radio" name="scheduleType" id="scheduleTypeOnce" value="once"
[(ngModel)]="schedule">
<label class="form-check-label" for="scheduleTypeOnce">Once</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="scheduleType" id="scheduleTypeEvery" value="every">
<input class="form-check-input" type="radio" name="scheduleType" id="scheduleTypeEvery" value="every"
[(ngModel)]="schedule">
<label class="form-check-label" for="scheduleTypeEvery">Every</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="scheduleType" id="scheduleTypeEach" value="daily">
<label class="form-check-label" for="scheduleTypeEach">Each</label>
@if (schedule() === 'every') {
<div class="input-group mt-3">
<input type="text" class="form-control awp-number-input" placeholder="Hours" min="0" max="99"
aria-label="Hours" [(ngModel)]="hours">
<span class="input-group-text">Hours</span>
<input type="number" class="form-control awp-number-input" placeholder="Minutes" min="0" max="59"
aria-label="Minutes" [(ngModel)]="minutes">
<span class="input-group-text">Minutes</span>
</div>
}
<div class="col-12 mt-2" style="max-height: 200px; overflow-y: auto;">
<table class="table table-sm table-striped table-borderless">
<caption class="caption-top">Headers</caption>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ChangeDetectionStrategy, Component, computed, signal } from '@angular/c
import { FormsModule } from '@angular/forms';
import { NgbActiveModal, NgbCollapse, NgbDropdownModule, NgbToast } from '@ng-bootstrap/ng-bootstrap';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { AASEndpoint, AASEndpointType, stringFormat } from 'aas-core';
import { AASEndpoint, AASEndpointScheduleType, AASEndpointType, stringFormat } from 'aas-core';

export interface HeaderItem {
id: string;
Expand Down Expand Up @@ -75,6 +75,12 @@ export class AddEndpointFormComponent {

public readonly selectedItem = computed(() => this._items()[this._selectedItemIndex()]);

public readonly schedule = signal<AASEndpointScheduleType>('every');

public readonly minutes = signal(0);

public readonly hours = signal(1);

public readonly headers = this._headers.asReadonly();

public readonly isCollapsed = signal(true);
Expand Down Expand Up @@ -129,6 +135,18 @@ export class AddEndpointFormComponent {
endpoint.version = 'v3';
}

switch (this.schedule()) {
case 'never':
endpoint.schedule = { type: 'never' };
break;
case 'once':
endpoint.schedule = { type: 'once' };
break;
default:
endpoint.schedule = { type: 'every', values: [(this.hours() * 60 + this.minutes()) * 60000] };
break;
}

const headers = this.headers().filter(header => header.name && header.value);
if (headers.length > 0) {
endpoint.headers = {};
Expand Down
4 changes: 2 additions & 2 deletions projects/aas-server/src/app/variable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ export class Variable {
this.ENDPOINTS = process.env.ENDPOINTS ? JSON.parse(process.env.ENDPOINTS) : ['file:///samples?name=Samples'];
this.SCAN_TEMPLATES_TIMEOUT = process.env.SCAN_TEMPLATES_TIMEOUT
? Number(process.env.SCAN_TEMPLATES_TIMEOUT)
: 300000;
: 3600000;

this.SCAN_ENDPOINT_TIMEOUT = process.env.SCAN_ENDPOINT_TIMEOUT
? Number(process.env.SCAN_ENDPOINT_TIMEOUT)
: 5000;
: 3600000;

this.HTTPS_CERT_FILE = process.env.HTTPS_CERT_FILE;
this.HTTPS_KEY_FILE = process.env.HTTPS_KEY_FILE;
Expand Down

0 comments on commit b98aa44

Please sign in to comment.