Rename notestutorial to upschooling

This commit is contained in:
Ben 2021-08-21 16:25:23 +02:00
parent f4bf5cb042
commit 3e17e44ab7
Signed by: ben
GPG key ID: 0F54A7ED232D3319
27 changed files with 442 additions and 192 deletions

View file

@ -8,7 +8,7 @@ on:
- stable* - stable*
env: env:
APP_NAME: notestutorial APP_NAME: upschooling
jobs: jobs:
php: php:

View file

@ -16,7 +16,7 @@
</dependencies> </dependencies>
<navigations> <navigations>
<navigation> <navigation>
<name>U Pschooling</name> <name>Support</name>
<route>upschooling.page.index</route> <route>upschooling.page.index</route>
</navigation> </navigation>
</navigations> </navigations>

500
composer.lock generated

File diff suppressed because it is too large Load diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
js/upschooling-main.js Normal file

Binary file not shown.

BIN
js/upschooling-main.js.map Normal file

Binary file not shown.

View file

@ -1,11 +1,11 @@
<?php <?php
namespace OCA\NotesTutorial\AppInfo; namespace OCA\UPschooling\AppInfo;
use OCP\AppFramework\App; use OCP\AppFramework\App;
class Application extends App { class Application extends App {
public const APP_ID = 'notestutorial'; public const APP_ID = 'upschooling';
public function __construct() { public function __construct() {
parent::__construct(self::APP_ID); parent::__construct(self::APP_ID);

View file

@ -1,13 +1,13 @@
<?php <?php
namespace OCA\NotesTutorial\Controller; namespace OCA\UPschooling\Controller;
use Closure; use Closure;
use OCP\AppFramework\Http; use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\DataResponse;
use OCA\NotesTutorial\Service\NoteNotFound; use OCA\UPschooling\Service\NoteNotFound;
trait Errors { trait Errors {
protected function handleNotFound(Closure $callback): DataResponse { protected function handleNotFound(Closure $callback): DataResponse {

View file

@ -1,9 +1,9 @@
<?php <?php
namespace OCA\NotesTutorial\Controller; namespace OCA\UPschooling\Controller;
use OCA\NotesTutorial\AppInfo\Application; use OCA\UPschooling\AppInfo\Application;
use OCA\NotesTutorial\Service\NoteService; use OCA\UPschooling\Service\NoteService;
use OCP\AppFramework\ApiController; use OCP\AppFramework\ApiController;
use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\DataResponse;
use OCP\IRequest; use OCP\IRequest;

View file

@ -1,9 +1,9 @@
<?php <?php
namespace OCA\NotesTutorial\Controller; namespace OCA\UPschooling\Controller;
use OCA\NotesTutorial\AppInfo\Application; use OCA\UPschooling\AppInfo\Application;
use OCA\NotesTutorial\Service\NoteService; use OCA\UPschooling\Service\NoteService;
use OCP\AppFramework\Controller; use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\DataResponse;
use OCP\IRequest; use OCP\IRequest;

View file

@ -1,8 +1,8 @@
<?php <?php
namespace OCA\NotesTutorial\Controller; namespace OCA\UPschooling\Controller;
use OCA\NotesTutorial\AppInfo\Application; use OCA\UPschooling\AppInfo\Application;
use OCP\AppFramework\Controller; use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
use OCP\IRequest; use OCP\IRequest;
@ -20,7 +20,7 @@ class PageController extends Controller {
* Render default template * Render default template
*/ */
public function index() { public function index() {
Util::addScript(Application::APP_ID, 'notestutorial-main'); Util::addScript(Application::APP_ID, 'upschooling-main');
return new TemplateResponse(Application::APP_ID, 'main'); return new TemplateResponse(Application::APP_ID, 'main');
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace OCA\NotesTutorial\Db; namespace OCA\UPschooling\Db;
use JsonSerializable; use JsonSerializable;

View file

@ -1,6 +1,6 @@
<?php <?php
namespace OCA\NotesTutorial\Db; namespace OCA\UPschooling\Db;
use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\Entity; use OCP\AppFramework\Db\Entity;
@ -10,7 +10,7 @@ use OCP\IDBConnection;
class NoteMapper extends QBMapper { class NoteMapper extends QBMapper {
public function __construct(IDBConnection $db) { public function __construct(IDBConnection $db) {
parent::__construct($db, 'notestutorial', Note::class); parent::__construct($db, 'upschooling', Note::class);
} }
/** /**
@ -24,7 +24,7 @@ class NoteMapper extends QBMapper {
/* @var $qb IQueryBuilder */ /* @var $qb IQueryBuilder */
$qb = $this->db->getQueryBuilder(); $qb = $this->db->getQueryBuilder();
$qb->select('*') $qb->select('*')
->from('notestutorial') ->from('upschooling')
->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))) ->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT)))
->andWhere($qb->expr()->eq('user_id', $qb->createNamedParameter($userId))); ->andWhere($qb->expr()->eq('user_id', $qb->createNamedParameter($userId)));
return $this->findEntity($qb); return $this->findEntity($qb);
@ -38,7 +38,7 @@ class NoteMapper extends QBMapper {
/* @var $qb IQueryBuilder */ /* @var $qb IQueryBuilder */
$qb = $this->db->getQueryBuilder(); $qb = $this->db->getQueryBuilder();
$qb->select('*') $qb->select('*')
->from('notestutorial') ->from('upschooling')
->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId))); ->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId)));
return $this->findEntities($qb); return $this->findEntities($qb);
} }

View file

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace OCA\NotesTutorial\Migration; namespace OCA\UPschooling\Migration;
use Closure; use Closure;
use OCP\DB\ISchemaWrapper; use OCP\DB\ISchemaWrapper;
@ -21,8 +21,8 @@ class Version000000Date20181013124731 extends SimpleMigrationStep {
/** @var ISchemaWrapper $schema */ /** @var ISchemaWrapper $schema */
$schema = $schemaClosure(); $schema = $schemaClosure();
if (!$schema->hasTable('notestutorial')) { if (!$schema->hasTable('upschooling')) {
$table = $schema->createTable('notestutorial'); $table = $schema->createTable('upschooling');
$table->addColumn('id', 'integer', [ $table->addColumn('id', 'integer', [
'autoincrement' => true, 'autoincrement' => true,
'notnull' => true, 'notnull' => true,
@ -41,7 +41,7 @@ class Version000000Date20181013124731 extends SimpleMigrationStep {
]); ]);
$table->setPrimaryKey(['id']); $table->setPrimaryKey(['id']);
$table->addIndex(['user_id'], 'notestutorial_user_id_index'); $table->addIndex(['user_id'], 'upschooling_user_id_index');
} }
return $schema; return $schema;
} }

View file

@ -1,6 +1,6 @@
<?php <?php
namespace OCA\NotesTutorial\Service; namespace OCA\UPschooling\Service;
class NoteNotFound extends \Exception { class NoteNotFound extends \Exception {
} }

View file

@ -1,14 +1,14 @@
<?php <?php
namespace OCA\NotesTutorial\Service; namespace OCA\UPschooling\Service;
use Exception; use Exception;
use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\MultipleObjectsReturnedException; use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCA\NotesTutorial\Db\Note; use OCA\UPschooling\Db\Note;
use OCA\NotesTutorial\Db\NoteMapper; use OCA\UPschooling\Db\NoteMapper;
class NoteService { class NoteService {

4
package-lock.json generated
View file

@ -1,11 +1,11 @@
{ {
"name": "notestutorial", "name": "upschooling",
"version": "19.0.0", "version": "19.0.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "notestutorial", "name": "upschooling",
"version": "19.0.0", "version": "19.0.0",
"license": "agpl", "license": "agpl",
"dependencies": { "dependencies": {

View file

@ -1,5 +1,5 @@
{ {
"name": "notestutorial", "name": "upschooling",
"description": "A simple Nextcloud app tutorial for building a notes app", "description": "A simple Nextcloud app tutorial for building a notes app",
"version": "19.0.0", "version": "19.0.0",
"author": "Julius Härtl <jus@bitgrid.net", "author": "Julius Härtl <jus@bitgrid.net",

View file

@ -8,7 +8,7 @@ DIR="${0%/*}"
podman run -d --name=nextcloud --replace=true -p 8080:80 -v "$DIR:/var/www/html/custom_apps/upschooling" docker.io/nextcloud podman run -d --name=nextcloud --replace=true -p 8080:80 -v "$DIR:/var/www/html/custom_apps/upschooling" docker.io/nextcloud
podman exec nextcloud chown -R 33 /var/www/html/custom_apps podman exec nextcloud chown -R 33 /var/www/html/custom_apps
"$DIR/podman-reown.sh" "$DIR/podman-reown.sh"
podman exec --user 33 nextcloud bash -c 'cd /var/www/html/custom_apps/upschooling && make' podman exec --user 33 nextcloud bash -c 'cd /var/www/html/custom_apps/upschooling && make composer'
podman exec --user 33 nextcloud php occ maintenance:install --database sqlite --admin-user admin --admin-pass admin podman exec --user 33 nextcloud php occ maintenance:install --database sqlite --admin-user admin --admin-pass admin
podman exec --user 33 nextcloud php occ config:system:set --value=true --type=boolean debug podman exec --user 33 nextcloud php occ config:system:set --value=true --type=boolean debug
podman exec --user 33 nextcloud php occ app:enable --force upschooling podman exec --user 33 nextcloud php occ app:enable --force upschooling

View file

@ -1,28 +1,28 @@
<template> <template>
<div id="content" class="app-notestutorial"> <div id="content" class="app-upschooling">
<AppNavigation> <AppNavigation>
<AppNavigationNew v-if="!loading" <AppNavigationNew v-if="!loading"
:text="t('notestutorial', 'New note')" :text="t('upschooling', 'New note')"
:disabled="false" :disabled="false"
button-id="new-notestutorial-button" button-id="new-upschooling-button"
button-class="icon-add" button-class="icon-add"
@click="newNote" /> @click="newNote" />
<ul> <ul>
<AppNavigationItem v-for="note in notes" <AppNavigationItem v-for="note in notes"
:key="note.id" :key="note.id"
:title="note.title ? note.title : t('notestutorial', 'New note')" :title="note.title ? note.title : t('upschooling', 'New note')"
:class="{active: currentNoteId === note.id}" :class="{active: currentNoteId === note.id}"
@click="openNote(note)"> @click="openNote(note)">
<template slot="actions"> <template slot="actions">
<ActionButton v-if="note.id === -1" <ActionButton v-if="note.id === -1"
icon="icon-close" icon="icon-close"
@click="cancelNewNote(note)"> @click="cancelNewNote(note)">
{{ t('notestutorial', 'Cancel note creation') }} {{ t('upschooling', 'Cancel note creation') }}
</ActionButton> </ActionButton>
<ActionButton v-else <ActionButton v-else
icon="icon-delete" icon="icon-delete"
@click="deleteNote(note)"> @click="deleteNote(note)">
{{ t('notestutorial', 'Delete note') }} {{ t('upschooling', 'Delete note') }}
</ActionButton> </ActionButton>
</template> </template>
</AppNavigationItem> </AppNavigationItem>
@ -37,13 +37,13 @@
<textarea ref="content" v-model="currentNote.content" :disabled="updating" /> <textarea ref="content" v-model="currentNote.content" :disabled="updating" />
<input type="button" <input type="button"
class="primary" class="primary"
:value="t('notestutorial', 'Save')" :value="t('upschooling', 'Save')"
:disabled="updating || !savePossible" :disabled="updating || !savePossible"
@click="saveNote"> @click="saveNote">
</div> </div>
<div v-else id="emptycontent"> <div v-else id="emptycontent">
<div class="icon-file" /> <div class="icon-file" />
<h2>{{ t('notestutorial', 'Create a note to get started') }}</h2> <h2>{{ t('upschooling', 'Create a note to get started') }}</h2>
</div> </div>
</AppContent> </AppContent>
</div> </div>
@ -103,11 +103,11 @@ export default {
*/ */
async mounted() { async mounted() {
try { try {
const response = await axios.get(generateUrl('/apps/notestutorial/notes')) const response = await axios.get(generateUrl('/apps/upschooling/notes'))
this.notes = response.data this.notes = response.data
} catch (e) { } catch (e) {
console.error(e) console.error(e)
showError(t('notestutorial', 'Could not fetch notes')) showError(t('upschooling', 'Could not fetch notes'))
} }
this.loading = false this.loading = false
}, },
@ -169,13 +169,13 @@ export default {
async createNote(note) { async createNote(note) {
this.updating = true this.updating = true
try { try {
const response = await axios.post(generateUrl('/apps/notestutorial/notes'), note) const response = await axios.post(generateUrl('/apps/upschooling/notes'), note)
const index = this.notes.findIndex((match) => match.id === this.currentNoteId) const index = this.notes.findIndex((match) => match.id === this.currentNoteId)
this.$set(this.notes, index, response.data) this.$set(this.notes, index, response.data)
this.currentNoteId = response.data.id this.currentNoteId = response.data.id
} catch (e) { } catch (e) {
console.error(e) console.error(e)
showError(t('notestutorial', 'Could not create the note')) showError(t('upschooling', 'Could not create the note'))
} }
this.updating = false this.updating = false
}, },
@ -186,10 +186,10 @@ export default {
async updateNote(note) { async updateNote(note) {
this.updating = true this.updating = true
try { try {
await axios.put(generateUrl(`/apps/notestutorial/notes/${note.id}`), note) await axios.put(generateUrl(`/apps/upschooling/notes/${note.id}`), note)
} catch (e) { } catch (e) {
console.error(e) console.error(e)
showError(t('notestutorial', 'Could not update the note')) showError(t('upschooling', 'Could not update the note'))
} }
this.updating = false this.updating = false
}, },
@ -199,15 +199,15 @@ export default {
*/ */
async deleteNote(note) { async deleteNote(note) {
try { try {
await axios.delete(generateUrl(`/apps/notestutorial/notes/${note.id}`)) await axios.delete(generateUrl(`/apps/upschooling/notes/${note.id}`))
this.notes.splice(this.notes.indexOf(note), 1) this.notes.splice(this.notes.indexOf(note), 1)
if (this.currentNoteId === note.id) { if (this.currentNoteId === note.id) {
this.currentNoteId = null this.currentNoteId = null
} }
showSuccess(t('notestutorial', 'Note deleted')) showSuccess(t('upschooling', 'Note deleted'))
} catch (e) { } catch (e) {
console.error(e) console.error(e)
showError(t('notestutorial', 'Could not delete the note')) showError(t('upschooling', 'Could not delete the note'))
} }
}, },
}, },

View file

@ -1,15 +1,15 @@
<?php <?php
namespace OCA\NotesTutorial\Tests\Integration\Controller; namespace OCA\UPschooling\Tests\Integration\Controller;
use OCP\AppFramework\App; use OCP\AppFramework\App;
use OCP\IRequest; use OCP\IRequest;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use OCA\NotesTutorial\Db\Note; use OCA\UPschooling\Db\Note;
use OCA\NotesTutorial\Db\NoteMapper; use OCA\UPschooling\Db\NoteMapper;
use OCA\NotesTutorial\Controller\NoteController; use OCA\UPschooling\Controller\NoteController;
class NoteIntegrationTest extends TestCase { class NoteIntegrationTest extends TestCase {
private $controller; private $controller;
@ -17,7 +17,7 @@ class NoteIntegrationTest extends TestCase {
private $userId = 'john'; private $userId = 'john';
public function setUp(): void { public function setUp(): void {
$app = new App('notestutorial'); $app = new App('upschooling');
$container = $app->getContainer(); $container = $app->getContainer();
// only replace the user id // only replace the user id

View file

@ -1,8 +1,8 @@
<?php <?php
namespace OCA\NotesTutorial\Tests\Unit\Controller; namespace OCA\UPschooling\Tests\Unit\Controller;
use OCA\NotesTutorial\Controller\NoteApiController; use OCA\UPschooling\Controller\NoteApiController;
class NoteApiControllerTest extends NoteControllerTest { class NoteApiControllerTest extends NoteControllerTest {
public function setUp(): void { public function setUp(): void {

View file

@ -1,15 +1,15 @@
<?php <?php
namespace OCA\NotesTutorial\Tests\Unit\Controller; namespace OCA\UPschooling\Tests\Unit\Controller;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use OCP\AppFramework\Http; use OCP\AppFramework\Http;
use OCP\IRequest; use OCP\IRequest;
use OCA\NotesTutorial\Service\NoteNotFound; use OCA\UPschooling\Service\NoteNotFound;
use OCA\NotesTutorial\Service\NoteService; use OCA\UPschooling\Service\NoteService;
use OCA\NotesTutorial\Controller\NoteController; use OCA\UPschooling\Controller\NoteController;
class NoteControllerTest extends TestCase { class NoteControllerTest extends TestCase {
protected $controller; protected $controller;

View file

@ -1,6 +1,6 @@
<?php <?php
namespace OCA\NotesTutorial\Controller; namespace OCA\UPschooling\Controller;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;

View file

@ -1,15 +1,15 @@
<?php <?php
namespace OCA\NotesTutorial\Tests\Unit\Service; namespace OCA\UPschooling\Tests\Unit\Service;
use OCA\NotesTutorial\Service\NoteNotFound; use OCA\UPschooling\Service\NoteNotFound;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Db\DoesNotExistException;
use OCA\NotesTutorial\Db\Note; use OCA\UPschooling\Db\Note;
use OCA\NotesTutorial\Service\NoteService; use OCA\UPschooling\Service\NoteService;
use OCA\NotesTutorial\Db\NoteMapper; use OCA\UPschooling\Db\NoteMapper;
class NoteServiceTest extends TestCase { class NoteServiceTest extends TestCase {
private $service; private $service;