imbajin commented on code in PR #348:
URL: 
https://github.com/apache/hugegraph-computer/pull/348#discussion_r3329216015


##########
vermeer/ui/ui/lib/functions.js:
##########
@@ -0,0 +1,181 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+; (function () {
+    const API_PREFIX = '/api/v1';
+    window.vermeer = {
+        login: function () {
+            const token = $('#admin_token').val();
+            if (!token) {
+                showDelModal('empty token');
+                return;
+            }
+
+            const req = { token: token };
+            postJson('/login', req,
+                function (data) {
+                    console.log(data.message);
+                    location.reload(true);
+                }
+            );
+        },
+        queryGraphs: function () {
+            const $t = $('#graphs_table');
+            $t.empty();
+            const fields = ['space_name', 'name', 'status', 'state', 
'create_time',
+                'update_time', 'use_out_edges', 'use_out_degree'];
+            $t.append('<thead><tr/></thead>');
+            const $tr = $t.find('thead tr');
+            $.each(fields, function (index, field) {
+                $tr.append($('<th/>').text(field));
+            });
+
+            const ok = function (data) {
+                const $tb = $('<tbody/>');
+                $t.append($tb);
+                const rows = data.graphs;
+                $.each(rows, function (index, row) {
+                    $tb.append(toTableRow(fields, row));
+                });
+            };
+
+            get('/graphs', ok);
+        },
+        queryTasks: function () {
+            const $t = $('#tasks_table');
+            $t.empty();
+            const fields = ['id', 'space_name', 'graph_name', 'create_user', 
'task_type',
+                'status', 'state', 'create_time', 'start_time', 'update_time'];
+            $t.append('<thead><tr/></thead>');
+            const $tr = $t.find('thead tr');
+            $.each(fields, function (index, field) {
+                $tr.append($('<th/>').text(field));
+            });
+
+            const ok = function (data) {
+                const $tb = $('<tbody/>');
+                $t.append($tb);
+                const rows = data.tasks;
+                $.each(rows, function (index, row) {
+                    $tb.append(toTableRow(fields, row));
+                });
+            };
+            get('/tasks', ok);
+        }
+
+    };
+
+    function toTableRow(fields, row) {
+        const $row = $('<tr>');
+        $.each(fields, function (index, field) {
+            let value = '';
+
+            if (field.endsWith('_time')) {

Review Comment:
   ⚠️ **Avoid showing zero start_time as a real date**
   
   This formats every `*_time` field unconditionally, but `/api/v1/tasks` 
copies `task.StartTime` directly from `TaskInfo`; async tasks are created with 
only `CreateTime` set and `StartTime` is assigned later when scheduling 
actually starts. For created/waiting tasks the zero Go time is serialized and 
the dashboard will render it as a real ancient date instead of showing that the 
task has not started, which makes task state misleading. Please guard 
empty/zero/invalid time values before formatting, e.g. return `-` for zero 
`start_time`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to