Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -10,7 +10,6 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"math"
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -627,9 +626,8 @@ func drawOrderHeader(pdf *gofpdf.Fpdf, h *OrderHeader, showDesc bool) float64 {
|
|||||||
/* ----------------------------------------------------
|
/* ----------------------------------------------------
|
||||||
1) LOGO
|
1) LOGO
|
||||||
---------------------------------------------------- */
|
---------------------------------------------------- */
|
||||||
logo := "./public/Baggi-Tekstil-A.s-Logolu.jpeg"
|
if logoPath, err := resolvePdfImagePath("Baggi-Tekstil-A.s-Logolu.jpeg"); err == nil {
|
||||||
if _, err := os.Stat(logo); err == nil {
|
pdf.ImageOptions(logoPath, marginL, y, 32, 0, false, gofpdf.ImageOptions{}, 0, "")
|
||||||
pdf.ImageOptions(logo, marginL, y, 32, 0, false, gofpdf.ImageOptions{}, 0, "")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------
|
/* ----------------------------------------------------
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path/filepath"
|
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -137,10 +136,9 @@ func hCalcRowHeightForText(pdf *gofpdf.Fpdf, text string, colWidth, lineHeight,
|
|||||||
/* ============================ HEADER ============================ */
|
/* ============================ HEADER ============================ */
|
||||||
|
|
||||||
func hDrawPageHeader(pdf *gofpdf.Fpdf, cariKod, cariIsim, start, end string) float64 {
|
func hDrawPageHeader(pdf *gofpdf.Fpdf, cariKod, cariIsim, start, end string) float64 {
|
||||||
logoPath, _ := filepath.Abs("./public/Baggi-Tekstil-A.s-Logolu.jpeg")
|
if logoPath, err := resolvePdfImagePath("Baggi-Tekstil-A.s-Logolu.jpeg"); err == nil {
|
||||||
|
pdf.ImageOptions(logoPath, hMarginL, 2, hLogoW, 0, false, gofpdf.ImageOptions{}, 0, "")
|
||||||
// Logo
|
}
|
||||||
pdf.ImageOptions(logoPath, hMarginL, 2, hLogoW, 0, false, gofpdf.ImageOptions{}, 0, "")
|
|
||||||
|
|
||||||
// Başlıklar
|
// Başlıklar
|
||||||
pdf.SetFont(hFontFamilyBold, "", 16)
|
pdf.SetFont(hFontFamilyBold, "", 16)
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path/filepath"
|
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -225,10 +224,9 @@ func drawLabeledBox(pdf *gofpdf.Fpdf, x, y, w, h float64, label, value string, a
|
|||||||
}
|
}
|
||||||
|
|
||||||
func drawPageHeader(pdf *gofpdf.Fpdf, cariKod, cariIsim, start, end string) float64 {
|
func drawPageHeader(pdf *gofpdf.Fpdf, cariKod, cariIsim, start, end string) float64 {
|
||||||
logoPath, _ := filepath.Abs("./public/Baggi-Tekstil-A.s-Logolu.jpeg")
|
if logoPath, err := resolvePdfImagePath("Baggi-Tekstil-A.s-Logolu.jpeg"); err == nil {
|
||||||
|
pdf.ImageOptions(logoPath, hMarginL, 2, hLogoW, 0, false, gofpdf.ImageOptions{}, 0, "")
|
||||||
// Logo
|
}
|
||||||
pdf.ImageOptions(logoPath, hMarginL, 2, hLogoW, 0, false, gofpdf.ImageOptions{}, 0, "")
|
|
||||||
|
|
||||||
// Başlıklar
|
// Başlıklar
|
||||||
pdf.SetFont(hFontFamilyBold, "", 16)
|
pdf.SetFont(hFontFamilyBold, "", 16)
|
||||||
|
|||||||
@@ -61,8 +61,66 @@ export const put = (u, b = {}, c = {}) =>
|
|||||||
export const del = (u, p = {}, c = {}) =>
|
export const del = (u, p = {}, c = {}) =>
|
||||||
api.delete(u, { params: p, ...c }).then(r => r.data)
|
api.delete(u, { params: p, ...c }).then(r => r.data)
|
||||||
|
|
||||||
export const download = (u, p = {}, c = {}) =>
|
async function parseBlobErrorMessage(data) {
|
||||||
api.get(u, { params: p, responseType: 'blob', ...c })
|
if (!data) return ''
|
||||||
.then(r => r.data)
|
|
||||||
|
if (typeof Blob !== 'undefined' && data instanceof Blob) {
|
||||||
|
try {
|
||||||
|
const text = (await data.text())?.trim()
|
||||||
|
if (!text) return ''
|
||||||
|
|
||||||
|
try {
|
||||||
|
const json = JSON.parse(text)
|
||||||
|
return (
|
||||||
|
json?.detail ||
|
||||||
|
json?.message ||
|
||||||
|
json?.error ||
|
||||||
|
text
|
||||||
|
)
|
||||||
|
} catch {
|
||||||
|
return text
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof data === 'string') return data.trim()
|
||||||
|
if (typeof data === 'object') {
|
||||||
|
return (
|
||||||
|
data?.detail ||
|
||||||
|
data?.message ||
|
||||||
|
data?.error ||
|
||||||
|
''
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
export const download = async (u, p = {}, c = {}) => {
|
||||||
|
try {
|
||||||
|
const r = await api.get(u, { params: p, responseType: 'blob', ...c })
|
||||||
|
return r.data
|
||||||
|
} catch (err) {
|
||||||
|
let detail =
|
||||||
|
err?.response?.data?.detail ||
|
||||||
|
err?.response?.data?.message ||
|
||||||
|
''
|
||||||
|
|
||||||
|
if (!detail) {
|
||||||
|
detail = await parseBlobErrorMessage(err?.response?.data)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!detail) {
|
||||||
|
detail = err?.message || 'Download failed'
|
||||||
|
}
|
||||||
|
|
||||||
|
const wrapped = new Error(detail)
|
||||||
|
wrapped.status = err?.response?.status
|
||||||
|
wrapped.original = err
|
||||||
|
throw wrapped
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default api
|
export default api
|
||||||
|
|||||||
Reference in New Issue
Block a user