forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ufal/fe-22-54-download-preview-item (#362)
* create new component and add model file and service file * build the user interface and calling the api from backend * add logic for handling data from BE and refactor the UI * fix the lint error and fix the collapse/hide behaviour * add UI for download buttons and fix UI for the ZIP Preview * getting data from backend and make the download feature * handle with the dynamic input * fix the collapese/hide behaviour and handle more cases * add more conditions for checking permission to preview and download files * fix lint error * fix failed test * Lock/download preview (#311) * create new component and add model file and service file * build the user interface and calling the api from backend * add logic for handling data from BE and refactor the UI * fix the lint error and fix the collapse/hide behaviour --------- Co-authored-by: HuynhKhoa1601 <[email protected]> * Resolved conflicts * Revert unnecessary changes * Refactoring and removed font awesome loading from node modules * Updated preview file box look and feel * Fixed file preview icons * Fixed html preview scrolling * Show scrollbar in txt preview * Some refactoring * Refactoring and the dspace BE is loaded from configuration property. * Added messages * Fixed tests * Added download buttons and fixed downloading * Added messages * Added image to the assetstore instead of url from lindat --------- Co-authored-by: HuynhKhoa1601 <[email protected]>
- Loading branch information
1 parent
774e409
commit 80394f1
Showing
33 changed files
with
1,293 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { hasValue } from '../../shared/empty.util'; | ||
import { RemoteData } from './remote-data'; | ||
import { RequestService } from './request.service'; | ||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; | ||
import { HALEndpointService } from '../shared/hal-endpoint.service'; | ||
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model'; | ||
import { Observable } from 'rxjs'; | ||
import { RequestParam } from '../cache/models/request-param.model'; | ||
import { NotificationsService } from '../../shared/notifications/notifications.service'; | ||
import { ObjectCacheService } from '../cache/object-cache.service'; | ||
import { METADATA_BITSTREAM } from '../metadata/metadata-bitstream.resource-type'; | ||
import { MetadataBitstream } from '../metadata/metadata-bitstream.model'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import { Store } from '@ngrx/store'; | ||
import { ChangeAnalyzer } from './change-analyzer'; | ||
import { IdentifiableDataService } from './base/identifiable-data.service'; | ||
import { SearchData, SearchDataImpl } from './base/search-data'; | ||
import { CoreState } from '../core-state.model'; | ||
import { dataService } from './base/data-service.decorator'; | ||
import { FindListOptions } from './find-list-options.model'; | ||
import { linkName } from './clarin/clarin-license-data.service'; | ||
import { PaginatedList } from './paginated-list.model'; | ||
|
||
/** | ||
* A service responsible for fetching/sending data from/to the REST API on the metadatafields endpoint | ||
*/ | ||
@Injectable() | ||
@dataService(METADATA_BITSTREAM) | ||
export class MetadataBitstreamDataService extends IdentifiableDataService<MetadataBitstream> implements SearchData<MetadataBitstream> { | ||
protected store: Store<CoreState>; | ||
protected http: HttpClient; | ||
protected comparator: ChangeAnalyzer<MetadataBitstream>; | ||
protected linkPath = 'metadatabitstreams'; | ||
protected searchByHandleLinkPath = 'byHandle'; | ||
private searchData: SearchData<MetadataBitstream>; | ||
|
||
constructor( | ||
protected requestService: RequestService, | ||
protected rdbService: RemoteDataBuildService, | ||
protected objectCache: ObjectCacheService, | ||
protected halService: HALEndpointService, | ||
protected notificationsService: NotificationsService | ||
) { | ||
super(linkName, requestService, rdbService, objectCache, halService, undefined); | ||
this.searchData = new SearchDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive); | ||
} | ||
|
||
/** | ||
* Find metadata fields with either the partial metadata field name (e.g. "dc.ti") as query or an exact match to | ||
* at least the schema, element or qualifier | ||
* @param handle optional; an exact match of the prefix of the item identifier (e.g. "123456789/1126") | ||
* @param fileGrpType optional; an exact match of the type of the file(e.g. "TEXT", "THUMBNAIL") | ||
* @param options The options info used to retrieve the fields | ||
* @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's no valid cached version. Defaults to true | ||
* @param reRequestOnStale Whether or not the request should automatically be re-requested after the response becomes stale | ||
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved | ||
*/ | ||
searchByHandleParams(handle: string, fileGrpType: string, options: FindListOptions = {}, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<any>[]): Observable<RemoteData<any>> { | ||
const optionParams = Object.assign(new FindListOptions(), options, { | ||
searchParams: [ | ||
new RequestParam('handle', hasValue(handle) ? handle : ''), | ||
new RequestParam( | ||
'fileGrpType', | ||
hasValue(fileGrpType) ? fileGrpType : '' | ||
), | ||
], | ||
}); | ||
return this.searchBy(this.searchByHandleLinkPath, optionParams, useCachedVersionIfAvailable, reRequestOnStale, | ||
...linksToFollow); | ||
} | ||
|
||
searchBy(searchMethod: string, options?: FindListOptions, useCachedVersionIfAvailable?: boolean, reRequestOnStale?: boolean, ...linksToFollow: FollowLinkConfig<MetadataBitstream>[]): Observable<RemoteData<PaginatedList<MetadataBitstream>>> { | ||
return this.searchData.searchBy(searchMethod, options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { autoserialize, autoserializeAs } from 'cerialize'; | ||
|
||
/** | ||
* This class is used to store the information about a file or a directory | ||
*/ | ||
export class FileInfo { | ||
@autoserialize name: string; | ||
@autoserialize content: any; | ||
@autoserialize size: string; | ||
@autoserialize isDirectory: boolean; | ||
@autoserializeAs('sub') sub: { [key: string]: FileInfo }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { | ||
autoserialize, | ||
autoserializeAs, | ||
deserialize, | ||
} from 'cerialize'; | ||
import { ListableObject } from '../../shared/object-collection/shared/listable-object.model'; | ||
import { typedObject } from '../cache/builders/build-decorators'; | ||
import { GenericConstructor } from '../shared/generic-constructor'; | ||
import { HALLink } from '../shared/hal-link.model'; | ||
import { HALResource } from '../shared/hal-resource.model'; | ||
import { ResourceType } from '../shared/resource-type'; | ||
import { excludeFromEquals } from '../utilities/equals.decorators'; | ||
import { METADATA_BITSTREAM } from './metadata-bitstream.resource-type'; | ||
import { FileInfo } from './file-info.model'; | ||
|
||
/** | ||
* Class that represents a MetadataBitstream | ||
*/ | ||
@typedObject | ||
export class MetadataBitstream extends ListableObject implements HALResource { | ||
static type = METADATA_BITSTREAM; | ||
|
||
/** | ||
* The object type | ||
*/ | ||
@excludeFromEquals | ||
@autoserialize | ||
type: ResourceType; | ||
|
||
/** | ||
* The identifier of this metadata field | ||
*/ | ||
@autoserialize | ||
id: number; | ||
|
||
/** | ||
* The name of this bitstream | ||
*/ | ||
@autoserialize | ||
name: string; | ||
|
||
/** | ||
* The description of this bitstream | ||
*/ | ||
@autoserialize | ||
description: string; | ||
|
||
/** | ||
* The fileSize of this bitstream | ||
*/ | ||
@autoserialize | ||
fileSize: string; | ||
|
||
/** | ||
* The checksum of this bitstream | ||
*/ | ||
@autoserialize | ||
checksum: string; | ||
|
||
/** | ||
* The fileInfo of this bitstream | ||
*/ | ||
@autoserializeAs(FileInfo, 'fileInfo') fileInfo: FileInfo[]; | ||
|
||
/** | ||
* The format of this bitstream | ||
*/ | ||
@autoserialize | ||
format: string; | ||
|
||
/** | ||
* The href of this bitstream | ||
*/ | ||
@autoserialize | ||
href: string; | ||
|
||
/** | ||
* The canPreview of this bitstream | ||
*/ | ||
@autoserialize | ||
canPreview: boolean; | ||
|
||
/** | ||
* The {@link HALLink}s for this MetadataField | ||
*/ | ||
@deserialize | ||
_links: { | ||
self: HALLink; | ||
schema: HALLink; | ||
}; | ||
|
||
getRenderTypes(): (string | GenericConstructor<ListableObject>)[] { | ||
return [this.constructor as GenericConstructor<ListableObject>]; | ||
} | ||
} | ||
export { FileInfo }; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ResourceType } from '../shared/resource-type'; | ||
|
||
/** | ||
* The resource type for MetadataBitstream | ||
* | ||
* Needs to be in a separate file to prevent circular | ||
* dependencies in webpack. | ||
*/ | ||
export const METADATA_BITSTREAM = new ResourceType('metadatabitstream'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.