forked from IceWhaleTech/CasaOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix bug * updata UI * 0.3.2 ### Added - [Files] Files can now be selected multiple files and downloaded, deleted, moved, etc. - [Apps] Support to modify the application opening address.([IceWhaleTech#204](IceWhaleTech#204)) ### Changed - [Apps] Hide the display of non-essential environment variables in the application. - [System] Network, disk, cpu, memory, etc. information is modified to be pushed via socket. - [System] Optimize opening speed.([IceWhaleTech#214](IceWhaleTech#214)) ### Fixed - [System] Fixed the problem that sync data cannot submit the device ID ([IceWhaleTech#68](IceWhaleTech#68)) - [Files] Fixed the code editor center alignment display problem.([IceWhaleTech#210](IceWhaleTech#210)) - [Files] Fixed the problem of wrong name when downloading files.([IceWhaleTech#240](IceWhaleTech#240)) - [System] Fixed the network display as a negative number problem.([IceWhaleTech#224](IceWhaleTech#224)) * Modify log help class * Fix some bugs in 0.3.2 * Solve the operation file queue problem * Exclude web folders * update UI * add cancel file operate * Update UI * Merge sockets to transfer data * Conflict Resolution
- Loading branch information
Showing
19 changed files
with
496 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* @Author: LinkLeong [email protected] | ||
* @Date: 2022-05-20 16:27:12 | ||
* @LastEditors: LinkLeong | ||
* @LastEditTime: 2022-06-08 15:40:33 | ||
* @LastEditTime: 2022-06-09 18:18:46 | ||
* @FilePath: /CasaOS/model/file.go | ||
* @Description: | ||
* @Website: https://www.casaos.io | ||
|
@@ -16,6 +16,8 @@ type FileOperate struct { | |
TotalSize int64 `json:"total_size"` | ||
ProcessedSize int64 `json:"processed_size"` | ||
To string `json:"to" binding:"required"` | ||
Style string `json:"style"` | ||
Finished bool `json:"finished"` | ||
} | ||
|
||
type FileItem struct { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* @Author: LinkLeong [email protected] | ||
* @Date: 2022-05-27 15:55:36 | ||
* @LastEditors: LinkLeong | ||
* @LastEditTime: 2022-05-27 18:57:40 | ||
* @LastEditTime: 2022-06-10 12:17:59 | ||
* @FilePath: /CasaOS/route/periodical.go | ||
* @Description: | ||
* @Website: https://www.casaos.io | ||
|
@@ -153,3 +153,133 @@ func SendUSBBySocket() { | |
} | ||
service.MyService.Notify().SendUSBInfoBySocket(usb) | ||
} | ||
|
||
func SendAllHardwareStatusBySocket() { | ||
|
||
netList := service.MyService.System().GetNetInfo() | ||
newNet := []model.IOCountersStat{} | ||
nets := service.MyService.System().GetNet(true) | ||
for _, n := range netList { | ||
for _, netCardName := range nets { | ||
if n.Name == netCardName { | ||
item := *(*model.IOCountersStat)(unsafe.Pointer(&n)) | ||
item.State = strings.TrimSpace(service.MyService.ZiMa().GetNetState(n.Name)) | ||
item.Time = time.Now().Unix() | ||
newNet = append(newNet, item) | ||
break | ||
} | ||
} | ||
} | ||
|
||
cpu := service.MyService.System().GetCpuPercent() | ||
num := service.MyService.System().GetCpuCoreNum() | ||
cpuData := make(map[string]interface{}) | ||
cpuData["percent"] = cpu | ||
cpuData["num"] = num | ||
|
||
list := service.MyService.Disk().LSBLK(true) | ||
|
||
summary := model.Summary{} | ||
healthy := true | ||
findSystem := 0 | ||
|
||
for i := 0; i < len(list); i++ { | ||
if len(list[i].Children) > 0 && findSystem == 0 { | ||
|
||
for j := 0; j < len(list[i].Children); j++ { | ||
|
||
if len(list[i].Children[j].Children) > 0 { | ||
for _, v := range list[i].Children[j].Children { | ||
if v.MountPoint == "/" { | ||
s, _ := strconv.ParseUint(v.FSSize, 10, 64) | ||
a, _ := strconv.ParseUint(v.FSAvail, 10, 64) | ||
u, _ := strconv.ParseUint(v.FSUsed, 10, 64) | ||
summary.Size += s | ||
summary.Avail += a | ||
summary.Used += u | ||
findSystem = 1 | ||
break | ||
} | ||
} | ||
} else { | ||
if list[i].Children[j].MountPoint == "/" { | ||
s, _ := strconv.ParseUint(list[i].Children[j].FSSize, 10, 64) | ||
a, _ := strconv.ParseUint(list[i].Children[j].FSAvail, 10, 64) | ||
u, _ := strconv.ParseUint(list[i].Children[j].FSUsed, 10, 64) | ||
summary.Size += s | ||
summary.Avail += a | ||
summary.Used += u | ||
findSystem = 1 | ||
break | ||
} | ||
} | ||
} | ||
|
||
} | ||
if findSystem == 1 { | ||
findSystem += 1 | ||
continue | ||
} | ||
if list[i].Tran == "sata" || list[i].Tran == "nvme" || list[i].Tran == "spi" || list[i].Tran == "sas" { | ||
temp := service.MyService.Disk().SmartCTL(list[i].Path) | ||
if reflect.DeepEqual(temp, model.SmartctlA{}) { | ||
continue | ||
} | ||
|
||
//list[i].Temperature = temp.Temperature.Current | ||
if !temp.SmartStatus.Passed { | ||
healthy = false | ||
} | ||
if len(list[i].Children) > 0 { | ||
for _, v := range list[i].Children { | ||
s, _ := strconv.ParseUint(v.FSSize, 10, 64) | ||
a, _ := strconv.ParseUint(v.FSAvail, 10, 64) | ||
u, _ := strconv.ParseUint(v.FSUsed, 10, 64) | ||
summary.Size += s | ||
summary.Avail += a | ||
summary.Used += u | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
||
summary.Health = healthy | ||
|
||
usbList := service.MyService.Disk().LSBLK(false) | ||
usb := []model.DriveUSB{} | ||
for _, v := range usbList { | ||
if v.Tran == "usb" { | ||
temp := model.DriveUSB{} | ||
temp.Model = v.Model | ||
temp.Name = v.Name | ||
temp.Size = v.Size | ||
mountTemp := true | ||
if len(v.Children) == 0 { | ||
mountTemp = false | ||
} | ||
for _, child := range v.Children { | ||
if len(child.MountPoint) > 0 { | ||
avail, _ := strconv.ParseUint(child.FSAvail, 10, 64) | ||
temp.Avail += avail | ||
used, _ := strconv.ParseUint(child.FSUsed, 10, 64) | ||
temp.Used += used | ||
} else { | ||
mountTemp = false | ||
} | ||
} | ||
temp.Mount = mountTemp | ||
usb = append(usb, temp) | ||
} | ||
} | ||
memInfo := service.MyService.System().GetMemInfo() | ||
memData := make(map[string]interface{}) | ||
memData["total"] = memInfo.Total | ||
memData["available"] = memInfo.Available | ||
memData["used"] = memInfo.Used | ||
memData["free"] = memInfo.Free | ||
memData["usedPercent"] = memInfo.UsedPercent | ||
|
||
service.MyService.Notify().SendAllHardwareStatusBySocket(summary, usb, memData, cpuData, newNet) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* @Author: LinkLeong [email protected] | ||
* @Date: 2022-05-23 17:18:56 | ||
* @LastEditors: LinkLeong | ||
* @LastEditTime: 2022-06-08 16:31:24 | ||
* @LastEditTime: 2022-06-09 21:48:10 | ||
* @FilePath: /CasaOS/route/socket.go | ||
* @Description: | ||
* @Website: https://www.casaos.io | ||
|
@@ -49,7 +49,7 @@ func SocketInit(msg chan notify.Message) { | |
go func(msg chan notify.Message) { | ||
for v := range msg { | ||
f.Broadcast("", v.Path, &v.Msg) | ||
time.Sleep(time.Millisecond * 300) | ||
time.Sleep(time.Millisecond * 100) | ||
} | ||
|
||
}(msg) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* @Author: LinkLeong [email protected] | ||
* @Date: 2021-12-20 14:15:46 | ||
* @LastEditors: LinkLeong | ||
* @LastEditTime: 2022-06-08 15:46:36 | ||
* @LastEditTime: 2022-06-09 18:15:54 | ||
* @FilePath: /CasaOS/service/file.go | ||
* @Description: | ||
* @Website: https://www.casaos.io | ||
|
@@ -21,6 +21,8 @@ import ( | |
|
||
"github.com/IceWhaleTech/CasaOS/model" | ||
"github.com/IceWhaleTech/CasaOS/pkg/utils/file" | ||
"github.com/IceWhaleTech/CasaOS/pkg/utils/loger" | ||
"go.uber.org/zap" | ||
) | ||
|
||
var FileQueue sync.Map | ||
|
@@ -87,26 +89,37 @@ func FileOperate(k string) { | |
if temp.ProcessedSize > 0 { | ||
return | ||
} | ||
for _, v := range temp.Item { | ||
for i := 0; i < len(temp.Item); i++ { | ||
v := temp.Item[i] | ||
if temp.Type == "move" { | ||
lastPath := v.From[strings.LastIndex(v.From, "/")+1:] | ||
|
||
if !file.CheckNotExist(temp.To + "/" + lastPath) { | ||
continue | ||
if temp.Style == "skip" { | ||
temp.Item[i].Finished = true | ||
continue | ||
} else { | ||
os.Remove(temp.To + "/" + lastPath) | ||
} | ||
} | ||
|
||
err := os.Rename(v.From, temp.To+"/"+lastPath) | ||
if err != nil { | ||
loger.Debug("file move error", zap.Any("err", err)) | ||
continue | ||
} | ||
} else if temp.Type == "copy" { | ||
err := file.CopyDir(v.From, temp.To) | ||
err := file.CopyDir(v.From, temp.To, temp.Style) | ||
if err != nil { | ||
continue | ||
} | ||
} else { | ||
continue | ||
} | ||
} | ||
|
||
} | ||
temp.Finished = true | ||
FileQueue.Store(k, temp) | ||
} | ||
|
||
func ExecOpFile() { | ||
|
Oops, something went wrong.