Compare commits
5 Commits
silvermobi
...
soukaina
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ecefbc8e1 | ||
| b77403c674 | |||
| f7cb9f1116 | |||
| 2aec61e520 | |||
| 73586aa61a |
81
.gitea/workflows/build.yml
Normal file
81
.gitea/workflows/build.yml
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
name: Build and Push Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- dev
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_and_push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Install Docker
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y docker.io
|
||||||
|
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set Kubernetes Context
|
||||||
|
uses: azure/k8s-set-context@v4
|
||||||
|
with:
|
||||||
|
method: kubeconfig
|
||||||
|
kubeconfig: ${{secrets.buildx_kubeconfig}}
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
driver: kubernetes
|
||||||
|
driver-opts: |
|
||||||
|
namespace=gitea
|
||||||
|
|
||||||
|
- name: Login to Docker Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: git.coopgo.io
|
||||||
|
username: ${{ secrets.REGISTRY_USER }}
|
||||||
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract metadata (tags, labels) for Docker image
|
||||||
|
id: metadata
|
||||||
|
uses: docker/metadata-action@v3
|
||||||
|
with:
|
||||||
|
images: git.coopgo.io/${{gitea.repository}}
|
||||||
|
tags: |
|
||||||
|
type=ref,event=branch
|
||||||
|
type=ref,event=tag
|
||||||
|
type=ref,event=pr
|
||||||
|
flavor: |
|
||||||
|
latest=auto
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
${{ steps.metadata.outputs.tags }}
|
||||||
|
build-args: |
|
||||||
|
ACCESS_TOKEN_USR=${{gitea.actor}}
|
||||||
|
ACCESS_TOKEN_PWD=${{gitea.token}}
|
||||||
|
|
||||||
|
# BUILD WITH KANIKO
|
||||||
|
# - name: Kaniko build and push
|
||||||
|
# uses: aevea/action-kaniko@master
|
||||||
|
# with:
|
||||||
|
# build_file: Dockerfile
|
||||||
|
# registry: git.coopgo.io
|
||||||
|
# username: ${{secrets.registry_user}}
|
||||||
|
# password: ${{secrets.registry_token}}
|
||||||
|
# image: ${{gitea.repository}}
|
||||||
|
# tag: ${{gitea.ref_name}}
|
||||||
|
# cache: true
|
||||||
|
# cache_registry: git.coopgo.io/${{gitea.repository}}/cache
|
||||||
|
# extra-args: |
|
||||||
|
# ACCESS_TOKEN_USR=${{gitea.actor}}
|
||||||
|
# ACCESS_TOKEN_PWD=${{gitea.token}}
|
||||||
@@ -255,7 +255,7 @@ func (h *ApplicationHandler) AgendaSubscribeEvent(w http.ResponseWriter, r *http
|
|||||||
}
|
}
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
eventid := vars["eventid"]
|
eventid := vars["eventid"]
|
||||||
|
fmt.Println(eventid)
|
||||||
if err := r.ParseForm(); err != nil {
|
if err := r.ParseForm(); err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
|||||||
@@ -205,6 +205,7 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
|
|||||||
|
|
||||||
subcriptionresp, err := h.services.GRPC.Agenda.GetSubscriptionByUser(context.TODO(), subscriptionrequest)
|
subcriptionresp, err := h.services.GRPC.Agenda.GetSubscriptionByUser(context.TODO(), subscriptionrequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("icii")
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
@@ -212,13 +213,15 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
|
|||||||
|
|
||||||
events := []agendastorage.Event{}
|
events := []agendastorage.Event{}
|
||||||
currentTime := time.Now().Truncate(24 * time.Hour)
|
currentTime := time.Now().Truncate(24 * time.Hour)
|
||||||
|
fmt.Println(subcriptionresp)
|
||||||
for _, e := range subcriptionresp.Subscription {
|
for _, e := range subcriptionresp.Subscription {
|
||||||
eventresquest := &agenda.GetEventRequest{
|
eventresquest := &agenda.GetEventRequest{
|
||||||
Id: e.Eventid,
|
Id: e.Eventid,
|
||||||
}
|
}
|
||||||
|
fmt.Println(eventresquest)
|
||||||
eventresp, err := h.services.GRPC.Agenda.GetEvent(context.TODO(), eventresquest)
|
eventresp, err := h.services.GRPC.Agenda.GetEvent(context.TODO(), eventresquest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("iciiiiii")
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
@@ -269,6 +272,7 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
|
|||||||
}
|
}
|
||||||
|
|
||||||
events_list = append(events_list, event)
|
events_list = append(events_list, event)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var status_booking int
|
var status_booking int
|
||||||
@@ -306,6 +310,7 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
|
|||||||
}
|
}
|
||||||
|
|
||||||
events_list = append(events_list, event)
|
events_list = append(events_list, event)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sortByDate(events_list)
|
sortByDate(events_list)
|
||||||
|
|||||||
@@ -302,12 +302,15 @@ func (h ApplicationHandler) VehicleManagementBookingDisplay(w http.ResponseWrite
|
|||||||
}
|
}
|
||||||
|
|
||||||
alternativerequest := &fleets.GetVehiclesRequest{
|
alternativerequest := &fleets.GetVehiclesRequest{
|
||||||
Namespaces: []string{"parcoursmob"},
|
Namespaces: []string{"parcoursmob"},
|
||||||
Types: []string{booking.Vehicle.Type},
|
Types: []string{booking.Vehicle.Type},
|
||||||
Administrators: booking.Vehicle.Administrators,
|
Administrators: booking.Vehicle.Administrators,
|
||||||
AvailabilityFrom: timestamppb.New(booking.Startdate),
|
//AvailabilityFrom: timestamppb.New(booking.Startdate),
|
||||||
AvailabilityTo: timestamppb.New(booking.Enddate.Add(24 * time.Hour)),
|
//AvailabilityTo: timestamppb.New(booking.Startdate.Add(After(time.Now()))),
|
||||||
}
|
}
|
||||||
|
// if alternativerequest.AvailabilityFrom.After(time.Now()) {
|
||||||
|
// fmt.Println("loooool")
|
||||||
|
// }
|
||||||
|
|
||||||
alternativeresp, err := h.services.GRPC.Fleets.GetVehicles(context.TODO(), alternativerequest)
|
alternativeresp, err := h.services.GRPC.Fleets.GetVehicles(context.TODO(), alternativerequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -319,11 +322,48 @@ func (h ApplicationHandler) VehicleManagementBookingDisplay(w http.ResponseWrite
|
|||||||
for _, a := range alternativeresp.Vehicles {
|
for _, a := range alternativeresp.Vehicles {
|
||||||
alternatives = append(alternatives, a.ToStorageType())
|
alternatives = append(alternatives, a.ToStorageType())
|
||||||
}
|
}
|
||||||
|
/***************************************add list of vehicules ******************************************/
|
||||||
|
requesst := &fleets.GetVehiclesRequest{
|
||||||
|
Namespaces: []string{"parcoursmob"},
|
||||||
|
}
|
||||||
|
ressp, err := h.services.GRPC.Fleets.GetVehicles(context.TODO(), requesst)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
|
||||||
|
vehicles := []fleetsstorage.Vehicle{}
|
||||||
|
bookings := []fleetsstorage.Booking{}
|
||||||
|
vehicles_map := map[string]fleetsstorage.Vehicle{}
|
||||||
|
|
||||||
|
for _, vehicle := range ressp.Vehicles {
|
||||||
|
if filterVehicle(r, vehicle) {
|
||||||
|
v := vehicle.ToStorageType()
|
||||||
|
vehicleBookings := []fleetsstorage.Booking{}
|
||||||
|
for _, b := range v.Bookings {
|
||||||
|
if b.Status() != fleetsstorage.StatusOld {
|
||||||
|
if deleted, ok := b.Data["Deleted"].(bool); !ok && !deleted {
|
||||||
|
bookings = append(bookings, b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if b.Unavailableto.After(time.Now()) {
|
||||||
|
vehicleBookings = append(vehicleBookings, b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
v.Bookings = vehicleBookings
|
||||||
|
vehicles = append(vehicles, v)
|
||||||
|
vehicles_map[v.ID] = v
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//sort.Sort(sorting.VehiclesByLicencePlate(vehicles))
|
||||||
|
//sort.Sort(sorting.BookingsByStartdate(bookings))
|
||||||
|
/*********************************************************************************/
|
||||||
documents := h.filestorage.List(filestorage.PREFIX_BOOKINGS + "/" + bookingid)
|
documents := h.filestorage.List(filestorage.PREFIX_BOOKINGS + "/" + bookingid)
|
||||||
file_types_map := h.config.GetStringMapString("storage.files.file_types")
|
file_types_map := h.config.GetStringMapString("storage.files.file_types")
|
||||||
|
|
||||||
h.Renderer.VehicleManagementBookingDisplay(w, r, booking, booking.Vehicle, beneficiary, groupresp.Group.ToStorageType(), documents, file_types_map, alternatives)
|
h.Renderer.VehicleManagementBookingDisplay(w, r, booking, booking.Vehicle, beneficiary, groupresp.Group.ToStorageType(), documents, file_types_map, alternatives, vehicles, vehicles_map, bookings)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h ApplicationHandler) VehicleManagementBookingChangeVehicle(w http.ResponseWriter, r *http.Request) {
|
func (h ApplicationHandler) VehicleManagementBookingChangeVehicle(w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -553,8 +593,17 @@ func (h *ApplicationHandler) UnbookingVehicle(w http.ResponseWriter, r *http.Req
|
|||||||
Data: datapb,
|
Data: datapb,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
requestt := &fleets.DeleteBookingRequest{
|
||||||
|
Id: bookingid,
|
||||||
|
}
|
||||||
|
_, errr := h.services.GRPC.Fleets.UpdateBooking(context.TODO(), request)
|
||||||
|
|
||||||
_, err := h.services.GRPC.Fleets.UpdateBooking(context.TODO(), request)
|
if errr != nil {
|
||||||
|
fmt.Println(errr)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, err := h.services.GRPC.Fleets.DeleteBooking(context.TODO(), requestt)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ func (h *AuthHandler) Onboarding(w http.ResponseWriter, r *http.Request) {
|
|||||||
display_name := fmt.Sprint(r.FormValue("first_name")) + " " + fmt.Sprint(r.FormValue("last_name"))
|
display_name := fmt.Sprint(r.FormValue("first_name")) + " " + fmt.Sprint(r.FormValue("last_name"))
|
||||||
account := &ma.Account{
|
account := &ma.Account{
|
||||||
Authentication: ma.AccountAuth{
|
Authentication: ma.AccountAuth{
|
||||||
Local: ma.LocalAuth{
|
Local: &ma.LocalAuth{
|
||||||
Username: onboardingmap["username"].(string),
|
Username: onboardingmap["username"].(*string),
|
||||||
Password: r.FormValue("password"),
|
Password: r.FormValue("password"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ func (renderer *Renderer) VehiclesFleetUpdate(w http.ResponseWriter, r *http.Req
|
|||||||
renderer.Render("fleet display vehicle", w, r, files, state)
|
renderer.Render("fleet display vehicle", w, r, files, state)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (renderer *Renderer) VehicleManagementBookingDisplay(w http.ResponseWriter, r *http.Request, booking any, vehicle any, beneficiary any, group any, documents []filestorage.FileInfo, file_types_map map[string]string, alternative_vehicles []any) {
|
func (renderer *Renderer) VehicleManagementBookingDisplay(w http.ResponseWriter, r *http.Request, booking any, vehicle any, beneficiary any, group any, documents []filestorage.FileInfo, file_types_map map[string]string, alternative_vehicles []any, vehicles []fleetsstorage.Vehicle, vehicles_map map[string]fleetsstorage.Vehicle, bookings []fleetsstorage.Booking) {
|
||||||
files := renderer.ThemeConfig.GetStringSlice("views.vehicles_management.booking_display.files")
|
files := renderer.ThemeConfig.GetStringSlice("views.vehicles_management.booking_display.files")
|
||||||
state := NewState(r, renderer.ThemeConfig, vehiclesmanagementMenu)
|
state := NewState(r, renderer.ThemeConfig, vehiclesmanagementMenu)
|
||||||
state.ViewState = map[string]any{
|
state.ViewState = map[string]any{
|
||||||
@@ -75,6 +75,9 @@ func (renderer *Renderer) VehicleManagementBookingDisplay(w http.ResponseWriter,
|
|||||||
"documents": documents,
|
"documents": documents,
|
||||||
"file_types_map": file_types_map,
|
"file_types_map": file_types_map,
|
||||||
"alternative_vehicles": alternative_vehicles,
|
"alternative_vehicles": alternative_vehicles,
|
||||||
|
"vehicles": vehicles,
|
||||||
|
"bookings": bookings,
|
||||||
|
"vehicles_map": vehicles_map,
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.Render("vehicles search", w, r, files, state)
|
renderer.Render("vehicles search", w, r, files, state)
|
||||||
@@ -84,7 +87,7 @@ func (renderer *Renderer) UnbookingVehicle(w http.ResponseWriter, r *http.Reques
|
|||||||
files := renderer.ThemeConfig.GetStringSlice("views.vehicles_management.delete_booking.files")
|
files := renderer.ThemeConfig.GetStringSlice("views.vehicles_management.delete_booking.files")
|
||||||
state := NewState(r, renderer.ThemeConfig, vehiclesmanagementMenu)
|
state := NewState(r, renderer.ThemeConfig, vehiclesmanagementMenu)
|
||||||
state.ViewState = map[string]any{
|
state.ViewState = map[string]any{
|
||||||
"booking": booking,
|
"booking": booking,
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.Render("vehicule unbooking", w, r, files, state)
|
renderer.Render("vehicule unbooking", w, r, files, state)
|
||||||
|
|||||||
Reference in New Issue
Block a user