add frontend project

This commit is contained in:
amar
2023-05-30 08:32:18 +02:00
parent 2a564bba38
commit ac3429868a
33 changed files with 12787 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

90
PROJECT/fastprod_frontend/.gitignore vendored Normal file
View File

@@ -0,0 +1,90 @@
# Created by .ignore support plugin (hsz.mobi)
### Node template
# Logs
/logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# parcel-bundler cache (https://parceljs.org/)
.cache
# next.js build output
.next
# nuxt.js build output
.nuxt
# Nuxt generate
dist
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless
# IDE / Editor
.idea
# Service worker
sw.*
# macOS
.DS_Store
# Vim swap files
*.swp

View File

@@ -0,0 +1,69 @@
# fastprod_frontend
## Build Setup
```bash
# install dependencies
$ npm install
# serve with hot reload at localhost:3000
$ npm run dev
# build for production and launch server
$ npm run build
$ npm run start
# generate static project
$ npm run generate
```
For detailed explanation on how things work, check out the [documentation](https://nuxtjs.org).
## Special Directories
You can create the following extra directories, some of which have special behaviors. Only `pages` is required; you can delete them if you don't want to use their functionality.
### `assets`
The assets directory contains your uncompiled assets such as Stylus or Sass files, images, or fonts.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/assets).
### `components`
The components directory contains your Vue.js components. Components make up the different parts of your page and can be reused and imported into your pages, layouts and even other components.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/components).
### `layouts`
Layouts are a great help when you want to change the look and feel of your Nuxt app, whether you want to include a sidebar or have distinct layouts for mobile and desktop.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/layouts).
### `pages`
This directory contains your application views and routes. Nuxt will read all the `*.vue` files inside this directory and setup Vue Router automatically.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/get-started/routing).
### `plugins`
The plugins directory contains JavaScript plugins that you want to run before instantiating the root Vue.js Application. This is the place to add Vue plugins and to inject functions or constants. Every time you need to use `Vue.use()`, you should create a file in `plugins/` and add its path to plugins in `nuxt.config.js`.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/plugins).
### `static`
This directory contains your static files. Each file inside this directory is mapped to `/`.
Example: `/static/robots.txt` is mapped as `/robots.txt`.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/static).
### `store`
This directory contains your Vuex store files. Creating a file in this directory automatically activates Vuex.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/store).

View File

@@ -0,0 +1,4 @@
// Ref: https://github.com/nuxt-community/vuetify-module#customvariables
//
// The variables you want to modify
// $font-size-root: 20px;

View File

@@ -0,0 +1,57 @@
<template>
<UiDialog
ref="ref"
:width="width"
:header="{
icon: header.icon,
label: header.label,
}"
>
<template #content>
<v-container>
<slot name="header"></slot>
<component
:is="component"
v-if="!!component"
:data="componentProps"
@event="$emit('event', null)"
@onSubmit="onSubmit"
></component>
</v-container>
</template>
</UiDialog>
</template>
<script>
export default {
props: {
component: {
type: String,
default: null,
},
componentProps: {
type: Object,
default: null,
},
width: {
type: String,
default: "800",
},
header: {
type: Object,
default: () => ({ icon: null, label: null }),
},
},
methods: {
open() {
this.$refs.ref.open();
},
close() {
this.$refs.ref.close();
},
onSubmit(e) {
this.$emit("onSubmit", e);
},
},
};
</script>

View File

@@ -0,0 +1,51 @@
<template>
<v-row justify="center">
<v-col cols="12">
<v-card :flat="flat" class="rounded-lg">
<v-card-title :class="headerClass">
<v-icon :color="iconColor" class="mr-1">mdi-{{ icon }}</v-icon>
{{ title }}
</v-card-title>
<div>
<slot name="headerActions"></slot>
</div>
<v-card-text>
<slot name="content"></slot>
</v-card-text>
<v-card-actions>
<slot name="footerActions"></slot>
</v-card-actions>
</v-card>
</v-col>
</v-row>
</template>
<script>
export default {
props: {
title: {
type: String,
default: null,
},
icon: {
type: String,
default: null,
},
flat: {
type: Boolean,
default: true,
},
headerClass: {
type: String,
default: 'primary white--text mb-2',
},
iconColor: {
type: String,
default: 'white',
},
},
data() {
return {}
},
}
</script>
<style scoped></style>

View File

@@ -0,0 +1,51 @@
<template>
<div>
<v-dialog v-model="dialog" :max-width="width">
<v-card>
<v-toolbar v-if="!!header" color="primary" dark>
<v-icon>mdi-{{ header.icon }}</v-icon>
<h4 class="ml-2">{{ header.label }}</h4>
<v-spacer></v-spacer>
<v-btn icon dark @click="dialog = false">
<v-icon>mdi-close</v-icon>
</v-btn>
</v-toolbar>
<v-card-text>
<slot name="content"></slot>
</v-card-text>
<v-card-actions class="justify-end">
<slot name="action"></slot>
</v-card-actions>
</v-card>
</v-dialog>
</div>
</template>
<script>
export default {
props: {
width: {
type: String,
default: '800',
},
header: {
type: Object,
default: null,
},
},
data() {
return {
dialog: false,
}
},
methods: {
open() {
this.dialog = true
},
close() {
this.dialog = false
},
},
}
</script>
<style scoped></style>

View File

@@ -0,0 +1,179 @@
<template>
<div>
<ValidationObserver
ref="observer"
v-slot="{ handleSubmit, validated, invalid }"
>
<v-form @submit.prevent="onSubmit">
<v-row>
<v-col lg="6" md="6" cols="12">
<ValidationProvider
v-slot="{ errors, valid }"
rules="required"
name="Hostname"
>
<v-text-field
v-model="host.data.device_name"
:error-messages="errors"
color="primary"
outlined
label="Hostname"
prepend-inner-icon="mdi-subtitles-outline"
></v-text-field>
</ValidationProvider>
</v-col>
<v-col lg="6" md="6" cols="12">
<ValidationProvider
v-slot="{ errors, valid }"
rules="required"
name="Ip address"
>
<v-text-field
v-model="host.hostname"
:error-messages="errors"
color="primary"
outlined
label="Ip address"
prepend-inner-icon="mdi-router-network"
></v-text-field>
</ValidationProvider>
</v-col>
<v-col lg="6" md="6" cols="12">
<ValidationProvider
v-slot="{ errors, valid }"
rules="required"
name="Model"
>
<v-text-field
v-model="host.data.device_model"
:error-messages="errors"
color="primary"
outlined
label="Model"
prepend-inner-icon="mdi-cog-sync-outline"
></v-text-field>
</ValidationProvider>
</v-col>
<v-col lg="6" md="6" cols="12">
<ValidationProvider
v-slot="{ errors, valid }"
rules="required"
name="Type"
>
<v-select
v-model="host.data.device_type"
:items="['router', 'routeur_switch']"
outlined
:error-messages="errors"
color="primary"
label="Type"
prepend-inner-icon="mdi-devices"
></v-select>
</ValidationProvider>
</v-col>
<v-col lg="6" md="6" cols="12">
<ValidationProvider
v-slot="{ errors, valid }"
rules="required"
name="Locality"
>
<v-text-field
v-model="host.data.locality"
:error-messages="errors"
color="primary"
outlined
label="Locality"
prepend-inner-icon="mdi-map-marker-radius-outline"
></v-text-field>
</ValidationProvider>
</v-col>
<v-col lg="6" md="6" cols="12">
<ValidationProvider
v-slot="{ errors, valid }"
rules="required"
name="Building"
>
<v-text-field
v-model="host.data.building"
:error-messages="errors"
color="primary"
outlined
label="Building"
prepend-inner-icon="mdi-office-building-marker-outline"
></v-text-field>
</ValidationProvider>
</v-col>
<v-col lg="8" md="8" cols="12">
<ValidationProvider
v-slot="{ errors, valid }"
rules="required"
name="Room"
>
<v-text-field
v-model="host.data.room"
:error-messages="errors"
color="primary"
outlined
label="Room"
prepend-inner-icon="mdi-domain"
></v-text-field>
</ValidationProvider>
</v-col>
</v-row>
<div class="text-center">
<v-btn
:disabled="invalid"
color="primary"
class="white--text"
x-large
:loading="loading"
@click="add"
outlined
>
Add <v-icon right dark> mdi-check </v-icon>
</v-btn>
</div>
</v-form>
</ValidationObserver>
</div>
</template>
<script>
export default {
data() {
return {
loading: false,
host: {
hostname: null,
data: {
device_type: null,
device_name: null,
device_model: null,
locality: "cisco",
building: null,
room: null,
},
},
};
},
mounted() {},
methods: {
add() {
this.loading = true;
this.$store
.dispatch("inventory/post", { data: this.host })
.then((response) => {
this.loading = false;
this.$emit("onSubmit");
})
.catch((error) => {
this.loading = false;
console.log("error", error);
});
},
},
};
</script>
<style scoped></style>

View File

@@ -0,0 +1,103 @@
<template>
<UiCard title="Device informations" icon="server" :flat="false">
<template #headerActions>
<div class="text-center">
<v-btn
v-show="!loading"
@click="$emit('refresh')"
color="primary"
outlined
>
Refresh
</v-btn>
</div>
<div class="text-center" v-show="!loading">
<v-icon size="100" color="primary">mdi-remote-desktop</v-icon>
<br />
<span class="text-h5 text-center" v-if="!!item">
{{ item.hostname }}
</span>
</div>
</template>
<template #content>
<div class="text-center">
<v-progress-circular
:size="70"
:width="7"
color="primary"
indeterminate
v-show="loading"
></v-progress-circular>
</div>
<v-divider class="mb-4" v-show="!loading"></v-divider>
<v-row
justify="center"
align="center"
class="text-center"
v-if="!!item"
v-show="!loading"
>
<v-col cols="12" class="text-capitalize">
<v-icon color="primary"> mdi-webpack </v-icon>
<span class="font-weight-bold">FQDN :</span>
{{ item.fqdn }}
</v-col>
<v-col lg="4" md="4" cols="12">
<v-icon color="primary"> mdi-office-building-cog-outline </v-icon>
<span class="font-weight-bold">vendor :</span>
{{ item.vendor }}
</v-col>
<v-col lg="4" md="4" cols="12">
<v-icon color="primary"> mdi-cog-sync-outline </v-icon>
<span class="font-weight-bold">Model :</span>
{{ item.model }}
</v-col>
<v-col lg="4" md="4" cols="12">
<v-icon color="primary"> mdi-barcode </v-icon>
<span class="font-weight-bold">Serial number :</span>
<span class="text-capitalize">
{{ item.serial_number }}
</span>
</v-col>
<v-col lg="4" md="4" cols="12">
<v-icon color="primary"> mdi-clock-outline </v-icon>
<span class="font-weight-bold">Up time :</span>
<span class="text-capitalize">
{{ item.uptime }}
</span>
</v-col>
<v-col cols="12">
<v-icon color="primary"> mdi-code-tags </v-icon>
<span class="font-weight-bold">OS version :</span>
<span class="text-capitalize">
{{ item.os_version }}
</span>
</v-col>
</v-row>
</template>
</UiCard>
</template>
<script>
export default {
props: {
item: {
type: Object,
default: null,
},
loading: {
type: Boolean,
default: false,
},
},
data() {
return {};
},
mounted() {},
methods: {},
};
</script>
<style scoped></style>

View File

@@ -0,0 +1,94 @@
<template>
<UiCard :title="deviceName" icon="server" :flat="false" v-if="!!item">
<template #headerActions>
<div class="text-center" v-show="!loading">
<v-icon
size="100"
v-if="item.data.device_type === 'router'"
color="primary"
>mdi-router</v-icon
>
<v-icon size="100" v-else color="primary">mdi-border-outside</v-icon>
<br />
<span class="text-h5 text-center">{{ item.hostname }}</span>
</div>
</template>
<template #content>
<div class="text-center">
<v-progress-circular
:size="70"
:width="7"
color="primary"
indeterminate
v-show="loading"
></v-progress-circular>
</div>
<div v-show="!loading">
<v-divider class="mb-4"></v-divider>
<v-row justify="center" align="center" class="text-center">
<v-col cols="3" class="text-capitalize">
<v-icon color="primary"> mdi-map-marker-radius-outline </v-icon>
<span class="font-weight-bold">Location :</span>
{{ item.data.locality }}
</v-col>
<v-col lg="4" md="4" cols="12">
<v-icon color="primary">
mdi-office-building-marker-outline
</v-icon>
<span class="font-weight-bold">Building :</span>
{{ item.data.building }}
</v-col>
<v-col lg="4" md="4" cols="12">
<v-icon color="primary"> mdi-domain </v-icon>
<span class="font-weight-bold">Room :</span>
{{ item.data.room }}
</v-col>
<v-col lg="4" md="4" cols="12">
<v-icon color="primary"> mdi-devices </v-icon>
<span class="font-weight-bold">Type :</span>
<span v-if="item.data.device_type == 'router'">Router</span>
<span v-if="item.data.device_type == 'switch_router'">Router</span>
</v-col>
<v-col lg="4" md="4" cols="12">
<v-icon color="primary"> mdi-cog-sync-outline </v-icon>
<span class="font-weight-bold">Model :</span>
{{ item.data.device_model }}
</v-col>
<v-col lg="4" md="4" cols="12">
<v-icon color="primary"> mdi-cog-sync-outline </v-icon>
<span class="font-weight-bold">OS :</span>
<span class="text-capitalize">
{{ item.groups[0] }}
</span>
</v-col>
</v-row>
</div>
</template>
</UiCard>
</template>
<script>
export default {
props: {
item: {
type: Object,
default: null,
},
deviceName: {
type: String,
default: null,
},
loading: {
type: Boolean,
default: false,
},
},
data() {
return {};
},
mounted() {},
methods: {},
};
</script>
<style scoped></style>

View File

@@ -0,0 +1,135 @@
<template>
<UiCard title="Devices interfaces" icon="connection" :flat="false">
<template #headerActions>
<div class="text-center">
<v-btn
@click="$emit('refresh')"
color="primary"
outlined
v-show="!loading"
>
Refresh
</v-btn>
</div>
<div class="text-center" v-show="!loading">
<v-icon size="100" color="primary">mdi-connection</v-icon>
<br />
<span class="text-h5 text-center" v-if="!!items">
{{ deviceName }}
</span>
</div>
</template>
<template #content>
<div class="text-center">
<v-progress-circular
:size="70"
:width="7"
color="primary"
indeterminate
v-show="loading"
></v-progress-circular>
</div>
<v-divider class="mb-4" v-show="!loading"></v-divider>
<div v-if="!!items" v-show="!loading">
<v-row justify="end">
<v-col cols="4">
<v-text-field
v-if="items.length > 1"
v-model="search"
color="secondary"
append-icon="mdi-magnify"
label="search an interface..."
single-line
hide-details
></v-text-field>
</v-col>
</v-row>
<v-data-table
hide-default-footer
class="row-pointer"
:search="search"
:headers="headers"
:items="items"
:items-per-page="100"
>
<template #[`item.is_up`]="{ item }">
<v-tooltip bottom>
<template #activator="{ on, attrs }">
<v-btn
v-bind="attrs"
icon
color="error"
v-on="on"
@click="onDelete(item)"
>
<v-icon size="65" :color="item.is_up ? 'success' : 'error'">
mdi-circle-small
</v-icon>
</v-btn>
</template>
<span>
<span v-if="item.is_up">IS UP</span>
<span v-else>IS DOWN</span>
</span>
</v-tooltip>
</template>
</v-data-table>
</div>
</template>
</UiCard>
</template>
<script>
export default {
props: {
items: {
type: Array,
default: null,
},
loading: {
type: Boolean,
default: false,
},
deviceName: {
type: String,
default: false,
},
},
data() {
return {
search: "",
headers: [
{
text: "Name",
value: "name",
align: "center",
},
{
text: "Description",
value: "description",
align: "center",
},
{
text: "Admin status",
value: "is_enabled",
align: "center",
},
{
text: "Status",
value: "is_up",
align: "center",
},
{
text: "Mac address",
value: "mac_addresss",
align: "center",
},
],
};
},
mounted() {},
methods: {},
};
</script>
<style scoped></style>

View File

@@ -0,0 +1,104 @@
<template>
<UiCard title="Configured interfaces" icon="connection" :flat="false">
<template #headerActions>
<div class="text-center">
<v-btn
@click="$emit('refresh')"
color="primary"
outlined
v-show="!loading"
>
Refresh
</v-btn>
</div>
<div class="text-center" v-show="!loading">
<v-icon size="100" color="primary">mdi-connection</v-icon>
<br />
<span class="text-h5 text-center" v-if="!!items">
{{ deviceName }}
</span>
</div>
</template>
<template #content>
<div class="text-center">
<v-progress-circular
:size="70"
:width="7"
color="primary"
indeterminate
v-show="loading"
></v-progress-circular>
</div>
<v-divider class="mb-4" v-show="!loading"></v-divider>
<div v-if="!!items" v-show="!loading">
<v-row justify="end">
<v-col cols="4">
<v-text-field
v-if="items.length > 1"
v-model="search"
color="secondary"
append-icon="mdi-magnify"
label="search an interface..."
single-line
hide-details
></v-text-field>
</v-col>
</v-row>
<v-data-table
hide-default-footer
class="row-pointer"
:search="search"
:headers="headers"
:items="items"
:items-per-page="100"
>
</v-data-table>
</div>
</template>
</UiCard>
</template>
<script>
export default {
props: {
items: {
type: Array,
default: null,
},
loading: {
type: Boolean,
default: false,
},
deviceName: {
type: String,
default: false,
},
},
data() {
return {
search:"",
headers: [
{
text: "Name",
value: "name",
align: "center",
},
{
text: "Ip address",
value: "ip",
align: "center",
},
{
text: "Prefix length",
value: "prefix_length",
align: "center",
},
],
};
},
mounted() {},
methods: {},
};
</script>
<style scoped></style>

View File

@@ -0,0 +1,132 @@
<template>
<UiCard
title="Devices snapshots"
icon="content-save-cog-outline"
:flat="false"
>
<template #headerActions>
<div class="text-center">
<v-btn
@click="$emit('createSnapshot')"
color="primary"
outlined
v-show="!loading"
>
Make a snapshot
</v-btn>
<v-btn
@click="$emit('refresh')"
color="primary"
outlined
v-show="!loading"
>
Refresh
</v-btn>
</div>
<div class="text-center" v-show="!loading">
<v-icon size="100" color="primary">mdi-content-save-cog-outline</v-icon>
<br />
<span class="text-h5 text-center" v-if="!!items">
{{ deviceName }}
</span>
</div>
</template>
<template #content>
<div class="text-center">
<v-progress-circular
:size="70"
:width="7"
color="primary"
indeterminate
v-show="loading"
></v-progress-circular>
</div>
<v-divider class="mb-4" v-show="!loading"></v-divider>
<div v-if="!!items" v-show="!loading">
<v-row justify="end">
<v-col cols="4">
<v-text-field
v-if="items.length > 1"
v-model="search"
color="secondary"
append-icon="mdi-magnify"
label="search a snapshot..."
single-line
hide-details
></v-text-field>
</v-col>
</v-row>
<v-data-table
hide-default-footer
class="row-pointer"
:search="search"
:headers="headers"
:items="items"
:items-per-page="100"
>
<template #[`item.actions`]="{ item }">
<v-tooltip bottom>
<template #activator="{ on, attrs }">
<v-btn v-bind="attrs" icon v-on="on" link :href="'http://192.168.1.36:5000/snapshots/'+item.file">
<v-icon> mdi-cloud-download-outline </v-icon>
</v-btn>
</template>
<span> Download </span>
</v-tooltip>
</template>
</v-data-table>
</div>
</template>
</UiCard>
</template>
<script>
export default {
props: {
items: {
type: Array,
default: null,
},
loading: {
type: Boolean,
default: false,
},
deviceName: {
type: String,
default: false,
},
},
data() {
return {
search: "",
headers: [
{
text: "Name",
value: "file",
align: "center",
},
{
text: "Path",
value: "path",
align: "center",
},
{
text: "At",
value: "at",
align: "center",
},
{
text: "Actions",
value: "actions",
align: "center",
},
],
};
},
mounted() {},
methods: {},
};
</script>
<style scoped></style>

View File

@@ -0,0 +1,152 @@
<template>
<div>
<v-row justify="center">
<v-col lg="6" md="12" cols="12">
<UiCard title="Show commands SHELL" icon="console" :flat="false">
<template #content>
<v-textarea
outlined
name="input-7-4"
label="Show commands"
v-model="showCommands"
></v-textarea>
<div class="text-center">
<v-btn
outlined
color="primary"
@click="sendShowCommands"
:loading="loadingShowCommands"
>
Send <v-icon>mdi-arrange-send-to-back</v-icon>
</v-btn>
</div>
</template>
</UiCard>
</v-col>
<v-col lg="6" md="12" cols="12">
<UiCard title="Config commands SHELL" icon="console" :flat="false">
<template #content>
<v-textarea
outlined
name="input-7-4"
label="Config commands"
v-model="configCommands"
></v-textarea>
<div class="text-center">
<v-btn
outlined
color="primary"
@click="sendConfigCommands"
:loading="loadingConfigCommands"
>
Send <v-icon>mdi-arrange-send-to-back</v-icon>
</v-btn>
<v-alert
dense
text
type="success"
class="my-5"
v-if="!!configResult && !configError"
>
Configuration deployed!
</v-alert>
<v-alert dense outlined type="error" class="my-5" v-if="configError">
Error config could not be deployed...
</v-alert>
</div>
</template>
</UiCard>
</v-col>
<v-col cols="12">
<div v-if="!!result" class="text-center">
<v-textarea
:value="result"
height="280"
outlined
color="primary"
label="Output"
></v-textarea>
</div>
</v-col>
</v-row>
</div>
</template>
<script>
export default {
data() {
return {
loadingShowCommands: false,
selectedDeviceName: null,
showCommands: null,
configCommands: null,
loadingConfigCommands: null,
result: null,
configResult: null,
configError:false,
};
},
mounted() {
//this.getDevices();
this.selectedDeviceName = this.$route.params.name;
},
methods: {
getDeviceByName() {
this.loading = true;
this.$store
.dispatch("inventory/getByName", { name: this.$route.params.name })
.then((response) => {
this.loading = false;
this.device = response.data.device;
})
.catch((error) => {
this.loading = false;
console.log("error", error);
});
},
sendShowCommands() {
const data = { mode: "enable", commands: this.showCommands.split("\n") };
this.loadingShowCommands = true;
this.$store
.dispatch("inventory/config", {
name: this.$route.params.name,
data: data,
})
.then((response) => {
this.loadingShowCommands = false;
this.result = response.data.result
.map((item) => {
return item.result;
})
.join("\n\n\n");
})
.catch((error) => {
this.loadingShowCommands = false;
console.log("error", error);
});
},
sendConfigCommands() {
const data = {
mode: "config",
commands: this.configCommands.split("\n"),
};
this.loadingConfigCommands = true;
this.configError = false
this.$store
.dispatch("inventory/config", {
name: this.$route.params.name,
data: data,
})
.then((response) => {
this.loadingConfigCommands = false;
this.configResult = response.data.result;
})
.catch((error) => {
this.configError = true
this.loadingConfigCommands = false;
console.log("error", error);
});
},
},
};
</script>

View File

@@ -0,0 +1,131 @@
<template>
<div>
<v-row justify="end">
<v-col cols="3">
<v-text-field
v-if="items.length > 1"
v-model="search"
color="secondary"
append-icon="mdi-magnify"
label="search a device..."
single-line
hide-details
></v-text-field>
</v-col>
</v-row>
<v-data-table
hide-default-footer
class="row-pointer"
:search="search"
:headers="headers"
:items="items"
:items-per-page="100"
>
<template #[`item.data`]="{ item }">
<span class="text-capitalize">
{{ item.data.locality }} - {{ item.data.building }}
</span>
</template>
<template #[`item.data.device_type`]="{ item }">
<span v-if="item.data.device_type == 'router_switch'">
Ethernet switch router - {{ item.data.device_model }}
</span>
<span v-if="item.data.device_type == 'router'">
Router - {{ item.data.device_model }}
</span>
</template>
<template #[`item.actions`]="{ item }">
<v-tooltip bottom>
<template #activator="{ on, attrs }">
<v-btn
v-bind="attrs"
icon
color="secondary"
v-on="on"
@click="onView(item)"
>
<v-icon> mdi-magnify </v-icon>
</v-btn>
</template>
<span> Detail </span>
</v-tooltip>
<v-tooltip bottom>
<template #activator="{ on, attrs }">
<v-btn
v-bind="attrs"
icon
color="error"
v-on="on"
@click="onDelete(item)"
>
<v-icon> mdi-delete-circle-outline </v-icon>
</v-btn>
</template>
<span> Delete this device </span>
</v-tooltip>
</template>
<template #no-data> No data .... </template>
<template #no-results> No data ....</template>
</v-data-table>
</div>
</template>
<script>
export default {
props: {
items: {
type: Array,
default: null,
},
},
data() {
return {
search: "",
headers: [
{
text: "Hostname",
value: "name",
align: "center",
},
{
text: "Ip address",
value: "hostname",
align: "center",
},
{
text: "Type",
value: "data.device_type",
align: "center",
},
{
text: "Location",
value: "data",
align: "center",
},
{
text: "Actions",
value: "actions",
align: "center",
},
],
};
},
mounted() {},
methods: {
onView(item) {
this.$emit("onAction", { item, action: "show" });
},
onDelete(item) {
this.$emit("onAction", { item, action: "delete" });
},
},
};
</script>
<style scoped>
.row-pointer >>> tbody tr :hover {
cursor: pointer;
}
</style>

View File

@@ -0,0 +1,11 @@
<template>
<svg class="nuxt-logo" viewBox="0 0 45 30" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M24.7203 29.704H41.1008C41.6211 29.7041 42.1322 29.5669 42.5828 29.3061C43.0334 29.0454 43.4075 28.6704 43.6675 28.2188C43.9275 27.7672 44.0643 27.2549 44.0641 26.7335C44.0639 26.2121 43.9266 25.6999 43.6662 25.2485L32.6655 6.15312C32.4055 5.70162 32.0315 5.32667 31.581 5.06598C31.1305 4.8053 30.6195 4.66805 30.0994 4.66805C29.5792 4.66805 29.0682 4.8053 28.6177 5.06598C28.1672 5.32667 27.7932 5.70162 27.5332 6.15312L24.7203 11.039L19.2208 1.48485C18.9606 1.03338 18.5864 0.658493 18.1358 0.397853C17.6852 0.137213 17.1741 0 16.6538 0C16.1336 0 15.6225 0.137213 15.1719 0.397853C14.7213 0.658493 14.3471 1.03338 14.0868 1.48485L0.397874 25.2485C0.137452 25.6999 0.000226653 26.2121 2.8053e-07 26.7335C-0.000226092 27.2549 0.136554 27.7672 0.396584 28.2188C0.656614 28.6704 1.03072 29.0454 1.48129 29.3061C1.93185 29.5669 2.44298 29.7041 2.96326 29.704H13.2456C17.3195 29.704 20.3239 27.9106 22.3912 24.4118L27.4102 15.7008L30.0986 11.039L38.1667 25.0422H27.4102L24.7203 29.704ZM13.0779 25.0374L5.9022 25.0358L16.6586 6.36589L22.0257 15.7008L18.4322 21.9401C17.0593 24.2103 15.4996 25.0374 13.0779 25.0374Z" fill="#00DC82" />
</svg>
</template>
<style>
.nuxt-logo {
height: 180px;
}
</style>

View File

@@ -0,0 +1,52 @@
<!-- Please remove this file from your project -->
<template>
<div class="relative flex items-top justify-center min-h-screen bg-gray-100 sm:items-center sm:pt-0">
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.1.2/dist/tailwind.min.css" rel="stylesheet">
<div class="max-w-4xl mx-auto sm:px-6 lg:px-8">
<a class="flex justify-center pt-8 sm:pt-0" href="https://nuxtjs.org" target="_blank">
<svg width="218" height="45" viewBox="0 0 159 30" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M55.5017 6.81866H60.1727L70.0719 22.9912V6.81866H74.3837V29.7345H69.7446L59.8135 13.5955V29.7345H55.5017V6.81866Z" fill="#003543" /> <path d="M93.657 29.7344H89.6389V27.1747C88.7241 28.9761 86.8628 29.9904 84.5113 29.9904C80.7869 29.9904 78.3684 27.3059 78.3684 23.4423V13.2339H82.3865V22.5976C82.3865 24.8566 83.7594 26.4276 85.8171 26.4276C88.0712 26.4276 89.6389 24.6598 89.6389 22.2377V13.2339H93.657V29.7344Z" fill="#003543" /> <path d="M107.64 29.7344L103.784 24.2342L99.9291 29.7344H95.6492L101.596 21.1242L96.1074 13.2339H100.485L103.784 17.9821L107.051 13.2339H111.461L105.94 21.1242L111.886 29.7344H107.64Z" fill="#003543" /> <path d="M120.053 8.25848V13.2339H124.627V16.6063H120.053V24.7974C120.053 25.0725 120.162 25.3363 120.356 25.531C120.55 25.7257 120.813 25.8353 121.087 25.8357H124.627V29.728H121.98C118.386 29.728 116.035 27.6323 116.035 23.9687V16.6095H112.801V13.2339H114.83C115.776 13.2339 116.327 12.6692 116.327 11.7349V8.25848H120.053Z" fill="#003543" /> <path d="M134.756 24.5446V6.81866H139.066V23.1864C139.066 27.6067 136.943 29.7345 133.349 29.7345H128.332V25.8421H133.461C133.804 25.8421 134.134 25.7054 134.377 25.4621C134.619 25.2188 134.756 24.8888 134.756 24.5446Z" fill="#003543" /> <path d="M141.649 22.0409H145.799C146.029 24.6006 147.728 26.2308 150.472 26.2308C152.923 26.2308 154.623 25.2501 154.623 23.2199C154.623 18.3085 142.331 21.7129 142.331 12.9395C142.334 9.17515 145.568 6.55945 150.215 6.55945C155.05 6.55945 158.317 9.34153 158.516 13.6306H154.388C154.193 11.6341 152.632 10.2918 150.207 10.2918C147.953 10.2918 146.548 11.3397 146.548 12.9427C146.548 18.0173 159 14.2226 159 23.1576C159 27.4131 155.504 30 150.474 30C145.279 30 141.882 26.8563 141.654 22.0441" fill="#003543" /> <path d="M24.7203 29.704H41.1008C41.6211 29.7041 42.1322 29.5669 42.5828 29.3061C43.0334 29.0454 43.4075 28.6704 43.6675 28.2188C43.9275 27.7672 44.0643 27.2549 44.0641 26.7335C44.0639 26.2121 43.9266 25.6999 43.6662 25.2485L32.6655 6.15312C32.4055 5.70162 32.0315 5.32667 31.581 5.06598C31.1305 4.8053 30.6195 4.66805 30.0994 4.66805C29.5792 4.66805 29.0682 4.8053 28.6177 5.06598C28.1672 5.32667 27.7932 5.70162 27.5332 6.15312L24.7203 11.039L19.2208 1.48485C18.9606 1.03338 18.5864 0.658493 18.1358 0.397853C17.6852 0.137213 17.1741 0 16.6538 0C16.1336 0 15.6225 0.137213 15.1719 0.397853C14.7213 0.658493 14.3471 1.03338 14.0868 1.48485L0.397874 25.2485C0.137452 25.6999 0.000226653 26.2121 2.8053e-07 26.7335C-0.000226092 27.2549 0.136554 27.7672 0.396584 28.2188C0.656614 28.6704 1.03072 29.0454 1.48129 29.3061C1.93185 29.5669 2.44298 29.7041 2.96326 29.704H13.2456C17.3195 29.704 20.3239 27.9106 22.3912 24.4118L27.4102 15.7008L30.0986 11.039L38.1667 25.0422H27.4102L24.7203 29.704ZM13.0779 25.0374L5.9022 25.0358L16.6586 6.36589L22.0257 15.7008L18.4322 21.9401C17.0593 24.2103 15.4996 25.0374 13.0779 25.0374Z" fill="#00DC82" /></svg>
</a>
<div class="mt-8 bg-white overflow-hidden shadow sm:rounded-lg p-6">
<h2 class="text-2xl leading-7 font-semibold">
Welcome to your Nuxt Application
</h2>
<p class="mt-3 text-gray-600">
We recommend you take a look at the <a href="https://nuxtjs.org" target="_blank" class="button--doc text-green-500 hover:underline">Nuxt documentation</a>, whether you are new or have previous experience with the framework.<br>
</p>
<p class="mt-4 pt-4 text-gray-800 border-t border-dashed">
To get started, remove <code class="bg-gray-100 text-sm p-1 rounded border">components/Tutorial.vue</code> and start coding in <code class="bg-gray-100 text-sm p-1 rounded border">pages/index.vue</code>. Have fun!
</p>
</div>
<div class="flex justify-center pt-4 space-x-2">
<a href="https://github.com/nuxt/nuxt.js" target="_blank"><svg
class="w-6 h-6 text-gray-600 hover:text-gray-800 button--github"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
aria-hidden="true"
role="img"
width="32"
height="32"
preserveAspectRatio="xMidYMid meet"
viewBox="0 0 24 24"
><path d="M12 2.247a10 10 0 0 0-3.162 19.487c.5.088.687-.212.687-.475c0-.237-.012-1.025-.012-1.862c-2.513.462-3.163-.613-3.363-1.175a3.636 3.636 0 0 0-1.025-1.413c-.35-.187-.85-.65-.013-.662a2.001 2.001 0 0 1 1.538 1.025a2.137 2.137 0 0 0 2.912.825a2.104 2.104 0 0 1 .638-1.338c-2.225-.25-4.55-1.112-4.55-4.937a3.892 3.892 0 0 1 1.025-2.688a3.594 3.594 0 0 1 .1-2.65s.837-.262 2.75 1.025a9.427 9.427 0 0 1 5 0c1.912-1.3 2.75-1.025 2.75-1.025a3.593 3.593 0 0 1 .1 2.65a3.869 3.869 0 0 1 1.025 2.688c0 3.837-2.338 4.687-4.563 4.937a2.368 2.368 0 0 1 .675 1.85c0 1.338-.012 2.413-.012 2.75c0 .263.187.575.687.475A10.005 10.005 0 0 0 12 2.247z" fill="currentColor" /></svg></a>
<a href="https://twitter.com/nuxt_js" target="_blank"><svg
class="w-6 h-6 text-gray-600 hover:text-gray-800"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
aria-hidden="true"
role="img"
width="32"
height="32"
preserveAspectRatio="xMidYMid meet"
viewBox="0 0 24 24"
><path d="M22.46 6c-.77.35-1.6.58-2.46.69c.88-.53 1.56-1.37 1.88-2.38c-.83.5-1.75.85-2.72 1.05C18.37 4.5 17.26 4 16 4c-2.35 0-4.27 1.92-4.27 4.29c0 .34.04.67.11.98C8.28 9.09 5.11 7.38 3 4.79c-.37.63-.58 1.37-.58 2.15c0 1.49.75 2.81 1.91 3.56c-.71 0-1.37-.2-1.95-.5v.03c0 2.08 1.48 3.82 3.44 4.21a4.22 4.22 0 0 1-1.93.07a4.28 4.28 0 0 0 4 2.98a8.521 8.521 0 0 1-5.33 1.84c-.34 0-.68-.02-1.02-.06C3.44 20.29 5.7 21 8.12 21C16 21 20.33 14.46 20.33 8.79c0-.19 0-.37-.01-.56c.84-.6 1.56-1.36 2.14-2.23z" fill="currentColor" /></svg></a>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'NuxtTutorial'
}
</script>

View File

@@ -0,0 +1,22 @@
<template>
<img
class="vuetify-logo"
alt="Vuetify Logo"
src="/vuetify-logo.svg"
>
</template>
<style>
.vuetify-logo {
height: 180px;
width: 180px;
transform: rotateY(560deg);
animation: turn 3.5s ease-out forwards 1s;
}
@keyframes turn {
100% {
transform: rotateY(0deg);
}
}
</style>

View File

@@ -0,0 +1,67 @@
<template>
<v-app dark>
<v-navigation-drawer :clipped="true" fixed app >
<v-list>
<v-list-item
v-for="(item, i) in items"
:key="i"
:to="item.to"
router
color="primary"
exact
>
<v-list-item-action>
<v-icon>{{ item.icon }}</v-icon>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title v-text="item.title" />
</v-list-item-content>
</v-list-item>
</v-list>
</v-navigation-drawer>
<v-app-bar :clipped-left="true" fixed app color="primary" class="white--text" flat>
<v-toolbar-title v-text="title" />
<v-icon class="white--text">mdi-code-tags</v-icon>
<v-spacer />
version 1.0.0
</v-app-bar>
<v-main>
<v-container>
<Nuxt />
</v-container>
</v-main>
<v-footer :absolute="!fixed" app>
<span>By &copy; Amar KANTAS - {{ new Date().getFullYear() }}</span>
</v-footer>
</v-app>
</template>
<script>
export default {
name: "DefaultLayout",
data() {
return {
clipped: false,
drawer: false,
fixed: false,
items: [
{
icon: "mdi-view-dashboard",
title: "Dashboard",
to: "/",
},
{
icon: "mdi-server",
title: "Inventory",
to: "/inventory",
},
],
miniVariant: false,
right: true,
rightDrawer: false,
title: "FastProduction",
};
},
};
</script>

View File

@@ -0,0 +1,45 @@
<template>
<v-app dark>
<h1 v-if="error.statusCode === 404">
{{ pageNotFound }}
</h1>
<h1 v-else>
{{ otherError }}
</h1>
<NuxtLink to="/">
Home page
</NuxtLink>
</v-app>
</template>
<script>
export default {
name: 'EmptyLayout',
layout: 'empty',
props: {
error: {
type: Object,
default: null
}
},
data () {
return {
pageNotFound: '404 Not Found',
otherError: 'An error occurred'
}
},
head () {
const title =
this.error.statusCode === 404 ? this.pageNotFound : this.otherError
return {
title
}
}
}
</script>
<style scoped>
h1 {
font-size: 20px;
}
</style>

View File

@@ -0,0 +1,80 @@
import colors from "vuetify/es5/util/colors";
export default {
// Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode
ssr: false,
// Global page headers: https://go.nuxtjs.dev/config-head
head: {
titleTemplate: "%s - fastprod_frontend",
title: "fastprod_frontend",
htmlAttrs: {
lang: "en",
},
meta: [
{ charset: "utf-8" },
{ name: "viewport", content: "width=device-width, initial-scale=1" },
{ hid: "description", name: "description", content: "" },
{ name: "format-detection", content: "telephone=no" },
],
link: [{ rel: "icon", type: "image/x-icon", href: "/favicon.ico" }],
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: [],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [
// { src: '~/plugins/vuetify.js' },
{ src: "~/plugins/veeValidate.js" },
],
// Auto import components: https://go.nuxtjs.dev/config-components
components: [
"~/components",
{ path: "~/components/Common", prefix: "" },
{ path: "~/components/Common/Ui", prefix: "ui" },
],
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
// https://go.nuxtjs.dev/vuetify
"@nuxtjs/vuetify",
"@nuxtjs/dotenv",
],
// Modules: https://go.nuxtjs.dev/config-modules
modules: ["@nuxtjs/axios"],
// Axios module configuration: https://go.nuxtjs.dev/config-axios
axios: {
baseURL: process.env.API_URL,
https: false,
progress: false,
// proxy: true,
debug: false,
prefix: "/",
},
// Vuetify module configuration: https://go.nuxtjs.dev/config-vuetify
vuetify: {
customVariables: ["~/assets/variables.scss"],
theme: {
dark: false,
themes: {
dark: {
primary: colors.blue.darken2,
accent: colors.grey.darken3,
secondary: "#E4EFFA",
info: colors.teal.lighten1,
warning: colors.amber.base,
error: colors.deepOrange.accent4,
success: colors.green.accent3,
},
},
},
},
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {},
};

10457
PROJECT/fastprod_frontend/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,26 @@
{
"name": "fastprod_frontend",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate"
},
"dependencies": {
"@nuxtjs/axios": "^5.13.6",
"@nuxtjs/dotenv": "^1.4.1",
"core-js": "^3.19.3",
"nuxt": "^2.15.8",
"vee-validate": "^3.4.5",
"vue": "^2.6.14",
"vue-server-renderer": "^2.6.14",
"vue-template-compiler": "^2.6.14",
"vuetify": "^2.6.1",
"webpack": "^4.46.0"
},
"devDependencies": {
"@nuxtjs/vuetify": "^1.12.3"
}
}

View File

@@ -0,0 +1,83 @@
<template>
<v-row justify="center" align="center">
<v-col cols="12" sm="8" md="6">
<v-card class="logo py-4 d-flex justify-center">
<NuxtLogo />
<VuetifyLogo />
</v-card>
<v-card>
<v-card-title class="headline">
Welcome to the Vuetify + Nuxt.js template
</v-card-title>
<v-card-text>
<p>Vuetify is a progressive Material Design component framework for Vue.js. It was designed to empower developers to create amazing applications.</p>
<p>
For more information on Vuetify, check out the <a
href="https://vuetifyjs.com"
target="_blank"
rel="noopener noreferrer"
>
documentation
</a>.
</p>
<p>
If you have questions, please join the official <a
href="https://chat.vuetifyjs.com/"
target="_blank"
rel="noopener noreferrer"
title="chat"
>
discord
</a>.
</p>
<p>
Find a bug? Report it on the github <a
href="https://github.com/vuetifyjs/vuetify/issues"
target="_blank"
rel="noopener noreferrer"
title="contribute"
>
issue board
</a>.
</p>
<p>Thank you for developing with Vuetify and I look forward to bringing more exciting features in the future.</p>
<div class="text-xs-right">
<em><small>&mdash; John Leider</small></em>
</div>
<hr class="my-3">
<a
href="https://nuxtjs.org/"
target="_blank"
rel="noopener noreferrer"
>
Nuxt Documentation
</a>
<br>
<a
href="https://github.com/nuxt/nuxt.js"
target="_blank"
rel="noopener noreferrer"
>
Nuxt GitHub
</a>
</v-card-text>
<v-card-actions>
<v-spacer />
<v-btn
color="primary"
nuxt
to="/inspire"
>
Continue
</v-btn>
</v-card-actions>
</v-card>
</v-col>
</v-row>
</template>
<script>
export default {
name: 'IndexPage'
}
</script>

View File

@@ -0,0 +1,25 @@
<template>
<v-row>
<v-col class="text-center">
<img
src="/v.png"
alt="Vuetify.js"
class="mb-5"
>
<blockquote class="blockquote">
&#8220;First, solve the problem. Then, write the code.&#8221;
<footer>
<small>
<em>&mdash;John Johnson</em>
</small>
</footer>
</blockquote>
</v-col>
</v-row>
</template>
<script>
export default {
name: 'InspirePage'
}
</script>

View File

@@ -0,0 +1,242 @@
<template>
<div>
<DialogBindComponent
ref="deviceShell"
:header="dialogHeader"
component="InventoryDeviceShelllCards"
@onSubmit="submitHandler"
:width="'1800'"
/>
<v-row justify="center">
<v-col cols="12">
<v-toolbar dense flat>
<v-toolbar-title>
<h3>{{ selectedDeviceName }}</h3>
</v-toolbar-title>
<v-spacer></v-spacer>
<v-tooltip bottom>
<template #activator="{ on, attrs }">
<v-btn
v-bind="attrs"
color="primary"
class="mr-2"
outlined
v-on="on"
@click="showShellDialog"
>
<v-icon>mdi-console</v-icon>
</v-btn>
</template>
<span> Console </span>
</v-tooltip>
<v-tooltip bottom>
<template #activator="{ on, attrs }">
<v-btn
v-bind="attrs"
color="primary"
outlined
v-on="on"
@click="refreshAll"
>
<v-icon>mdi-refresh</v-icon>
</v-btn>
</template>
<span> Refresh </span>
</v-tooltip>
</v-toolbar>
</v-col>
<v-col lg="6" md="10" cols="12">
<InventoryDeviceInfoCard
:loading="loading"
:item="device"
:device-name="selectedDeviceName"
/>
<InventoryDeviceFactsCard
:item="deviceFacts"
:loading="loadingFacts"
@refresh="getDeviceFacts"
/>
</v-col>
<v-col lg="6" md="10" cols="12">
<InventoryDeviceSanpshotsCard
:items="deviceSnapshots"
:loading="loadingSnapshots"
@refresh="getDeviceSnapshots"
@createSnapshot="buildSnapshot"
:device-name="selectedDeviceName"
/>
</v-col>
<v-col lg="6" md="10" cols="12">
<InventoryDeviceIpInterfacesCard
:items="deviceIpInterfaces"
:device-name="selectedDeviceName"
:loading="loadingIpInterfaces"
@refresh="getdeviceIpInterfaces"
/>
</v-col>
<v-col lg="6" md="10" cols="12">
<InventoryDeviceInterfacesCard
:items="deviceInterfaces"
:device-name="selectedDeviceName"
:loading="loadingInterfaces"
@refresh="getdeviceInterfaces"
/>
</v-col>
</v-row>
<v-snackbar v-model="snackbar" color="success" class="font-weight-bold">
{{ notification.title }}
<template v-slot:action="{ attrs }">
<v-btn color="white" text v-bind="attrs" @click="snackbar = false">
Close
</v-btn>
</template>
</v-snackbar>
</div>
</template>
<script>
export default {
data() {
return {
loading: false,
loadingFacts: false,
loadingIpInterfaces: false,
loadingInterfaces: false,
loadingSnapshots: false,
notification: {},
selectedDeviceName: null,
device: null,
deviceFacts: null,
deviceInterfaces: null,
deviceIpInterfaces: null,
deviceSnapshots: null,
snackbar: false,
dialog: false,
items: [],
dialogHeader: {
icon: "console",
label: "FastProd SHELL",
},
};
},
mounted() {
//this.getDevices();
this.selectedDeviceName = this.$route.params.name;
this.getDeviceByName();
this.getDeviceFacts();
this.getdeviceIpInterfaces();
this.getdeviceInterfaces();
this.getDeviceSnapshots();
},
methods: {
refreshAll() {
this.getDeviceByName();
this.getDeviceFacts();
this.getdeviceIpInterfaces();
this.getdeviceInterfaces();
this.getDeviceSnapshots();
},
getDeviceByName() {
this.loading = true;
this.$store
.dispatch("inventory/getByName", { name: this.$route.params.name })
.then((response) => {
this.loading = false;
this.device = response.data.device;
})
.catch((error) => {
this.loading = false;
console.log("error", error);
});
},
getDeviceFacts() {
this.loadingFacts = true;
this.$store
.dispatch("inventory/getFacts", { name: this.$route.params.name })
.then((response) => {
this.loadingFacts = false;
this.deviceFacts = response.data.facts;
})
.catch((error) => {
this.loadingFacts = false;
console.log("error", error);
});
},
getdeviceIpInterfaces() {
this.loadingIpInterfaces = true;
this.$store
.dispatch("inventory/getInterfacesIp", {
name: this.$route.params.name,
})
.then((response) => {
this.loadingIpInterfaces = false;
this.deviceIpInterfaces = response.data.interfaces_ip;
})
.catch((error) => {
this.loadingIpInterfaces = false;
console.log("error", error);
});
},
getdeviceInterfaces() {
this.loadingInterfaces = true;
this.$store
.dispatch("inventory/getInterfaces", {
name: this.$route.params.name,
})
.then((response) => {
this.loadingInterfaces = false;
this.deviceInterfaces = response.data.interfaces;
})
.catch((error) => {
this.loadingInterfaces = false;
console.log("error", error);
});
},
getDeviceSnapshots() {
this.loadingSnapshots = true;
this.$store
.dispatch("inventory/getSnapshots", {
name: this.$route.params.name,
})
.then((response) => {
this.loadingSnapshots = false;
this.deviceSnapshots = response.data.snapshots;
})
.catch((error) => {
this.loadingSnapshots = false;
console.log("error", error);
});
},
openDialog() {
this.$refs.addDeviceDialog.open();
},
submitHandler(e) {
this.$refs.addDeviceDialog.close();
this.notification.title = "Device added!";
this.snackbar = true;
this.getDevices();
},
buildSnapshot() {
this.$store
.dispatch("inventory/buildSnapshots", {
name: this.$route.params.name,
})
.then((response) => {
this.notification.title = "Snapshot created!";
this.snackbar = true;
this.getDeviceSnapshots();
})
.catch((error) => {
console.log("error", error);
});
},
showShellDialog() {
this.$refs.deviceShell.open();
},
},
};
</script>

View File

@@ -0,0 +1,187 @@
<template>
<div>
<DialogBindComponent
ref="addDeviceDialog"
:header="dialogHeader"
component="InventoryAddDeviceForm"
@onSubmit="submitHandler"
/>
<v-dialog v-model="dialog" persistent max-width="290">
<v-card>
<v-card-title class="text-center">
Do you want to delete this device ?
</v-card-title>
<v-card-text v-if="!!selectedItem">
Hostname : {{ selectedItem.data.device_name }}
<br />
Ip address :
{{ selectedItem.hostname }}
<br />
Device type :
{{ selectedItem.data.device_type }}
<br />
Device model :
{{ selectedItem.data.device_model }}
<br />
<br />
<span class="text-center error--text">
Device will be permanently removed from the inventory
</span>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="green darken-1" text @click="dialog = false">
Cancel
</v-btn>
<v-btn color="error darken-1" text @click="deleteDevice">
Delete
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-row justify="center" align="center">
<v-col cols="12">
<v-toolbar dense flat>
<v-toolbar-title>
<h3>Inventory</h3>
</v-toolbar-title>
<v-spacer></v-spacer>
<v-tooltip bottom>
<template #activator="{ on, attrs }">
<v-btn
color="primary"
outlined
v-bind="attrs"
v-on="on"
class="mr-2"
@click="openDialog"
>
<v-icon>mdi-plus</v-icon>
</v-btn>
</template>
<span> Add a new device </span>
</v-tooltip>
<v-tooltip bottom>
<template #activator="{ on, attrs }">
<v-btn
v-bind="attrs"
color="primary"
outlined
v-on="on"
@click="getDevices"
>
<v-icon>mdi-refresh</v-icon>
</v-btn>
</template>
<span> Refresh </span>
</v-tooltip>
</v-toolbar>
</v-col>
<v-col lg="10" md="10" cols="12">
<UiCard title="Device list" icon="server" :flat="false">
<template #headerActions>
<v-progress-linear
v-show="loading"
color="primary"
indeterminate
rounded
height="6"
></v-progress-linear>
</template>
<template #content>
<InventoryTable :items="items" @onAction="handleAction" />
</template>
</UiCard>
</v-col>
</v-row>
<v-snackbar v-model="snackbar" color="success">
{{ notification.title }}
<template v-slot:action="{ attrs }">
<v-btn color="white" text v-bind="attrs" @click="snackbar = false">
Close
</v-btn>
</template>
</v-snackbar>
</div>
</template>
<script>
export default {
data() {
return {
notification: {},
selectedItem: null,
snackbar: false,
loading: false,
dialog: false,
items: [],
dialogHeader: {
icon: "server",
label: "Add a new device",
},
};
},
mounted() {
this.getDevices();
},
methods: {
getDevices() {
this.loading = true;
this.$store
.dispatch("inventory/get")
.then((response) => {
this.loading = false;
this.items = response.data.devices;
})
.catch((error) => {
this.loading = false;
console.log("error", error);
});
},
openDialog() {
this.$refs.addDeviceDialog.open();
},
submitHandler(e) {
this.$refs.addDeviceDialog.close();
this.notification.title = "Device added!";
this.snackbar = true;
this.getDevices();
},
handleAction(e) {
console.log(e);
if (e.action == "delete") {
this.selectedItem = e.item;
this.dialog = true;
}
if (e.action == "show") {
this.$router.push({
name: "inventory-name",
params: { name: e.item.data.device_name },
});
}
},
deleteDevice() {
this.dialog = false;
this.loading = true;
this.$store
.dispatch("inventory/delete", {
name: this.selectedItem.data.device_name,
})
.then((response) => {
this.loading = false;
this.notification.title = "Device removed!";
this.snackbar = true;
this.getDevices();
})
.catch((error) => {
this.loading = false;
console.log("error", error);
});
},
},
};
</script>

View File

@@ -0,0 +1,57 @@
// import * as VeeValidate from 'vee-validate'
import {
required,
confirmed,
email,
alpha,
digits,
numeric,
regex,
} from "vee-validate/dist/rules";
import {
ValidationProvider,
ValidationObserver,
extend,
localize,
} from "vee-validate";
// import attributesFr from 'vee-validate/dist/locale/fr'
import fr from "vee-validate/dist/locale/fr.json";
import Vue from "vue";
Vue.component("ValidationProvider", ValidationProvider);
Vue.component("ValidationObserver", ValidationObserver);
localize("fr", fr);
extend("required", required);
extend("confirmed", confirmed);
extend("alpha", alpha);
extend("digits", digits);
extend("regex", regex);
extend("numeric", numeric);
extend("decimal", {
validate: (value, { decimals = "*", separator = "." } = {}) => {
if (value === null || value === undefined || value === "") {
return {
valid: false,
};
}
if (Number(decimals) === 0) {
return {
valid: /^-?\d*$/.test(value),
};
}
const regexPart = decimals === "*" ? "+" : `{1,${decimals}}`;
// eslint-disable-next-line no-unused-vars
const regex = new RegExp(
`^[-+]?\\d*(\\${separator}\\d${regexPart})?([eE]{1}[-]?\\d+)?$`
);
value = Number(value);
return {
valid: regex.test(value),
};
},
message:
"Le champ {_field_} doit contenir seulement un chiffre décimal par exemple: 500 ou 500.50",
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@@ -0,0 +1 @@
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 87.5 100"><defs><style>.cls-1{fill:#1697f6;}.cls-2{fill:#7bc6ff;}.cls-3{fill:#1867c0;}.cls-4{fill:#aeddff;}</style></defs><title>Artboard 46</title><polyline class="cls-1" points="43.75 0 23.31 0 43.75 48.32"/><polygon class="cls-2" points="43.75 62.5 43.75 100 0 14.58 22.92 14.58 43.75 62.5"/><polyline class="cls-3" points="43.75 0 64.19 0 43.75 48.32"/><polygon class="cls-4" points="64.58 14.58 87.5 14.58 43.75 100 43.75 62.5 64.58 14.58"/></svg>

After

Width:  |  Height:  |  Size: 539 B

View File

@@ -0,0 +1,10 @@
# STORE
**This directory is not required, you can delete it if you don't want to use it.**
This directory contains your Vuex Store files.
Vuex Store option is implemented in the Nuxt.js framework.
Creating a file in this directory automatically activates the option in the framework.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/vuex-store).

View File

@@ -0,0 +1,57 @@
export const state = () => ({
devices: [],
device: {},
});
export const mutations = {
update(state, params) {
state.device = { ...params };
},
updateDevices(state, params) {
state.devices = [...params];
},
};
export const actions = {
get({ commit, state }, params) {
console.log("===>", this.$axios);
return this.$axios.get(`/devices`);
},
getByName({ commit, rootGetters }, params) {
return this.$axios.get(`/devices/${params.name}`);
},
getFacts({ commit, rootGetters }, params) {
return this.$axios.get(`/devices/${params.name}/facts`);
},
getInterfacesIp({ commit, rootGetters }, params) {
return this.$axios.get(`/devices/${params.name}/interfaces/ip`);
},
getInterfaces({ commit, rootGetters }, params) {
return this.$axios.get(`/devices/${params.name}/interfaces`);
},
getSnapshots({ commit, rootGetters }, params) {
return this.$axios.get(`/devices/${params.name}/snapshots`);
},
buildSnapshots({ commit, rootGetters }, params) {
return this.$axios.post(`/devices/${params.name}/snapshots`);
},
config({ commit, rootGetters }, params) {
return this.$axios.post(`/devices/${params.name}/config`, params.data);
},
post({ commit }, params) {
return this.$axios.post(`/devices`, params.data);
},
delete({ commit }, params) {
return this.$axios.delete(`/devices/${params.name}`);
},
};
export const getters = {
get: (state) => {
return state.device;
},
getDevices: (state) => {
return state.devices;
},
};