Compare commits
2 commits
0a90ea80b8
...
1f14932b28
Author | SHA1 | Date | |
---|---|---|---|
Ben | 1f14932b28 | ||
Ben | 70d59ebece |
209
.gitignore
vendored
209
.gitignore
vendored
|
@ -1,10 +1,207 @@
|
|||
/.idea/
|
||||
*.iml
|
||||
/build/
|
||||
node_modules/
|
||||
/.php_cs.cache
|
||||
/js/
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/phpstorm+all,phpunit,composer,node,vue
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=phpstorm+all,phpunit,composer,node,vue
|
||||
|
||||
### Composer ###
|
||||
composer.phar
|
||||
/vendor/
|
||||
|
||||
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
|
||||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
|
||||
# composer.lock
|
||||
|
||||
### Node ###
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# webpack output
|
||||
js/
|
||||
|
||||
### PhpStorm+all ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# AWS User-specific
|
||||
.idea/**/aws.xml
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
### PhpStorm+all Patch ###
|
||||
# Ignores the whole .idea folder and all .iml files
|
||||
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
|
||||
|
||||
.idea/
|
||||
|
||||
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
|
||||
|
||||
*.iml
|
||||
modules.xml
|
||||
.idea/misc.xml
|
||||
*.ipr
|
||||
|
||||
# Sonarlint plugin
|
||||
.idea/sonarlint
|
||||
|
||||
### PHPUnit ###
|
||||
# Covers PHPUnit
|
||||
# Reference: https://phpunit.de/
|
||||
|
||||
# Generated files
|
||||
.phpunit.result.cache
|
||||
.phpunit.cache
|
||||
|
||||
# PHPUnit
|
||||
/app/phpunit.xml
|
||||
/phpunit.xml
|
||||
|
||||
# Build data
|
||||
/build/
|
||||
|
||||
### Vue ###
|
||||
# gitignore template for Vue.js projects
|
||||
#
|
||||
# Recommended template: Node.gitignore
|
||||
|
||||
# TODO: where does this rule come from?
|
||||
docs/_book
|
||||
|
||||
# TODO: where does this rule come from?
|
||||
test/
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/phpstorm+all,phpunit,composer,node,vue
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<category>tools</category>
|
||||
<bugs>https://gitea.rs485.network/UPschooling/Nextcloud-App/issues</bugs>
|
||||
<dependencies>
|
||||
<nextcloud min-version="15" max-version="22"/>
|
||||
<nextcloud min-version="20" max-version="22"/>
|
||||
</dependencies>
|
||||
<navigations>
|
||||
<navigation>
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
return [
|
||||
'resources' => [
|
||||
'ticket_api' => ['url' => '/api/v1/ticket']
|
||||
'ticket_api' => ['url' => '/api/v1/tickets']
|
||||
],
|
||||
'routes' => [
|
||||
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
|
||||
[
|
||||
'name' => 'ticket_api#preflighted_cors',
|
||||
'url' => '/api/v1/{path}',
|
||||
'url' => '/api/v1/tickets',
|
||||
'verb' => 'OPTIONS',
|
||||
'requirements' => ['path' => '.+'],
|
||||
],
|
||||
|
|
|
@ -8,7 +8,8 @@ use OCP\AppFramework\ApiController;
|
|||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\IRequest;
|
||||
|
||||
class TicketApiController extends ApiController {
|
||||
class TicketApiController extends ApiController
|
||||
{
|
||||
/** @var TicketService */
|
||||
private $service;
|
||||
|
||||
|
@ -17,62 +18,46 @@ class TicketApiController extends ApiController {
|
|||
|
||||
use Errors;
|
||||
|
||||
public function __construct(IRequest $request,
|
||||
TicketService $service,
|
||||
$userId) {
|
||||
public function __construct(IRequest $request, TicketService $service, $userId)
|
||||
{
|
||||
parent::__construct(Application::APP_ID, $request);
|
||||
$this->service = $service;
|
||||
$this->userId = $userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @CORS
|
||||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function index(): DataResponse {
|
||||
public function index(): DataResponse
|
||||
{
|
||||
return new DataResponse($this->service->findAll($this->userId));
|
||||
}
|
||||
|
||||
/**
|
||||
* @CORS
|
||||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function show(int $id): DataResponse {
|
||||
public function show(int $id): DataResponse
|
||||
{
|
||||
return $this->handleNotFound(function () use ($id) {
|
||||
return $this->service->find($id, $this->userId);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @CORS
|
||||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function create(string $title, string $content): DataResponse {
|
||||
public function create(string $title, string $content): DataResponse
|
||||
{
|
||||
return new DataResponse($this->service->create($title, $content,
|
||||
$this->userId));
|
||||
}
|
||||
|
||||
/**
|
||||
* @CORS
|
||||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function update(int $id, string $title,
|
||||
string $content): DataResponse {
|
||||
public function update(int $id, string $title, string $content): DataResponse
|
||||
{
|
||||
return $this->handleNotFound(function () use ($id, $title, $content) {
|
||||
return $this->service->update($id, $title, $content, $this->userId);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @CORS
|
||||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function destroy(int $id): DataResponse {
|
||||
public function destroy(int $id): DataResponse
|
||||
{
|
||||
return $this->handleNotFound(function () use ($id) {
|
||||
return $this->service->delete($id, $this->userId);
|
||||
});
|
||||
|
|
|
@ -31,11 +31,18 @@ class MatrixService
|
|||
$this->channel = "#issue:synapse";
|
||||
$this->client = new MatrixClient("http://synapse:8008");
|
||||
$this->token = $this->client->login("upschooling", "secret");
|
||||
try {
|
||||
$this->room = $this->client->createRoom($this->channel, false, array());
|
||||
} catch (MatrixException $e) {
|
||||
$this->logger->error("Could not create room ".$this->channel, array('exception' => $e));
|
||||
}
|
||||
// try {
|
||||
// $this->room = $this->client->createRoom($this->channel, false, array());
|
||||
// } catch (MatrixException $createE) {
|
||||
// try {
|
||||
// $this->room = $this->client->joinRoom($this->channel);
|
||||
// } catch (MatrixException $e) {
|
||||
// $this->logger->error(
|
||||
// "Could not create room ".$this->channel,
|
||||
// array('exception' => $e, 'causedBy' => $createE)
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
51
src/App.vue
51
src/App.vue
|
@ -18,6 +18,7 @@ import AppNavigation from '@nextcloud/vue/dist/Components/AppNavigation'
|
|||
import TicketList from './components/TicketList'
|
||||
import Ticket from './Ticket'
|
||||
import '@nextcloud/dialogs/styles/toast.scss'
|
||||
import axios from '@nextcloud/axios'
|
||||
|
||||
export default {
|
||||
name: 'App',
|
||||
|
@ -27,6 +28,7 @@ export default {
|
|||
AppContent,
|
||||
AppNavigation,
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
/**
|
||||
|
@ -36,37 +38,32 @@ export default {
|
|||
*/
|
||||
currentTicket: undefined,
|
||||
|
||||
testTickets: [
|
||||
{
|
||||
id: 1234,
|
||||
status: 'Offen',
|
||||
title: 'Dies ist ein Ticket-Titel',
|
||||
},
|
||||
{
|
||||
id: 12345,
|
||||
status: 'Offen',
|
||||
title: 'Dies ist ein anderer Ticket-Titel',
|
||||
},
|
||||
{
|
||||
id: 123456,
|
||||
status: 'Behoben',
|
||||
title: 'Sowieso behoben',
|
||||
},
|
||||
],
|
||||
tickets: [],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
/**
|
||||
* Returns the list of ticket objects the current account has access to.
|
||||
*
|
||||
* @return {Array}
|
||||
*/
|
||||
tickets() {
|
||||
// TODO: ask API (dont forget permission check in API)
|
||||
return this.testTickets
|
||||
},
|
||||
watch: {
|
||||
$route: 'fetchTickets',
|
||||
},
|
||||
created() {
|
||||
this.fetchTickets()
|
||||
},
|
||||
methods: {
|
||||
fetchTickets() {
|
||||
axios.get(
|
||||
'api/v1/tickets',
|
||||
{ headers: { Accept: 'application/json' } }
|
||||
).then((response) => {
|
||||
if (Array.isArray(response.data)) {
|
||||
if (response.data.length !== 0) {
|
||||
this.tickets.push(response.data)
|
||||
} else {
|
||||
console.warn('Empty ticket list :(')
|
||||
}
|
||||
} else {
|
||||
console.error('API did not return array: ', response)
|
||||
}
|
||||
}).catch(console.error)
|
||||
},
|
||||
saveTicket(ticketId, data) {
|
||||
// TODO send to API (dont forget permission check in API)
|
||||
console.debug('upschooling', 'saveTicket', ticketId, data)
|
||||
|
|
|
@ -4,21 +4,33 @@ namespace Unit\Service;
|
|||
|
||||
use OCA\UPschooling\Db\MatrixTicket;
|
||||
use OCA\UPschooling\Db\TicketMapper;
|
||||
use OCA\UPschooling\Service\MatrixService;
|
||||
use OCA\UPschooling\Service\NoteNotFound;
|
||||
use OCA\UPschooling\Service\TicketService;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\NullLogger;
|
||||
|
||||
class NoteServiceTest extends TestCase {
|
||||
|
||||
/** @var TicketService */
|
||||
private $service;
|
||||
|
||||
/** @var MatrixService */
|
||||
private $matrixService;
|
||||
|
||||
/** @var TicketMapper */
|
||||
private $mapper;
|
||||
|
||||
/** @var string */
|
||||
private $userId = 'john';
|
||||
|
||||
public function setUp(): void {
|
||||
$this->mapper = $this->getMockBuilder(TicketMapper::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->service = new TicketService($this->mapper);
|
||||
$this->matrixService = new MatrixService(new NullLogger());
|
||||
$this->service = new TicketService($this->matrixService, $this->mapper);
|
||||
}
|
||||
|
||||
public function testUpdate() {
|
||||
|
|
Loading…
Reference in a new issue