Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jDrupal and Angular 4 (TypeScript) #86

Open
liquidcms opened this issue May 14, 2019 · 1 comment
Open

jDrupal and Angular 4 (TypeScript) #86

liquidcms opened this issue May 14, 2019 · 1 comment

Comments

@liquidcms
Copy link

I saw an old post of someone looking for jDrupal support for Angular 2. I'm a bit late but i got this working with Angular 4 (TypeScript).

npm install jdrupal

in angular.json under "scripts" i added: "node_modules/jdrupal/jdrupal.js"

using an import statement should have worked but i couldn't figure it out.

then in mypage.page.ts


import { Component, OnInit } from '@angular/core';
// import * as Drupal from 'jdrupal';

declare var Drupal: any;

@Component({
  selector: 'app-drupal-test',
  templateUrl: './drupal-test.page.html',
  styleUrls: ['./drupal-test.page.scss'],
})
export class DrupalTestPage implements OnInit {

  constructor() {}

  ngOnInit() {
    Drupal.settings.site_path = 'http://qleva.liquidcms.org';
    Drupal.settings.endpoint = 'rest';
    this.initDrupal();
    this.userLogin();
  }

  initDrupal() {
    system_connect({
      success: function(result) {

        // Prepare a message for the user.
        const text = result.user.uid === 0 ? 'Hello World' : 'Hello ' + result.user.name;

        // Show the message in the paragraph.
        document.getElementById('msg').innerHTML = text;

      }
    });
  }

  userLogin() {
    user_login('qleva-admin', 'qpoiqpoi', {
      success:function(result) {
        document.getElementById('useremail').innerHTML = result.user.mail;
      },
      error:function(xhr, status, message) {
        alert(message);
      }
    });
  }
}
@liquidcms
Copy link
Author

Not exactly sure what system_connect() does. Don't think it is really needed for anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant