Browse Source
Start with commands
Start with commands
Signed-off-by: Joas Schilling <coding@schilljs.com>pull/1453/head
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
18 changed files with 6602 additions and 1 deletions
-
3appinfo/info.xml
-
297js/admin/commands.js
-
1js/admin/commands.js.map
-
72lib/Controller/CommandController.php
-
73lib/Migration/Version5099Date20190121102337.php
-
57lib/Model/Command.php
-
48lib/Model/CommandMapper.php
-
56lib/Settings/Admin/Commands.php
-
14templates/settings/admin/commands.php
-
33vue/Makefile
-
5697vue/package-lock.json
-
34vue/package.json
-
60vue/src/Commands.vue
-
34vue/src/commands.js
-
61vue/src/components/Command.vue
-
44vue/webpack.common.js
-
12vue/webpack.dev.js
-
7vue/webpack.prod.js
297
js/admin/commands.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1
js/admin/commands.js.map
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,72 @@ |
|||
<?php |
|||
/** |
|||
* @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> |
|||
* |
|||
* @author Joas Schilling <coding@schilljs.com> |
|||
* |
|||
* @license GNU AGPL version 3 or any later version |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU Affero General Public License as |
|||
* published by the Free Software Foundation, either version 3 of the |
|||
* License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU Affero General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU Affero General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace OCA\Spreed\Controller; |
|||
|
|||
use OCA\Spreed\Exceptions\ParticipantNotFoundException; |
|||
use OCA\Spreed\Exceptions\RoomNotFoundException; |
|||
use OCA\Spreed\Manager; |
|||
use OCA\Spreed\Model\CommandMapper; |
|||
use OCA\Spreed\Participant; |
|||
use OCA\Spreed\TalkSession; |
|||
use OCP\AppFramework\Http; |
|||
use OCP\AppFramework\Http\DataResponse; |
|||
use OCP\AppFramework\OCSController; |
|||
use OCP\IRequest; |
|||
|
|||
class CommandController extends OCSController { |
|||
/** @var CommandMapper */ |
|||
protected $commandMapper; |
|||
|
|||
/** |
|||
* @param string $appName |
|||
* @param IRequest $request |
|||
* @param CommandMapper $commandMapper |
|||
*/ |
|||
public function __construct($appName, |
|||
IRequest $request, |
|||
CommandMapper $commandMapper) { |
|||
parent::__construct($appName, $request); |
|||
$this->commandMapper = $commandMapper; |
|||
} |
|||
|
|||
/** |
|||
* @return DataResponse |
|||
*/ |
|||
public function getAll(): DataResponse { |
|||
$commands = $this->commandMapper->findAll(); |
|||
|
|||
$result = []; |
|||
foreach ($commands as $command) { |
|||
$result[] = [ |
|||
'id' => $command->getId(), |
|||
'pattern' => $command->getPattern(), |
|||
'script' => $command->getScript(), |
|||
'output' => $command->getOutput(), |
|||
]; |
|||
} |
|||
|
|||
return new DataResponse($result); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,73 @@ |
|||
<?php |
|||
declare(strict_types=1); |
|||
/** |
|||
* @copyright Copyright (c) 2019, Joas Schilling <coding@schilljs.com> |
|||
* |
|||
* @license GNU AGPL version 3 or any later version |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU Affero General Public License as |
|||
* published by the Free Software Foundation, either version 3 of the |
|||
* License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU Affero General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU Affero General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace OCA\Spreed\Migration; |
|||
|
|||
use Closure; |
|||
use Doctrine\DBAL\Types\Type; |
|||
use OCP\DB\ISchemaWrapper; |
|||
use OCP\Migration\SimpleMigrationStep; |
|||
use OCP\Migration\IOutput; |
|||
|
|||
class Version5099Date20190121102337 extends SimpleMigrationStep { |
|||
/** |
|||
* @param IOutput $output |
|||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|||
* @param array $options |
|||
* @return null|ISchemaWrapper |
|||
*/ |
|||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|||
/** @var ISchemaWrapper $schema */ |
|||
$schema = $schemaClosure(); |
|||
|
|||
if (!$schema->hasTable('talk_commands')) { |
|||
$table = $schema->createTable('talk_commands'); |
|||
|
|||
$table->addColumn('id', Type::INTEGER, [ |
|||
'autoincrement' => true, |
|||
'notnull' => true, |
|||
'length' => 20, |
|||
]); |
|||
$table->addColumn('name', Type::STRING, [ |
|||
'notnull' => true, |
|||
'length' => 64, |
|||
]); |
|||
$table->addColumn('pattern', Type::STRING, [ |
|||
'notnull' => true, |
|||
'length' => 512, |
|||
]); |
|||
$table->addColumn('script', Type::STRING, [ |
|||
'notnull' => true, |
|||
'length' => 512, |
|||
]); |
|||
$table->addColumn('output', Type::INTEGER, [ |
|||
'notnull' => true, |
|||
'length' => 6, |
|||
'default' => 0, |
|||
]); |
|||
|
|||
$table->setPrimaryKey(['id']); |
|||
} |
|||
|
|||
return $schema; |
|||
} |
|||
} |
|||
@ -0,0 +1,57 @@ |
|||
<?php |
|||
declare(strict_types=1); |
|||
/** |
|||
* @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> |
|||
* |
|||
* @license GNU AGPL version 3 or any later version |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU Affero General Public License as |
|||
* published by the Free Software Foundation, either version 3 of the |
|||
* License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU Affero General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU Affero General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace OCA\Spreed\Model; |
|||
|
|||
use OCP\AppFramework\Db\Entity; |
|||
|
|||
/** |
|||
* @method void setName(string $name) |
|||
* @method string getName() |
|||
* @method void setPattern(string $pattern) |
|||
* @method string getPattern() |
|||
* @method void setScript(string $name) |
|||
* @method string getScript() |
|||
* @method void setOutput(int $output) |
|||
* @method int getOutput() |
|||
*/ |
|||
class Command extends Entity { |
|||
|
|||
/** @var string */ |
|||
protected $name; |
|||
|
|||
/** @var string */ |
|||
protected $pattern; |
|||
|
|||
/** @var string */ |
|||
protected $script; |
|||
|
|||
/** @var int */ |
|||
protected $output; |
|||
|
|||
public function __construct() { |
|||
$this->addType('name', 'string'); |
|||
$this->addType('pattern', 'string'); |
|||
$this->addType('script', 'string'); |
|||
$this->addType('output', 'int'); |
|||
} |
|||
} |
|||
@ -0,0 +1,48 @@ |
|||
<?php |
|||
declare(strict_types=1); |
|||
/** |
|||
* @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> |
|||
* |
|||
* @license GNU AGPL version 3 or any later version |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU Affero General Public License as |
|||
* published by the Free Software Foundation, either version 3 of the |
|||
* License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU Affero General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU Affero General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace OCA\Spreed\Model; |
|||
|
|||
use OCP\AppFramework\Db\QBMapper; |
|||
use OCP\IDBConnection; |
|||
|
|||
class CommandMapper extends QBMapper { |
|||
|
|||
/** |
|||
* @param IDBConnection $db |
|||
*/ |
|||
public function __construct(IDBConnection $db) { |
|||
parent::__construct($db, 'talk_commands', Command::class); |
|||
} |
|||
|
|||
/** |
|||
* @return Command[] |
|||
*/ |
|||
public function findAll(): array { |
|||
$qb = $this->db->getQueryBuilder(); |
|||
$qb->select('*') |
|||
->from($this->getTableName()) |
|||
->orderBy('id', 'ASC'); |
|||
|
|||
return $this->findEntities($qb); |
|||
} |
|||
} |
|||
@ -0,0 +1,56 @@ |
|||
<?php |
|||
declare(strict_types=1); |
|||
/** |
|||
* @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> |
|||
* |
|||
* @license GNU AGPL version 3 or any later version |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU Affero General Public License as |
|||
* published by the Free Software Foundation, either version 3 of the |
|||
* License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU Affero General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU Affero General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace OCA\Spreed\Settings\Admin; |
|||
|
|||
|
|||
use OCP\AppFramework\Http\TemplateResponse; |
|||
use OCP\Settings\ISettings; |
|||
|
|||
class Commands implements ISettings { |
|||
|
|||
/** |
|||
* @return TemplateResponse |
|||
*/ |
|||
public function getForm(): TemplateResponse { |
|||
return new TemplateResponse('spreed', 'settings/admin/commands', [], ''); |
|||
} |
|||
|
|||
/** |
|||
* @return string the section ID, e.g. 'sharing' |
|||
*/ |
|||
public function getSection(): string { |
|||
return 'talk'; |
|||
} |
|||
|
|||
/** |
|||
* @return int whether the form should be rather on the top or bottom of |
|||
* the admin section. The forms are arranged in ascending order of the |
|||
* priority values. It is required to return a value between 0 and 100. |
|||
* |
|||
* E.g.: 70 |
|||
*/ |
|||
public function getPriority(): int { |
|||
return 85; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
<?php |
|||
/** @var array $_ */ |
|||
/** @var \OCP\IL10N $l */ |
|||
script('spreed', ['admin/commands']); |
|||
style('spreed', ['settings-admin']); |
|||
?>
|
|||
|
|||
<div class="videocalls section" id="chat_commands"> |
|||
<h2><?php p($l->t('Commands')) ?></h2>
|
|||
<p class="settings-hint"><?php p($l->t('Specify commands the users can use in chats')); ?></p>
|
|||
|
|||
<div class="commands"> |
|||
</div> |
|||
</div> |
|||
@ -0,0 +1,33 @@ |
|||
app_name=spreed |
|||
|
|||
project_dir=$(CURDIR)/../$(app_name) |
|||
build_dir=$(CURDIR)/build |
|||
source_dir=$(build_dir)/$(app_name) |
|||
sign_dir=$(build_dir)/sign |
|||
|
|||
all: dev-setup build-js-production |
|||
|
|||
dev-setup: clean clean-dev npm-init |
|||
|
|||
npm-init: |
|||
npm install |
|||
|
|||
npm-update: |
|||
npm update |
|||
|
|||
build-js: |
|||
npm run dev |
|||
|
|||
build-js-production: |
|||
npm run build |
|||
|
|||
watch-js: |
|||
npm run watch |
|||
|
|||
clean: |
|||
rm -f ../js/admin/commands.js |
|||
rm -f ../js/admin/commands.js.map |
|||
rm -rf $(build_dir) |
|||
|
|||
clean-dev: |
|||
rm -rf node_modules |
|||
5697
vue/package-lock.json
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,34 @@ |
|||
{ |
|||
"name": "spreed", |
|||
"description": "", |
|||
"version": "6.0.0", |
|||
"author": "Joas Schilling <coding@schilljs.com>", |
|||
"license": "agpl", |
|||
"private": true, |
|||
"scripts": { |
|||
"dev": "webpack --config webpack.dev.js", |
|||
"watch": "webpack --progress --watch --config webpack.dev.js", |
|||
"build": "webpack --progress --hide-modules --config webpack.prod.js" |
|||
}, |
|||
"dependencies": { |
|||
"nextcloud-axios": "^0.1.3", |
|||
"nextcloud-vue": "^0.6.0", |
|||
"vue": "^2.5.22" |
|||
}, |
|||
"browserslist": [ |
|||
"last 2 versions", |
|||
"ie >= 11" |
|||
], |
|||
"devDependencies": { |
|||
"@babel/core": "^7.2.2", |
|||
"@babel/preset-env": "^7.2.3", |
|||
"babel-loader": "^8.0.5", |
|||
"css-loader": "^2.1.0", |
|||
"file-loader": "^3.0.1", |
|||
"vue-loader": "^15.5.1", |
|||
"vue-template-compiler": "^2.5.22", |
|||
"webpack": "^4.28.4", |
|||
"webpack-cli": "^3.2.1", |
|||
"webpack-merge": "^4.2.1" |
|||
} |
|||
} |
|||
@ -0,0 +1,60 @@ |
|||
<!-- |
|||
- @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> |
|||
- |
|||
- @author Joas Schilling <coding@schilljs.com> |
|||
- |
|||
- @license GNU AGPL version 3 or any later version |
|||
- |
|||
- This program is free software: you can redistribute it and/or modify |
|||
- it under the terms of the GNU Affero General Public License as |
|||
- published by the Free Software Foundation, either version 3 of the |
|||
- License, or (at your option) any later version. |
|||
- |
|||
- This program is distributed in the hope that it will be useful, |
|||
- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
- GNU Affero General Public License for more details. |
|||
- |
|||
- You should have received a copy of the GNU Affero General Public License |
|||
- along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
- |
|||
--> |
|||
|
|||
<template> |
|||
<div id="chat_commands" class="section"> |
|||
<h2>{{ t('spreed', 'Commands') }}</h2> |
|||
|
|||
<div> |
|||
<command v-for="command in commands" v-bind="command" :key="command.id"></command> |
|||
</div> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import axios from 'nextcloud-axios'; |
|||
import Command from './components/Command'; |
|||
|
|||
export default { |
|||
name: 'app', |
|||
|
|||
data () { |
|||
return { |
|||
commands: {} |
|||
} |
|||
}, |
|||
|
|||
components: { |
|||
Command |
|||
}, |
|||
|
|||
mounted () { |
|||
axios |
|||
.get(OC.linkToOCS('apps/spreed/api/v1', 2) + 'command') |
|||
.then(response => { |
|||
if (response.data.ocs.data.length !== 0) { |
|||
this.commands = response.data.ocs.data; |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
</script> |
|||
@ -0,0 +1,34 @@ |
|||
/* |
|||
* @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com> |
|||
* |
|||
* @author Joas Schilling <coding@schilljs.com> |
|||
* |
|||
* @license GNU AGPL version 3 or any later version |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU Affero General Public License as |
|||
* published by the Free Software Foundation, either version 3 of the |
|||
* License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU Affero General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU Affero General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
* |
|||
*/ |
|||
|
|||
import Vue from 'vue'; |
|||
import Commands from './Commands'; |
|||
|
|||
Vue.prototype.t = t; |
|||
Vue.prototype.n = n; |
|||
Vue.prototype.OC = OC; |
|||
Vue.prototype.OCA = OCA; |
|||
|
|||
new Vue({ |
|||
el: '#chat_commands', |
|||
render: h => h(Commands) |
|||
}); |
|||
@ -0,0 +1,61 @@ |
|||
<!-- |
|||
- @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> |
|||
- |
|||
- @author Joas Schilling <coding@schilljs.com> |
|||
- |
|||
- @license GNU AGPL version 3 or any later version |
|||
- |
|||
- This program is free software: you can redistribute it and/or modify |
|||
- it under the terms of the GNU Affero General Public License as |
|||
- published by the Free Software Foundation, either version 3 of the |
|||
- License, or (at your option) any later version. |
|||
- |
|||
- This program is distributed in the hope that it will be useful, |
|||
- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
- GNU Affero General Public License for more details. |
|||
- |
|||
- You should have received a copy of the GNU Affero General Public License |
|||
- along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
- |
|||
--> |
|||
|
|||
<template> |
|||
<div> |
|||
<input type="text" class="name" placeholder="t('spreed', 'Poster name')" :value="name" :aria-label="t('spreed', 'Poster name')"> |
|||
<input type="text" class="pattern" placeholder="t('spreed', 'Command pattern (e.g. `^help` to match all messages starting with help)')" :value="pattern" :aria-label="t('spreed', 'Command pattern')"> |
|||
<input type="text" class="script" placeholder="/path/to/your/script" :value="script" :aria-label="t('spreed', 'Script to execute')"> |
|||
|
|||
<multiselect v-model="output" :options="outputOptions" :placeholder="t('spreed', 'Response visibility')" label="label" track-by="value" /> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import { Multiselect } from 'nextcloud-vue'; |
|||
|
|||
export default { |
|||
name: 'command', |
|||
|
|||
props: [ |
|||
'id', |
|||
'name', |
|||
'pattern', |
|||
'script', |
|||
'output' |
|||
], |
|||
|
|||
computed: { |
|||
outputOptions () { |
|||
return [ |
|||
{ label: t('spreed', 'None'), value: 0 }, |
|||
{ label: t('spreed', 'User'), value: 1 }, |
|||
{ label: t('spreed', 'Everyone'), value: 2 }, |
|||
]; |
|||
} |
|||
}, |
|||
|
|||
components: { |
|||
Multiselect |
|||
} |
|||
} |
|||
</script> |
|||
@ -0,0 +1,44 @@ |
|||
const path = require('path'); |
|||
const { VueLoaderPlugin } = require('vue-loader'); |
|||
|
|||
module.exports = { |
|||
entry: { |
|||
"admin/commands": path.join(__dirname, 'src', 'commands.js'), |
|||
}, |
|||
output: { |
|||
path: path.resolve(__dirname, '../js'), |
|||
publicPath: '/js/', |
|||
filename: '[name].js' |
|||
}, |
|||
module: { |
|||
rules: [ |
|||
{ |
|||
test: /\.css$/, |
|||
use: ['vue-style-loader', 'css-loader'] |
|||
}, |
|||
{ |
|||
test: /\.vue$/, |
|||
loader: 'vue-loader' |
|||
}, |
|||
{ |
|||
test: /\.js$/, |
|||
loader: 'babel-loader', |
|||
exclude: /node_modules/ |
|||
}, |
|||
{ |
|||
test: /\.(png|jpg|gif|svg)$/, |
|||
loader: 'file-loader', |
|||
options: { |
|||
name: '[name].[ext]?[hash]' |
|||
} |
|||
} |
|||
] |
|||
}, |
|||
plugins: [new VueLoaderPlugin()], |
|||
resolve: { |
|||
alias: { |
|||
vue$: 'vue/dist/vue.esm.js' |
|||
}, |
|||
extensions: ['*', '.js', '.vue', '.json'] |
|||
} |
|||
}; |
|||
@ -0,0 +1,12 @@ |
|||
const merge = require('webpack-merge'); |
|||
const common = require('./webpack.common.js'); |
|||
|
|||
module.exports = merge(common, { |
|||
mode: 'development', |
|||
devServer: { |
|||
historyApiFallback: true, |
|||
noInfo: true, |
|||
overlay: true |
|||
}, |
|||
devtool: '#cheap-source-map', |
|||
}); |
|||
@ -0,0 +1,7 @@ |
|||
const merge = require('webpack-merge') |
|||
const common = require('./webpack.common.js') |
|||
|
|||
module.exports = merge(common, { |
|||
mode: 'production', |
|||
devtool: '#source-map' |
|||
}); |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue