diff --git a/docker/watching/watch.sh b/docker/watching/watch.sh index 7ddeff54..635c96d5 100755 --- a/docker/watching/watch.sh +++ b/docker/watching/watch.sh @@ -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 diff --git a/scripts/dev-laravel.js b/scripts/dev-laravel.js new file mode 100755 index 00000000..395f33b4 --- /dev/null +++ b/scripts/dev-laravel.js @@ -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); +}); diff --git a/src/app/assets/scss/components/_article-card.scss b/src/app/assets/scss/components/_article-card.scss index bd0a42ea..3b9d349d 100644 --- a/src/app/assets/scss/components/_article-card.scss +++ b/src/app/assets/scss/components/_article-card.scss @@ -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; } \ No newline at end of file diff --git a/src/app/assets/scss/views/river-detail/components/_side-bar-articles.scss b/src/app/assets/scss/views/river-detail/components/_side-bar-articles.scss index 1dce408e..da3046bc 100644 --- a/src/app/assets/scss/views/river-detail/components/_side-bar-articles.scss +++ b/src/app/assets/scss/views/river-detail/components/_side-bar-articles.scss @@ -5,13 +5,10 @@ align-items: center; } - .sidebar-article { + .sidebar-title { &:hover { cursor: pointer; - h5, - p { - text-decoration: underline; - } + text-decoration: underline; } .article-thumb { diff --git a/src/app/global/components/app-toaster/app-toaster.vue b/src/app/global/components/app-toaster/app-toaster.vue index 0b6ee700..9ac58fd7 100644 --- a/src/app/global/components/app-toaster/app-toaster.vue +++ b/src/app/global/components/app-toaster/app-toaster.vue @@ -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(); diff --git a/src/app/global/components/post-update-modal/post-update-modal.vue b/src/app/global/components/post-update-modal/post-update-modal.vue index 532d5b57..2000c4d2 100644 --- a/src/app/global/components/post-update-modal/post-update-modal.vue +++ b/src/app/global/components/post-update-modal/post-update-modal.vue @@ -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) diff --git a/src/app/global/lib/gages/index.js b/src/app/global/lib/gages/index.js new file mode 100644 index 00000000..eb069075 --- /dev/null +++ b/src/app/global/lib/gages/index.js @@ -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 ""; +} diff --git a/src/app/plugins/random-id.js b/src/app/plugins/random-id.js index 89ad0206..1246a239 100644 --- a/src/app/plugins/random-id.js +++ b/src/app/plugins/random-id.js @@ -1,6 +1,6 @@ import Vue from 'vue' -import { nanoid } from 'nanoid' +import { customAlphabet } from 'nanoid' /** * @description use this when creating new resources. @@ -9,5 +9,6 @@ import { nanoid } from 'nanoid' */ Vue.prototype.$randomId = function () { - return nanoid(21, '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz') + const nanoid = customAlphabet('1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 21); + return nanoid(); } diff --git a/src/app/services/updatePost.js b/src/app/services/updatePost.js index de6dcf41..c6fadc66 100644 --- a/src/app/services/updatePost.js +++ b/src/app/services/updatePost.js @@ -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 @@ -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; diff --git a/src/app/store/modules/river-credits.js b/src/app/store/modules/river-credits.js index add0a9c9..e8cf73a6 100644 --- a/src/app/store/modules/river-credits.js +++ b/src/app/store/modules/river-credits.js @@ -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) { diff --git a/src/app/views/river-detail/components/main-tab/components/beta-box/beta-box.vue b/src/app/views/river-detail/components/main-tab/components/beta-box/beta-box.vue index c5210879..b6528f4d 100644 --- a/src/app/views/river-detail/components/main-tab/components/beta-box/beta-box.vue +++ b/src/app/views/river-detail/components/main-tab/components/beta-box/beta-box.vue @@ -41,7 +41,7 @@ Gage