feat: sync vehicle monitoring and accumulated platform updates
Add monitoring metrics, numeric sorting, report-time display, vehicle number labels, and map layout fixes. Include accumulated mileage, hydrogen, OneOS authentication, open platform, ingestion, deployment, and UI updates. Exclude temporary files, generated reports, and credentials. Validate frontend 632 tests and production build, API packages, vehicle-map tests, and release installer tests. Gateway suite has one pre-existing date-sensitive identity throttling test failure reproduced on the parent commit.
This commit is contained in:
@@ -13,25 +13,31 @@ type VehicleGrant struct {
|
||||
}
|
||||
|
||||
type Principal struct {
|
||||
SubjectID string `json:"subjectId,omitempty"`
|
||||
SessionID string `json:"-"`
|
||||
Name string `json:"name"`
|
||||
Username string `json:"username,omitempty"`
|
||||
Role string `json:"role"`
|
||||
UserType string `json:"userType"`
|
||||
CustomerRef string `json:"customerRef,omitempty"`
|
||||
TenantRef string `json:"tenantRef,omitempty"`
|
||||
AuthProvider string `json:"authProvider"`
|
||||
MenuKeys []string `json:"menuKeys"`
|
||||
VehicleVINs []string `json:"-"`
|
||||
VehicleGrants []VehicleGrant `json:"-"`
|
||||
VehicleCount int `json:"vehicleCount"`
|
||||
BusinessScopeLevel string `json:"businessScopeLevel,omitempty"`
|
||||
DepartmentIDs []string `json:"departmentIds,omitempty"`
|
||||
ResponsibleUserID string `json:"responsibleUserId,omitempty"`
|
||||
VehicleScopeSource string `json:"vehicleScopeSource,omitempty"`
|
||||
ReadOnly bool `json:"readOnly,omitempty"`
|
||||
DataSource string `json:"dataSource,omitempty"`
|
||||
AuthorizationStatus string `json:"authorizationStatus,omitempty"`
|
||||
PermissionKeys []string `json:"-"`
|
||||
SubjectID string `json:"subjectId,omitempty"`
|
||||
SessionID string `json:"-"`
|
||||
Name string `json:"name"`
|
||||
Username string `json:"username,omitempty"`
|
||||
Role string `json:"role"`
|
||||
UserType string `json:"userType"`
|
||||
CustomerRef string `json:"customerRef,omitempty"`
|
||||
TenantRef string `json:"tenantRef,omitempty"`
|
||||
AuthProvider string `json:"authProvider"`
|
||||
MenuKeys []string `json:"menuKeys"`
|
||||
VehicleVINs []string `json:"-"`
|
||||
VehicleGrants []VehicleGrant `json:"-"`
|
||||
VehicleCount int `json:"vehicleCount"`
|
||||
BusinessScopeLevel string `json:"businessScopeLevel,omitempty"`
|
||||
DepartmentIDs []string `json:"departmentIds,omitempty"`
|
||||
ResponsibleUserID string `json:"responsibleUserId,omitempty"`
|
||||
}
|
||||
|
||||
func (p Principal) Clone() Principal {
|
||||
p.PermissionKeys = append([]string(nil), p.PermissionKeys...)
|
||||
p.MenuKeys = append([]string(nil), p.MenuKeys...)
|
||||
p.VehicleVINs = append([]string(nil), p.VehicleVINs...)
|
||||
p.VehicleGrants = append([]VehicleGrant(nil), p.VehicleGrants...)
|
||||
@@ -41,6 +47,9 @@ func (p Principal) Clone() Principal {
|
||||
}
|
||||
|
||||
func (p Principal) CanMenu(key string) bool {
|
||||
if p.AuthorizationStatus == "loading" {
|
||||
return false
|
||||
}
|
||||
for _, value := range p.MenuKeys {
|
||||
if value == key {
|
||||
return true
|
||||
@@ -55,12 +64,31 @@ func (p Principal) CanMenu(key string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (p Principal) HasVehicleScope() bool {
|
||||
return p.UserType == "customer" || p.VehicleScopeSource == "oneos-vehicle-query"
|
||||
}
|
||||
|
||||
// Vehicle-query authorization grants history for currently visible VINs. It
|
||||
// carries no assignment dates; existing local/contract time grants stay intact.
|
||||
func (p Principal) HasHistoryTimeScope() bool {
|
||||
return p.HasVehicleScope() && p.VehicleScopeSource != "oneos-vehicle-query"
|
||||
}
|
||||
|
||||
func (p Principal) CanVIN(vin string) bool {
|
||||
if p.UserType != "customer" {
|
||||
if p.AuthorizationStatus == "loading" {
|
||||
return false
|
||||
}
|
||||
if !p.HasVehicleScope() {
|
||||
return true
|
||||
}
|
||||
for _, allowed := range p.VehicleVINs {
|
||||
if allowed == vin {
|
||||
if p.AuthProvider == "oneos" {
|
||||
if grant, ok := p.VehicleGrant(vin); ok && !grant.ValidFrom.IsZero() {
|
||||
now := time.Now()
|
||||
return !grant.ValidFrom.After(now) && (grant.ValidTo == nil || grant.ValidTo.After(now))
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user