]> git.localhorst.tv Git - alttp.git/commitdiff
add aos seed retry button
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Thu, 12 May 2022 21:38:37 +0000 (23:38 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Thu, 12 May 2022 21:38:37 +0000 (23:38 +0200)
app/Http/Controllers/AosSeedController.php
resources/js/components/aos/Seed.js
resources/js/components/pages/AosSeed.js
resources/js/i18n/de.js
resources/js/i18n/en.js
routes/api.php

index 3e3a2b05afcd293acd034bb2bf79f5e2e4daa9b4..9d35bc09fd0fcc44324a94178665f0158c974a9f 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace App\Http\Controllers;
 
 
 namespace App\Http\Controllers;
 
+use App\Jobs\GenerateAosSeed;
 use App\Models\AosSeed;
 use Illuminate\Http\Request;
 
 use App\Models\AosSeed;
 use Illuminate\Http\Request;
 
@@ -21,4 +22,16 @@ class AosSeedController extends Controller
                return $seed->toJson();
        }
 
                return $seed->toJson();
        }
 
+       public function retry($hash) {
+               $seed = AosSeed::where('hash', '=', $hash)->firstOrFail();
+
+               if ($seed->status == 'error') {
+                       $seed->status = 'pending';
+                       $seed->save();
+                       GenerateAosSeed::dispatch($seed)->onConnection('database');
+               }
+
+               return $seed->toJson();
+       }
+
 }
 }
index 3e6ac4af4e11bce9575ac8221fa0610016beb9af..a035e602b2e58f2f6aaed8ea886abb910075bcc6 100644 (file)
@@ -65,7 +65,7 @@ const isDefaultSetting = (name, value) => {
        }
 };
 
        }
 };
 
-const Seed = ({ patch, seed }) => {
+const Seed = ({ onRetry, patch, seed }) => {
        const { rom } = useAosBaseRom();
 
        return <Container>
        const { rom } = useAosBaseRom();
 
        return <Container>
@@ -125,6 +125,16 @@ const Seed = ({ patch, seed }) => {
                                                <strong>{i18n.t(`aosSeeds.statuses.${seed.status}`)}</strong>
                                        </p>
                                }
                                                <strong>{i18n.t(`aosSeeds.statuses.${seed.status}`)}</strong>
                                        </p>
                                }
+                               {seed.status === 'error' ?
+                                       <p>
+                                               <Button
+                                                       onClick={onRetry}
+                                                       variant="secondary"
+                                               >
+                                                       {i18n.t('button.retry')}
+                                               </Button>
+                                       </p>
+                               : null}
                        </Col>
                </Row>
                <h2 className="mt-5">{i18n.t('aosSeeds.generator')}</h2>
                        </Col>
                </Row>
                <h2 className="mt-5">{i18n.t('aosSeeds.generator')}</h2>
@@ -151,6 +161,7 @@ const Seed = ({ patch, seed }) => {
 };
 
 Seed.propTypes = {
 };
 
 Seed.propTypes = {
+       onRetry: PropTypes.func,
        patch: PropTypes.instanceOf(ArrayBuffer),
        seed: PropTypes.shape({
                generator: PropTypes.string,
        patch: PropTypes.instanceOf(ArrayBuffer),
        seed: PropTypes.shape({
                generator: PropTypes.string,
index e3cfda8f93b6a8f3e6b754b6007691d1e0254eb3..165a2bedbea81e17a0576b53b6e761c578dc3e4d 100644 (file)
@@ -78,6 +78,11 @@ const AosSeed = () => {
                };
        }, [hash, seed]);
 
                };
        }, [hash, seed]);
 
+       const retry = useCallback(async () => {
+               await axios.post(`/api/aos-seed/${hash}/retry`);
+               setSeed(seed => ({ ...seed, status: 'pending' }));
+       });
+
        if (loading) {
                return <Loading />;
        }
        if (loading) {
                return <Loading />;
        }
@@ -91,7 +96,7 @@ const AosSeed = () => {
        }
 
        return <ErrorBoundary>
        }
 
        return <ErrorBoundary>
-               <Seed patch={patch} seed={seed} />
+               <Seed onRetry={retry} patch={patch} seed={seed} />
        </ErrorBoundary>;
 };
 
        </ErrorBoundary>;
 };
 
index a8445bd11d7245bd477941a8de3f7682d46e3db6..a51c84679e0af4d8bee1fab8f1e52ba99bc0be08 100644 (file)
@@ -198,6 +198,7 @@ export default {
                        logout: 'Logout',
                        new: 'Neu',
                        protocol: 'Protokoll',
                        logout: 'Logout',
                        new: 'Neu',
                        protocol: 'Protokoll',
+                       retry: 'Neu versuchen',
                        save: 'Speichern',
                        search: 'Suche',
                        settings: 'Einstellungen',
                        save: 'Speichern',
                        search: 'Suche',
                        settings: 'Einstellungen',
index 510d68be553541b26f8eda3c2707d76a2477ecf3..64d38bb609feeeab23838b174334865260e1e342 100644 (file)
@@ -198,6 +198,7 @@ export default {
                        logout: 'Logout',
                        new: 'New',
                        protocol: 'Protocol',
                        logout: 'Logout',
                        new: 'New',
                        protocol: 'Protocol',
+                       retry: 'Retry',
                        save: 'Save',
                        search: 'Search',
                        settings: 'Settings',
                        save: 'Save',
                        search: 'Search',
                        settings: 'Settings',
index e3a5ad8b32bf1523ff98f9a66e93bac86726b6f2..f43505aa4374c4aa16615493a00f84d8c42532d8 100644 (file)
@@ -19,6 +19,7 @@ Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
 });
 
 Route::get('aos-seed/{hash}', 'App\Http\Controllers\AosSeedController@byHash');
 });
 
 Route::get('aos-seed/{hash}', 'App\Http\Controllers\AosSeedController@byHash');
+Route::post('aos-seed/{hash}/retry', 'App\Http\Controllers\AosSeedController@retry');
 
 Route::post('application/{application}/accept', 'App\Http\Controllers\ApplicationController@accept');
 Route::post('application/{application}/reject', 'App\Http\Controllers\ApplicationController@reject');
 
 Route::post('application/{application}/accept', 'App\Http\Controllers\ApplicationController@accept');
 Route::post('application/{application}/reject', 'App\Http\Controllers\ApplicationController@reject');