Skip to content

Commit

Permalink
Add ticket header
Browse files Browse the repository at this point in the history
  • Loading branch information
cagataycivici committed Jan 1, 2025
1 parent ec0a5f4 commit 681af39
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 16 deletions.
12 changes: 10 additions & 2 deletions apps/showcase/components/layout/AppDesigner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ export default {
this.$toast.add({ severity: 'error', summary: 'Not Available', detail: 'A license is required to download', life: 3000 });
} else {
try {
const response = await $fetch(this.designerApiBase + '/theme/download/' + this.$appState.designer.licenseKey + '/' + theme.t_key, {
responseType: 'blob'
const response = await $fetch(this.designerApiBase + '/theme/download/' + theme.t_key, {
responseType: 'blob',
headers: {
Authorization: `Bearer ${this.$appState.designer.ticket}`,
'X-License-Key': this.$appState.designer.licenseKey
}
});
if (response.error) {
Expand All @@ -96,6 +100,10 @@ export default {
async saveTheme(theme) {
const { error } = await $fetch(this.designerApiBase + '/theme/update', {
method: 'POST',
headers: {
Authorization: `Bearer ${this.$appState.designer.ticket}`,
'X-License-Key': this.$appState.designer.licenseKey
},
body: {
key: theme.key,
preset: theme.preset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,13 @@ export default {
if (this.$appState.designer.licenseKey) {
const { data, error } = await $fetch(this.designerApiBase + '/theme/create', {
method: 'POST',
headers: {
Authorization: `Bearer ${this.$appState.designer.ticket}`,
'X-License-Key': this.$appState.designer.licenseKey
},
body: {
name: this.themeName,
preset: newPreset,
license_key: this.$appState.designer.licenseKey,
config: {
font_size: '14px',
font_family: 'Inter var'
Expand All @@ -125,10 +128,13 @@ export default {
if (this.$appState.designer.licenseKey) {
const { data, error } = await $fetch(this.designerApiBase + '/theme/figma', {
method: 'POST',
headers: {
Authorization: `Bearer ${this.$appState.designer.ticket}`,
'X-License-Key': this.$appState.designer.licenseKey
},
body: {
name: this.themeName,
figma_tokens: this.figmaData,
license_key: this.$appState.designer.licenseKey,
config: {
font_size: '14px',
font_family: 'Inter var'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,15 @@ export default {
} else {
if (data.valid) {
this.$appState.designer.licenseKey = this.licenseKey;
this.$appState.designer.ticket = data.ticket;
this.loadThemes();
localStorage.setItem(this.$appState.designer.localStoreKey, this.licenseKey);
if (!silent) {
this.$toast.add({ severity: 'success', summary: 'Success', detail: 'License is activated.', life: 3000 });
}
this.loadThemes();
localStorage.setItem(this.$appState.designer.localStoreKey, this.$appState.designer.licenseKey);
} else {
this.$toast.add({ severity: 'warn', summary: 'Unable to Activate', detail: 'Invalid key', life: 3000 });
this.$appState.designer.themes = [];
Expand All @@ -152,7 +154,12 @@ export default {
},
async loadThemes() {
this.loading = true;
const { data, error } = await $fetch(this.designerApiBase + '/theme/list/' + this.$appState.designer.licenseKey);
const { data, error } = await $fetch(this.designerApiBase + '/theme/list/', {
headers: {
Authorization: `Bearer ${this.$appState.designer.ticket}`,
'X-License-Key': this.$appState.designer.licenseKey
}
});
if (error) {
this.$toast.add({ severity: 'error', summary: 'An Error Occurred', detail: error.message, life: 3000 });
Expand All @@ -163,7 +170,12 @@ export default {
this.loading = false;
},
async loadTheme(theme) {
const { data, error } = await $fetch(this.designerApiBase + '/theme/load/' + this.$appState.designer.licenseKey + '/' + theme.t_key);
const { data, error } = await $fetch(this.designerApiBase + '/theme/load/' + theme.t_key, {
headers: {
Authorization: `Bearer ${this.$appState.designer.ticket}`,
'X-License-Key': this.$appState.designer.licenseKey
}
});
if (error) {
this.$toast.add({ severity: 'error', summary: 'An Error Occurred', detail: error.message, life: 3000 });
Expand All @@ -185,9 +197,12 @@ export default {
async renameTheme(theme) {
const { error } = await $fetch(this.designerApiBase + '/theme/rename/' + theme.t_key, {
method: 'PATCH',
headers: {
Authorization: `Bearer ${this.$appState.designer.ticket}`,
'X-License-Key': this.$appState.designer.licenseKey
},
body: {
name: theme.t_name,
license_key: this.$appState.designer.licenseKey
name: theme.t_name
}
});
Expand All @@ -198,8 +213,9 @@ export default {
async deleteTheme(theme) {
const { error } = await $fetch(this.designerApiBase + '/theme/delete/' + theme.t_key, {
method: 'DELETE',
body: {
license_key: this.$appState.designer.licenseKey
headers: {
Authorization: `Bearer ${this.$appState.designer.ticket}`,
'X-License-Key': this.$appState.designer.licenseKey
}
});
Expand All @@ -212,8 +228,9 @@ export default {
async duplicateTheme(theme) {
const { error } = await $fetch(this.designerApiBase + '/theme/duplicate/' + theme.t_key, {
method: 'POST',
body: {
license_key: this.$appState.designer.licenseKey
headers: {
Authorization: `Bearer ${this.$appState.designer.ticket}`,
'X-License-Key': this.$appState.designer.licenseKey
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ export default {
async preview() {
const { data, error } = await $fetch(this.designerApiBase + '/theme/migrate/preview/' + this.$appState.designer.theme.key, {
method: 'PATCH',
headers: {
Authorization: `Bearer ${this.$appState.designer.ticket}`,
'X-License-Key': this.$appState.designer.licenseKey
},
body: {
license_key: this.$appState.designer.licenseKey
}
Expand Down Expand Up @@ -124,6 +128,10 @@ export default {
async migrate() {
const { error } = await $fetch(this.designerApiBase + '/theme/migrate/execute/' + this.$appState.designer.theme.key, {
method: 'PATCH',
headers: {
Authorization: `Bearer ${this.$appState.designer.ticket}`,
'X-License-Key': this.$appState.designer.licenseKey
},
body: {
license_key: this.$appState.designer.licenseKey
}
Expand Down
3 changes: 2 additions & 1 deletion apps/showcase/plugins/app-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ const $appState = {
announcement: null,
storageKey: 'primevue',
designer: {
localStoreKey: 'primevue-designer-licensekey',
localStoreKey: 'primevue-designer',
licenseKey: null,
ticket: null,
active: false,
activeView: 'dashboard',
activeTab: '0',
Expand Down

0 comments on commit 681af39

Please sign in to comment.