diff --git a/src/api-legacy/__init__.py b/src/api-legacy/__init__.py index 8e3333195..dc917fc1b 100644 --- a/src/api-legacy/__init__.py +++ b/src/api-legacy/__init__.py @@ -35,7 +35,6 @@ from bms.v1.borehole.identifier import IdentifierViewerHandler # Stratigraphy's ACTION Handlers -from bms.v1.borehole.stratigraphy.viewer import StratigraphyViewerHandler from bms.v1.borehole.stratigraphy.producer import StratigraphyProducerHandler # Profiles's ACTION Handlers diff --git a/src/api-legacy/main.py b/src/api-legacy/main.py index 5abd1dfbe..40915a940 100644 --- a/src/api-legacy/main.py +++ b/src/api-legacy/main.py @@ -141,7 +141,6 @@ async def close(application): IdentifierViewerHandler, # Stratigraphy handlers - StratigraphyViewerHandler, StratigraphyProducerHandler, # Layer handlers @@ -220,7 +219,6 @@ async def close(application): (r'/api/v1/feedback', FeedbackHandler), # Stratigraphy handlers (will be deprecated) - (r'/api/v1/borehole/stratigraphy', StratigraphyViewerHandler), (r'/api/v1/borehole/stratigraphy/edit', StratigraphyProducerHandler), # Layer handlers (will be deprecated) diff --git a/src/api-legacy/v1/borehole/stratigraphy/__init__.py b/src/api-legacy/v1/borehole/stratigraphy/__init__.py index 9121f14aa..6dcfc4948 100644 --- a/src/api-legacy/v1/borehole/stratigraphy/__init__.py +++ b/src/api-legacy/v1/borehole/stratigraphy/__init__.py @@ -2,7 +2,6 @@ # Actions from bms.v1.borehole.stratigraphy.addbedrock import AddBedrock -from bms.v1.borehole.stratigraphy.list import ListStratigraphies from bms.v1.borehole.stratigraphy.create import CreateStratigraphy from bms.v1.borehole.stratigraphy.delete import DeleteStratigraphy from bms.v1.borehole.stratigraphy.clone import CloneStratigraphy diff --git a/src/api-legacy/v1/borehole/stratigraphy/list.py b/src/api-legacy/v1/borehole/stratigraphy/list.py deleted file mode 100644 index 4018110ee..000000000 --- a/src/api-legacy/v1/borehole/stratigraphy/list.py +++ /dev/null @@ -1,188 +0,0 @@ -# -*- coding: utf-8 -*- -from bms.v1.action import Action -import math - - -class ListStratigraphies(Action): - - async def execute(self, limit=None, page=None, filter={}, user=None): - - paging = '' - params = [] - where = [] - fkeys = filter.keys() - - permissions = None - if user is not None: - permissions = self.filterPermission(user) - - if 'borehole' in fkeys and filter['borehole'] != '': - params.append(filter['borehole']) - where.append(""" - stratigraphy.id_bho_fk = %s - """ % self.getIdx()) - - if 'kind' in fkeys and filter['kind'] != '': - params.append(filter['kind']) - where.append(""" - stratigraphy.kind_id_cli = %s - """ % self.getIdx()) - - if limit is not None and page is not None: - paging = """ - LIMIT %s - OFFSET %s - """ % (self.getIdx(), self.getIdx()) - params += [ - limit, (int(limit) * (int(page) - 1)) - ] - - rowsSql = """ - SELECT - id_sty as id, - stratigraphy.id_bho_fk as borehole, - stratigraphy.kind_id_cli AS kind, - name_sty as name, - primary_sty as primary, - to_char( - date_sty, - 'YYYY-MM-DD' - ) as date - FROM - bdms.stratigraphy - - INNER JOIN bdms.borehole - ON stratigraphy.id_bho_fk = id_bho - - INNER JOIN ( - SELECT - id_bho_fk, - array_agg( - json_build_object( - 'workflow', id_wkf, - 'role', name_rol, - 'username', username, - 'started', started, - 'finished', finished - ) - ) as status - FROM ( - SELECT - id_bho_fk, - name_rol, - id_wkf, - username, - started_wkf as started, - finished_wkf as finished - FROM - bdms.workflow, - bdms.roles, - bdms.users - WHERE - id_rol = id_rol_fk - AND - id_usr = id_usr_fk - ORDER BY - id_bho_fk asc, id_wkf asc - ) t - GROUP BY - id_bho_fk - ) as v - ON - v.id_bho_fk = id_bho - - """ - - cntSql = """ - SELECT count(*) AS cnt - FROM bdms.stratigraphy - - INNER JOIN bdms.borehole - ON id_bho_fk = id_bho - - INNER JOIN ( - SELECT - id_bho_fk, - array_agg( - json_build_object( - 'workflow', id_wkf, - 'role', name_rol, - 'username', username, - 'started', started, - 'finished', finished - ) - ) as status - FROM ( - SELECT - id_bho_fk, - name_rol, - id_wkf, - username, - started_wkf as started, - finished_wkf as finished - FROM - bdms.workflow, - bdms.roles, - bdms.users - WHERE - id_rol = id_rol_fk - AND - id_usr = id_usr_fk - ORDER BY - id_bho_fk asc, id_wkf asc - ) t - GROUP BY - id_bho_fk - ) as v - ON - v.id_bho_fk = id_bho - """ - - if len(where) > 0: - rowsSql += """ - WHERE %s - """ % " AND ".join(where) - cntSql += """ - WHERE %s - """ % " AND ".join(where) - - - if permissions is not None: - operator = 'AND' if len(where) > 0 else 'WHERE' - rowsSql += """ - {} {} - """.format( - operator, permissions - ) - cntSql += """ - {} {} - """.format( - operator, permissions - ) - - sql = """ - SELECT - array_to_json( - array_agg( - row_to_json(t) - ) - ), - COALESCE(( - %s - ), 0) - FROM ( - %s - ORDER BY date_sty desc - %s - ) AS t - """ % (cntSql, rowsSql, paging) - - rec = await self.conn.fetchrow( - sql, *(params) - ) - return { - "data": self.decode(rec[0]) if rec[0] is not None else [], - "page": page if page is not None else 1, - "pages": math.ceil(rec[1]/limit) if limit is not None else 1, - "rows": rec[1] - } diff --git a/src/api-legacy/v1/borehole/stratigraphy/viewer.py b/src/api-legacy/v1/borehole/stratigraphy/viewer.py deleted file mode 100644 index 4fe3fe8f1..000000000 --- a/src/api-legacy/v1/borehole/stratigraphy/viewer.py +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- -from bms.v1.handlers import Viewer -from bms.v1.borehole.stratigraphy import ( - ListStratigraphies -) - - -class StratigraphyViewerHandler(Viewer): - async def execute(self, request): - action = request.pop('action', None) - - if action in [ - 'LIST', - 'GET' - ]: - - async with self.pool.acquire() as conn: - - exe = None - - request['user'] = self.user - - if action == 'LIST': - exe = ListStratigraphies(conn) - - request.pop('lang', None) - - if exe is not None: - return ( - await exe.execute(**request) - ) - - raise Exception("Action '%s' unknown" % action) diff --git a/src/client/src/api-lib/actions/stratigraphy.js b/src/client/src/api-lib/actions/stratigraphy.js index 3c4812dd7..2ae8d43c8 100644 --- a/src/client/src/api-lib/actions/stratigraphy.js +++ b/src/client/src/api-lib/actions/stratigraphy.js @@ -1,14 +1,5 @@ import { fetch } from "./index"; -export function getStratigraphiesByBorehole(id) { - return fetch("/borehole/stratigraphy", { - action: "LIST", - filter: { - borehole: id, - }, - }); -} - // Create a new stratigraphy for the given borehole id export function createStratigraphy(id, kind = null) { return fetch("/borehole/stratigraphy/edit", { diff --git a/src/client/src/api-lib/index.js b/src/client/src/api-lib/index.js index 067ed4916..16f4f3031 100644 --- a/src/client/src/api-lib/index.js +++ b/src/client/src/api-lib/index.js @@ -76,7 +76,6 @@ import { } from "./actions/workflow"; import { - getStratigraphiesByBorehole, createStratigraphy, deleteStratigraphy, addBedrock, @@ -165,7 +164,6 @@ export { submitWorkflow, rejectWorkflow, resetWorkflow, - getStratigraphiesByBorehole, createStratigraphy, deleteStratigraphy, addBedrock, diff --git a/src/client/src/commons/detail/detailsComponent.js b/src/client/src/commons/detail/detailsComponent.js index ec88fa4d0..b29148623 100644 --- a/src/client/src/commons/detail/detailsComponent.js +++ b/src/client/src/commons/detail/detailsComponent.js @@ -239,10 +239,7 @@ class DetailsComponent extends React.Component { paddingBottom: "1em", overflowY: "hidden", }}> - + , ] ) : detail.isFetching === true ? ( diff --git a/src/client/src/commons/detail/detailsContainer.js b/src/client/src/commons/detail/detailsContainer.js index 05a72be6a..2b824915d 100644 --- a/src/client/src/commons/detail/detailsContainer.js +++ b/src/client/src/commons/detail/detailsContainer.js @@ -4,21 +4,19 @@ import { connect } from "react-redux"; import _ from "lodash"; import DetailsComponent from "./detailsComponent"; -import { getBorehole, getStratigraphiesByBorehole } from "../../api-lib/index"; +import { getBorehole } from "../../api-lib/index"; class DetailsContainer extends React.Component { componentDidMount() { const { id } = this.props; if (!_.isNil(id)) { this.props.getBorehole(id); - // this.props.getStratigraphiesByBorehole(id); } } componentDidUpdate(prevProps) { const { id, detail } = this.props; if (detail.borehole !== null && id !== null && detail.borehole.id !== id) { this.props.getBorehole(id); - // this.props.getStratigraphiesByBorehole(id); } else if (detail.error !== null) { } } @@ -38,7 +36,6 @@ DetailsContainer.propTypes = { detail: PropTypes.object, domains: PropTypes.object, getBorehole: PropTypes.func, - getStratigraphiesByBorehole: PropTypes.func, id: PropTypes.number, }; @@ -71,23 +68,6 @@ const mapDispatchToProps = dispatch => { type: "GETBOREHOLEDETAILS_OK", borehole: response.data.data, }); - getStratigraphiesByBorehole(id) - .then(function (response) { - if (response.data.success) { - dispatch({ - type: "GET_BOREHOLE_STRATIGRAPHIES_OK", - stratigraphies: response.data.data, - }); - } else { - dispatch({ - type: "GET_BOREHOLE_STRATIGRAPHIES_ERROR", - message: response.message, - }); - } - }) - .catch(function (error) { - console.log(error); - }); } else { dispatch({ type: "GETBOREHOLEDETAILS_ERROR", @@ -100,28 +80,6 @@ const mapDispatchToProps = dispatch => { }); } }, - getStratigraphiesByBorehole: id => { - dispatch({ - type: "GET_BOREHOLE_STRATIGRAPHIES", - }); - getStratigraphiesByBorehole(id) - .then(function (response) { - if (response.data.success) { - dispatch({ - type: "GET_BOREHOLE_STRATIGRAPHIES_OK", - stratigraphies: response.data.data, - }); - } else { - dispatch({ - type: "GET_BOREHOLE_STRATIGRAPHIES_ERROR", - message: response.message, - }); - } - }) - .catch(function (error) { - console.log(error); - }); - }, }; }; diff --git a/src/client/src/commons/detail/detailsState.js b/src/client/src/commons/detail/detailsState.js index 7b7b27b4a..7d7af1c60 100644 --- a/src/client/src/commons/detail/detailsState.js +++ b/src/client/src/commons/detail/detailsState.js @@ -1,10 +1,8 @@ const initialState = { error: null, isFetching: false, - isFetchingStratigraphies: false, tab: 0, borehole: null, - stratigraphies: [], }; const detail_borehole = (state = initialState, action) => { @@ -20,7 +18,6 @@ const detail_borehole = (state = initialState, action) => { ...state, error: null, borehole: null, - stratigraphies: [], isFetching: true, }; } @@ -38,20 +35,6 @@ const detail_borehole = (state = initialState, action) => { error: action.error, }; } - case "GET_BOREHOLE_STRATIGRAPHIES": { - return { - ...state, - stratigraphies: [], - isFetchingStratigraphies: true, - }; - } - case "GET_BOREHOLE_STRATIGRAPHIES_OK": { - return { - ...state, - isFetchingStratigraphies: false, - stratigraphies: action.stratigraphies, - }; - } default: return state; } diff --git a/src/client/src/commons/detail/stratigrafy/stratigraphiesComponent.js b/src/client/src/commons/detail/stratigrafy/stratigraphiesComponent.js index 7caab7b28..50b043700 100644 --- a/src/client/src/commons/detail/stratigrafy/stratigraphiesComponent.js +++ b/src/client/src/commons/detail/stratigrafy/stratigraphiesComponent.js @@ -54,13 +54,11 @@ class StratigraphiesComponent extends React.Component { render: () => (
@@ -68,12 +66,7 @@ class StratigraphiesComponent extends React.Component { }, { menuItem: ( - +

@@ -95,7 +88,6 @@ class StratigraphiesComponent extends React.Component { border: "1px solid #D4D4D5", borderTop: "none", padding: "1em", - // border: 'thin solid #cecece' }}> {data.borehole.attachments === 0 ? ( "Empty" @@ -128,7 +120,7 @@ class StratigraphiesComponent extends React.Component { }} options={data.borehole.stratigraphy.map( (ditem, idx2) => ({ - value: idx2, // ditem.id, + value: idx2, selected: ditem.id === item.id, text: (
@@ -175,13 +167,11 @@ class StratigraphiesComponent extends React.Component { render: () => (
@@ -192,7 +182,6 @@ class StratigraphiesComponent extends React.Component { return (