20181224_jeffrey - silenceuncrio/diary GitHub Wiki

0925

今天先把 wizard 告一小段落

作不完也沒關係

先以 V1.76 為優先

1140

先為了 wizard 的每個 step 都加上 reset 鈕讓使用者能重新跟 device 上目前該 step 的 config 作 sync

而且在 sync 的過程讓頁面能夠顯示正在 refresh

上 code 且 push

commit df414f9702dc4b0d6a7fd5e37135b61d6846e8c7
Refs: [develop]
Author: jeffrey <[email protected]>
Date:   Mon Dec 24 11:39:07 2018 +0800

    setting wizard:
    - each step has a 'Reset' button to sync the current configurations at devic
    - display a sync icon while syncing

 proscend/prosrc/www/app/feature/wizard.html | 163 ++++++++++++------
 proscend/prosrc/www/app/feature/wizard.js   | 256 +++++++++++++++++++++-------
 2 files changed, 301 insertions(+), 118 deletions(-)

1145

M300 先切回 hotfix/v1.76 branch

這禮拜要 release

先 build 一版

1300

利用 mfgtool 作燒錄

1305

spring 表示 M300 的 backup file 檔名最前面多了一個引號

待會 mfgtool 燒錄後開機就來 check 一下

先描述一下異常的現象

M300 Configuration backup - http responde - filename

image

M300 Configuration backup - window popup

image

會發現 window 已經幫忙做了兩件事

  • 把最前面的引號拿掉
  • 把時間戳記產生的冒號變成底線

CGI 相關的 code 如下

static void _backup()
{
    if (ICOS_cfg_backup(BACKUP_PATH, XOR_ENABLED) != 0)
    {
        jweb.http.status(500);
    }
    else
    {
        char *filename = get_command_output("date +'%Y-%m-%d-%H:%M.tgz'");
        jweb.out.download.path(filename, BACKUP_PATH);
    }
}

get_command_output() 的 source code 如下

char* get_command_output(const char *cmd)
{
    int size = 1024;
    char *result = (char *) malloc(sizeof(char) * size);

    if (!result)
    {
        return NULL;
    }

    char *temp;

    int current_pos = 0;
    result[current_pos] = 0;

    FILE *fp = popen(cmd, "r");

    if (fp == NULL)
    {
        free(result);
        return NULL;
    }

    while (fgets(result + current_pos, size - current_pos, fp) != NULL)
    {
        current_pos = strlen(result);
        size += 1024;

        temp = (char *) malloc(sizeof(char) * size);
        if (!temp)
        {
            free(result);
            return NULL;
        }

        strcpy(temp, result);
        free(result);
        result = temp;
    }

    pclose(fp);

    return result;
}

發現 char *filename = get_command_output("date +'%Y-%m-%d-%H:%M.tgz'"); 會多了一個跳行字元

chrome 按 view source 可以發現

image

get_command_output 這個 function 有點歷史 不好隨便去改

比較好的方式是我改寫一下 cgi 不要使用 get_command_output()

可以參考 Building a date string in c

不過這邊的修改還是上到 develop 會比較好

可以先改來試試看有沒有效

再把 diff 的結果記錄在日記上方便之後修改到 develop

修改成功

keep 一下 diff 的結果

diff --git a/proscend/prosrc/webcgi/configuration.c b/proscend/prosrc/webcgi/configuration.c
index 2c5ea84..a0492e5 100644
--- a/proscend/prosrc/webcgi/configuration.c
+++ b/proscend/prosrc/webcgi/configuration.c
@@ -19,7 +19,10 @@ static void _backup()
     }
     else
     {
-        char *filename = get_command_output("date +'%Y-%m-%d-%H:%M.tgz'");
+        char filename[100];
+        time_t now = time(NULL);
+        struct tm *t = localtime(&now);
+        strftime(filename, sizeof(filename)-1, "%Y-%m-%d-%H_%M.tgz", t);
         jweb.out.download.path(filename, BACKUP_PATH);
     }
 }
(END)

1445

來加 ip filter 的 white list

參考 M360 的修改

1525

M300 ip filter white list 從 M360 merge 完畢

重新 build 一版 image

用 mfgtool 作燒錄

看來 web ui 已經長出來了

commit 吧

commit a46b2999954d4320c765294d33687298195dcca2
Refs: [hotfix/v1.76], {origin/hotfix/v1.76}
Author: jeffrey <[email protected]>
Date:   Mon Dec 24 15:36:19 2018 +0800

    modify 'Firewall > IP Filter' accoring to the designer:
    - support white list
    - add some hints

 proscend/prosrc/webcgi/configuration.c             |  5 ++-
 proscend/prosrc/webcgi/ipfilter.c                  | 16 +++++++-
 proscend/prosrc/www/app/feature/ipfilter.js        |  4 +-
 proscend/prosrc/www/app/feature/ipfilter_edit.html | 19 +++++++++
 .../prosrc/www/app/feature/ipfilter_summary.html   | 46 +++++++++++++++++-----
 proscend/prosrc/www/app/locale-en.json             | 24 +++++++++++
 proscend/prosrc/www/app/locale-fr.json             | 24 +++++++++++
 proscend/prosrc/www/app/locale-zh-tw.json          | 24 +++++++++++
 8 files changed, 149 insertions(+), 13 deletions(-)

不小心把 backup file 的 修改 commit 上去了

就這樣吧

不用特地為了它 commit 了

1545

john 的 vlan 需要新增一個 field 叫 VLAN Isolation

修改後直接 build 一版 image

mfgtool 燒錄

驗證無誤

上 code

commit c83324bf2409668b8a24ba3795d0caf386d2de0a
Refs: [hotfix/v1.76], {origin/hotfix/v1.76}
Author: jeffrey <[email protected]>
Date:   Mon Dec 24 16:19:28 2018 +0800

    add 'VLAN Isolation' field at 'VLAN' web page

 proscend/prosrc/webcgi/vlan.c             |  2 ++
 proscend/prosrc/www/app/feature/vlan.html | 12 ++++++++++++
 proscend/prosrc/www/app/locale-en.json    |  1 +
 proscend/prosrc/www/app/locale-fr.json    |  1 +
 proscend/prosrc/www/app/locale-zh-tw.json |  1 +
 5 files changed, 17 insertions(+)

1620

回到 develop

繼續 wizard

build image... mfgtool 燒錄...

1640

試著來做 wizard 的滿版

1800

成功的利用

app.controller.js 的 $scope.$on('$routeChangeStart', function(event, next, current) {...})

搞定 wizard 的滿版

commit df26272042bb00960767f8e2af6ccc36505404e9
Refs: [develop], {origin/develop}
Author: jeffrey <[email protected]>
Date:   Mon Dec 24 17:58:31 2018 +0800

    display wizard in full layout and stay original layout while not in wizard m

 proscend/prosrc/www/app/app.controller.js | 27 +++++++--------------------
 proscend/prosrc/www/src/index.html.src    | 10 ++++++----
 2 files changed, 13 insertions(+), 24 deletions(-)

比較值得一提的是 Angular not updating ng-class on ng-view 這個現象

花了不少時間才理解 angular 有這個問題

幸好有方法閃了過去