Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2021-02-03 #325

Merged
merged 26 commits into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2e39c49
Merge branch 'main' into 1937-see-more
ericnatejones Jan 1, 2021
6e12567
Merge branch 'development' into 1937-see-more
ericnatejones Jan 1, 2021
57fe922
adds dev server change for running integrated
ryangroth5 Jan 6, 2021
6e43086
Settings that allow the SPA to run integrated.
ryangroth5 Jan 7, 2021
1fcbd18
Merge branch 'development' into features/spa-required-changes
ryangroth5 Jan 20, 2021
0a86f40
articles done. Needs projects
ericnatejones Jan 25, 2021
e8cdbb8
Merge branch 'main' into 1937-see-more
ericnatejones Jan 25, 2021
bc269c1
ready for review
ericnatejones Jan 25, 2021
6484d73
Merge pull request #317 from AmericanWhitewater/features/spa-required…
ryangroth5 Jan 31, 2021
a1d07b4
Reverse River Detail River & Reach Font Sizes #1924
ericnatejones Feb 1, 2021
865774f
See More in rapid descriptions now same font
ericnatejones Feb 1, 2021
a0d4082
Merge branch 'development' into 1937-see-more
ericnatejones Feb 1, 2021
35c1901
fixes display on #1929 - matches correct gage
ryangroth5 Feb 1, 2021
6273f2f
fixes a reference error with navigator object in chrome on non-local …
ryangroth5 Feb 1, 2021
d4b1cf5
Merge pull request #322 from AmericanWhitewater/bugfix/navgator-null-…
ryangroth5 Feb 1, 2021
025347e
type check on parameter
ryangroth5 Feb 1, 2021
5533f12
type check
ryangroth5 Feb 2, 2021
76e6145
fix usage of nanoid to match documentation
ngottlieb Feb 3, 2021
aaca58d
Merge pull request #323 from AmericanWhitewater/bug/rapid-adding-broken
ngottlieb Feb 3, 2021
7c3d01e
fix updatePost service to work for comments like it used to
ngottlieb Feb 3, 2021
a89bc4e
Merge pull request #324 from AmericanWhitewater/bug/new-comment-not-w…
ngottlieb Feb 3, 2021
6225561
Fixes reach credits
mattanger Feb 3, 2021
21e94a6
Merge pull request #321 from AmericanWhitewater/bugfix/1929_beta-gage…
mattanger Feb 3, 2021
a36a743
Merge pull request #326 from AmericanWhitewater/bugfixes/2021-02-32
mattanger Feb 3, 2021
1c5b896
Deleted a personal notes file
ericnatejones Feb 3, 2021
8564c3e
Merge pull request #327 from AmericanWhitewater/1937-see-more
mattanger Feb 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker/watching/watch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
npm config set registry https://npm.americanwhitewater.org
npm i
rm -rf dist/*
npm run serve
node ./scripts/dev-laravel.js
23 changes: 23 additions & 0 deletions scripts/dev-laravel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env node
require("dotenv").config();
// grab cli service requirements.
const { error } = require("@vue/cli-shared-utils");
const Service = require("@vue/cli-service/lib/Service");
const service = new Service(process.env.VUE_CLI_CONTEXT || process.cwd());

//parse the environment base
const url = require("url");
const baseURL = process.env.VUE_APP_BASE_URL || "http://localhost:9669";
const parts = url.parse(baseURL);

const command = "serve";
const publicHost = `${parts.hostname}:${parts.port}`;

//set container name based on URL base.
const args = ["--public", publicHost, "--port", parts.port];
const argsV = { public: publicHost, port: parts.port };

service.run(command, argsV, args).catch((err) => {
error(err);
process.exit(1);
});
11 changes: 11 additions & 0 deletions src/app/assets/scss/components/_article-card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,15 @@
.bx--article-card__icon--action
svg {
fill: $carbon--gray-70; //$disabled-02 for gray 90
}

.abstract-content {
p {
display: inline;
}
}

.read-more {
color: $ui-02;
font-weight: 200;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@
align-items: center;
}

.sidebar-article {
.sidebar-title {
&:hover {
cursor: pointer;
h5,
p {
text-decoration: underline;
}
text-decoration: underline;
}

.article-thumb {
Expand Down
3 changes: 2 additions & 1 deletion src/app/global/components/app-toaster/app-toaster.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ export default {
},
created() {
document.addEventListener("swUpdated", this.showRefreshUI, { once: true });
navigator.serviceWorker.addEventListener("controllerchange", () => {
//navigator.serviceWorker only exists when either https://... or http://localhost/...
navigator && navigator.serviceWorker && navigator.serviceWorker.addEventListener("controllerchange", () => {
if (this.refreshing) return;
this.refreshing = true;
window.location.reload();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export default {
this.formPending = true
this.$emit('update:pending', true)

try {
try {
const result = await updatePost(this.formData)
if (!result.errors) {
this.$emit('update:success', result.data.postUpdate.id)
Expand Down
21 changes: 21 additions & 0 deletions src/app/global/lib/gages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Returns the reading with the precision specified by the gauge format.
* @param reading {number}
* @param metric_format {string} - value from metrics
* @return number with the specified precision
*/

export function formatReading(reading, metric_format) {
if (typeof reading === "number") {
if (metric_format) {
const m = metric_format.match(/%([0-9]+)\.([0-9]+)f/);

if (m.length) {
return reading.toFixed(Number.parseInt(m[2]));
}
}

return reading.toFixed(2);
}
return "";
}
5 changes: 3 additions & 2 deletions src/app/plugins/random-id.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Vue from 'vue'

import { nanoid } from 'nanoid'
import { customAlphabet } from 'nanoid'

/**
* @description use this when creating new resources.
Expand All @@ -9,5 +9,6 @@ import { nanoid } from 'nanoid'
*/

Vue.prototype.$randomId = function () {
return nanoid(21, '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')
const nanoid = customAlphabet('1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 21);
return nanoid();
}
30 changes: 15 additions & 15 deletions src/app/services/updatePost.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import http from "@/app/http";

export async function updatePost(formData, photo) {
//if post is coming in with an ID then remove that property.
const photoCopy = Object.assign({}, photo);
delete photoCopy.id;
photoCopy.post_id = formData.id;
const variables = {
id: formData.id,
post: formData.post
};
if (photo) {
// if post is coming in with an ID then remove that property.
const photoCopy = Object.assign({}, photo);
delete photoCopy.id;
photoCopy.post_id = formData.id;
variables.photo = photoCopy;
variables.photo_id = photo.id;
}
return http
.post("/graphql", {
query: `
mutation ($id:ID!, $photo_id: ID!, $photo: PhotoInput!, $post: PostInput!) {
mutation ($id:ID!, ${photo ? "$photo_id: ID!, $photo: PhotoInput!, " : ''}$post: PostInput!) {
postUpdate(id: $id, post:$post) {
id
detail
Expand All @@ -24,17 +32,9 @@ export async function updatePost(formData, photo) {
uid
}
}
photoUpdate(id: $photo_id, photo: $photo)
{
id
},
${photo ? "photoUpdate(id: $photo_id, photo: $photo) { id }," : '' }
}`,
variables: {
id: formData.id,
post: formData.post,
photo: photoCopy,
photo_id: photo.id,
},
variables: variables,
})
.then((response) => {
return response.data;
Expand Down
3 changes: 1 addition & 2 deletions src/app/store/modules/river-credits.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ export default {
context.commit('DATA_REQUEST')
const result = await getReachCredits(id)


if (!result.errors) {
context.commit('DATA_SUCCESS', result)
context.commit('DATA_SUCCESS', result.data.reach.revisions.data)
}

} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<td>Gage</td>
<template v-if="!loading">
<td
v-if="gages && gages.length"
v-if="gages && gages.length && reachGage && reachGage.gauge"
class="river-gages"
>
<a :href="formatLinkUrl(`content/gauge/detail-new/${reachGage.gauge.id || ''}`)">{{
Expand Down Expand Up @@ -70,7 +70,7 @@
v-if="gages && gages.length"
class="flow-range"
>
{{ formatFlowRange(reachGage.rmin, reachGage.rmax) }}
{{ formatFlowRange(reachGage.rmin, reachGage.rmax, reachGage.gauge_metric) }}
</td>
<td
v-else
Expand All @@ -97,7 +97,7 @@
v-if="gages && gages.length"
class="river-flow-rate"
>
{{ gages[0].gauge_reading }}
{{ formatReading(reachGage.gauge_reading, reachGage.gauge_metric) }}
{{ formatMetric(reachGage.gauge_metric) }}
<cv-tag
v-if="reachGage.adjusted_reach_class"
Expand Down Expand Up @@ -167,6 +167,7 @@
import { mapState } from 'vuex'
import { humanReadable } from '@/app/global/services/human-readable'
import { BetaBoxEditModal } from './components'
import { formatReading } from '@/app/global/lib/gages'

/**
* @todo if reach has multiple gages, add dropdown to
Expand Down Expand Up @@ -200,8 +201,9 @@ export default {
return this.$route.params.id
},
reachGage() {

if (this.river && this.river.readingsummary && this.gages) {
return this.gages.find(g => g.gauge.id.toString() === this.river.readingsummary.gauge_id.toString())
return this.gages.find(g => g.gauge.id.toString() === this.river.readingsummary.gauge_id.toString());
}
return this.gages[0]
}
Expand All @@ -227,18 +229,29 @@ export default {
}
return humanReadable(input)
},
formatFlowRange (min, max) {
formatFlowRange (min, max, metricID) {
if (min && max) {
return `${min} – ${max} ${this.formatMetric(this.gages[0].gauge_metric)}`
return `${this.formatReading(min,metricID)} – ${this.formatReading(max,metricID)} ${this.formatMetric(metricID)}`
}
return 'n/a'
},
getMetric(metricID){
if(metricID && this.metrics?.length)
{
return this.metrics.find(m => m.id === metricID.toString())
}
return null;
},
formatMetric (metricId) {
if (this.metrics) {
return this.metrics.find(m => m.id === metricId.toString())?.unit
return this.getMetric(metricId)?.unit || 'n/a'
}
return 'n/a'
},
formatReading(reading, metricID)
{
return formatReading(reading,this.getMetric(metricID)?.format || '');
},
formatTag (gage) {
if (gage.rmin && gage.rmax && gage.gauge_reading) {
if (gage.gauge_reading < gage.rmin) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,20 @@
<template
v-if="
sanitizedDescription &&
sanitizedDescription.length > characterLimit
sanitizedDescription.length > characterLimit &&
!readMoreActive
"
>
<div
class="description"
v-html="sanitizedDescription.slice(0, characterLimit) + '...'"
/>
<div
v-if="sanitizedDescription && readMoreActive"
v-html="
sanitizedDescription.slice(
characterLimit,
sanitizedDescription.length * 2
)
"
/>

</template>
<template v-else>
<div class="description" v-html="sanitizedDescription" />
</template>

</template>
<template v-else>
<div class>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
<div
v-for="(article, i) in articles.slice(0, 1)"
:key="i + 3 * 4"
class="bx--row mb-spacing-xs sidebar-article"
@keydown.enter="readArticle(article)"
@click.exact="readArticle(article)"
class="bx--row mb-spacing-xs"

>
<div class="bx--col-sm-12 bx--col-md-3">
<img
Expand All @@ -38,12 +37,35 @@
<div class="bx--col-sm-12 bx--col-md-5">
<div class="pt-spacing-sm pb-spacing-md">
<h5
class="mb-spacing-2xs"
class="mb-spacing-2xs sidebar-title"
@click.exact="readArticle(article)"
@keydown.enter="readArticle(article)"
v-text="$titleCase(article.title)"
/>
<p v-html="article.abstract" />
<div
v-if="article.abstract.length > 200"
ref="abstract"
class="abstract-content"

>
<span v-html="article.abstract.slice(0, 200)"/>
<cv-link
:href="articleUrl(article)"
class="read-more">
... Read More
</cv-link>
</div>
<div
v-else
ref="abstract"
class="abstract-content"
v-html="article.abstract"
/>


</div>
</div>

</div>
</template>
<template v-else>
Expand Down Expand Up @@ -79,8 +101,8 @@ export default {
}
return null
},
readArticle (article) {
this.goToLink(this.formatLinkUrl(`content/Article/view/article_id/${article.id}/`))
articleUrl (article) {
return `/content/Article/view/article_id/${article.id}/`
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,25 @@
</h5>
</cv-link>

<p v-html="project.description" />
<div
v-if="project.description.length > 200"
ref="abstract"
class="abstract-content"

>
<span v-html="project.description.slice(0, 200)"/>
<cv-link
:href="projectUrl(project)"
class="read-more">
... Read More
</cv-link>
</div>
<div
v-else
ref="abstract"
class="abstract-content"
v-html="project.description"
/>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export default {
async submitPost () {
this.formPending = true
try {
//upload the details collected from the form, not just reach id etc.
// upload the details collected from the form, not just reach id etc.
await updatePost(this.postFormData, { ...this.formData.photo, id: this.formData.id })

this.$emit('form:success')
Expand Down
Loading