mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-08-07 17:48:54 +00:00
@@ -0,0 +1,8 @@
|
||||
<adf-search-control [highlight]="true"
|
||||
(optionClicked)="onItemClicked($event)"
|
||||
(submit)="onSearchSubmit($event)">
|
||||
</adf-search-control>
|
||||
|
||||
<adf-viewer *ngIf="fileShowed" [(showViewer)]="fileShowed" [fileNodeId]="fileNodeId" [overlayMode]="true">
|
||||
<mat-spinner></mat-spinner>
|
||||
</adf-viewer>
|
@@ -0,0 +1,5 @@
|
||||
|
||||
.adf-search-elements {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
70
demo-shell/src/app/components/search/search-bar.component.ts
Normal file
70
demo-shell/src/app/components/search/search-bar.component.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, EventEmitter, Output, Input } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { MinimalNodeEntity } from 'alfresco-js-api';
|
||||
import { AuthenticationService } from '@alfresco/core';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-search-bar',
|
||||
templateUrl: './search-bar.component.html',
|
||||
styleUrls: ['./search-bar.component.scss']
|
||||
})
|
||||
export class SearchBarComponent {
|
||||
|
||||
@Input()
|
||||
expandable: boolean = true;
|
||||
|
||||
@Output()
|
||||
expand = new EventEmitter();
|
||||
|
||||
fileNodeId: string;
|
||||
fileShowed: boolean = false;
|
||||
searchTerm: string = '';
|
||||
subscriptAnimationState: string;
|
||||
|
||||
constructor(public router: Router,
|
||||
public authService: AuthenticationService) {
|
||||
}
|
||||
|
||||
isLoggedIn(): boolean {
|
||||
return this.authService.isLoggedIn();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the user submits the search, e.g. hits enter or clicks submit
|
||||
*
|
||||
* @param event Parameters relating to the search
|
||||
*/
|
||||
onSearchSubmit(event: KeyboardEvent) {
|
||||
let value = (event.target as HTMLInputElement).value;
|
||||
this.router.navigate(['/search', {
|
||||
q: value
|
||||
}]);
|
||||
}
|
||||
|
||||
onItemClicked(event: MinimalNodeEntity) {
|
||||
if (event.entry.isFile) {
|
||||
this.fileNodeId = event.entry.id;
|
||||
this.fileShowed = true;
|
||||
} else if (event.entry.isFolder) {
|
||||
this.router.navigate(['/files', event.entry.id]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
<adf-search [searchTerm]="searchedWord"
|
||||
(resultLoaded)="showSearchResult($event)"
|
||||
#search>
|
||||
</adf-search>
|
||||
|
||||
<adf-files-component
|
||||
[currentFolderId]="null"
|
||||
[nodeResult]="resultNodePageList"
|
||||
(documentListReady)="refreshResults($event)">
|
||||
</adf-files-component>
|
@@ -0,0 +1,20 @@
|
||||
div.search-results-container {
|
||||
padding: 0 20px 20px 20px;
|
||||
}
|
||||
|
||||
.adf-search-title {
|
||||
font-size: 22px;
|
||||
padding: 15px 0 15px 0;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 600px) {
|
||||
:host .col-display-name {
|
||||
min-width: 100px;
|
||||
}
|
||||
:host .col-modified-at, :host .col-modified-by {
|
||||
display: none;
|
||||
}
|
||||
:host div.search-results-container table {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, OnInit, Optional, ViewChild } from '@angular/core';
|
||||
import { Router, ActivatedRoute, Params } from '@angular/router';
|
||||
import { NodePaging } from 'alfresco-js-api';
|
||||
import { SearchComponent } from '@alfresco/content-services';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-search-result-component',
|
||||
templateUrl: './search-result.component.html',
|
||||
styleUrls: ['./search-result.component.scss']
|
||||
})
|
||||
export class SearchResultComponent implements OnInit {
|
||||
|
||||
@ViewChild('search')
|
||||
search: SearchComponent;
|
||||
|
||||
fileNodeId: string;
|
||||
queryParamName = 'q';
|
||||
searchedWord: string = '';
|
||||
fileShowed: boolean = false;
|
||||
navigationMode: string = 'dblclick';
|
||||
resultNodePageList: NodePaging;
|
||||
|
||||
constructor(public router: Router,
|
||||
@Optional() private route: ActivatedRoute) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
if (this.route) {
|
||||
this.route.params.forEach((params: Params) => {
|
||||
this.searchedWord = params.hasOwnProperty(this.queryParamName) ? params[this.queryParamName] : null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
showSearchResult(event: NodePaging) {
|
||||
this.resultNodePageList = event;
|
||||
}
|
||||
|
||||
refreshResults(event: any) {
|
||||
this.search.reload();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user