Changeset 306f18a for src


Ignore:
Timestamp:
Feb 23, 2020, 4:11:08 PM (7 years ago)
Author:
Joachim Langenbach <joachim.langenbach@…>
Branches:
debian/bullseye, master
Children:
bd0cb38
Parents:
75adef3
Message:
  • added queue table
    • added logview to make the envelope of a log available
    • Added processing state to Log MetaData and Log table
    • Added icons for the processing state from Breeze
Location:
src
Files:
4 added
7 edited

Legend:

Unmodified
Added
Removed
  • src/mapservice-webclient/src/app/logs/logs.component.html

    r75adef3 r306f18a  
    1212        <th>Start</th>
    1313        <th>End</th>
     14        <th>Status</th>
    1415        <th>Comment</th>
    1516        <th></th>
    … …  
    2526          <td>{{printDate(log.start)}}</td>
    2627          <td>{{printDate(log.end)}}</td>
     28          <td [ngSwitch]="log.processingState.id">
     29            <img *ngSwitchCase="2" class="pure-img state-icon" src='/resources/log-queued.svg' title='Status: {{log.processingState.label}}'>
     30            <img *ngSwitchCase="3" class="pure-img state-icon" src='/resources/processing.svg' title='Status: {{log.processingState.label}}'>
     31            <img *ngSwitchCase="4" class="pure-img state-icon" src='/resources/log-processed.svg' title='Status: {{log.processingState.label}}'>
     32            <img *ngSwitchCase="4" class="pure-img state-icon" src='/resources/log-excluded.svg' title='Status: {{log.processingState.label}}'>
     33            <img *ngSwitchDefault class="pure-img state-icon" src='/resources/log-undefined.svg' title='Status: {{log.processingState.label}}'>
     34          </td>
    2735          <td>{{log.comment}}</td>
    2836          <td>
  • src/mapservice-webclient/src/css/GnuBoat.Mapservice.Webclient.css

    r75adef3 r306f18a  
    185185}
    186186
     187.state-icon {
     188  height: 100%;
     189  max-height: 2em;
     190  width: auto;
     191}
     192
    187193@-webkit-keyframes rotating {
    188194    from{
    … …  
    201207  margin-right: 1em;
    202208}
     209
    203210.footer {
    204211  background-color: var(--gnuboat-primary-light);
  • src/mapservice-webclient/webpack.config.js

    r75adef3 r306f18a  
    4747          { from: '../common/icon/gnuboat-gauge.svg', to: 'resources' },
    4848          { from: '../common/icon/gnuboat-logfile.svg', to: 'resources' },
    49           { from: '../common/icon/gnuboat-water.svg', to: 'resources' }
     49          { from: '../common/icon/gnuboat-water.svg', to: 'resources' },
    5050          { from: '../common/icon/processing.svg', to: 'resources' },
     51          { from: '../common/icon/log-excluded.svg', to: 'resources' },
     52          { from: '../common/icon/log-processed.svg', to: 'resources' },
     53          { from: '../common/icon/log-queued.svg', to: 'resources' },
     54          { from: '../common/icon/log-undefined.svg', to: 'resources' }
    5155        ])
    5256    ],
  • src/mapservice/codegen/templates/requirements.mustache

    r75adef3 r306f18a  
    1111geoalchemy2
    1212sqlalchemy_utc
     13sqlalchemy-utils
    1314gnuboat_common
  • src/mapservice/openapi.yaml

    r75adef3 r306f18a  
    10001000          type: string
    10011001          format: date-time
     1002        processingState:
     1003            $ref: '#/components/schemas/itemBase'
    10021004        entriesCount:
    10031005          title: Number of measurings in the log
  • src/mapservice/src/server_impl/controllers/LogsController.py

    r75adef3 r306f18a  
    1919from gnuboat_common.datahandler import loghandler
    2020
    21 from ..database.Model import User, Log, LogEntry, Water, Device, Gauge, db
     21from ..database.Model import User, Log, LogEntry, Water, Device, Gauge, ProcessingStatus, Queue, db
    2222from ..HttpErrors import MapserviceBadRequest, MapserviceUnauthorized, MapserviceNotFound
    2323
    … …  
    129129                raise MapserviceBadRequest(detail='No log data')
    130130       
     131        processing_state = ProcessingStatus.query.filter_by(label='Queued').all()
     132        if len(processing_state) != 1:
     133                raise MapserviceBadRequest(detail='Processing status Queued not found database')
     134        processing_state = processing_state[0]
     135       
    131136        log = Log.query.filter_by(id=log_id).all()
    132137        if len(log) != 1:
    … …  
    150155                raise MapserviceBadRequest(detail='No start or end date found')
    151156       
    152         log.start = log_callback.start()
    153         log.end = log_callback.end()
    154157        for entry in log_callback.entries():
    155158                if entry.water_depth() is not None:
    … …  
    157160                        log_entry = LogEntry(log=log, datetime=entry.datetime_object(), location='SRID=4326;POINT({} {})'.format(location.longitude, location.latitude), water_depth=entry.water_depth())
    158161                        db.session.add(log_entry)
     162       
     163        queue = Queue(log=log)
     164        db.session.add(queue)
     165       
     166        log.start = log_callback.start()
     167        log.end = log_callback.end()
     168        log.processingstatus = processing_state
     169               
    159170        db.session.commit()
    160171       
  • src/mapservice/src/server_impl/database/Model.py

    r75adef3 r306f18a  
    2222from geoalchemy2.shape import to_shape
    2323from sqlalchemy_utc import UtcDateTime
     24from sqlalchemy_utils import create_view
    2425from shapely import wkb
    2526import hashlib
    … …  
    207208                        result['comment'] = obj.comment
    208209                return result
    209        
     210
     211class ProcessingStatus(db.Model):
     212        __tablename__ = "processingstatus"
     213       
     214        id = db.Column(db.Integer, primary_key=True, autoincrement=True)
     215        label = db.Column(db.String(255), nullable=False)
     216       
     217        @staticmethod
     218        def insert_states():
     219                states = [ 'Undefined', 'Queued', 'Processing', 'Processed', 'To Old' ]
     220                changed = False
     221                for state in states:
     222                        query = ProcessingStatus.query.filter_by(label=state).all()
     223                        if len(query) != 1:
     224                                state = ProcessingStatus(label=state)
     225                                db.session.add(state)
     226                                changed = True
     227                if changed:
     228                        db.session.commit()
     229
    210230class Log(db.Model):
    211231        __tablename__ = "logs"
    … …  
    219239        start = db.Column(UtcDateTime, nullable=True)
    220240        end = db.Column(UtcDateTime, nullable=True)
     241        processing_state = db.Column(db.Integer, db.ForeignKey('processingstatus.id'), default=1)
    221242        comment = db.Column(db.String(255))
    222243       
    … …  
    225246        device = db.relationship("Device", backref=db.backref("logs"), lazy=True)
    226247        gauge = db.relationship("Gauge", backref=db.backref("logs"), lazy=True)
     248        processingstatus = db.relationship("ProcessingStatus", backref=db.backref("logs"), lazy=True)
    227249       
    228250        def meta_data(obj):
    … …  
    244266                        'gaugeLevel': obj.gauge_level,
    245267                        'start': '',
    246                         'end': ''
     268                        'end': '',
     269                        'processingState': {
     270                                'id': obj.processingstatus.id,
     271                                'label': obj.processingstatus.label
     272                        }
    247273                }
    248274                if obj.start is not None:
    … …  
    308334                        result['waterDepth'] = obj.water_depth
    309335                return result
    310        
     336
     337class LogView(db.Model):
     338        __table__ = create_view(
     339                name='logview',
     340                metadata=db.Model.metadata,
     341                selectable=select(
     342                        [
     343                                Log.submitter_id,
     344                                Log.water_id,
     345                                Log.device_id,
     346                                Log.gauge_id,
     347                                Log.gauge_level,
     348                                Log.start,
     349                                Log.end,
     350                                ProcessingStatus.label,
     351                                func.Envelope(func.MakeLine(LogEntry.location)).label('envelope')
     352                        ],
     353                        from_obj=(Log.__table__.join(LogEntry, Log.id == LogEntry.log_id).join(ProcessingStatus, Log.processing_state == ProcessingStatus.id)),
     354                        group_by=(Log.id)
     355                )
     356        )
     357
     358class Queue(db.Model):
     359        __tablename__ = "queue"
     360       
     361        log_id = db.Column(db.Integer, db.ForeignKey('logs.id'), primary_key=True)
     362        datetime = db.Column(UtcDateTime, nullable=False, default=datetime.datetime.now(datetime.timezone.utc))
     363
     364        log = db.relationship("Log", backref=db.backref("queue"), lazy=True)
    311365
    312366def db_setup():
    … …  
    316370                print("...Finished")
    317371        db.create_all()
     372        ProcessingStatus.insert_states()
    318373
    319374def db_test_setup():
    … …  
    410465                        end = datetime.datetime.now(pytz.timezone('Europe/Berlin'))
    411466                        start = end - datetime.timedelta(hours=1)
    412                         log = Log(submitter=test_user_jane, water=mississippi, device=gnuboat_one, gauge=new_orleans, gauge_level=2.2, start=start, end=end, comment='Test log for {}'.format(mississippi.name))
     467                        log = Log(submitter=test_user_jane, water=mississippi, device=gnuboat_one, gauge=new_orleans, gauge_level=2.2, start=start, end=end, processing_state=2, comment='Test log for {}'.format(mississippi.name))
    413468                        db.session.add(log)
    414469                       
    … …  
    418473                                i += 1
    419474                       
    420                        
    421475                        db.session.commit()
    422476                print("...Finished")
Note: See TracChangeset for help on using the changeset viewer.