Skip to content

Commit

Permalink
Fix send config and upgrade bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
oopsdump committed Jan 19, 2017
1 parent 206374c commit e17bc1e
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 85 deletions.
6 changes: 2 additions & 4 deletions src/opwifi/app/Http/Controllers/InstallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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"=> [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ 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');
$id = $request->get('id');
$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();
Expand Down
4 changes: 2 additions & 2 deletions src/opwifi/app/Http/Helpers/Install/DatabaseManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/opwifi/app/Http/Helpers/Opwifi/DeviceConfigApply.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
6 changes: 3 additions & 3 deletions src/opwifi/config/opwifi.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
return [
'version'=>'v0.2.1',
'version_raw'=>2001,
'publish_date'=>'2016-11-29'
'version'=>'v0.2.2',
'version_raw'=>2002,
'publish_date'=>'2017-01-19'
];
Original file line number Diff line number Diff line change
Expand Up @@ -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) {};

}

Expand All @@ -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) {
Expand Down
10 changes: 6 additions & 4 deletions src/public/res/js/opwifi_upload_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
61 changes: 0 additions & 61 deletions src/public/test.html

This file was deleted.

0 comments on commit e17bc1e

Please sign in to comment.