Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
anis
anis-client
Commits
e34f0488
Commit
e34f0488
authored
Sep 17, 2019
by
Tifenn Guillas
Browse files
WIP: action vers serveur
parent
b86a88bf
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/app/search/components/result/datatable.component.html
View file @
e34f0488
...
...
@@ -14,7 +14,7 @@
</div>
<div
*ngIf=
"searchMeta"
>
<div
class=
"mb-2"
>
<button
[disabled]=
"noSelectedData()"
class=
"btn btn-sm btn-outline-primary"
>
Action
</button>
<button
[disabled]=
"noSelectedData()"
(click)=
"fireAction('csv')"
class=
"btn btn-sm btn-outline-primary"
>
To CSV
</button>
</div>
<div
class=
"table-responsive"
>
<table
class=
"table table-bordered table-hover"
>
...
...
src/app/search/components/result/datatable.component.ts
View file @
e34f0488
...
...
@@ -21,6 +21,7 @@ export class DatatableComponent {
@
Output
()
getSearchData
:
EventEmitter
<
number
>
=
new
EventEmitter
();
@
Output
()
addSelectedData
:
EventEmitter
<
any
>
=
new
EventEmitter
();
@
Output
()
deleteSelectedData
:
EventEmitter
<
any
>
=
new
EventEmitter
();
@
Output
()
executeAction
:
EventEmitter
<
string
>
=
new
EventEmitter
();
initDatatable
()
{
this
.
initSearchMeta
.
emit
();
...
...
@@ -73,4 +74,8 @@ export class DatatableComponent {
noSelectedData
()
{
return
this
.
selectedData
.
length
<
1
;
}
fireAction
(
typeAction
:
string
):
void
{
this
.
executeAction
.
emit
(
typeAction
);
}
}
src/app/search/containers/result.component.html
View file @
e34f0488
...
...
@@ -22,7 +22,8 @@
(initSearchMeta)=
"getSearchMeta()"
(getSearchData)=
"getSearchData($event)"
(addSelectedData)=
"addSearchData($event)"
(deleteSelectedData)=
"deleteSearchData($event)"
>
(deleteSelectedData)=
"deleteSearchData($event)"
(executeAction)=
"fireAction($event)"
>
</app-datatable>
</div>
<div
class=
"col-12 col-md-4 pt-2"
>
...
...
src/app/search/containers/result.component.ts
View file @
e34f0488
import
{
Component
,
OnInit
}
from
'
@angular/core
'
;
import
{
Component
,
OnInit
,
Query
}
from
'
@angular/core
'
;
import
{
Observable
}
from
'
rxjs
'
;
import
{
Store
}
from
'
@ngrx/store
'
;
...
...
@@ -12,6 +12,7 @@ import * as fromSearch from '../store/search.reducer';
import
*
as
fromMetamodel
from
'
../../metamodel/reducers
'
;
import
*
as
searchSelector
from
'
../store/search.selector
'
;
import
*
as
metamodelSelector
from
'
../../metamodel/selectors
'
;
import
{
SearchService
}
from
'
../store/search.service
'
;
interface
StoreState
{
search
:
fromSearch
.
State
;
...
...
@@ -41,7 +42,7 @@ export class ResultComponent implements OnInit {
public
selectedData
:
Observable
<
any
[]
>
;
public
queryParams
:
Observable
<
SearchQueryParams
>
;
constructor
(
private
store
:
Store
<
StoreState
>
)
{
constructor
(
private
store
:
Store
<
StoreState
>
,
private
searchService
:
SearchService
)
{
this
.
datasetSearchMetaIsLoading
=
store
.
select
(
metamodelSelector
.
getDatasetSearchMetaIsLoading
);
this
.
datasetSearchMetaIsLoaded
=
store
.
select
(
metamodelSelector
.
getDatasetSearchMetaIsLoaded
);
this
.
attributeSearchMetaIsLoading
=
store
.
select
(
metamodelSelector
.
getAttributeSearchMetaIsLoading
);
...
...
@@ -75,11 +76,28 @@ export class ResultComponent implements OnInit {
this
.
store
.
dispatch
(
new
searchActions
.
RetrieveDataAction
(
page
));
}
addSearchData
(
data
:
any
)
{
addSearchData
(
data
:
any
)
:
void
{
this
.
store
.
dispatch
(
new
searchActions
.
AddSelectedDataAction
(
data
));
}
deleteSearchData
(
data
:
any
)
{
deleteSearchData
(
data
:
any
)
:
void
{
this
.
store
.
dispatch
(
new
searchActions
.
DeleteSelectedDataAction
(
data
));
}
fireAction
(
typeAction
:
string
):
void
{
let
dname
:
string
;
this
.
datasetName
.
subscribe
((
d
:
string
)
=>
dname
=
d
);
let
query
=
'
?a=
'
;
this
.
queryParams
.
subscribe
(
queryParams
=>
query
+=
queryParams
.
a
);
query
+=
'
&c=
'
;
this
.
datasetAttributeList
.
subscribe
(
attributeList
=>
{
const
attribute
=
attributeList
.
find
(
a
=>
a
.
search_flag
===
'
ID
'
);
query
+=
attribute
.
id
;
});
query
+=
'
::eq::
'
;
this
.
selectedData
.
subscribe
(
data
=>
{
query
+=
data
.
join
(
'
|
'
);
});
this
.
searchService
.
webServiceCall
(
typeAction
,
dname
,
query
);
}
}
src/app/search/store/search.service.ts
View file @
e34f0488
...
...
@@ -6,15 +6,22 @@ import { environment } from '../../../environments/environment';
@
Injectable
()
export
class
SearchService
{
private
API_PATH
:
string
=
environment
.
apiUrl
+
'
/search/
'
+
environment
.
instanceName
;
private
API_PATH
:
string
=
environment
.
apiUrl
;
private
instanceName
:
string
=
environment
.
instanceName
;
constructor
(
private
http
:
HttpClient
)
{
}
retrieveMeta
(
query
:
string
)
{
return
this
.
http
.
get
<
SearchMeta
>
(
this
.
API_PATH
+
'
/meta/
'
+
query
);
return
this
.
http
.
get
<
SearchMeta
>
(
this
.
API_PATH
+
'
/search/
'
+
this
.
instanceName
+
'
/meta/
'
+
query
);
}
retrieveData
(
query
:
string
)
{
return
this
.
http
.
get
<
any
[]
>
(
this
.
API_PATH
+
'
/data/
'
+
query
);
return
this
.
http
.
get
<
any
[]
>
(
this
.
API_PATH
+
'
/search/
'
+
this
.
instanceName
+
'
/data/
'
+
query
);
}
webServiceCall
(
typeAction
:
string
,
dname
:
string
,
query
:
string
)
{
const
url
=
this
.
API_PATH
+
'
/service/
'
+
environment
.
instanceName
+
'
/
'
+
dname
+
'
/
'
+
query
;
console
.
log
(
this
.
http
.
get
<
any
[]
>
(
url
));
return
this
.
http
.
get
<
any
[]
>
(
url
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment