Mercurial > gemma
changeset 4898:79a5d0c0d2f5 fairway-marks-import
Merge branch default into fairway-marks-import
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Mon, 03 Feb 2020 15:08:06 +0100 |
parents | 638a61fb881b (current diff) de12c9af3abf (diff) |
children | b2d88c680691 |
files | |
diffstat | 9 files changed, 92 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/importconfiguration/Import.vue Fri Jan 31 16:53:06 2020 +0100 +++ b/client/src/components/importconfiguration/Import.vue Mon Feb 03 15:08:06 2020 +0100 @@ -5,12 +5,12 @@ <UISpinnerOverlay v-if="loading" /> <UITableHeader :columns="[ - { id: 'id', title: `${idLabel}`, class: 'col-1' }, - { id: 'kind', title: `${typeLabel}`, class: 'col-1' }, - { id: 'user', title: `${ownerLabel}`, class: 'col-2' }, - { id: 'country', title: `${countryLabel}`, class: 'col-1' }, - { id: 'config.cron', title: `${scheduleLabel}`, class: 'col-2' }, - { id: 'config.send-email', title: `${emailLabel}`, class: 'col-2' } + { id: 'id', title: `${idLabel}`, width: '60px;' }, + { id: 'kind', title: `${typeLabel}`, width: '60px;' }, + { id: 'user', title: `${ownerLabel}`, width: '250px' }, + { id: 'country', title: `${countryLabel}`, width: '80px' }, + { id: 'config.cron', title: `${scheduleLabel}`, width: '100px' }, + { id: 'config.send-email', title: `${emailLabel}`, width: '70px' } ]" /> <UITableBody @@ -18,18 +18,22 @@ :isActive="item => currentSchedule && item.id === currentSchedule.id" > <template v-slot:row="{ item: schedule }"> - <div class="table-cell py-1 col-1">{{ schedule.id }}</div> - <div class="table-cell py-1 col-1"> + <div style="width:60px" class="table-cell py-1"> + {{ schedule.id }} + </div> + <div style="width:60px" class="table-cell py-1"> {{ schedule.kind.toUpperCase() }} </div> - <div style="width:115px;" class="table-cell py-1"> + <div style="width:250px;" class="table-cell py-1"> {{ schedule.user }} </div> - <div style="width:55px;" class="table-cell py-1"> + <div style="width:80px;" class="table-cell py-1"> {{ userCountries[schedule.user] }} </div> - <div class="table-cell py-1 col-2">{{ schedule.config.cron }}</div> - <div class="table-cell py-1 col-2"> + <div style="width:100px" class="table-cell py-1"> + {{ schedule.config.cron }} + </div> + <div style="width:70px" class="table-cell py-1 truncate"> <font-awesome-icon v-if="schedule.config['send-email']" class="fa-fw mr-2" @@ -37,7 +41,7 @@ icon="check" /> </div> - <div class="table-cell py-1 col justify-content-end"> + <div class="table-cell py-1 justify-content-end"> <button @click="triggerManualImport(schedule.id)" class="btn btn-xs btn-dark mr-1"
--- a/client/src/components/importoverview/ImportOverview.vue Fri Jan 31 16:53:06 2020 +0100 +++ b/client/src/components/importoverview/ImportOverview.vue Mon Feb 03 15:08:06 2020 +0100 @@ -77,8 +77,8 @@ </div> <UITableHeader :columns="[ - { id: 'id', title: `${idLabel}`, width: '75px' }, - { id: 'kind', title: `${kindLabel}`, width: '53px' }, + { id: 'id', title: `${idLabel}`, width: '70px' }, + { id: 'kind', title: `${kindLabel}`, width: '50px' }, { id: 'enqueued', title: `${enqueuedLabel}`, width: '138px' }, { id: 'user', title: `${ownerLabel}`, width: '80px' }, { id: 'country', title: `${countryLabel}`, width: '55px' },
--- a/client/src/components/importoverview/LogEntry.vue Fri Jan 31 16:53:06 2020 +0100 +++ b/client/src/components/importoverview/LogEntry.vue Mon Feb 03 15:08:06 2020 +0100 @@ -1,6 +1,6 @@ <template> <div class="row w-100 no-gutters text-left"> - <div style="width: 75px;" class="table-cell d-flex justify-content-between"> + <div style="width: 70px;" class="table-cell d-flex justify-content-between"> <UISpinnerButton @click="toggleDetails" :loading="loading" @@ -9,7 +9,7 @@ /> {{ entry.id }} </div> - <div style="width: 53px;" class="table-cell center"> + <div style="width: 50px;" class="table-cell center"> {{ entry.kind.toUpperCase() }} </div> <div style="width: 138px;" class="table-cell center">
--- a/pkg/controllers/srimports.go Fri Jan 31 16:53:06 2020 +0100 +++ b/pkg/controllers/srimports.go Mon Feb 03 15:08:06 2020 +0100 @@ -40,7 +40,7 @@ const ( soundingResultName = "soundingresult" - maxSoundingResultSize = 25 * 1024 * 1024 + maxSoundingResultSize = 50 * 1024 * 1024 ) func fetchSoundingResult(req *http.Request) (string, error) { @@ -63,11 +63,12 @@ return dst, nil } - return misc.StoreUploadedFile( + return misc.StoreUploadedFileCheck( req, soundingResultName, "sr.zip", maxSoundingResultSize, + true, ) } @@ -194,11 +195,12 @@ func uploadSoundingResult(req *http.Request) (jr mw.JSONResult, err error) { var dir string - if dir, err = misc.StoreUploadedFile( + if dir, err = misc.StoreUploadedFileCheck( req, soundingResultName, "sr.zip", maxSoundingResultSize, + true, ); err != nil { return }
--- a/pkg/misc/http.go Fri Jan 31 16:53:06 2020 +0100 +++ b/pkg/misc/http.go Mon Feb 03 15:08:06 2020 +0100 @@ -15,6 +15,7 @@ import ( "bufio" + "fmt" "io" "io/ioutil" "net/http" @@ -30,7 +31,14 @@ // the given file name. // If the file is long than the given limit maxSize // this function returns an error. -func StoreUploadedFile(req *http.Request, field, fname string, maxSize int64) (string, error) { +func StoreUploadedFile( + req *http.Request, + field, fname string, + maxSize int64) (string, error) { + return StoreUploadedFileCheck(req, field, fname, maxSize, false) +} + +func StoreUploadedFileCheck(req *http.Request, field, fname string, maxSize int64, errorOverMax bool) (string, error) { // Check for direct upload. f, _, err := req.FormFile(field) @@ -52,14 +60,34 @@ out := bufio.NewWriter(o) - if _, err = io.Copy(out, io.LimitReader(f, maxSize)); err != nil { + // Little trick to check if we are over the limit. + size := maxSize + if errorOverMax { + size++ + } + + cleanup := func() { o.Close() os.RemoveAll(dir) + } + + r, err := io.Copy(out, io.LimitReader(f, size)) + if err != nil { + cleanup() return "", err } + if errorOverMax && r > maxSize { + cleanup() + return "", fmt.Errorf("upload exceeded limit of %d bytes", maxSize) + } + if err = out.Flush(); err != nil { - o.Close() + cleanup() + return "", err + } + + if err := o.Close(); err != nil { os.RemoveAll(dir) return "", err }
--- a/pkg/pgxutils/errors.go Fri Jan 31 16:53:06 2020 +0100 +++ b/pkg/pgxutils/errors.go Mon Feb 03 15:08:06 2020 +0100 @@ -147,6 +147,16 @@ return } } + case "internal": + switch err.TableName { + case "user_profiles": + switch err.ConstraintName { + case "user_profiles_username_check": + m = "User name too long" + c = http.StatusBadRequest + return + } + } } case duplicateObject: switch {
--- a/schema/search_functions.sql Fri Jan 31 16:53:06 2020 +0100 +++ b/schema/search_functions.sql Mon Feb 03 15:08:06 2020 +0100 @@ -52,9 +52,11 @@ INTO _result FROM (SELECT objnam AS name, ST_AsGeoJSON(ST_Envelope(area::geometry))::json AS geom, - 'bottleneck' AS type + 'bottleneck' AS type, + bottleneck_id AS location FROM waterway.bottlenecks - WHERE objnam ILIKE '%' || search_string || '%' + WHERE (objnam ILIKE '%' || search_string || '%' + OR bottleneck_id ILIKE '%' || search_string || '%') AND validity @> now() ORDER BY name) r; RETURN _result;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/updates/1316/01.search_for_bottleneck_id.sql Mon Feb 03 15:08:06 2020 +0100 @@ -0,0 +1,20 @@ +CREATE OR REPLACE FUNCTION search_bottlenecks(search_string text) RETURNS jsonb + LANGUAGE plpgsql STABLE PARALLEL SAFE + AS $$ +DECLARE + _result jsonb; +BEGIN + SELECT COALESCE(json_agg(r),'[]') + INTO _result + FROM (SELECT objnam AS name, + ST_AsGeoJSON(ST_Envelope(area::geometry))::json AS geom, + 'bottleneck' AS type, + bottleneck_id AS location + FROM waterway.bottlenecks + WHERE (objnam ILIKE '%' || search_string || '%' + OR bottleneck_id ILIKE '%' || search_string || '%') + AND validity @> now() + ORDER BY name) r; + RETURN _result; +END; +$$;