mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 16:35:45 +01:00
split sonia.plugin.js into smaller pieces
This commit is contained in:
@@ -109,7 +109,12 @@
|
|||||||
<script type="text/javascript" src="resources/js/action/sonia.action.js"></script>
|
<script type="text/javascript" src="resources/js/action/sonia.action.js"></script>
|
||||||
<script type="text/javascript" src="resources/js/action/sonia.action.changepasswordwindow.js"></script>
|
<script type="text/javascript" src="resources/js/action/sonia.action.changepasswordwindow.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript" src="resources/js/sonia.plugin.js"></script>
|
<!-- sonia.plugin -->
|
||||||
|
<script type="text/javascript" src="resources/js/plugin/sonia.plugin.js"></script>
|
||||||
|
<script type="text/javascript" src="resources/js/plugin/sonia.plugin.center.js"></script>
|
||||||
|
<script type="text/javascript" src="resources/js/plugin/sonia.plugin.store.js"></script>
|
||||||
|
<script type="text/javascript" src="resources/js/plugin/sonia.plugin.grid.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript" src="resources/js/sonia.scm.js"></script>
|
<script type="text/javascript" src="resources/js/sonia.scm.js"></script>
|
||||||
<!--/compress-->
|
<!--/compress-->
|
||||||
<script type="text/javascript" src="plugins/sonia.plugin.js"></script>
|
<script type="text/javascript" src="plugins/sonia.plugin.js"></script>
|
||||||
|
|||||||
@@ -29,8 +29,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// register namespace
|
|
||||||
Ext.ns("Sonia.plugin");
|
|
||||||
|
|
||||||
Sonia.plugin.Center = Ext.extend(Ext.util.Observable, {
|
Sonia.plugin.Center = Ext.extend(Ext.util.Observable, {
|
||||||
|
|
||||||
@@ -181,95 +179,3 @@ Sonia.plugin.Center = Ext.extend(Ext.util.Observable, {
|
|||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// the plugin center
|
|
||||||
Sonia.plugin.CenterInstance = new Sonia.plugin.Center();
|
|
||||||
|
|
||||||
// plguin store
|
|
||||||
|
|
||||||
Sonia.plugin.Store = Ext.extend(Sonia.rest.JsonStore, {
|
|
||||||
|
|
||||||
constructor: function(config) {
|
|
||||||
var baseConfig = {
|
|
||||||
fields: [ 'name', 'author', 'description', 'url', 'version', 'state', 'groupId', 'artifactId' ],
|
|
||||||
sortInfo: {
|
|
||||||
field: 'name'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Sonia.plugin.Store.superclass.constructor.call(this, Ext.apply(baseConfig, config));
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
// plugin grid
|
|
||||||
|
|
||||||
Sonia.plugin.Grid = Ext.extend(Sonia.rest.Grid, {
|
|
||||||
|
|
||||||
colNameText: 'Name',
|
|
||||||
colAuthorText: 'Author',
|
|
||||||
colDescriptionText: 'Description',
|
|
||||||
colVersionText: 'Version',
|
|
||||||
colActionText: 'Action',
|
|
||||||
colUrlText: 'Url',
|
|
||||||
emptyText: 'No plugins avaiable',
|
|
||||||
|
|
||||||
actionLinkTemplate: '<a style="cursor: pointer;" onclick="Sonia.plugin.CenterInstance.{1}(\'{2}\')">{0}</a>',
|
|
||||||
|
|
||||||
initComponent: function(){
|
|
||||||
|
|
||||||
var pluginColModel = new Ext.grid.ColumnModel({
|
|
||||||
defaults: {
|
|
||||||
sortable: true,
|
|
||||||
scope: this,
|
|
||||||
width: 125
|
|
||||||
},
|
|
||||||
columns: [
|
|
||||||
{id: 'name', header: this.colNameText, dataIndex: 'name'},
|
|
||||||
{id: 'author', header: this.colAuthorText, dataIndex: 'author'},
|
|
||||||
{id: 'description', header: this.colDescriptionText, dataIndex: 'description'},
|
|
||||||
{id: 'version', header: this.colVersionText, dataIndex: 'version'},
|
|
||||||
{id: 'action', header: this.colActionText, renderer: this.renderActionColumn},
|
|
||||||
{id: 'Url', header: this.colUrlText, dataIndex: 'url', renderer: this.renderUrl, width: 150}
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
var config = {
|
|
||||||
autoExpandColumn: 'description',
|
|
||||||
store: new Sonia.plugin.Store({
|
|
||||||
url: restUrl + 'plugins/overview.json'
|
|
||||||
}),
|
|
||||||
colModel: pluginColModel,
|
|
||||||
emptyText: this.emptyText
|
|
||||||
};
|
|
||||||
|
|
||||||
Sonia.plugin.CenterInstance.addListener('changed', function(){
|
|
||||||
if (debug){
|
|
||||||
console.debug( 'receive change event, reload plugin store' );
|
|
||||||
}
|
|
||||||
this.getStore().reload();
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
|
||||||
Sonia.plugin.Grid.superclass.initComponent.apply(this, arguments);
|
|
||||||
},
|
|
||||||
|
|
||||||
renderActionColumn: function(val, meta, record){
|
|
||||||
var out = "";
|
|
||||||
var data = record.data;
|
|
||||||
var id = Sonia.plugin.CenterInstance.getPluginId(data);
|
|
||||||
if ( data.state == 'AVAILABLE' ){
|
|
||||||
out = String.format(this.actionLinkTemplate, 'Install', 'install', id);
|
|
||||||
} else if ( data.state == 'INSTALLED' ){
|
|
||||||
out = String.format(this.actionLinkTemplate, 'Uninstall', 'uninstall', id);
|
|
||||||
} else if ( data.state == 'UPDATE_AVAILABLE' ){
|
|
||||||
out = String.format(this.actionLinkTemplate, 'Update', 'update', id);
|
|
||||||
out += ', '
|
|
||||||
out += String.format(this.actionLinkTemplate, 'Uninstall', 'uninstall', id);
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
// register xtype
|
|
||||||
Ext.reg('pluginGrid', Sonia.plugin.Grid);
|
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
/* *
|
||||||
|
* Copyright (c) 2010, Sebastian Sdorra
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* http://bitbucket.org/sdorra/scm-manager
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// the plugin center
|
||||||
|
Sonia.plugin.CenterInstance = new Sonia.plugin.Center();
|
||||||
|
|
||||||
|
|
||||||
|
// plugin grid
|
||||||
|
Sonia.plugin.Grid = Ext.extend(Sonia.rest.Grid, {
|
||||||
|
|
||||||
|
colNameText: 'Name',
|
||||||
|
colAuthorText: 'Author',
|
||||||
|
colDescriptionText: 'Description',
|
||||||
|
colVersionText: 'Version',
|
||||||
|
colActionText: 'Action',
|
||||||
|
colUrlText: 'Url',
|
||||||
|
emptyText: 'No plugins avaiable',
|
||||||
|
|
||||||
|
actionLinkTemplate: '<a style="cursor: pointer;" onclick="Sonia.plugin.CenterInstance.{1}(\'{2}\')">{0}</a>',
|
||||||
|
|
||||||
|
initComponent: function(){
|
||||||
|
|
||||||
|
var pluginColModel = new Ext.grid.ColumnModel({
|
||||||
|
defaults: {
|
||||||
|
sortable: true,
|
||||||
|
scope: this,
|
||||||
|
width: 125
|
||||||
|
},
|
||||||
|
columns: [
|
||||||
|
{id: 'name', header: this.colNameText, dataIndex: 'name'},
|
||||||
|
{id: 'author', header: this.colAuthorText, dataIndex: 'author'},
|
||||||
|
{id: 'description', header: this.colDescriptionText, dataIndex: 'description'},
|
||||||
|
{id: 'version', header: this.colVersionText, dataIndex: 'version'},
|
||||||
|
{id: 'action', header: this.colActionText, renderer: this.renderActionColumn},
|
||||||
|
{id: 'Url', header: this.colUrlText, dataIndex: 'url', renderer: this.renderUrl, width: 150}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
autoExpandColumn: 'description',
|
||||||
|
store: new Sonia.plugin.Store({
|
||||||
|
url: restUrl + 'plugins/overview.json'
|
||||||
|
}),
|
||||||
|
colModel: pluginColModel,
|
||||||
|
emptyText: this.emptyText
|
||||||
|
};
|
||||||
|
|
||||||
|
Sonia.plugin.CenterInstance.addListener('changed', function(){
|
||||||
|
if (debug){
|
||||||
|
console.debug( 'receive change event, reload plugin store' );
|
||||||
|
}
|
||||||
|
this.getStore().reload();
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
||||||
|
Sonia.plugin.Grid.superclass.initComponent.apply(this, arguments);
|
||||||
|
},
|
||||||
|
|
||||||
|
renderActionColumn: function(val, meta, record){
|
||||||
|
var out = "";
|
||||||
|
var data = record.data;
|
||||||
|
var id = Sonia.plugin.CenterInstance.getPluginId(data);
|
||||||
|
if ( data.state == 'AVAILABLE' ){
|
||||||
|
out = String.format(this.actionLinkTemplate, 'Install', 'install', id);
|
||||||
|
} else if ( data.state == 'INSTALLED' ){
|
||||||
|
out = String.format(this.actionLinkTemplate, 'Uninstall', 'uninstall', id);
|
||||||
|
} else if ( data.state == 'UPDATE_AVAILABLE' ){
|
||||||
|
out = String.format(this.actionLinkTemplate, 'Update', 'update', id);
|
||||||
|
out += ', '
|
||||||
|
out += String.format(this.actionLinkTemplate, 'Uninstall', 'uninstall', id);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// register xtype
|
||||||
|
Ext.reg('pluginGrid', Sonia.plugin.Grid);
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/* *
|
||||||
|
* Copyright (c) 2010, Sebastian Sdorra
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* http://bitbucket.org/sdorra/scm-manager
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
// register namespace
|
||||||
|
Ext.ns("Sonia.plugin");
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/* *
|
||||||
|
* Copyright (c) 2010, Sebastian Sdorra
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* http://bitbucket.org/sdorra/scm-manager
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
Sonia.plugin.Store = Ext.extend(Sonia.rest.JsonStore, {
|
||||||
|
|
||||||
|
constructor: function(config) {
|
||||||
|
var baseConfig = {
|
||||||
|
fields: [ 'name', 'author', 'description', 'url', 'version', 'state', 'groupId', 'artifactId' ],
|
||||||
|
sortInfo: {
|
||||||
|
field: 'name'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Sonia.plugin.Store.superclass.constructor.call(this, Ext.apply(baseConfig, config));
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user