mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-11 11:51:27 +00:00
refactor: location display
This commit is contained in:
@@ -14,7 +14,6 @@ import { MetadataDetails, useMetadata } from '../../../../metadata';
|
|||||||
import ObjectUtils from '../../../../metadata/utils/object-utils';
|
import ObjectUtils from '../../../../metadata/utils/object-utils';
|
||||||
import { getCellValueByColumn, getDateDisplayString, decimalToExposureTime } from '../../../../metadata/utils/cell';
|
import { getCellValueByColumn, getDateDisplayString, decimalToExposureTime } from '../../../../metadata/utils/cell';
|
||||||
import Collapse from './collapse';
|
import Collapse from './collapse';
|
||||||
import Location from './location';
|
|
||||||
|
|
||||||
import './index.css';
|
import './index.css';
|
||||||
|
|
||||||
@@ -126,7 +125,6 @@ const FileDetails = React.memo(({ repoID, repoInfo, dirent, path, direntDetail,
|
|||||||
if (Utils.imageCheck(dirent.name) || Utils.videoCheck(dirent.name)) {
|
if (Utils.imageCheck(dirent.name) || Utils.videoCheck(dirent.name)) {
|
||||||
const fileDetails = getCellValueByColumn(record, { key: PRIVATE_COLUMN_KEY.FILE_DETAILS });
|
const fileDetails = getCellValueByColumn(record, { key: PRIVATE_COLUMN_KEY.FILE_DETAILS });
|
||||||
const fileDetailsJson = JSON.parse(fileDetails?.slice(9, -7) || '{}');
|
const fileDetailsJson = JSON.parse(fileDetails?.slice(9, -7) || '{}');
|
||||||
const fileLocation = getCellValueByColumn(record, { key: PRIVATE_COLUMN_KEY.LOCATION });
|
|
||||||
|
|
||||||
component = (
|
component = (
|
||||||
<>
|
<>
|
||||||
@@ -142,7 +140,6 @@ const FileDetails = React.memo(({ repoID, repoInfo, dirent, path, direntDetail,
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
{record && (<Location position={fileLocation} />)}
|
|
||||||
</Collapse>
|
</Collapse>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@@ -13,6 +13,7 @@ import { gettext } from '../../../utils/constants';
|
|||||||
import { CellType, PREDEFINED_COLUMN_KEYS, PRIVATE_COLUMN_KEY } from '../../constants';
|
import { CellType, PREDEFINED_COLUMN_KEYS, PRIVATE_COLUMN_KEY } from '../../constants';
|
||||||
import { getColumnOptions, getColumnOriginName } from '../../utils/column';
|
import { getColumnOptions, getColumnOriginName } from '../../utils/column';
|
||||||
import { SYSTEM_FOLDERS } from './constants';
|
import { SYSTEM_FOLDERS } from './constants';
|
||||||
|
import Location from './location';
|
||||||
|
|
||||||
import './index.css';
|
import './index.css';
|
||||||
|
|
||||||
@@ -120,6 +121,7 @@ const MetadataDetails = ({ repoID, filePath, repoInfo, direntType, updateRecord
|
|||||||
</DetailItem>
|
</DetailItem>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
{isImage && (<Location position={getCellValueByColumn(record, { key: PRIVATE_COLUMN_KEY.LOCATION })} />)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@@ -1,15 +1,17 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import { initMapInfo, loadMapSource } from '../../../../../utils/map-utils';
|
import { initMapInfo, loadMapSource } from '../../../../utils/map-utils';
|
||||||
import { MAP_TYPE, DOMESTIC_MAP_TYPE } from '../../../../../constants';
|
import { MAP_TYPE, DOMESTIC_MAP_TYPE } from '../../../../constants';
|
||||||
import Loading from '../../../../loading';
|
import Loading from '../../../../components/loading';
|
||||||
import { gettext, baiduMapKey, googleMapKey, googleMapId } from '../../../../../utils/constants';
|
import { gettext, baiduMapKey, googleMapKey, googleMapId } from '../../../../utils/constants';
|
||||||
import { GEOLOCATION_FORMAT } from '../../../../../metadata/constants';
|
import { CellType, GEOLOCATION_FORMAT, PRIVATE_COLUMN_KEY } from '../../../constants';
|
||||||
import { getGeolocationDisplayString } from '../../../../../metadata/utils/cell';
|
import { getGeolocationDisplayString } from '../../../utils/cell';
|
||||||
import { isValidPosition } from '../../../../../metadata/utils/validate';
|
import { isValidPosition } from '../../../utils/validate';
|
||||||
import toaster from '../../../../toast';
|
import toaster from '../../../../components/toast';
|
||||||
import ObjectUtils from '../../../../../metadata/utils/object-utils';
|
import ObjectUtils from '../../../utils/object-utils';
|
||||||
|
import DetailItem from '../../../../components/dirent-detail/detail-item';
|
||||||
|
import { getColumnDisplayName } from '../../../utils/column';
|
||||||
|
|
||||||
import './index.css';
|
import './index.css';
|
||||||
|
|
||||||
@@ -167,11 +169,9 @@ class Location extends React.Component {
|
|||||||
const isValid = isValidPosition(position?.lng, position?.lat);
|
const isValid = isValidPosition(position?.lng, position?.lat);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="dirent-detail-item sf-metadata-property-detail-capture-information-item" key={'location'}>
|
<DetailItem field={{ key: PRIVATE_COLUMN_KEY.LOCATION, type: CellType.GEOLOCATION, name: getColumnDisplayName(PRIVATE_COLUMN_KEY.LOCATION) }} readonly={true}>
|
||||||
<div className="dirent-detail-item-name">{gettext('Location')}</div>
|
{isValid ? (
|
||||||
<div className="dirent-detail-item-value" placeholder={gettext('Empty')}>
|
<div className="sf-metadata-ui cell-formatter-container text-formatter sf-metadata-text-formatter">
|
||||||
{isValid && (
|
|
||||||
<>
|
|
||||||
{!isLoading && this.mapType && address && (
|
{!isLoading && this.mapType && address && (
|
||||||
<>
|
<>
|
||||||
<span>{address}</span>
|
<span>{address}</span>
|
||||||
@@ -179,19 +179,16 @@ class Location extends React.Component {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<span>{getGeolocationDisplayString(position, { geo_format: GEOLOCATION_FORMAT.LNG_LAT })}</span>
|
<span>{getGeolocationDisplayString(position, { geo_format: GEOLOCATION_FORMAT.LNG_LAT })}</span>
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{isLoading ? (<Loading />) : (
|
|
||||||
<>
|
|
||||||
{this.mapType ? (
|
|
||||||
<div className="dirent-detail-item-value-map">
|
|
||||||
{!isLoading && (<div className={classnames('w-100 h-100', { 'd-none': !isValid })} ref={ref => this.ref = ref} id="sf-geolocation-map-container"></div>)}
|
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="dirent-detail-item-value-map alert-danger error-message d-flex justify-content-center">
|
<div className="sf-metadata-record-cell-empty" placeholder={gettext('Empty')}></div>
|
||||||
{gettext('The map plugin is not properly configured. Contact the administrator.')}
|
)}
|
||||||
|
</DetailItem>
|
||||||
|
{isLoading ? (<Loading />) : (
|
||||||
|
<>
|
||||||
|
{this.mapType && (
|
||||||
|
<div className={classnames('dirent-detail-item-value-map', { 'd-none': !isValid })}>
|
||||||
|
<div className="w-100 h-100" ref={ref => this.ref = ref} id="sf-geolocation-map-container"></div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
@@ -43,6 +43,9 @@ window.app.pageOptions = {
|
|||||||
canDownloadFile: {% if can_download_file %}true{% else %}false{% endif %},
|
canDownloadFile: {% if can_download_file %}true{% else %}false{% endif %},
|
||||||
enableWatermark: {% if enable_watermark %}true{% else %}false{% endif %},
|
enableWatermark: {% if enable_watermark %}true{% else %}false{% endif %},
|
||||||
enableMetadataManagement: {% if enable_metadata_management %} true {% else %} false {% endif %},
|
enableMetadataManagement: {% if enable_metadata_management %} true {% else %} false {% endif %},
|
||||||
|
baiduMapKey: '{{ baidu_map_key }}',
|
||||||
|
googleMapKey: '{{ google_map_key }}',
|
||||||
|
googleMapId: '{{ google_map_id }}',
|
||||||
// for {{filetype}} file
|
// for {{filetype}} file
|
||||||
{% block extra_data %}
|
{% block extra_data %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@@ -87,7 +87,8 @@ from seahub.settings import FILE_ENCODING_LIST, FILE_PREVIEW_MAX_SIZE, \
|
|||||||
FILE_ENCODING_TRY_LIST, MEDIA_URL, SEAFILE_COLLAB_SERVER, ENABLE_WATERMARK, \
|
FILE_ENCODING_TRY_LIST, MEDIA_URL, SEAFILE_COLLAB_SERVER, ENABLE_WATERMARK, \
|
||||||
SHARE_LINK_EXPIRE_DAYS_MIN, SHARE_LINK_EXPIRE_DAYS_MAX, SHARE_LINK_PASSWORD_MIN_LENGTH, \
|
SHARE_LINK_EXPIRE_DAYS_MIN, SHARE_LINK_EXPIRE_DAYS_MAX, SHARE_LINK_PASSWORD_MIN_LENGTH, \
|
||||||
SHARE_LINK_FORCE_USE_PASSWORD, SHARE_LINK_PASSWORD_STRENGTH_LEVEL, \
|
SHARE_LINK_FORCE_USE_PASSWORD, SHARE_LINK_PASSWORD_STRENGTH_LEVEL, \
|
||||||
SHARE_LINK_EXPIRE_DAYS_DEFAULT, ENABLE_SHARE_LINK_REPORT_ABUSE, SEADOC_SERVER_URL
|
SHARE_LINK_EXPIRE_DAYS_DEFAULT, ENABLE_SHARE_LINK_REPORT_ABUSE, SEADOC_SERVER_URL, \
|
||||||
|
ENABLE_METADATA_MANAGEMENT, BAIDU_MAP_KEY, GOOGLE_MAP_KEY, GOOGLE_MAP_ID
|
||||||
|
|
||||||
|
|
||||||
# wopi
|
# wopi
|
||||||
@@ -574,10 +575,16 @@ def view_lib_file(request, repo_id, path):
|
|||||||
'share_link_expire_days_max': SHARE_LINK_EXPIRE_DAYS_MAX,
|
'share_link_expire_days_max': SHARE_LINK_EXPIRE_DAYS_MAX,
|
||||||
'can_download_file': parse_repo_perm(permission).can_download,
|
'can_download_file': parse_repo_perm(permission).can_download,
|
||||||
'seafile_collab_server': SEAFILE_COLLAB_SERVER,
|
'seafile_collab_server': SEAFILE_COLLAB_SERVER,
|
||||||
'enable_metadata_management': settings.ENABLE_METADATA_MANAGEMENT,
|
'enable_metadata_management': ENABLE_METADATA_MANAGEMENT,
|
||||||
'file_download_url': gen_file_get_url_new(repo_id, path)
|
'file_download_url': gen_file_get_url_new(repo_id, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ENABLE_METADATA_MANAGEMENT:
|
||||||
|
return_dict['baidu_map_key'] = BAIDU_MAP_KEY
|
||||||
|
return_dict['google_map_key'] = GOOGLE_MAP_KEY
|
||||||
|
return_dict['google_map_id'] = GOOGLE_MAP_ID
|
||||||
|
|
||||||
|
|
||||||
# check whether file is starred
|
# check whether file is starred
|
||||||
is_starred = is_file_starred(username, repo_id, path, org_id)
|
is_starred = is_file_starred(username, repo_id, path, org_id)
|
||||||
return_dict['is_starred'] = is_starred
|
return_dict['is_starred'] = is_starred
|
||||||
|
Reference in New Issue
Block a user