From b8b0af6a7f9b906cc836af7d20a77035dc98bf11 Mon Sep 17 00:00:00 2001 From: Omar Junior Date: Dec 10 2017 19:47:35 +0000 Subject: [PATCH 1/9] Create user profile layout Signed-off-by: Eduardo Nunes Signed-off-by: Omar Junior --- diff --git a/src/components/profile/FavoritesTable.vue b/src/components/profile/FavoritesTable.vue new file mode 100644 index 0000000..96b0d7b --- /dev/null +++ b/src/components/profile/FavoritesTable.vue @@ -0,0 +1,20 @@ + + + \ No newline at end of file diff --git a/src/components/profile/ProfileForm.vue b/src/components/profile/ProfileForm.vue new file mode 100644 index 0000000..35556fd --- /dev/null +++ b/src/components/profile/ProfileForm.vue @@ -0,0 +1,72 @@ + + + + + + \ No newline at end of file diff --git a/src/components/profile/ProfilePage.vue b/src/components/profile/ProfilePage.vue new file mode 100644 index 0000000..c900685 --- /dev/null +++ b/src/components/profile/ProfilePage.vue @@ -0,0 +1,31 @@ + + + + + diff --git a/src/router/routes.js b/src/router/routes.js index 6d317bb..25ea003 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -1,7 +1,9 @@ import Home from '../components/home/Home.vue' import PackagePage from '../components/package/PackagePage.vue' +import ProfilePage from '../components/profile/ProfilePage.vue' export const routes = [ { name: 'home', path: '', component: Home }, - { name: 'analysis', path: '/analysis/', component: PackagePage, props: route => ({package: route.params.package}) } + { name: 'analysis', path: '/analysis/', component: PackagePage, props: route => ({package: route.params.package}) }, + { name: 'profile-page', path: '/profile', component: ProfilePage } ] From 56708199b640123e3e96cfe6dc647aeb06ea23a1 Mon Sep 17 00:00:00 2001 From: MaxOliveira Date: Dec 10 2017 19:47:42 +0000 Subject: [PATCH 2/9] Create register page Signed-off-by: MaxOliveira Signed-off-by: eduqg --- diff --git a/src/components/register/RegisterForm.vue b/src/components/register/RegisterForm.vue new file mode 100644 index 0000000..87582bd --- /dev/null +++ b/src/components/register/RegisterForm.vue @@ -0,0 +1,79 @@ + + + + + \ No newline at end of file diff --git a/src/components/register/RegisterPage.vue b/src/components/register/RegisterPage.vue new file mode 100644 index 0000000..3d6233d --- /dev/null +++ b/src/components/register/RegisterPage.vue @@ -0,0 +1,34 @@ + + + + + + + + diff --git a/src/router/routes.js b/src/router/routes.js index 25ea003..9fa02c2 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -1,9 +1,11 @@ import Home from '../components/home/Home.vue' import PackagePage from '../components/package/PackagePage.vue' import ProfilePage from '../components/profile/ProfilePage.vue' +import RegisterPage from '../components/register/RegisterPage.vue' export const routes = [ { name: 'home', path: '', component: Home }, { name: 'analysis', path: '/analysis/', component: PackagePage, props: route => ({package: route.params.package}) }, - { name: 'profile-page', path: '/profile', component: ProfilePage } + { name: 'profile-page', path: '/profile', component: ProfilePage }, + { name: 'register-page', path: '/register', component: RegisterPage } ] From 88b604ba2ee2c2f3363d789989fd57863918429e Mon Sep 17 00:00:00 2001 From: MaxOliveira Date: Dec 10 2017 19:47:50 +0000 Subject: [PATCH 3/9] Create login page. - Integrating user data to login on backend Signed-off-by: maxoliveira Signed-off-by: eduqg Signed-off-by: Daniel Moura Signed-off-by: Fabio Teixeira Signed-off-by: Eduardo Gomes Signed-off-by: Rafael Rabetti Signed-off-by: Omar Junior --- diff --git a/.gitignore b/.gitignore index f14e4e1..85f0e51 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ yarn-error.log* test/unit/coverage *lock.json package-lock.json +yarn.lock # Editor directories and files .idea @@ -14,3 +15,4 @@ package-lock.json *.ntvs* *.njsproj *.sln + diff --git a/src/components/login/LoginForm.vue b/src/components/login/LoginForm.vue new file mode 100644 index 0000000..dc281cc --- /dev/null +++ b/src/components/login/LoginForm.vue @@ -0,0 +1,77 @@ + + + + + \ No newline at end of file diff --git a/src/components/login/LoginPage.vue b/src/components/login/LoginPage.vue new file mode 100644 index 0000000..83ef2a7 --- /dev/null +++ b/src/components/login/LoginPage.vue @@ -0,0 +1,29 @@ + + + + + + diff --git a/src/components/register/RegisterPage.vue b/src/components/register/RegisterPage.vue index 3d6233d..6fb6b38 100644 --- a/src/components/register/RegisterPage.vue +++ b/src/components/register/RegisterPage.vue @@ -23,10 +23,7 @@ export default { diff --git a/src/router/routes.js b/src/router/routes.js index 9fa02c2..6cb99e1 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -2,10 +2,12 @@ import Home from '../components/home/Home.vue' import PackagePage from '../components/package/PackagePage.vue' import ProfilePage from '../components/profile/ProfilePage.vue' import RegisterPage from '../components/register/RegisterPage.vue' +import LoginPage from '../components/login/LoginPage.vue' export const routes = [ { name: 'home', path: '', component: Home }, { name: 'analysis', path: '/analysis/', component: PackagePage, props: route => ({package: route.params.package}) }, { name: 'profile-page', path: '/profile', component: ProfilePage }, - { name: 'register-page', path: '/register', component: RegisterPage } + { name: 'register-page', path: '/register', component: RegisterPage }, + { name: 'login-page', path: '/login', component: LoginPage } ] From 402ff824b3b6a8edc205e58286c8c399009b99c2 Mon Sep 17 00:00:00 2001 From: Daniel Date: Dec 10 2017 19:48:10 +0000 Subject: [PATCH 4/9] Create user register Signed-off-by: Daniel Moura Signed-off-by: Fabio Teixeira Signed-off-by: Eduardo Gomes Signed-off-by: Rafael Rabetti Signed-off-by: Omar Junior --- diff --git a/src/components/register/RegisterForm.vue b/src/components/register/RegisterForm.vue index 87582bd..c8c6ec7 100644 --- a/src/components/register/RegisterForm.vue +++ b/src/components/register/RegisterForm.vue @@ -50,6 +50,7 @@ diff --git a/src/components/package/ErrorsTable.vue b/src/components/package/ErrorsTable.vue index 7f0545a..1040ba6 100644 --- a/src/components/package/ErrorsTable.vue +++ b/src/components/package/ErrorsTable.vue @@ -1,28 +1,15 @@ - diff --git a/src/components/package/PackagePage.vue b/src/components/package/PackagePage.vue index 276519a..c8dcc93 100644 --- a/src/components/package/PackagePage.vue +++ b/src/components/package/PackagePage.vue @@ -16,7 +16,14 @@ - + + + + + + + + @@ -25,6 +32,7 @@ import { mapActions, mapGetters } from 'vuex' import * as actionTypes from '../../store/actionTypes.js' import * as getterNames from '../../store/getterNames.js' import SummaryPackage from './SummaryPackage' +import InformationPerFileTable from './InformationPerFileTable' import ErrorsTable from './ErrorsTable' import PieChart from './PieChart' @@ -32,7 +40,8 @@ export default { components: { SummaryPackage, ErrorsTable, - PieChart + PieChart, + InformationPerFileTable }, props: { package: { diff --git a/src/components/package/Search.vue b/src/components/package/Search.vue index 37d55f5..cc89481 100644 --- a/src/components/package/Search.vue +++ b/src/components/package/Search.vue @@ -78,6 +78,11 @@ export default { } } +.row { + margin-right: 0px!important; + margin-left: 0px!important; +} + .search-wrapper { /*background-image: url('/static/grey.jpg');*/ background-size: cover; diff --git a/src/components/package/SummaryPackage.vue b/src/components/package/SummaryPackage.vue index a7e7394..103f592 100644 --- a/src/components/package/SummaryPackage.vue +++ b/src/components/package/SummaryPackage.vue @@ -1,7 +1,7 @@ diff --git a/src/components/packages/jsonItems.json b/src/components/packages/jsonItems.json deleted file mode 100644 index cecb76a..0000000 --- a/src/components/packages/jsonItems.json +++ /dev/null @@ -1,291 +0,0 @@ -{ - "analysis": { - "analyzer_id": 1, - "id": 1, - "raw": { - "customfields": null, - "metadata": { - "file_": null, - "generator": { - "name": "cppcheck", - "version": "1.80" - }, - "stats": null, - "sut": null - }, - "results": [ - { - "customfields": null, - "cwe": null, - "location": { - "file": { - "abspath": null, - "givenpath": "source/active_children.c", - "hash_": null - }, - "function": null, - "point": { - "column": 0, - "line": 42 - }, - "range_": null - }, - "message": { - "text": "Unused variable: stdin_descriptor" - }, - "notes": null, - "severity": "style", - "testid": "unusedVariable", - "trace": null, - "type": "Issue" - }, - { - "customfields": null, - "cwe": null, - "location": { - "file": { - "abspath": null, - "givenpath": "source/father.c", - "hash_": null - }, - "function": null, - "point": { - "column": 0, - "line": 43 - }, - "range_": null - }, - "message": { - "text": "The scope of the variable 'times' can be reduced." - }, - "notes": { - "text": "The scope of the variable 'times' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:\\012void f(int x)\\012{\\012 int i = 0;\\012 if (x) {\\012 // it's safe to move 'int i = 0;' here\\012 for (int n = 0; n < 10; ++n) {\\012 // it is possible but not safe to move 'int i = 0;' here\\012 do_something(&i);\\012 }\\012 }\\012}\\012When you see this message it is always safe to reduce the variable scope 1 level." - }, - "severity": "style", - "testid": "variableScope", - "trace": null, - "type": "Issue" - }, - { - "customfields": null, - "cwe": null, - "location": { - "file": { - "abspath": null, - "givenpath": "source/father.c", - "hash_": null - }, - "function": null, - "point": { - "column": 0, - "line": 45 - }, - "range_": null - }, - "message": { - "text": "The scope of the variable 'complete_msg_sleepy' can be reduced." - }, - "notes": { - "text": "The scope of the variable 'complete_msg_sleepy' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:\\012void f(int x)\\012{\\012 int i = 0;\\012 if (x) {\\012 // it's safe to move 'int i = 0;' here\\012 for (int n = 0; n < 10; ++n) {\\012 // it is possible but not safe to move 'int i = 0;' here\\012 do_something(&i);\\012 }\\012 }\\012}\\012When you see this message it is always safe to reduce the variable scope 1 level." - }, - "severity": "style", - "testid": "variableScope", - "trace": null, - "type": "Issue" - }, - { - "customfields": null, - "cwe": null, - "location": { - "file": { - "abspath": null, - "givenpath": "source/father.c", - "hash_": null - }, - "function": null, - "point": { - "column": 0, - "line": 46 - }, - "range_": null - }, - "message": { - "text": "The scope of the variable 'complete_msg_active' can be reduced." - }, - "notes": { - "text": "The scope of the variable 'complete_msg_active' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:\\012void f(int x)\\012{\\012 int i = 0;\\012 if (x) {\\012 // it's safe to move 'int i = 0;' here\\012 for (int n = 0; n < 10; ++n) {\\012 // it is possible but not safe to move 'int i = 0;' here\\012 do_something(&i);\\012 }\\012 }\\012}\\012When you see this message it is always safe to reduce the variable scope 1 level." - }, - "severity": "style", - "testid": "variableScope", - "trace": null, - "type": "Issue" - }, - { - "customfields": null, - "cwe": null, - "location": { - "file": { - "abspath": null, - "givenpath": "source/father.c", - "hash_": null - }, - "function": null, - "point": { - "column": 0, - "line": 77 - }, - "range_": null - }, - "message": { - "text": "The scope of the variable 'seconds' can be reduced." - }, - "notes": { - "text": "The scope of the variable 'seconds' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:\\012void f(int x)\\012{\\012 int i = 0;\\012 if (x) {\\012 // it's safe to move 'int i = 0;' here\\012 for (int n = 0; n < 10; ++n) {\\012 // it is possible but not safe to move 'int i = 0;' here\\012 do_something(&i);\\012 }\\012 }\\012}\\012When you see this message it is always safe to reduce the variable scope 1 level." - }, - "severity": "style", - "testid": "variableScope", - "trace": null, - "type": "Issue" - }, - { - "customfields": null, - "cwe": null, - "location": { - "file": { - "abspath": null, - "givenpath": "source/father.c", - "hash_": null - }, - "function": null, - "point": { - "column": 0, - "line": 114 - }, - "range_": null - }, - "message": { - "text": "Uninitialized variable: readbuffer_active" - }, - "notes": null, - "severity": "error", - "testid": "uninitvar", - "trace": null, - "type": "Issue" - }, - { - "customfields": null, - "cwe": null, - "location": { - "file": { - "abspath": null, - "givenpath": "source/main.c", - "hash_": null - }, - "function": null, - "point": { - "column": 0, - "line": 14 - }, - "range_": null - }, - "message": { - "text": "Uninitialized variable: sleepy_children" - }, - "notes": null, - "severity": "error", - "testid": "uninitvar", - "trace": null, - "type": "Issue" - }, - { - "customfields": null, - "cwe": null, - "location": { - "file": { - "abspath": null, - "givenpath": "source/main.c", - "hash_": null - }, - "function": null, - "point": { - "column": 0, - "line": 14 - }, - "range_": null - }, - "message": { - "text": "Uninitialized variable: active_children" - }, - "notes": null, - "severity": "error", - "testid": "uninitvar", - "trace": null, - "type": "Issue" - }, - { - "customfields": null, - "cwe": null, - "location": { - "file": { - "abspath": null, - "givenpath": "source/sleepy_children.c", - "hash_": null - }, - "function": null, - "point": { - "column": 0, - "line": 30 - }, - "range_": null - }, - "message": { - "text": "The scope of the variable 'time_to_sleep' can be reduced." - }, - "notes": { - "text": "The scope of the variable 'time_to_sleep' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:\\012void f(int x)\\012{\\012 int i = 0;\\012 if (x) {\\012 // it's safe to move 'int i = 0;' here\\012 for (int n = 0; n < 10; ++n) {\\012 // it is possible but not safe to move 'int i = 0;' here\\012 do_something(&i);\\012 }\\012 }\\012}\\012When you see this message it is always safe to reduce the variable scope 1 level." - }, - "severity": "style", - "testid": "variableScope", - "trace": null, - "type": "Issue" - }, - { - "customfields": null, - "cwe": null, - "location": { - "file": { - "abspath": null, - "givenpath": "source/sleepy_children.c", - "hash_": null - }, - "function": null, - "point": { - "column": 0, - "line": 28 - }, - "range_": null - }, - "message": { - "text": "Unused variable: readbuffer_sleepy" - }, - "notes": null, - "severity": "style", - "testid": "unusedVariable", - "trace": null, - "type": "Issue" - } - - ] - }, - "reports": [ - { - "analysis_id": 1, - "errors": 3, - "id": 1, - "styles": 7, - "warnings": 0 - } - ], - "version_id": 1 - } -} diff --git a/src/components/shared/DefaultTable.vue b/src/components/shared/DefaultTable.vue new file mode 100644 index 0000000..a21ee6a --- /dev/null +++ b/src/components/shared/DefaultTable.vue @@ -0,0 +1,79 @@ + + diff --git a/src/store/modules/analysis.js b/src/store/modules/analysis.js index 81fdfb9..801f4f8 100644 --- a/src/store/modules/analysis.js +++ b/src/store/modules/analysis.js @@ -249,7 +249,7 @@ const state = { 'notes': { 'text': `The scope of the variable 'time_to_sleep' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:\\012void f(int x)\\012{\\012 int i = 0;\\012 if (x) {\\012 // it's safe to move 'int i = 0;' here\\012 for (int n = 0; n < 10; ++n) {\\012 // it is possible but not safe to move 'int i = 0;' here\\012 do_something(&i);\\012 }\\012 }\\012}\\012When you see this message it is always safe to reduce the variable scope 1 level.` }, - 'severity': 'style', + 'severity': 'warnings', 'testid': 'variableScope', 'trace': null, 'type': 'Issue' @@ -274,7 +274,7 @@ const state = { 'text': 'Unused variable: readbuffer_sleepy' }, 'notes': null, - 'severity': 'style', + 'severity': 'warnings', 'testid': 'unusedVariable', 'trace': null, 'type': 'Issue' @@ -297,8 +297,8 @@ const state = { 'id': 1, 'results': { 'errors': 3, - 'styles': 7, - 'warnings': 0 + 'styles': 5, + 'warnings': 2 } }, 'version_id': 1 @@ -323,9 +323,10 @@ const state = { 'id': 2, 'analyzer_id': 1, 'results': { - 'styles': 10, + 'errors': 10, 'warnings': 3, - 'errors': 4 + 'style': 4, + 'Other': 15 } }, 'version_id': 2 diff --git a/src/store/modules/packages.js b/src/store/modules/packages.js index 008592f..11bca3e 100644 --- a/src/store/modules/packages.js +++ b/src/store/modules/packages.js @@ -110,7 +110,7 @@ const mutations = { return { package_id: pkg.versions[0].package_id, name: pkg.name, - + last_updated: pkg.lastUpdate, last_version: pkg.versions[0].number, fetcher_id: pkg.fetcher_id, analyzer_id: pkg.versions[0].analysis[0].analyzer_id From 029cb7a892c97ea87bf763922bf132100404d26b Mon Sep 17 00:00:00 2001 From: MatheusMello Date: Dec 10 2017 19:51:21 +0000 Subject: [PATCH 6/9] Header Anchors to Login and Register - Login and Register validation and style Signed-off-by: MatheusMello Signed-off-by: RafaelRabetti Signed-off-by EduardoQuintino Signed-off-by MaxOliveira --- diff --git a/src/components/login/LoginForm.vue b/src/components/login/LoginForm.vue index dc281cc..d6613fe 100644 --- a/src/components/login/LoginForm.vue +++ b/src/components/login/LoginForm.vue @@ -1,6 +1,10 @@ - diff --git a/src/components/register/RegisterForm.vue b/src/components/register/RegisterForm.vue index 016c3cc..5164ab6 100644 --- a/src/components/register/RegisterForm.vue +++ b/src/components/register/RegisterForm.vue @@ -1,6 +1,10 @@ @@ -125,4 +142,8 @@ margin-bottom: 10px; color: rgb(10, 46, 96); } + .route-card { + vertical-align: center; + padding-top: 1em; + } diff --git a/src/components/register/RegisterPage.vue b/src/components/register/RegisterPage.vue index 2abda56..3c0b0ef 100644 --- a/src/components/register/RegisterPage.vue +++ b/src/components/register/RegisterPage.vue @@ -28,9 +28,5 @@ export default { .register-form { margin: auto; - padding-top: 3%; } - - - diff --git a/src/components/shared/DefaultTable.vue b/src/components/shared/DefaultTable.vue index a21ee6a..5c5b65a 100644 --- a/src/components/shared/DefaultTable.vue +++ b/src/components/shared/DefaultTable.vue @@ -16,7 +16,7 @@ - +

- + Login Register From 8702f90b7d6779bca1e3ab8fb252cfeebced3b78 Mon Sep 17 00:00:00 2001 From: Vitor Borges Date: Dec 10 2017 19:53:20 +0000 Subject: [PATCH 8/9] [API] Add api endpoint for packages Signed-off-by: MatheusGodinho Signed-off-by: Vitor Borges --- diff --git a/src/api/analyzers.js b/src/api/analyzers.js new file mode 100644 index 0000000..f5a33d4 --- /dev/null +++ b/src/api/analyzers.js @@ -0,0 +1,7 @@ +import axios from '.' + +export default { + get: (currentPackage) => { + return axios.get(`/analysis/${currentPackage.name}/${currentPackage.version}`) + } +} diff --git a/src/components/package/PackagePage.vue b/src/components/package/PackagePage.vue index 3e1ba03..54c8d9a 100644 --- a/src/components/package/PackagePage.vue +++ b/src/components/package/PackagePage.vue @@ -4,18 +4,20 @@

- Selecione um analizador para verificar os erros: - - {{ analizer.name }} + Select an analyzer + + {{ analyzer.name }}

-

Total de erros do analizador {{ analizers[selectedAnalizer].name }}:

+

Total complaints from {{ selectedAnalyzerName }}

{{ total }}

-
- +
+
+ +
@@ -26,7 +28,7 @@ - + int for packages
@@ -38,8 +40,19 @@ import SummaryPackage from './SummaryPackage' import InformationPerFileTable from './InformationPerFileTable' import ErrorsTable from './ErrorsTable' import PieChart from './PieChart' +import store from '../../store' export default { + async beforeRouteEnter (to, from, next) { + try { + // await Do something before router PUSH + // next(vm => vm.foo = bar) + await store.dispatch('fetchAnalyzers', to.params.package) + next() + } catch (err) { + console.log(err) + } + }, components: { SummaryPackage, ErrorsTable, @@ -56,12 +69,12 @@ export default { }, data () { return { - selectedAnalizer: 0 + selectedAnalyzerId: 0 } }, computed: { ...mapGetters([ - getterNames.analizers, + getterNames.analyzers, getterNames.reports ]), pkg () { @@ -70,6 +83,16 @@ export default { packageNameVersion () { return this.pkg.name + ' - v' + this.pkg.last_version }, + selectedAnalyzer () { + return ( + this.analyzers + .filter(a => a.id === this.selectedAnalyzerId) || + [{name: 'teste', id: 0}] + )[0] + }, + selectedAnalyzerName () { + return (this.selectedAnalyzer || {name: 'error'}).name + }, datasets () { const labels = Object.keys(this.reports) const data = labels.map((key) => { @@ -92,15 +115,14 @@ export default { }, methods: { ...mapActions([ - actionTypes.SET_SELECTED + actionTypes.FETCH_ANALYZERS ]), - onSelectAnalizer (index) { - this.selectedAnalizer = index - this.setSelected(this.analizers[this.selectedAnalizer].id) + onSelectAnalyzer (index, analyzer) { + this.selectedAnalyzerId = analyzer.id } }, - mounted () { - this.setSelected(this.analizers[this.selectedAnalizer].id) + async mounted () { + this.selectedAnalyzerId = this.analyzers[0].id } } diff --git a/src/store/actionTypes.js b/src/store/actionTypes.js index 3cbf87c..1469345 100644 --- a/src/store/actionTypes.js +++ b/src/store/actionTypes.js @@ -1,4 +1,6 @@ // Packages export const FETCH_PACKAGES = 'fetchPackages' -export const SET_SELECTED = 'setSelected' export const FILTERED_PACKAGES = 'filteredPackages' + +// Analyzers +export const FETCH_ANALYZERS = 'fetchAnalyzers' diff --git a/src/store/getterNames.js b/src/store/getterNames.js index 2ffb321..971ffe7 100644 --- a/src/store/getterNames.js +++ b/src/store/getterNames.js @@ -1,6 +1,6 @@ // Packages export const allPackages = 'allPackages' -export const analizers = 'analizers' +export const analyzers = 'analyzers' export const reports = 'reports' export const errorsList = 'errorsList' export const filteredPackages = 'filteredPackages' diff --git a/src/store/index.js b/src/store/index.js index 2b4a4c9..3821c50 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,11 +1,11 @@ import Vuex from 'vuex' import packages from './modules/packages' -import analisys from './modules/analysis' +import analyzers from './modules/analyzers' export default new Vuex.Store({ modules: { packages, - analisys + analyzers } }) diff --git a/src/store/modules/analyzers.js b/src/store/modules/analyzers.js new file mode 100644 index 0000000..06c340d --- /dev/null +++ b/src/store/modules/analyzers.js @@ -0,0 +1,42 @@ +import * as actionTypes from '../actionTypes' +import * as getterNames from '../getterNames' +import * as mutationTypes from '../mutationsTypes' +import api from '../../api/analyzers' + +const state = { + analyzers: [] +} + +const getters = { + [getterNames.analyzers]: (state) => { + return state.analyzers + }, + [getterNames.reports]: (state) => { + return [] + }, + [getterNames.errorsList]: (state) => { + return [] + } +} + +const actions = { + async [actionTypes.FETCH_ANALYZERS] ({commit, getters, state}, currentPackage) { + console.log(currentPackage) + let { data } = await api.get(currentPackage) + console.log(data) + commit(mutationTypes.STORE_ANALYZERS, data) + } +} + +const mutations = { + [mutationTypes.STORE_ANALYZERS] (state, data) { + state.analyzers = data + } +} + +export default { + state, + getters, + actions, + mutations +} diff --git a/src/store/modules/packages.js b/src/store/modules/packages.js index 11bca3e..cd9dd27 100644 --- a/src/store/modules/packages.js +++ b/src/store/modules/packages.js @@ -1,73 +1,10 @@ -// import api from '../../api/packages' +import api from '../../api/packages' import * as actionTypes from '../actionTypes' import * as getterNames from '../getterNames' import * as mutationTypes from '../mutationsTypes' -// const mockedPackages = [ -// { -// name: 'example1', -// last_version: '0.1' -// }, -// { -// name: 'foo1', -// last_version: '0.2' -// }, -// { -// name: 'example2', -// last_version: '0.3' -// } -// ] - -const mockedPackages = [ - { - name: 'Fedora Package', - version: '0.3.8', - upstream: 'http://www.google.com', - lastUpdate: '17/09/2017', - last_version: '0.1', - versions: [ - {analysis: [ - {analyzer_id: '2'} - ], - number: '2', - package_id: '1' - } - ] - }, - { - name: 'Pacote de Dados', - version: '0.3.8', - upstream: 'http://www.google.com', - lastUpdate: '17/09/2017', - last_version: '0.2', - versions: [ - {analysis: [ - {analyzer_id: '3'} - ], - number: '2', - package_id: '1' - } - ] - }, - { - name: 'Teste', - version: '0.3.8', - upstream: 'http://www.google.com', - lastUpdate: '17/09/2017', - last_version: '0.3', - versions: [ - {analysis: [ - {analyzer_id: '1'} - ], - number: '2', - package_id: '1' - } - ] - } -] - const state = { - allPackages: mockedPackages, + allPackages: [], filteredPackages: {} } @@ -83,21 +20,17 @@ const getters = { const actions = { async [actionTypes.FETCH_PACKAGES] ({commit, getters, state}, search) { // let { data } = await api.get() - let data = [] + let { data } = await api.get() + let results = [] if (!search) { - data = mockedPackages + results = data.packages } else { - data = mockedPackages.filter((pkg) => { + results = data.packages.filter((pkg) => { return pkg.name.includes(search) }) } - commit(mutationTypes.STORE_PACKAGES, data) - - if (data.length === 0) { - return false - } else { - return true - } + commit(mutationTypes.STORE_PACKAGES, results) + return true }, async [actionTypes.FILTERED_PACKAGES] ({commit, getters, state}, search) { commit(mutationTypes.FILTER_PACKAGES, search) @@ -106,16 +39,7 @@ const actions = { const mutations = { [mutationTypes.STORE_PACKAGES] (state, data) { - state.allPackages = data.map((pkg) => { - return { - package_id: pkg.versions[0].package_id, - name: pkg.name, - last_updated: pkg.lastUpdate, - last_version: pkg.versions[0].number, - fetcher_id: pkg.fetcher_id, - analyzer_id: pkg.versions[0].analysis[0].analyzer_id - } - }) + state.allPackages = data }, [mutationTypes.FILTER_PACKAGES] (state, search) { state.filtered = state.allPackages.map((pkg) => { diff --git a/src/store/mutationsTypes.js b/src/store/mutationsTypes.js index f2ba8b2..c34f0c0 100644 --- a/src/store/mutationsTypes.js +++ b/src/store/mutationsTypes.js @@ -2,3 +2,6 @@ export const STORE_PACKAGES = 'STORE_PACKAGES' export const STORE_SELECTED = 'STORE_SELECTED' export const FILTER_PACKAGES = 'FILTER_PACKAGES' + +// Analyzers +export const STORE_ANALYZERS = 'STORE_ANALYZERS' From f9396960496797994e7f956029ca1ae45e1e8b32 Mon Sep 17 00:00:00 2001 From: Vitor Borges Date: Dec 10 2017 20:37:41 +0000 Subject: [PATCH 9/9] Adding route recovery package logic - Fix confusion between analyzers and analysis on store --- diff --git a/src/api/analysis.js b/src/api/analysis.js new file mode 100644 index 0000000..3801b1a --- /dev/null +++ b/src/api/analysis.js @@ -0,0 +1,13 @@ +import axios from '.' + +export default { + get: (currentPackage) => { + return axios.get(`/analysis/${currentPackage.name}/${currentPackage.versions}`) + }, + getReports: (currentPackage, id) => { + return axios.get(`/analysis/${currentPackage.name}/${currentPackage.version}/${id}/reports`) + }, + getResults: (currentPackage, id) => { + return axios.get(`/analysis/${currentPackage.name}/${currentPackage.version}/${id}/results`) + } +} diff --git a/src/api/analyzers.js b/src/api/analyzers.js deleted file mode 100644 index f5a33d4..0000000 --- a/src/api/analyzers.js +++ /dev/null @@ -1,7 +0,0 @@ -import axios from '.' - -export default { - get: (currentPackage) => { - return axios.get(`/analysis/${currentPackage.name}/${currentPackage.version}`) - } -} diff --git a/src/components/package/ErrorsTable.vue b/src/components/package/ErrorsTable.vue index 817b1a6..632ef7a 100644 --- a/src/components/package/ErrorsTable.vue +++ b/src/components/package/ErrorsTable.vue @@ -1,5 +1,5 @@ diff --git a/src/router/routes.js b/src/router/routes.js index 6cb99e1..cb3d611 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -6,7 +6,7 @@ import LoginPage from '../components/login/LoginPage.vue' export const routes = [ { name: 'home', path: '', component: Home }, - { name: 'analysis', path: '/analysis/', component: PackagePage, props: route => ({package: route.params.package}) }, + { name: 'analysis', path: '/analysis/', component: PackagePage, props: route => ({package: route.params.package}), query: { package: 'Test' } }, { name: 'profile-page', path: '/profile', component: ProfilePage }, { name: 'register-page', path: '/register', component: RegisterPage }, { name: 'login-page', path: '/login', component: LoginPage } diff --git a/src/store/actionTypes.js b/src/store/actionTypes.js index 1469345..e90584a 100644 --- a/src/store/actionTypes.js +++ b/src/store/actionTypes.js @@ -3,4 +3,7 @@ export const FETCH_PACKAGES = 'fetchPackages' export const FILTERED_PACKAGES = 'filteredPackages' // Analyzers -export const FETCH_ANALYZERS = 'fetchAnalyzers' +export const FETCH_ANALYSIS = 'fetchAnalysis' + +// Analysis +export const FETCH_ANALYSIS_DATA = 'fetchAnalysisData' diff --git a/src/store/getterNames.js b/src/store/getterNames.js index 971ffe7..a52326b 100644 --- a/src/store/getterNames.js +++ b/src/store/getterNames.js @@ -1,6 +1,6 @@ // Packages export const allPackages = 'allPackages' -export const analyzers = 'analyzers' +export const analysis = 'analysis' export const reports = 'reports' export const errorsList = 'errorsList' export const filteredPackages = 'filteredPackages' diff --git a/src/store/index.js b/src/store/index.js index 3821c50..f3b9238 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,11 +1,13 @@ import Vuex from 'vuex' import packages from './modules/packages' -import analyzers from './modules/analyzers' +import analysis from './modules/analysis' +import analysisData from './modules/analysisData' export default new Vuex.Store({ modules: { packages, - analyzers + analysisData, + analysis } }) diff --git a/src/store/modules/analysis.js b/src/store/modules/analysis.js index 801f4f8..45ca73c 100644 --- a/src/store/modules/analysis.js +++ b/src/store/modules/analysis.js @@ -1,371 +1,28 @@ import * as actionTypes from '../actionTypes' import * as getterNames from '../getterNames' import * as mutationTypes from '../mutationsTypes' +import api from '../../api/analysis' const state = { - analysis: [ - { - 'analyzer_id': 1, - 'id': 1, - 'raw': { - 'customfields': null, - 'metadata': { - 'file_': null, - 'generator': { - 'name': 'cppcheck', - 'version': '1.80' - }, - 'stats': null, - 'sut': null - }, - 'results': [ - { - 'customfields': null, - 'cwe': null, - 'location': { - 'file': { - 'abspath': null, - 'givenpath': 'source/active_children.c', - 'hash_': null - }, - 'function': null, - 'point': { - 'column': 0, - 'line': 42 - }, - 'range_': null - }, - 'message': { - 'text': 'Unused variable: stdin_descriptor' - }, - 'notes': null, - 'severity': 'style', - 'testid': 'unusedVariable', - 'trace': null, - 'type': 'Issue' - }, - { - 'customfields': null, - 'cwe': null, - 'location': { - 'file': { - 'abspath': null, - 'givenpath': 'source/father.c', - 'hash_': null - }, - 'function': null, - 'point': { - 'column': 0, - 'line': 43 - }, - 'range_': null - }, - 'message': { - 'text': 'The scope of the variable \'times\' can be reduced.' - }, - 'notes': { - 'text': `The scope of the variable 'times' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:\\012void f(int x)\\012{\\012 int i = 0;\\012 if (x) {\\012 // it's safe to move 'int i = 0;' here\\012 for (int n = 0; n < 10; ++n) {\\012 // it is possible but not safe to move 'int i = 0;' here\\012 do_something(&i);\\012 }\\012 }\\012}\\012When you see this message it is always safe to reduce the variable scope 1 level.` - }, - 'severity': 'style', - 'testid': 'variableScope', - 'trace': null, - 'type': 'Issue' - }, - { - 'customfields': null, - 'cwe': null, - 'location': { - 'file': { - 'abspath': null, - 'givenpath': 'source/father.c', - 'hash_': null - }, - 'function': null, - 'point': { - 'column': 0, - 'line': 45 - }, - 'range_': null - }, - 'message': { - 'text': `The scope of the variable 'complete_msg_sleepy' can be reduced.` - }, - 'notes': { - 'text': `The scope of the variable 'complete_msg_sleepy' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:\\012void f(int x)\\012{\\012 int i = 0;\\012 if (x) {\\012 // it's safe to move 'int i = 0;' here\\012 for (int n = 0; n < 10; ++n) {\\012 // it is possible but not safe to move 'int i = 0;' here\\012 do_something(&i);\\012 }\\012 }\\012}\\012When you see this message it is always safe to reduce the variable scope 1 level.` - }, - 'severity': 'style', - 'testid': 'variableScope', - 'trace': null, - 'type': 'Issue' - }, - { - 'customfields': null, - 'cwe': null, - 'location': { - 'file': { - 'abspath': null, - 'givenpath': 'source/father.c', - 'hash_': null - }, - 'function': null, - 'point': { - 'column': 0, - 'line': 46 - }, - 'range_': null - }, - 'message': { - 'text': `The scope of the variable 'complete_msg_active' can be reduced.` - }, - 'notes': { - 'text': `The scope of the variable 'complete_msg_active' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:\\012void f(int x)\\012{\\012 int i = 0;\\012 if (x) {\\012 // it's safe to move 'int i = 0;' here\\012 for (int n = 0; n < 10; ++n) {\\012 // it is possible but not safe to move 'int i = 0;' here\\012 do_something(&i);\\012 }\\012 }\\012}\\012When you see this message it is always safe to reduce the variable scope 1 level.` - }, - 'severity': 'style', - 'testid': 'variableScope', - 'trace': null, - 'type': 'Issue' - }, - { - 'customfields': null, - 'cwe': null, - 'location': { - 'file': { - 'abspath': null, - 'givenpath': 'source/father.c', - 'hash_': null - }, - 'function': null, - 'point': { - 'column': 0, - 'line': 77 - }, - 'range_': null - }, - 'message': { - 'text': `The scope of the variable 'seconds' can be reduced.` - }, - 'notes': { - 'text': `The scope of the variable 'seconds' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:\\012void f(int x)\\012{\\012 int i = 0;\\012 if (x) {\\012 // it's safe to move 'int i = 0;' here\\012 for (int n = 0; n < 10; ++n) {\\012 // it is possible but not safe to move 'int i = 0;' here\\012 do_something(&i);\\012 }\\012 }\\012}\\012When you see this message it is always safe to reduce the variable scope 1 level.` - }, - 'severity': 'style', - 'testid': 'variableScope', - 'trace': null, - 'type': 'Issue' - }, - { - 'customfields': null, - 'cwe': null, - 'location': { - 'file': { - 'abspath': null, - 'givenpath': 'source/father.c', - 'hash_': null - }, - 'function': null, - 'point': { - 'column': 0, - 'line': 114 - }, - 'range_': null - }, - 'message': { - 'text': 'Uninitialized variable: readbuffer_active' - }, - 'notes': null, - 'severity': 'error', - 'testid': 'uninitvar', - 'trace': null, - 'type': 'Issue' - }, - { - 'customfields': null, - 'cwe': null, - 'location': { - 'file': { - 'abspath': null, - 'givenpath': 'source/main.c', - 'hash_': null - }, - 'function': null, - 'point': { - 'column': 0, - 'line': 14 - }, - 'range_': null - }, - 'message': { - 'text': 'Uninitialized variable: sleepy_children' - }, - 'notes': null, - 'severity': 'error', - 'testid': 'uninitvar', - 'trace': null, - 'type': 'Issue' - }, - { - 'customfields': null, - 'cwe': null, - 'location': { - 'file': { - 'abspath': null, - 'givenpath': 'source/main.c', - 'hash_': null - }, - 'function': null, - 'point': { - 'column': 0, - 'line': 14 - }, - 'range_': null - }, - 'message': { - 'text': 'Uninitialized variable: active_children' - }, - 'notes': null, - 'severity': 'error', - 'testid': 'uninitvar', - 'trace': null, - 'type': 'Issue' - }, - { - 'customfields': null, - 'cwe': null, - 'location': { - 'file': { - 'abspath': null, - 'givenpath': 'source/sleepy_children.c', - 'hash_': null - }, - 'function': null, - 'point': { - 'column': 0, - 'line': 30 - }, - 'range_': null - }, - 'message': { - 'text': `The scope of the variable 'time_to_sleep' can be reduced.` - }, - 'notes': { - 'text': `The scope of the variable 'time_to_sleep' can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:\\012void f(int x)\\012{\\012 int i = 0;\\012 if (x) {\\012 // it's safe to move 'int i = 0;' here\\012 for (int n = 0; n < 10; ++n) {\\012 // it is possible but not safe to move 'int i = 0;' here\\012 do_something(&i);\\012 }\\012 }\\012}\\012When you see this message it is always safe to reduce the variable scope 1 level.` - }, - 'severity': 'warnings', - 'testid': 'variableScope', - 'trace': null, - 'type': 'Issue' - }, - { - 'customfields': null, - 'cwe': null, - 'location': { - 'file': { - 'abspath': null, - 'givenpath': 'source/sleepy_children.c', - 'hash_': null - }, - 'function': null, - 'point': { - 'column': 0, - 'line': 28 - }, - 'range_': null - }, - 'message': { - 'text': 'Unused variable: readbuffer_sleepy' - }, - 'notes': null, - 'severity': 'warnings', - 'testid': 'unusedVariable', - 'trace': null, - 'type': 'Issue' - }, - { - 'customfields': { - 'verbose': `Cppcheck cannot find all the include files. Cppcheck can check the code without the include files found. But the results will probably be more accurate if all the include files are found. Please check your project's include directories and add all of them as include directories for Cppcheck. To see what files Cppcheck cannot find use --check-config.` - }, - 'failureid': 'missingIncludeSystem', - 'location': null, - 'message': { - 'text': 'Cppcheck cannot find all the include files (use --check-config for details)' - }, - 'type': 'Failure' - } - ] - }, - 'report': { - 'analysis_id': 1, - 'id': 1, - 'results': { - 'errors': 3, - 'styles': 5, - 'warnings': 2 - } - }, - 'version_id': 1 - }, - { - 'analyzer_id': 2, - 'id': 1, - 'raw': { - 'customfields': null, - 'metadata': { - 'file_': null, - 'generator': { - 'name': 'outro', - 'version': '2.22' - }, - 'stats': null, - 'sut': null - }, - 'results': [] - }, - 'report': { - 'id': 2, - 'analyzer_id': 1, - 'results': { - 'errors': 10, - 'warnings': 3, - 'style': 4, - 'Other': 15 - } - }, - 'version_id': 2 - } - ], - selectedAnalyzer: 1 + analysis: [] } const getters = { - [getterNames.analizers]: (state) => { - return state.analysis.map((analizer) => { - return { - id: analizer.analyzer_id, - name: analizer.raw.metadata.generator.name, - version: analizer.raw.metadata.generator.version - } - }) - }, - [getterNames.reports]: (state) => { - return state.analysis.filter((analyzer) => { - return analyzer.analyzer_id === state.selectedAnalyzer - }).map((analizer) => { - return analizer.report.results - })[0] - }, - [getterNames.errorsList]: (state) => { - return state.analysis.filter((analyzer) => analyzer.analyzer_id === state.selectedAnalyzer).map((analyzer) => analyzer.raw.results)[0] + [getterNames.analysis]: (state) => { + return state.analysis } } const actions = { - async [actionTypes.SET_SELECTED] ({commit, getters, state}, id) { - commit(mutationTypes.STORE_SELECTED, id) + async [actionTypes.FETCH_ANALYSIS] ({commit, getters, state}, currentPackage) { + let { data } = await api.get(currentPackage) + commit(mutationTypes.STORE_ANALYSIS, data) } } const mutations = { - [mutationTypes.STORE_SELECTED] (state, id) { - state.selectedAnalyzer = id + [mutationTypes.STORE_ANALYSIS] (state, data) { + state.analysis = data } } diff --git a/src/store/modules/analysisData.js b/src/store/modules/analysisData.js new file mode 100644 index 0000000..39a0c9e --- /dev/null +++ b/src/store/modules/analysisData.js @@ -0,0 +1,48 @@ +import * as actionTypes from '../actionTypes' +import * as getterNames from '../getterNames' +import * as mutationTypes from '../mutationsTypes' +import api from '../../api/analysis' + +const state = { + analysis: { + results: [], + reports: [] + } +} + +const getters = { + [getterNames.reports]: (state) => { + return state.analysis.reports + }, + [getterNames.errorsList]: (state) => { + return state.analysis.results + } +} + +const actions = { + async [actionTypes.FETCH_ANALYSIS_DATA] ({commit, getters, state}, payload) { + let reports = (await api.getReports(payload.currentPackage, payload.id)).data + let results = (await api.getResults(payload.currentPackage, payload.id)).data + commit(mutationTypes.STORE_RESULTS, results) + commit(mutationTypes.STORE_REPORTS, reports) + } +} + +const mutations = { + [mutationTypes.STORE_SELECTED_ANALYSIS] (state, id) { + state.selectedAnalyzer = id + }, + [mutationTypes.STORE_RESULTS] (state, results) { + state.analysis.results = results.analysis_results + }, + [mutationTypes.STORE_REPORTS] (state, reports) { + state.analysis.reports = reports.analysis_report.results + } +} + +export default { + state, + getters, + actions, + mutations +} diff --git a/src/store/modules/analyzers.js b/src/store/modules/analyzers.js deleted file mode 100644 index 06c340d..0000000 --- a/src/store/modules/analyzers.js +++ /dev/null @@ -1,42 +0,0 @@ -import * as actionTypes from '../actionTypes' -import * as getterNames from '../getterNames' -import * as mutationTypes from '../mutationsTypes' -import api from '../../api/analyzers' - -const state = { - analyzers: [] -} - -const getters = { - [getterNames.analyzers]: (state) => { - return state.analyzers - }, - [getterNames.reports]: (state) => { - return [] - }, - [getterNames.errorsList]: (state) => { - return [] - } -} - -const actions = { - async [actionTypes.FETCH_ANALYZERS] ({commit, getters, state}, currentPackage) { - console.log(currentPackage) - let { data } = await api.get(currentPackage) - console.log(data) - commit(mutationTypes.STORE_ANALYZERS, data) - } -} - -const mutations = { - [mutationTypes.STORE_ANALYZERS] (state, data) { - state.analyzers = data - } -} - -export default { - state, - getters, - actions, - mutations -} diff --git a/src/store/mutationsTypes.js b/src/store/mutationsTypes.js index c34f0c0..d6723d9 100644 --- a/src/store/mutationsTypes.js +++ b/src/store/mutationsTypes.js @@ -4,4 +4,9 @@ export const STORE_SELECTED = 'STORE_SELECTED' export const FILTER_PACKAGES = 'FILTER_PACKAGES' // Analyzers -export const STORE_ANALYZERS = 'STORE_ANALYZERS' +export const STORE_ANALYSIS = 'STORE_ANALYSIS' + +// Analysis +export const STORE_SELECTED_ANALYSIS = 'STORE_SELECTED_ANALYSIS' +export const STORE_REPORTS = 'STORE_REPORTS' +export const STORE_RESULTS = 'STORE_RESULTS'