diff --git a/public/check-requirements.html b/public/check-requirements.html index ef04f8afe26adcdd2d16bb871aa28b6372918625..a70c88d1716793ae8a5664591b358a4a61b5913d 100644 --- a/public/check-requirements.html +++ b/public/check-requirements.html @@ -25,6 +25,7 @@ SPDX-License-Identifier: MIT type="module" src="https://pyscript.net/releases/2023.11.1/core.js" ></script> + <script src="https://cdn.jsdelivr.net/pyodide/v0.24.1/full/pyodide.js"></script> </head> <body> diff --git a/public/check-requirements.json b/public/check-requirements.json index e937592329e2c4b47aae2f25eda93b9907003289..5781f065421bd06b28fbd78563ee7268689338c6 100644 --- a/public/check-requirements.json +++ b/public/check-requirements.json @@ -1,3 +1,3 @@ { - "packages": ["arrr"] + "packages": ["pyodide_http", "http://localhost:8080/howfairis-0.14.2-py3-none-any.whl", "http://localhost:8080/ratelimit-2.2.1-py3-none-any.whl", "voluptuous"] } diff --git a/public/check-requirements.py b/public/check-requirements.py index c3dd2ef4edca3618f2e33fceb205a03b7df51e02..579061664cdae9f2a0bf5b38bdb0609e91708165 100644 --- a/public/check-requirements.py +++ b/public/check-requirements.py @@ -1,18 +1,48 @@ -from pyscript import when, document +from pyscript import when, document, window +import pyodide_http +import sys +import voluptuous +from howfairis import Repo, Checker from js import console +pyodide_http.patch_all() + @when("submit", "#categoryForm") def trigger_check(data): # gitURL = data.repoURL console.log("trigger_check was called") console.log(data) + applicationClass = int(document.getElementById("applicationClassSlider").value) + console.log(applicationClass) + gitURL = document.getElementById("repoURL").value + console.log(gitURL) + console.log(document) + console.log(f"Python version: {sys.version_info}") + console.log(f"Volutptuous version: {voluptuous.__version__}") + console.log(f"Pyodide_http version: {pyodide_http.__version__}") + + # url = "https://github.com/fair-software/howfairis" + # repo = Repo(url) + # checker = Checker(repo, is_quiet=False) + # repo_valid = checker.check_repository() + # console.log(f"Repo is checked and valid: {repo_valid}") + + existing_git(gitURL) + + # Cannot access the JS-variable "allStandards" + # and therefore not report back the results of the tests + + # allStd = document.getElementsByName("allStandards") + # console.log(allStd) + # allStandards.value.versionControl.fulfilled = True + # allStandards.value.versionControl.automaticallyChecked = True # if data.applicationClass >= 1: # existing_git(gitURL=gitURL) -# @when("triggerExistingGit", "#checkRequirements") +# @when("triggerExistingGit", "#categoryForm") def existing_git(gitURL): console.log("existing_git was called") console.log(gitURL) - document.allStandards.value.versionControl.fulfilled = True - document.allStandards.value.versionControl.automaticallyChecked = True + window.document.allStandards.value.versionControl.fulfilled = True + window.document.allStandards.value.versionControl.automaticallyChecked = True diff --git a/src/pages/check-requirements.vue b/src/pages/check-requirements.vue index 38dae3470358e487bfa3cab0a666b137a72911d6..a9b97af38a83efb6ec674cf01fc4e9f1259d5172 100644 --- a/src/pages/check-requirements.vue +++ b/src/pages/check-requirements.vue @@ -13,19 +13,18 @@ SPDX-License-Identifier: MIT v-model="category" type="form" :actions="true" - @submit="triggerCheck" - submit-label='Check' + submit-label="Automatically check some requirements" :submit-attr="{ - help: 'Automatically check some requirements', 'py-click': 'trigger_check' }" + @submit="triggerCheck" > <FormKit + id="applicationClassSlider" type="range" label="Application class of the software" help="If you don't know the application class, see the links above to determine it (by table or by decision tree)" name="applicationClass" - id="applicationClassSlider" number="integer" validation="required" min="0" @@ -40,7 +39,7 @@ SPDX-License-Identifier: MIT Your chosen application class is {{ category.applicationClass }} </p> <FormKit - v-if="category.applicationClass>0" + id="repoURL" type="text" label="URL of the git-repository" name="repoURL" @@ -49,21 +48,7 @@ SPDX-License-Identifier: MIT required: 'URL is required if automatic check shall be used.', url: 'A valid URL is required for automatic check to work.' }" - /> - - <!-- <FormKit - v-if="category.applicationClass>0" - class="formkit-input" - type="submit" - name="check_category" - id="" - :disabled="disabled" - help="Automatically check some requirements" - label="Check python" - py-click="trigger_check" - @click="unused" - /> --> </FormKit> <FormKit @@ -147,31 +132,17 @@ import CreateBadge from '@/components/createBadge.vue' import { FormKit } from '@formkit/vue' import { ref } from 'vue' import printJS from 'print-js' -// import * as allStandards from '@/components/standards.json' -// const triggerExistingGit = (allStandards, gitURL) => emit('existingGit', allStandards, gitURL); </script> <script> const getStandards = () => { - let standards = require('@/components/standards.json') - for (const [key, ] of Object.entries(standards)) { - standards[key]['automaticallyChecked'] = false, - standards[key]['fulfilled'] = false - } - return standards + let standards = require('@/components/standards.json') + for (const [key, ] of Object.entries(standards)) { + standards[key]['automaticallyChecked'] = false, + standards[key]['fulfilled'] = false + } + return standards } -// const triggerCheck = (data) => { -// const gitURL = data.repoURL -// if (data.applicationClass >= 1) { -// console.log(gitURL); -// // check versionControl -// emit('existingGit', {allStandards, gitURL}); -// console.log("Triggered python"); -// // allStandards.value.versionControl.fulfilled = validGit(gitURL); -// // allStandards.value.versionControl.automaticallyChecked = true; -// console.log(allStandards.value.versionControl.automaticallyChecked) -// } -// } var allStandards = ref(getStandards()) const category = ref({}) var requiredStandards = ref({})