2020-10-20 17:10:23 +00:00
|
|
|
package admin
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/caos/logging"
|
2021-02-23 14:13:04 +00:00
|
|
|
"github.com/caos/zitadel/internal/domain"
|
2020-10-20 17:10:23 +00:00
|
|
|
iam_model "github.com/caos/zitadel/internal/iam/model"
|
|
|
|
"github.com/caos/zitadel/pkg/grpc/admin"
|
|
|
|
"github.com/golang/protobuf/ptypes"
|
2021-01-20 10:06:52 +00:00
|
|
|
"google.golang.org/protobuf/types/known/timestamppb"
|
2020-10-20 17:10:23 +00:00
|
|
|
)
|
|
|
|
|
2021-01-05 08:33:45 +00:00
|
|
|
func labelPolicyToDomain(policy *admin.DefaultLabelPolicyUpdate) *domain.LabelPolicy {
|
|
|
|
return &domain.LabelPolicy{
|
2020-10-20 17:10:23 +00:00
|
|
|
PrimaryColor: policy.PrimaryColor,
|
|
|
|
SecondaryColor: policy.SecondaryColor,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-05 08:33:45 +00:00
|
|
|
func labelPolicyFromDomain(policy *domain.LabelPolicy) *admin.DefaultLabelPolicy {
|
2020-10-20 17:10:23 +00:00
|
|
|
return &admin.DefaultLabelPolicy{
|
|
|
|
PrimaryColor: policy.PrimaryColor,
|
|
|
|
SecondaryColor: policy.SecondaryColor,
|
2021-01-20 10:06:52 +00:00
|
|
|
ChangeDate: timestamppb.New(policy.ChangeDate),
|
2020-10-20 17:10:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func labelPolicyViewFromModel(policy *iam_model.LabelPolicyView) *admin.DefaultLabelPolicyView {
|
|
|
|
creationDate, err := ptypes.TimestampProto(policy.CreationDate)
|
|
|
|
logging.Log("ADMIN-zMnlF").OnError(err).Debug("date parse failed")
|
|
|
|
|
|
|
|
changeDate, err := ptypes.TimestampProto(policy.ChangeDate)
|
|
|
|
logging.Log("ADMIN-Vhvfp").OnError(err).Debug("date parse failed")
|
|
|
|
|
|
|
|
return &admin.DefaultLabelPolicyView{
|
|
|
|
PrimaryColor: policy.PrimaryColor,
|
|
|
|
SecondaryColor: policy.SecondaryColor,
|
|
|
|
CreationDate: creationDate,
|
|
|
|
ChangeDate: changeDate,
|
|
|
|
}
|
|
|
|
}
|