Custom Module stuck installing

Hello,

I’m trying to develop a custom module. First I’d like to make a simple Test Module and go on form there.
But when I want to install my module in the cms, it just installs forever and never finishes.
I can’t find what’s wrong with the code.
Any help would be appreciated.

cippools.json:

{
  "title": "CIP Pools",
  "author": "Thomas F.",
  "description": "Zeigt freie Cip Pools.",
  "name": "cippools",
  "class": "Xibo\\Custom\\CipPools\\CipPools"
}

CipPools/CipPools.php:

<?php

namespace Xibo\Custom\CipPools;

class CipPools extends \Xibo\Widget\ModuleWidget {

public $codeSchemaVersion = 1;

public function init() {

}

public function installOrUpdate($moduleFactory) {
	// Install
	if ($this->module == null) {
		$module = $moduleFactory->createEmpty();
		$module->name = 'CipPools';
		$module->type = 'cippools';
		$module->viewPath = '../custom/CipPools';
		$module->class = 'Xibo\Custom\CipPools\CipPools';
		$module->description = 'Zeigt freie CIP Pools an';
		$module->imageUri = 'forms/library.gif';
		$module->enabled = 1;
		$module->previewEnabled = 1;
		$module->assignable = 1;
		$module->regionSpecific = 1;
		$module->renderAs = 'html';
		$module->schemaVersion = $this->codeSchemaVersion;
		$module->defaultDuration = 60;
		$module->settings = [];

		$this->setModule($module);
		$this->installModule();
	}

	$this->installFiles();
}

public function installFiles() {

}

public function settingsForm() {
	return 'cippools-form-settings';
}

public function settings() {
	return $this->module->settings;
}


public function add() {
	$this->saveWidget();
}

public function edit() {
	$this->saveWidget();
}

public function preview($width, $height, $scaleOverride = 0) {
	return $this->previewAsClient($width, $height, $scaleOverride);
}

public function getResource($displayId = 0) {
	$this
    ->initialiseGetResource()
    ->appendViewPortWidth($this->region->width)
    ->appendFontCss())
    ->appendBody('<h1>My HTML</h1>')
    ->appendJavaScript('$(document).ready(function() { $("h1").html("My Altered HTML"); } ');

return $this->finaliseGetResource();
}

public function IsValid() {
	return 1;
}
}

CipPools/cippools-form-add.twig:

{% extends "form-base.twig" %}
{% import "forms.twig" as forms %}

{% block formTitle %}
    {% trans "Test" %}
{% endblock %}

{% block formButtons %}
    {% trans "Cancel" %}, XiboDialogClose()
    {% trans "Save" %}, $("#rgraphAddForm").submit()
{% endblock %}

CipPools/cippools-form-edit.twig:

{% extends "form-base.twig" %}
{% import "forms.twig" as forms %}

{% block formTitle %}
    {% trans "Edit Test" %}
{% endblock %}

{% block formButtons %}
    {% trans "Cancel" %}, XiboDialogClose()
    {% trans "Save" %}, $("#rgraphEditForm").submit()
{% endblock %}

CipPools/cippools-form-settings.twig:

{% extends "module-form-settings.twig" %}
{% import "forms.twig" as forms %}

{% block moduleFormFields %}

    {% set title %}{% trans "Test" %}{% endset %}

{% endblock %}

I don’t have a solution yet but I’m having the same issue as you currently. It appears as thought the module is stuck “installing” forever but in reality if you check your browser’s console logs you might also see “POST https://mywebsite/web/module/inst/MyModule 500 (Internal Server Error)” – this is what i’m currently getting. I’ve been tinkering with it for the past couple hours but if I manage a solution and this is the same problem you have, i’ll share it here, provided there isn’t any other support!

So i’m not sure if you ever ended up fixing your problem or moving on to something else but after turning on the “test” option for the CMS, I got proper debugging. I ended up having to add the “edit()” and “isValid()” methods (which can be added as empty methods), which were originally missing from my module. I don’t believe this is in the documentation so this may be what you’re also missing?

Good luck!