Cannot find name 'ContentGetter'.

Bug and problem reporting on Cyclos 4 version

Moderators: hugo, alexandre, rmvanarkel

Post Reply
atitokor
Posts: 46
Joined: Tue Jan 01, 2019 8:33 pm

Cannot find name 'ContentGetter'.

Post by atitokor » Thu May 23, 2019 10:48 am

I'm trying to fetch the content of my first Cyclos floating page, but I'm getting the following error when running "npm run build". I'm using Cyclos 4.11.5, NodeJS 10.15.3, NPM 6.4.1, CORS.

Code: Select all

ERROR in src/app/setup.ts(30,14): error TS2304: Cannot find name 'ContentGetter'.
Bellow is my setup.ts

Code: Select all

import { Configuration } from 'app/configuration';

/**
 * Set all desired Cyclos configuration options
 */
export function setup() {
  Configuration.apiRoot = 'https://cyclossubdoain.domain.com/api';
  Configuration.appTitle = 'MyApp';
  Configuration.appTitleSmall = 'MyApp';
  Configuration.appTitleMenu = 'MyApp menu';
  // true means a separated menu bar, false means joining the menu on the top bar
  Configuration.menuBar = false;
  // The key is the ad category internal name, the value defines the icon and color
  Configuration.adCategories = {
    'community': { icon: 'people', color: '#2196f3' },
    'food': { icon: 'restaurant', color: '#f04d4e' },
    'goods': { icon: 'pages', color: '#ff9700' },
    'housing': { icon: 'location_city', color: '#029487' },
    'jobs': { icon: 'work', color: '#8062b3' },
    'labor': { icon: 'business', color: '#de3eaa' },
    'leisure': { icon: 'mood', color: '#687ebd' },
    'services': { icon: 'room_service', color: '#8ec63f' }
  };
  // The key is the custom operation internal name, the value defines the icon
  Configuration.operations = {
    addUnitsWithPayPal: { icon: 'format_paint' },
  };
  // This example uses the full URL, assuming the Cyclos server has CORS enabled
  Configuration.homePage = {
    content: ContentGetter.cyclosPage('https://cyclossubdoain.domain.com/web-rpc/menuEntry/menuItemDetails/981917799751577186')
  };
}
And here is my content.ts

Code: Select all

/**
 * The default number of seconds to cache content (1 hour)
 */
export const DEFAULT_CACHE_SECONDS = 60 * 60;

/**
 * A negative number, indicating to never cache the content
 */
export const DISABLE_CACHE_SECONDS = -1;

/**
 * A large number of seconds, which, in practice, means the cache "never" expires (1 year)
 */
export const CACHE_FOREVER_SECONDS = 365 * 24 * 60 * 60;

/**
 * Interface describing a content
 */
export interface Content {

  /**
   * The content itself, which may be a raw string or a content getter
   */
  content: string | ContentGetter;

  /**
   * The cache key. When not set, will not cache
   */
  cacheKey?: string;

  /**
   * The number of seconds the content should be cached
   */
  cacheSeconds?: number;

}
Any help would be highly appreciated.
Thanks!
Art

luis
Posts: 182
Joined: Fri Feb 17, 2006 11:01 am

Re: Cannot find name 'ContentGetter'.

Post by luis » Thu May 23, 2019 11:42 am

You have to import it.
Add the following line on the top of the file:

Code: Select all

import { ContentGetter } from 'app/content/content-getter';
It is advised to use an editor such as VisualStudio Code, so you could just press ctrl+space while the cursor is at the end of the ContentGetter name and it would add the import automatically.
Luis Fernando Planella Gonzalez
Cyclos development team

atitokor
Posts: 46
Joined: Tue Jan 01, 2019 8:33 pm

Re: Cannot find name 'ContentGetter'.

Post by atitokor » Thu May 23, 2019 10:15 pm

It works! Thank you, and for the advice on VisualStudio Code...
Art

Post Reply