Skip to content

Commit

Permalink
add missing js files in build, remove useless js
Browse files Browse the repository at this point in the history
  • Loading branch information
alcalyn committed Nov 25, 2022
1 parent 12cb46c commit c514e64
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 143 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/vue/dist/
/vue/dist/*.map
/vue/dist/*.umd.js
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Signup",
"description": "Let new users signup on your Matomo instance to track their own website.",
"version": "4.1.1",
"version": "4.1.2",
"license": "GPL-3.0+",
"homepage": "https://github.com/alcalyn/matomo-plugin-signup",
"theme": false,
Expand Down
8 changes: 8 additions & 0 deletions vue/dist/Signup.umd.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions vue/dist/umd.metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependsOn": [
"CoreHome"
]
}
151 changes: 10 additions & 141 deletions vue/src/CreateSite.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<div class="col s12 m6 input-field">
<input
type="text"
v-model="theSite.name"
v-model="site.name"
maxlength="90"
:placeholder="translate('General_Name')"
/>
Expand All @@ -33,7 +33,6 @@

<div class="editingSiteFooter">
<input
v-show="!isLoading"
type="submit"
class="btn btn-block btn-large"
:value="translate('General_Save')"
Expand All @@ -42,7 +41,7 @@
<p id="nav">
<a
href="#"
@click="cancelEditSite(site)"
@click="cancelEditSite()"
>{{ translate('General_Cancel', '', '') }}</a>
</p>
</div>
Expand All @@ -52,27 +51,16 @@
</template>

<script lang="ts">
import { DeepReadonly, defineComponent } from 'vue';
import { defineComponent } from 'vue';
import {
Site,
MatomoUrl,
translate,
AjaxHelper,
NotificationsStore,
} from 'CoreHome';
import {
Field,
Setting,
} from 'CorePluginsAdmin';
import CurrencyStore from '../../../SitesManager/vue/src/CurrencyStore/CurrencyStore';
import SiteTypesStore from '../../../SitesManager/vue/src/SiteTypesStore/SiteTypesStore';
import SiteType from '../../../SitesManager/vue/src/SiteTypesStore/SiteType';
interface SiteFieldsState {
isLoading: boolean;
theSite: Site;
settingValues: Record<string, unknown>;
showRemoveDialog: boolean;
site: Site;
}
interface CreateEditSiteResponse {
Expand All @@ -82,81 +70,19 @@ interface CreateEditSiteResponse {
export default defineComponent({
data(): SiteFieldsState {
return {
isLoading: false,
theSite: {} as Site,
settingValues: {},
showRemoveDialog: false,
site: {} as Site,
};
},
components: {
Field,
},
emits: ['delete', 'editSite', 'cancelEditSite', 'save'],
created() {
this.onSiteChanged();
},
watch: {
site() {
this.onSiteChanged();
},
},
methods: {
onSiteChanged() {
const site = this.site as Site;
this.theSite = { ...site };
this.editSite();
},
editSite() {
this.$emit('editSite', { idSite: this.theSite.idsite });
},
saveSite() {
const values: Record<string, unknown> = {
siteName: this.theSite.name,
currency: this.theSite.currency,
type: this.theSite.type,
settingValues: {} as Record<string, Setting[]>,
};
// process measurable settings
Object.entries(this.settingValues).forEach(([fullName, fieldValue]) => {
const [pluginName, name] = fullName.split('.');
const settingValues = values.settingValues as Record<string, Setting[]>;
if (!settingValues[pluginName]) {
settingValues[pluginName] = [];
}
let value = fieldValue;
if (fieldValue === false) {
value = '0';
} else if (fieldValue === true) {
value = '1';
} else if (Array.isArray(fieldValue)) {
value = fieldValue.filter((x) => !!x);
}
settingValues[pluginName].push({
name,
value,
});
});
AjaxHelper.post<CreateEditSiteResponse>(
{
method: 'Signup.signupSite',
},
values,
).then((response) => {
if (!this.theSite.idsite && response && response.value) {
this.theSite.idsite = `${response.value}`;
}
if (this.theSite.currency) {
this.theSite.currency_name = CurrencyStore.currencies.value[this.theSite.currency];
}
{
siteName: this.site.name,
},
).then(() => {
const notificationId = NotificationsStore.show({
message: translate('SitesManager_WebsiteCreated'),
context: 'success',
Expand All @@ -165,72 +91,15 @@ export default defineComponent({
});
NotificationsStore.scrollToNotification(notificationId);
SiteTypesStore.removeEditSiteIdParameterFromHash();
this.$emit('save', { site: this.theSite, settingValues: values.settingValues, isNew: true });
document.dispatchEvent(new Event('signup_site_created'));
});
},
cancelEditSite(site: Site) {
SiteTypesStore.removeEditSiteIdParameterFromHash();
this.$emit('cancelEditSite', { site, element: this.$refs.root as HTMLElement });
cancelEditSite() {
/* eslint-disable-next-line no-alert */
if (window.confirm(translate('Signup_CancelSiteConfirm'))) {
document.dispatchEvent(new Event('signup_site_created'));
}
},
},
computed: {
availableTypes() {
return SiteTypesStore.types.value;
},
setupUrl() {
const site = this.theSite as Site;
let suffix = '';
let connector = '';
if (this.isInternalSetupUrl) {
suffix = MatomoUrl.stringify({
idSite: site.idsite,
period: MatomoUrl.parsed.value.period,
date: MatomoUrl.parsed.value.date,
updated: 'false',
});
connector = this.howToSetupUrl!.indexOf('?') === -1 ? '?' : '&';
}
return `${this.howToSetupUrl}${connector}${suffix}`;
},
currencies() {
return CurrencyStore.currencies.value;
},
currentType(): DeepReadonly<SiteType> {
const site = this.site as Site;
const type = SiteTypesStore.typesById.value[site.type];
if (!type) {
return { name: site.type } as SiteType;
}
return type;
},
howToSetupUrl() {
const type = this.currentType;
if (!type) {
return undefined;
}
return type.howToSetupUrl;
},
isInternalSetupUrl() {
const { howToSetupUrl } = this;
if (!howToSetupUrl) {
return false;
}
return (`${howToSetupUrl}`).substring(0, 1) === '?';
},
},
});
</script>

0 comments on commit c514e64

Please sign in to comment.