Commit 586ccd41 authored by Frank Bergmann's avatar Frank Bergmann

- New operations store status filtering is working

  for syncUpload.
  ToDos:
  - Add this to the other sync execution functions
  - Add a throtteling function in order to avoid
    more than N concurrent uploads at the same
    time.
  - Test the conflict cases
parent b5b55e60
......@@ -107,28 +107,40 @@ Ext.define('POSync.view.Viewport', {
id: 'tabpanel',
defaults: set_defaults(2, {layout: 'fit', defaults: set_defaults(3)}),
items: [
Ext.create('POSync.view.LoginPanel'), {
{
title: 'Login',
hidden: false,
itemId: 'login_tab',
items: [
Ext.create('POSync.view.LoginPanel')
]
}, {
title: 'Sync',
itemId: 'synctab',
hidden: false,
itemId: 'sync_tab',
items: {
xtype: 'grid',
itemId: 'operations',
store: Ext.create('POSync.store.Operations', {storeId: 'operations2'}),
emptyText: 'No operations available',
emptyText: 'No operations, or all operations already executed',
columns: [
// {text: 'Project', dataIndex: 'project_id', flex: 1},
{text: 'Operation', dataIndex: 'op', flex: 1},
{text: 'Operation', dataIndex: 'op', width: 50},
{text: 'Path', dataIndex: 'file_path', flex: 2},
{text: 'Name', dataIndex: 'file_name', flex: 3},
{text: 'Status', dataIndex: 'status', flex: 4},
{text: 'Comment', dataIndex: 'comment', flex: 5}
{text: 'Status', dataIndex: 'status', width: 50},
// {text: 'Comment', dataIndex: 'comment', flex: 5}
]
}
}, {
title: 'Projects',
icon: 'images/tray.png',
itemId: 'projects_tab',
hidden: false,
items: [
Ext.create('POSync.view.ProjectsPanel')
]
/*
items: {
xtype: 'grid',
itemId: 'projects',
......@@ -140,6 +152,7 @@ Ext.define('POSync.view.Viewport', {
{text: 'Name', dataIndex: 'project_name', flex: 7}
]
}
*/
},{
title: 'Local Files',
hidden: false,
......@@ -209,7 +222,7 @@ Ext.define('POSync.view.Viewport', {
html: [
']project-open[ Sync',
'version 1.0.0',
'Copyright © 2018 ]project-open[ Business Solutions, S.L.',
'Copyright © 2019 ]project-open[ Business Solutions, S.L.',
'Authors:',
'- <a href="mailto:gonzalo.perez@project-open.com">Gonzalo Pérez de Olaguer Córdoba</a>',
'- <a href="mailto:frank.bergmann@project-open.com">Frank Bergmann</a>',
......@@ -220,7 +233,7 @@ Ext.define('POSync.view.Viewport', {
'<tr><td>Chrome version</td><td>' + chrome_version + '</td></tr>' +
'<tr><td>Electron version</td><td>' + electron_version + '</td></tr>' +
'<tr><td>ExtJS version</td><td>' + extjs_version + '</td></tr>' +
'</table>'
'</table>'
].join('<br/>')
}
]
......@@ -269,20 +282,22 @@ var app = Ext.application({
models: ['Project', 'File', 'Operation'],
stores: ['Projects', 'Files', 'Operations'],
controllers: ['Gui', 'Connection'],
})
// Setup the tabs programmatically
launch: function() {
// Show panel tabs
var tabPanel = Ext.getCmp('tabpanel');
var syncTab = tabPanel.child('#synctab');
var projectsTab = tabPanel.child('#synctab');
var tabPanel = Ext.getCmp('tabpanel');
var loginTab = tabPanel.child('#login_tab');
var syncTab = tabPanel.child('#sync_tab');
var projectsTab = tabPanel.child('#projects_tab');
var localTab = tabPanel.child('#local_files');
var remoteTab = tabPanel.child('#remote_files');
syncTab.hide();
projectsTab.hide();
localTab.hide();
remoteTab.hide();
tabPanel.setActiveTab(syncTab);
loginTab.tab.show();
syncTab.tab.hide();
projectsTab.tab.hide();
localTab.tab.hide();
remoteTab.tab.hide();
tabPanel.setActiveTab(loginTab);
}
});
// vi: set ts=8 sts=4 sw=4 et :
......@@ -504,7 +504,7 @@ Ext.define('POSync.controller.Connection', {
file_name: localFile.get('name'),
local_file: localFile,
remote_file: remoteFile,
status: 'created'
status: 'created'
});
me.operationsStore.add(operation);
if (me.debug) console.log('Connection.sync local: mkdir: path='+purePathArray.join('/'));
......@@ -725,7 +725,7 @@ Ext.define('POSync.controller.Connection', {
local_file: localFile,
remote_file: remoteFile,
comment: 'Status: old='+oldStatus+', local='+localStatus+', remote='+remoteStatus,
status: 'created'
status: 'created'
});
me.operationsStore.add(operation);
},
......@@ -741,19 +741,21 @@ Ext.define('POSync.controller.Connection', {
var me = this;
if (me.debug) if (me.debug) console.log('Connection.sync: projectId='+projectId);
// Show panel tabs
// Show panel tabs
var tabPanel = Ext.getCmp('tabpanel');
var syncTab = tabPanel.child('#synctab');
var projectsTab = tabPanel.child('#synctab');
var localTab = tabPanel.child('#local_files');
var remoteTab = tabPanel.child('#remote_files');
syncTab.show();
projectsTab.show();
localTab.show();
remoteTab.show();
tabPanel.setActiveTab(syncTab);
var loginTab = tabPanel.child('#login_tab');
var syncTab = tabPanel.child('#sync_tab');
var projectsTab = tabPanel.child('#projects_tab');
var localTab = tabPanel.child('#local_files');
var remoteTab = tabPanel.child('#remote_files');
loginTab.tab.show();
syncTab.tab.show();
projectsTab.tab.hide();
localTab.tab.hide();
remoteTab.tab.hide();
tabPanel.setActiveTab(syncTab);
// Load the list of local files needed for sync
me.loadLocalDirectory(projectId);
......@@ -865,7 +867,7 @@ Ext.define('POSync.controller.Connection', {
var commitText = Ext.getCmp('textfield_commit');
if (commitText.getValue().length > 5) {
if (1 || commitText.getValue().length > 5) {
var loginButton = Ext.getCmp('button_login');
var syncButton = Ext.getCmp('button_sync');
var commitText = Ext.getCmp('textfield_commit');
......@@ -987,40 +989,32 @@ Ext.define('POSync.controller.Connection', {
// POST the file to the upload page
var xhr = new XMLHttpRequest();
xhr.operationId = op.get('id');
xhr.operationId = op.get('id');
var url = configData.url + '/intranet-rest-fs-openacs/upload';
var formData = new FormData();
formData.append('project_id', projectId);
formData.append('path', filePath);
formData.append('creation_date', localVersion.creation_date);
formData.append('modification_date', localVersion.modification_date);
formData.append('sha1', localVersion.sha1);
// formData.append('upload_file', fileContent);
formData.append('ignore_p', '1'); // Debugging: Don't really execute on server-side...
var blob = new Blob([fileContent], { type: mimeType});
formData.append('upload_file', blob, fileName);
// xhr.responseType = "arraybuffer";
// xhr.submittedData = fileContent;
op.set('status', 'running');
xhr.open("POST", url, true);
// xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
// xhr.setRequestHeader('X-Requested-With','XMLHttpRequest');
xhr.onload = function() {
// Asynchronously saving files after they have been downloaded
var opId = this.operationId;
var op = me.operationsStore.getById(opId);
alert(this.responseText + ', opId='+opId);
var opId = this.operationId;
var op = me.operationsStore.getById(opId);
if (this.status === 200) {
if (me.debug) console.log('Connection.syncUpload: successful upload');
op.set('status', 'done');
op.set('status', 'done');
} else {
if (me.debug) console.log('Connection.syncUpload: upload status='+this.status);
op.set('status', 'error');
op.set('err_msg', this.responseText);
op.set('status', 'error');
op.set('err_msg', this.responseText);
}
me.operationsStore.filterBy(me.operationsStore.myFilter);
};
xhr.send(formData);
},
......
......@@ -2,11 +2,28 @@
* DataStore for Sync operations
*/
/*
var operationsStoreStatusFilter = new Ext.util.Filter({
filterFn: function(op) {
var status = op.get('status');
if (!status) return true;
return (status === 'created' || status === 'error');
}
});
*/
Ext.define('POSync.store.Operations', {
storeId: 'operations',
extend: 'Ext.data.Store',
requires: 'POSync.model.Operation',
model: 'POSync.model.Operation'
model: 'POSync.model.Operation',
myFilter: (function(item) {
var status = item.get('status');
if (!status) return true;
return (status === 'created' || status === 'error' || status === 'running');
})
});
......@@ -22,11 +22,9 @@ Ext.define('POSync.store.Projects', {
url: '/intranet-rest/im_project',
appendId: true,
timeout: 300000,
extraParams: {
extraParams: { // This should be overwrittten during load.
format: 'json',
query: 'parent_id is NULL' // Select only top-level projects
// deref_p: '1' // We don't need company_name etc.
// This should be overwrittten during load.
},
reader: {
type: 'json', // Tell the Proxy Reader to parse JSON
......
......@@ -4,11 +4,10 @@
Ext.define('POSync.view.LoginPanel', {
alias: 'loginPanel',
extend: 'Ext.panel.Panel',
title: 'Configuration',
items: {
xtype: 'form',
itemId: 'config',
bodyPadding: 10,
bodyPadding: 0,
defaults: {
anchor: '100%',
xtype: 'textfield',
......
......@@ -3,21 +3,20 @@
* Currently not used, because moving it creates an error
*/
Ext.define('POSync.view.ProjectsPanel', {
alias: 'projectsPanel',
extend: 'Ext.panel.Panel',
title: 'Projects',
layout: 'fit',
alias: 'projectsPanel',
extend: 'Ext.panel.Panel',
id: 'projects_panel',
itemId: 'projects_panel',
items: {
xtype: 'grid',
itemId: 'projects',
store: Ext.StoreManager.get('Projects'),
// store: 'Projects',
/* FIXME: emptyText initially not shown */
emptyText: 'No projects available',
columns: [
{text: 'Id', dataIndex: 'project_id', align: 'right', flex: 1},
{text: 'Number', dataIndex: 'project_nr', flex: 2},
{text: 'Name', dataIndex: 'project_name', flex: 7}
]
xtype: 'grid',
itemId: 'projects',
// store: Ext.StoreManager.get('Projects'),
store: Ext.create('POSync.store.Projects'),
emptyText: 'No projects available',
columns: [
{text: 'Id', dataIndex: 'project_id', align: 'right', flex: 1},
{text: 'Number', dataIndex: 'project_nr', flex: 2},
{text: 'Name', dataIndex: 'project_name', flex: 7}
]
}
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment