Skip to content

Commit

Permalink
move tomato-component to tomato-admin
Browse files Browse the repository at this point in the history
  • Loading branch information
3x1io committed Sep 3, 2023
1 parent d43c54d commit 043da9b
Show file tree
Hide file tree
Showing 37 changed files with 2,499 additions and 44 deletions.
20 changes: 13 additions & 7 deletions publish/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,31 @@
"@protonemedia/laravel-splade": "^1.1.0",
"@tailwindcss/forms": "^0.5.3",
"@tailwindcss/typography": "^0.5.8",
"@vitejs/plugin-vue": "^3.0.0",
"@vitejs/plugin-vue": "^4.0.0",
"autoprefixer": "^10.4.13",
"axios": "^1.1.2",
"laravel-vite-plugin": "^0.5.0",
"laravel-vite-plugin": "^0.7.3",
"lodash": "^4.17.21",
"postcss": "^8.4.18",
"tailwindcss": "^3.2.1",
"vite": "^3.0.0",
"vue": "^3.2.41",
"postcss-scss": "^4.0.6",
"sass": "^1.57.1"
"sass": "^1.57.1",
"tailwindcss": "^3.2.1",
"vite": "^4.0.0",
"vue": "^3.2.41"
},
"dependencies": {
"@suadelabs/vue3-multiselect": "^1.0.2",
"@tailwindcss/line-clamp": "^0.4.2",
"boxicons": "^2.1.4",
"codemirror-editor-vue3": "^2.1.8",
"moment": "^2.29.4",
"numeral": "^2.0.6",
"postcss-import": "^15.1.0",
"tailwindcss-rtl": "^0.9.0",
"tippy.js": "^6.3.7"
"tippy.js": "^6.3.7",
"vue-draggable-next": "^2.2.1",
"vue3-editor": "^0.1.1",
"vue3-swatches": "^1.2.3",
"vue3-tel-input": "^1.0.4"
}
}
19 changes: 19 additions & 0 deletions publish/resources/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ const el = document.getElementById("app");

import './choices.scss';

import TomatoRoles from "../../vendor/tomatophp/tomato-admin/resources/js/components/TomatoRoles.vue";
import TomatoRepeater from "../../vendor/tomatophp/tomato-admin/resources/js/components/TomatoRepeater.vue";
import TomatoColor from "../../vendor/tomatophp/tomato-admin/resources/js/components/TomatoColor.vue";
import TomatoRich from "../../vendor/tomatophp/tomato-admin/resources/js/components/TomatoRich.vue";
import TomatoTel from "../../vendor/tomatophp/tomato-admin/resources/js/components/TomatoTel.vue";
import TomatoSelect from "../../vendor/tomatophp/tomato-admin/resources/js/components/TomatoSelect.vue";
import TomatoArtisan from "../../vendor/tomatophp/tomato-admin/resources/js/components/TomatoArtisan.vue";
import TomatoCode from "../../vendor/tomatophp/tomato-admin/resources/js/components/TomatoCode.vue";
import TomatoDraggable from "../../vendor/tomatophp/tomato-admin/resources/js/components/TomatoDraggable.vue";

createApp({
render: renderSpladeApp({ el })
})
Expand All @@ -17,4 +27,13 @@ createApp({
transform_anchors: false,
progress_bar: true,
})
.component("TomatoDraggable", TomatoDraggable)
.component("TomatoRoles", TomatoRoles)
.component("TomatoRepeater", TomatoRepeater)
.component("TomatoColor", TomatoColor)
.component("TomatoTel", TomatoTel)
.component("TomatoRich", TomatoRich)
.component("TomatoSelect", TomatoSelect)
.component("TomatoArtisan", TomatoArtisan)
.component("TomatoCode", TomatoCode)
.mount(el);
172 changes: 172 additions & 0 deletions resources/js/components/TomatoArtisan.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
<template>
<div class="w-full antialiased" :class="{'overflow-y-auto': selectedCommand == null, 'overflow-hidden': selectedCommand != null}">
<div>

<div class="container mx-auto">
<top-bar @search="onSearch" :home="$attrs.route+'/admin/artisan'"/>

<div v-for="(group, key) in filteredGroups" :key="group.name">
<group @select="onSelect" :name="key" :commands="group"/>
</div>

</div>
</div>

<!-- Overlay -->
<transition
enter-active-class="transition-all duration-300 ease-out-quad"
leave-active-class="transition-all ease-in-quad duration-50"
enter-class="opacity-0"
enter-to-class="opacity-100"
leave-class="opacity-100"
leave-to-class="opacity-0"
>
<div v-if="selectedCommand != null || loading" @click="selectedCommand = null" class="fixed top-0 left-0 w-full h-full" :class="{'cursor-pointer': selectedCommand != null}">
<div class="w-full h-full bg-black opacity-20"></div>
</div>
</transition>
<!-- Sidebar -->
<transition
enter-active-class="transition-all duration-300 ease-out-quad"
leave-active-class="transition-all ease-in-quad duration-50"
enter-class="transform translate-x-full"
enter-to-class="transform translate-x-0"
leave-class="transform translate-x-0"
leave-to-class="transform translate-x-full"
>
<div v-if="selectedCommand != null" class="fixed top-0 right-0 w-full h-full max-w-lg overflow-x-hidden overflow-y-auto bg-white">
<command-sidebar :old="old" :errors="errors" @run="runCommand" @close="selectedCommand = null" :command="selectedCommand" />
</div>

</transition>
<!-- Loading spinner -->
<transition
enter-active-class="transition-all duration-300 ease-out-quad"
leave-active-class="transition-all ease-in-quad duration-50"
enter-class="opacity-0"
enter-to-class="opacity-100"
leave-class="opacity-100"
leave-to-class="opacity-0"
>
<div v-if="loading" class="fixed top-0 left-0 flex items-center justify-center w-full h-full text-primary-500">
<div class="w-8 h-8 text-primary-500 animate-spin">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" class="w-full h-full" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6" />
</svg>
</div>
</div>
</transition>

<transition
enter-active-class="transition-all duration-300 ease-out-quad"
leave-active-class="transition-all ease-in-quad duration-50"
enter-class="transform translate-y-full"
enter-to-class="transform translate-y-0"
leave-class="transform translate-y-0"
leave-to-class="transform translate-y-full"
>
<div v-if="output != null" class="fixed bottom-0 left-0 w-full mb-6">

<div @click="output = null" class="container px-4 mx-auto overflow-hidden cursor-pointer rounded-2xl md:px-0">
<command-output :command="output.command" :status="output.status" :output="output.output.replaceAll('\n', '<br />')" />
</div>

</div>
</transition>

</div>

</template>

<script>
import TopBar from "./components/TopBar.vue";
import Group from "./components/Group.vue";
import CommandSidebar from "./components/CommandSidebar.vue";
import Output from "./components/CommandOutput.vue";
import CommandOutput from "./components/CommandOutput.vue";
export default {
components: {CommandOutput, CommandSidebar, Group, TopBar},
data() {
return {
groups: [],
loading: false,
selectedCommand: null,
search: '',
errors: [],
old: null,
output: null
}
},
created() {
this.fetchGroups();
},
computed: {
filteredGroups() {
if (this.search === '')
return this.groups;
let res = {};
for (let key of Object.keys(this.groups ?? {})) {
let group = this.groups[key];
if (key.toLowerCase().includes(this.search.toLowerCase())) {
res[key] = group;
continue;
}
let tmpGroup = [];
for (let command of group) {
if (command.name.toLowerCase().includes(this.search.toLowerCase())) {
tmpGroup.push(command);
}
}
if (tmpGroup.length > 0)
res[key] = tmpGroup;
}
return res;
},
commands(){
return this.$attrs.commands;
}
},
methods: {
reload(){
this.$splade.get(this.$attrs.route+'/admin/artisan');
},
fetchGroups() {
this.groups = this.commands;
},
onSelect(command) {
this.errors = [];
this.old = null;
if (command.arguments == null && command.options == null)
this.runCommand(command)
else
this.selectedCommand = command;
},
runCommand(command, formData) {
this.loading = true;
Object.assign(command, formData);
axios.post(this.$attrs.route+'/admin/artisan/run',command).then(response => {
this.output = response.data;
this.loading = false;
})
},
onSearch(search) {
this.search = search
}
}
}
</script>
127 changes: 127 additions & 0 deletions resources/js/components/TomatoCode.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<template>
<div ref="input">
<slot name="prepend"/>
<Codemirror
v-model:value="value"
ref="cmEditor"
width="100%"
:options="cmOptions"
border
/>
<slot name="append"/>
</div>
</template>
<script>
import "codemirror/lib/codemirror.css";
import "codemirror/mode/php/php.js";
import "codemirror/mode/javascript/javascript.js";
import "codemirror/mode/css/css.js";
import "codemirror/mode/htmlmixed/htmlmixed.js";
import "codemirror/addon/edit/matchbrackets";
import "codemirror/mode/xml/xml.js";
import "codemirror/theme/base16-dark.css";
import "codemirror/mode/clike/clike.js";
import Codemirror from "codemirror-editor-vue3";
export default {
components: {
Codemirror
},
props: {
modelValue: {
type: [String, Number],
required: false,
},
ex: {
type: [String, Number],
required: false,
default: "txt"
}
},
data() {
return {
disabled: false,
element: null,
observer: null,
value: "",
cmOptions: {
tabSize: 4,
mode: "application/x-httpd-php",
theme: "base16-dark",
lineNumbers: true,
line: true,
matchBrackets: true,
indentUnit: 4,
indentWithTabs: true,
lineWrapping: true,
}
};
},
emits: ["update:modelValue"],
watch: {
value(updatedValue) {
this.$emit("update:modelValue", updatedValue);
},
ex(newValue){
if (this.ex == "php") {
this.cmOptions.mode = "application/x-httpd-php";
} else if (
this.ex == "js" ||
this.ex == "json" ||
this.ex == "lock"
) {
this.cmOptions.mode = {
name: "javascript",
json: true,
};
} else if (this.ex == "css") {
this.cmOptions.mode = "text/css";
} else if (
this.ex == "webp" ||
this.ex == "svg" ||
this.ex == "png" ||
this.ex == "jpg" ||
this.ex == "jpeg" ||
this.ex == "tif" ||
this.ex == "gif" ||
this.ex == "ico"
) {
}
}
},
mounted() {
if (this.modelValue !== null && this.modelValue !== undefined) {
this.value = this.modelValue
}
else {
if (this.default) {
this.value = this.default
}
}
},
render(){
return this.$slots.default({
disabled: this.disabled,
element: this.element,
observer: this.observer,
value: this.value,
cmOptions: {
tabSize: 4,
mode: "application/x-httpd-php",
theme: "base16-dark",
lineNumbers: true,
line: true,
matchBrackets: true,
indentUnit: 4,
indentWithTabs: true,
lineWrapping: true,
},
Codemirror
});
}
};
</script>
Loading

0 comments on commit 043da9b

Please sign in to comment.