From 8fe59f6c6689bcf2a578acaeafe395707d488f64 Mon Sep 17 00:00:00 2001 From: Winfried Kappeler Date: Thu, 28 Mar 2024 22:32:53 +0100 Subject: [PATCH] V0.0.3 InitApp.sh improvements - InitApp.sh improvements: - installing npm - installing vite --- CHANGELOG.md | 9 + app/Http/Controllers/Word2Controller.php | 225 ----------------------- scripts/InitApp.sh | 5 +- 3 files changed, 13 insertions(+), 226 deletions(-) delete mode 100644 app/Http/Controllers/Word2Controller.php diff --git a/CHANGELOG.md b/CHANGELOG.md index c9eb208..19971ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# V0.0.3 InitApp.sh improvements + +## Changed + +- InitApp.sh improvements: + - installing npm + - installing vite + + # V0.0.2 InitApp.sh improvements ## Changed diff --git a/app/Http/Controllers/Word2Controller.php b/app/Http/Controllers/Word2Controller.php deleted file mode 100644 index 40c9998..0000000 --- a/app/Http/Controllers/Word2Controller.php +++ /dev/null @@ -1,225 +0,0 @@ -btnSubmit === 'btnCancel') { - $rc = redirect('/word-index'); - } else { - $fields = $request->all(); - if (count($fields) === 0) { - $fields = [ - 'name' => '', - 'usage' => '', - 'wordtype_scope' => '', - 'verifiedby_id' => '' - ]; - } - $optionsWordtype = SProperty::optionsByScope('wordtype', $fields['wordtype_scope'], '-'); - $optionsVerifiedby = DbHelper::comboboxDataOfTable('users', 'name', 'id', $fields['verifiedby_id'], __('')); - $context = new ContextLaraKnife($request, $fields); - $rc = view('word.create', [ - 'context' => $context, - 'optionsWordtype' => $optionsWordtype, - 'optionsVerifiedby' => $optionsVerifiedby, - ]); - } - return $rc; - } - /** - * Show the form for editing the specified resource. - */ - public function edit(Word $word, Request $request) - { - if ($request->btnSubmit === 'btnCancel') { - $rc = redirect('/word-index'); - } else { - $fields = $request->all(); - if (count($fields) === 0) { - $fields = [ - 'name' => '', - 'usage' => '', - 'wordtype_scope' => '', - 'verifiedby_id' => '' - ]; - } - $optionsWordtype = SProperty::optionsByScope('wordtype', $word->wordtype_scope, ''); - $optionsVerifiedby = DbHelper::comboboxDataOfTable('users', 'name', 'id', $fields['verifiedby_id'], __('')); - $context = new ContextLaraKnife($request, null, $word); - $rc = view('word.edit', [ - 'context' => $context, - 'optionsWordtype' => $optionsWordtype, - 'optionsVerifiedby' => $optionsVerifiedby, - ]); - } - return $rc; - } - /** - * Remove the specified resource from storage. - */ - public function destroy(Word $word, Request $request) - { - if ($request->btnSubmit === 'btnDelete') { - $word->delete(); - } - return redirect('/word-index'); - } - /** - * Display the database records of the resource. - */ - public function index(Request $request) - { - if ($request->btnSubmit === 'btnNew') { - return redirect('/word-create'); - } else { - $sql = 'SELECT t0.*, t1.name as wordtype_scope, t2.name as verifiedby_id ' - . ' FROM words t0' - . ' LEFT JOIN sproperties t1 ON t1.id=t0.wordtype_scope' - . ' LEFT JOIN sproperties t2 ON t2.id=t0.verifiedby_id' - ; - $parameters = []; - $fields = $request->all(); - if (count($fields) == 0) { - $fields = [ - 'wordtype' => '', - 'verifiedby' => '', - 'name' => '', - 'usage' => '', - '_sortParams' => 'id:asc' - . ';name:desc' - ]; - } else { - $conditions = []; - ViewHelper::addConditionPattern($conditions, $parameters, 't0.name', 'name'); - ViewHelper::addConditionComparism($conditions, $parameters, 'wordtype_scope', 'wordtype'); - ViewHelper::addConditionComparism($conditions, $parameters, 'verifiedby_id', 'verifiedby'); - ViewHelper::addConditionPattern($conditions, $parameters, 'usage'); - $sql = DbHelper::addConditions($sql, $conditions); - } - $sql = DbHelper::addOrderBy($sql, $fields['_sortParams']); - $pagination = new Pagination($sql, $parameters, $fields); - $records = $pagination->records; - $optionsWordtype = SProperty::optionsByScope('wordtype', $fields['wordtype'], 'all'); - $optionsVerifiedby = DbHelper::comboboxDataOfTable('users', 'name', 'id', $fields['verifiedby'], __('')); - $context = new ContextLaraKnife($request, $fields); - return view('word.index', [ - 'context' => $context, - 'records' => $records, - 'optionsWordtype' => $optionsWordtype, - 'optionsVerifiedby' => $optionsVerifiedby, - 'pagination' => $pagination - ]); - } - } - /** - * Returns the validation rules. - * @return array The validation rules. - */ - private function rules(bool $isCreate=false): array - { - $rc = [ - 'name' => 'required', - 'usage' => 'required', - 'verifiedby_id' => '' - ]; - return $rc; - } - public static function routes() - { - Route::get('/word-index', [WordController::class, 'index'])->middleware('auth'); - Route::post('/word-index', [WordController::class, 'index'])->middleware('auth'); - Route::get('/word-create', [WordController::class, 'create'])->middleware('auth'); - Route::put('/word-store', [WordController::class, 'store'])->middleware('auth'); - Route::post('/word-edit/{word}', [WordController::class, 'edit'])->middleware('auth'); - Route::get('/word-edit/{word}', [WordController::class, 'edit'])->middleware('auth'); - Route::post('/word-update/{word}', [WordController::class, 'update'])->middleware('auth'); - Route::get('/word-show/{word}/delete', [WordController::class, 'show'])->middleware('auth'); - Route::delete('/word-show/{word}/delete', [WordController::class, 'destroy'])->middleware('auth'); - } - /** - * Display the specified resource. - */ - public function show(Word $word, Request $request) - { - if ($request->btnSubmit === 'btnCancel') { - $rc = redirect('/word-index')->middleware('auth'); - } else { - $fields = $request->all(); - $optionsWordtype = SProperty::optionsByScope('wordtype', $word->wordtype_scope, ''); - $optionsVerifiedby = DbHelper::comboboxDataOfTable('users', 'name', 'id', $word->verifiedby_id, __('')); - $context = new ContextLaraKnife($request, null, $word); - $rc = view('word.show', [ - 'context' => $context, - 'optionsWordtype' => $optionsWordtype, - 'optionsVerifiedby' => $optionsVerifiedby, - 'mode' => 'delete' - ]); - } - return $rc; - } - - /** - * Store a newly created resource in storage. - */ - public function store(Request $request) - { - $rc = null; - if ($request->btnSubmit === 'btnStore') { - $fields = $request->all(); - $validator = Validator::make($fields, $this->rules(true)); - if ($validator->fails()) { - $rc = back()->withErrors($validator)->withInput(); - } else { - $validated = $validator->validated(); - $validated['usage'] = strip_tags($validated['usage']); - Word::create($validated); - } - } - if ($rc == null){ - $rc = redirect('/word-index'); - } - return $rc; - } - /** - * Update the specified resource in storage. - */ - public function update(Word $word, Request $request) - { - $rc = null; - $session = $request->session(); - if ($request->btnSubmit === 'btnStore') { - $fields = $request->all(); - $validator = Validator::make($fields, $this->rules(false)); - if ($validator->fails()) { - $errors = $validator->errors(); - $rc = back()->withErrors($validator)->withInput(); - } else { - $validated = $validator->validated(); - $validated['usage'] = strip_tags($validated['usage']); - $word->update($validated); - } - } - if ($rc == null){ - $rc = redirect('/word-index'); - } - return $rc; - } -} diff --git a/scripts/InitApp.sh b/scripts/InitApp.sh index 377a7ca..ad8eb05 100755 --- a/scripts/InitApp.sh +++ b/scripts/InitApp.sh @@ -26,7 +26,7 @@ function LinkLaraknife(){ function DoIt(){ # get DEV_USER . .dev.user - apt update && apt install composer + apt update && apt install composer npm LinkLaraknife CreateStorage Wait @@ -37,7 +37,10 @@ function DoIt(){ Wait SeedIt Wait + egrep '"vite":' package.json && sudo -u $DEV_USER npm install vite + Wait sudo -u $DEV_USER npm run build + echo "see .lrv.credential for first login" } if [ ! -d ../laraknife ]; then echo "+++ missing ../laraknife" -- 2.39.5