Minor fixes
This commit is contained in:
parent
a65940b0be
commit
4d0886e568
@ -16,9 +16,15 @@ export const clearDiscussion = createAction(
|
||||
'[DiscussionChooser] Clear Discussion'
|
||||
);
|
||||
export const addDimensionToFile = createAction(
|
||||
'[Dimension] Add Dimenstion To File',
|
||||
'[DiscussionChooser] Add Dimenstion To File',
|
||||
props<{ dimension: Dimension }>()
|
||||
);
|
||||
export const addDimensionToFileSuccess = createAction(
|
||||
'[Dimension] Add Dimension To File Success'
|
||||
'[DiscussionChooser] Add Dimension To File Success'
|
||||
);
|
||||
export const bindClassifier = createAction(
|
||||
'[DiscussionChooser] Bind Classifier'
|
||||
);
|
||||
export const bindClassifierSuccess = createAction(
|
||||
'[DiscussionChooser] Bind Classifier Success'
|
||||
);
|
||||
|
@ -5,6 +5,8 @@ import {
|
||||
loadDiscussions,
|
||||
discussionLoadSuccess,
|
||||
availableDimensionsLoadSuccess,
|
||||
bindClassifier,
|
||||
bindClassifierSuccess,
|
||||
} from '../actions/discussion-chooser.actions';
|
||||
import {
|
||||
catchError,
|
||||
@ -14,6 +16,7 @@ import {
|
||||
withLatestFrom,
|
||||
} from 'rxjs/operators';
|
||||
import { EMPTY, forkJoin, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { selectRouteParam, State as AppState } from '../reducers';
|
||||
import { GetDiscussionService } from '../services/get-discussion.service';
|
||||
|
||||
@ -47,4 +50,21 @@ export class DiscussionChooserEffects {
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$bind = createEffect(() =>
|
||||
this.actions$.pipe(
|
||||
ofType(bindClassifier),
|
||||
withLatestFrom(
|
||||
this.store$.select((state) => state.dataState.data?.discussions)
|
||||
),
|
||||
flatMap(([action, data]) =>
|
||||
forkJoin(
|
||||
data?.map((el) => this.discussionService.bindClassfier(el.id))
|
||||
).pipe(
|
||||
map(() => bindClassifierSuccess()),
|
||||
catchError((err) => EMPTY)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -38,6 +38,13 @@
|
||||
</button></nb-card-body
|
||||
>
|
||||
</nb-card>
|
||||
<nb-card>
|
||||
<nb-card-body>
|
||||
<button nbButton (click)="bindClassifier()" status="info">
|
||||
Przypisz anotacje z klasyfikatora
|
||||
</button>
|
||||
</nb-card-body>
|
||||
</nb-card>
|
||||
</nb-layout-column>
|
||||
</nb-layout>
|
||||
|
||||
|
@ -9,6 +9,7 @@ import {
|
||||
loadDiscussions,
|
||||
clearDiscussion,
|
||||
addDimensionToFile,
|
||||
bindClassifier,
|
||||
} from '../../../actions/discussion-chooser.actions';
|
||||
import {
|
||||
selectData,
|
||||
@ -56,7 +57,7 @@ export class DiscussionChooserComponent implements OnInit, OnDestroy {
|
||||
})
|
||||
.onClose.subscribe((res) => {
|
||||
this.store.dispatch(
|
||||
setCurrentDiscussion({ dimensionId: res, discussionId: this.id })
|
||||
setCurrentDiscussion({ dimensionId: res, discussionId: id })
|
||||
);
|
||||
this.router.navigate(['./topic'], { relativeTo: this.route });
|
||||
});
|
||||
@ -76,6 +77,10 @@ export class DiscussionChooserComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
bindClassifier() {
|
||||
this.store.dispatch(bindClassifier());
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.store.dispatch(clearDiscussion());
|
||||
}
|
||||
|
@ -13,17 +13,21 @@ import maked3hierarchy from 'src/app/_functions/maked3hierarchy';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { State } from 'src/app/reducers';
|
||||
import { selectPosts } from 'src/app/selectors/discussion.selectors';
|
||||
import { first, map, share, switchMap } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
selector: 'graph',
|
||||
templateUrl: './graph.component.html',
|
||||
styleUrls: ['./graph.component.scss'],
|
||||
})
|
||||
export class GraphComponent {
|
||||
export class GraphComponent implements AfterViewInit, OnDestroy {
|
||||
private hierarchizedData: Post[];
|
||||
@ViewChild('tree', { read: ElementRef })
|
||||
private treeContainer: ElementRef;
|
||||
data: Post[];
|
||||
sub = this.store
|
||||
.select((state) => state.currentDiscussion.selectedDiscussion)
|
||||
.pipe(first());
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
@ -32,16 +36,16 @@ export class GraphComponent {
|
||||
) {}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
this.store
|
||||
.select((state) => state.currentDiscussion.selectedDiscussion)
|
||||
.subscribe((id) =>
|
||||
this.visualizationDataService.getDiscussion(id).subscribe((res) => {
|
||||
this.initializeData(res.posts);
|
||||
this.generateGraph();
|
||||
})
|
||||
);
|
||||
this.sub
|
||||
.pipe(switchMap((id) => this.visualizationDataService.getDiscussion(id)))
|
||||
.subscribe((res) => {
|
||||
this.initializeData(res.posts);
|
||||
this.generateGraph();
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {}
|
||||
|
||||
private initializeData(data: Post[]): void {
|
||||
this.data = data;
|
||||
this.hierarchizedData = maked3hierarchy(data);
|
||||
|
@ -31,12 +31,6 @@ export class StyledParagraphComponent implements OnInit {
|
||||
constructor(private store: Store<State>) {}
|
||||
|
||||
ngOnInit() {
|
||||
// this.selectedDimension$.subscribe((res) => {
|
||||
// this.dimension = res;
|
||||
// res === 0
|
||||
// ? (this.trigger = 'noop' as NbTrigger)
|
||||
// : (this.trigger = 'hover' as NbTrigger);
|
||||
// });
|
||||
this.currentCategories$.subscribe((res) => {
|
||||
this.categories = res;
|
||||
});
|
||||
@ -46,7 +40,7 @@ export class StyledParagraphComponent implements OnInit {
|
||||
this.store.dispatch(
|
||||
updateCategory({ categoryId, paragraphId: this.item.para_id[this.index] })
|
||||
);
|
||||
this.store.dispatch(getDiscussion());
|
||||
setTimeout(() => this.store.dispatch(getDiscussion()), 500);
|
||||
}
|
||||
|
||||
get itemLabel() {
|
||||
|
@ -19,4 +19,8 @@ export class GetDiscussionService {
|
||||
`http://127.0.0.1:8000/discussions/${discussionId}/${dimmensionId}`
|
||||
);
|
||||
}
|
||||
|
||||
bindClassfier(id: number) {
|
||||
return this.http.get<any>(`http://127.0.0.1:8000/classifier/${id}`);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user