Browse Source

Fixed some issues

master
Radu Liviu Carjan 3 years ago
parent
commit
3c34d48883
  1. 6
      app/Http/Controllers/SearchAndDisplaceController.php
  2. 4
      app/Http/Controllers/SearcherController.php
  3. 3
      app/SearchDisplace/Searchers/Duckling.php
  4. 2
      app/SearchDisplace/Searchers/Searcher.php
  5. 2
      app/SearchDisplace/Searchers/SearcherCreator.php
  6. 4
      app/SearchDisplace/Searchers/SearcherFactory.php
  7. 4
      app/SearchDisplace/Searchers/SearchersStorage.php
  8. 25769
      package-lock.json
  9. 626
      public/css/app.css
  10. 2
      resources/js/app.ts
  11. 7
      resources/js/components/ProcessFile/ProcessFile.ts
  12. 21
      resources/js/components/ProcessFile/ProcessFile.vue
  13. 95
      resources/js/components/Regex/Create.vue
  14. 91
      resources/js/components/Searchers/Create.vue
  15. 6
      resources/js/components/Searchers/DefineSearcher.vue
  16. 1
      resources/js/interfaces/Searcher.ts
  17. 7
      resources/sass/components/regex/create/_index.sass
  18. 2
      resources/sass/components/searchers/_create.sass

6
app/Http/Controllers/SearchAndDisplaceController.php

@ -14,9 +14,9 @@ class SearchAndDisplaceController extends Controller
try {
$result = $handler->getAfterIngest($id);
if ($result['status'] !== 'processing') {
$handler->destroy($id);
}
// if ($result['status'] !== 'processing') {
// $handler->destroy($id);
// }
return response()->json($result, 200);
} catch (\Exception $exception) {

4
app/Http/Controllers/SearcherController.php

@ -37,6 +37,7 @@ class SearcherController extends Controller
{
request()->validate([
'name' => 'required',
'description' => 'required',
'tag' => 'nullable',
'rows' => 'required|array',
'rows.*' => 'array',
@ -45,6 +46,7 @@ class SearcherController extends Controller
try {
$factory = new SearcherFactory(
request()->get('name'),
request()->get('description'),
request()->get('rows'),
request()->get('tag')
);
@ -112,6 +114,7 @@ class SearcherController extends Controller
{
request()->validate([
'name' => 'required',
'description' => 'required',
'tag' => 'nullable',
'rows' => 'required|array',
'rows.*' => 'array',
@ -120,6 +123,7 @@ class SearcherController extends Controller
try {
$factory = new SearcherFactory(
request()->get('name'),
request()->get('description'),
request()->get('rows'),
request()->get('tag')
);

3
app/SearchDisplace/Searchers/Duckling.php

@ -10,7 +10,8 @@ class Duckling
public function __construct()
{
$this->url = env('SD_DUCKLING_URL');
// $this->url = env('SD_DUCKLING_URL');
$this->url = 'host.docker.internal:5000/parse';
}
public function execute($content, $dimensions)

2
app/SearchDisplace/Searchers/Searcher.php

@ -53,7 +53,7 @@ class Searcher
return [
'start' => $item['start'],
'end' => $item['end'] - 1,
'content' => $item['body'],
'content' => filter_var($item['body'], FILTER_SANITIZE_URL),
];
}, $result);
}

2
app/SearchDisplace/Searchers/SearcherCreator.php

@ -62,8 +62,8 @@ abstract class SearcherCreator
$contents = [
'id' => $id,
'name' => $this->name,
'tag' => $this->tag,
'description' => $this->description,
'tag' => $this->tag,
'rows' => $this->rows,
];

4
app/SearchDisplace/Searchers/SearcherFactory.php

@ -4,9 +4,9 @@ namespace App\SearchDisplace\Searchers;
class SearcherFactory extends SearcherCreator
{
public function __construct($name, $rows, $tag = '')
public function __construct($name, $description, $rows, $tag = '')
{
parent::__construct($name, $tag, '');
parent::__construct($name, $tag, $description);
$this->rows = $rows;
}

4
app/SearchDisplace/Searchers/SearchersStorage.php

@ -28,9 +28,13 @@ class SearchersStorage
continue;
}
$contents = json_decode($this->storage->get($file), true);
$description = $contents['description'];
$searchers[$fileName] = [
'id' => $fileName,
'name' => $result[1],
'description' => $description,
'tag' => '',
'param' => SearchersCollection::PARAM_REQUIRED,
];

25769
package-lock.json
File diff suppressed because it is too large
View File

626
public/css/app.css
File diff suppressed because it is too large
View File

2
resources/js/app.ts

@ -36,6 +36,7 @@ import ScrollPanel from 'primevue/scrollpanel';
import ConfirmationService from 'primevue/confirmationservice';
import ConfirmDialog from 'primevue/confirmdialog';
import Tooltip from 'primevue/tooltip';
import Textarea from 'primevue/textarea';
// Own components
import AppHeader from './components/layout/Header.vue';
@ -83,6 +84,7 @@ Vue.component('Message', Message);
Vue.component('Timeline', Timeline);
Vue.component('ScrollPanel', ScrollPanel);
Vue.component('ConfirmDialog', ConfirmDialog);
Vue.component('Textarea', Textarea);
Vue.directive('tooltip', Tooltip);

7
resources/js/components/ProcessFile/ProcessFile.ts

@ -17,7 +17,7 @@ export default class ProcessFile extends Vue {
/**
* Props
*/
// The data for the file we are processing
// The data for the file we are processing
@Prop({default: {id: -1, file: '', path: ''}})
public readonly file!: FileData;
@ -60,7 +60,10 @@ export default class ProcessFile extends Vue {
// private searchersData: Array<{ id: string; name: string; type: string; }> = [];
// The list of filters applied to the selected searchers
private searchersFilters: any = [];
private searchersFilters: any = {
name: '',
global: ''
};
// The list of selected filters/searchers
private selectedSearchers: any = {};

21
resources/js/components/ProcessFile/ProcessFile.vue

@ -181,10 +181,27 @@
:rows="10"
paginatorTemplate="CurrentPageReport FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown"
currentPageReportTemplate="Showing {first} to {last} of {totalRecords}"
:rowsPerPageOptions="[10,20,50]">
:rowsPerPageOptions="[10,20,50]"
:filters="searchersFilters">
<Column selectionMode="multiple" headerStyle="width: 3em"></Column>
<Column field="name" header="Name" sortable></Column>
<Column
field="name"
header="Name"
sortable>
<template #body="slotProps">
{{slotProps.data.name}}
</template>
<template #filter>
<InputText type="text" v-model="searchersFilters['global']" class="p-column-filter" placeholder="Search by name"/>
</template>
</Column>
<Column
field="description"
header="Description"
sortable
class="filter-description">
</Column>
</DataTable>
<template #footer>

95
resources/js/components/Regex/Create.vue

@ -1,58 +1,57 @@
<template>
<div id="regex-create">
<div class="regex-header">
<h1 v-if=" ! regex"> New regex searcher </h1>
<div class="p-d-flex p-jc-center">
<div class="p-formgroup-inline">
<div class="p-field" v-if=" ! regex">
<span class="p-float-label">
<InputText v-model="name"
<Card>
<template #title v-if=" ! regex">
New regex searcher
</template>
<template #content>
<div class="p-fluid p-formgrid p-grid">
<div class="p-field p-col-12 p-md-6">
<label for="name">Enter searcher name</label>
<InputText v-model="name"
type="text"
name="name"
id="name">
</InputText>
</div>
<div class="p-field p-col-12 p-md-6">
<label for="tag">Enter searcher tag (optional)</label>
<InputText v-model="tag"
type="text"
name="name"
id="name">
</InputText>
<label for="name">Enter searcher name</label>
</span>
name="tag"
id="tag">
</InputText>
</div>
<div class="p-field">
<span class="p-float-label">
<InputText v-model="tag"
type="text"
name="tag"
id="tag">
</InputText>
<label for="tag">Enter searcher tag (optional)</label>
</span>
</div>
</template>
<template #footer>
<Button @click="onSave"
:disabled="( ! name && ! regex) || ! pattern"
class="p-button-raised">
Save
</Button>
</template>
</Card>
<Card>
<template #content>
<div class="regex-box">
<div class="main">
<pattern-box v-model="pattern"></pattern-box>
<text-box :pattern="pattern"
:flags="flags">
</text-box>
<flags v-model="flags"></flags>
</div>
<Button @click="onSave"
:disabled="( ! name && ! regex) || ! pattern"
class="p-button-raised">
Save
</Button>
<aside>
<side-bar></side-bar>
</aside>
</div>
</div>
</div>
<div class="regex-box">
<div class="main">
<pattern-box v-model="pattern"></pattern-box>
<text-box :pattern="pattern"
:flags="flags">
</text-box>
<flags v-model="flags"></flags>
</div>
<aside>
<side-bar></side-bar>
</aside>
</div>
</template>
</Card>
</div>
</template>

91
resources/js/components/Searchers/Create.vue

@ -1,39 +1,57 @@
<template>
<div id="searchers-create" :class="{'is-defining': isDefining,}">
<div>
<h1> {{ searcher.id ? 'Edit' : 'New' }} searcher </h1>
<InputText v-model="name"
type="text"
placeholder="Enter searcher name"
class="input">
</InputText>
<Button @click="onSave" :disabled=" ! name || rows.length === 0">
Save
</Button>
</div>
<div>
<h3>Default tag (optional)</h3>
<InputText v-model="tag"
type="text"
placeholder="Enter the default tag"
class="input">
</InputText>
</div>
<div v-if="standalone">
<p>
A searcher may contain multiple compounded searchers on multiple rows and columns.
</p>
<p>
Each searcher in a row is extending the searching criteria on the content resulted from the
previous row searchers.
</p>
</div>
<!-- <h1> {{ searcher.id ? 'Edit' : 'New' }} searcher </h1> -->
<Card>
<template #title>
{{ searcher.id ? 'Edit' : 'New' }} searcher
</template>
<template #content>
<div class="p-fluid p-formgrid p-grid">
<div class="p-field p-col-12 p-md-6">
<label for="searcher-">Searcher name</label>
<InputText v-model="name"
type="text"
placeholder="Enter searcher name"
class="input"
id="searcher-name"
name="searcher-name">
</InputText>
</div>
<div class="p-field p-col-12 p-md-6">
<label for="lastname">Default tag</label>
<InputText v-model="tag"
type="text"
placeholder="Enter the default tag"
class="input"
id="searcher-default-tag"
name="searcher-default-tag">
</InputText>
</div>
<div class="p-field p-col-12">
<label for="address">Description</label>
<Textarea
v-model="description"
rows="5"
placeholder="Enter searcher description"
id="searcher-description"
name="searcher-description"
/>
</div>
</div>
<Message severity="info" v-if="standalone">
<p>A searcher may contain multiple compounded searchers on multiple rows and columns.</p>
<p>Each searcher in a row is extending the searching criteria on the content resulted from the
previous row searchers.</p>
</Message>
</template>
<template #footer>
<Button @click="onSave" :disabled=" ! name || rows.length === 0">
Save
</Button>
</template>
</Card>
<div v-for="(row, rowIndex) in rows"
:key="`row-${rowIndex}`"
@ -77,6 +95,7 @@ import {Component, Prop, Vue} from "vue-property-decorator";
export default class Create extends Vue {
private id: String = '';
private name: String = '';
private description: String = '';
private tag: String = '';
private rows: Array<Array<any>> = [];
@ -85,6 +104,7 @@ import {Component, Prop, Vue} from "vue-property-decorator";
return {
id: '',
name: '',
description: '',
tag: '',
rows: [],
};
@ -126,6 +146,7 @@ import {Component, Prop, Vue} from "vue-property-decorator";
const updatedSearcher = Object.assign(this.searcher, {
name: this.name,
description: this.description,
tag: this.tag,
rows: this.rows,
});
@ -153,6 +174,7 @@ import {Component, Prop, Vue} from "vue-property-decorator";
async update() {
const { data } = await (window as any).axios.put(`/searchers/${this.id}`, {
name: this.name,
description: this.description,
tag: this.tag,
rows: this.rows,
});
@ -163,6 +185,7 @@ import {Component, Prop, Vue} from "vue-property-decorator";
async create() {
const { data } = await (window as any).axios.post('/searchers', {
name: this.name,
description: this.description,
tag: this.tag,
rows: this.rows,
});
@ -208,11 +231,13 @@ import {Component, Prop, Vue} from "vue-property-decorator";
this.id = this.searcher.id;
this.rows = this.searcher.rows;
this.name = this.searcher.name;
this.description = this.searcher.description;
this.tag = this.searcher.tag;
}
if (this.isDefining && this.definedSearcher) {
this.name = this.definedSearcher;
this.description = '';
this.rows.push([
{

6
resources/js/components/Searchers/DefineSearcher.vue

@ -3,9 +3,9 @@
:visible.sync="showDialog"
:maximizable="true"
:modal="true"
:block-scroll="true"
:style="{width: '95vw', height: '95vh',}"
:contentStyle="{overflow: 'visible'}"
:block-scroll="false"
:style="{'position': 'absolute'}"
:contentStyle="{height: '100%'}"
:baseZIndex="2014"
id="define-searcher"
ref="define-searcher">

1
resources/js/interfaces/Searcher.ts

@ -1,6 +1,7 @@
export interface Searcher {
id: string;
name: string,
description: string,
param: string,
type: string;
}

7
resources/sass/components/regex/create/_index.sass

@ -4,6 +4,13 @@
@import 'references'
#regex-create
text-align: left
margin: 10px
.p-card
margin-top: 10px
margin-bottom: 10px
.regex-header
margin-bottom: 5rem

2
resources/sass/components/searchers/_create.sass

@ -1,3 +1,5 @@
#searchers-create.is-defining
max-height: 100%
overflow-y: auto
margin: 10px
text-align: left
Loading…
Cancel
Save