diff --git a/src/opwifi/app/Http/Controllers/InstallController.php b/src/opwifi/app/Http/Controllers/InstallController.php index 085c9bf..5238254 100644 --- a/src/opwifi/app/Http/Controllers/InstallController.php +++ b/src/opwifi/app/Http/Controllers/InstallController.php @@ -156,11 +156,9 @@ public function getPermissions() */ public function getDatabase() { - $message = $this->databaseManager->migrateAndSeed(); + $resp = $this->databaseManager->migrateAndSeed(); - return view('installer.finished', compact('message')); - // return redirect()->route('Installer::final') - // ->with(['message' => $response]); + return view('installer.finished', $resp); } /** diff --git a/src/opwifi/app/Http/Controllers/Opwifi/Device/DeviceServController.php b/src/opwifi/app/Http/Controllers/Opwifi/Device/DeviceServController.php index 2f4dcc6..89b477e 100644 --- a/src/opwifi/app/Http/Controllers/Opwifi/Device/DeviceServController.php +++ b/src/opwifi/app/Http/Controllers/Opwifi/Device/DeviceServController.php @@ -197,9 +197,9 @@ private function appendOperation($req, &$rep) { /* For test */ /* end */ - if ($this->meta->op_config_id && - $this->configSha1) { - /* 简单处理,如果更改过,就进行下发 */ + if ($this->meta->op_config_id && $this->configSha1 && + isset($req['count']) && $req['count'] == 0) { + /* 简单处理,如果更改过,就进行下发。只第一次上报时下发,防止一直循环。 */ $setting = DeviceConfigApply::devmeta($this->meta)->check($this->configSha1); if ($setting) { $this->enCrypted['config'] = array( @@ -221,7 +221,7 @@ private function appendOperation($req, &$rep) { if ($this->meta['op_upgrade_id']){ $fw = $this->meta->upgrade()->first(); - if ($fw && $this->meta['m_fullver'] != $fw['version'] && + if ($fw && $this->meta['fullver'] != $fw['version'] && $this->meta['op_upgrade_trys'] != 1) { $rep['upgrade'] = array( "firmware"=> [ diff --git a/src/opwifi/app/Http/Controllers/Opwifi/Device/FirmwareController.php b/src/opwifi/app/Http/Controllers/Opwifi/Device/FirmwareController.php index 3a4212f..cb7094f 100644 --- a/src/opwifi/app/Http/Controllers/Opwifi/Device/FirmwareController.php +++ b/src/opwifi/app/Http/Controllers/Opwifi/Device/FirmwareController.php @@ -58,7 +58,7 @@ public function getSelect(Request $request) { public function postUpload(Request $request) { if (!$request->hasFile('file')) { - return response()->json(['error' => 'No file in submit.' ]); + return response()->json(['errors' => ['No file in submit.'] ]); } $file = $request->file('file'); $name = $request->get('name'); @@ -66,7 +66,7 @@ public function postUpload(Request $request) { $allowed_extensions = ["bin", "img", "spkg"]; if ($file->getClientOriginalExtension() && !in_array($file->getClientOriginalExtension(), $allowed_extensions)) { - return response()->json(['error' => 'You may only upload spkg, bin or img.']); + return response()->json(['errors' => ['You may only upload spkg, bin or img.']]); } $extension = $file->getClientOriginalExtension(); diff --git a/src/opwifi/app/Http/Helpers/Install/DatabaseManager.php b/src/opwifi/app/Http/Helpers/Install/DatabaseManager.php index 435dc78..3bc6fc4 100644 --- a/src/opwifi/app/Http/Helpers/Install/DatabaseManager.php +++ b/src/opwifi/app/Http/Helpers/Install/DatabaseManager.php @@ -46,10 +46,10 @@ private function seed() Artisan::call('db:seed'); } catch(Exception $e){ - return $e->getMessage(); + return $this->response($e->getMessage()); } - return trans('installer.final.finished'); + return $this->response(trans('installer.final.finished'), 'success'); } /** diff --git a/src/opwifi/app/Http/Helpers/Opwifi/DeviceConfigApply.php b/src/opwifi/app/Http/Helpers/Opwifi/DeviceConfigApply.php index 84de0cb..cf1a67d 100644 --- a/src/opwifi/app/Http/Helpers/Opwifi/DeviceConfigApply.php +++ b/src/opwifi/app/Http/Helpers/Opwifi/DeviceConfigApply.php @@ -101,6 +101,6 @@ public function check($sha1) { } public function update($sha1) { - $meta->update(['op_configed_sha1' => $sha1]); + $this->devMeta->update(['op_configed_sha1' => $sha1]); } } \ No newline at end of file diff --git a/src/opwifi/config/opwifi.php b/src/opwifi/config/opwifi.php index 65df1f1..fbb8679 100644 --- a/src/opwifi/config/opwifi.php +++ b/src/opwifi/config/opwifi.php @@ -1,6 +1,6 @@ 'v0.2.1', -'version_raw'=>2001, -'publish_date'=>'2016-11-29' +'version'=>'v0.2.2', +'version_raw'=>2002, +'publish_date'=>'2017-01-19' ]; \ No newline at end of file diff --git a/src/opwifi/database/migrations/2016_04_26_121053_create_ow_event.php b/src/opwifi/database/migrations/2016_04_26_121053_create_ow_event.php index c31198a..8fd683f 100644 --- a/src/opwifi/database/migrations/2016_04_26_121053_create_ow_event.php +++ b/src/opwifi/database/migrations/2016_04_26_121053_create_ow_event.php @@ -30,22 +30,25 @@ public function up() DO BEGIN '.$s['sql'].' END;'); } - DB::unprepared(' + try { + /* When mysql enable binlog, need SUPER privilege. Skip, let script do it! */ + DB::unprepared(' CREATE TRIGGER `owNewDevice` AFTER INSERT ON `ow_devices` FOR EACH ROW BEGIN INSERT INTO ow_devicemeta( dev_id, created_at, updated_at ) VALUES (NEW.id, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); INSERT INTO ow_webportal_devices( dev_id, created_at, updated_at ) VALUES (NEW.id, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); END - '); + '); - DB::unprepared(' + DB::unprepared(' CREATE TRIGGER `owNewStation` AFTER INSERT ON `ow_stations` FOR EACH ROW BEGIN INSERT INTO ow_stationmeta( sta_id, created_at, updated_at ) VALUES (NEW.id, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); END - '); + '); + } catch (\Exception $e) {}; } @@ -56,6 +59,7 @@ public function up() */ public function down() { + DB::unprepared('DELETE TRIGGER owNewStation'); DB::unprepared('DELETE TRIGGER owNewDevice'); $ss = SqlFakeScheduler::getRules(); foreach ($ss as $s) { diff --git a/src/public/res/js/opwifi_upload_file.js b/src/public/res/js/opwifi_upload_file.js index 66761c8..08dd9cd 100644 --- a/src/public/res/js/opwifi_upload_file.js +++ b/src/public/res/js/opwifi_upload_file.js @@ -14,20 +14,22 @@ $(function(){ $('#uploadFileForm').fileupload({ dataType: 'json', done: function (e, data) { - if(data.success == false) { - var responseErrors = data.errors; + var res = data.result; + if(res.success == false || res.errors != undefined) { + var responseErrors = res.errors; $.each(responseErrors, function(index, value){ if (value.length != 0) { $.opwifi.opalert($('#owcontent'), 'warning', value); } }); - $.opwifi.opalert($('#owcontent'), 'warning'); + if (res.errors.length == 0) + $.opwifi.opalert($('#owcontent'), 'warning'); } else { $('.upload-file-mask').hide(); $('.upload-file').hide(); $.opwifi.opalert($('#owcontent'), 'success'); - if (success) success(data); + if (success) success(res); } }, progressall: function (e, data) { diff --git a/src/public/test.html b/src/public/test.html deleted file mode 100644 index 23f54ec..0000000 --- a/src/public/test.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - -
-
-
- -
-
- - - - - - \ No newline at end of file