Initial commit
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
const defaultParams = {
|
||||
exclude_shared: false,
|
||||
per_page: 12,
|
||||
shared: 'no',
|
||||
locked: false,
|
||||
only_liked: false,
|
||||
deepInsights: false
|
||||
};
|
||||
|
||||
const mine = {
|
||||
...defaultParams
|
||||
};
|
||||
|
||||
const locked = {
|
||||
...defaultParams,
|
||||
locked: true
|
||||
};
|
||||
|
||||
const shared = {
|
||||
...defaultParams,
|
||||
shared: 'only'
|
||||
};
|
||||
|
||||
const favorited = {
|
||||
...defaultParams,
|
||||
only_liked: true
|
||||
};
|
||||
|
||||
const publicPrivacy = {
|
||||
...defaultParams,
|
||||
privacy: 'public'
|
||||
};
|
||||
|
||||
const linkPrivacy = {
|
||||
...defaultParams,
|
||||
privacy: 'link'
|
||||
};
|
||||
|
||||
const passwordPrivacy = {
|
||||
...defaultParams,
|
||||
privacy: 'password'
|
||||
};
|
||||
|
||||
const privatePrivacy = {
|
||||
...defaultParams,
|
||||
privacy: 'private'
|
||||
};
|
||||
|
||||
const filters = {
|
||||
mine,
|
||||
locked,
|
||||
shared,
|
||||
favorited,
|
||||
public: publicPrivacy,
|
||||
link: linkPrivacy,
|
||||
password: passwordPrivacy,
|
||||
private: privatePrivacy
|
||||
};
|
||||
|
||||
const allowedFilters = Object.keys(filters);
|
||||
|
||||
export default filters;
|
||||
|
||||
export { defaultParams };
|
||||
|
||||
export function isAllowed (filter) {
|
||||
return allowedFilters.includes(filter);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export const accountsWithLimits = ['Individual', 'Annual Individual'];
|
||||
@@ -0,0 +1,5 @@
|
||||
export const apiKeysTypes = {
|
||||
MASTER: 'master',
|
||||
DEFAULT: 'default',
|
||||
REGULAR: 'regular'
|
||||
};
|
||||
@@ -0,0 +1,226 @@
|
||||
// Dialogs
|
||||
import Dialog from 'new-dashboard/components/Backbone/Dialog.vue';
|
||||
import CreateDialog from 'new-dashboard/components/Backbone/Dialogs/CreateDialog';
|
||||
import ChangePrivacy from 'new-dashboard/components/Backbone/Dialogs/ChangePrivacy';
|
||||
import DeleteDialog from 'new-dashboard/components/Backbone/Dialogs/DeleteDialog';
|
||||
import DuplicateMap from 'new-dashboard/components/Backbone/Dialogs/DuplicateMap';
|
||||
import LockVisualization from 'new-dashboard/components/Backbone/Dialogs/LockVisualization';
|
||||
import MapMetadata from 'new-dashboard/components/Backbone/Dialogs/MapMetadata';
|
||||
import DatasetMetadata from 'new-dashboard/components/Backbone/Dialogs/DatasetMetadata';
|
||||
import Share from 'new-dashboard/components/Backbone/Dialogs/Share';
|
||||
|
||||
export function editMapMetadata (visualization, actionHandlers) {
|
||||
this.showModal(
|
||||
{
|
||||
template: `
|
||||
<Dialog v-on:close="$emit('close')">
|
||||
<MapMetadata
|
||||
:visualization="visualization"
|
||||
@close="$emit('close')"
|
||||
v-on="getEventListeners()" />
|
||||
</Dialog>`,
|
||||
props: ['visualization'],
|
||||
components: { Dialog, MapMetadata },
|
||||
methods: {
|
||||
getEventListeners: function () {
|
||||
return actionHandlers || {};
|
||||
}
|
||||
}
|
||||
},
|
||||
{ visualization }
|
||||
);
|
||||
}
|
||||
|
||||
export function editDatasetMetadata (dataset, actionHandlers) {
|
||||
this.showModal(
|
||||
{
|
||||
template: `
|
||||
<Dialog v-on:close="$emit('close')">
|
||||
<DatasetMetadata
|
||||
:dataset="dataset"
|
||||
@close="$emit('close')"
|
||||
v-on="getEventListeners()" />
|
||||
</Dialog>`,
|
||||
props: ['dataset'],
|
||||
components: { Dialog, DatasetMetadata },
|
||||
methods: {
|
||||
getEventListeners: function () {
|
||||
return actionHandlers || {};
|
||||
}
|
||||
}
|
||||
},
|
||||
{ dataset }
|
||||
);
|
||||
}
|
||||
|
||||
export function createMap (selectedDatasets, backgroundPollingView, mamufasImportView) {
|
||||
this.showModal(
|
||||
{
|
||||
template: `
|
||||
<Dialog @close="$emit('close')">
|
||||
<CreateDialog :selectedItems="selectedItems" :backgroundPollingView="backgroundPollingView" :mamufasImportView="mamufasImportView" @close="$emit('close')"/>
|
||||
</Dialog>`,
|
||||
props: ['selectedItems', 'backgroundPollingView', 'mamufasImportView'],
|
||||
components: { Dialog, CreateDialog }
|
||||
},
|
||||
{
|
||||
selectedItems: selectedDatasets,
|
||||
backgroundPollingView,
|
||||
mamufasImportView
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export function changePrivacy (visualization, actionHandlers) {
|
||||
this.showModal(
|
||||
{
|
||||
template: `
|
||||
<Dialog @close="$emit('close')">
|
||||
<ChangePrivacy
|
||||
:visualization="visualization"
|
||||
@close="$emit('close')"
|
||||
v-on="getEventListeners()" />
|
||||
</Dialog>`,
|
||||
props: ['visualization'],
|
||||
components: { Dialog, ChangePrivacy },
|
||||
methods: {
|
||||
getEventListeners: function () {
|
||||
return actionHandlers || {};
|
||||
}
|
||||
}
|
||||
},
|
||||
{ visualization }
|
||||
);
|
||||
}
|
||||
|
||||
export function shareVisualization (visualization, actionHandlers) {
|
||||
this.showModal(
|
||||
{
|
||||
template: `
|
||||
<Dialog v-on:close="$emit('close')">
|
||||
<Share
|
||||
:visualization="visualization"
|
||||
@close="$emit('close')"
|
||||
v-on="getEventListeners()" />
|
||||
</Dialog>`,
|
||||
props: ['visualization'],
|
||||
components: { Dialog, Share },
|
||||
methods: {
|
||||
getEventListeners: function () {
|
||||
return actionHandlers || {};
|
||||
}
|
||||
}
|
||||
},
|
||||
{ visualization }
|
||||
);
|
||||
}
|
||||
|
||||
export function duplicateVisualization (visualization) {
|
||||
this.showModal(
|
||||
{
|
||||
template: `
|
||||
<Dialog @close="$emit('close')">
|
||||
<DuplicateMap :visualization="visualization" @close="$emit('close')"/>
|
||||
</Dialog>`,
|
||||
props: ['visualization'],
|
||||
components: { Dialog, DuplicateMap }
|
||||
},
|
||||
{ visualization }
|
||||
);
|
||||
}
|
||||
|
||||
export function changeLockState (visualization, contentType, actionHandlers) {
|
||||
const dialogProps = { visualization, contentType };
|
||||
|
||||
this.showModal(
|
||||
{
|
||||
template: `
|
||||
<Dialog @close="$emit('close')">
|
||||
<LockVisualization
|
||||
:visualization="visualization"
|
||||
:contentType="contentType"
|
||||
@close="$emit('close')"
|
||||
v-on="getEventListeners()" />
|
||||
</Dialog>`,
|
||||
props: ['visualization', 'contentType'],
|
||||
components: { Dialog, LockVisualization },
|
||||
methods: {
|
||||
getEventListeners: function () {
|
||||
return actionHandlers || {};
|
||||
}
|
||||
}
|
||||
}, dialogProps
|
||||
);
|
||||
}
|
||||
|
||||
export function changeVisualizationsLockState (visualizations, contentType, actionHandlers) {
|
||||
const dialogProps = { visualizations, contentType };
|
||||
|
||||
this.showModal(
|
||||
{
|
||||
template: `
|
||||
<Dialog @close="$emit('close')">
|
||||
<LockVisualization
|
||||
:visualizations="visualizations"
|
||||
:contentType="contentType"
|
||||
@close="$emit('close')"
|
||||
v-on="getEventListeners()" />
|
||||
</Dialog>`,
|
||||
props: ['visualizations', 'contentType'],
|
||||
components: { Dialog, LockVisualization },
|
||||
methods: {
|
||||
getEventListeners: function () {
|
||||
return actionHandlers || {};
|
||||
}
|
||||
}
|
||||
}, dialogProps
|
||||
);
|
||||
}
|
||||
|
||||
export function deleteVisualization (visualization, contentType, actionHandlers) {
|
||||
const dialogProps = { visualization, contentType };
|
||||
|
||||
this.showModal(
|
||||
{
|
||||
template: `
|
||||
<Dialog @close="$emit('close')">
|
||||
<DeleteDialog
|
||||
:visualization="visualization"
|
||||
:contentType="contentType"
|
||||
@close="$emit('close')"
|
||||
v-on="getEventListeners()" />
|
||||
</Dialog>`,
|
||||
props: ['visualization', 'contentType'],
|
||||
components: { Dialog, DeleteDialog },
|
||||
methods: {
|
||||
getEventListeners: function () {
|
||||
return actionHandlers || {};
|
||||
}
|
||||
}
|
||||
}, dialogProps
|
||||
);
|
||||
}
|
||||
|
||||
export function deleteVisualizations (visualizations, contentType, actionHandlers) {
|
||||
const dialogProps = { visualizations, contentType };
|
||||
|
||||
this.showModal(
|
||||
{
|
||||
template: `
|
||||
<Dialog @close="$emit('close')">
|
||||
<DeleteDialog
|
||||
:visualizations="visualizations"
|
||||
:contentType="contentType"
|
||||
@close="$emit('close')"
|
||||
v-on="getEventListeners()" />
|
||||
</Dialog>`,
|
||||
props: ['visualizations', 'contentType'],
|
||||
components: { Dialog, DeleteDialog },
|
||||
methods: {
|
||||
getEventListeners: function () {
|
||||
return actionHandlers || {};
|
||||
}
|
||||
}
|
||||
}, dialogProps
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import store from 'new-dashboard/store';
|
||||
import MetricsTypes from 'builder/components/metrics/metrics-types';
|
||||
|
||||
export { MetricsTypes };
|
||||
export function sendMetric (eventName, eventProperties) {
|
||||
const baseURL = store.state.config.base_url;
|
||||
const requestURL = `${baseURL}/api/v3/metrics`;
|
||||
const requestData = getJSONMetricsData(eventName, eventProperties);
|
||||
|
||||
const requestOptions = {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(requestData)
|
||||
};
|
||||
|
||||
return fetch(requestURL, requestOptions);
|
||||
}
|
||||
|
||||
function getJSONMetricsData (name, properties) {
|
||||
return {
|
||||
name,
|
||||
properties: {
|
||||
...properties,
|
||||
user_id: store.state.user.id
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export function isOrganizationAdmin (organizationData = {}, userData = {}) {
|
||||
return organizationData.owner.id === userData.id ||
|
||||
Boolean((organizationData.admins || []).find(u => u.id === userData.id));
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import TableNameUtils from 'builder/helpers/table-name-utils';
|
||||
|
||||
export function getUnqualifiedName (originalName) {
|
||||
return TableNameUtils.getUnqualifiedName(originalName);
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
import PermissionModel from 'dashboard/data/permission-model';
|
||||
|
||||
export function isSharedWithMe (visualizationData, models) {
|
||||
return models.user.get('id') !== visualizationData.permission.owner.id;
|
||||
}
|
||||
|
||||
export function getURL (visualizationData, models) {
|
||||
const loggedUserBackboneModel = models.user;
|
||||
const loggedUserId = loggedUserBackboneModel.id || loggedUserBackboneModel.get('id');
|
||||
const permissionModel = new PermissionModel(
|
||||
visualizationData.permission, { configModel: models.config }
|
||||
);
|
||||
|
||||
let id = visualizationData.id;
|
||||
let userUrl = permissionModel.owner.viewUrl();
|
||||
|
||||
const isVisualization = visualizationData.type === 'derived' || typeof visualizationData.type === 'undefined';
|
||||
if (isVisualization) {
|
||||
if (loggedUserBackboneModel &&
|
||||
loggedUserId !== permissionModel.owner.get('id') &&
|
||||
permissionModel.hasAccess(loggedUserBackboneModel)) {
|
||||
userUrl = loggedUserBackboneModel.viewUrl();
|
||||
id = `${permissionModel.owner.get('username')}.${id}`;
|
||||
}
|
||||
|
||||
return userUrl.urlToPath('viz', id).get('base_url');
|
||||
} else {
|
||||
if (loggedUserBackboneModel && permissionModel.hasAccess(loggedUserBackboneModel)) {
|
||||
userUrl = loggedUserBackboneModel.viewUrl();
|
||||
}
|
||||
|
||||
return userUrl.urlToPath('tables', getUnquotedName(visualizationData.table.name)).get('base_url');
|
||||
}
|
||||
}
|
||||
|
||||
export function getThumbnailUrl (visualizationData, models, options) {
|
||||
const protocol = isHTTPS() ? 'https' : 'http';
|
||||
const cdnConfig = models.config.get('cdn_url');
|
||||
const username = visualizationData.permission.owner.username || models.user.get('username');
|
||||
const thumbnailOptions = {
|
||||
protocol,
|
||||
username,
|
||||
mapsApiResource: models.config.getMapsResourceName(username),
|
||||
tpl: _generateImageTemplate(visualizationData.id),
|
||||
width: options.width,
|
||||
height: options.height,
|
||||
authTokens: _generateAuthTokensParams(visualizationData.auth_tokens)
|
||||
};
|
||||
|
||||
if (cdnConfig) {
|
||||
Object.assign(thumbnailOptions, { cdn: cdnConfig[protocol] });
|
||||
}
|
||||
|
||||
return interpolateTemplateUrl(cdnConfig ? 'cdn' : 'regular', thumbnailOptions);
|
||||
}
|
||||
|
||||
const interpolateTemplateUrl = function (type, options) {
|
||||
if (type === 'regular') {
|
||||
return `${options.protocol}://${options.mapsApiResource}/api/v1/map/static/named/${options.tpl}/${options.width}/${options.height}.png${options.authTokens}`;
|
||||
}
|
||||
|
||||
if (type === 'cdn') {
|
||||
return `${options.protocol}://${options.cdn}/${options.username}/api/v1/map/static/named/${options.tpl}/${options.width}/${options.height}.png${options.authTokens}`;
|
||||
}
|
||||
};
|
||||
|
||||
const _generateAuthTokensParams = function (authTokens) {
|
||||
if (authTokens && authTokens.length > 0) {
|
||||
return '?' + authTokens.map(t => `auth_token=${t}`).join('&');
|
||||
}
|
||||
|
||||
return '';
|
||||
};
|
||||
|
||||
const _generateImageTemplate = function (visualizationId) {
|
||||
return `tpl_${visualizationId.replace(/-/g, '_')}`;
|
||||
};
|
||||
|
||||
const isHTTPS = function () {
|
||||
return location.protocol.indexOf('https') === 0;
|
||||
};
|
||||
|
||||
const getUnquotedName = function (name = '') {
|
||||
return name.replace(/"/g, '');
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
import { TrackJS } from 'trackjs';
|
||||
import store from '../store';
|
||||
|
||||
// TrackJS Configuration
|
||||
const isTrackJSEnabled = store.state.config.trackjs_enabled;
|
||||
|
||||
if (isTrackJSEnabled) {
|
||||
TrackJS.install({
|
||||
token: store.state.config.trackjs_customer,
|
||||
application: store.state.config.trackjs_app_key,
|
||||
userId: store.state.user.username,
|
||||
version: __ASSETS_VERSION__ + '-nd' // eslint-disable-line
|
||||
});
|
||||
}
|
||||
|
||||
// Google Tag Manager
|
||||
const tagManagerId = store.state.config.google_tag_manager_id;
|
||||
|
||||
if (tagManagerId) {
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
window.dataLayer.push({
|
||||
userId: store.state.user.id,
|
||||
userAccountType: store.state.user.account_type,
|
||||
userSignUpDate: Date.parse(store.state.user.created_at) / 1000,
|
||||
userJobRole: store.state.user.job_role,
|
||||
userInTrialPeriod: store.state.user.show_trial_reminder.toString()
|
||||
});
|
||||
|
||||
/* eslint-disable */
|
||||
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
||||
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
||||
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
||||
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
||||
})(window,document,'script','dataLayer', store.state.config.google_tag_manager_id);
|
||||
/* eslint-enable */
|
||||
}
|
||||
Reference in New Issue
Block a user